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

Added name property to Forces (#3049)

parent 7c2e5991
......@@ -45,6 +45,7 @@ void RMSDForceProxy::serialize(const void* object, SerializationNode& node) cons
node.setIntProperty("version", 0);
const RMSDForce& force = *reinterpret_cast<const RMSDForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setStringProperty("name", force.getName());
SerializationNode& positionsNode = node.createChildNode("ReferencePositions");
for (const Vec3& pos : force.getReferencePositions())
positionsNode.createChildNode("Position").setDoubleProperty("x", pos[0]).setDoubleProperty("y", pos[1]).setDoubleProperty("z", pos[2]);
......@@ -67,6 +68,7 @@ void* RMSDForceProxy::deserialize(const SerializationNode& node) const {
particles.push_back(particle.getIntProperty("index"));
force = new RMSDForce(positions, particles);
force->setForceGroup(node.getIntProperty("forceGroup", 0));
force->setName(node.getStringProperty("name", force->getName()));
return force;
}
catch (...) {
......
......@@ -43,6 +43,7 @@ void testSerialization() {
AndersenThermostat force(250.0, 0.2);
force.setForceGroup(3);
force.setName("custom name");
force.setRandomNumberSeed(3);
// Serialize and then deserialize it.
......@@ -55,6 +56,7 @@ void testSerialization() {
AndersenThermostat& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getDefaultTemperature(), force2.getDefaultTemperature());
ASSERT_EQUAL(force.getDefaultCollisionFrequency(), force2.getDefaultCollisionFrequency());
ASSERT_EQUAL(force.getRandomNumberSeed(), force2.getRandomNumberSeed());
......
......@@ -43,6 +43,7 @@ void testSerialization() {
CMAPTorsionForce force;
force.setForceGroup(3);
force.setName("custom name");
vector<double> map1(9);
for (int i = 0; i < 9; i++)
map1[i] = 0.1*i;
......@@ -67,6 +68,7 @@ void testSerialization() {
CMAPTorsionForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force.getNumMaps(), force2.getNumMaps());
for (int i = 0; i < force.getNumMaps(); i++) {
......
......@@ -43,6 +43,7 @@ void testSerialization() {
CMMotionRemover force(5);
force.setForceGroup(3);
force.setName("custom name");
// Serialize and then deserialize it.
......@@ -54,6 +55,7 @@ void testSerialization() {
CMMotionRemover& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getFrequency(), force2.getFrequency());
}
......
......@@ -43,6 +43,7 @@ void testSerialization() {
CustomAngleForce force("5*sin(x)^2+y*z");
force.setForceGroup(3);
force.setName("custom name");
force.addGlobalParameter("x", 1.3);
force.addGlobalParameter("y", 2.221);
force.addPerAngleParameter("z");
......@@ -66,6 +67,7 @@ void testSerialization() {
CustomAngleForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getEnergyFunction(), force2.getEnergyFunction());
ASSERT_EQUAL(force.getNumPerAngleParameters(), force2.getNumPerAngleParameters());
for (int i = 0; i < force.getNumPerAngleParameters(); i++)
......
......@@ -43,6 +43,7 @@ void testSerialization() {
CustomBondForce force("5*sin(x)^2+y*z");
force.setForceGroup(3);
force.setName("custom name");
force.addGlobalParameter("x", 1.3);
force.addGlobalParameter("y", 2.221);
force.addPerBondParameter("z");
......@@ -66,6 +67,7 @@ void testSerialization() {
CustomBondForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getEnergyFunction(), force2.getEnergyFunction());
ASSERT_EQUAL(force.getNumPerBondParameters(), force2.getNumPerBondParameters());
for (int i = 0; i < force.getNumPerBondParameters(); i++)
......
......@@ -45,6 +45,7 @@ void testSerialization() {
CustomCVForce force("2*v1+v2");
force.setForceGroup(3);
force.setName("custom name");
force.addGlobalParameter("x", 1.3);
force.addGlobalParameter("y", 2.221);
force.addEnergyParameterDerivative("y");
......@@ -69,6 +70,7 @@ void testSerialization() {
CustomCVForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getEnergyFunction(), force2.getEnergyFunction());
ASSERT_EQUAL(force.getNumGlobalParameters(), force2.getNumGlobalParameters());
for (int i = 0; i < force.getNumGlobalParameters(); i++) {
......
......@@ -43,6 +43,7 @@ void testSerialization() {
CustomCentroidBondForce force(3, "5*sin(distance(g1,g2))^2+y*z");
force.setForceGroup(3);
force.setName("custom name");
force.addGlobalParameter("x", 1.3);
force.addGlobalParameter("y", 2.221);
force.addPerBondParameter("z");
......@@ -90,6 +91,7 @@ void testSerialization() {
CustomCentroidBondForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getNumGroupsPerBond(), force2.getNumGroupsPerBond());
ASSERT_EQUAL(force.getEnergyFunction(), force2.getEnergyFunction());
ASSERT_EQUAL(force.getNumPerBondParameters(), force2.getNumPerBondParameters());
......
......@@ -43,6 +43,7 @@ void testSerialization() {
CustomCompoundBondForce force(3, "5*sin(distance(p1,p2))^2+y*z");
force.setForceGroup(3);
force.setName("custom name");
force.addGlobalParameter("x", 1.3);
force.addGlobalParameter("y", 2.221);
force.addPerBondParameter("z");
......@@ -80,6 +81,7 @@ void testSerialization() {
CustomCompoundBondForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getNumParticlesPerBond(), force2.getNumParticlesPerBond());
ASSERT_EQUAL(force.getEnergyFunction(), force2.getEnergyFunction());
ASSERT_EQUAL(force.getNumPerBondParameters(), force2.getNumPerBondParameters());
......
......@@ -43,6 +43,7 @@ void testSerialization() {
CustomExternalForce force("5*sin(x)^2+y*z");
force.setForceGroup(3);
force.setName("custom name");
force.addGlobalParameter("x", 1.3);
force.addGlobalParameter("y", 2.221);
force.addPerParticleParameter("z");
......@@ -64,6 +65,7 @@ void testSerialization() {
CustomExternalForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getEnergyFunction(), force2.getEnergyFunction());
ASSERT_EQUAL(force.getNumPerParticleParameters(), force2.getNumPerParticleParameters());
for (int i = 0; i < force.getNumPerParticleParameters(); i++)
......
......@@ -43,6 +43,7 @@ void testSerialization() {
CustomGBForce force;
force.setForceGroup(3);
force.setName("custom name");
force.setNonbondedMethod(CustomGBForce::CutoffPeriodic);
force.setCutoffDistance(2.1);
force.addGlobalParameter("x", 1.3);
......@@ -77,6 +78,7 @@ void testSerialization() {
CustomGBForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getNonbondedMethod(), force2.getNonbondedMethod());
ASSERT_EQUAL(force.getCutoffDistance(), force2.getCutoffDistance());
ASSERT_EQUAL(force.getNumPerParticleParameters(), force2.getNumPerParticleParameters());
......
......@@ -43,6 +43,7 @@ void testSerialization() {
CustomHbondForce force("5*sin(x)^2+y*z");
force.setForceGroup(3);
force.setName("custom name");
force.setNonbondedMethod(CustomHbondForce::CutoffPeriodic);
force.setCutoffDistance(2.1);
force.addGlobalParameter("x", 1.3);
......@@ -79,6 +80,7 @@ void testSerialization() {
CustomHbondForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getEnergyFunction(), force2.getEnergyFunction());
ASSERT_EQUAL(force.getNonbondedMethod(), force2.getNonbondedMethod());
ASSERT_EQUAL(force.getCutoffDistance(), force2.getCutoffDistance());
......
......@@ -43,6 +43,7 @@ void testSerialization() {
CustomManyParticleForce force(3, "C*(a1+a2+a3)*(distance(p1,p2)+distance(p1,p3))");
force.setForceGroup(3);
force.setName("custom name");
force.setNonbondedMethod(CustomManyParticleForce::CutoffPeriodic);
force.setPermutationMode(CustomManyParticleForce::UniqueCentralParticle);
force.setCutoffDistance(2.1);
......@@ -78,6 +79,7 @@ void testSerialization() {
CustomManyParticleForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getNumParticlesPerSet(), force2.getNumParticlesPerSet());
ASSERT_EQUAL(force.getEnergyFunction(), force2.getEnergyFunction());
ASSERT_EQUAL(force.getNonbondedMethod(), force2.getNonbondedMethod());
......
......@@ -43,6 +43,7 @@ void testSerialization() {
CustomNonbondedForce force("5*sin(x)^2+y*z");
force.setForceGroup(3);
force.setName("custom name");
force.setNonbondedMethod(CustomNonbondedForce::CutoffPeriodic);
force.setUseSwitchingFunction(true);
force.setUseLongRangeCorrection(true);
......@@ -81,6 +82,7 @@ void testSerialization() {
CustomNonbondedForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getEnergyFunction(), force2.getEnergyFunction());
ASSERT_EQUAL(force.getNonbondedMethod(), force2.getNonbondedMethod());
ASSERT_EQUAL(force.getCutoffDistance(), force2.getCutoffDistance());
......
......@@ -43,6 +43,7 @@ void testSerialization() {
CustomTorsionForce force("5*sin(x)^2+y*z");
force.setForceGroup(3);
force.setName("custom name");
force.addGlobalParameter("x", 1.3);
force.addGlobalParameter("y", 2.221);
force.addPerTorsionParameter("z");
......@@ -66,6 +67,7 @@ void testSerialization() {
CustomTorsionForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getEnergyFunction(), force2.getEnergyFunction());
ASSERT_EQUAL(force.getNumPerTorsionParameters(), force2.getNumPerTorsionParameters());
for (int i = 0; i < force.getNumPerTorsionParameters(); i++)
......
......@@ -43,6 +43,7 @@ void testSerialization() {
GBSAOBCForce force;
force.setForceGroup(3);
force.setName("custom name");
force.setNonbondedMethod(GBSAOBCForce::CutoffPeriodic);
force.setCutoffDistance(2.0);
force.setSoluteDielectric(5.1);
......@@ -62,6 +63,7 @@ void testSerialization() {
GBSAOBCForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getNonbondedMethod(), force2.getNonbondedMethod());
ASSERT_EQUAL(force.getCutoffDistance(), force2.getCutoffDistance());
ASSERT_EQUAL(force.getSoluteDielectric(), force2.getSoluteDielectric());
......
......@@ -43,6 +43,7 @@ void testSerialization() {
GayBerneForce force;
force.setForceGroup(3);
force.setName("custom name");
force.setNonbondedMethod(GayBerneForce::CutoffPeriodic);
force.setSwitchingDistance(1.5);
force.setUseSwitchingFunction(true);
......@@ -63,6 +64,7 @@ void testSerialization() {
GayBerneForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.getNonbondedMethod(), force2.getNonbondedMethod());
ASSERT_EQUAL(force.getSwitchingDistance(), force2.getSwitchingDistance());
ASSERT_EQUAL(force.getUseSwitchingFunction(), force2.getUseSwitchingFunction());
......
......@@ -43,6 +43,7 @@ void testSerialization() {
HarmonicAngleForce force;
force.setForceGroup(3);
force.setName("custom name");
force.addAngle(0, 1, 2, 1.0, 2.0);
force.addAngle(0, 2, 3, 2.0, 2.1);
force.addAngle(2, 3, 4, 3.0, 2.2);
......@@ -59,6 +60,7 @@ void testSerialization() {
HarmonicAngleForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force.getNumAngles(), force2.getNumAngles());
for (int i = 0; i < force.getNumAngles(); i++) {
......
......@@ -43,6 +43,7 @@ void testSerialization() {
HarmonicBondForce force;
force.setForceGroup(3);
force.setName("custom name");
force.addBond(0, 1, 1.0, 2.0);
force.addBond(0, 2, 2.0, 2.1);
force.addBond(2, 3, 3.0, 2.2);
......@@ -59,6 +60,7 @@ void testSerialization() {
HarmonicBondForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force.getNumBonds(), force2.getNumBonds());
for (int i = 0; i < force.getNumBonds(); i++) {
......
......@@ -43,6 +43,7 @@ void testSerialization() {
MonteCarloAnisotropicBarostat force(Vec3(15.1, 18.2, 19.3), 250.0, true, false, true, 14);
force.setForceGroup(3);
force.setName("custom name");
force.setRandomNumberSeed(3);
// Serialize and then deserialize it.
......@@ -55,6 +56,7 @@ void testSerialization() {
MonteCarloAnisotropicBarostat& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getName(), force2.getName());
ASSERT_EQUAL_VEC(force.getDefaultPressure(), force2.getDefaultPressure(), 0.0);
ASSERT_EQUAL(force.getDefaultTemperature(), force2.getDefaultTemperature());
ASSERT_EQUAL(force.getScaleX(), force2.getScaleX());
......
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