<commit_before>package etomica.modules.sam;

import etomica.api.IAtomList;
import etomica.api.IPotentialAtomic;
import etomica.api.IVector;
import etomica.integrator.IntegratorBox;
import etomica.potential.PotentialCalculationForceSum;
import etomica.potential.PotentialSoft;

public class PotentialCalculationForceSumWall extends
        PotentialCalculationForceSum {

    public PotentialCalculationForceSumWall(P1WCAWall wallPotential) {
        this.wallPotential = wallPotential;
    }
    
    public P1WCAWall getWallPotential() {
        return wallPotential;
    }

    public void reset() {
        super.reset();
        wallForceSum = 0;
    }
    
    public double getWallForce() {
        return wallForceSum;
    }
    
    public void doCalculation(IAtomList atoms, IPotentialAtomic potential) {
        PotentialSoft potentialSoft = (PotentialSoft)potential;
        int nBody = potential.nBody();
        IVector[] f = potentialSoft.gradient(atoms);
        switch(nBody) {
            case 1:
                if (f[0].squared() > 2.5e9) {
                    double scale = 50000/Math.sqrt(f[0].squared());
                    ((IntegratorBox.Forcible)integratorAgentManager.getAgent(atoms.getAtom(0))).force().PEa1Tv1(-scale, f[0]);
                    if (potential == wallPotential) {
                        wallForceSum += scale*f[0].x(wallPotential.getWallDim());
                    }
                }
                else {
                    ((IntegratorBox.Forcible)integratorAgentManager.getAgent(atoms.getAtom(0))).force().ME(f[0]);
                    if (potential == wallPotential) {
                        wallForceSum += f[0].x(wallPotential.getWallDim());
                    }
                }
                break;
            case 2:
                if (f[0].squared() > 2.5e9) {
                    double scale = 50000/Math.sqrt(f[0].squared());
                    ((IntegratorBox.Forcible)integratorAgentManager.getAgent(atoms.getAtom(0))).force().PEa1Tv1(-scale, f[0]);
                    ((IntegratorBox.Forcible)integratorAgentManager.getAgent(atoms.getAtom(1))).force().PEa1Tv1(-scale, f[1]);
                }
                else {
                    ((IntegratorBox.Forcible)integratorAgentManager.getAgent(atoms.getAtom(0))).force().ME(f[0]);
                    ((IntegratorBox.Forcible)integratorAgentManager.getAgent(atoms.getAtom(1))).force().ME(f[1]);
                }
                break;
            default:
                throw new RuntimeException("we don't do N-body");
        }
    }

    protected final P1WCAWall wallPotential;
    protected double wallForceSum;
}<commit_msg>handle bond potentials<commit_after>package etomica.modules.sam;

import etomica.api.IAtomList;
import etomica.api.IPotentialAtomic;
import etomica.api.IVector;
import etomica.integrator.IntegratorBox;
import etomica.potential.PotentialCalculationForceSum;
import etomica.potential.PotentialSoft;

public class PotentialCalculationForceSumWall extends
        PotentialCalculationForceSum {

    public PotentialCalculationForceSumWall(P1WCAWall wallPotential) {
        this.wallPotential = wallPotential;
    }
    
    public P1WCAWall getWallPotential() {
        return wallPotential;
    }

    public void reset() {
        super.reset();
        wallForceSum = 0;
    }
    
    public double getWallForce() {
        return wallForceSum;
    }
    
    public void doCalculation(IAtomList atoms, IPotentialAtomic potential) {
        PotentialSoft potentialSoft = (PotentialSoft)potential;
        int nBody = potential.nBody();
        IVector[] f = potentialSoft.gradient(atoms);
        switch(nBody) {
            case 1:
                if (f[0].squared() > 2.5e9) {
                    double scale = 50000/Math.sqrt(f[0].squared());
                    ((IntegratorBox.Forcible)integratorAgentManager.getAgent(atoms.getAtom(0))).force().PEa1Tv1(-scale, f[0]);
                    if (potential == wallPotential) {
                        wallForceSum += scale*f[0].x(wallPotential.getWallDim());
                    }
                }
                else {
                    ((IntegratorBox.Forcible)integratorAgentManager.getAgent(atoms.getAtom(0))).force().ME(f[0]);
                    if (potential == wallPotential) {
                        wallForceSum += f[0].x(wallPotential.getWallDim());
                    }
                }
                break;
            case 2:
                if (f[0].squared() > 2.5e9) {
                    double scale = 50000/Math.sqrt(f[0].squared());
                    ((IntegratorBox.Forcible)integratorAgentManager.getAgent(atoms.getAtom(0))).force().PEa1Tv1(-scale, f[0]);
                    ((IntegratorBox.Forcible)integratorAgentManager.getAgent(atoms.getAtom(1))).force().PEa1Tv1(-scale, f[1]);
                }
                else {
                    ((IntegratorBox.Forcible)integratorAgentManager.getAgent(atoms.getAtom(0))).force().ME(f[0]);
                    ((IntegratorBox.Forcible)integratorAgentManager.getAgent(atoms.getAtom(1))).force().ME(f[1]);
                }
                break;
            default:
                // we hit this for bonding potentials
                for (int i=0; i<atoms.getAtomCount(); i++) {
                    ((IntegratorBox.Forcible)integratorAgentManager.getAgent(atoms.getAtom(i))).force().ME(f[i]);
                }
        }
    }

    protected final P1WCAWall wallPotential;
    protected double wallForceSum;
}
{'fraction_non_alphanumeric': 0.11450381679389313, 'fraction_numerical': 0.016902944383860415, 'mean_word_length': 2.0420121614151463, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6891190', 'n_tokens_mistral': 1748, 'n_tokens_neox': 1563, 'n_words': 226}