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

Merge remote-tracking branch 'upstream/master'

parents 71d33617 62f167cc
...@@ -1222,9 +1222,9 @@ specify if you want further control over the minimization. First, you can ...@@ -1222,9 +1222,9 @@ specify if you want further control over the minimization. First, you can
specify a tolerance for when the energy should be considered to have converged: specify a tolerance for when the energy should be considered to have converged:
:: ::
simulation.minimizeEnergy(tolerance=10*kilojoule/mole) simulation.minimizeEnergy(tolerance=5*kilojoule/mole)
If you do not specify this parameter, a default tolerance of 1 kJ/mole is used. If you do not specify this parameter, a default tolerance of 10 kJ/mole is used.
Second, you can specify a maximum number of iterations: Second, you can specify a maximum number of iterations:
:: ::
...@@ -1405,8 +1405,13 @@ size, you can specify one: ...@@ -1405,8 +1405,13 @@ size, you can specify one:
modeller.addSolvent(forcefield, boxSize=Vec3(5.0, 3.5, 3.5)*nanometers) modeller.addSolvent(forcefield, boxSize=Vec3(5.0, 3.5, 3.5)*nanometers)
This requests a 5 nm by 3.5 nm by 3.5 nm box. Another option is to specify a This requests a 5 nm by 3.5 nm by 3.5 nm box. For a non-rectangular box, you
padding distance: can specify the three box vectors defining the unit cell:
::
modeller.addSolvent(forcefield, boxVectors=(avec, bvec, cvec))
Another option is to specify a padding distance:
:: ::
modeller.addSolvent(forcefield, padding=1.0*nanometers) modeller.addSolvent(forcefield, padding=1.0*nanometers)
...@@ -1416,6 +1421,14 @@ then creates a cubic box of width (solute size)+2*(padding). The above line ...@@ -1416,6 +1421,14 @@ then creates a cubic box of width (solute size)+2*(padding). The above line
guarantees that no part of the solute comes closer than 1 nm to any edge of the guarantees that no part of the solute comes closer than 1 nm to any edge of the
box. box.
Finally, you can specify the exact number of solvent molecules (including both
water and ions) to add. This is useful when you want to solvate several different
conformations of the same molecule while guaranteeing they all have the same
amount of solvent:
::
modeller.addSolvent(forcefield, numAdded=5000)
By default, :meth:`addSolvent` creates TIP3P water molecules, but it also supports other By default, :meth:`addSolvent` creates TIP3P water molecules, but it also supports other
water models: water models:
:: ::
......
...@@ -1040,9 +1040,9 @@ The following operators are supported: + (add), - (subtract), * (multiply), / ...@@ -1040,9 +1040,9 @@ The following operators are supported: + (add), - (subtract), * (multiply), /
The following standard functions are supported: sqrt, exp, log, sin, cos, sec, The following standard functions are supported: sqrt, exp, log, sin, cos, sec,
csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs,
floor, ceil, step, delta. step(x) = 0 if x < 0, 1 otherwise. delta(x) = 1 if x is 0, 0 floor, ceil, step, delta, select. step(x) = 0 if x < 0, 1 otherwise.
otherwise. Some custom forces allow additional functions to be defined from delta(x) = 1 if x is 0, 0 otherwise. select(x,y,z) = z if x = 0, y otherwise.
tabulated values. Some custom forces allow additional functions to be defined from tabulated values.
Numbers may be given in either decimal or exponential form. All of the Numbers may be given in either decimal or exponential form. All of the
following are valid numbers: 5, -3.1, 1e6, and 3.12e-2. following are valid numbers: 5, -3.1, 1e6, and 3.12e-2.
......
...@@ -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) 2009-2013 Stanford University and the Authors. * * Portions copyright (c) 2009-2015 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -64,7 +64,7 @@ public: ...@@ -64,7 +64,7 @@ public:
*/ */
enum Id {CONSTANT, VARIABLE, CUSTOM, ADD, SUBTRACT, MULTIPLY, DIVIDE, POWER, NEGATE, SQRT, EXP, LOG, enum Id {CONSTANT, VARIABLE, CUSTOM, ADD, SUBTRACT, MULTIPLY, DIVIDE, POWER, NEGATE, SQRT, EXP, LOG,
SIN, COS, SEC, CSC, TAN, COT, ASIN, ACOS, ATAN, SINH, COSH, TANH, ERF, ERFC, STEP, DELTA, SQUARE, CUBE, RECIPROCAL, SIN, COS, SEC, CSC, TAN, COT, ASIN, ACOS, ATAN, SINH, COSH, TANH, ERF, ERFC, STEP, DELTA, SQUARE, CUBE, RECIPROCAL,
ADD_CONSTANT, MULTIPLY_CONSTANT, POWER_CONSTANT, MIN, MAX, ABS, FLOOR, CEIL}; ADD_CONSTANT, MULTIPLY_CONSTANT, POWER_CONSTANT, MIN, MAX, ABS, FLOOR, CEIL, SELECT};
/** /**
* Get the name of this Operation. * Get the name of this Operation.
*/ */
...@@ -155,6 +155,7 @@ public: ...@@ -155,6 +155,7 @@ public:
class Abs; class Abs;
class Floor; class Floor;
class Ceil; class Ceil;
class Select;
}; };
class LEPTON_EXPORT Operation::Constant : public Operation { class LEPTON_EXPORT Operation::Constant : public Operation {
...@@ -1137,6 +1138,28 @@ public: ...@@ -1137,6 +1138,28 @@ public:
ExpressionTreeNode differentiate(const std::vector<ExpressionTreeNode>& children, const std::vector<ExpressionTreeNode>& childDerivs, const std::string& variable) const; ExpressionTreeNode differentiate(const std::vector<ExpressionTreeNode>& children, const std::vector<ExpressionTreeNode>& childDerivs, const std::string& variable) const;
}; };
class LEPTON_EXPORT Operation::Select : public Operation {
public:
Select() {
}
std::string getName() const {
return "select";
}
Id getId() const {
return SELECT;
}
int getNumArguments() const {
return 3;
}
Operation* clone() const {
return new Select();
}
double evaluate(double* args, const std::map<std::string, double>& variables) const {
return (args[0] != 0.0 ? args[1] : args[2]);
}
ExpressionTreeNode differentiate(const std::vector<ExpressionTreeNode>& children, const std::vector<ExpressionTreeNode>& childDerivs, const std::string& variable) const;
};
} // namespace Lepton } // namespace Lepton
#endif /*LEPTON_OPERATION_H_*/ #endif /*LEPTON_OPERATION_H_*/
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,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) 2009 Stanford University and the Authors. * * Portions copyright (c) 2009-2015 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -325,3 +325,11 @@ ExpressionTreeNode Operation::Floor::differentiate(const std::vector<ExpressionT ...@@ -325,3 +325,11 @@ ExpressionTreeNode Operation::Floor::differentiate(const std::vector<ExpressionT
ExpressionTreeNode Operation::Ceil::differentiate(const std::vector<ExpressionTreeNode>& children, const std::vector<ExpressionTreeNode>& childDerivs, const std::string& variable) const { ExpressionTreeNode Operation::Ceil::differentiate(const std::vector<ExpressionTreeNode>& children, const std::vector<ExpressionTreeNode>& childDerivs, const std::string& variable) const {
return ExpressionTreeNode(new Operation::Constant(0.0)); return ExpressionTreeNode(new Operation::Constant(0.0));
} }
ExpressionTreeNode Operation::Select::differentiate(const std::vector<ExpressionTreeNode>& children, const std::vector<ExpressionTreeNode>& childDerivs, const std::string& variable) const {
vector<ExpressionTreeNode> derivChildren;
derivChildren.push_back(children[0]);
derivChildren.push_back(childDerivs[1]);
derivChildren.push_back(childDerivs[2]);
return ExpressionTreeNode(new Operation::Select(), derivChildren);
}
...@@ -328,6 +328,7 @@ Operation* Parser::getFunctionOperation(const std::string& name, const map<strin ...@@ -328,6 +328,7 @@ Operation* Parser::getFunctionOperation(const std::string& name, const map<strin
opMap["abs"] = Operation::ABS; opMap["abs"] = Operation::ABS;
opMap["floor"] = Operation::FLOOR; opMap["floor"] = Operation::FLOOR;
opMap["ceil"] = Operation::CEIL; opMap["ceil"] = Operation::CEIL;
opMap["select"] = Operation::SELECT;
} }
string trimmed = name.substr(0, name.size()-1); string trimmed = name.substr(0, name.size()-1);
...@@ -397,6 +398,8 @@ Operation* Parser::getFunctionOperation(const std::string& name, const map<strin ...@@ -397,6 +398,8 @@ Operation* Parser::getFunctionOperation(const std::string& name, const map<strin
return new Operation::Floor(); return new Operation::Floor();
case Operation::CEIL: case Operation::CEIL:
return new Operation::Ceil(); return new Operation::Ceil();
case Operation::SELECT:
return new Operation::Select();
default: default:
throw Exception("unknown function"); throw Exception("unknown function");
} }
......
...@@ -109,11 +109,14 @@ ...@@ -109,11 +109,14 @@
/* Include everything */ /* Include everything */
#endif #endif
#ifdef _UWIN #if defined(_UWIN)
# define HAVE_STRUCT_TIMESPEC 1 # define HAVE_STRUCT_TIMESPEC 1
# define HAVE_SIGNAL_H 1 # define HAVE_SIGNAL_H 1
# undef HAVE_CONFIG_H # undef HAVE_CONFIG_H
# pragma comment(lib, "pthread") # pragma comment(lib, "pthread")
#elif defined(__MINGW32__)
# define HAVE_STRUCT_TIMESPEC 1
# define HAVE_SIGNAL_H 1
#endif #endif
/* /*
......
...@@ -179,13 +179,13 @@ static HMODULE loadOneLibrary(const string& file) { ...@@ -179,13 +179,13 @@ static HMODULE loadOneLibrary(const string& file) {
static void initializePlugins(vector<HMODULE>& plugins) { static void initializePlugins(vector<HMODULE>& plugins) {
for (int i = 0; i < (int) plugins.size(); i++) { for (int i = 0; i < (int) plugins.size(); i++) {
void (*init)(); void (*init)();
*(void **)(&init) = GetProcAddress(plugins[i], "registerPlatforms"); *(void **)(&init) = (void *) GetProcAddress(plugins[i], "registerPlatforms");
if (init != NULL) if (init != NULL)
(*init)(); (*init)();
} }
for (int i = 0; i < (int) plugins.size(); i++) { for (int i = 0; i < (int) plugins.size(); i++) {
void (*init)(); void (*init)();
*(void **)(&init) = GetProcAddress(plugins[i], "registerKernelFactories"); *(void **)(&init) = (void *) GetProcAddress(plugins[i], "registerKernelFactories");
if (init != NULL) if (init != NULL)
(*init)(); (*init)();
} }
......
...@@ -65,8 +65,9 @@ namespace OpenMM { ...@@ -65,8 +65,9 @@ namespace OpenMM {
* </pre></tt> * </pre></tt>
* *
* Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following * Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following
* functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta. All trigonometric functions * functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta, select. All trigonometric functions
* are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise. * are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise.
* select(x,y,z) = z if x = 0, y otherwise.
*/ */
class OPENMM_EXPORT CustomAngleForce : public Force { class OPENMM_EXPORT CustomAngleForce : public Force {
......
...@@ -65,8 +65,9 @@ namespace OpenMM { ...@@ -65,8 +65,9 @@ namespace OpenMM {
* </pre></tt> * </pre></tt>
* *
* Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following * Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following
* functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta. All trigonometric functions * functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta, select. All trigonometric functions
* are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise. * are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise.
* select(x,y,z) = z if x = 0, y otherwise.
*/ */
class OPENMM_EXPORT CustomBondForce : public Force { class OPENMM_EXPORT CustomBondForce : public Force {
......
...@@ -89,8 +89,9 @@ namespace OpenMM { ...@@ -89,8 +89,9 @@ namespace OpenMM {
* </pre></tt> * </pre></tt>
* *
* Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following * Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following
* functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta. All trigonometric functions * functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta, select. All trigonometric functions
* are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise. * are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise.
* select(x,y,z) = z if x = 0, y otherwise.
* *
* In addition, you can call addTabulatedFunction() to define a new function based on tabulated values. You specify the function by * In addition, you can call addTabulatedFunction() to define a new function based on tabulated values. You specify the function by
* creating a TabulatedFunction object. That function can then appear in the expression. * creating a TabulatedFunction object. That function can then appear in the expression.
......
...@@ -68,8 +68,9 @@ namespace OpenMM { ...@@ -68,8 +68,9 @@ namespace OpenMM {
* </pre></tt> * </pre></tt>
* *
* Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following * Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following
* functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta. All trigonometric functions * functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta, select. All trigonometric functions
* are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise. * are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise.
* select(x,y,z) = z if x = 0, y otherwise.
*/ */
class OPENMM_EXPORT CustomExternalForce : public Force { class OPENMM_EXPORT CustomExternalForce : public Force {
......
...@@ -129,9 +129,9 @@ namespace OpenMM { ...@@ -129,9 +129,9 @@ namespace OpenMM {
* particular piece of the computation. * particular piece of the computation.
* *
* Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following * Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following
* functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta. All trigonometric functions * functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta, select. All trigonometric functions
* are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise. In expressions for * are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise.
* particle pair calculations, the names of per-particle parameters and computed values * select(x,y,z) = z if x = 0, y otherwise. In expressions for particle pair calculations, the names of per-particle parameters and computed values
* have the suffix "1" or "2" appended to them to indicate the values for the two interacting particles. As seen in the above example, * have the suffix "1" or "2" appended to them to indicate the values for the two interacting particles. As seen in the above example,
* an expression may also involve intermediate quantities that are defined following the main expression, using ";" as a separator. * an expression may also involve intermediate quantities that are defined following the main expression, using ";" as a separator.
* *
......
...@@ -89,8 +89,9 @@ namespace OpenMM { ...@@ -89,8 +89,9 @@ namespace OpenMM {
* </pre></tt> * </pre></tt>
* *
* Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following * Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following
* functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta. All trigonometric functions * functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta, select. All trigonometric functions
* are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise. * are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise.
* select(x,y,z) = z if x = 0, y otherwise.
* *
* In addition, you can call addTabulatedFunction() to define a new function based on tabulated values. You specify the function by * In addition, you can call addTabulatedFunction() to define a new function based on tabulated values. You specify the function by
* creating a TabulatedFunction object. That function can then appear in the expression. * creating a TabulatedFunction object. That function can then appear in the expression.
......
...@@ -204,9 +204,9 @@ namespace OpenMM { ...@@ -204,9 +204,9 @@ namespace OpenMM {
* the force from a single force group, or a random number. * the force from a single force group, or a random number.
* *
* Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following * Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following
* functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta. All trigonometric functions * functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta, select. All trigonometric functions
* are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise. An expression * are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise.
* may also involve intermediate quantities that are defined following the main expression, using ";" as a separator. * select(x,y,z) = z if x = 0, y otherwise. An expression may also involve intermediate quantities that are defined following the main expression, using ";" as a separator.
*/ */
class OPENMM_EXPORT CustomIntegrator : public Integrator { class OPENMM_EXPORT CustomIntegrator : public Integrator {
......
...@@ -149,10 +149,10 @@ namespace OpenMM { ...@@ -149,10 +149,10 @@ namespace OpenMM {
* still only be evaluated once for each triplet, so it must still be symmetric with respect to p2 and p3. * still only be evaluated once for each triplet, so it must still be symmetric with respect to p2 and p3.
* *
* Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following * Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following
* functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta. All trigonometric functions * functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta, select. All trigonometric functions
* are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise. * are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise.
* The names of per-particle parameters have the suffix "1", "2", etc. appended to them to indicate the values for the multiple interacting particles. * select(x,y,z) = z if x = 0, y otherwise. The names of per-particle parameters have the suffix "1", "2", etc. appended to them to indicate the values for
* For example, if you define a per-particle parameter called "charge", then the variable "charge2" is the charge of particle p2. * the multiple interacting particles. For example, if you define a per-particle parameter called "charge", then the variable "charge2" is the charge of particle p2.
* As seen above, the expression may also involve intermediate quantities that are defined following the main expression, using ";" as a separator. * As seen above, the expression may also involve intermediate quantities that are defined following the main expression, using ";" as a separator.
* *
* In addition, you can call addTabulatedFunction() to define a new function based on tabulated values. You specify the function by * In addition, you can call addTabulatedFunction() to define a new function based on tabulated values. You specify the function by
......
...@@ -120,10 +120,11 @@ namespace OpenMM { ...@@ -120,10 +120,11 @@ namespace OpenMM {
* frequently, the long range correction can be very slow. For this reason, it is disabled by default. * frequently, the long range correction can be very slow. For this reason, it is disabled by default.
* *
* Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following * Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following
* functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta. All trigonometric functions * functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta, select. All trigonometric functions
* are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise. The names of per-particle parameters * are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise.
* have the suffix "1" or "2" appended to them to indicate the values for the two interacting particles. As seen in the above example, * select(x,y,z) = z if x = 0, y otherwise. The names of per-particle parameters have the suffix "1" or "2" appended to them to indicate the values for the
* the expression may also involve intermediate quantities that are defined following the main expression, using ";" as a separator. * two interacting particles. As seen in the above example, the expression may also involve intermediate quantities that are defined following the main expression,
* using ";" as a separator.
* *
* In addition, you can call addTabulatedFunction() to define a new function based on tabulated values. You specify the function by * In addition, you can call addTabulatedFunction() to define a new function based on tabulated values. You specify the function by
* creating a TabulatedFunction object. That function can then appear in the expression. * creating a TabulatedFunction object. That function can then appear in the expression.
......
...@@ -65,8 +65,9 @@ namespace OpenMM { ...@@ -65,8 +65,9 @@ namespace OpenMM {
* </pre></tt> * </pre></tt>
* *
* Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following * Expressions may involve the operators + (add), - (subtract), * (multiply), / (divide), and ^ (power), and the following
* functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta. All trigonometric functions * functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, floor, ceil, step, delta, select. All trigonometric functions
* are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise. * are defined in radians, and log is the natural logarithm. step(x) = 0 if x is less than 0, 1 otherwise. delta(x) = 1 if x is 0, 0 otherwise.
* select(x,y,z) = z if x = 0, y otherwise.
*/ */
class OPENMM_EXPORT CustomTorsionForce : public Force { class OPENMM_EXPORT CustomTorsionForce : public Force {
......
...@@ -54,12 +54,12 @@ public: ...@@ -54,12 +54,12 @@ public:
* @param context a Context specifying the System to minimize and the initial particle positions * @param context a Context specifying the System to minimize and the initial particle positions
* @param tolerance this specifies how precisely the energy minimum must be located. Minimization * @param tolerance this specifies how precisely the energy minimum must be located. Minimization
* will be halted once the root-mean-square value of all force components reaches * will be halted once the root-mean-square value of all force components reaches
* this tolerance. The default value is 1. * this tolerance. The default value is 10.
* @param maxIterations the maximum number of iterations to perform. If this is 0, minimation is continued * @param maxIterations the maximum number of iterations to perform. If this is 0, minimation is continued
* until the results converge without regard to how many iterations it takes. The * until the results converge without regard to how many iterations it takes. The
* default value is 0. * default value is 0.
*/ */
static void minimize(Context& context, double tolerance = 1, int maxIterations = 0); static void minimize(Context& context, double tolerance = 10, int maxIterations = 0);
}; };
} // namespace OpenMM } // namespace OpenMM
......
/* Portions copyright (c) 2006-2013 Stanford University and Simbios. /* Portions copyright (c) 2006-2015 Stanford University and Simbios.
* Contributors: Pande Group * Contributors: Pande Group
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -364,15 +364,15 @@ void CpuNonbondedForce::threadComputeDirect(ThreadPool& threads, int threadIndex ...@@ -364,15 +364,15 @@ void CpuNonbondedForce::threadComputeDirect(ThreadPool& threads, int threadIndex
float inverseR = 1/r; float inverseR = 1/r;
float chargeProd = ONE_4PI_EPS0*posq[4*i+3]*posq[4*j+3]; float chargeProd = ONE_4PI_EPS0*posq[4*i+3]*posq[4*j+3];
float alphaR = alphaEwald*r; float alphaR = alphaEwald*r;
float erfcAlphaR = erfcApprox(alphaR); float erfAlphaR = erf(alphaR);
if (1-erfcAlphaR > 1e-6f) { if (erfAlphaR > 1e-6f) {
float dEdR = (float) (chargeProd * inverseR * inverseR * inverseR); float dEdR = (float) (chargeProd * inverseR * inverseR * inverseR);
dEdR = (float) (dEdR * (1.0f-erfcAlphaR-TWO_OVER_SQRT_PI*alphaR*exp(-alphaR*alphaR))); dEdR = (float) (dEdR * (erfAlphaR-TWO_OVER_SQRT_PI*alphaR*exp(-alphaR*alphaR)));
fvec4 result = deltaR*dEdR; fvec4 result = deltaR*dEdR;
(fvec4(forces+4*i)-result).store(forces+4*i); (fvec4(forces+4*i)-result).store(forces+4*i);
(fvec4(forces+4*j)+result).store(forces+4*j); (fvec4(forces+4*j)+result).store(forces+4*j);
if (includeEnergy) if (includeEnergy)
threadEnergy[threadIndex] -= chargeProd*inverseR*(1.0f-erfcAlphaR); threadEnergy[threadIndex] -= chargeProd*inverseR*erfAlphaR;
} }
} }
} }
......
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