Commit cf3d54fc authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

More serialization proxies

parent 3c3df452
#ifndef OPENMM_AMOEBA_GENERALIZED_KIRKWOOD_FORCE_PROXY_H_
#define OPENMM_AMOEBA_GENERALIZED_KIRKWOOD_FORCE_PROXY_H_
/* -------------------------------------------------------------------------- *
* 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/internal/windowsExport.h"
#include "openmm/serialization/SerializationProxy.h"
namespace OpenMM {
/**
* This is a proxy for serializing AmoebaUreyBradleyForce objects.
*/
class OPENMM_EXPORT AmoebaGeneralizedKirkwoodForceProxy : public SerializationProxy {
public:
AmoebaGeneralizedKirkwoodForceProxy();
void serialize(const void* object, SerializationNode& node) const;
void* deserialize(const SerializationNode& node) const;
};
} // namespace OpenMM
#endif /*OPENMM_AMOEBA_GENERALIZED_KIRKWOOD_FORCE_PROXY_H_*/
#ifndef OPENMM_AMOEBA_MULTIPOLE_FORCE_PROXY_H_
#define OPENMM_AMOEBA_MULTIPOLE_FORCE_PROXY_H_
/* -------------------------------------------------------------------------- *
* 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/internal/windowsExport.h"
#include "openmm/serialization/SerializationProxy.h"
namespace OpenMM {
/**
* This is a proxy for serializing AmoebaUreyBradleyForce objects.
*/
class OPENMM_EXPORT AmoebaMultipole : public SerializationProxy {
public:
AmoebaMultipole();
void serialize(const void* object, SerializationNode& node) const;
void* deserialize(const SerializationNode& node) const;
};
} // namespace OpenMM
#endif /*OPENMM_AMOEBA_UREY_BRADLEY_FORCE_PROXY_H_*/
#ifndef OPENMM_AMOEBA_STRETCH_BEND_FORCE_PROXY_H_
#define OPENMM_AMOEBA_STRETCH_BEND_FORCE_PROXY_H_
/* -------------------------------------------------------------------------- *
* 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/internal/windowsExport.h"
#include "openmm/serialization/SerializationProxy.h"
namespace OpenMM {
/**
* This is a proxy for serializing AmoebaUreyBradleyForce objects.
*/
class OPENMM_EXPORT AmoebaStretchBendForceProxy : public SerializationProxy {
public:
AmoebaStretchBendForceProxy();
void serialize(const void* object, SerializationNode& node) const;
void* deserialize(const SerializationNode& node) const;
};
} // namespace OpenMM
#endif /*OPENMM_AMOEBA_STRETCH_BEND_FORCE_PROXY_H_*/
#ifndef OPENMM_AMOEBA_VDW_FORCE_PROXY_H_
#define OPENMM_AMOEBA_VDW_FORCE_PROXY_H_
/* -------------------------------------------------------------------------- *
* 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/internal/windowsExport.h"
#include "openmm/serialization/SerializationProxy.h"
namespace OpenMM {
/**
* This is a proxy for serializing AmoebaUreyBradleyForce objects.
*/
class OPENMM_EXPORT AmoebaVdwForceProxy : public SerializationProxy {
public:
AmoebaVdwForceProxy();
void serialize(const void* object, SerializationNode& node) const;
void* deserialize(const SerializationNode& node) const;
};
} // namespace OpenMM
#endif /*OPENMM_AMOEBA_VDW_FORCE_PROXY_H_*/
#ifndef OPENMM_AMOEBA_WCA_DISPERSION_FORCE_PROXY_H_
#define OPENMM_AMOEBA_WCA_DISPERSION_FORCE_PROXY_H_
/* -------------------------------------------------------------------------- *
* 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/internal/windowsExport.h"
#include "openmm/serialization/SerializationProxy.h"
namespace OpenMM {
/**
* This is a proxy for serializing AmoebaUreyBradleyForce objects.
*/
class OPENMM_EXPORT AmoebaWcaDispersionForceProxy : public SerializationProxy {
public:
AmoebaWcaDispersionForceProxy();
void serialize(const void* object, SerializationNode& node) const;
void* deserialize(const SerializationNode& node) const;
};
} // namespace OpenMM
#endif /*OPENMM_AMOEBA_WCA_DISPERSION_FORCE_PROXY_H_*/
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#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/serialization/SerializationProxy.h" #include "openmm/serialization/SerializationProxy.h"
#include "openmm/serialization/AmoebaHarmonicBondForceProxy.h" #include "openmm/serialization/AmoebaHarmonicBondForceProxy.h"
...@@ -57,6 +58,7 @@ ...@@ -57,6 +58,7 @@
#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"
#if defined(WIN32) #if defined(WIN32)
#include <windows.h> #include <windows.h>
...@@ -107,4 +109,5 @@ extern "C" void registerAmoebaSerializationProxies() { ...@@ -107,4 +109,5 @@ extern "C" void registerAmoebaSerializationProxies() {
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());
} }
/* -------------------------------------------------------------------------- *
* 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/AmoebaVdwForceProxy.h"
#include "openmm/serialization/SerializationNode.h"
#include "openmm/Force.h"
#include "openmm/AmoebaVdwForce.h"
#include <sstream>
using namespace OpenMM;
using namespace std;
AmoebaVdwForceProxy::AmoebaVdwForceProxy() : SerializationProxy("AmoebaVdwForce") {
}
void AmoebaVdwForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const AmoebaVdwForce& force = *reinterpret_cast<const AmoebaVdwForce*>(object);
node.setStringProperty("SigmaCombiningRule", force.getSigmaCombiningRule());
node.setStringProperty("EpsilonCombiningRule", force.getEpsilonCombiningRule());
node.setDoubleProperty("VdwCutoff", force.getCutoff());
node.setIntProperty("VdwUseNeighborList", force.getUseNeighborList());
node.setIntProperty("VdwPBC", force.getPBC());
SerializationNode& particles = node.createChildNode("VdwParticles");
for (int i = 0; i < force.getNumParticles(); i++) {
int ivIndex, classIndex;
double sigma, epsilon, reductionFactor;
force.getParticleParameters( i, 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& particleExclusions = node.createChildNode("VdwParticleExclusions");
for (int i = 0; i < force.getNumParticles(); i++) {
std::vector< int > exclusions;
force.getParticleExclusions( i, exclusions );
SerializationNode& particle = particleExclusions.createChildNode("ParticleExclusion");
particle.setIntProperty("size", exclusions.size() );
particle.setIntProperty("index", i );
for (unsigned int jj = 0; jj < exclusions.size(); jj++) {
particle.createChildNode("ParticleExclusion").setIntProperty( "ex", exclusions[jj] );
}
}
}
void* AmoebaVdwForceProxy::deserialize(const SerializationNode& node) const {
if (node.getIntProperty("version") != 1)
throw OpenMMException("Unsupported version number");
AmoebaVdwForce* force = new AmoebaVdwForce();
try {
force->setSigmaCombiningRule( node.getStringProperty( "SigmaCombiningRule" ) );
force->setEpsilonCombiningRule( node.getStringProperty( "EpsilonCombiningRule" ) );
force->setCutoff( node.getDoubleProperty( "VdwCutoff" ) );
force->setUseNeighborList( node.getIntProperty( "VdwUseNeighborList" ) );
force->setPBC( node.getIntProperty( "VdwPBC" ) );
const SerializationNode& particles = node.getChildNode("VdwParticles");
for (int i = 0; i < (int) particles.getChildren().size(); i++) {
const SerializationNode& particle = particles.getChildren()[i];
force->addParticle(particle.getIntProperty("ivIndex"), particle.getIntProperty("classIndex"), particle.getDoubleProperty("sig"), particle.getDoubleProperty("eps"), particle.getDoubleProperty("red"));
}
// exclusions
const SerializationNode& particleExclusions = node.getChildNode("VdwParticleExclusions");
for (int i = 0; i < (int) particleExclusions.getChildren().size(); i++) {
const SerializationNode& particleExclusion = particleExclusions.getChildren()[i];
std::vector< int > exclusions;
for (unsigned int jj = 0; jj < particleExclusion.getChildren().size(); jj++) {
exclusions.push_back( particleExclusion.getChildren()[jj].getIntProperty("ex") );
}
int index = particleExclusion.getIntProperty( "index" );
force->setParticleExclusions( index, exclusions );
}
}
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/AmoebaVdwForce.h"
#include "openmm/serialization/XmlSerializer.h"
#include <iostream>
#include <sstream>
using namespace OpenMM;
using namespace std;
void testSerialization() {
// Create a Force.
AmoebaVdwForce force;
force.setSigmaCombiningRule( "GEOMETRIC" );
force.setEpsilonCombiningRule( "GEOMETRIC" );
force.setCutoff( 0.9 );
force.setUseNeighborList( 1 );
force.setPBC( 1 );
force.addParticle(0, 1, 1.0, 2.0, 0.9);
force.addParticle(1, 0, 1.1, 2.1, 0.9);
force.addParticle(2, 3, 1.3, 4.1, 0.9);
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 );
force.setParticleExclusions( ii, exclusions );
}
// Serialize and then deserialize it.
stringstream buffer;
XmlSerializer::serialize<AmoebaVdwForce>(&force, "Force", buffer);
if( 1 ){
FILE* filePtr = fopen("Vdw.xml", "w" );
(void) fprintf( filePtr, "%s", buffer.str().c_str() );
(void) fclose( filePtr );
}
AmoebaVdwForce* copy = XmlSerializer::deserialize<AmoebaVdwForce>(buffer);
// Compare the two forces to see if they are identical.
AmoebaVdwForce& force2 = *copy;
ASSERT_EQUAL(force.getSigmaCombiningRule(), force2.getSigmaCombiningRule());
ASSERT_EQUAL(force.getEpsilonCombiningRule(), force2.getEpsilonCombiningRule());
ASSERT_EQUAL(force.getCutoff(), force2.getCutoff());
ASSERT_EQUAL(force.getUseNeighborList(), force2.getUseNeighborList());
ASSERT_EQUAL(force.getPBC(), force2.getPBC());
ASSERT_EQUAL(force.getNumParticles(), force2.getNumParticles());
for (int i = 0; i < force.getNumParticles(); i++) {
int ivIndex1, classIndex1;
int ivIndex2, classIndex2;
double sigma1, epsilon1, reductionFactor1;
double sigma2, epsilon2, reductionFactor2;
force.getParticleParameters( i, ivIndex1, classIndex1, sigma1, epsilon1, reductionFactor1 );
force2.getParticleParameters(i, ivIndex2, classIndex2, sigma2, epsilon2, reductionFactor2 );
ASSERT_EQUAL(ivIndex1, ivIndex2 );
ASSERT_EQUAL(classIndex1, classIndex2 );
ASSERT_EQUAL(sigma1, sigma2);
ASSERT_EQUAL(epsilon1, epsilon2);
ASSERT_EQUAL(reductionFactor1, reductionFactor2);
}
for (int i = 0; i < force.getNumParticles(); i++) {
std::vector< int > exclusions1;
std::vector< int > exclusions2;
force.getParticleExclusions( i, exclusions1 );
force2.getParticleExclusions( i, exclusions2 );
ASSERT_EQUAL(exclusions1.size(), exclusions2.size());
for (unsigned int ii = 0; ii < exclusions1.size(); ii++) {
int hit = 0;
for (unsigned int jj = 0; jj < exclusions2.size() && hit == 0; jj++) {
if( exclusions2[jj] == exclusions1[ii] )hit++;
}
ASSERT_EQUAL(hit, 1);
}
}
}
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