Unverified Commit 4c6cf680 authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Added name property to Forces (#3049)

parent 7c2e5991
...@@ -43,6 +43,7 @@ void testSerialization() { ...@@ -43,6 +43,7 @@ void testSerialization() {
MonteCarloBarostat force(25.5, 250.0, 14); MonteCarloBarostat force(25.5, 250.0, 14);
force.setForceGroup(3); force.setForceGroup(3);
force.setName("custom name");
force.setRandomNumberSeed(3); force.setRandomNumberSeed(3);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -55,6 +56,7 @@ void testSerialization() { ...@@ -55,6 +56,7 @@ void testSerialization() {
MonteCarloBarostat& force2 = *copy; MonteCarloBarostat& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getDefaultPressure(), force2.getDefaultPressure()); ASSERT_EQUAL(force.getDefaultPressure(), force2.getDefaultPressure());
ASSERT_EQUAL(force.getDefaultTemperature(), force2.getDefaultTemperature()); ASSERT_EQUAL(force.getDefaultTemperature(), force2.getDefaultTemperature());
ASSERT_EQUAL(force.getFrequency(), force2.getFrequency()); ASSERT_EQUAL(force.getFrequency(), force2.getFrequency());
......
...@@ -43,6 +43,7 @@ void testSerialization() { ...@@ -43,6 +43,7 @@ void testSerialization() {
MonteCarloMembraneBarostat force(25.5, 11.2, 250.0, MonteCarloMembraneBarostat::XYAnisotropic, MonteCarloMembraneBarostat::ZFixed, 14); MonteCarloMembraneBarostat force(25.5, 11.2, 250.0, MonteCarloMembraneBarostat::XYAnisotropic, MonteCarloMembraneBarostat::ZFixed, 14);
force.setForceGroup(3); force.setForceGroup(3);
force.setName("custom name");
force.setRandomNumberSeed(3); force.setRandomNumberSeed(3);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -55,6 +56,7 @@ void testSerialization() { ...@@ -55,6 +56,7 @@ void testSerialization() {
MonteCarloMembraneBarostat& force2 = *copy; MonteCarloMembraneBarostat& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getDefaultPressure(), force2.getDefaultPressure()); ASSERT_EQUAL(force.getDefaultPressure(), force2.getDefaultPressure());
ASSERT_EQUAL(force.getDefaultSurfaceTension(), force2.getDefaultSurfaceTension()); ASSERT_EQUAL(force.getDefaultSurfaceTension(), force2.getDefaultSurfaceTension());
ASSERT_EQUAL(force.getDefaultTemperature(), force2.getDefaultTemperature()); ASSERT_EQUAL(force.getDefaultTemperature(), force2.getDefaultTemperature());
......
...@@ -43,6 +43,7 @@ void testSerialization() { ...@@ -43,6 +43,7 @@ void testSerialization() {
NonbondedForce force; NonbondedForce force;
force.setForceGroup(3); force.setForceGroup(3);
force.setName("custom name");
force.setNonbondedMethod(NonbondedForce::CutoffPeriodic); force.setNonbondedMethod(NonbondedForce::CutoffPeriodic);
force.setSwitchingDistance(1.5); force.setSwitchingDistance(1.5);
force.setUseSwitchingFunction(true); force.setUseSwitchingFunction(true);
...@@ -77,6 +78,7 @@ void testSerialization() { ...@@ -77,6 +78,7 @@ void testSerialization() {
NonbondedForce& force2 = *copy; NonbondedForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getNonbondedMethod(), force2.getNonbondedMethod()); ASSERT_EQUAL(force.getNonbondedMethod(), force2.getNonbondedMethod());
ASSERT_EQUAL(force.getSwitchingDistance(), force2.getSwitchingDistance()); ASSERT_EQUAL(force.getSwitchingDistance(), force2.getSwitchingDistance());
ASSERT_EQUAL(force.getUseSwitchingFunction(), force2.getUseSwitchingFunction()); ASSERT_EQUAL(force.getUseSwitchingFunction(), force2.getUseSwitchingFunction());
......
...@@ -43,6 +43,7 @@ void testSerialization() { ...@@ -43,6 +43,7 @@ void testSerialization() {
PeriodicTorsionForce force; PeriodicTorsionForce force;
force.setForceGroup(3); force.setForceGroup(3);
force.setName("custom name");
force.addTorsion(0, 1, 2, 3, 2, 1.0, 2.0); force.addTorsion(0, 1, 2, 3, 2, 1.0, 2.0);
force.addTorsion(0, 2, 3, 4, 2, 2.0, 2.1); force.addTorsion(0, 2, 3, 4, 2, 2.0, 2.1);
force.addTorsion(2, 3, 4, 7, 1, 3.0, 2.2); force.addTorsion(2, 3, 4, 7, 1, 3.0, 2.2);
...@@ -59,6 +60,7 @@ void testSerialization() { ...@@ -59,6 +60,7 @@ void testSerialization() {
PeriodicTorsionForce& force2 = *copy; PeriodicTorsionForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions()); ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force.getNumTorsions(), force2.getNumTorsions()); ASSERT_EQUAL(force.getNumTorsions(), force2.getNumTorsions());
for (int i = 0; i < force.getNumTorsions(); i++) { for (int i = 0; i < force.getNumTorsions(); i++) {
......
...@@ -43,6 +43,7 @@ void testSerialization() { ...@@ -43,6 +43,7 @@ void testSerialization() {
RBTorsionForce force; RBTorsionForce force;
force.setForceGroup(3); force.setForceGroup(3);
force.setName("custom name");
force.addTorsion(0, 1, 2, 3, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6); force.addTorsion(0, 1, 2, 3, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6);
force.addTorsion(0, 2, 3, 4, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7); force.addTorsion(0, 2, 3, 4, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7);
force.addTorsion(2, 3, 4, 7, -1, -2, -3, 1.1, 2.2, 3.3); force.addTorsion(2, 3, 4, 7, -1, -2, -3, 1.1, 2.2, 3.3);
...@@ -58,6 +59,7 @@ void testSerialization() { ...@@ -58,6 +59,7 @@ void testSerialization() {
RBTorsionForce& force2 = *copy; RBTorsionForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions()); ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force.getNumTorsions(), force2.getNumTorsions()); ASSERT_EQUAL(force.getNumTorsions(), force2.getNumTorsions());
for (int i = 0; i < force.getNumTorsions(); i++) { for (int i = 0; i < force.getNumTorsions(); i++) {
......
...@@ -49,6 +49,7 @@ void testSerialization() { ...@@ -49,6 +49,7 @@ void testSerialization() {
particles.push_back(i*i); particles.push_back(i*i);
RMSDForce force(refPos, particles); RMSDForce force(refPos, particles);
force.setForceGroup(3); force.setForceGroup(3);
force.setName("custom name");
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -60,6 +61,7 @@ void testSerialization() { ...@@ -60,6 +61,7 @@ void testSerialization() {
RMSDForce& force2 = *copy; RMSDForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getReferencePositions().size(), force2.getReferencePositions().size()); ASSERT_EQUAL(force.getReferencePositions().size(), force2.getReferencePositions().size());
for (int i = 0; i < force.getReferencePositions().size(); i++) for (int i = 0; i < force.getReferencePositions().size(); i++)
ASSERT_EQUAL_VEC(force.getReferencePositions()[i], force2.getReferencePositions()[i], 0.0); ASSERT_EQUAL_VEC(force.getReferencePositions()[i], force2.getReferencePositions()[i], 0.0);
......
...@@ -2569,6 +2569,7 @@ class LennardJonesGenerator(object): ...@@ -2569,6 +2569,7 @@ class LennardJonesGenerator(object):
self.force.addTabulatedFunction('acoef', mm.Discrete2DFunction(numLjTypes, numLjTypes, acoef)) self.force.addTabulatedFunction('acoef', mm.Discrete2DFunction(numLjTypes, numLjTypes, acoef))
self.force.addTabulatedFunction('bcoef', mm.Discrete2DFunction(numLjTypes, numLjTypes, bcoef)) self.force.addTabulatedFunction('bcoef', mm.Discrete2DFunction(numLjTypes, numLjTypes, bcoef))
self.force.addPerParticleParameter('type') self.force.addPerParticleParameter('type')
self.force.setName('LennardJones')
if nonbondedMethod in [CutoffPeriodic, Ewald, PME, LJPME]: if nonbondedMethod in [CutoffPeriodic, Ewald, PME, LJPME]:
self.force.setNonbondedMethod(mm.CustomNonbondedForce.CutoffPeriodic) self.force.setNonbondedMethod(mm.CustomNonbondedForce.CutoffPeriodic)
elif nonbondedMethod is NoCutoff: elif nonbondedMethod is NoCutoff:
...@@ -2614,6 +2615,7 @@ class LennardJonesGenerator(object): ...@@ -2614,6 +2615,7 @@ class LennardJonesGenerator(object):
bonded = mm.CustomBondForce('%g*epsilon*((sigma/r)^12-(sigma/r)^6)' % (4*self.lj14scale)) bonded = mm.CustomBondForce('%g*epsilon*((sigma/r)^12-(sigma/r)^6)' % (4*self.lj14scale))
bonded.addPerBondParameter('sigma') bonded.addPerBondParameter('sigma')
bonded.addPerBondParameter('epsilon') bonded.addPerBondParameter('epsilon')
bonded.setName('LennardJones14')
sys.addForce(bonded) sys.addForce(bonded)
skip = set(tuple(forceCopy.getExclusionParticles(i)) for i in range(forceCopy.getNumExclusions())) skip = set(tuple(forceCopy.getExclusionParticles(i)) for i in range(forceCopy.getNumExclusions()))
for i in range(self.force.getNumExclusions()): for i in range(self.force.getNumExclusions()):
...@@ -3340,6 +3342,7 @@ class AmoebaBondGenerator(object): ...@@ -3340,6 +3342,7 @@ class AmoebaBondGenerator(object):
force = mm.CustomBondForce(energy) force = mm.CustomBondForce(energy)
force.addPerBondParameter('r0') force.addPerBondParameter('r0')
force.addPerBondParameter('k') force.addPerBondParameter('k')
force.setName('AmoebaBond')
sys.addForce(force) sys.addForce(force)
else: else:
force = existing[0] force = existing[0]
...@@ -3474,6 +3477,7 @@ class AmoebaAngleGenerator(object): ...@@ -3474,6 +3477,7 @@ class AmoebaAngleGenerator(object):
force = mm.CustomAngleForce(energy) force = mm.CustomAngleForce(energy)
force.addPerAngleParameter('theta0') force.addPerAngleParameter('theta0')
force.addPerAngleParameter('k') force.addPerAngleParameter('k')
force.setName('AmoebaAngle')
sys.addForce(force) sys.addForce(force)
else: else:
force = existing[0] force = existing[0]
...@@ -3543,6 +3547,7 @@ class AmoebaAngleGenerator(object): ...@@ -3543,6 +3547,7 @@ class AmoebaAngleGenerator(object):
force = mm.CustomCompoundBondForce(4, energy) force = mm.CustomCompoundBondForce(4, energy)
force.addPerBondParameter("theta0") force.addPerBondParameter("theta0")
force.addPerBondParameter("k") force.addPerBondParameter("k")
force.setName('AmoebaInPlaneAngle')
sys.addForce(force) sys.addForce(force)
else: else:
force = existing[0] force = existing[0]
...@@ -3706,6 +3711,7 @@ class AmoebaOutOfPlaneBendGenerator(object): ...@@ -3706,6 +3711,7 @@ class AmoebaOutOfPlaneBendGenerator(object):
if len(existing) == 0: if len(existing) == 0:
force = mm.CustomCompoundBondForce(4, energy) force = mm.CustomCompoundBondForce(4, energy)
force.addPerBondParameter("k") force.addPerBondParameter("k")
force.setName('AmoebaOutOfPlaneBend')
sys.addForce(force) sys.addForce(force)
else: else:
force = existing[0] force = existing[0]
...@@ -4014,6 +4020,7 @@ class AmoebaPiTorsionGenerator(object): ...@@ -4014,6 +4020,7 @@ class AmoebaPiTorsionGenerator(object):
if len(existing) == 0: if len(existing) == 0:
force = mm.CustomCompoundBondForce(6, energy) force = mm.CustomCompoundBondForce(6, energy)
force.addPerBondParameter('k') force.addPerBondParameter('k')
force.setName('AmoebaPiTorsion')
sys.addForce(force) sys.addForce(force)
else: else:
force = existing[0] force = existing[0]
...@@ -4398,6 +4405,7 @@ class AmoebaStretchBendGenerator(object): ...@@ -4398,6 +4405,7 @@ class AmoebaStretchBendGenerator(object):
force.addPerBondParameter("theta0") force.addPerBondParameter("theta0")
force.addPerBondParameter("k1") force.addPerBondParameter("k1")
force.addPerBondParameter("k2") force.addPerBondParameter("k2")
force.setName('AmoebaStretchBend')
sys.addForce(force) sys.addForce(force)
else: else:
force = existing[0] force = existing[0]
......
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