Verlet Algorithm 3. Relevant Methods in Java Code
//(anonymous) class for incrementing the sum of the forces on each atom
forceSum = new AtomPair.Action() {
private Space.Vector f = simulation().space.makeVector();
public void action(AtomPair pair) {
PotentialSoft potential = (PotentialSoft)simulation().getPotential(pair) //identify pot’l
f.E(potential.force(pair)); //compute force of atom1 on atom2
((Agent)pair.atom1().ia).force.PE(f); //increment atom1 force
((Agent)pair.atom2().ia).force.ME(f); //increment atom2 force
//Agent class for IntegratorVerlet; stores useful quantities in each Atom
public final static class Agent implements Integrator.Agent {
public Space.Vector force; //used to accumulate the force on the atom
public Space.Vector rLast; //holds the position of the atom at the last step
public Agent(Atom a) { //constructor
force = atom.parentMolecule().parentPhase().parentSimulation.space.makeVector();
rLast = atom.parentMolecule().parentPhase().parentSimulation.space.makeVector();
public class IntegratorVerlet extends Integrator