void CustomBondForceProxy::serialize(const void* object, SerializationNode& node) const { node.setIntProperty("version", 1); const CustomBondForce& force = *reinterpret_cast<const CustomBondForce*>(object); node.setStringProperty("energy", force.getEnergyFunction()); SerializationNode& perBondParams = node.createChildNode("PerBondParameters"); for (int i = 0; i < force.getNumPerBondParameters(); i++) { perBondParams.createChildNode("Parameter").setStringProperty("name", force.getPerBondParameterName(i)); } SerializationNode& globalParams = node.createChildNode("GlobalParameters"); for (int i = 0; i < force.getNumGlobalParameters(); i++) { globalParams.createChildNode("Parameter").setStringProperty("name", force.getGlobalParameterName(i)).setDoubleProperty("default", force.getGlobalParameterDefaultValue(i)); } SerializationNode& bonds = node.createChildNode("Bonds"); for (int i = 0; i < force.getNumBonds(); i++) { int p1, p2; vector<double> params; force.getBondParameters(i, p1, p2, params); SerializationNode& node = bonds.createChildNode("Bond").setIntProperty("p1", p1).setIntProperty("p2", p2); for (int j = 0; j < (int) params.size(); j++) { stringstream key; key << "param"; key << j+1; node.setDoubleProperty(key.str(), params[j]); } } }
void CustomTorsionForceProxy::serialize(const void* object, SerializationNode& node) const { node.setIntProperty("version", 2); const CustomTorsionForce& force = *reinterpret_cast<const CustomTorsionForce*>(object); node.setIntProperty("forceGroup", force.getForceGroup()); node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions()); node.setStringProperty("energy", force.getEnergyFunction()); SerializationNode& perTorsionParams = node.createChildNode("PerTorsionParameters"); for (int i = 0; i < force.getNumPerTorsionParameters(); i++) { perTorsionParams.createChildNode("Parameter").setStringProperty("name", force.getPerTorsionParameterName(i)); } SerializationNode& globalParams = node.createChildNode("GlobalParameters"); for (int i = 0; i < force.getNumGlobalParameters(); i++) { globalParams.createChildNode("Parameter").setStringProperty("name", force.getGlobalParameterName(i)).setDoubleProperty("default", force.getGlobalParameterDefaultValue(i)); } SerializationNode& torsions = node.createChildNode("Torsions"); for (int i = 0; i < force.getNumTorsions(); i++) { int p1, p2, p3, p4; vector<double> params; force.getTorsionParameters(i, p1, p2, p3, p4, params); SerializationNode& node = torsions.createChildNode("Torsion").setIntProperty("p1", p1).setIntProperty("p2", p2).setIntProperty("p3", p3).setIntProperty("p4", p4); for (int j = 0; j < (int) params.size(); j++) { stringstream key; key << "param"; key << j+1; node.setDoubleProperty(key.str(), params[j]); } } }
void CustomNonbondedForceProxy::serialize(const void* object, SerializationNode& node) const { node.setIntProperty("version", 2); const CustomNonbondedForce& force = *reinterpret_cast<const CustomNonbondedForce*>(object); node.setIntProperty("forceGroup", force.getForceGroup()); node.setStringProperty("energy", force.getEnergyFunction()); node.setIntProperty("method", (int) force.getNonbondedMethod()); node.setDoubleProperty("cutoff", force.getCutoffDistance()); node.setBoolProperty("useSwitchingFunction", force.getUseSwitchingFunction()); node.setDoubleProperty("switchingDistance", force.getSwitchingDistance()); node.setBoolProperty("useLongRangeCorrection", force.getUseLongRangeCorrection()); SerializationNode& perParticleParams = node.createChildNode("PerParticleParameters"); for (int i = 0; i < force.getNumPerParticleParameters(); i++) { perParticleParams.createChildNode("Parameter").setStringProperty("name", force.getPerParticleParameterName(i)); } SerializationNode& globalParams = node.createChildNode("GlobalParameters"); for (int i = 0; i < force.getNumGlobalParameters(); i++) { globalParams.createChildNode("Parameter").setStringProperty("name", force.getGlobalParameterName(i)).setDoubleProperty("default", force.getGlobalParameterDefaultValue(i)); } SerializationNode& energyDerivs = node.createChildNode("EnergyParameterDerivatives"); for (int i = 0; i < force.getNumEnergyParameterDerivatives(); i++) { energyDerivs.createChildNode("Parameter").setStringProperty("name", force.getEnergyParameterDerivativeName(i)); } SerializationNode& particles = node.createChildNode("Particles"); for (int i = 0; i < force.getNumParticles(); i++) { vector<double> params; force.getParticleParameters(i, params); SerializationNode& node = particles.createChildNode("Particle"); for (int j = 0; j < (int) params.size(); j++) { stringstream key; key << "param"; key << j+1; node.setDoubleProperty(key.str(), params[j]); } } SerializationNode& exclusions = node.createChildNode("Exclusions"); for (int i = 0; i < force.getNumExclusions(); i++) { int particle1, particle2; force.getExclusionParticles(i, particle1, particle2); exclusions.createChildNode("Exclusion").setIntProperty("p1", particle1).setIntProperty("p2", particle2); } SerializationNode& functions = node.createChildNode("Functions"); for (int i = 0; i < force.getNumTabulatedFunctions(); i++) functions.createChildNode("Function", &force.getTabulatedFunction(i)).setStringProperty("name", force.getTabulatedFunctionName(i)); SerializationNode& interactionGroups = node.createChildNode("InteractionGroups"); for (int i = 0; i < force.getNumInteractionGroups(); i++) { SerializationNode& interactionGroup = interactionGroups.createChildNode("InteractionGroup"); std::set<int> set1; std::set<int> set2; force.getInteractionGroupParameters(i, set1, set2); SerializationNode& set1node = interactionGroup.createChildNode("Set1"); for (std::set<int>::iterator it = set1.begin(); it != set1.end(); ++it) set1node.createChildNode("Particle").setIntProperty("index", *it); SerializationNode& set2node = interactionGroup.createChildNode("Set2"); for (std::set<int>::iterator it = set2.begin(); it != set2.end(); ++it) set2node.createChildNode("Particle").setIntProperty("index", *it); } }
void CustomNonbondedForceProxy::serialize(const void* object, SerializationNode& node) const { node.setIntProperty("version", 1); const CustomNonbondedForce& force = *reinterpret_cast<const CustomNonbondedForce*>(object); node.setStringProperty("energy", force.getEnergyFunction()); node.setIntProperty("method", (int) force.getNonbondedMethod()); node.setDoubleProperty("cutoff", force.getCutoffDistance()); SerializationNode& perParticleParams = node.createChildNode("PerParticleParameters"); for (int i = 0; i < force.getNumPerParticleParameters(); i++) { perParticleParams.createChildNode("Parameter").setStringProperty("name", force.getPerParticleParameterName(i)); } SerializationNode& globalParams = node.createChildNode("GlobalParameters"); for (int i = 0; i < force.getNumGlobalParameters(); i++) { globalParams.createChildNode("Parameter").setStringProperty("name", force.getGlobalParameterName(i)).setDoubleProperty("default", force.getGlobalParameterDefaultValue(i)); } SerializationNode& particles = node.createChildNode("Particles"); for (int i = 0; i < force.getNumParticles(); i++) { vector<double> params; force.getParticleParameters(i, params); SerializationNode& node = particles.createChildNode("Particle"); for (int j = 0; j < (int) params.size(); j++) { stringstream key; key << "param"; key << j+1; node.setDoubleProperty(key.str(), params[j]); } } SerializationNode& exclusions = node.createChildNode("Exclusions"); for (int i = 0; i < force.getNumExclusions(); i++) { int particle1, particle2; force.getExclusionParticles(i, particle1, particle2); exclusions.createChildNode("Exclusion").setIntProperty("p1", particle1).setIntProperty("p2", particle2); } SerializationNode& functions = node.createChildNode("Functions"); for (int i = 0; i < force.getNumFunctions(); i++) { string name; vector<double> values; double min, max; force.getFunctionParameters(i, name, values, min, max); SerializationNode& node = functions.createChildNode("Function").setStringProperty("name", name).setDoubleProperty("min", min).setDoubleProperty("max", max); SerializationNode& valuesNode = node.createChildNode("Values"); for (int j = 0; j < (int) values.size(); j++) valuesNode.createChildNode("Value").setDoubleProperty("v", values[j]); } }
void CustomCompoundBondForceProxy::serialize(const void* object, SerializationNode& node) const { node.setIntProperty("version", 3); const CustomCompoundBondForce& force = *reinterpret_cast<const CustomCompoundBondForce*>(object); node.setIntProperty("forceGroup", force.getForceGroup()); node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions()); node.setIntProperty("particles", force.getNumParticlesPerBond()); node.setStringProperty("energy", force.getEnergyFunction()); SerializationNode& perBondParams = node.createChildNode("PerBondParameters"); for (int i = 0; i < force.getNumPerBondParameters(); i++) { perBondParams.createChildNode("Parameter").setStringProperty("name", force.getPerBondParameterName(i)); } SerializationNode& globalParams = node.createChildNode("GlobalParameters"); for (int i = 0; i < force.getNumGlobalParameters(); i++) { globalParams.createChildNode("Parameter").setStringProperty("name", force.getGlobalParameterName(i)).setDoubleProperty("default", force.getGlobalParameterDefaultValue(i)); } SerializationNode& energyDerivs = node.createChildNode("EnergyParameterDerivatives"); for (int i = 0; i < force.getNumEnergyParameterDerivatives(); i++) { energyDerivs.createChildNode("Parameter").setStringProperty("name", force.getEnergyParameterDerivativeName(i)); } SerializationNode& bonds = node.createChildNode("Bonds"); for (int i = 0; i < force.getNumBonds(); i++) { vector<int> particles; vector<double> params; force.getBondParameters(i, particles, params); SerializationNode& node = bonds.createChildNode("Bond"); for (int j = 0; j < (int) particles.size(); j++) { stringstream key; key << "p"; key << j+1; node.setIntProperty(key.str(), particles[j]); } for (int j = 0; j < (int) params.size(); j++) { stringstream key; key << "param"; key << j+1; node.setDoubleProperty(key.str(), params[j]); } } SerializationNode& functions = node.createChildNode("Functions"); for (int i = 0; i < force.getNumTabulatedFunctions(); i++) functions.createChildNode("Function", &force.getTabulatedFunction(i)).setStringProperty("name", force.getTabulatedFunctionName(i)); }