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

Max Drude distance defaults to 0.02 nm (#3508)

* Max Drude distance defaults to 0.2 nm

* Fixed incorrect number in docs

* Fixed a test case
parent a76c2de1
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2008-2021 Stanford University and the Authors. * * Portions copyright (c) 2008-2022 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -72,12 +72,12 @@ public: ...@@ -72,12 +72,12 @@ public:
void setDrudeTemperature(double temp); void setDrudeTemperature(double temp);
/** /**
* Get the maximum distance a Drude particle can ever move from its parent particle, measured in nm. This is implemented * Get the maximum distance a Drude particle can ever move from its parent particle, measured in nm. This is implemented
* with a hard wall constraint. If this distance is set to 0 (the default), the hard wall constraint is omitted. * with a hard wall constraint. The default value is 0.02. If this distance is set to 0, the hard wall constraint is omitted.
*/ */
double getMaxDrudeDistance() const; double getMaxDrudeDistance() const;
/** /**
* Set the maximum distance a Drude particle can ever move from its parent particle, measured in nm. This is implemented * Set the maximum distance a Drude particle can ever move from its parent particle, measured in nm. This is implemented
* with a hard wall constraint. If this distance is set to 0 (the default), the hard wall constraint is omitted. * with a hard wall constraint. The default value is 0.02. If this distance is set to 0, the hard wall constraint is omitted.
*/ */
void setMaxDrudeDistance(double distance); void setMaxDrudeDistance(double distance);
/** /**
......
...@@ -47,7 +47,7 @@ namespace OpenMM { ...@@ -47,7 +47,7 @@ namespace OpenMM {
* *
* This integrator can optionally set an upper limit on how far any Drude particle is ever allowed to * This integrator can optionally set an upper limit on how far any Drude particle is ever allowed to
* get from its parent particle. This can sometimes help to improve stability. The limit is enforced * get from its parent particle. This can sometimes help to improve stability. The limit is enforced
* with a hard wall constraint. * with a hard wall constraint. By default the limit is set to 0.02 nm.
* *
* This Integrator requires the System to include a DrudeForce, which it uses to identify the Drude * This Integrator requires the System to include a DrudeForce, which it uses to identify the Drude
* particles. * particles.
......
...@@ -45,6 +45,10 @@ namespace OpenMM { ...@@ -45,6 +45,10 @@ namespace OpenMM {
* A second thermostat, typically with a much lower temperature, is applied to the relative internal * A second thermostat, typically with a much lower temperature, is applied to the relative internal
* displacement of each pair. * displacement of each pair.
* *
* This integrator can optionally set an upper limit on how far any Drude particle is ever allowed to
* get from its parent particle. This can sometimes help to improve stability. The limit is enforced
* with a hard wall constraint. By default the limit is set to 0.02 nm.
*
* This Integrator requires the System to include a DrudeForce, which it uses to identify the Drude * This Integrator requires the System to include a DrudeForce, which it uses to identify the Drude
* particles. * particles.
*/ */
......
...@@ -52,7 +52,7 @@ DrudeLangevinIntegrator::DrudeLangevinIntegrator(double temperature, double fric ...@@ -52,7 +52,7 @@ DrudeLangevinIntegrator::DrudeLangevinIntegrator(double temperature, double fric
setFriction(frictionCoeff); setFriction(frictionCoeff);
setDrudeTemperature(drudeTemperature); setDrudeTemperature(drudeTemperature);
setDrudeFriction(drudeFrictionCoeff); setDrudeFriction(drudeFrictionCoeff);
setMaxDrudeDistance(0); setMaxDrudeDistance(0.02);
setStepSize(stepSize); setStepSize(stepSize);
setConstraintTolerance(1e-5); setConstraintTolerance(1e-5);
setRandomNumberSeed(0); setRandomNumberSeed(0);
......
...@@ -54,10 +54,8 @@ namespace OpenMM { ...@@ -54,10 +54,8 @@ namespace OpenMM {
DrudeNoseHooverIntegrator::DrudeNoseHooverIntegrator(double temperature, double collisionFrequency, DrudeNoseHooverIntegrator::DrudeNoseHooverIntegrator(double temperature, double collisionFrequency,
double drudeTemperature, double drudeCollisionFrequency, double drudeTemperature, double drudeCollisionFrequency,
double stepSize, int chainLength, int numMTS, int numYoshidaSuzuki) : double stepSize, int chainLength, int numMTS, int numYoshidaSuzuki) :
NoseHooverIntegrator(stepSize), NoseHooverIntegrator(stepSize), drudeTemperature(drudeTemperature) {
drudeTemperature(drudeTemperature) setMaxDrudeDistance(0.02);
{
setMaxDrudeDistance(0);
hasSubsystemThermostats_ = false; hasSubsystemThermostats_ = false;
addSubsystemThermostat(std::vector<int>(), std::vector<std::pair<int, int>>(), temperature, addSubsystemThermostat(std::vector<int>(), std::vector<std::pair<int, int>>(), temperature,
collisionFrequency, drudeTemperature, drudeCollisionFrequency, collisionFrequency, drudeTemperature, drudeCollisionFrequency,
......
...@@ -48,6 +48,7 @@ DrudeSCFIntegrator::DrudeSCFIntegrator(double stepSize) : DrudeIntegrator(stepSi ...@@ -48,6 +48,7 @@ DrudeSCFIntegrator::DrudeSCFIntegrator(double stepSize) : DrudeIntegrator(stepSi
setStepSize(stepSize); setStepSize(stepSize);
setMinimizationErrorTolerance(0.1); setMinimizationErrorTolerance(0.1);
setConstraintTolerance(1e-5); setConstraintTolerance(1e-5);
setMaxDrudeDistance(0.0);
} }
void DrudeSCFIntegrator::initialize(ContextImpl& contextRef) { void DrudeSCFIntegrator::initialize(ContextImpl& contextRef) {
...@@ -64,6 +65,8 @@ void DrudeSCFIntegrator::initialize(ContextImpl& contextRef) { ...@@ -64,6 +65,8 @@ void DrudeSCFIntegrator::initialize(ContextImpl& contextRef) {
} }
if (force == NULL) if (force == NULL)
throw OpenMMException("The System does not contain a DrudeForce"); throw OpenMMException("The System does not contain a DrudeForce");
if (getMaxDrudeDistance() != 0.0)
throw OpenMMException("DrudeSCFIntegrator does not currently support setting max Drude distance");
context = &contextRef; context = &contextRef;
owner = &contextRef.getOwner(); owner = &contextRef.getOwner();
kernel = context->getPlatform().createKernel(IntegrateDrudeSCFStepKernel::Name(), contextRef); kernel = context->getPlatform().createKernel(IntegrateDrudeSCFStepKernel::Name(), contextRef);
......
...@@ -1051,7 +1051,7 @@ class TestAPIUnits(unittest.TestCase): ...@@ -1051,7 +1051,7 @@ class TestAPIUnits(unittest.TestCase):
self.assertEqual(integrator.getStepSize(), 0.1*femtosecond) self.assertEqual(integrator.getStepSize(), 0.1*femtosecond)
integrator.setStepSize(0.0005) integrator.setStepSize(0.0005)
self.assertEqual(integrator.getStepSize(), 0.0005*picosecond) self.assertEqual(integrator.getStepSize(), 0.0005*picosecond)
self.assertEqual(integrator.getMaxDrudeDistance(), 0*nanometer) self.assertEqual(integrator.getMaxDrudeDistance(), 0.02*nanometer)
integrator.setMaxDrudeDistance(0.05) integrator.setMaxDrudeDistance(0.05)
self.assertEqual(integrator.getMaxDrudeDistance(), 0.05*nanometer) self.assertEqual(integrator.getMaxDrudeDistance(), 0.05*nanometer)
......
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