Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
dabc225e
"platforms/reference/include/CpuObc.h" did not exist on "2cfc68215e38966587f6dbfbcf6918f04c363a86"
Commit
dabc225e
authored
Jan 23, 2014
by
peastman
Browse files
Created new API for tabulated functions
parent
77a54244
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
458 additions
and
154 deletions
+458
-154
openmmapi/include/OpenMM.h
openmmapi/include/OpenMM.h
+1
-0
openmmapi/include/openmm/CustomCompoundBondForce.h
openmmapi/include/openmm/CustomCompoundBondForce.h
+43
-23
openmmapi/include/openmm/CustomGBForce.h
openmmapi/include/openmm/CustomGBForce.h
+45
-25
openmmapi/include/openmm/CustomHbondForce.h
openmmapi/include/openmm/CustomHbondForce.h
+43
-23
openmmapi/include/openmm/CustomNonbondedForce.h
openmmapi/include/openmm/CustomNonbondedForce.h
+43
-23
openmmapi/include/openmm/TabulatedFunction.h
openmmapi/include/openmm/TabulatedFunction.h
+106
-0
openmmapi/src/CustomCompoundBondForce.cpp
openmmapi/src/CustomCompoundBondForce.cpp
+29
-15
openmmapi/src/CustomGBForce.cpp
openmmapi/src/CustomGBForce.cpp
+29
-15
openmmapi/src/CustomHbondForce.cpp
openmmapi/src/CustomHbondForce.cpp
+29
-15
openmmapi/src/CustomNonbondedForce.cpp
openmmapi/src/CustomNonbondedForce.cpp
+28
-15
openmmapi/src/TabulatedFunction.cpp
openmmapi/src/TabulatedFunction.cpp
+62
-0
No files found.
openmmapi/include/OpenMM.h
View file @
dabc225e
...
@@ -62,6 +62,7 @@
...
@@ -62,6 +62,7 @@
#include "openmm/RBTorsionForce.h"
#include "openmm/RBTorsionForce.h"
#include "openmm/State.h"
#include "openmm/State.h"
#include "openmm/System.h"
#include "openmm/System.h"
#include "openmm/TabulatedFunction.h"
#include "openmm/Units.h"
#include "openmm/Units.h"
#include "openmm/VariableLangevinIntegrator.h"
#include "openmm/VariableLangevinIntegrator.h"
#include "openmm/VariableVerletIntegrator.h"
#include "openmm/VariableVerletIntegrator.h"
...
...
openmmapi/include/openmm/CustomCompoundBondForce.h
View file @
dabc225e
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
#include "TabulatedFunction.h"
#include "Force.h"
#include "Force.h"
#include "Vec3.h"
#include "Vec3.h"
#include <vector>
#include <vector>
...
@@ -91,8 +92,8 @@ namespace OpenMM {
...
@@ -91,8 +92,8 @@ namespace OpenMM {
* functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, 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, step, delta. 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.
*
*
* In addition, you can call addFunction() to define a new function based on tabulated values. You specify
a vector of
* In addition, you can call addFunction() to define a new function based on tabulated values. You specify
the function by
*
values, and a natural spline is created from them
. That function can then appear in the expression.
*
creating a TabulatedFunction object
. That function can then appear in the expression.
*/
*/
class
OPENMM_EXPORT
CustomCompoundBondForce
:
public
Force
{
class
OPENMM_EXPORT
CustomCompoundBondForce
:
public
Force
{
...
@@ -229,33 +230,54 @@ public:
...
@@ -229,33 +230,54 @@ public:
* Add a tabulated function that may appear in the energy expression.
* Add a tabulated function that may appear in the energy expression.
*
*
* @param name the name of the function as it appears in expressions
* @param name the name of the function as it appears in expressions
* @param values the tabulated values of the function f(x) at uniformly spaced values of x between min and max.
* @param function a TabulatedFunction object defining the function. The TabulatedFunction
* The function is assumed to be zero for x < min or x > max.
* should have been created on the heap with the "new" operator. The
* @param min the value of the independent variable corresponding to the first element of values
* Force takes over ownership of it, and deletes it when the Force itself is deleted.
* @param max the value of the independent variable corresponding to the last element of values
* @return the index of the function that was added
* @return the index of the function that was added
*/
*/
int
addFunction
(
const
std
::
string
&
name
,
TabulatedFunction
*
function
);
/**
* Get a const reference to a tabulated function that may appear in the energy expression.
*
* @param index the index of the function to get
* @return the TabulatedFunction object defining the function
*/
const
TabulatedFunction
&
getFunction
(
int
index
)
const
;
/**
* Get a reference to a tabulated function that may appear in the energy expression.
*
* @param index the index of the function to get
* @return the TabulatedFunction object defining the function
*/
TabulatedFunction
&
getFunction
(
int
index
);
/**
* Get the name of a tabulated function that may appear in the energy expression.
*
* @param index the index of the function to get
* @return the name of the function as it appears in expressions
*/
const
std
::
string
&
getFunctionName
(
int
index
);
/**
* Add a tabulated function that may appear in the energy expression.
*
* @deprecated This method exists only for backward compatibility. Use the version that takes
* a TabulatedFunction instead.
*/
int
addFunction
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
int
addFunction
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
/**
/**
* Get the parameters for a tabulated function that may appear in the energy expression.
* Get the parameters for a tabulated function that may appear in the energy expression.
*
*
* @param index the index of the function for which to get parameters
* @deprecated This method exists only for backward compatibility. Use the version that takes
* @param name the name of the function as it appears in expressions
* a TabulatedFunction instead. If the specified function is not a Continuous1DFunction, this throws
* @param values the tabulated values of the function f(x) at uniformly spaced values of x between min and max.
* an exception.
* The function is assumed to be zero for x < min or x > max.
* @param min the value of the independent variable corresponding to the first element of values
* @param max the value of the independent variable corresponding to the last element of values
*/
*/
void
getFunctionParameters
(
int
index
,
std
::
string
&
name
,
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
;
void
getFunctionParameters
(
int
index
,
std
::
string
&
name
,
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
;
/**
/**
* Set the parameters for a tabulated function that may appear in
algebraic
expression
s
.
* Set the parameters for a tabulated function that may appear in
the energy
expression.
*
*
* @param index the index of the function for which to set parameters
* @deprecated This method exists only for backward compatibility. Use the version that takes
* @param name the name of the function as it appears in expressions
* a TabulatedFunction instead. If the specified function is not a Continuous1DFunction, this throws
* @param values the tabulated values of the function f(x) at uniformly spaced values of x between min and max.
* an exception.
* The function is assumed to be zero for x < min or x > max.
* @param min the value of the independent variable corresponding to the first element of values
* @param max the value of the independent variable corresponding to the last element of values
*/
*/
void
setFunctionParameters
(
int
index
,
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
void
setFunctionParameters
(
int
index
,
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
/**
/**
...
@@ -333,12 +355,10 @@ public:
...
@@ -333,12 +355,10 @@ public:
class
CustomCompoundBondForce
::
FunctionInfo
{
class
CustomCompoundBondForce
::
FunctionInfo
{
public:
public:
std
::
string
name
;
std
::
string
name
;
std
::
vector
<
double
>
values
;
TabulatedFunction
*
function
;
double
min
,
max
;
FunctionInfo
()
{
FunctionInfo
()
{
}
}
FunctionInfo
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
:
FunctionInfo
(
const
std
::
string
&
name
,
TabulatedFunction
*
function
)
:
name
(
name
),
function
(
function
)
{
name
(
name
),
values
(
values
),
min
(
min
),
max
(
max
)
{
}
}
};
};
...
...
openmmapi/include/openmm/CustomGBForce.h
View file @
dabc225e
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
#include "TabulatedFunction.h"
#include "Force.h"
#include "Force.h"
#include "Vec3.h"
#include "Vec3.h"
#include <map>
#include <map>
...
@@ -134,8 +135,8 @@ namespace OpenMM {
...
@@ -134,8 +135,8 @@ namespace OpenMM {
* 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.
*
*
* In addition, you can call addFunction() to define a new function based on tabulated values. You specify
a vector of
* In addition, you can call addFunction() to define a new function based on tabulated values. You specify
the function by
*
values, and a natural spline is created from them
. That function can then appear in expressions.
*
creating a TabulatedFunction object
. That function can then appear in expressions.
*/
*/
class
OPENMM_EXPORT
CustomGBForce
:
public
Force
{
class
OPENMM_EXPORT
CustomGBForce
:
public
Force
{
...
@@ -452,36 +453,57 @@ public:
...
@@ -452,36 +453,57 @@ public:
*/
*/
void
setExclusionParticles
(
int
index
,
int
particle1
,
int
particle2
);
void
setExclusionParticles
(
int
index
,
int
particle1
,
int
particle2
);
/**
/**
* Add a tabulated function that may appear in
the energy
expression.
* Add a tabulated function that may appear in expression
s
.
*
*
* @param name the name of the function as it appears in expressions
* @param name the name of the function as it appears in expressions
* @param values the tabulated values of the function f(x) at uniformly spaced values of x between min and max.
* @param function a TabulatedFunction object defining the function. The TabulatedFunction
* The function is assumed to be zero for x < min or x > max.
* should have been created on the heap with the "new" operator. The
* @param min the value of the independent variable corresponding to the first element of values
* Force takes over ownership of it, and deletes it when the Force itself is deleted.
* @param max the value of the independent variable corresponding to the last element of values
* @return the index of the function that was added
* @return the index of the function that was added
*/
*/
int
addFunction
(
const
std
::
string
&
name
,
TabulatedFunction
*
function
);
/**
* Get a const reference to a tabulated function that may appear in expressions.
*
* @param index the index of the function to get
* @return the TabulatedFunction object defining the function
*/
const
TabulatedFunction
&
getFunction
(
int
index
)
const
;
/**
* Get a reference to a tabulated function that may appear in expressions.
*
* @param index the index of the function to get
* @return the TabulatedFunction object defining the function
*/
TabulatedFunction
&
getFunction
(
int
index
);
/**
* Get the name of a tabulated function that may appear in expressions.
*
* @param index the index of the function to get
* @return the name of the function as it appears in expressions
*/
const
std
::
string
&
getFunctionName
(
int
index
);
/**
* Add a tabulated function that may appear in expressions.
*
* @deprecated This method exists only for backward compatibility. Use the version that takes
* a TabulatedFunction instead.
*/
int
addFunction
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
int
addFunction
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
/**
/**
* Get the parameters for a tabulated function that may appear in
the energy
expression.
* Get the parameters for a tabulated function that may appear in expression
s
.
*
*
* @param index the index of the function for which to get parameters
* @deprecated This method exists only for backward compatibility. Use the version that takes
* @param name the name of the function as it appears in expressions
* a TabulatedFunction instead. If the specified function is not a Continuous1DFunction, this throws
* @param values the tabulated values of the function f(x) at uniformly spaced values of x between min and max.
* an exception.
* The function is assumed to be zero for x < min or x > max.
* @param min the value of the independent variable corresponding to the first element of values
* @param max the value of the independent variable corresponding to the last element of values
*/
*/
void
getFunctionParameters
(
int
index
,
std
::
string
&
name
,
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
;
void
getFunctionParameters
(
int
index
,
std
::
string
&
name
,
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
;
/**
/**
* Set the parameters for a tabulated function that may appear in
algebraic
expressions.
* Set the parameters for a tabulated function that may appear in expressions.
*
*
* @param index the index of the function for which to set parameters
* @deprecated This method exists only for backward compatibility. Use the version that takes
* @param name the name of the function as it appears in expressions
* a TabulatedFunction instead. If the specified function is not a Continuous1DFunction, this throws
* @param values the tabulated values of the function f(x) at uniformly spaced values of x between min and max.
* an exception.
* The function is assumed to be zero for x < min or x > max.
* @param min the value of the independent variable corresponding to the first element of values
* @param max the value of the independent variable corresponding to the last element of values
*/
*/
void
setFunctionParameters
(
int
index
,
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
void
setFunctionParameters
(
int
index
,
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
/**
/**
...
@@ -577,12 +599,10 @@ public:
...
@@ -577,12 +599,10 @@ public:
class
CustomGBForce
::
FunctionInfo
{
class
CustomGBForce
::
FunctionInfo
{
public:
public:
std
::
string
name
;
std
::
string
name
;
std
::
vector
<
double
>
values
;
TabulatedFunction
*
function
;
double
min
,
max
;
FunctionInfo
()
{
FunctionInfo
()
{
}
}
FunctionInfo
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
:
FunctionInfo
(
const
std
::
string
&
name
,
TabulatedFunction
*
function
)
:
name
(
name
),
function
(
function
)
{
name
(
name
),
values
(
values
),
min
(
min
),
max
(
max
)
{
}
}
};
};
...
...
openmmapi/include/openmm/CustomHbondForce.h
View file @
dabc225e
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
#include "TabulatedFunction.h"
#include "Force.h"
#include "Force.h"
#include "Vec3.h"
#include "Vec3.h"
#include <map>
#include <map>
...
@@ -91,8 +92,8 @@ namespace OpenMM {
...
@@ -91,8 +92,8 @@ namespace OpenMM {
* functions: sqrt, exp, log, sin, cos, sec, csc, tan, cot, asin, acos, atan, sinh, cosh, tanh, erf, erfc, min, max, abs, 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, step, delta. 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.
*
*
* In addition, you can call addFunction() to define a new function based on tabulated values. You specify
a vector of
* In addition, you can call addFunction() to define a new function based on tabulated values. You specify
the function by
*
values, and a natural spline is created from them
. That function can then appear in the expression.
*
creating a TabulatedFunction object
. That function can then appear in the expression.
*/
*/
class
OPENMM_EXPORT
CustomHbondForce
:
public
Force
{
class
OPENMM_EXPORT
CustomHbondForce
:
public
Force
{
...
@@ -374,33 +375,54 @@ public:
...
@@ -374,33 +375,54 @@ public:
* Add a tabulated function that may appear in the energy expression.
* Add a tabulated function that may appear in the energy expression.
*
*
* @param name the name of the function as it appears in expressions
* @param name the name of the function as it appears in expressions
* @param values the tabulated values of the function f(x) at uniformly spaced values of x between min and max.
* @param function a TabulatedFunction object defining the function. The TabulatedFunction
* The function is assumed to be zero for x < min or x > max.
* should have been created on the heap with the "new" operator. The
* @param min the value of the independent variable corresponding to the first element of values
* Force takes over ownership of it, and deletes it when the Force itself is deleted.
* @param max the value of the independent variable corresponding to the last element of values
* @return the index of the function that was added
* @return the index of the function that was added
*/
*/
int
addFunction
(
const
std
::
string
&
name
,
TabulatedFunction
*
function
);
/**
* Get a const reference to a tabulated function that may appear in the energy expression.
*
* @param index the index of the function to get
* @return the TabulatedFunction object defining the function
*/
const
TabulatedFunction
&
getFunction
(
int
index
)
const
;
/**
* Get a reference to a tabulated function that may appear in the energy expression.
*
* @param index the index of the function to get
* @return the TabulatedFunction object defining the function
*/
TabulatedFunction
&
getFunction
(
int
index
);
/**
* Get the name of a tabulated function that may appear in the energy expression.
*
* @param index the index of the function to get
* @return the name of the function as it appears in expressions
*/
const
std
::
string
&
getFunctionName
(
int
index
);
/**
* Add a tabulated function that may appear in the energy expression.
*
* @deprecated This method exists only for backward compatibility. Use the version that takes
* a TabulatedFunction instead.
*/
int
addFunction
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
int
addFunction
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
/**
/**
* Get the parameters for a tabulated function that may appear in the energy expression.
* Get the parameters for a tabulated function that may appear in the energy expression.
*
*
* @param index the index of the function for which to get parameters
* @deprecated This method exists only for backward compatibility. Use the version that takes
* @param name the name of the function as it appears in expressions
* a TabulatedFunction instead. If the specified function is not a Continuous1DFunction, this throws
* @param values the tabulated values of the function f(x) at uniformly spaced values of x between min and max.
* an exception.
* The function is assumed to be zero for x < min or x > max.
* @param min the value of the independent variable corresponding to the first element of values
* @param max the value of the independent variable corresponding to the last element of values
*/
*/
void
getFunctionParameters
(
int
index
,
std
::
string
&
name
,
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
;
void
getFunctionParameters
(
int
index
,
std
::
string
&
name
,
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
;
/**
/**
* Set the parameters for a tabulated function that may appear in
algebraic
expression
s
.
* Set the parameters for a tabulated function that may appear in
the energy
expression.
*
*
* @param index the index of the function for which to set parameters
* @deprecated This method exists only for backward compatibility. Use the version that takes
* @param name the name of the function as it appears in expressions
* a TabulatedFunction instead. If the specified function is not a Continuous1DFunction, this throws
* @param values the tabulated values of the function f(x) at uniformly spaced values of x between min and max.
* an exception.
* The function is assumed to be zero for x < min or x > max.
* @param min the value of the independent variable corresponding to the first element of values
* @param max the value of the independent variable corresponding to the last element of values
*/
*/
void
setFunctionParameters
(
int
index
,
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
void
setFunctionParameters
(
int
index
,
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
/**
/**
...
@@ -499,12 +521,10 @@ public:
...
@@ -499,12 +521,10 @@ public:
class
CustomHbondForce
::
FunctionInfo
{
class
CustomHbondForce
::
FunctionInfo
{
public:
public:
std
::
string
name
;
std
::
string
name
;
std
::
vector
<
double
>
values
;
TabulatedFunction
*
function
;
double
min
,
max
;
FunctionInfo
()
{
FunctionInfo
()
{
}
}
FunctionInfo
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
:
FunctionInfo
(
const
std
::
string
&
name
,
TabulatedFunction
*
function
)
:
name
(
name
),
function
(
function
)
{
name
(
name
),
values
(
values
),
min
(
min
),
max
(
max
)
{
}
}
};
};
...
...
openmmapi/include/openmm/CustomNonbondedForce.h
View file @
dabc225e
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
#include "TabulatedFunction.h"
#include "Force.h"
#include "Force.h"
#include "Vec3.h"
#include "Vec3.h"
#include <map>
#include <map>
...
@@ -124,8 +125,8 @@ namespace OpenMM {
...
@@ -124,8 +125,8 @@ namespace OpenMM {
* 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,
* the expression may also involve intermediate quantities that are defined following the main expression, using ";" as a separator.
* the expression may also involve intermediate quantities that are defined following the main expression, using ";" as a separator.
*
*
* In addition, you can call addFunction() to define a new function based on tabulated values. You specify
a vector of
* In addition, you can call addFunction() to define a new function based on tabulated values. You specify
the function by
*
values, and a natural spline is created from them
. That function can then appear in the expression.
*
creating a TabulatedFunction object
. That function can then appear in the expression.
*/
*/
class
OPENMM_EXPORT
CustomNonbondedForce
:
public
Force
{
class
OPENMM_EXPORT
CustomNonbondedForce
:
public
Force
{
...
@@ -359,33 +360,54 @@ public:
...
@@ -359,33 +360,54 @@ public:
* Add a tabulated function that may appear in the energy expression.
* Add a tabulated function that may appear in the energy expression.
*
*
* @param name the name of the function as it appears in expressions
* @param name the name of the function as it appears in expressions
* @param values the tabulated values of the function f(x) at uniformly spaced values of x between min and max.
* @param function a TabulatedFunction object defining the function. The TabulatedFunction
* The function is assumed to be zero for x < min or x > max.
* should have been created on the heap with the "new" operator. The
* @param min the value of the independent variable corresponding to the first element of values
* Force takes over ownership of it, and deletes it when the Force itself is deleted.
* @param max the value of the independent variable corresponding to the last element of values
* @return the index of the function that was added
* @return the index of the function that was added
*/
*/
int
addFunction
(
const
std
::
string
&
name
,
TabulatedFunction
*
function
);
/**
* Get a const reference to a tabulated function that may appear in the energy expression.
*
* @param index the index of the function to get
* @return the TabulatedFunction object defining the function
*/
const
TabulatedFunction
&
getFunction
(
int
index
)
const
;
/**
* Get a reference to a tabulated function that may appear in the energy expression.
*
* @param index the index of the function to get
* @return the TabulatedFunction object defining the function
*/
TabulatedFunction
&
getFunction
(
int
index
);
/**
* Get the name of a tabulated function that may appear in the energy expression.
*
* @param index the index of the function to get
* @return the name of the function as it appears in expressions
*/
const
std
::
string
&
getFunctionName
(
int
index
);
/**
* Add a tabulated function that may appear in the energy expression.
*
* @deprecated This method exists only for backward compatibility. Use the version that takes
* a TabulatedFunction instead.
*/
int
addFunction
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
int
addFunction
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
/**
/**
* Get the parameters for a tabulated function that may appear in the energy expression.
* Get the parameters for a tabulated function that may appear in the energy expression.
*
*
* @param index the index of the function for which to get parameters
* @deprecated This method exists only for backward compatibility. Use the version that takes
* @param name the name of the function as it appears in expressions
* a TabulatedFunction instead. If the specified function is not a Continuous1DFunction, this throws
* @param values the tabulated values of the function f(x) at uniformly spaced values of x between min and max.
* an exception.
* The function is assumed to be zero for x < min or x > max.
* @param min the value of the independent variable corresponding to the first element of values
* @param max the value of the independent variable corresponding to the last element of values
*/
*/
void
getFunctionParameters
(
int
index
,
std
::
string
&
name
,
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
;
void
getFunctionParameters
(
int
index
,
std
::
string
&
name
,
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
;
/**
/**
* Set the parameters for a tabulated function that may appear in
algebraic
expression
s
.
* Set the parameters for a tabulated function that may appear in
the energy
expression.
*
*
* @param index the index of the function for which to set parameters
* @deprecated This method exists only for backward compatibility. Use the version that takes
* @param name the name of the function as it appears in expressions
* a TabulatedFunction instead. If the specified function is not a Continuous1DFunction, this throws
* @param values the tabulated values of the function f(x) at uniformly spaced values of x between min and max.
* an exception.
* The function is assumed to be zero for x < min or x > max.
* @param min the value of the independent variable corresponding to the first element of values
* @param max the value of the independent variable corresponding to the last element of values
*/
*/
void
setFunctionParameters
(
int
index
,
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
void
setFunctionParameters
(
int
index
,
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
/**
/**
...
@@ -507,12 +529,10 @@ public:
...
@@ -507,12 +529,10 @@ public:
class
CustomNonbondedForce
::
FunctionInfo
{
class
CustomNonbondedForce
::
FunctionInfo
{
public:
public:
std
::
string
name
;
std
::
string
name
;
std
::
vector
<
double
>
values
;
TabulatedFunction
*
function
;
double
min
,
max
;
FunctionInfo
()
{
FunctionInfo
()
{
}
}
FunctionInfo
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
:
FunctionInfo
(
const
std
::
string
&
name
,
TabulatedFunction
*
function
)
:
name
(
name
),
function
(
function
)
{
name
(
name
),
values
(
values
),
min
(
min
),
max
(
max
)
{
}
}
};
};
...
...
openmmapi/include/openmm/TabulatedFunction.h
0 → 100644
View file @
dabc225e
#ifndef OPENMM_TabulatedFunction_H_
#define OPENMM_TabulatedFunction_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) 2014 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 "internal/windowsExport.h"
#include <vector>
namespace
OpenMM
{
/**
* A TabulatedFunction uses a set of tabulated values to define a mathematical function.
* It can be used by various custom forces.
*
* TabulatedFunction is an abstract class with concrete subclasses for more specific
* types of functions. There are subclasses for:
*
* <ul>
* <li>1, 2, and 3 dimensional functions. The dimensionality of a function means
* the number of input arguments it takes.</li>
* <li>Continuous and discrete functions. A continuous function is interpolated by
* fitting a natural cubic spline to the tabulated values. A discrete function is
* only defined for integer values of its arguments (that is, at the tabulated points),
* and does not try to interpolate between them. Discrete function can be evaluated
* more quickly than continuous ones.</li>
* </ul>
*/
class
OPENMM_EXPORT
TabulatedFunction
{
public:
virtual
~
TabulatedFunction
()
{
}
};
/**
* This is a TabulatedFunction that computes a continuous one dimensional function.
*/
class
OPENMM_EXPORT
Continuous1DFunction
:
public
TabulatedFunction
{
public:
/**
* Create a Continuous1DFunction f(x) based on a set of tabulated values.
*
* @param values the tabulated values of the function f(x) at uniformly spaced values of x between min
* and max. A natural cubic spline is used to interpolated between the tabulated values.
* The function is assumed to be zero for x < min or x > max.
* @param min the value of x corresponding to the first element of values
* @param max the value of x corresponding to the last element of values
*/
Continuous1DFunction
(
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
/**
* Get the parameters for the tabulated function.
*
* @param values the tabulated values of the function f(x) at uniformly spaced values of x between min
* and max. A natural cubic spline is used to interpolated between the tabulated values.
* The function is assumed to be zero for x < min or x > max.
* @param min the value of x corresponding to the first element of values
* @param max the value of x corresponding to the last element of values
*/
void
getFunctionParameters
(
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
;
/**
* Set the parameters for the tabulated function.
*
* @param values the tabulated values of the function f(x) at uniformly spaced values of x between min
* and max. A natural cubic spline is used to interpolated between the tabulated values.
* The function is assumed to be zero for x < min or x > max.
* @param min the value of x corresponding to the first element of values
* @param max the value of x corresponding to the last element of values
*/
void
setFunctionParameters
(
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
);
private:
std
::
vector
<
double
>
values
;
double
min
,
max
;
};
}
// namespace OpenMM
#endif
/*OPENMM_TabulatedFunction_H_*/
openmmapi/src/CustomCompoundBondForce.cpp
View file @
dabc225e
...
@@ -120,33 +120,47 @@ void CustomCompoundBondForce::setBondParameters(int index, const vector<int>& pa
...
@@ -120,33 +120,47 @@ void CustomCompoundBondForce::setBondParameters(int index, const vector<int>& pa
bonds
[
index
].
parameters
=
parameters
;
bonds
[
index
].
parameters
=
parameters
;
}
}
int
CustomCompoundBondForce
::
addFunction
(
const
std
::
string
&
name
,
TabulatedFunction
*
function
)
{
functions
.
push_back
(
FunctionInfo
(
name
,
function
));
return
functions
.
size
()
-
1
;
}
const
TabulatedFunction
&
CustomCompoundBondForce
::
getFunction
(
int
index
)
const
{
ASSERT_VALID_INDEX
(
index
,
functions
);
return
*
functions
[
index
].
function
;
}
TabulatedFunction
&
CustomCompoundBondForce
::
getFunction
(
int
index
)
{
ASSERT_VALID_INDEX
(
index
,
functions
);
return
*
functions
[
index
].
function
;
}
const
string
&
CustomCompoundBondForce
::
getFunctionName
(
int
index
)
{
ASSERT_VALID_INDEX
(
index
,
functions
);
return
functions
[
index
].
name
;
}
int
CustomCompoundBondForce
::
addFunction
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
int
CustomCompoundBondForce
::
addFunction
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
if
(
max
<=
min
)
functions
.
push_back
(
FunctionInfo
(
name
,
new
Continuous1DFunction
(
values
,
min
,
max
)));
throw
OpenMMException
(
"CustomCompoundBondForce: max <= min for a tabulated function."
);
if
(
values
.
size
()
<
2
)
throw
OpenMMException
(
"CustomCompoundBondForce: a tabulated function must have at least two points"
);
functions
.
push_back
(
FunctionInfo
(
name
,
values
,
min
,
max
));
return
functions
.
size
()
-
1
;
return
functions
.
size
()
-
1
;
}
}
void
CustomCompoundBondForce
::
getFunctionParameters
(
int
index
,
std
::
string
&
name
,
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
{
void
CustomCompoundBondForce
::
getFunctionParameters
(
int
index
,
std
::
string
&
name
,
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
{
ASSERT_VALID_INDEX
(
index
,
functions
);
ASSERT_VALID_INDEX
(
index
,
functions
);
Continuous1DFunction
*
function
=
dynamic_cast
<
Continuous1DFunction
*>
(
functions
[
index
].
function
);
if
(
function
==
NULL
)
throw
OpenMMException
(
"CustomCompoundBondForce: function is not a Continuous1DFunction"
);
name
=
functions
[
index
].
name
;
name
=
functions
[
index
].
name
;
values
=
functions
[
index
].
values
;
function
->
getFunctionParameters
(
values
,
min
,
max
);
min
=
functions
[
index
].
min
;
max
=
functions
[
index
].
max
;
}
}
void
CustomCompoundBondForce
::
setFunctionParameters
(
int
index
,
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
void
CustomCompoundBondForce
::
setFunctionParameters
(
int
index
,
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
if
(
max
<=
min
)
throw
OpenMMException
(
"CustomCompoundBondForce: max <= min for a tabulated function."
);
if
(
values
.
size
()
<
2
)
throw
OpenMMException
(
"CustomCompoundBondForce: a tabulated function must have at least two points"
);
ASSERT_VALID_INDEX
(
index
,
functions
);
ASSERT_VALID_INDEX
(
index
,
functions
);
Continuous1DFunction
*
function
=
dynamic_cast
<
Continuous1DFunction
*>
(
functions
[
index
].
function
);
if
(
function
==
NULL
)
throw
OpenMMException
(
"CustomCompoundBondForce: function is not a Continuous1DFunction"
);
functions
[
index
].
name
=
name
;
functions
[
index
].
name
=
name
;
functions
[
index
].
values
=
values
;
function
->
setFunctionParameters
(
values
,
min
,
max
);
functions
[
index
].
min
=
min
;
functions
[
index
].
max
=
max
;
}
}
ForceImpl
*
CustomCompoundBondForce
::
createImpl
()
const
{
ForceImpl
*
CustomCompoundBondForce
::
createImpl
()
const
{
...
...
openmmapi/src/CustomGBForce.cpp
View file @
dabc225e
...
@@ -173,33 +173,47 @@ void CustomGBForce::setExclusionParticles(int index, int particle1, int particle
...
@@ -173,33 +173,47 @@ void CustomGBForce::setExclusionParticles(int index, int particle1, int particle
exclusions
[
index
].
particle2
=
particle2
;
exclusions
[
index
].
particle2
=
particle2
;
}
}
int
CustomGBForce
::
addFunction
(
const
std
::
string
&
name
,
TabulatedFunction
*
function
)
{
functions
.
push_back
(
FunctionInfo
(
name
,
function
));
return
functions
.
size
()
-
1
;
}
const
TabulatedFunction
&
CustomGBForce
::
getFunction
(
int
index
)
const
{
ASSERT_VALID_INDEX
(
index
,
functions
);
return
*
functions
[
index
].
function
;
}
TabulatedFunction
&
CustomGBForce
::
getFunction
(
int
index
)
{
ASSERT_VALID_INDEX
(
index
,
functions
);
return
*
functions
[
index
].
function
;
}
const
string
&
CustomGBForce
::
getFunctionName
(
int
index
)
{
ASSERT_VALID_INDEX
(
index
,
functions
);
return
functions
[
index
].
name
;
}
int
CustomGBForce
::
addFunction
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
int
CustomGBForce
::
addFunction
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
if
(
max
<=
min
)
functions
.
push_back
(
FunctionInfo
(
name
,
new
Continuous1DFunction
(
values
,
min
,
max
)));
throw
OpenMMException
(
"CustomGBForce: max <= min for a tabulated function."
);
if
(
values
.
size
()
<
2
)
throw
OpenMMException
(
"CustomGBForce: a tabulated function must have at least two points"
);
functions
.
push_back
(
FunctionInfo
(
name
,
values
,
min
,
max
));
return
functions
.
size
()
-
1
;
return
functions
.
size
()
-
1
;
}
}
void
CustomGBForce
::
getFunctionParameters
(
int
index
,
std
::
string
&
name
,
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
{
void
CustomGBForce
::
getFunctionParameters
(
int
index
,
std
::
string
&
name
,
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
{
ASSERT_VALID_INDEX
(
index
,
functions
);
ASSERT_VALID_INDEX
(
index
,
functions
);
Continuous1DFunction
*
function
=
dynamic_cast
<
Continuous1DFunction
*>
(
functions
[
index
].
function
);
if
(
function
==
NULL
)
throw
OpenMMException
(
"CustomGBForce: function is not a Continuous1DFunction"
);
name
=
functions
[
index
].
name
;
name
=
functions
[
index
].
name
;
values
=
functions
[
index
].
values
;
function
->
getFunctionParameters
(
values
,
min
,
max
);
min
=
functions
[
index
].
min
;
max
=
functions
[
index
].
max
;
}
}
void
CustomGBForce
::
setFunctionParameters
(
int
index
,
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
void
CustomGBForce
::
setFunctionParameters
(
int
index
,
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
if
(
max
<=
min
)
throw
OpenMMException
(
"CustomGBForce: max <= min for a tabulated function."
);
if
(
values
.
size
()
<
2
)
throw
OpenMMException
(
"CustomGBForce: a tabulated function must have at least two points"
);
ASSERT_VALID_INDEX
(
index
,
functions
);
ASSERT_VALID_INDEX
(
index
,
functions
);
Continuous1DFunction
*
function
=
dynamic_cast
<
Continuous1DFunction
*>
(
functions
[
index
].
function
);
if
(
function
==
NULL
)
throw
OpenMMException
(
"CustomGBForce: function is not a Continuous1DFunction"
);
functions
[
index
].
name
=
name
;
functions
[
index
].
name
=
name
;
functions
[
index
].
values
=
values
;
function
->
setFunctionParameters
(
values
,
min
,
max
);
functions
[
index
].
min
=
min
;
functions
[
index
].
max
=
max
;
}
}
ForceImpl
*
CustomGBForce
::
createImpl
()
const
{
ForceImpl
*
CustomGBForce
::
createImpl
()
const
{
...
...
openmmapi/src/CustomHbondForce.cpp
View file @
dabc225e
...
@@ -187,33 +187,47 @@ void CustomHbondForce::setExclusionParticles(int index, int donor, int acceptor)
...
@@ -187,33 +187,47 @@ void CustomHbondForce::setExclusionParticles(int index, int donor, int acceptor)
exclusions
[
index
].
acceptor
=
acceptor
;
exclusions
[
index
].
acceptor
=
acceptor
;
}
}
int
CustomHbondForce
::
addFunction
(
const
std
::
string
&
name
,
TabulatedFunction
*
function
)
{
functions
.
push_back
(
FunctionInfo
(
name
,
function
));
return
functions
.
size
()
-
1
;
}
const
TabulatedFunction
&
CustomHbondForce
::
getFunction
(
int
index
)
const
{
ASSERT_VALID_INDEX
(
index
,
functions
);
return
*
functions
[
index
].
function
;
}
TabulatedFunction
&
CustomHbondForce
::
getFunction
(
int
index
)
{
ASSERT_VALID_INDEX
(
index
,
functions
);
return
*
functions
[
index
].
function
;
}
const
string
&
CustomHbondForce
::
getFunctionName
(
int
index
)
{
ASSERT_VALID_INDEX
(
index
,
functions
);
return
functions
[
index
].
name
;
}
int
CustomHbondForce
::
addFunction
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
int
CustomHbondForce
::
addFunction
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
if
(
max
<=
min
)
functions
.
push_back
(
FunctionInfo
(
name
,
new
Continuous1DFunction
(
values
,
min
,
max
)));
throw
OpenMMException
(
"CustomHbondForce: max <= min for a tabulated function."
);
if
(
values
.
size
()
<
2
)
throw
OpenMMException
(
"CustomHbondForce: a tabulated function must have at least two points"
);
functions
.
push_back
(
FunctionInfo
(
name
,
values
,
min
,
max
));
return
functions
.
size
()
-
1
;
return
functions
.
size
()
-
1
;
}
}
void
CustomHbondForce
::
getFunctionParameters
(
int
index
,
std
::
string
&
name
,
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
{
void
CustomHbondForce
::
getFunctionParameters
(
int
index
,
std
::
string
&
name
,
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
{
ASSERT_VALID_INDEX
(
index
,
functions
);
ASSERT_VALID_INDEX
(
index
,
functions
);
Continuous1DFunction
*
function
=
dynamic_cast
<
Continuous1DFunction
*>
(
functions
[
index
].
function
);
if
(
function
==
NULL
)
throw
OpenMMException
(
"CustomHbondForce: function is not a Continuous1DFunction"
);
name
=
functions
[
index
].
name
;
name
=
functions
[
index
].
name
;
values
=
functions
[
index
].
values
;
function
->
getFunctionParameters
(
values
,
min
,
max
);
min
=
functions
[
index
].
min
;
max
=
functions
[
index
].
max
;
}
}
void
CustomHbondForce
::
setFunctionParameters
(
int
index
,
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
void
CustomHbondForce
::
setFunctionParameters
(
int
index
,
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
if
(
max
<=
min
)
throw
OpenMMException
(
"CustomHbondForce: max <= min for a tabulated function."
);
if
(
values
.
size
()
<
2
)
throw
OpenMMException
(
"CustomHbondForce: a tabulated function must have at least two points"
);
ASSERT_VALID_INDEX
(
index
,
functions
);
ASSERT_VALID_INDEX
(
index
,
functions
);
Continuous1DFunction
*
function
=
dynamic_cast
<
Continuous1DFunction
*>
(
functions
[
index
].
function
);
if
(
function
==
NULL
)
throw
OpenMMException
(
"CustomHbondForce: function is not a Continuous1DFunction"
);
functions
[
index
].
name
=
name
;
functions
[
index
].
name
=
name
;
functions
[
index
].
values
=
values
;
function
->
setFunctionParameters
(
values
,
min
,
max
);
functions
[
index
].
min
=
min
;
functions
[
index
].
max
=
max
;
}
}
ForceImpl
*
CustomHbondForce
::
createImpl
()
const
{
ForceImpl
*
CustomHbondForce
::
createImpl
()
const
{
...
...
openmmapi/src/CustomNonbondedForce.cpp
View file @
dabc225e
...
@@ -169,34 +169,47 @@ void CustomNonbondedForce::setExclusionParticles(int index, int particle1, int p
...
@@ -169,34 +169,47 @@ void CustomNonbondedForce::setExclusionParticles(int index, int particle1, int p
exclusions
[
index
].
particle1
=
particle1
;
exclusions
[
index
].
particle1
=
particle1
;
exclusions
[
index
].
particle2
=
particle2
;
exclusions
[
index
].
particle2
=
particle2
;
}
}
int
CustomNonbondedForce
::
addFunction
(
const
std
::
string
&
name
,
TabulatedFunction
*
function
)
{
functions
.
push_back
(
FunctionInfo
(
name
,
function
));
return
functions
.
size
()
-
1
;
}
const
TabulatedFunction
&
CustomNonbondedForce
::
getFunction
(
int
index
)
const
{
ASSERT_VALID_INDEX
(
index
,
functions
);
return
*
functions
[
index
].
function
;
}
TabulatedFunction
&
CustomNonbondedForce
::
getFunction
(
int
index
)
{
ASSERT_VALID_INDEX
(
index
,
functions
);
return
*
functions
[
index
].
function
;
}
const
string
&
CustomNonbondedForce
::
getFunctionName
(
int
index
)
{
ASSERT_VALID_INDEX
(
index
,
functions
);
return
functions
[
index
].
name
;
}
int
CustomNonbondedForce
::
addFunction
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
int
CustomNonbondedForce
::
addFunction
(
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
if
(
max
<=
min
)
functions
.
push_back
(
FunctionInfo
(
name
,
new
Continuous1DFunction
(
values
,
min
,
max
)));
throw
OpenMMException
(
"CustomNonbondedForce: max <= min for a tabulated function."
);
if
(
values
.
size
()
<
2
)
throw
OpenMMException
(
"CustomNonbondedForce: a tabulated function must have at least two points"
);
functions
.
push_back
(
FunctionInfo
(
name
,
values
,
min
,
max
));
return
functions
.
size
()
-
1
;
return
functions
.
size
()
-
1
;
}
}
void
CustomNonbondedForce
::
getFunctionParameters
(
int
index
,
std
::
string
&
name
,
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
{
void
CustomNonbondedForce
::
getFunctionParameters
(
int
index
,
std
::
string
&
name
,
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
{
ASSERT_VALID_INDEX
(
index
,
functions
);
ASSERT_VALID_INDEX
(
index
,
functions
);
Continuous1DFunction
*
function
=
dynamic_cast
<
Continuous1DFunction
*>
(
functions
[
index
].
function
);
if
(
function
==
NULL
)
throw
OpenMMException
(
"CustomNonbondedForce: function is not a Continuous1DFunction"
);
name
=
functions
[
index
].
name
;
name
=
functions
[
index
].
name
;
values
=
functions
[
index
].
values
;
function
->
getFunctionParameters
(
values
,
min
,
max
);
min
=
functions
[
index
].
min
;
max
=
functions
[
index
].
max
;
}
}
void
CustomNonbondedForce
::
setFunctionParameters
(
int
index
,
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
void
CustomNonbondedForce
::
setFunctionParameters
(
int
index
,
const
std
::
string
&
name
,
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
if
(
max
<=
min
)
throw
OpenMMException
(
"CustomNonbondedForce: max <= min for a tabulated function."
);
if
(
values
.
size
()
<
2
)
throw
OpenMMException
(
"CustomNonbondedForce: a tabulated function must have at least two points"
);
ASSERT_VALID_INDEX
(
index
,
functions
);
ASSERT_VALID_INDEX
(
index
,
functions
);
Continuous1DFunction
*
function
=
dynamic_cast
<
Continuous1DFunction
*>
(
functions
[
index
].
function
);
if
(
function
==
NULL
)
throw
OpenMMException
(
"CustomNonbondedForce: function is not a Continuous1DFunction"
);
functions
[
index
].
name
=
name
;
functions
[
index
].
name
=
name
;
functions
[
index
].
values
=
values
;
function
->
setFunctionParameters
(
values
,
min
,
max
);
functions
[
index
].
min
=
min
;
functions
[
index
].
max
=
max
;
}
}
int
CustomNonbondedForce
::
addInteractionGroup
(
const
std
::
set
<
int
>&
set1
,
const
std
::
set
<
int
>&
set2
)
{
int
CustomNonbondedForce
::
addInteractionGroup
(
const
std
::
set
<
int
>&
set1
,
const
std
::
set
<
int
>&
set2
)
{
...
...
openmmapi/src/TabulatedFunction.cpp
0 → 100644
View file @
dabc225e
/* -------------------------------------------------------------------------- *
* 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) 2014 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/TabulatedFunction.h"
#include "openmm/OpenMMException.h"
using
namespace
OpenMM
;
using
namespace
std
;
Continuous1DFunction
::
Continuous1DFunction
(
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
if
(
max
<=
min
)
throw
OpenMMException
(
"Continuous1DFunction: max <= min for a tabulated function."
);
if
(
values
.
size
()
<
2
)
throw
OpenMMException
(
"Continuous1DFunction: a tabulated function must have at least two points"
);
this
->
values
=
values
;
this
->
min
=
min
;
this
->
max
=
max
;
}
void
Continuous1DFunction
::
getFunctionParameters
(
std
::
vector
<
double
>&
values
,
double
&
min
,
double
&
max
)
const
{
values
=
this
->
values
;
min
=
this
->
min
;
max
=
this
->
max
;
}
void
Continuous1DFunction
::
setFunctionParameters
(
const
std
::
vector
<
double
>&
values
,
double
min
,
double
max
)
{
if
(
max
<=
min
)
throw
OpenMMException
(
"Continuous1DFunction: max <= min for a tabulated function."
);
if
(
values
.
size
()
<
2
)
throw
OpenMMException
(
"Continuous1DFunction: a tabulated function must have at least two points"
);
this
->
values
=
values
;
this
->
min
=
min
;
this
->
max
=
max
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment