Commit eb232608 authored by John Chodera (MSKCC)'s avatar John Chodera (MSKCC)
Browse files

Merge remote-tracking branch 'upstream/master'

parents 62581e9c 7f8c5089
......@@ -60,7 +60,7 @@ void* AmoebaStretchBendForceProxy::deserialize(const SerializationNode& node) co
AmoebaStretchBendForce* force = new AmoebaStretchBendForce();
try {
const SerializationNode& bonds = node.getChildNode("StretchBendAngles");
for ( unsigned int ii = 0; ii < (int) bonds.getChildren().size(); ii++) {
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("k1"), bond.getDoubleProperty("k2"));
......
......@@ -41,23 +41,23 @@ using namespace std;
AmoebaTorsionTorsionForceProxy::AmoebaTorsionTorsionForceProxy() : SerializationProxy("AmoebaTorsionTorsionForce") {
}
static void loadGrid( const SerializationNode& grid, std::vector< std::vector< std::vector<double> > >& gridVector ){
static void loadGrid(const SerializationNode& grid, std::vector< std::vector< std::vector<double> > >& gridVector) {
const std::vector<SerializationNode>& gridSerializationRows = grid.getChildren();
gridVector.resize( gridSerializationRows.size() );
gridVector.resize(gridSerializationRows.size());
for( unsigned int ii = 0; ii < gridSerializationRows.size(); ii++) {
for (unsigned int ii = 0; ii < gridSerializationRows.size(); ii++) {
const std::vector<SerializationNode>& gridSerializationColumns = gridSerializationRows[ii].getChildren();
gridVector[ii].resize( gridSerializationColumns.size() );
for( unsigned int jj = 0; jj < gridSerializationColumns.size(); jj++) {
gridVector[ii].resize(gridSerializationColumns.size());
for (unsigned int jj = 0; jj < gridSerializationColumns.size(); jj++) {
const SerializationNode& gridSerializationColumnNode = gridSerializationColumns[jj];
gridVector[ii][jj].resize( 6 );
gridVector[ii][jj][0] = gridSerializationColumnNode.getDoubleProperty( "x" );
gridVector[ii][jj][1] = gridSerializationColumnNode.getDoubleProperty( "y" );
gridVector[ii][jj][2] = gridSerializationColumnNode.getDoubleProperty( "f" );
gridVector[ii][jj][3] = gridSerializationColumnNode.getDoubleProperty( "fx" );
gridVector[ii][jj][4] = gridSerializationColumnNode.getDoubleProperty( "fy" );
gridVector[ii][jj][5] = gridSerializationColumnNode.getDoubleProperty( "fxy" );
gridVector[ii][jj].resize(6);
gridVector[ii][jj][0] = gridSerializationColumnNode.getDoubleProperty("x");
gridVector[ii][jj][1] = gridSerializationColumnNode.getDoubleProperty("y");
gridVector[ii][jj][2] = gridSerializationColumnNode.getDoubleProperty("f");
gridVector[ii][jj][3] = gridSerializationColumnNode.getDoubleProperty("fx");
gridVector[ii][jj][4] = gridSerializationColumnNode.getDoubleProperty("fy");
gridVector[ii][jj][5] = gridSerializationColumnNode.getDoubleProperty("fxy");
}
}
}
......@@ -78,28 +78,28 @@ void AmoebaTorsionTorsionForceProxy::serialize(const void* object, Serialization
SerializationNode& grids = node.createChildNode("TorsionTorsionGrids");
for (unsigned int kk = 0; kk < static_cast<unsigned int>(force.getNumTorsionTorsionGrids()); kk++) {
const std::vector< std::vector< std::vector<double> > > grid = force.getTorsionTorsionGrid( kk );
const std::vector< std::vector< std::vector<double> > > grid = force.getTorsionTorsionGrid(kk);
unsigned int gridCount = 0;
unsigned int gridYsize = grid[0].size();
for ( unsigned int ii = 0; ii < grid.size(); ii++) {
for (unsigned int ii = 0; ii < grid.size(); ii++) {
gridCount += grid[ii].size();
}
SerializationNode& gridNode = grids.createChildNode("TorsionTorsionGrid");
for ( unsigned int ii = 0; ii < grid.size(); ii++) {
for (unsigned int ii = 0; ii < grid.size(); ii++) {
SerializationNode& gridSerializationRow = gridNode.createChildNode("RowNode");
gridSerializationRow.setIntProperty("dim", ii );
for ( unsigned int jj = 0; jj < grid[ii].size(); jj++) {
gridSerializationRow.setIntProperty("dim", ii);
for (unsigned int jj = 0; jj < grid[ii].size(); jj++) {
SerializationNode& gridSerializationColumnNode = gridSerializationRow.createChildNode("ColumnNode");
gridSerializationColumnNode.setIntProperty("dim", jj );
gridSerializationColumnNode.setIntProperty("dim", jj);
unsigned int index = 0;
gridSerializationColumnNode.setDoubleProperty("x", grid[ii][jj][index++] );
gridSerializationColumnNode.setDoubleProperty("y", grid[ii][jj][index++] );
gridSerializationColumnNode.setDoubleProperty("f", grid[ii][jj][index++] );
gridSerializationColumnNode.setDoubleProperty("fx", grid[ii][jj][index++] );
gridSerializationColumnNode.setDoubleProperty("fy", grid[ii][jj][index++] );
gridSerializationColumnNode.setDoubleProperty("fxy", grid[ii][jj][index++] );
gridSerializationColumnNode.setDoubleProperty("x", grid[ii][jj][index++]);
gridSerializationColumnNode.setDoubleProperty("y", grid[ii][jj][index++]);
gridSerializationColumnNode.setDoubleProperty("f", grid[ii][jj][index++]);
gridSerializationColumnNode.setDoubleProperty("fx", grid[ii][jj][index++]);
gridSerializationColumnNode.setDoubleProperty("fy", grid[ii][jj][index++]);
gridSerializationColumnNode.setDoubleProperty("fxy", grid[ii][jj][index++]);
}
}
}
......@@ -108,8 +108,8 @@ void AmoebaTorsionTorsionForceProxy::serialize(const void* object, Serialization
for (unsigned int ii = 0; ii < static_cast<unsigned int>(force.getNumTorsionTorsions()); ii++) {
int particle1, particle2, particle3, particle4, particle5;
int 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 );
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);
}
}
......@@ -124,10 +124,10 @@ void* AmoebaTorsionTorsionForceProxy::deserialize(const SerializationNode& node)
const SerializationNode& grids = node.getChildNode("TorsionTorsionGrids");
const std::vector<SerializationNode>& gridList = grids.getChildren();
for( unsigned int ii = 0; ii < gridList.size(); ii++) {
for (unsigned int ii = 0; ii < gridList.size(); ii++) {
std::vector< std::vector< std::vector<double> > > gridVector;
loadGrid( gridList[ii], gridVector );
force->setTorsionTorsionGrid( ii, gridVector );
loadGrid(gridList[ii], gridVector);
force->setTorsionTorsionGrid(ii, gridVector);
}
const SerializationNode& bonds = node.getChildNode("TorsionTorsion");
......
......@@ -56,17 +56,17 @@ void AmoebaVdwForceProxy::serialize(const void* object, SerializationNode& node)
int ivIndex;
double sigma, epsilon, reductionFactor;
force.getParticleParameters( ii, ivIndex, sigma, epsilon, reductionFactor );
force.getParticleParameters(ii, ivIndex, sigma, epsilon, reductionFactor);
SerializationNode& particle = particles.createChildNode("Particle");
particle.setIntProperty("ivIndex", ivIndex).setDoubleProperty("sigma", sigma).setDoubleProperty("epsilon", epsilon).setDoubleProperty("reductionFactor", reductionFactor);
std::vector< int > exclusions;
force.getParticleExclusions( ii, exclusions );
force.getParticleExclusions(ii, exclusions);
SerializationNode& particleExclusions = particle.createChildNode("ParticleExclusions");
for (unsigned int jj = 0; jj < exclusions.size(); jj++) {
particleExclusions.createChildNode( "excl" ).setIntProperty( "index", exclusions[jj] );
particleExclusions.createChildNode("excl").setIntProperty("index", exclusions[jj]);
}
}
}
......@@ -77,9 +77,9 @@ void* AmoebaVdwForceProxy::deserialize(const SerializationNode& node) const {
AmoebaVdwForce* force = new AmoebaVdwForce();
try {
force->setSigmaCombiningRule(node.getStringProperty( "SigmaCombiningRule" ) );
force->setEpsilonCombiningRule(node.getStringProperty( "EpsilonCombiningRule" ) );
force->setCutoff(node.getDoubleProperty( "VdwCutoff" ) );
force->setSigmaCombiningRule(node.getStringProperty("SigmaCombiningRule"));
force->setEpsilonCombiningRule(node.getStringProperty("EpsilonCombiningRule"));
force->setCutoff(node.getDoubleProperty("VdwCutoff"));
force->setNonbondedMethod((AmoebaVdwForce::NonbondedMethod) node.getIntProperty("method"));
const SerializationNode& particles = node.getChildNode("VdwParticles");
......@@ -92,9 +92,9 @@ void* AmoebaVdwForceProxy::deserialize(const SerializationNode& node) const {
const SerializationNode& particleExclusions = particle.getChildNode("ParticleExclusions");
std::vector< int > exclusions;
for (unsigned int jj = 0; jj < particleExclusions.getChildren().size(); jj++) {
exclusions.push_back( particleExclusions.getChildren()[jj].getIntProperty("index") );
exclusions.push_back(particleExclusions.getChildren()[jj].getIntProperty("index"));
}
force->setParticleExclusions( ii, exclusions );
force->setParticleExclusions(ii, exclusions);
}
}
......
......@@ -56,7 +56,7 @@ void AmoebaWcaDispersionForceProxy::serialize(const void* object, SerializationN
SerializationNode& particles = node.createChildNode("WcaDispersionParticles");
for (unsigned int ii = 0; ii < static_cast<unsigned int>(force.getNumParticles()); ii++) {
double radius, epsilon;
force.getParticleParameters( ii, radius, epsilon );
force.getParticleParameters(ii, radius, epsilon);
particles.createChildNode("Particle").setDoubleProperty("radius", radius).setDoubleProperty("epsilon", epsilon);
}
......@@ -69,21 +69,21 @@ void* AmoebaWcaDispersionForceProxy::deserialize(const SerializationNode& node)
try {
force->setEpso( node.getDoubleProperty( "Epso" ) );
force->setEpsh( node.getDoubleProperty( "Epsh" ) );
force->setRmino( node.getDoubleProperty( "Rmino" ) );
force->setRminh( node.getDoubleProperty( "Rminh" ) );
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" ) );
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"));
force->addParticle(particle.getDoubleProperty("radius"), particle.getDoubleProperty("epsilon"));
}
}
......
......@@ -45,10 +45,10 @@ void testSerialization() {
// Create a Force.
AmoebaAngleForce force1;
force1.setAmoebaGlobalAngleCubic( 12.3 );
force1.setAmoebaGlobalAngleQuartic( 98.7 );
force1.setAmoebaGlobalAnglePentic( 91.7 );
force1.setAmoebaGlobalAngleSextic( 93.7 );
force1.setAmoebaGlobalAngleCubic(12.3);
force1.setAmoebaGlobalAngleQuartic(98.7);
force1.setAmoebaGlobalAnglePentic(91.7);
force1.setAmoebaGlobalAngleSextic(93.7);
force1.addAngle(0, 1, 3, 1.0, 2.0);
force1.addAngle(0, 2, 3, 2.0, 2.1);
force1.addAngle(2, 3, 5, 3.0, 2.2);
......
......@@ -45,8 +45,8 @@ void testSerialization() {
// Create a Force.
AmoebaBondForce force1;
force1.setAmoebaGlobalBondCubic( 12.3 );
force1.setAmoebaGlobalBondQuartic( 98.7 );
force1.setAmoebaGlobalBondCubic(12.3);
force1.setAmoebaGlobalBondQuartic(98.7);
force1.addBond(0, 1, 1.0, 2.0);
force1.addBond(0, 2, 2.0, 2.1);
force1.addBond(2, 3, 3.0, 2.2);
......
......@@ -45,12 +45,12 @@ 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.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);
......@@ -60,14 +60,6 @@ void testSerialization() {
stringstream buffer;
XmlSerializer::serialize<AmoebaGeneralizedKirkwoodForce>(&force1, "Force", buffer);
#ifdef AMOEBA_DEBUG
if( 0 ){
FILE* filePtr = fopen("GeneralizedKirkwood.xml", "w" );
(void) fprintf( filePtr, "%s", buffer.str().c_str() );
(void) fclose( filePtr );
}
#endif
AmoebaGeneralizedKirkwoodForce* copy = XmlSerializer::deserialize<AmoebaGeneralizedKirkwoodForce>(buffer);
// Compare the two forces to see if they are identical.
......@@ -85,8 +77,8 @@ void testSerialization() {
double radius1, charge1, scaleFactor1;
double radius2, charge2, scaleFactor2;
force1.getParticleParameters( ii, charge1, radius1, scaleFactor1 );
force2.getParticleParameters( ii, charge2, radius2, scaleFactor2 );
force1.getParticleParameters(ii, charge1, radius1, scaleFactor1);
force2.getParticleParameters(ii, charge2, radius2, scaleFactor2);
ASSERT_EQUAL(charge1, charge2);
ASSERT_EQUAL(radius1, radius2);
......
......@@ -46,10 +46,10 @@ void testSerialization() {
AmoebaInPlaneAngleForce force1;
force1.setAmoebaGlobalInPlaneAngleCubic( 12.3 );
force1.setAmoebaGlobalInPlaneAngleQuartic( 98.7 );
force1.setAmoebaGlobalInPlaneAnglePentic( 91.7 );
force1.setAmoebaGlobalInPlaneAngleSextic( 93.7 );
force1.setAmoebaGlobalInPlaneAngleCubic(12.3);
force1.setAmoebaGlobalInPlaneAngleQuartic(98.7);
force1.setAmoebaGlobalInPlaneAnglePentic(91.7);
force1.setAmoebaGlobalInPlaneAngleSextic(93.7);
force1.addAngle(0, 1, 3, 4, 1.0, 2.0);
force1.addAngle(0, 2, 3, 5, 2.0, 2.1);
......@@ -71,7 +71,7 @@ void testSerialization() {
ASSERT_EQUAL(force1.getAmoebaGlobalInPlaneAngleSextic(), force2.getAmoebaGlobalInPlaneAngleSextic());
ASSERT_EQUAL(force1.getNumAngles(), force2.getNumAngles());
for ( unsigned int ii = 0; ii < static_cast<unsigned int>(force1.getNumAngles()); ii++) {
for (unsigned int ii = 0; ii < static_cast<unsigned int>(force1.getNumAngles()); ii++) {
int a1, a2, a3, a4, b1, b2, b3, b4;
double da, db, ka, kb;
force1.getAngleParameters(ii, a1, a2, a3, a4, da, ka);
......
......@@ -42,56 +42,56 @@ using namespace std;
extern "C" void registerAmoebaSerializationProxies();
static void getCovalentTypes( std::vector<std::string>& covalentTypes ){
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("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" );
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 );
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 );
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 );
getCovalentTypes(covalentTypes);
for( unsigned int ii = 0; ii < 3; ii++ ){
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()) );
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.addMultipole( 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()) );
force1.addMultipole(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++ ){
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);
covalentMap.push_back(ii*jj); covalentMap.push_back(rand()); covalentMap.push_back(rand());
force1.setCovalentMap(ii, static_cast<AmoebaMultipoleForce::CovalentType>(jj), covalentMap);
}
}
......@@ -99,13 +99,6 @@ void testSerialization() {
stringstream buffer;
XmlSerializer::serialize<AmoebaMultipoleForce>(&force1, "Force", buffer);
#ifdef AMOEBA_DEBUG
if( 0 ){
FILE* filePtr = fopen("Multipole.xml", "w" );
(void) fprintf( filePtr, "%s", buffer.str().c_str() );
(void) fclose( filePtr );
}
#endif
AmoebaMultipoleForce* copy = XmlSerializer::deserialize<AmoebaMultipoleForce>(buffer);
......@@ -125,10 +118,10 @@ void testSerialization() {
std::vector<int> gridDimension1;
std::vector<int> gridDimension2;
force1.getPmeGridDimensions( gridDimension1 );
force2.getPmeGridDimensions( gridDimension2 );
force1.getPmeGridDimensions(gridDimension1);
force2.getPmeGridDimensions(gridDimension2);
ASSERT_EQUAL(gridDimension1.size(), gridDimension2.size());
for( unsigned int jj = 0; jj < gridDimension1.size(); jj++ ){
for (unsigned int jj = 0; jj < gridDimension1.size(); jj++) {
ASSERT_EQUAL(gridDimension1[jj], gridDimension2[jj]);
}
......@@ -147,11 +140,11 @@ void testSerialization() {
std::vector<double> molecularDipole2;
std::vector<double> molecularQuadrupole2;
force1.getMultipoleParameters( ii, charge1, molecularDipole1, molecularQuadrupole1, axisType1, multipoleAtomZ1, multipoleAtomX1, multipoleAtomY1,
thole1, dampingFactor1, polarity1 );
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 );
force2.getMultipoleParameters(ii, charge2, molecularDipole2, molecularQuadrupole2, axisType2, multipoleAtomZ2, multipoleAtomX2, multipoleAtomY2,
thole2, dampingFactor2, polarity2);
ASSERT_EQUAL(charge1, charge2);
ASSERT_EQUAL(axisType1, axisType2);
......@@ -162,25 +155,25 @@ void testSerialization() {
ASSERT_EQUAL(dampingFactor1, dampingFactor2);
ASSERT_EQUAL(polarity1, polarity2);
ASSERT_EQUAL(molecularDipole1.size(), molecularDipole2.size() );
ASSERT_EQUAL(molecularDipole1.size(), 3 );
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(molecularDipole1[jj], molecularDipole2[jj]);
}
ASSERT_EQUAL(molecularQuadrupole1.size(), molecularQuadrupole2.size() );
ASSERT_EQUAL(molecularQuadrupole1.size(), 9 );
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] );
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() );
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] );
ASSERT_EQUAL(covalentMap1[kk], covalentMap2[kk]);
}
}
}
......
......@@ -46,10 +46,10 @@ void testSerialization() {
AmoebaOutOfPlaneBendForce force1;
force1.setAmoebaGlobalOutOfPlaneBendCubic( 12.3 );
force1.setAmoebaGlobalOutOfPlaneBendQuartic( 98.7 );
force1.setAmoebaGlobalOutOfPlaneBendPentic( 91.7 );
force1.setAmoebaGlobalOutOfPlaneBendSextic( 93.7 );
force1.setAmoebaGlobalOutOfPlaneBendCubic(12.3);
force1.setAmoebaGlobalOutOfPlaneBendQuartic(98.7);
force1.setAmoebaGlobalOutOfPlaneBendPentic(91.7);
force1.setAmoebaGlobalOutOfPlaneBendSextic(93.7);
force1.addOutOfPlaneBend(0, 1, 3, 4, 2.0);
force1.addOutOfPlaneBend(0, 2, 3, 5, 2.1);
......
......@@ -42,27 +42,27 @@ using namespace std;
extern "C" void registerAmoebaSerializationProxies();
static void loadTorsionTorsionGrid( std::vector< std::vector< std::vector<double> > >& gridVector ){
static void loadTorsionTorsionGrid(std::vector< std::vector< std::vector<double> > >& gridVector) {
static const int gridSize = 25;
gridVector.resize( gridSize );
for( unsigned int ii = 0; ii < gridSize; ii++ ){
gridVector[ii].resize( gridSize );
for( unsigned int jj = 0; jj < gridSize; jj++ ){
gridVector[ii][jj].resize( 6 );
for( unsigned int kk = 0; kk < 6; kk++ ){
gridVector.resize(gridSize);
for (unsigned int ii = 0; ii < gridSize; ii++) {
gridVector[ii].resize(gridSize);
for (unsigned int jj = 0; jj < gridSize; jj++) {
gridVector[ii][jj].resize(6);
for (unsigned int kk = 0; kk < 6; kk++) {
gridVector[ii][jj][0] = -180.0 + 15.0*static_cast<double>(ii);
gridVector[ii][jj][1] = -180.0 + 15.0*static_cast<double>(jj);
gridVector[ii][jj][2] = static_cast<double>( rand());
gridVector[ii][jj][3] = static_cast<double>( rand());
gridVector[ii][jj][4] = static_cast<double>( rand());
gridVector[ii][jj][5] = static_cast<double>( rand());
gridVector[ii][jj][2] = static_cast<double>(rand());
gridVector[ii][jj][3] = static_cast<double>(rand());
gridVector[ii][jj][4] = static_cast<double>(rand());
gridVector[ii][jj][5] = static_cast<double>(rand());
}
}
}
}
static void compareGrids( const std::vector< std::vector< std::vector<double> > >& grid1, const std::vector< std::vector< std::vector<double> > >& grid2 ) {
static void compareGrids(const std::vector< std::vector< std::vector<double> > >& grid1, const std::vector< std::vector< std::vector<double> > >& grid2) {
ASSERT_EQUAL(grid1.size(), grid2.size());
for (unsigned int ii = 0; ii < grid1.size(); ii++) {
......@@ -81,27 +81,19 @@ void testSerialization() {
AmoebaTorsionTorsionForce force1;
for( unsigned int ii = 0; ii < 5; ii++ ){
for (unsigned int ii = 0; ii < 5; ii++) {
std::vector< std::vector< std::vector<double> > > gridVector;
loadTorsionTorsionGrid( gridVector );
force1.setTorsionTorsionGrid( ii, gridVector );
loadTorsionTorsionGrid(gridVector);
force1.setTorsionTorsionGrid(ii, gridVector);
}
for( unsigned int ii = 0; ii < 5; ii++ ){
force1.addTorsionTorsion( ii, ii+1,ii+3, ii+4, ii+5, ( (ii % 2 ) ? 1 : 0), (ii % 4) );
for (unsigned int ii = 0; ii < 5; ii++) {
force1.addTorsionTorsion(ii, ii+1,ii+3, ii+4, ii+5, ((ii % 2) ? 1 : 0), (ii % 4));
}
// Serialize and then deserialize it.
stringstream buffer;
XmlSerializer::serialize<AmoebaTorsionTorsionForce>(&force1, "Force", buffer);
#ifdef AMOEBA_DEBUG
if( 0 ){
FILE* filePtr = fopen("TorsionTorsion.xml", "w" );
(void) fprintf( filePtr, "%s", buffer.str().c_str() );
(void) fclose( filePtr );
}
#endif
AmoebaTorsionTorsionForce* copy = XmlSerializer::deserialize<AmoebaTorsionTorsionForce>(buffer);
// Compare the two force1s to see if they are identical.
......@@ -112,8 +104,8 @@ void testSerialization() {
int a1, a2, a3, a4, a5, aChiral, aGridIndex, b1, b2, b3, b4, b5, bChiral, bGridIndex;
force1.getTorsionTorsionParameters( ii, a1, a2, a3, a4, a5, aChiral, aGridIndex);
force2.getTorsionTorsionParameters( ii, b1, b2, b3, b4, b5, bChiral, bGridIndex);
force1.getTorsionTorsionParameters(ii, a1, a2, a3, a4, a5, aChiral, aGridIndex);
force2.getTorsionTorsionParameters(ii, b1, b2, b3, b4, b5, bChiral, bGridIndex);
ASSERT_EQUAL(a1, b1);
ASSERT_EQUAL(a2, b2);
......@@ -121,14 +113,14 @@ void testSerialization() {
ASSERT_EQUAL(a4, b4);
ASSERT_EQUAL(a5, b5);
ASSERT_EQUAL(aChiral, bChiral);
ASSERT_EQUAL(aGridIndex, bGridIndex );
ASSERT_EQUAL(aGridIndex, bGridIndex);
}
ASSERT_EQUAL(force1.getNumTorsionTorsionGrids(), force2.getNumTorsionTorsionGrids());
for (unsigned int ii = 0; ii < static_cast<unsigned int>(force1.getNumTorsionTorsionGrids()); ii++) {
const std::vector< std::vector< std::vector<double> > >& grid1 = force1.getTorsionTorsionGrid( ii );
const std::vector< std::vector< std::vector<double> > >& grid2 = force2.getTorsionTorsionGrid( ii );
compareGrids(grid1, grid2 );
const std::vector< std::vector< std::vector<double> > >& grid1 = force1.getTorsionTorsionGrid(ii);
const std::vector< std::vector< std::vector<double> > >& grid2 = force2.getTorsionTorsionGrid(ii);
compareGrids(grid1, grid2);
}
}
......
......@@ -45,34 +45,26 @@ void testSerialization() {
// Create a Force.
AmoebaVdwForce force1;
force1.setSigmaCombiningRule( "GEOMETRIC" );
force1.setEpsilonCombiningRule( "GEOMETRIC" );
force1.setCutoff( 0.9 );
force1.setSigmaCombiningRule("GEOMETRIC");
force1.setEpsilonCombiningRule("GEOMETRIC");
force1.setCutoff(0.9);
force1.setNonbondedMethod(AmoebaVdwForce::CutoffPeriodic);
force1.addParticle(0, 1.0, 2.0, 0.9);
force1.addParticle(1, 1.1, 2.1, 0.9);
force1.addParticle(2, 1.3, 4.1, 0.9);
for( unsigned int ii = 0; ii < 3; ii++ ){
for (unsigned int ii = 0; ii < 3; ii++) {
std::vector< int > exclusions;
exclusions.push_back( ii );
exclusions.push_back( ii + 1 );
exclusions.push_back( ii + 10 );
force1.setParticleExclusions( ii, exclusions );
exclusions.push_back(ii);
exclusions.push_back(ii + 1);
exclusions.push_back(ii + 10);
force1.setParticleExclusions(ii, exclusions);
}
// Serialize and then deserialize it.
stringstream buffer;
XmlSerializer::serialize<AmoebaVdwForce>(&force1, "Force", buffer);
#ifdef AMOEBA_DEBUG
if( 0 ){
FILE* filePtr = fopen("Vdw.xml", "w" );
(void) fprintf( filePtr, "%s", buffer.str().c_str() );
(void) fclose( filePtr );
}
#endif
AmoebaVdwForce* copy = XmlSerializer::deserialize<AmoebaVdwForce>(buffer);
// Compare the two forces to see if they are identical.
......@@ -93,10 +85,10 @@ void testSerialization() {
double sigma1, epsilon1, reductionFactor1;
double sigma2, epsilon2, reductionFactor2;
force1.getParticleParameters( ii, ivIndex1, sigma1, epsilon1, reductionFactor1 );
force2.getParticleParameters( ii, ivIndex2, sigma2, epsilon2, reductionFactor2 );
force1.getParticleParameters(ii, ivIndex1, sigma1, epsilon1, reductionFactor1);
force2.getParticleParameters(ii, ivIndex2, sigma2, epsilon2, reductionFactor2);
ASSERT_EQUAL(ivIndex1, ivIndex2 );
ASSERT_EQUAL(ivIndex1, ivIndex2);
ASSERT_EQUAL(sigma1, sigma2);
ASSERT_EQUAL(epsilon1, epsilon2);
ASSERT_EQUAL(reductionFactor1, reductionFactor2);
......@@ -106,14 +98,14 @@ void testSerialization() {
std::vector< int > exclusions1;
std::vector< int > exclusions2;
force1.getParticleExclusions( ii, exclusions1 );
force2.getParticleExclusions( ii, exclusions2 );
force1.getParticleExclusions(ii, exclusions1);
force2.getParticleExclusions(ii, exclusions2);
ASSERT_EQUAL(exclusions1.size(), exclusions2.size());
for (unsigned int jj = 0; jj < exclusions1.size(); jj++) {
int hit = 0;
for (unsigned int kk = 0; kk < exclusions2.size(); kk++) {
if( exclusions2[jj] == exclusions1[kk] )hit++;
if (exclusions2[jj] == exclusions1[kk])hit++;
}
ASSERT_EQUAL(hit, 1);
}
......
......@@ -45,14 +45,14 @@ void testSerialization() {
// Create a Force.
AmoebaWcaDispersionForce force1;
force1.setEpso( 1.0 );
force1.setEpsh( 1.1 );
force1.setRmino( 1.2 );
force1.setRminh( 1.3 );
force1.setAwater( 1.4 );
force1.setShctd( 1.5 );
force1.setDispoff( 1.6 );
force1.setSlevy( 1.7 );
force1.setEpso( 1.0);
force1.setEpsh( 1.1);
force1.setRmino( 1.2);
force1.setRminh( 1.3);
force1.setAwater( 1.4);
force1.setShctd( 1.5);
force1.setDispoff(1.6);
force1.setSlevy( 1.7);
force1.addParticle(1.0, 2.0);
force1.addParticle(1.1, 2.1);
......@@ -62,14 +62,6 @@ void testSerialization() {
stringstream buffer;
XmlSerializer::serialize<AmoebaWcaDispersionForce>(&force1, "Force", buffer);
#ifdef AMOEBA_DEBUG
if( 0 ){
FILE* filePtr = fopen("WcaDispersion.xml", "w" );
(void) fprintf( filePtr, "%s", buffer.str().c_str() );
(void) fclose( filePtr );
}
#endif
AmoebaWcaDispersionForce* copy = XmlSerializer::deserialize<AmoebaWcaDispersionForce>(buffer);
// Compare the two forces to see if they are identical.
......@@ -91,8 +83,8 @@ void testSerialization() {
double radius1, epsilon1;
double radius2, epsilon2;
force1.getParticleParameters( ii, radius1, epsilon1 );
force2.getParticleParameters( ii, radius2, epsilon2 );
force1.getParticleParameters(ii, radius1, epsilon1);
force2.getParticleParameters(ii, radius2, epsilon2);
ASSERT_EQUAL(radius1, radius2);
ASSERT_EQUAL(epsilon1, epsilon2);
......
......@@ -327,7 +327,7 @@ extern "C" {
/* OpenMM_3D_DoubleArray */
OPENMM_EXPORT_AMOEBA OpenMM_3D_DoubleArray* OpenMM_3D_DoubleArray_create(int size1, int size2, int size3);
OPENMM_EXPORT_AMOEBA void OpenMM_3D_DoubleArray_set(OpenMM_3D_DoubleArray* array, int index1, int index2, OpenMM_DoubleArray* values);
OPENMM_EXPORT_AMOEBA void OpenMM_3D_DoubleArray_destroy( OpenMM_3D_DoubleArray* array);""", file=self.out)
OPENMM_EXPORT_AMOEBA void OpenMM_3D_DoubleArray_destroy(OpenMM_3D_DoubleArray* array);""", file=self.out)
self.writeClasses()
......@@ -586,29 +586,29 @@ OPENMM_EXPORT_AMOEBA int OpenMM_2D_IntArray_getSize(const OpenMM_2D_IntArray* ar
OPENMM_EXPORT_AMOEBA void OpenMM_2D_IntArray_resize(OpenMM_2D_IntArray* array, int size) {
reinterpret_cast<vector<vector<int> >*>(array)->resize(size);
}
OPENMM_EXPORT_AMOEBA void OpenMM_2D_IntArray_append(OpenMM_2D_IntArray* array, int index1, int value ) {
OPENMM_EXPORT_AMOEBA void OpenMM_2D_IntArray_append(OpenMM_2D_IntArray* array, int index1, int value) {
vector<vector<int> >* array2DInt = reinterpret_cast<vector<vector<int> >*>(array);
if( array2DInt->size() <= index1 ){
array2DInt->resize( index1+1 );
if (array2DInt->size() <= index1) {
array2DInt->resize(index1+1);
}
(*array2DInt)[index1].push_back( value );
(*array2DInt)[index1].push_back(value);
}
OPENMM_EXPORT_AMOEBA void OpenMM_2D_IntArray_set(OpenMM_2D_IntArray* array, int index1, int index2, int value) {
vector<vector<int> >* array2DInt = reinterpret_cast<vector<vector<int> >*>(array);
if( array2DInt->size() <= index1 ){
array2DInt->resize( index1+1 );
if (array2DInt->size() <= index1) {
array2DInt->resize(index1+1);
}
if( array2DInt[index1].size() <= index2 ){
array2DInt[index1].resize( index2+1 );
if (array2DInt[index1].size() <= index2) {
array2DInt[index1].resize(index2+1);
}
(*array2DInt)[index1][index2] = value;
}
OPENMM_EXPORT_AMOEBA void OpenMM_2D_IntArray_get(const OpenMM_2D_IntArray* array, int index1, int index2, int* value) {
const vector<vector<int> >* array2DInt = reinterpret_cast<const vector<vector<int> >*>(array);
if ( array2DInt->size() <= index1 )
if (array2DInt->size() <= index1)
throw OpenMMException("OpenMM_2D_IntArray_get: first index out of range.");
if ( (*array2DInt)[index1].size() <= index2 )
if ((*array2DInt)[index1].size() <= index2)
throw OpenMMException("OpenMM_2D_IntArray_get: second index out of range.");
*value = (*array2DInt)[index1][index2];
}
......@@ -618,9 +618,9 @@ OPENMM_EXPORT_AMOEBA OpenMM_3D_DoubleArray* OpenMM_3D_DoubleArray_create(int siz
int ii, jj;
std::vector< std::vector< std::vector<double> > >* v3D_Array = new std::vector<std::vector<std::vector<double> > >(size1);
for( ii = 0; ii < size1; ii++ ){
for (ii = 0; ii < size1; ii++) {
(*v3D_Array)[ii].resize(size2);
for( jj = 0; jj < size2; jj++ ){
for (jj = 0; jj < size2; jj++) {
(*v3D_Array)[ii][jj].resize(size3);
}
}
......@@ -631,12 +631,12 @@ OPENMM_EXPORT_AMOEBA void OpenMM_3D_DoubleArray_set(OpenMM_3D_DoubleArray* array
unsigned int ii;
std::vector< std::vector< std::vector<double> > >* v3D_Array = reinterpret_cast<std::vector<std::vector<std::vector<double> > >*>(array);
std::vector<double> * value_array = reinterpret_cast<std::vector<double> *>(values);
for( ii = 0; ii < (*value_array).size(); ii++ ){
for (ii = 0; ii < (*value_array).size(); ii++) {
(*v3D_Array)[index1][index2][ii] = (*value_array)[ii];
}
}
OPENMM_EXPORT_AMOEBA void OpenMM_3D_DoubleArray_destroy( OpenMM_3D_DoubleArray* array) {
OPENMM_EXPORT_AMOEBA void OpenMM_3D_DoubleArray_destroy(OpenMM_3D_DoubleArray* array) {
delete reinterpret_cast<std::vector<std::vector<std::vector<double> > >*>(array);
}""", file=self.out)
......
......@@ -99,7 +99,7 @@ void testWater() {
// Create a box of SWM4-NDP water molecules. This involves constraints, virtual sites,
// and Drude particles.
const int gridSize = 4;
const int gridSize = 3;
const int numMolecules = gridSize*gridSize*gridSize;
const double spacing = 0.6;
const double boxSize = spacing*(gridSize+1);
......
......@@ -54,7 +54,7 @@ void testWater() {
// Create a box of SWM4-NDP water molecules. This involves constraints, virtual sites,
// and Drude particles.
const int gridSize = 4;
const int gridSize = 3;
const int numMolecules = gridSize*gridSize*gridSize;
const double spacing = 0.6;
const double boxSize = spacing*(gridSize+1);
......
#ifndef OPENMM_RPMDMONTECARLOBAROSTAT_H_
#define OPENMM_RPMDMONTECARLOBAROSTAT_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* 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-2015 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/Force.h"
#include <string>
#include "internal/windowsExportRpmd.h"
namespace OpenMM {
/**
* This class is very similar to MonteCarloBarostat, but it is specifically designed for use
* with RPMDIntegrator. For each trial move, it scales all copies of the system by the same
* amount, then accepts or rejects the move based on the change to the total energy of the
* ring polymer (as returned by the integrator's getTotalEnergy() method).
*/
class OPENMM_EXPORT_RPMD RPMDMonteCarloBarostat : public Force {
public:
/**
* This is the name of the parameter which stores the current pressure acting on
* the system (in bar).
*/
static const std::string& Pressure() {
static const std::string key = "RPMDMonteCarloPressure";
return key;
}
/**
* Create a MonteCarloBarostat.
*
* @param defaultPressure the default pressure acting on the system (in bar)
* @param frequency the frequency at which Monte Carlo pressure changes should be attempted (in time steps)
*/
RPMDMonteCarloBarostat(double defaultPressure, int frequency = 25);
/**
* Get the default pressure acting on the system (in bar).
*
* @return the default pressure acting on the system, measured in bar.
*/
double getDefaultPressure() const {
return defaultPressure;
}
/**
* Set the default pressure acting on the system. This will affect any new Contexts you create,
* but not ones that already exist.
*
* @param pressure the default pressure acting on the system, measured in bar.
*/
void setDefaultPressure(double pressure) {
defaultPressure = pressure;
}
/**
* Get the frequency (in time steps) at which Monte Carlo pressure changes should be attempted. If this is set to
* 0, the barostat is disabled.
*/
int getFrequency() const {
return frequency;
}
/**
* Set the frequency (in time steps) at which Monte Carlo pressure changes should be attempted. If this is set to
* 0, the barostat is disabled.
*/
void setFrequency(int freq) {
frequency = freq;
}
/**
* Get the random number seed. See setRandomNumberSeed() for details.
*/
int getRandomNumberSeed() const {
return randomNumberSeed;
}
/**
* Set the random number seed. It is guaranteed that if two simulations are run
* with different random number seeds, the sequence of Monte Carlo steps will be different. On
* the other hand, no guarantees are made about the behavior of simulations that use the same seed.
* In particular, Platforms are permitted to use non-deterministic algorithms which produce different
* results on successive runs, even if those runs were initialized identically.
*
* If seed is set to 0 (which is the default value assigned), a unique seed is chosen when a Context
* is created from this Force. This is done to ensure that each Context receives unique random seeds
* without you needing to set them explicitly.
*/
void setRandomNumberSeed(int seed) {
randomNumberSeed = seed;
}
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if force uses PBC and false otherwise
*/
bool usesPeriodicBoundaryConditions() const {
return true;
}
protected:
ForceImpl* createImpl() const;
private:
double defaultPressure;
int frequency, randomNumberSeed;
};
} // namespace OpenMM
#endif /*OPENMM_RPMDMONTECARLOBAROSTAT_H_*/
#ifndef OPENMM_RPMDUPDATER_H_
#define OPENMM_RPMDUPDATER_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* 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) 2015 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/internal/ForceImpl.h"
#include "internal/windowsExportRpmd.h"
namespace OpenMM {
/**
* This ForceImpl subclass is for forces specifically designed to work with RPMDIntegrator.
* It adds an updateRPMDState() method that is invoked at the start of each time step
* (in contrast to updateContextState(), which gets invoked many times per time step, once
* for each copy).
*/
class OPENMM_EXPORT_RPMD RPMDUpdater : public ForceImpl {
public:
virtual void updateRPMDState(ContextImpl& context) = 0;
};
} // namespace OpenMM
#endif /*OPENMM_RPMDUPDATER_H_*/
#ifndef OPENMM_RPMDMONTECARLOBAROSTATIMPL_H_
#define OPENMM_RPMDMONTECARLOBAROSTATIMPL_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* 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-2015 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/RPMDMonteCarloBarostat.h"
#include "openmm/RPMDUpdater.h"
#include "openmm/Kernel.h"
#include "openmm/Vec3.h"
#include "sfmt/SFMT.h"
#include <string>
#include <vector>
namespace OpenMM {
/**
* This is the internal implementation of RPMDMonteCarloBarostat.
*/
class RPMDMonteCarloBarostatImpl : public RPMDUpdater {
public:
RPMDMonteCarloBarostatImpl(const RPMDMonteCarloBarostat& owner);
void initialize(ContextImpl& context);
const RPMDMonteCarloBarostat& getOwner() const {
return owner;
}
void updateRPMDState(ContextImpl& context);
void updateContextState(ContextImpl& context) {
// This is unused, since the updating is done in updateRPMDState().
}
double calcForcesAndEnergy(ContextImpl& context, bool includeForces, bool includeEnergy, int groups) {
// This force doesn't apply forces to particles.
return 0.0;
}
std::map<std::string, double> getDefaultParameters();
std::vector<std::string> getKernelNames();
private:
const RPMDMonteCarloBarostat& owner;
int step, numAttempted, numAccepted;
double volumeScale;
OpenMM_SFMT::SFMT random;
std::vector<std::vector<Vec3> > savedPositions;
Kernel kernel;
};
} // namespace OpenMM
#endif /*OPENMM_RPMDMONTECARLOBAROSTATIMPL_H_*/
......@@ -34,6 +34,7 @@
#include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/RpmdKernels.h"
#include "openmm/RPMDUpdater.h"
#include "SimTKOpenMMRealType.h"
#include <cmath>
#include <string>
......@@ -190,6 +191,12 @@ void RPMDIntegrator::step(int steps) {
context->getOwner().setPositions(p);
isFirstStep = false;
}
vector<ForceImpl*>& forceImpls = context->getForceImpls();
for (int i = 0; i < (int) forceImpls.size(); i++) {
RPMDUpdater* updater = dynamic_cast<RPMDUpdater*>(forceImpls[i]);
if (updater != NULL)
updater->updateRPMDState(*context);
}
for (int i = 0; i < steps; ++i) {
kernel.getAs<IntegrateRPMDStepKernel>().execute(*context, *this, forcesAreValid);
forcesAreValid = true;
......
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