Commit 73183c61 authored by ChayaSt's avatar ChayaSt
Browse files

resolved conflict

parents 0e218233 32e08b87
......@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2012 Stanford University and the Authors. *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -102,20 +102,23 @@ public:
* in a angle cannot be changed, nor can new angles be added.
*/
void updateParametersInContext(Context& context);
/**
* Set whether this force should apply periodic boundary conditions when calculating displacements.
* Usually this is not appropriate for bonded forces, but there are situations when it can be useful.
*/
void setUsesPeriodicBoundaryConditions(bool periodic);
/**
* 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 false;
}
protected:
bool usesPeriodicBoundaryConditions() const;protected:
ForceImpl* createImpl() const;
private:
class AngleInfo;
std::vector<AngleInfo> angles;
bool usePeriodic;
};
/**
......
......@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2012 Stanford University and the Authors. *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -99,20 +99,24 @@ public:
* in a bond cannot be changed, nor can new bonds be added.
*/
void updateParametersInContext(Context& context);
/**
* Set whether this force should apply periodic boundary conditions when calculating displacements.
* Usually this is not appropriate for bonded forces, but there are situations when it can be useful.
*/
void setUsesPeriodicBoundaryConditions(bool periodic);
/**
* 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 false;
}
bool usesPeriodicBoundaryConditions() const;
protected:
ForceImpl* createImpl() const;
private:
class BondInfo;
std::vector<BondInfo> bonds;
bool usePeriodic;
};
/**
......
......@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010-2013 Stanford University and the Authors. *
* Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman, Lee-Ping Wang *
* Contributors: *
* *
......@@ -81,17 +81,25 @@ public:
static const std::string key = "MonteCarloPressureZ";
return key;
}
/**
* This is the name of the parameter which stores the current temperature at which the
* system is being maintained (in Kelvin)
*/
static const std::string& Temperature() {
static const std::string key = "AnisotropicMonteCarloTemperature";
return key;
}
/**
* Create a MonteCarloAnisotropicBarostat.
*
* @param defaultPressure The default pressure acting on each axis (in bar)
* @param temperature the temperature at which the system is being maintained (in Kelvin)
* @param scaleX whether to allow the X dimension of the periodic box to change size
* @param scaleY whether to allow the Y dimension of the periodic box to change size
* @param scaleZ whether to allow the Z dimension of the periodic box to change size
* @param frequency the frequency at which Monte Carlo pressure changes should be attempted (in time steps)
* @param defaultPressure The default pressure acting on each axis (in bar)
* @param defaultTemperature the default temperature at which the system is being maintained (in Kelvin)
* @param scaleX whether to allow the X dimension of the periodic box to change size
* @param scaleY whether to allow the Y dimension of the periodic box to change size
* @param scaleZ whether to allow the Z dimension of the periodic box to change size
* @param frequency the frequency at which Monte Carlo pressure changes should be attempted (in time steps)
*/
MonteCarloAnisotropicBarostat(const Vec3& defaultPressure, double temperature, bool scaleX = true, bool scaleY = true, bool scaleZ = true, int frequency = 25);
MonteCarloAnisotropicBarostat(const Vec3& defaultPressure, double defaultTemperature, bool scaleX = true, bool scaleY = true, bool scaleZ = true, int frequency = 25);
/**
* Get the default pressure (in bar).
*
......@@ -142,18 +150,19 @@ public:
frequency = freq;
}
/**
* Get the temperature at which the system is being maintained, measured in Kelvin.
* Get the default temperature at which the system is being maintained, measured in Kelvin.
*/
double getTemperature() const {
return temperature;
double getDefaultTemperature() const {
return defaultTemperature;
}
/**
* Set the temperature at which the system is being maintained.
* Set the default temperature at which the system is being maintained. This will affect any new Contexts you create,
* but not ones that already exist.
*
* @param temp the system temperature, measured in Kelvin.
*/
void setTemperature(double temp) {
temperature = temp;
void setDefaultTemperature(double temp) {
defaultTemperature = temp;
}
/**
* Get the random number seed. See setRandomNumberSeed() for details.
......@@ -188,7 +197,7 @@ protected:
ForceImpl* createImpl() const;
private:
Vec3 defaultPressure;
double temperature;
double defaultTemperature;
bool scaleX, scaleY, scaleZ;
int frequency, randomNumberSeed;
};
......
......@@ -9,7 +9,7 @@
* 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. *
* Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -58,14 +58,22 @@ public:
static const std::string key = "MonteCarloPressure";
return key;
}
/**
* This is the name of the parameter which stores the current temperature at which the
* system is being maintained (in Kelvin)
*/
static const std::string& Temperature() {
static const std::string key = "MonteCarloTemperature";
return key;
}
/**
* Create a MonteCarloBarostat.
*
* @param defaultPressure the default pressure acting on the system (in bar)
* @param temperature the temperature at which the system is being maintained (in Kelvin)
* @param frequency the frequency at which Monte Carlo pressure changes should be attempted (in time steps)
* @param defaultPressure the default pressure acting on the system (in bar)
* @param defaultTemperature the default temperature at which the system is being maintained (in Kelvin)
* @param frequency the frequency at which Monte Carlo pressure changes should be attempted (in time steps)
*/
MonteCarloBarostat(double defaultPressure, double temperature, int frequency = 25);
MonteCarloBarostat(double defaultPressure, double defaultTemperature, int frequency = 25);
/**
* Get the default pressure acting on the system (in bar).
*
......@@ -98,18 +106,19 @@ public:
frequency = freq;
}
/**
* Get the temperature at which the system is being maintained, measured in Kelvin.
* Get the default temperature at which the system is being maintained, measured in Kelvin.
*/
double getTemperature() const {
return temperature;
double getDefaultTemperature() const {
return defaultTemperature;
}
/**
* Set the temperature at which the system is being maintained.
* Set the default temperature at which the system is being maintained. This will affect any new Contexts you create,
* but not ones that already exist.
*
* @param temp the system temperature, measured in Kelvin.
*/
void setTemperature(double temp) {
temperature = temp;
void setDefaultTemperature(double temp) {
defaultTemperature = temp;
}
/**
* Get the random number seed. See setRandomNumberSeed() for details.
......@@ -143,7 +152,7 @@ public:
protected:
ForceImpl* createImpl() const;
private:
double defaultPressure, temperature;
double defaultPressure, defaultTemperature;
int frequency, randomNumberSeed;
};
......
......@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -111,17 +111,25 @@ public:
static const std::string key = "MembraneMonteCarloSurfaceTension";
return key;
}
/**
* This is the name of the parameter which stores the current temperature at which the
* system is being maintained (in Kelvin)
*/
static const std::string& Temperature() {
static const std::string key = "MembraneMonteCarloTemperature";
return key;
}
/**
* Create a MonteCarloMembraneBarostat.
*
* @param defaultPressure the default pressure acting on the system (in bar)
* @param defaultSurfaceTension the default surface tension acting on the system (in bar*nm)
* @param temperature the temperature at which the system is being maintained (in Kelvin)
* @param defaultTemperature the default temperature at which the system is being maintained (in Kelvin)
* @param xymode the mode specifying the behavior of the X and Y axes
* @param zmode the mode specifying the behavior of the Z axis
* @param frequency the frequency at which Monte Carlo volume changes should be attempted (in time steps)
*/
MonteCarloMembraneBarostat(double defaultPressure, double defaultSurfaceTension, double temperature, XYMode xymode, ZMode zmode, int frequency = 25);
MonteCarloMembraneBarostat(double defaultPressure, double defaultSurfaceTension, double defaultTemperature, XYMode xymode, ZMode zmode, int frequency = 25);
/**
* Get the default pressure acting on the system (in bar).
*
......@@ -171,18 +179,19 @@ public:
frequency = freq;
}
/**
* Get the temperature at which the system is being maintained, measured in Kelvin.
* Get the default temperature at which the system is being maintained, measured in Kelvin.
*/
double getTemperature() const {
return temperature;
double getDefaultTemperature() const {
return defaultTemperature;
}
/**
* Set the temperature at which the system is being maintained.
* Set the default temperature at which the system is being maintained. This will affect any new Contexts you create,
* but not ones that already exist.
*
* @param temp the system temperature, measured in Kelvin.
*/
void setTemperature(double temp) {
temperature = temp;
void setDefaultTemperature(double temp) {
defaultTemperature = temp;
}
/**
* Get the mode specifying the behavior of the X and Y axes.
......@@ -240,7 +249,7 @@ public:
protected:
ForceImpl* createImpl() const;
private:
double defaultPressure, defaultSurfaceTension, temperature;
double defaultPressure, defaultSurfaceTension, defaultTemperature;
XYMode xymode;
ZMode zmode;
int frequency, randomNumberSeed;
......
......@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2012 Stanford University and the Authors. *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -108,20 +108,24 @@ public:
* in a torsion cannot be changed, nor can new torsions be added.
*/
void updateParametersInContext(Context& context);
/**
* Set whether this force should apply periodic boundary conditions when calculating displacements.
* Usually this is not appropriate for bonded forces, but there are situations when it can be useful.
*/
void setUsesPeriodicBoundaryConditions(bool periodic);
/**
* 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 false;
}
bool usesPeriodicBoundaryConditions() const;
protected:
ForceImpl* createImpl() const;
private:
class PeriodicTorsionInfo;
std::vector<PeriodicTorsionInfo> periodicTorsions;
bool usePeriodic;
};
/**
......
......@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2012 Stanford University and the Authors. *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -117,20 +117,24 @@ public:
* in a torsion cannot be changed, nor can new torsions be added.
*/
void updateParametersInContext(Context& context);
/**
* Set whether this force should apply periodic boundary conditions when calculating displacements.
* Usually this is not appropriate for bonded forces, but there are situations when it can be useful.
*/
void setUsesPeriodicBoundaryConditions(bool periodic);
/**
* 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 false;
}
bool usesPeriodicBoundaryConditions() const;
protected:
ForceImpl* createImpl() const;
private:
class RBTorsionInfo;
std::vector<RBTorsionInfo> rbTorsions;
bool usePeriodic;
};
/**
......
#ifndef OPENMM_OSRNGSEED_H_
#ifndef OPENMM_OSRNGSEED_H_
#define OPENMM_OSRNGSEED_H_
......
......@@ -6,7 +6,7 @@
* 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. *
* Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -37,7 +37,7 @@
using namespace OpenMM;
CMAPTorsionForce::CMAPTorsionForce() {
CMAPTorsionForce::CMAPTorsionForce() : usePeriodic(false) {
}
int CMAPTorsionForce::addMap(int size, const std::vector<double>& energy) {
......@@ -99,3 +99,11 @@ ForceImpl* CMAPTorsionForce::createImpl() const {
void CMAPTorsionForce::updateParametersInContext(Context& context) {
dynamic_cast<CMAPTorsionForceImpl&>(getImplInContext(context)).updateParametersInContext(getContextImpl(context));
}
void CMAPTorsionForce::setUsesPeriodicBoundaryConditions(bool periodic) {
usePeriodic = periodic;
}
bool CMAPTorsionForce::usesPeriodicBoundaryConditions() const {
return usePeriodic;
}
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2013 Stanford University and the Authors. *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -84,15 +84,20 @@ ContextImpl::ContextImpl(Context& owner, const System& system, Integrator& integ
// Validate the list of properties.
const vector<string>& platformProperties = platform->getPropertyNames();
map<string, string> validatedProperties;
for (map<string, string>::const_iterator iter = properties.begin(); iter != properties.end(); ++iter) {
string property = iter->first;
if (platform->deprecatedPropertyReplacements.find(property) != platform->deprecatedPropertyReplacements.end())
property = platform->deprecatedPropertyReplacements[property];
bool valid = false;
for (int i = 0; i < (int) platformProperties.size(); i++)
if (platformProperties[i] == iter->first) {
if (platformProperties[i] == property) {
valid = true;
break;
}
if (!valid)
throw OpenMMException("Illegal property name: "+iter->first);
validatedProperties[property] = iter->second;
}
// Find the list of kernels required.
......@@ -139,7 +144,7 @@ ContextImpl::ContextImpl(Context& owner, const System& system, Integrator& integ
for (int i = candidatePlatforms.size()-1; i >= 0; i--) {
try {
this->platform = platform = candidatePlatforms[i].second;
platform->contextCreated(*this, properties);
platform->contextCreated(*this, validatedProperties);
break;
}
catch (...) {
......
......@@ -6,7 +6,7 @@
* 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. *
* Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,7 +44,7 @@ using std::string;
using std::stringstream;
using std::vector;
CustomAngleForce::CustomAngleForce(const string& energy) : energyExpression(energy) {
CustomAngleForce::CustomAngleForce(const string& energy) : energyExpression(energy), usePeriodic(false) {
}
const string& CustomAngleForce::getEnergyFunction() const {
......@@ -123,3 +123,11 @@ ForceImpl* CustomAngleForce::createImpl() const {
void CustomAngleForce::updateParametersInContext(Context& context) {
dynamic_cast<CustomAngleForceImpl&>(getImplInContext(context)).updateParametersInContext(getContextImpl(context));
}
void CustomAngleForce::setUsesPeriodicBoundaryConditions(bool periodic) {
usePeriodic = periodic;
}
bool CustomAngleForce::usesPeriodicBoundaryConditions() const {
return usePeriodic;
}
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,7 +44,7 @@ using std::string;
using std::stringstream;
using std::vector;
CustomBondForce::CustomBondForce(const string& energy) : energyExpression(energy) {
CustomBondForce::CustomBondForce(const string& energy) : energyExpression(energy), usePeriodic(false) {
}
const string& CustomBondForce::getEnergyFunction() const {
......@@ -121,3 +121,11 @@ ForceImpl* CustomBondForce::createImpl() const {
void CustomBondForce::updateParametersInContext(Context& context) {
dynamic_cast<CustomBondForceImpl&>(getImplInContext(context)).updateParametersInContext(getContextImpl(context));
}
void CustomBondForce::setUsesPeriodicBoundaryConditions(bool periodic) {
usePeriodic = periodic;
}
bool CustomBondForce::usesPeriodicBoundaryConditions() const {
return usePeriodic;
}
......@@ -6,7 +6,7 @@
* 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. *
* Portions copyright (c) 2015-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -48,7 +48,7 @@ using std::string;
using std::stringstream;
using std::vector;
CustomCentroidBondForce::CustomCentroidBondForce(int numGroups, const string& energy) : groupsPerBond(numGroups), energyExpression(energy) {
CustomCentroidBondForce::CustomCentroidBondForce(int numGroups, const string& energy) : groupsPerBond(numGroups), energyExpression(energy), usePeriodic(false) {
}
CustomCentroidBondForce::~CustomCentroidBondForce() {
......@@ -173,3 +173,11 @@ ForceImpl* CustomCentroidBondForce::createImpl() const {
void CustomCentroidBondForce::updateParametersInContext(Context& context) {
dynamic_cast<CustomCentroidBondForceImpl&>(getImplInContext(context)).updateParametersInContext(getContextImpl(context));
}
void CustomCentroidBondForce::setUsesPeriodicBoundaryConditions(bool periodic) {
usePeriodic = periodic;
}
bool CustomCentroidBondForce::usesPeriodicBoundaryConditions() const {
return usePeriodic;
}
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2014 Stanford University and the Authors. *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -48,7 +48,7 @@ using std::string;
using std::stringstream;
using std::vector;
CustomCompoundBondForce::CustomCompoundBondForce(int numParticles, const string& energy) : particlesPerBond(numParticles), energyExpression(energy) {
CustomCompoundBondForce::CustomCompoundBondForce(int numParticles, const string& energy) : particlesPerBond(numParticles), energyExpression(energy), usePeriodic(false) {
}
......@@ -176,3 +176,11 @@ ForceImpl* CustomCompoundBondForce::createImpl() const {
void CustomCompoundBondForce::updateParametersInContext(Context& context) {
dynamic_cast<CustomCompoundBondForceImpl&>(getImplInContext(context)).updateParametersInContext(getContextImpl(context));
}
void CustomCompoundBondForce::setUsesPeriodicBoundaryConditions(bool periodic) {
usePeriodic = periodic;
}
bool CustomCompoundBondForce::usesPeriodicBoundaryConditions() const {
return usePeriodic;
}
......@@ -248,21 +248,21 @@ int CustomIntegrator::addUpdateContextState() {
int CustomIntegrator::beginIfBlock(const string& expression) {
if (owner != NULL)
throw OpenMMException("The integrator cannot be modified after it is bound to a context");
computations.push_back(ComputationInfo(BeginIfBlock, "", expression));
computations.push_back(ComputationInfo(IfBlockStart, "", expression));
return computations.size()-1;
}
int CustomIntegrator::beginWhileBlock(const string& expression) {
if (owner != NULL)
throw OpenMMException("The integrator cannot be modified after it is bound to a context");
computations.push_back(ComputationInfo(BeginWhileBlock, "", expression));
computations.push_back(ComputationInfo(WhileBlockStart, "", expression));
return computations.size()-1;
}
int CustomIntegrator::endBlock() {
if (owner != NULL)
throw OpenMMException("The integrator cannot be modified after it is bound to a context");
computations.push_back(ComputationInfo(EndBlock, "", ""));
computations.push_back(ComputationInfo(BlockEnd, "", ""));
return computations.size()-1;
}
......
......@@ -87,7 +87,7 @@ void CustomIntegratorUtilities::analyzeComputations(const ContextImpl& context,
for (int step = 0; step < numSteps; step++) {
string expression;
integrator.getComputationStep(step, stepType[step], stepVariable[step], expression);
if (stepType[step] == CustomIntegrator::BeginIfBlock || stepType[step] == CustomIntegrator::BeginWhileBlock) {
if (stepType[step] == CustomIntegrator::IfBlockStart || stepType[step] == CustomIntegrator::WhileBlockStart) {
// This step involves a condition.
string lhs, rhs;
......@@ -158,9 +158,9 @@ void CustomIntegratorUtilities::analyzeComputations(const ContextImpl& context,
vector<int> blockStart;
blockEnd.resize(numSteps, -1);
for (int step = 0; step < numSteps; step++) {
if (stepType[step] == CustomIntegrator::BeginIfBlock || stepType[step] == CustomIntegrator::BeginWhileBlock)
if (stepType[step] == CustomIntegrator::IfBlockStart || stepType[step] == CustomIntegrator::WhileBlockStart)
blockStart.push_back(step);
else if (stepType[step] == CustomIntegrator::EndBlock) {
else if (stepType[step] == CustomIntegrator::BlockEnd) {
if (blockStart.size() == 0) {
stringstream error("CustomIntegrator: Unexpected end of block at computation ");
error << step;
......@@ -207,7 +207,7 @@ void CustomIntegratorUtilities::enumeratePaths(int firstStep, vector<int> steps,
jumps[step] = -1;
step = nextStep;
}
else if (stepType[step] == CustomIntegrator::BeginIfBlock) {
else if (stepType[step] == CustomIntegrator::IfBlockStart) {
// Consider skipping the block.
enumeratePaths(blockEnd[step]+1, steps, jumps, blockEnd, stepType, needsForces, needsEnergy, invalidatesForces, forceGroup, computeBoth);
......@@ -216,7 +216,7 @@ void CustomIntegratorUtilities::enumeratePaths(int firstStep, vector<int> steps,
step++;
}
else if (stepType[step] == CustomIntegrator::BeginWhileBlock && jumps[step] != -2) {
else if (stepType[step] == CustomIntegrator::WhileBlockStart && jumps[step] != -2) {
// Consider skipping the block.
enumeratePaths(blockEnd[step]+1, steps, jumps, blockEnd, stepType, needsForces, needsEnergy, invalidatesForces, forceGroup, computeBoth);
......
......@@ -6,7 +6,7 @@
* 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. *
* Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,7 +44,7 @@ using std::string;
using std::stringstream;
using std::vector;
CustomTorsionForce::CustomTorsionForce(const string& energy) : energyExpression(energy) {
CustomTorsionForce::CustomTorsionForce(const string& energy) : energyExpression(energy), usePeriodic(false) {
}
const string& CustomTorsionForce::getEnergyFunction() const {
......@@ -125,3 +125,11 @@ ForceImpl* CustomTorsionForce::createImpl() const {
void CustomTorsionForce::updateParametersInContext(Context& context) {
dynamic_cast<CustomTorsionForceImpl&>(getImplInContext(context)).updateParametersInContext(getContextImpl(context));
}
void CustomTorsionForce::setUsesPeriodicBoundaryConditions(bool periodic) {
usePeriodic = periodic;
}
bool CustomTorsionForce::usesPeriodicBoundaryConditions() const {
return usePeriodic;
}
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2009 Stanford University and the Authors. *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -37,7 +37,7 @@
using namespace OpenMM;
HarmonicAngleForce::HarmonicAngleForce() {
HarmonicAngleForce::HarmonicAngleForce() : usePeriodic(false) {
}
int HarmonicAngleForce::addAngle(int particle1, int particle2, int particle3, double angle, double k) {
......@@ -70,3 +70,11 @@ ForceImpl* HarmonicAngleForce::createImpl() const {
void HarmonicAngleForce::updateParametersInContext(Context& context) {
dynamic_cast<HarmonicAngleForceImpl&>(getImplInContext(context)).updateParametersInContext(getContextImpl(context));
}
void HarmonicAngleForce::setUsesPeriodicBoundaryConditions(bool periodic) {
usePeriodic = periodic;
}
bool HarmonicAngleForce::usesPeriodicBoundaryConditions() const {
return usePeriodic;
}
......@@ -37,7 +37,7 @@
using namespace OpenMM;
HarmonicBondForce::HarmonicBondForce() {
HarmonicBondForce::HarmonicBondForce() : usePeriodic(false) {
}
int HarmonicBondForce::addBond(int particle1, int particle2, double length, double k) {
......@@ -68,3 +68,11 @@ ForceImpl* HarmonicBondForce::createImpl() const {
void HarmonicBondForce::updateParametersInContext(Context& context) {
dynamic_cast<HarmonicBondForceImpl&>(getImplInContext(context)).updateParametersInContext(getContextImpl(context));
}
void HarmonicBondForce::setUsesPeriodicBoundaryConditions(bool periodic) {
usePeriodic = periodic;
}
bool HarmonicBondForce::usesPeriodicBoundaryConditions() const {
return usePeriodic;
}
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010-2012 Stanford University and the Authors. *
* Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -108,7 +108,8 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
if (x == NULL)
throw OpenMMException("LocalEnergyMinimizer: Failed to allocate memory");
double constraintTol = context.getIntegrator().getConstraintTolerance();
double k = tolerance/constraintTol;
double workingConstraintTol = max(1e-4, constraintTol);
double k = tolerance/workingConstraintTol;
// Initialize the minimizer.
......@@ -121,7 +122,7 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
// Make sure the initial configuration satisfies all constraints.
context.applyConstraints(constraintTol);
context.applyConstraints(workingConstraintTol);
// Record the initial positions and determine a normalization constant for scaling the tolerance.
......@@ -162,14 +163,14 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
if (error > maxError)
maxError = error;
}
if (maxError <= constraintTol)
if (maxError <= workingConstraintTol)
break; // All constraints are satisfied.
context.setPositions(initialPos);
if (maxError >= prevMaxError)
break; // Further tightening the springs doesn't seem to be helping, so just give up.
prevMaxError = maxError;
k *= 10;
if (maxError > 100*constraintTol) {
if (maxError > 100*workingConstraintTol) {
// We've gotten far enough from a valid state that we might have trouble getting
// back, so reset to the original positions.
......@@ -181,5 +182,11 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
}
}
lbfgs_free(x);
// If necessary, do a final constraint projection to make sure they are satisfied
// to the full precision requested by the user.
if (constraintTol < workingConstraintTol)
context.applyConstraints(workingConstraintTol);
}
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