Commit 9e800ced authored by Jason Swails's avatar Jason Swails
Browse files

Add units to the returned bond cubic and quartic terms and add tests for

AmoebaBondForce.
parent d04154b4
...@@ -224,8 +224,8 @@ UNITS = { ...@@ -224,8 +224,8 @@ UNITS = {
("AmoebaAngleForce", "getAmoebaGlobalAngleSextic") : ( None,()), ("AmoebaAngleForce", "getAmoebaGlobalAngleSextic") : ( None,()),
("AmoebaAngleForce", "getAngleParameters") : ( None, (None, None, None, 'unit.radian', 'unit.kilojoule_per_mole/(unit.radian*unit.radian)')), ("AmoebaAngleForce", "getAngleParameters") : ( None, (None, None, None, 'unit.radian', 'unit.kilojoule_per_mole/(unit.radian*unit.radian)')),
("AmoebaBondForce", "getAmoebaGlobalBondCubic") : ( None,()), ("AmoebaBondForce", "getAmoebaGlobalBondCubic") : ( '1/unit.nanometer',()),
("AmoebaBondForce", "getAmoebaGlobalBondQuartic") : ( None,()), ("AmoebaBondForce", "getAmoebaGlobalBondQuartic") : ( '1/unit.nanometer**2',()),
("AmoebaBondForce", "getBondParameters") : ( None, (None, None, 'unit.nanometer', 'unit.kilojoule_per_mole/(unit.nanometer*unit.nanometer)')), ("AmoebaBondForce", "getBondParameters") : ( None, (None, None, 'unit.nanometer', 'unit.kilojoule_per_mole/(unit.nanometer*unit.nanometer)')),
("AmoebaInPlaneAngleForce", "getAmoebaGlobalInPlaneAngleCubic") : ( None,()), ("AmoebaInPlaneAngleForce", "getAmoebaGlobalInPlaneAngleCubic") : ( None,()),
......
...@@ -517,5 +517,36 @@ class TestAPIUnits(unittest.TestCase): ...@@ -517,5 +517,36 @@ class TestAPIUnits(unittest.TestCase):
self.assertEqual(force.getParticleParameters(1)[0][0], 20) self.assertEqual(force.getParticleParameters(1)[0][0], 20)
self.assertEqual(force.getParticleParameters(2)[0][0], 30*4.184) self.assertEqual(force.getParticleParameters(2)[0][0], 30*4.184)
def testAmoebaBondForce(self):
""" Tests the AmoebaBondForce API features """
force1 = AmoebaBondForce()
force2 = AmoebaBondForce()
force1.setAmoebaGlobalBondCubic(1.5)
force2.setAmoebaGlobalBondCubic(1.5/angstrom)
force1.setAmoebaGlobalBondQuartic(1.5)
force2.setAmoebaGlobalBondQuartic(1.5/angstrom**2)
self.assertEqual(force1.getAmoebaGlobalBondCubic(), 1.5/nanometer)
self.assertEqual(force2.getAmoebaGlobalBondCubic(), 1.5/angstrom)
self.assertEqual(force1.getAmoebaGlobalBondQuartic(), 1.5/nanometer**2)
self.assertAlmostEqualUnit(force2.getAmoebaGlobalBondQuartic(), 1.5/angstrom**2)
force1.addBond(0, 1, 0.15, 10.0)
force1.addBond(1, 2, 1.5*angstroms, 10.0*kilocalories_per_mole/angstroms**2)
self.assertEqual(force1.getNumBonds(), 2)
self.assertEqual(force2.getNumBonds(), 0)
i, j, req, k = force1.getBondParameters(0)
self.assertEqual(req, 0.15*nanometers)
self.assertEqual(k, 10.0*kilojoules_per_mole/nanometers**2)
i, j, req, k = force1.getBondParameters(1)
self.assertAlmostEqualUnit(req, 1.5*angstroms)
self.assertAlmostEqualUnit(k, 10.0*kilocalories_per_mole/angstroms**2)
def testAmoebaAngleForce(self):
""" Tests the AmoebaAngleForce API features """
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment