@@ -0,0 +1,2453 @@
+package etomica.potential;%0A%0Aimport etomica.atom.IAtom;%0Aimport etomica.atom.IAtomList;%0Aimport etomica.box.Box;%0Aimport etomica.simulation.Simulation;%0Aimport etomica.space.Vector;%0Aimport etomica.space3d.Space3D;%0Aimport etomica.space3d.Vector3D;%0Aimport etomica.species.SpeciesAlkane;%0Aimport etomica.species.SpeciesGeneral;%0Aimport etomica.units.Kelvin;%0Aimport org.junit.jupiter.api.BeforeEach;%0Aimport org.junit.jupiter.api.Test;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport static org.junit.jupiter.api.Assertions.assertEquals;%0A%0Aclass P3BondAngleTest %7B%0A%0A    Simulation sim;%0A    PotentialMasterBonding pmBonding;%0A    int nSpheres;%0A%0A    @BeforeEach%0A    void setUp() %7B%0A        Space3D space = Space3D.getInstance();%0A        sim = new Simulation(space);%0A        nSpheres = 6;%0A        SpeciesGeneral alkane = SpeciesAlkane.create(nSpheres);%0A        sim.addSpecies(alkane);%0A        Box box = sim.makeBox();%0A        box.setNMolecules(alkane, 1);%0A        IAtomList atoms = box.getMoleculeList().get(0).getChildList();%0A        pmBonding = new PotentialMasterBonding(sim, box);%0A        P3BondAngle p3 = new P3BondAngle(space);%0A        p3.setAngle(Math.PI * 114.0 / 180.0);%0A        p3.setEpsilon(Kelvin.UNIT.toSim(62500));%0A        List%3Cint%5B%5D%3E triplets = new ArrayList%3C%3E();%0A        for (int i = 0; i %3C nSpheres - 2; i++) %7B%0A            triplets.add(new int%5B%5D%7Bi, i + 1, i + 2%7D);%0A        %7D%0A        pmBonding.setBondingPairTriplet(alkane, p3, triplets);%0A        pmBonding.init();%0A    %7D%0A%0A    @Test%0A    public void testForce() %7B%0A        double u = pmBonding.computeAll(true);%0A        Vector%5B%5D f = pmBonding.forces;%0A        IAtomList atoms = sim.box().getMoleculeList().get(0).getChildList();%0A        for (int j = 0; j %3C 10; j++) %7B%0A            for (int i = 0; i %3C nSpheres; i++) %7B%0A                IAtom a = atoms.get(i);%0A                Vector3D dr = new Vector3D();%0A                dr.setRandomSphere(sim.getRandom());%0A                dr.TE(1e-4);%0A                Vector fi = new Vector3D();%0A                fi.E(f%5Bi%5D);%0A%0A                a.getPosition().PE(dr);%0A                double newU = pmBonding.computeAll(true);%0A                fi.PE(f%5Bi%5D);%0A                fi.TE(0.5);%0A                double duExpected = -fi.dot(dr);%0A//                System.out.println(i+%22 %22+dr+%22 %22+duExpected+%22 %22+(newU-u));%0A                // typically less than 1e-8%0A                assertEquals(duExpected, newU - u, 1e-7);%0A%0A                u = newU;%0A            %7D%0A        %7D%0A    %7D%0A%7D

add a bond angle test