Commit 1877eb67 authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

edit/add AMOEBA serialization proxies

parent 67971bf4
/* -------------------------------------------------------------------------- *
* OpenMMAmoeba *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/AmoebaGeneralizedKirkwoodForceProxy.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/Force.h"
#include "openmm/AmoebaGeneralizedKirkwoodForce.h"
#include <sstream>
using namespace OpenMM;
using namespace std;
AmoebaGeneralizedKirkwoodForceProxy::AmoebaGeneralizedKirkwoodForceProxy() : SerializationProxy("AmoebaGeneralizedKirkwoodForce") {
}
void AmoebaGeneralizedKirkwoodForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const AmoebaGeneralizedKirkwoodForce& force = *reinterpret_cast<const AmoebaGeneralizedKirkwoodForce*>(object);
node.setDoubleProperty("GeneralizedKirkwoodSolventDielectric", force.getSolventDielectric() );
node.setDoubleProperty("GeneralizedKirkwoodSoluteDielectric", force.getSoluteDielectric() );
node.setDoubleProperty("GeneralizedKirkwoodDielectricOffset", force.getDielectricOffset() );
node.setDoubleProperty("GeneralizedKirkwoodProbeRadius", force.getProbeRadius() );
node.setDoubleProperty("GeneralizedKirkwoodSurfaceAreaFactor", force.getSurfaceAreaFactor() );
node.setIntProperty( "GeneralizedKirkwoodIncludeCavityTerm", force.getIncludeCavityTerm() );
SerializationNode& particles = node.createChildNode("GeneralizedKirkwoodParticles").setIntProperty( "size", force.getNumParticles() );
for (unsigned int ii = 0; ii < force.getNumParticles(); ii++) {
double radius, charge, scalingFactor;
force.getParticleParameters( ii, charge, radius, scalingFactor );
particles.createChildNode("Particle").setIntProperty("index", ii).setDoubleProperty("charge", charge).setDoubleProperty("radius", radius).setDoubleProperty("scaleFactor", scalingFactor);
}
}
void* AmoebaGeneralizedKirkwoodForceProxy::deserialize(const SerializationNode& node) const {
if (node.getIntProperty("version") != 1)
throw OpenMMException("Unsupported version number");
AmoebaGeneralizedKirkwoodForce* force = new AmoebaGeneralizedKirkwoodForce();
try {
force->setSolventDielectric( node.getDoubleProperty( "GeneralizedKirkwoodSolventDielectric" ) );
force->setSoluteDielectric( node.getDoubleProperty( "GeneralizedKirkwoodSoluteDielectric" ) );
force->setDielectricOffset( node.getDoubleProperty( "GeneralizedKirkwoodDielectricOffset" ) );
force->setProbeRadius( node.getDoubleProperty( "GeneralizedKirkwoodProbeRadius" ) );
force->setSurfaceAreaFactor( node.getDoubleProperty( "GeneralizedKirkwoodSurfaceAreaFactor" ) );
force->setIncludeCavityTerm( node.getIntProperty( "GeneralizedKirkwoodIncludeCavityTerm" ) );
const SerializationNode& particles = node.getChildNode("GeneralizedKirkwoodParticles");
for (unsigned int ii = 0; ii < particles.getChildren().size(); ii++) {
const SerializationNode& particle = particles.getChildren()[ii];
force->addParticle( particle.getDoubleProperty("charge"), particle.getDoubleProperty("radius"), particle.getDoubleProperty("scaleFactor"));
}
}
catch (...) {
delete force;
throw;
}
return force;
}
...@@ -43,16 +43,19 @@ AmoebaHarmonicAngleForceProxy::AmoebaHarmonicAngleForceProxy() : SerializationPr ...@@ -43,16 +43,19 @@ AmoebaHarmonicAngleForceProxy::AmoebaHarmonicAngleForceProxy() : SerializationPr
void AmoebaHarmonicAngleForceProxy::serialize(const void* object, SerializationNode& node) const { void AmoebaHarmonicAngleForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const AmoebaHarmonicAngleForce& force = *reinterpret_cast<const AmoebaHarmonicAngleForce*>(object); const AmoebaHarmonicAngleForce& force = *reinterpret_cast<const AmoebaHarmonicAngleForce*>(object);
node.setDoubleProperty("HarmonicAngleCubic", force.getAmoebaGlobalHarmonicAngleCubic()); node.setDoubleProperty("HarmonicAngleCubic", force.getAmoebaGlobalHarmonicAngleCubic());
node.setDoubleProperty("HarmonicAngleQuartic", force.getAmoebaGlobalHarmonicAngleQuartic()); node.setDoubleProperty("HarmonicAngleQuartic", force.getAmoebaGlobalHarmonicAngleQuartic());
node.setDoubleProperty("HarmonicAnglePentic", force.getAmoebaGlobalHarmonicAnglePentic()); node.setDoubleProperty("HarmonicAnglePentic", force.getAmoebaGlobalHarmonicAnglePentic());
node.setDoubleProperty("HarmonicAngleSextic", force.getAmoebaGlobalHarmonicAngleSextic()); node.setDoubleProperty("HarmonicAngleSextic", force.getAmoebaGlobalHarmonicAngleSextic());
SerializationNode& bonds = node.createChildNode("Angles");
for (int i = 0; i < force.getNumAngles(); i++) { SerializationNode& bonds = node.createChildNode("Angles").setIntProperty( "size", force.getNumAngles() );
for (unsigned int ii = 0; ii < force.getNumAngles(); ii++) {
int particle1, particle2, particle3; int particle1, particle2, particle3;
double distance, k; double distance, k;
force.getAngleParameters(i, particle1, particle2, particle3, distance, k); force.getAngleParameters(ii, particle1, particle2, particle3, distance, k);
bonds.createChildNode("Angle").setIntProperty("p1", particle1).setIntProperty("p2", particle2).setIntProperty("p3", particle3).setDoubleProperty("d", distance).setDoubleProperty("k", k); bonds.createChildNode("Angle").setIntProperty("p1", particle1).setIntProperty("p2", particle2).setIntProperty("p3", particle3).setDoubleProperty("d", distance).setDoubleProperty("k", k);
} }
} }
...@@ -62,13 +65,15 @@ void* AmoebaHarmonicAngleForceProxy::deserialize(const SerializationNode& node) ...@@ -62,13 +65,15 @@ void* AmoebaHarmonicAngleForceProxy::deserialize(const SerializationNode& node)
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
AmoebaHarmonicAngleForce* force = new AmoebaHarmonicAngleForce(); AmoebaHarmonicAngleForce* force = new AmoebaHarmonicAngleForce();
try { try {
force->setAmoebaGlobalHarmonicAngleCubic(node.getDoubleProperty("HarmonicAngleCubic"));
force->setAmoebaGlobalHarmonicAngleCubic(node.getDoubleProperty( "HarmonicAngleCubic"));
force->setAmoebaGlobalHarmonicAngleQuartic(node.getDoubleProperty("HarmonicAngleQuartic")); force->setAmoebaGlobalHarmonicAngleQuartic(node.getDoubleProperty("HarmonicAngleQuartic"));
force->setAmoebaGlobalHarmonicAnglePentic(node.getDoubleProperty("HarmonicAnglePentic")); force->setAmoebaGlobalHarmonicAnglePentic(node.getDoubleProperty( "HarmonicAnglePentic"));
force->setAmoebaGlobalHarmonicAngleSextic(node.getDoubleProperty("HarmonicAngleSextic")); force->setAmoebaGlobalHarmonicAngleSextic(node.getDoubleProperty( "HarmonicAngleSextic"));
const SerializationNode& bonds = node.getChildNode("Angles"); const SerializationNode& bonds = node.getChildNode("Angles");
for (int i = 0; i < (int) bonds.getChildren().size(); i++) { for ( unsigned int ii = 0; ii < bonds.getChildren().size(); ii++) {
const SerializationNode& bond = bonds.getChildren()[i]; const SerializationNode& bond = bonds.getChildren()[ii];
force->addAngle(bond.getIntProperty("p1"), bond.getIntProperty("p2"), bond.getIntProperty("p3"), bond.getDoubleProperty("d"), bond.getDoubleProperty("k")); force->addAngle(bond.getIntProperty("p1"), bond.getIntProperty("p2"), bond.getIntProperty("p3"), bond.getDoubleProperty("d"), bond.getDoubleProperty("k"));
} }
} }
......
...@@ -44,13 +44,15 @@ AmoebaHarmonicBondForceProxy::AmoebaHarmonicBondForceProxy() : SerializationProx ...@@ -44,13 +44,15 @@ AmoebaHarmonicBondForceProxy::AmoebaHarmonicBondForceProxy() : SerializationProx
void AmoebaHarmonicBondForceProxy::serialize(const void* object, SerializationNode& node) const { void AmoebaHarmonicBondForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const AmoebaHarmonicBondForce& force = *reinterpret_cast<const AmoebaHarmonicBondForce*>(object); const AmoebaHarmonicBondForce& force = *reinterpret_cast<const AmoebaHarmonicBondForce*>(object);
node.setDoubleProperty("HarmonicBondCubic", force.getAmoebaGlobalHarmonicBondCubic()); node.setDoubleProperty("HarmonicBondCubic", force.getAmoebaGlobalHarmonicBondCubic());
node.setDoubleProperty("HarmonicBondQuartic", force.getAmoebaGlobalHarmonicBondQuartic()); node.setDoubleProperty("HarmonicBondQuartic", force.getAmoebaGlobalHarmonicBondQuartic());
SerializationNode& bonds = node.createChildNode("Bonds");
for (int i = 0; i < force.getNumBonds(); i++) { SerializationNode& bonds = node.createChildNode("Bonds").setIntProperty( "size", force.getNumBonds() );
for (unsigned int ii = 0; ii < force.getNumBonds(); ii++) {
int particle1, particle2; int particle1, particle2;
double distance, k; double distance, k;
force.getBondParameters(i, particle1, particle2, distance, k); force.getBondParameters(ii, particle1, particle2, distance, k);
bonds.createChildNode("Bond").setIntProperty("p1", particle1).setIntProperty("p2", particle2).setDoubleProperty("d", distance).setDoubleProperty("k", k); bonds.createChildNode("Bond").setIntProperty("p1", particle1).setIntProperty("p2", particle2).setDoubleProperty("d", distance).setDoubleProperty("k", k);
} }
} }
...@@ -63,8 +65,8 @@ void* AmoebaHarmonicBondForceProxy::deserialize(const SerializationNode& node) c ...@@ -63,8 +65,8 @@ void* AmoebaHarmonicBondForceProxy::deserialize(const SerializationNode& node) c
force->setAmoebaGlobalHarmonicBondCubic(node.getDoubleProperty("HarmonicBondCubic")); force->setAmoebaGlobalHarmonicBondCubic(node.getDoubleProperty("HarmonicBondCubic"));
force->setAmoebaGlobalHarmonicBondQuartic(node.getDoubleProperty("HarmonicBondQuartic")); force->setAmoebaGlobalHarmonicBondQuartic(node.getDoubleProperty("HarmonicBondQuartic"));
const SerializationNode& bonds = node.getChildNode("Bonds"); const SerializationNode& bonds = node.getChildNode("Bonds");
for (int i = 0; i < (int) bonds.getChildren().size(); i++) { for ( unsigned int ii = 0; ii < (int) bonds.getChildren().size(); ii++) {
const SerializationNode& bond = bonds.getChildren()[i]; const SerializationNode& bond = bonds.getChildren()[ii];
force->addBond(bond.getIntProperty("p1"), bond.getIntProperty("p2"), bond.getDoubleProperty("d"), bond.getDoubleProperty("k")); force->addBond(bond.getIntProperty("p1"), bond.getIntProperty("p2"), bond.getDoubleProperty("d"), bond.getDoubleProperty("k"));
} }
} }
......
...@@ -42,17 +42,20 @@ AmoebaHarmonicInPlaneAngleForceProxy::AmoebaHarmonicInPlaneAngleForceProxy() : S ...@@ -42,17 +42,20 @@ AmoebaHarmonicInPlaneAngleForceProxy::AmoebaHarmonicInPlaneAngleForceProxy() : S
} }
void AmoebaHarmonicInPlaneAngleForceProxy::serialize(const void* object, SerializationNode& node) const { void AmoebaHarmonicInPlaneAngleForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const AmoebaHarmonicInPlaneAngleForce& force = *reinterpret_cast<const AmoebaHarmonicInPlaneAngleForce*>(object); const AmoebaHarmonicInPlaneAngleForce& force = *reinterpret_cast<const AmoebaHarmonicInPlaneAngleForce*>(object);
node.setDoubleProperty("HarmonicInPlaneAngleCubic", force.getAmoebaGlobalHarmonicInPlaneAngleCubic()); node.setDoubleProperty("HarmonicInPlaneAngleCubic", force.getAmoebaGlobalHarmonicInPlaneAngleCubic());
node.setDoubleProperty("HarmonicInPlaneAngleQuartic", force.getAmoebaGlobalHarmonicInPlaneAngleQuartic()); node.setDoubleProperty("HarmonicInPlaneAngleQuartic", force.getAmoebaGlobalHarmonicInPlaneAngleQuartic());
node.setDoubleProperty("HarmonicInPlaneAnglePentic", force.getAmoebaGlobalHarmonicInPlaneAnglePentic()); node.setDoubleProperty("HarmonicInPlaneAnglePentic", force.getAmoebaGlobalHarmonicInPlaneAnglePentic());
node.setDoubleProperty("HarmonicInPlaneAngleSextic", force.getAmoebaGlobalHarmonicInPlaneAngleSextic()); node.setDoubleProperty("HarmonicInPlaneAngleSextic", force.getAmoebaGlobalHarmonicInPlaneAngleSextic());
SerializationNode& bonds = node.createChildNode("InPlaneAngles");
for (int i = 0; i < force.getNumAngles(); i++) { SerializationNode& bonds = node.createChildNode("InPlaneAngles").setIntProperty( "size", force.getNumAngles() );
for ( unsigned int ii = 0; ii < force.getNumAngles(); ii++) {
int particle1, particle2, particle3, particle4; int particle1, particle2, particle3, particle4;
double distance, k; double distance, k;
force.getAngleParameters(i, particle1, particle2, particle3, particle4, distance, k); force.getAngleParameters(ii, particle1, particle2, particle3, particle4, distance, k);
bonds.createChildNode("InPlaneAngle").setIntProperty("p1", particle1).setIntProperty("p2", particle2).setIntProperty("p3", particle3).setIntProperty("p4", particle4).setDoubleProperty("d", distance).setDoubleProperty("k", k); bonds.createChildNode("InPlaneAngle").setIntProperty("p1", particle1).setIntProperty("p2", particle2).setIntProperty("p3", particle3).setIntProperty("p4", particle4).setDoubleProperty("d", distance).setDoubleProperty("k", k);
} }
} }
...@@ -62,13 +65,15 @@ void* AmoebaHarmonicInPlaneAngleForceProxy::deserialize(const SerializationNode& ...@@ -62,13 +65,15 @@ void* AmoebaHarmonicInPlaneAngleForceProxy::deserialize(const SerializationNode&
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
AmoebaHarmonicInPlaneAngleForce* force = new AmoebaHarmonicInPlaneAngleForce(); AmoebaHarmonicInPlaneAngleForce* force = new AmoebaHarmonicInPlaneAngleForce();
try { try {
force->setAmoebaGlobalHarmonicInPlaneAngleCubic(node.getDoubleProperty("HarmonicInPlaneAngleCubic"));
force->setAmoebaGlobalHarmonicInPlaneAngleCubic( node.getDoubleProperty("HarmonicInPlaneAngleCubic"));
force->setAmoebaGlobalHarmonicInPlaneAngleQuartic(node.getDoubleProperty("HarmonicInPlaneAngleQuartic")); force->setAmoebaGlobalHarmonicInPlaneAngleQuartic(node.getDoubleProperty("HarmonicInPlaneAngleQuartic"));
force->setAmoebaGlobalHarmonicInPlaneAnglePentic(node.getDoubleProperty("HarmonicInPlaneAnglePentic")); force->setAmoebaGlobalHarmonicInPlaneAnglePentic( node.getDoubleProperty("HarmonicInPlaneAnglePentic"));
force->setAmoebaGlobalHarmonicInPlaneAngleSextic(node.getDoubleProperty("HarmonicInPlaneAngleSextic")); force->setAmoebaGlobalHarmonicInPlaneAngleSextic( node.getDoubleProperty("HarmonicInPlaneAngleSextic"));
const SerializationNode& bonds = node.getChildNode("InPlaneAngles"); const SerializationNode& bonds = node.getChildNode("InPlaneAngles");
for (int i = 0; i < (int) bonds.getChildren().size(); i++) { for (unsigned int ii = 0; ii < bonds.getChildren().size(); ii++) {
const SerializationNode& bond = bonds.getChildren()[i]; const SerializationNode& bond = bonds.getChildren()[ii];
force->addAngle(bond.getIntProperty("p1"), bond.getIntProperty("p2"), bond.getIntProperty("p3"), bond.getIntProperty("p4"), bond.getDoubleProperty("d"), bond.getDoubleProperty("k")); force->addAngle(bond.getIntProperty("p1"), bond.getIntProperty("p2"), bond.getIntProperty("p3"), bond.getIntProperty("p4"), bond.getDoubleProperty("d"), bond.getDoubleProperty("k"));
} }
} }
......
/* -------------------------------------------------------------------------- *
* OpenMMAmoeba *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/AmoebaMultipoleForceProxy.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/Force.h"
#include "openmm/AmoebaMultipoleForce.h"
#include <sstream>
using namespace OpenMM;
using namespace std;
AmoebaMultipoleForceProxy::AmoebaMultipoleForceProxy() : SerializationProxy("AmoebaMultipoleForce") {
}
static void getCovalentTypes( std::vector<std::string>& covalentTypes ){
covalentTypes.push_back( "Covalent12" );
covalentTypes.push_back( "Covalent13" );
covalentTypes.push_back( "Covalent14" );
covalentTypes.push_back( "Covalent15" );
covalentTypes.push_back( "PolarizationCovalent11" );
covalentTypes.push_back( "PolarizationCovalent12" );
covalentTypes.push_back( "PolarizationCovalent13" );
covalentTypes.push_back( "PolarizationCovalent14" );
}
static void addCovalentMap( SerializationNode& particleExclusions, int particleIndex, std::string mapName, std::vector< int > covalentMap ){
SerializationNode& map = particleExclusions.createChildNode(mapName);
map.setIntProperty( "index", particleIndex );
map.setIntProperty( "size", covalentMap.size() );
for (unsigned int ii = 0; ii < covalentMap.size(); ii++) {
map.createChildNode("Cv").setIntProperty( "v", covalentMap[ii] );
}
}
int loadCovalentMap( const SerializationNode& map, std::vector< int >& covalentMap ){
for (unsigned int ii = 0; ii < map.getChildren().size(); ii++) {
covalentMap.push_back( map.getChildren()[ii].getIntProperty( "v" ) );
}
}
void AmoebaMultipoleForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const AmoebaMultipoleForce& force = *reinterpret_cast<const AmoebaMultipoleForce*>(object);
node.setIntProperty("nonbondedMethod", force.getNonbondedMethod());
node.setIntProperty("pmeBSplineOrder", force.getPmeBSplineOrder());
node.setIntProperty("mutualInducedIterationMethod", force.getMutualInducedIterationMethod());
node.setIntProperty("mutualInducedMaxIterations", force.getMutualInducedMaxIterations());
node.setDoubleProperty("cutoffDistance", force.getCutoffDistance());
node.setDoubleProperty("aEwald", force.getAEwald());
node.setDoubleProperty("mutualInducedTargetEpsilon", force.getMutualInducedTargetEpsilon());
node.setDoubleProperty("electricConstant", force.getElectricConstant());
node.setDoubleProperty("ewaldErrorTolerance", force.getEwaldErrorTolerance());
std::vector<int> gridDimensions;
force.getPmeGridDimensions( gridDimensions );
SerializationNode& gridDimensionsNode = node.createChildNode("MultipoleParticleGridDimension");
gridDimensionsNode.setIntProperty( "d0", gridDimensions[0] ).setIntProperty( "d1", gridDimensions[1] ).setIntProperty( "d2", gridDimensions[2] );
std::vector<std::string> covalentTypes;
getCovalentTypes( covalentTypes );
SerializationNode& particles = node.createChildNode("MultipoleParticles").setIntProperty( "size", force.getNumMultipoles() );
for (unsigned int ii = 0; ii < force.getNumMultipoles(); ii++) {
int axisType, multipoleAtomZ, multipoleAtomX, multipoleAtomY;
double charge, thole, dampingFactor, polarity;
std::vector<double> molecularDipole;
std::vector<double> molecularQuadrupole;
force.getMultipoleParameters( ii, charge, molecularDipole, molecularQuadrupole,
axisType, multipoleAtomZ, multipoleAtomX, multipoleAtomY, thole, dampingFactor, polarity );
SerializationNode& particle = particles.createChildNode("Particle");
particle.setIntProperty("index", ii).setIntProperty("axisType", axisType).setIntProperty("multipoleAtomZ", multipoleAtomZ).setIntProperty("multipoleAtomX", multipoleAtomX).setIntProperty("multipoleAtomY", multipoleAtomY);
particle.setDoubleProperty("charge", charge).setDoubleProperty("thole", thole).setDoubleProperty("damp", dampingFactor).setDoubleProperty("polarity", polarity);
SerializationNode& dipole = particle.createChildNode("Dipole").setIntProperty( "size", 3 );
dipole.setDoubleProperty( "d0", molecularDipole[0] ).setDoubleProperty( "d1", molecularDipole[1] ).setDoubleProperty( "d2", molecularDipole[2] );
SerializationNode& quadrupole = particle.createChildNode("Quadrupole").setIntProperty( "size", 9 );
quadrupole.setDoubleProperty( "q0", molecularQuadrupole[0] ).setDoubleProperty( "q1", molecularQuadrupole[1] ).setDoubleProperty( "q2", molecularQuadrupole[2] );
quadrupole.setDoubleProperty( "q3", molecularQuadrupole[3] ).setDoubleProperty( "q4", molecularQuadrupole[4] ).setDoubleProperty( "q5", molecularQuadrupole[5] );
quadrupole.setDoubleProperty( "q6", molecularQuadrupole[6] ).setDoubleProperty( "q7", molecularQuadrupole[7] ).setDoubleProperty( "q8", molecularQuadrupole[8] );
for (unsigned int jj = 0; jj < covalentTypes.size(); jj++) {
std::vector< int > covalentMap;
force.getCovalentMap(ii, static_cast<AmoebaMultipoleForce::CovalentType>(jj), covalentMap );
addCovalentMap( particle, ii, covalentTypes[jj], covalentMap );
}
}
}
void* AmoebaMultipoleForceProxy::deserialize(const SerializationNode& node) const {
if (node.getIntProperty("version") != 1)
throw OpenMMException("Unsupported version number");
AmoebaMultipoleForce* force = new AmoebaMultipoleForce();
try {
force->setNonbondedMethod( static_cast<AmoebaMultipoleForce::AmoebaNonbondedMethod>(node.getIntProperty( "nonbondedMethod" )) );
force->setPmeBSplineOrder( node.getIntProperty( "pmeBSplineOrder" ) );
force->setMutualInducedIterationMethod( static_cast<AmoebaMultipoleForce::MutualInducedIterationMethod>(node.getIntProperty( "mutualInducedIterationMethod" ) ) );
force->setMutualInducedMaxIterations( node.getIntProperty( "mutualInducedMaxIterations" ) );
force->setCutoffDistance( node.getDoubleProperty( "cutoffDistance" ) );
force->setAEwald( node.getDoubleProperty( "aEwald" ) );
force->setMutualInducedTargetEpsilon( node.getDoubleProperty( "mutualInducedTargetEpsilon" ) );
force->setElectricConstant( node.getDoubleProperty( "electricConstant" ) );
force->setEwaldErrorTolerance( node.getDoubleProperty( "ewaldErrorTolerance" ) );
std::vector<int> gridDimensions;
const SerializationNode& gridDimensionsNode = node.getChildNode("MultipoleParticleGridDimension");
gridDimensions.push_back( gridDimensionsNode.getIntProperty( "d0" ));
gridDimensions.push_back( gridDimensionsNode.getIntProperty( "d1" ));
gridDimensions.push_back( gridDimensionsNode.getIntProperty( "d2" ));
force->setPmeGridDimensions( gridDimensions );
std::vector<std::string> covalentTypes;
getCovalentTypes( covalentTypes );
const SerializationNode& particles = node.getChildNode("MultipoleParticles");
for ( unsigned int ii = 0; ii < particles.getChildren().size(); ii++) {
const SerializationNode& particle = particles.getChildren()[ii];
std::vector<double> molecularDipole;
const SerializationNode& dipole = particle.getChildNode("Dipole");
molecularDipole.push_back( dipole.getDoubleProperty( "d0" ) );
molecularDipole.push_back( dipole.getDoubleProperty( "d1" ) );
molecularDipole.push_back( dipole.getDoubleProperty( "d2" ) );
std::vector<double> molecularQuadrupole;
const SerializationNode& quadrupole = particle.getChildNode("Quadrupole");
molecularQuadrupole.push_back( quadrupole.getDoubleProperty( "q0" ) );
molecularQuadrupole.push_back( quadrupole.getDoubleProperty( "q1" ) );
molecularQuadrupole.push_back( quadrupole.getDoubleProperty( "q2" ) );
molecularQuadrupole.push_back( quadrupole.getDoubleProperty( "q3" ) );
molecularQuadrupole.push_back( quadrupole.getDoubleProperty( "q4" ) );
molecularQuadrupole.push_back( quadrupole.getDoubleProperty( "q5" ) );
molecularQuadrupole.push_back( quadrupole.getDoubleProperty( "q6" ) );
molecularQuadrupole.push_back( quadrupole.getDoubleProperty( "q7" ) );
molecularQuadrupole.push_back( quadrupole.getDoubleProperty( "q8" ) );
force->addParticle( particle.getDoubleProperty("charge"), molecularDipole, molecularQuadrupole,
particle.getIntProperty("axisType"),
particle.getIntProperty("multipoleAtomZ"),
particle.getIntProperty("multipoleAtomX"),
particle.getIntProperty("multipoleAtomY"),
particle.getDoubleProperty("thole"),
particle.getDoubleProperty("damp"), particle.getDoubleProperty("polarity"));
// covalent maps
for (unsigned int jj = 0; jj < covalentTypes.size(); jj++) {
std::vector< int > covalentMap;
loadCovalentMap( particle.getChildNode(covalentTypes[jj]), covalentMap );
force->setCovalentMap( ii, static_cast<AmoebaMultipoleForce::CovalentType>(jj), covalentMap );
}
}
}
catch (...) {
delete force;
throw;
}
return force;
}
...@@ -48,11 +48,12 @@ void AmoebaOutOfPlaneBendForceProxy::serialize(const void* object, Serialization ...@@ -48,11 +48,12 @@ void AmoebaOutOfPlaneBendForceProxy::serialize(const void* object, Serialization
node.setDoubleProperty("OutOfPlaneBendQuartic", force.getAmoebaGlobalOutOfPlaneBendQuartic()); node.setDoubleProperty("OutOfPlaneBendQuartic", force.getAmoebaGlobalOutOfPlaneBendQuartic());
node.setDoubleProperty("OutOfPlaneBendPentic", force.getAmoebaGlobalOutOfPlaneBendPentic()); node.setDoubleProperty("OutOfPlaneBendPentic", force.getAmoebaGlobalOutOfPlaneBendPentic());
node.setDoubleProperty("OutOfPlaneBendSextic", force.getAmoebaGlobalOutOfPlaneBendSextic()); node.setDoubleProperty("OutOfPlaneBendSextic", force.getAmoebaGlobalOutOfPlaneBendSextic());
SerializationNode& bonds = node.createChildNode("OutOfPlaneBend");
for (int i = 0; i < force.getNumOutOfPlaneBends(); i++) { SerializationNode& bonds = node.createChildNode("OutOfPlaneBend").setIntProperty( "size", force.getNumOutOfPlaneBends() );
for (unsigned int ii = 0; ii < force.getNumOutOfPlaneBends(); ii++) {
int particle1, particle2, particle3, particle4; int particle1, particle2, particle3, particle4;
double k; double k;
force.getOutOfPlaneBendParameters(i, particle1, particle2, particle3, particle4, k); force.getOutOfPlaneBendParameters(ii, particle1, particle2, particle3, particle4, k);
bonds.createChildNode("OutOfPlaneBend").setIntProperty("p1", particle1).setIntProperty("p2", particle2).setIntProperty("p3", particle3).setIntProperty("p4", particle4).setDoubleProperty("k", k); bonds.createChildNode("OutOfPlaneBend").setIntProperty("p1", particle1).setIntProperty("p2", particle2).setIntProperty("p3", particle3).setIntProperty("p4", particle4).setDoubleProperty("k", k);
} }
} }
...@@ -62,13 +63,15 @@ void* AmoebaOutOfPlaneBendForceProxy::deserialize(const SerializationNode& node) ...@@ -62,13 +63,15 @@ void* AmoebaOutOfPlaneBendForceProxy::deserialize(const SerializationNode& node)
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
AmoebaOutOfPlaneBendForce* force = new AmoebaOutOfPlaneBendForce(); AmoebaOutOfPlaneBendForce* force = new AmoebaOutOfPlaneBendForce();
try { try {
force->setAmoebaGlobalOutOfPlaneBendCubic(node.getDoubleProperty("OutOfPlaneBendCubic"));
force->setAmoebaGlobalOutOfPlaneBendCubic(node.getDoubleProperty( "OutOfPlaneBendCubic"));
force->setAmoebaGlobalOutOfPlaneBendQuartic(node.getDoubleProperty("OutOfPlaneBendQuartic")); force->setAmoebaGlobalOutOfPlaneBendQuartic(node.getDoubleProperty("OutOfPlaneBendQuartic"));
force->setAmoebaGlobalOutOfPlaneBendPentic(node.getDoubleProperty("OutOfPlaneBendPentic")); force->setAmoebaGlobalOutOfPlaneBendPentic(node.getDoubleProperty( "OutOfPlaneBendPentic"));
force->setAmoebaGlobalOutOfPlaneBendSextic(node.getDoubleProperty("OutOfPlaneBendSextic")); force->setAmoebaGlobalOutOfPlaneBendSextic(node.getDoubleProperty( "OutOfPlaneBendSextic"));
const SerializationNode& bonds = node.getChildNode("OutOfPlaneBend"); const SerializationNode& bonds = node.getChildNode("OutOfPlaneBend");
for (int i = 0; i < (int) bonds.getChildren().size(); i++) { for (unsigned int ii = 0; ii < bonds.getChildren().size(); ii++) {
const SerializationNode& bond = bonds.getChildren()[i]; const SerializationNode& bond = bonds.getChildren()[ii];
force->addOutOfPlaneBend(bond.getIntProperty("p1"), bond.getIntProperty("p2"), bond.getIntProperty("p3"), bond.getIntProperty("p4"), bond.getDoubleProperty("k")); force->addOutOfPlaneBend(bond.getIntProperty("p1"), bond.getIntProperty("p2"), bond.getIntProperty("p3"), bond.getIntProperty("p4"), bond.getDoubleProperty("k"));
} }
} }
......
...@@ -44,11 +44,11 @@ AmoebaPiTorsionForceProxy::AmoebaPiTorsionForceProxy() : SerializationProxy("Amo ...@@ -44,11 +44,11 @@ AmoebaPiTorsionForceProxy::AmoebaPiTorsionForceProxy() : SerializationProxy("Amo
void AmoebaPiTorsionForceProxy::serialize(const void* object, SerializationNode& node) const { void AmoebaPiTorsionForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const AmoebaPiTorsionForce& force = *reinterpret_cast<const AmoebaPiTorsionForce*>(object); const AmoebaPiTorsionForce& force = *reinterpret_cast<const AmoebaPiTorsionForce*>(object);
SerializationNode& bonds = node.createChildNode("PiTorsion"); SerializationNode& bonds = node.createChildNode("PiTorsion").setIntProperty( "size", force.getNumPiTorsions() );
for (int i = 0; i < force.getNumPiTorsions(); i++) { for ( unsigned int ii = 0; ii < force.getNumPiTorsions(); ii++) {
int particle1, particle2, particle3, particle4, particle5, particle6; int particle1, particle2, particle3, particle4, particle5, particle6;
double k; double k;
force.getPiTorsionParameters(i, particle1, particle2, particle3, particle4, particle5, particle6, k); force.getPiTorsionParameters(ii, particle1, particle2, particle3, particle4, particle5, particle6, k);
bonds.createChildNode("PiTorsion").setIntProperty("p1", particle1).setIntProperty("p2", particle2).setIntProperty("p3", particle3).setIntProperty("p4", particle4).setIntProperty("p5", particle5).setIntProperty("p6", particle6).setDoubleProperty("k", k); bonds.createChildNode("PiTorsion").setIntProperty("p1", particle1).setIntProperty("p2", particle2).setIntProperty("p3", particle3).setIntProperty("p4", particle4).setIntProperty("p5", particle5).setIntProperty("p6", particle6).setDoubleProperty("k", k);
} }
} }
...@@ -59,9 +59,9 @@ void* AmoebaPiTorsionForceProxy::deserialize(const SerializationNode& node) cons ...@@ -59,9 +59,9 @@ void* AmoebaPiTorsionForceProxy::deserialize(const SerializationNode& node) cons
AmoebaPiTorsionForce* force = new AmoebaPiTorsionForce(); AmoebaPiTorsionForce* force = new AmoebaPiTorsionForce();
try { try {
const SerializationNode& bonds = node.getChildNode("PiTorsion"); const SerializationNode& bonds = node.getChildNode("PiTorsion");
for (int i = 0; i < (int) bonds.getChildren().size(); i++) { for (unsigned int ii = 0; ii < bonds.getChildren().size(); ii++) {
const SerializationNode& bond = bonds.getChildren()[i]; const SerializationNode& bond = bonds.getChildren()[ii];
force->addPiTorsion(bond.getIntProperty("p1"), bond.getIntProperty("p2"), bond.getIntProperty("p3"), bond.getIntProperty("p4"), bond.getIntProperty("p5"), bond.getIntProperty("p6"),bond.getDoubleProperty("k")); force->addPiTorsion(bond.getIntProperty("p1"), bond.getIntProperty("p2"), bond.getIntProperty("p3"), bond.getIntProperty("p4"), bond.getIntProperty("p5"), bond.getIntProperty("p6"), bond.getDoubleProperty("k"));
} }
} }
catch (...) { catch (...) {
......
...@@ -39,26 +39,36 @@ ...@@ -39,26 +39,36 @@
#endif #endif
#include "openmm/OpenMMException.h" #include "openmm/OpenMMException.h"
#include "openmm/AmoebaGeneralizedKirkwoodForce.h"
#include "openmm/AmoebaHarmonicBondForce.h" #include "openmm/AmoebaHarmonicBondForce.h"
#include "openmm/AmoebaHarmonicAngleForce.h" #include "openmm/AmoebaHarmonicAngleForce.h"
#include "openmm/AmoebaHarmonicInPlaneAngleForce.h" #include "openmm/AmoebaHarmonicInPlaneAngleForce.h"
#include "openmm/AmoebaMultipoleForce.h"
#include "openmm/AmoebaOutOfPlaneBendForce.h" #include "openmm/AmoebaOutOfPlaneBendForce.h"
#include "openmm/AmoebaPiTorsionForce.h" #include "openmm/AmoebaPiTorsionForce.h"
#include "openmm/AmoebaStretchBendForce.h"
#include "openmm/AmoebaTorsionForce.h" #include "openmm/AmoebaTorsionForce.h"
#include "openmm/AmoebaTorsionTorsionForce.h" #include "openmm/AmoebaTorsionTorsionForce.h"
#include "openmm/AmoebaUreyBradleyForce.h" #include "openmm/AmoebaUreyBradleyForce.h"
#include "openmm/AmoebaVdwForce.h" #include "openmm/AmoebaVdwForce.h"
#include "openmm/AmoebaWcaDispersionForce.h"
#include "openmm/serialization/SerializationProxy.h" #include "openmm/serialization/SerializationProxy.h"
#include "openmm/serialization/AmoebaGeneralizedKirkwoodForceProxy.h"
#include "openmm/serialization/AmoebaHarmonicBondForceProxy.h" #include "openmm/serialization/AmoebaHarmonicBondForceProxy.h"
#include "openmm/serialization/AmoebaHarmonicAngleForceProxy.h" #include "openmm/serialization/AmoebaHarmonicAngleForceProxy.h"
#include "openmm/serialization/AmoebaHarmonicInPlaneAngleForceProxy.h" #include "openmm/serialization/AmoebaHarmonicInPlaneAngleForceProxy.h"
#include "openmm/serialization/AmoebaMultipoleForceProxy.h"
#include "openmm/serialization/AmoebaOutOfPlaneBendForceProxy.h" #include "openmm/serialization/AmoebaOutOfPlaneBendForceProxy.h"
#include "openmm/serialization/AmoebaPiTorsionForceProxy.h" #include "openmm/serialization/AmoebaPiTorsionForceProxy.h"
#include "openmm/serialization/AmoebaStretchBendForceProxy.h"
#include "openmm/serialization/AmoebaTorsionForceProxy.h" #include "openmm/serialization/AmoebaTorsionForceProxy.h"
#include "openmm/serialization/AmoebaTorsionTorsionForceProxy.h" #include "openmm/serialization/AmoebaTorsionTorsionForceProxy.h"
#include "openmm/serialization/AmoebaUreyBradleyForceProxy.h" #include "openmm/serialization/AmoebaUreyBradleyForceProxy.h"
#include "openmm/serialization/AmoebaVdwForceProxy.h" #include "openmm/serialization/AmoebaVdwForceProxy.h"
#include "openmm/serialization/AmoebaWcaDispersionForceProxy.h"
#if defined(WIN32) #if defined(WIN32)
#include <windows.h> #include <windows.h>
...@@ -101,13 +111,17 @@ extern "C" void registerAmoebaSerializationProxies() { ...@@ -101,13 +111,17 @@ extern "C" void registerAmoebaSerializationProxies() {
#endif #endif
SerializationProxy::registerProxy(typeid(AmoebaGeneralizedKirkwoodForce), new AmoebaGeneralizedKirkwoodForceProxy());
SerializationProxy::registerProxy(typeid(AmoebaHarmonicBondForce), new AmoebaHarmonicBondForceProxy()); SerializationProxy::registerProxy(typeid(AmoebaHarmonicBondForce), new AmoebaHarmonicBondForceProxy());
SerializationProxy::registerProxy(typeid(AmoebaHarmonicAngleForce), new AmoebaHarmonicAngleForceProxy()); SerializationProxy::registerProxy(typeid(AmoebaHarmonicAngleForce), new AmoebaHarmonicAngleForceProxy());
SerializationProxy::registerProxy(typeid(AmoebaHarmonicInPlaneAngleForce), new AmoebaHarmonicInPlaneAngleForceProxy()); SerializationProxy::registerProxy(typeid(AmoebaHarmonicInPlaneAngleForce), new AmoebaHarmonicInPlaneAngleForceProxy());
SerializationProxy::registerProxy(typeid(AmoebaMultipoleForce), new AmoebaMultipoleForceProxy());
SerializationProxy::registerProxy(typeid(AmoebaOutOfPlaneBendForce), new AmoebaOutOfPlaneBendForceProxy()); SerializationProxy::registerProxy(typeid(AmoebaOutOfPlaneBendForce), new AmoebaOutOfPlaneBendForceProxy());
SerializationProxy::registerProxy(typeid(AmoebaPiTorsionForce), new AmoebaPiTorsionForceProxy()); SerializationProxy::registerProxy(typeid(AmoebaPiTorsionForce), new AmoebaPiTorsionForceProxy());
SerializationProxy::registerProxy(typeid(AmoebaStretchBendForce), new AmoebaStretchBendForceProxy());
SerializationProxy::registerProxy(typeid(AmoebaTorsionForce), new AmoebaTorsionForceProxy()); SerializationProxy::registerProxy(typeid(AmoebaTorsionForce), new AmoebaTorsionForceProxy());
SerializationProxy::registerProxy(typeid(AmoebaTorsionTorsionForce), new AmoebaTorsionTorsionForceProxy()); SerializationProxy::registerProxy(typeid(AmoebaTorsionTorsionForce), new AmoebaTorsionTorsionForceProxy());
SerializationProxy::registerProxy(typeid(AmoebaUreyBradleyForce), new AmoebaUreyBradleyForceProxy()); SerializationProxy::registerProxy(typeid(AmoebaUreyBradleyForce), new AmoebaUreyBradleyForceProxy());
SerializationProxy::registerProxy(typeid(AmoebaVdwForce), new AmoebaVdwForceProxy()); SerializationProxy::registerProxy(typeid(AmoebaVdwForce), new AmoebaVdwForceProxy());
SerializationProxy::registerProxy(typeid(AmoebaWcaDispersionForce), new AmoebaWcaDispersionForceProxy());
} }
/* -------------------------------------------------------------------------- *
* OpenMMAmoeba *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/AmoebaStretchBendForceProxy.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/Force.h"
#include "openmm/AmoebaStretchBendForce.h"
#include <sstream>
using namespace OpenMM;
using namespace std;
AmoebaStretchBendForceProxy::AmoebaStretchBendForceProxy() : SerializationProxy("AmoebaStretchBendForce") {
}
void AmoebaStretchBendForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const AmoebaStretchBendForce& force = *reinterpret_cast<const AmoebaStretchBendForce*>(object);
SerializationNode& bonds = node.createChildNode("StretchBendAngles").setIntProperty( "size", force.getNumStretchBends() );
for (unsigned int ii = 0; ii < force.getNumStretchBends(); ii++) {
int particle1, particle2, particle3;
double distanceAB, distanceCB, angle, k;
force.getStretchBendParameters(ii, particle1, particle2, particle3, distanceAB, distanceCB, angle, k);
bonds.createChildNode("StretchBendAngle").setIntProperty("p1", particle1).setIntProperty("p2", particle2).setIntProperty("p3", particle3).setDoubleProperty("dAB", distanceAB).setDoubleProperty("dCB", distanceCB).setDoubleProperty("angle", angle).setDoubleProperty("k", k);
}
}
void* AmoebaStretchBendForceProxy::deserialize(const SerializationNode& node) const {
if (node.getIntProperty("version") != 1)
throw OpenMMException("Unsupported version number");
AmoebaStretchBendForce* force = new AmoebaStretchBendForce();
try {
const SerializationNode& bonds = node.getChildNode("StretchBendAngles");
for ( unsigned int ii = 0; ii < (int) bonds.getChildren().size(); ii++) {
const SerializationNode& bond = bonds.getChildren()[ii];
force->addStretchBend(bond.getIntProperty("p1"), bond.getIntProperty("p2"), bond.getIntProperty("p3"), bond.getDoubleProperty("dAB"), bond.getDoubleProperty("dCB"), bond.getDoubleProperty("angle"), bond.getDoubleProperty("k"));
}
}
catch (...) {
delete force;
throw;
}
return force;
}
...@@ -42,30 +42,31 @@ AmoebaTorsionForceProxy::AmoebaTorsionForceProxy() : SerializationProxy("AmoebaT ...@@ -42,30 +42,31 @@ AmoebaTorsionForceProxy::AmoebaTorsionForceProxy() : SerializationProxy("AmoebaT
} }
static void addTorsionValues( SerializationNode& torsion, const std::vector<double>& torsionValues ){ static void addTorsionValues( SerializationNode& torsion, const std::vector<double>& torsionValues ){
for (int j = 0; j < torsionValues.size(); j++) { for (unsigned int jj = 0; jj < torsionValues.size(); jj++) {
torsion.createChildNode("Value").setDoubleProperty("v", torsionValues[j]); torsion.createChildNode("Value").setDoubleProperty("v", torsionValues[jj]);
} }
} }
static void loadTorsionValues( SerializationNode& torsion, std::vector<double>& torsionValues ){ static void loadTorsionValues( SerializationNode& torsion, std::vector<double>& torsionValues ){
int size = torsion.getIntProperty("size"); int size = torsion.getIntProperty("size");
torsionValues.resize(size); torsionValues.resize(size);
for (int j = 0; j < size; j++) { for (unsigned int jj = 0; jj < size; jj++) {
torsionValues[j] = ( torsion.getChildren()[j].getDoubleProperty("v") ); torsionValues[jj] = ( torsion.getChildren()[jj].getDoubleProperty("v") );
} }
} }
void AmoebaTorsionForceProxy::serialize(const void* object, SerializationNode& node) const { void AmoebaTorsionForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const AmoebaTorsionForce& force = *reinterpret_cast<const AmoebaTorsionForce*>(object); const AmoebaTorsionForce& force = *reinterpret_cast<const AmoebaTorsionForce*>(object);
SerializationNode& bonds = node.createChildNode("Torsion");
for (int i = 0; i < force.getNumTorsions(); i++) { SerializationNode& bonds = node.createChildNode("Torsion").setIntProperty("size", force.getNumTorsions() );
for (unsigned int ii = 0; ii < force.getNumTorsions(); ii++) {
int particle1, particle2, particle3, particle4; int particle1, particle2, particle3, particle4;
std::vector<double> torsion1; std::vector<double> torsion1;
std::vector<double> torsion2; std::vector<double> torsion2;
std::vector<double> torsion3; std::vector<double> torsion3;
force.getTorsionParameters(i, particle1, particle2, particle3, particle4, torsion1, torsion2, torsion3); force.getTorsionParameters(ii, particle1, particle2, particle3, particle4, torsion1, torsion2, torsion3);
SerializationNode& torsionBond = bonds.createChildNode("Torsion"); SerializationNode& torsionBond = bonds.createChildNode("Torsion");
torsionBond.setIntProperty("p1", particle1).setIntProperty("p2", particle2).setIntProperty("p3", particle3).setIntProperty("p4", particle4); torsionBond.setIntProperty("p1", particle1).setIntProperty("p2", particle2).setIntProperty("p3", particle3).setIntProperty("p4", particle4);
...@@ -92,15 +93,20 @@ void* AmoebaTorsionForceProxy::deserialize(const SerializationNode& node) const ...@@ -92,15 +93,20 @@ void* AmoebaTorsionForceProxy::deserialize(const SerializationNode& node) const
vector<SerializationNode> children = bonds.getChildren(); vector<SerializationNode> children = bonds.getChildren();
for (unsigned int i = 0; i < children.size(); i++) { for (unsigned int i = 0; i < children.size(); i++) {
SerializationNode& bond = children[i]; SerializationNode& bond = children[i];
std::vector<double> torsion1; std::vector<double> torsion1;
std::vector<double> torsion2; std::vector<double> torsion2;
std::vector<double> torsion3; std::vector<double> torsion3;
SerializationNode& torsionNode1 = bond.getChildNode("Torsion1"); SerializationNode& torsionNode1 = bond.getChildNode("Torsion1");
loadTorsionValues( torsionNode1, torsion1 ); loadTorsionValues( torsionNode1, torsion1 );
SerializationNode& torsionNode2 = bond.getChildNode("Torsion2"); SerializationNode& torsionNode2 = bond.getChildNode("Torsion2");
loadTorsionValues( torsionNode2, torsion2 ); loadTorsionValues( torsionNode2, torsion2 );
SerializationNode& torsionNode3 = bond.getChildNode("Torsion3"); SerializationNode& torsionNode3 = bond.getChildNode("Torsion3");
loadTorsionValues( torsionNode3, torsion3 ); loadTorsionValues( torsionNode3, torsion3 );
force->addTorsion(bond.getIntProperty("p1"), bond.getIntProperty("p2"), bond.getIntProperty("p3"), bond.getIntProperty("p4"), torsion1, torsion2, torsion3 ); force->addTorsion(bond.getIntProperty("p1"), bond.getIntProperty("p2"), bond.getIntProperty("p3"), bond.getIntProperty("p4"), torsion1, torsion2, torsion3 );
} }
} }
......
...@@ -77,9 +77,9 @@ void AmoebaTorsionTorsionForceProxy::serialize(const void* object, Serialization ...@@ -77,9 +77,9 @@ void AmoebaTorsionTorsionForceProxy::serialize(const void* object, Serialization
SerializationNode& grids = node.createChildNode("TorsionTorsionGrids"); SerializationNode& grids = node.createChildNode("TorsionTorsionGrids");
grids.setIntProperty("size", static_cast<int>(force.getNumTorsionTorsionGrids())); grids.setIntProperty("size", static_cast<int>(force.getNumTorsionTorsionGrids()));
for (int i = 0; i < force.getNumTorsionTorsionGrids(); i++) { for (unsigned int kk = 0; kk < force.getNumTorsionTorsionGrids(); kk++) {
const std::vector< std::vector< std::vector<double> > > grid = force.getTorsionTorsionGrid( i ); const std::vector< std::vector< std::vector<double> > > grid = force.getTorsionTorsionGrid( kk );
unsigned int gridCount = 0; unsigned int gridCount = 0;
unsigned int gridYsize = grid[0].size(); unsigned int gridYsize = grid[0].size();
...@@ -107,10 +107,10 @@ void AmoebaTorsionTorsionForceProxy::serialize(const void* object, Serialization ...@@ -107,10 +107,10 @@ void AmoebaTorsionTorsionForceProxy::serialize(const void* object, Serialization
} }
SerializationNode& bonds = node.createChildNode("TorsionTorsion"); SerializationNode& bonds = node.createChildNode("TorsionTorsion");
for (int i = 0; i < force.getNumTorsionTorsions(); i++) { for (unsigned int ii = 0; ii < force.getNumTorsionTorsions(); ii++) {
int particle1, particle2, particle3, particle4, particle5; int particle1, particle2, particle3, particle4, particle5;
int chiralCheckAtomIndex, gridIndex; int chiralCheckAtomIndex, gridIndex;
force.getTorsionTorsionParameters(i, particle1, particle2, particle3, particle4, particle5, chiralCheckAtomIndex, gridIndex ); force.getTorsionTorsionParameters(ii, particle1, particle2, particle3, particle4, particle5, chiralCheckAtomIndex, gridIndex );
bonds.createChildNode("TorsionTorsion").setIntProperty("p1", particle1).setIntProperty("p2", particle2).setIntProperty("p3", particle3).setIntProperty("p4", particle4).setIntProperty("p5", particle5).setIntProperty("chiralCheckAtomIndex", chiralCheckAtomIndex).setIntProperty("gridIndex", gridIndex ); bonds.createChildNode("TorsionTorsion").setIntProperty("p1", particle1).setIntProperty("p2", particle2).setIntProperty("p3", particle3).setIntProperty("p4", particle4).setIntProperty("p5", particle5).setIntProperty("chiralCheckAtomIndex", chiralCheckAtomIndex).setIntProperty("gridIndex", gridIndex );
} }
......
...@@ -44,14 +44,16 @@ AmoebaUreyBradleyForceProxy::AmoebaUreyBradleyForceProxy() : SerializationProxy( ...@@ -44,14 +44,16 @@ AmoebaUreyBradleyForceProxy::AmoebaUreyBradleyForceProxy() : SerializationProxy(
void AmoebaUreyBradleyForceProxy::serialize(const void* object, SerializationNode& node) const { void AmoebaUreyBradleyForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const AmoebaUreyBradleyForce& force = *reinterpret_cast<const AmoebaUreyBradleyForce*>(object); const AmoebaUreyBradleyForce& force = *reinterpret_cast<const AmoebaUreyBradleyForce*>(object);
node.setDoubleProperty("UreyBradleyCubic", force.getAmoebaGlobalUreyBradleyCubic()); node.setDoubleProperty("UreyBradleyCubic", force.getAmoebaGlobalUreyBradleyCubic());
node.setDoubleProperty("UreyBradleyQuartic", force.getAmoebaGlobalUreyBradleyQuartic()); node.setDoubleProperty("UreyBradleyQuartic", force.getAmoebaGlobalUreyBradleyQuartic());
SerializationNode& bonds = node.createChildNode("Bonds");
for (int i = 0; i < force.getNumInteractions(); i++) { SerializationNode& bonds = node.createChildNode("UreyBradley").setIntProperty( "size", force.getNumInteractions() );
for (unsigned int ii = 0; ii < force.getNumInteractions(); ii++) {
int particle1, particle2; int particle1, particle2;
double distance, k; double distance, k;
force.getUreyBradleyParameters(i, particle1, particle2, distance, k); force.getUreyBradleyParameters(ii, particle1, particle2, distance, k);
bonds.createChildNode("Bond").setIntProperty("p1", particle1).setIntProperty("p2", particle2).setDoubleProperty("d", distance).setDoubleProperty("k", k); bonds.createChildNode("Ixn").setIntProperty( "index", ii ).setIntProperty("p1", particle1).setIntProperty("p2", particle2).setDoubleProperty("d", distance).setDoubleProperty("k", k);
} }
} }
...@@ -60,11 +62,13 @@ void* AmoebaUreyBradleyForceProxy::deserialize(const SerializationNode& node) co ...@@ -60,11 +62,13 @@ void* AmoebaUreyBradleyForceProxy::deserialize(const SerializationNode& node) co
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
AmoebaUreyBradleyForce* force = new AmoebaUreyBradleyForce(); AmoebaUreyBradleyForce* force = new AmoebaUreyBradleyForce();
try { try {
force->setAmoebaGlobalUreyBradleyCubic(node.getDoubleProperty("UreyBradleyCubic"));
force->setAmoebaGlobalUreyBradleyCubic(node.getDoubleProperty( "UreyBradleyCubic"));
force->setAmoebaGlobalUreyBradleyQuartic(node.getDoubleProperty("UreyBradleyQuartic")); force->setAmoebaGlobalUreyBradleyQuartic(node.getDoubleProperty("UreyBradleyQuartic"));
const SerializationNode& bonds = node.getChildNode("Bonds");
for (int i = 0; i < (int) bonds.getChildren().size(); i++) { const SerializationNode& bonds = node.getChildNode("UreyBradley");
const SerializationNode& bond = bonds.getChildren()[i]; for (unsigned int ii = 0; ii < bonds.getChildren().size(); ii++) {
const SerializationNode& bond = bonds.getChildren()[ii];
force->addUreyBradley(bond.getIntProperty("p1"), bond.getIntProperty("p2"), bond.getDoubleProperty("d"), bond.getDoubleProperty("k")); force->addUreyBradley(bond.getIntProperty("p1"), bond.getIntProperty("p2"), bond.getDoubleProperty("d"), bond.getDoubleProperty("k"));
} }
} }
......
...@@ -44,28 +44,32 @@ AmoebaVdwForceProxy::AmoebaVdwForceProxy() : SerializationProxy("AmoebaVdwForce" ...@@ -44,28 +44,32 @@ AmoebaVdwForceProxy::AmoebaVdwForceProxy() : SerializationProxy("AmoebaVdwForce"
void AmoebaVdwForceProxy::serialize(const void* object, SerializationNode& node) const { void AmoebaVdwForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const AmoebaVdwForce& force = *reinterpret_cast<const AmoebaVdwForce*>(object); const AmoebaVdwForce& force = *reinterpret_cast<const AmoebaVdwForce*>(object);
node.setStringProperty("SigmaCombiningRule", force.getSigmaCombiningRule()); node.setStringProperty("SigmaCombiningRule", force.getSigmaCombiningRule());
node.setStringProperty("EpsilonCombiningRule", force.getEpsilonCombiningRule()); node.setStringProperty("EpsilonCombiningRule", force.getEpsilonCombiningRule());
node.setDoubleProperty("VdwCutoff", force.getCutoff()); node.setDoubleProperty("VdwCutoff", force.getCutoff());
node.setIntProperty("VdwUseNeighborList", force.getUseNeighborList());
node.setIntProperty("VdwPBC", force.getPBC()); node.setIntProperty( "VdwUseNeighborList", force.getUseNeighborList());
SerializationNode& particles = node.createChildNode("VdwParticles"); node.setIntProperty( "VdwPBC", force.getPBC());
for (int i = 0; i < force.getNumParticles(); i++) {
SerializationNode& particles = node.createChildNode("VdwParticles").setIntProperty("size", force.getNumParticles() );
for (unsigned int ii = 0; ii < force.getNumParticles(); ii++) {
int ivIndex, classIndex; int ivIndex, classIndex;
double sigma, epsilon, reductionFactor; double sigma, epsilon, reductionFactor;
force.getParticleParameters( i, ivIndex, classIndex, sigma, epsilon, reductionFactor ); force.getParticleParameters( ii, ivIndex, classIndex, sigma, epsilon, reductionFactor );
particles.createChildNode("Particle").setIntProperty("index", i).setIntProperty("ivIndex", ivIndex).setIntProperty("classIndex", classIndex).setDoubleProperty("sig", sigma).setDoubleProperty("eps", epsilon).setDoubleProperty("red", reductionFactor);
} SerializationNode& particle = particles.createChildNode("Particle");
particle.setIntProperty("index", ii).setIntProperty("ivIndex", ivIndex).setIntProperty("classIndex", classIndex).setDoubleProperty("sigma", sigma).setDoubleProperty("epsilon", epsilon).setDoubleProperty("reductionFactor", reductionFactor);
SerializationNode& particleExclusions = node.createChildNode("VdwParticleExclusions");
for (int i = 0; i < force.getNumParticles(); i++) {
std::vector< int > exclusions; std::vector< int > exclusions;
force.getParticleExclusions( i, exclusions ); force.getParticleExclusions( ii, exclusions );
SerializationNode& particle = particleExclusions.createChildNode("ParticleExclusion");
particle.setIntProperty("size", exclusions.size() ); SerializationNode& particleExclusions = particle.createChildNode("ParticleExclusions");
particle.setIntProperty("index", i ); particleExclusions.setIntProperty("size", exclusions.size() );
particleExclusions.setIntProperty("index", ii );
for (unsigned int jj = 0; jj < exclusions.size(); jj++) { for (unsigned int jj = 0; jj < exclusions.size(); jj++) {
particle.createChildNode("ParticleExclusion").setIntProperty( "ex", exclusions[jj] ); particleExclusions.createChildNode( "excl" ).setIntProperty( "index", exclusions[jj] );
} }
} }
} }
...@@ -83,23 +87,20 @@ void* AmoebaVdwForceProxy::deserialize(const SerializationNode& node) const { ...@@ -83,23 +87,20 @@ void* AmoebaVdwForceProxy::deserialize(const SerializationNode& node) const {
force->setPBC( node.getIntProperty( "VdwPBC" ) ); force->setPBC( node.getIntProperty( "VdwPBC" ) );
const SerializationNode& particles = node.getChildNode("VdwParticles"); const SerializationNode& particles = node.getChildNode("VdwParticles");
for (int i = 0; i < (int) particles.getChildren().size(); i++) { for (unsigned int ii = 0; ii < particles.getChildren().size(); ii++) {
const SerializationNode& particle = particles.getChildren()[i]; const SerializationNode& particle = particles.getChildren()[ii];
force->addParticle(particle.getIntProperty("ivIndex"), particle.getIntProperty("classIndex"), particle.getDoubleProperty("sig"), particle.getDoubleProperty("eps"), particle.getDoubleProperty("red")); force->addParticle(particle.getIntProperty("ivIndex"), particle.getIntProperty("classIndex"), particle.getDoubleProperty("sigma"), particle.getDoubleProperty("epsilon"), particle.getDoubleProperty("reductionFactor"));
}
// exclusions // exclusions
const SerializationNode& particleExclusions = node.getChildNode("VdwParticleExclusions"); const SerializationNode& particleExclusions = particle.getChildNode("ParticleExclusions");
for (int i = 0; i < (int) particleExclusions.getChildren().size(); i++) {
const SerializationNode& particleExclusion = particleExclusions.getChildren()[i];
std::vector< int > exclusions; std::vector< int > exclusions;
for (unsigned int jj = 0; jj < particleExclusion.getChildren().size(); jj++) { for (unsigned int jj = 0; jj < particleExclusions.getChildren().size(); jj++) {
exclusions.push_back( particleExclusion.getChildren()[jj].getIntProperty("ex") ); exclusions.push_back( particleExclusions.getChildren()[jj].getIntProperty("index") );
} }
int index = particleExclusion.getIntProperty( "index" ); force->setParticleExclusions( ii, exclusions );
force->setParticleExclusions( index, exclusions );
} }
} }
catch (...) { catch (...) {
delete force; delete force;
......
/* -------------------------------------------------------------------------- *
* OpenMMAmoeba *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/serialization/AmoebaWcaDispersionForceProxy.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/Force.h"
#include "openmm/AmoebaWcaDispersionForce.h"
#include <sstream>
using namespace OpenMM;
using namespace std;
AmoebaWcaDispersionForceProxy::AmoebaWcaDispersionForceProxy() : SerializationProxy("AmoebaWcaDispersionForce") {
}
void AmoebaWcaDispersionForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const AmoebaWcaDispersionForce& force = *reinterpret_cast<const AmoebaWcaDispersionForce*>(object);
node.setDoubleProperty("Epso", force.getEpso());
node.setDoubleProperty("Epsh", force.getEpsh());
node.setDoubleProperty("Rmino", force.getRmino());
node.setDoubleProperty("Rminh", force.getRminh());
node.setDoubleProperty("Awater", force.getAwater());
node.setDoubleProperty("Shctd", force.getShctd());
node.setDoubleProperty("Dispoff", force.getDispoff());
node.setDoubleProperty("Slevy", force.getSlevy());
SerializationNode& particles = node.createChildNode("WcaDispersionParticles").setIntProperty( "size", force.getNumParticles() );
for (unsigned int ii = 0; ii < force.getNumParticles(); ii++) {
double radius, epsilon;
force.getParticleParameters( ii, radius, epsilon );
particles.createChildNode("Particle").setIntProperty("index", ii).setDoubleProperty("radius", radius).setDoubleProperty("epsilon", epsilon);
}
}
void* AmoebaWcaDispersionForceProxy::deserialize(const SerializationNode& node) const {
if (node.getIntProperty("version") != 1)
throw OpenMMException("Unsupported version number");
AmoebaWcaDispersionForce* force = new AmoebaWcaDispersionForce();
try {
force->setEpso( node.getDoubleProperty( "Epso" ) );
force->setEpsh( node.getDoubleProperty( "Epsh" ) );
force->setRmino( node.getDoubleProperty( "Rmino" ) );
force->setRminh( node.getDoubleProperty( "Rminh" ) );
force->setAwater( node.getDoubleProperty( "Awater" ) );
force->setShctd( node.getDoubleProperty( "Shctd" ) );
force->setDispoff( node.getDoubleProperty( "Dispoff" ) );
force->setSlevy( node.getDoubleProperty( "Slevy" ) );
const SerializationNode& particles = node.getChildNode("WcaDispersionParticles");
for (unsigned int ii = 0; ii < particles.getChildren().size(); ii++) {
const SerializationNode& particle = particles.getChildren()[ii];
force->addParticle( particle.getDoubleProperty("radius"), particle.getDoubleProperty("epsilon"));
}
}
catch (...) {
delete force;
throw;
}
return force;
}
/* -------------------------------------------------------------------------- *
* OpenMMAmoeba *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "../../../tests/AssertionUtilities.h"
#include "openmm/AmoebaGeneralizedKirkwoodForce.h"
#include "openmm/serialization/XmlSerializer.h"
#include <iostream>
#include <sstream>
using namespace OpenMM;
using namespace std;
void testSerialization() {
// Create a Force.
AmoebaGeneralizedKirkwoodForce force1;
force1.setSolventDielectric( 80.0 );
force1.setSoluteDielectric( 1.0 );
force1.setDielectricOffset( 0.09 );
force1.setProbeRadius( 1.40 );
force1.setSurfaceAreaFactor( 0.888 );
force1.setIncludeCavityTerm( 1 );
force1.addParticle(1.0, 2.0, 0.9);
force1.addParticle(-1.1,2.1, 0.8);
force1.addParticle(0.1, 2.2, 0.7);
// Serialize and then deserialize it.
stringstream buffer;
XmlSerializer::serialize<AmoebaGeneralizedKirkwoodForce>(&force1, "Force", buffer);
if( 0 ){
FILE* filePtr = fopen("GeneralizedKirkwood.xml", "w" );
(void) fprintf( filePtr, "%s", buffer.str().c_str() );
(void) fclose( filePtr );
}
AmoebaGeneralizedKirkwoodForce* copy = XmlSerializer::deserialize<AmoebaGeneralizedKirkwoodForce>(buffer);
// Compare the two forces to see if they are identical.
AmoebaGeneralizedKirkwoodForce& force2 = *copy;
ASSERT_EQUAL(force1.getSolventDielectric(), force2.getSolventDielectric());
ASSERT_EQUAL(force1.getSoluteDielectric(), force2.getSoluteDielectric());
ASSERT_EQUAL(force1.getDielectricOffset(), force2.getDielectricOffset());
ASSERT_EQUAL(force1.getProbeRadius(), force2.getProbeRadius());
ASSERT_EQUAL(force1.getSurfaceAreaFactor(), force2.getSurfaceAreaFactor());
ASSERT_EQUAL(force1.getIncludeCavityTerm(), force2.getIncludeCavityTerm());
ASSERT_EQUAL(force1.getNumParticles(), force2.getNumParticles());
for (unsigned int ii = 0; ii < force1.getNumParticles(); ii++) {
double radius1, charge1, scaleFactor1;
double radius2, charge2, scaleFactor2;
force1.getParticleParameters( ii, charge1, radius1, scaleFactor1 );
force2.getParticleParameters( ii, charge2, radius2, scaleFactor2 );
ASSERT_EQUAL(charge1, charge2);
ASSERT_EQUAL(radius1, radius2);
ASSERT_EQUAL(scaleFactor1, scaleFactor2);
}
}
int main() {
try {
testSerialization();
}
catch(const exception& e) {
cout << "exception: " << e.what() << endl;
return 1;
}
cout << "Done" << endl;
return 0;
}
...@@ -41,34 +41,34 @@ using namespace std; ...@@ -41,34 +41,34 @@ using namespace std;
void testSerialization() { void testSerialization() {
// Create a Force. // Create a Force.
AmoebaHarmonicAngleForce force; AmoebaHarmonicAngleForce force1;
force.setAmoebaGlobalHarmonicAngleCubic( 12.3 ); force1.setAmoebaGlobalHarmonicAngleCubic( 12.3 );
force.setAmoebaGlobalHarmonicAngleQuartic( 98.7 ); force1.setAmoebaGlobalHarmonicAngleQuartic( 98.7 );
force.setAmoebaGlobalHarmonicAnglePentic( 91.7 ); force1.setAmoebaGlobalHarmonicAnglePentic( 91.7 );
force.setAmoebaGlobalHarmonicAngleSextic( 93.7 ); force1.setAmoebaGlobalHarmonicAngleSextic( 93.7 );
force.addAngle(0, 1, 3, 1.0, 2.0); force1.addAngle(0, 1, 3, 1.0, 2.0);
force.addAngle(0, 2, 3, 2.0, 2.1); force1.addAngle(0, 2, 3, 2.0, 2.1);
force.addAngle(2, 3, 5, 3.0, 2.2); force1.addAngle(2, 3, 5, 3.0, 2.2);
force.addAngle(5, 1, 8, 4.0, 2.3); force1.addAngle(5, 1, 8, 4.0, 2.3);
// Serialize and then deserialize it. // Serialize and then deserialize it.
stringstream buffer; stringstream buffer;
XmlSerializer::serialize<AmoebaHarmonicAngleForce>(&force, "Force", buffer); XmlSerializer::serialize<AmoebaHarmonicAngleForce>(&force1, "Force", buffer);
AmoebaHarmonicAngleForce* copy = XmlSerializer::deserialize<AmoebaHarmonicAngleForce>(buffer); AmoebaHarmonicAngleForce* copy = XmlSerializer::deserialize<AmoebaHarmonicAngleForce>(buffer);
// Compare the two forces to see if they are identical. // Compare the two forces to see if they are identical.
AmoebaHarmonicAngleForce& force2 = *copy; AmoebaHarmonicAngleForce& force2 = *copy;
ASSERT_EQUAL(force.getAmoebaGlobalHarmonicAngleCubic(), force2.getAmoebaGlobalHarmonicAngleCubic()); ASSERT_EQUAL(force1.getAmoebaGlobalHarmonicAngleCubic(), force2.getAmoebaGlobalHarmonicAngleCubic());
ASSERT_EQUAL(force.getAmoebaGlobalHarmonicAngleQuartic(), force2.getAmoebaGlobalHarmonicAngleQuartic()); ASSERT_EQUAL(force1.getAmoebaGlobalHarmonicAngleQuartic(), force2.getAmoebaGlobalHarmonicAngleQuartic());
ASSERT_EQUAL(force.getAmoebaGlobalHarmonicAnglePentic(), force2.getAmoebaGlobalHarmonicAnglePentic()); ASSERT_EQUAL(force1.getAmoebaGlobalHarmonicAnglePentic(), force2.getAmoebaGlobalHarmonicAnglePentic());
ASSERT_EQUAL(force.getAmoebaGlobalHarmonicAngleSextic(), force2.getAmoebaGlobalHarmonicAngleSextic()); ASSERT_EQUAL(force1.getAmoebaGlobalHarmonicAngleSextic(), force2.getAmoebaGlobalHarmonicAngleSextic());
ASSERT_EQUAL(force.getNumAngles(), force2.getNumAngles()); ASSERT_EQUAL(force1.getNumAngles(), force2.getNumAngles());
for (int i = 0; i < force.getNumAngles(); i++) { for (unsigned int ii = 0; ii < force1.getNumAngles(); ii++) {
int a1, a2, a3, b1, b2, b3; int a1, a2, a3, b1, b2, b3;
double da, db, ka, kb; double da, db, ka, kb;
force.getAngleParameters(i, a1, a2, a3, da, ka); force1.getAngleParameters(ii, a1, a2, a3, da, ka);
force2.getAngleParameters(i, b1, b2, b3, db, kb); force2.getAngleParameters(ii, b1, b2, b3, db, kb);
ASSERT_EQUAL(a1, b1); ASSERT_EQUAL(a1, b1);
ASSERT_EQUAL(a2, b2); ASSERT_EQUAL(a2, b2);
ASSERT_EQUAL(a3, b3); ASSERT_EQUAL(a3, b3);
......
...@@ -41,30 +41,30 @@ using namespace std; ...@@ -41,30 +41,30 @@ using namespace std;
void testSerialization() { void testSerialization() {
// Create a Force. // Create a Force.
AmoebaHarmonicBondForce force; AmoebaHarmonicBondForce force1;
force.setAmoebaGlobalHarmonicBondCubic( 12.3 ); force1.setAmoebaGlobalHarmonicBondCubic( 12.3 );
force.setAmoebaGlobalHarmonicBondQuartic( 98.7 ); force1.setAmoebaGlobalHarmonicBondQuartic( 98.7 );
force.addBond(0, 1, 1.0, 2.0); force1.addBond(0, 1, 1.0, 2.0);
force.addBond(0, 2, 2.0, 2.1); force1.addBond(0, 2, 2.0, 2.1);
force.addBond(2, 3, 3.0, 2.2); force1.addBond(2, 3, 3.0, 2.2);
force.addBond(5, 1, 4.0, 2.3); force1.addBond(5, 1, 4.0, 2.3);
// Serialize and then deserialize it. // Serialize and then deserialize it.
stringstream buffer; stringstream buffer;
XmlSerializer::serialize<AmoebaHarmonicBondForce>(&force, "Force", buffer); XmlSerializer::serialize<AmoebaHarmonicBondForce>(&force1, "Force", buffer);
AmoebaHarmonicBondForce* copy = XmlSerializer::deserialize<AmoebaHarmonicBondForce>(buffer); AmoebaHarmonicBondForce* copy = XmlSerializer::deserialize<AmoebaHarmonicBondForce>(buffer);
// Compare the two forces to see if they are identical. // Compare the two forces to see if they are identical.
AmoebaHarmonicBondForce& force2 = *copy; AmoebaHarmonicBondForce& force2 = *copy;
ASSERT_EQUAL(force.getAmoebaGlobalHarmonicBondCubic(), force2.getAmoebaGlobalHarmonicBondCubic()); ASSERT_EQUAL(force1.getAmoebaGlobalHarmonicBondCubic(), force2.getAmoebaGlobalHarmonicBondCubic());
ASSERT_EQUAL(force.getAmoebaGlobalHarmonicBondQuartic(), force2.getAmoebaGlobalHarmonicBondQuartic()); ASSERT_EQUAL(force1.getAmoebaGlobalHarmonicBondQuartic(), force2.getAmoebaGlobalHarmonicBondQuartic());
ASSERT_EQUAL(force.getNumBonds(), force2.getNumBonds()); ASSERT_EQUAL(force1.getNumBonds(), force2.getNumBonds());
for (int i = 0; i < force.getNumBonds(); i++) { for (unsigned int ii = 0; ii < force1.getNumBonds(); ii++) {
int a1, a2, b1, b2; int a1, a2, b1, b2;
double da, db, ka, kb; double da, db, ka, kb;
force.getBondParameters(i, a1, a2, da, ka); force1.getBondParameters(ii, a1, a2, da, ka);
force2.getBondParameters(i, b1, b2, db, kb); force2.getBondParameters(ii, b1, b2, db, kb);
ASSERT_EQUAL(a1, b1); ASSERT_EQUAL(a1, b1);
ASSERT_EQUAL(a2, b2); ASSERT_EQUAL(a2, b2);
ASSERT_EQUAL(da, db); ASSERT_EQUAL(da, db);
......
...@@ -41,34 +41,38 @@ using namespace std; ...@@ -41,34 +41,38 @@ using namespace std;
void testSerialization() { void testSerialization() {
// Create a Force. // Create a Force.
AmoebaHarmonicInPlaneAngleForce force; AmoebaHarmonicInPlaneAngleForce force1;
force.setAmoebaGlobalHarmonicInPlaneAngleCubic( 12.3 );
force.setAmoebaGlobalHarmonicInPlaneAngleQuartic( 98.7 ); force1.setAmoebaGlobalHarmonicInPlaneAngleCubic( 12.3 );
force.setAmoebaGlobalHarmonicInPlaneAnglePentic( 91.7 ); force1.setAmoebaGlobalHarmonicInPlaneAngleQuartic( 98.7 );
force.setAmoebaGlobalHarmonicInPlaneAngleSextic( 93.7 ); force1.setAmoebaGlobalHarmonicInPlaneAnglePentic( 91.7 );
force.addAngle(0, 1, 3, 4, 1.0, 2.0); force1.setAmoebaGlobalHarmonicInPlaneAngleSextic( 93.7 );
force.addAngle(0, 2, 3, 5, 2.0, 2.1);
force.addAngle(2, 3, 5, 6, 3.0, 2.2); force1.addAngle(0, 1, 3, 4, 1.0, 2.0);
force.addAngle(5, 1, 8, 8, 4.0, 2.3); force1.addAngle(0, 2, 3, 5, 2.0, 2.1);
force1.addAngle(2, 3, 5, 6, 3.0, 2.2);
force1.addAngle(5, 1, 8, 8, 4.0, 2.3);
// Serialize and then deserialize it. // Serialize and then deserialize it.
stringstream buffer; stringstream buffer;
XmlSerializer::serialize<AmoebaHarmonicInPlaneAngleForce>(&force, "Force", buffer); XmlSerializer::serialize<AmoebaHarmonicInPlaneAngleForce>(&force1, "Force", buffer);
AmoebaHarmonicInPlaneAngleForce* copy = XmlSerializer::deserialize<AmoebaHarmonicInPlaneAngleForce>(buffer); AmoebaHarmonicInPlaneAngleForce* copy = XmlSerializer::deserialize<AmoebaHarmonicInPlaneAngleForce>(buffer);
// Compare the two forces to see if they are identical. // Compare the two forces to see if they are identical.
AmoebaHarmonicInPlaneAngleForce& force2 = *copy; AmoebaHarmonicInPlaneAngleForce& force2 = *copy;
ASSERT_EQUAL(force.getAmoebaGlobalHarmonicInPlaneAngleCubic(), force2.getAmoebaGlobalHarmonicInPlaneAngleCubic());
ASSERT_EQUAL(force.getAmoebaGlobalHarmonicInPlaneAngleQuartic(), force2.getAmoebaGlobalHarmonicInPlaneAngleQuartic()); ASSERT_EQUAL(force1.getAmoebaGlobalHarmonicInPlaneAngleCubic(), force2.getAmoebaGlobalHarmonicInPlaneAngleCubic());
ASSERT_EQUAL(force.getAmoebaGlobalHarmonicInPlaneAnglePentic(), force2.getAmoebaGlobalHarmonicInPlaneAnglePentic()); ASSERT_EQUAL(force1.getAmoebaGlobalHarmonicInPlaneAngleQuartic(), force2.getAmoebaGlobalHarmonicInPlaneAngleQuartic());
ASSERT_EQUAL(force.getAmoebaGlobalHarmonicInPlaneAngleSextic(), force2.getAmoebaGlobalHarmonicInPlaneAngleSextic()); ASSERT_EQUAL(force1.getAmoebaGlobalHarmonicInPlaneAnglePentic(), force2.getAmoebaGlobalHarmonicInPlaneAnglePentic());
ASSERT_EQUAL(force.getNumAngles(), force2.getNumAngles()); ASSERT_EQUAL(force1.getAmoebaGlobalHarmonicInPlaneAngleSextic(), force2.getAmoebaGlobalHarmonicInPlaneAngleSextic());
for (int i = 0; i < force.getNumAngles(); i++) { ASSERT_EQUAL(force1.getNumAngles(), force2.getNumAngles());
for ( unsigned int ii = 0; ii < force1.getNumAngles(); ii++) {
int a1, a2, a3, a4, b1, b2, b3, b4; int a1, a2, a3, a4, b1, b2, b3, b4;
double da, db, ka, kb; double da, db, ka, kb;
force.getAngleParameters(i, a1, a2, a3, a4, da, ka); force1.getAngleParameters(ii, a1, a2, a3, a4, da, ka);
force2.getAngleParameters(i, b1, b2, b3, b4, db, kb); force2.getAngleParameters(ii, b1, b2, b3, b4, db, kb);
ASSERT_EQUAL(a1, b1); ASSERT_EQUAL(a1, b1);
ASSERT_EQUAL(a2, b2); ASSERT_EQUAL(a2, b2);
ASSERT_EQUAL(a3, b3); ASSERT_EQUAL(a3, b3);
......
/* -------------------------------------------------------------------------- *
* OpenMMAmoeba *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "../../../tests/AssertionUtilities.h"
#include "openmm/AmoebaMultipoleForce.h"
#include "openmm/serialization/XmlSerializer.h"
#include <iostream>
#include <sstream>
#include <stdlib.h>
using namespace OpenMM;
using namespace std;
static void getCovalentTypes( std::vector<std::string>& covalentTypes ){
covalentTypes.push_back( "Covalent12" );
covalentTypes.push_back( "Covalent13" );
covalentTypes.push_back( "Covalent14" );
covalentTypes.push_back( "Covalent15" );
covalentTypes.push_back( "PolarizationCovalent11" );
covalentTypes.push_back( "PolarizationCovalent12" );
covalentTypes.push_back( "PolarizationCovalent13" );
covalentTypes.push_back( "PolarizationCovalent14" );
}
void testSerialization() {
// Create a Force.
AmoebaMultipoleForce force1;
force1.setNonbondedMethod( AmoebaMultipoleForce::NoCutoff );
force1.setCutoffDistance( 0.9 );
force1.setAEwald( 0.544 );
force1.setPmeBSplineOrder( 4 );
std::vector<int> gridDimension;
gridDimension.push_back( 64 );
gridDimension.push_back( 63 );
gridDimension.push_back( 61 );
force1.setPmeGridDimensions( gridDimension );
force1.setMutualInducedIterationMethod( AmoebaMultipoleForce::SOR );
force1.setMutualInducedMaxIterations( 200 );
force1.setMutualInducedTargetEpsilon( 1.0e-05 );
force1.setElectricConstant( 138.93 );
force1.setEwaldErrorTolerance( 1.0e-05 );
std::vector<std::string> covalentTypes;
getCovalentTypes( covalentTypes );
for( unsigned int ii = 0; ii < 3; ii++ ){
std::vector<double> molecularDipole;
std::vector<double> molecularQuadrupole;
molecularDipole.push_back( 0.1 ); molecularDipole.push_back( rand() ); molecularDipole.push_back( rand() );
for( unsigned int jj = 0; jj < 9; jj++ ){
molecularQuadrupole.push_back( static_cast<double>(rand()) );
}
force1.addParticle( static_cast<double>(ii+1), molecularDipole, molecularQuadrupole, AmoebaMultipoleForce::Bisector,
ii+1, ii+2, ii+3, static_cast<double>(rand()), static_cast<double>(rand()), static_cast<double>(rand()) );
for( unsigned int jj = 0; jj < covalentTypes.size(); jj++ ){
std::vector< int > covalentMap;
covalentMap.push_back( ii*jj ); covalentMap.push_back( rand() ); covalentMap.push_back( rand() );
force1.setCovalentMap( ii, static_cast<AmoebaMultipoleForce::CovalentType>(jj), covalentMap);
}
}
// Serialize and then deserialize it.
stringstream buffer;
XmlSerializer::serialize<AmoebaMultipoleForce>(&force1, "Force", buffer);
if( 0 ){
FILE* filePtr = fopen("Multipole.xml", "w" );
(void) fprintf( filePtr, "%s", buffer.str().c_str() );
(void) fclose( filePtr );
}
AmoebaMultipoleForce* copy = XmlSerializer::deserialize<AmoebaMultipoleForce>(buffer);
// Compare the two forces to see if they are identical.
AmoebaMultipoleForce& force2 = *copy;
ASSERT_EQUAL(force1.getCutoffDistance(), force2.getCutoffDistance());
ASSERT_EQUAL(force1.getNonbondedMethod(), force2.getNonbondedMethod());
ASSERT_EQUAL(force1.getAEwald(), force2.getAEwald());
ASSERT_EQUAL(force1.getPmeBSplineOrder(), force2.getPmeBSplineOrder());
ASSERT_EQUAL(force1.getMutualInducedIterationMethod(), force2.getMutualInducedIterationMethod());
ASSERT_EQUAL(force1.getMutualInducedMaxIterations(), force2.getMutualInducedMaxIterations());
ASSERT_EQUAL(force1.getMutualInducedTargetEpsilon(), force2.getMutualInducedTargetEpsilon());
ASSERT_EQUAL(force1.getElectricConstant(), force2.getElectricConstant());
ASSERT_EQUAL(force1.getEwaldErrorTolerance(), force2.getEwaldErrorTolerance());
std::vector<int> gridDimension1;
std::vector<int> gridDimension2;
force1.getPmeGridDimensions( gridDimension1 );
force2.getPmeGridDimensions( gridDimension2 );
ASSERT_EQUAL(gridDimension1.size(), gridDimension2.size());
for( unsigned int jj = 0; jj < gridDimension1.size(); jj++ ){
ASSERT_EQUAL(gridDimension1[jj], gridDimension2[jj]);
}
ASSERT_EQUAL(force1.getNumMultipoles(), force2.getNumMultipoles());
for (unsigned int ii = 0; ii < force1.getNumMultipoles(); ii++) {
int axisType1, multipoleAtomZ1, multipoleAtomX1, multipoleAtomY1;
int axisType2, multipoleAtomZ2, multipoleAtomX2, multipoleAtomY2;
double charge1, thole1, dampingFactor1, polarity1;
double charge2, thole2, dampingFactor2, polarity2;
std::vector<double> molecularDipole1;
std::vector<double> molecularQuadrupole1;
std::vector<double> molecularDipole2;
std::vector<double> molecularQuadrupole2;
force1.getMultipoleParameters( ii, charge1, molecularDipole1, molecularQuadrupole1, axisType1, multipoleAtomZ1, multipoleAtomX1, multipoleAtomY1,
thole1, dampingFactor1, polarity1 );
force2.getMultipoleParameters( ii, charge2, molecularDipole2, molecularQuadrupole2, axisType2, multipoleAtomZ2, multipoleAtomX2, multipoleAtomY2,
thole2, dampingFactor2, polarity2 );
ASSERT_EQUAL(charge1, charge2);
ASSERT_EQUAL(axisType1, axisType2);
ASSERT_EQUAL(multipoleAtomZ1, multipoleAtomZ2);
ASSERT_EQUAL(multipoleAtomX1, multipoleAtomX2);
ASSERT_EQUAL(multipoleAtomY1, multipoleAtomY2);
ASSERT_EQUAL(thole1, thole2);
ASSERT_EQUAL(dampingFactor1, dampingFactor2);
ASSERT_EQUAL(polarity1, polarity2);
ASSERT_EQUAL(molecularDipole1.size(), molecularDipole2.size() );
ASSERT_EQUAL(molecularDipole1.size(), 3 );
for (unsigned int jj = 0; jj < molecularDipole1.size(); jj++) {
ASSERT_EQUAL(molecularDipole1[jj], molecularDipole2[jj] );
}
ASSERT_EQUAL(molecularQuadrupole1.size(), molecularQuadrupole2.size() );
ASSERT_EQUAL(molecularQuadrupole1.size(), 9 );
for (unsigned int jj = 0; jj < molecularQuadrupole1.size(); jj++) {
ASSERT_EQUAL(molecularQuadrupole1[jj], molecularQuadrupole2[jj] );
}
for (unsigned int jj = 0; jj < covalentTypes.size(); jj++) {
std::vector<int> covalentMap1;
std::vector<int> covalentMap2;
force1.getCovalentMap( ii, static_cast<AmoebaMultipoleForce::CovalentType>(jj), covalentMap1 );
force2.getCovalentMap( ii, static_cast<AmoebaMultipoleForce::CovalentType>(jj), covalentMap2 );
ASSERT_EQUAL(covalentMap1.size(), covalentMap2.size() );
for (unsigned int kk = 0; kk < covalentMap1.size(); kk++) {
ASSERT_EQUAL(covalentMap1[kk], covalentMap2[kk] );
}
}
}
}
int main() {
try {
testSerialization();
}
catch(const exception& e) {
cout << "exception: " << e.what() << endl;
return 1;
}
cout << "Done" << endl;
return 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