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
d099819a
Commit
d099819a
authored
Aug 03, 2009
by
Peter Eastman
Browse files
Global parameters defined by CustomNonbondedForce can have default values
parent
3ea53872
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
12 deletions
+46
-12
openmmapi/include/openmm/CustomNonbondedForce.h
openmmapi/include/openmm/CustomNonbondedForce.h
+28
-2
openmmapi/include/openmm/Force.h
openmmapi/include/openmm/Force.h
+3
-3
openmmapi/src/CustomNonbondedForce.cpp
openmmapi/src/CustomNonbondedForce.cpp
+12
-4
openmmapi/src/CustomNonbondedForceImpl.cpp
openmmapi/src/CustomNonbondedForceImpl.cpp
+1
-1
platforms/reference/tests/TestReferenceCustomNonbondedForce.cpp
...rms/reference/tests/TestReferenceCustomNonbondedForce.cpp
+2
-2
No files found.
openmmapi/include/openmm/CustomNonbondedForce.h
View file @
d099819a
...
@@ -187,9 +187,10 @@ public:
...
@@ -187,9 +187,10 @@ public:
* Add a new global parmeter that the interaction may depend on.
* Add a new global parmeter that the interaction may depend on.
*
*
* @param name the name of the parameter
* @param name the name of the parameter
* @param defaultValue the default value of the parameter
* @return the index of the parameter that was added
* @return the index of the parameter that was added
*/
*/
int
addGlobalParameter
(
const
std
::
string
&
name
);
int
addGlobalParameter
(
const
std
::
string
&
name
,
double
defaultValue
);
/**
/**
* Get the name of a global parameter.
* Get the name of a global parameter.
*
*
...
@@ -204,6 +205,20 @@ public:
...
@@ -204,6 +205,20 @@ public:
* @param name the name of the parameter
* @param name the name of the parameter
*/
*/
void
setGlobalParameterName
(
int
index
,
const
std
::
string
&
name
);
void
setGlobalParameterName
(
int
index
,
const
std
::
string
&
name
);
/**
* Get the default value of a global parameter.
*
* @param index the index of the parameter for which to get the default value
* @return the parameter default value
*/
double
getGlobalParameterDefaultValue
(
int
index
)
const
;
/**
* Set the default value of a global parameter.
*
* @param index the index of the parameter for which to set the default value
* @param name the default value of the parameter
*/
void
setGlobalParameterDefaultValue
(
int
index
,
double
defaultValue
);
/**
/**
* Add the nonbonded force parameters for a particle. This should be called once for each particle
* Add the nonbonded force parameters for a particle. This should be called once for each particle
* in the System. When it is called for the i'th time, it specifies the parameters for the i'th particle.
* in the System. When it is called for the i'th time, it specifies the parameters for the i'th particle.
...
@@ -263,13 +278,14 @@ protected:
...
@@ -263,13 +278,14 @@ protected:
private:
private:
class
ParticleInfo
;
class
ParticleInfo
;
class
ParameterInfo
;
class
ParameterInfo
;
class
GlobalParameterInfo
;
class
ExceptionInfo
;
class
ExceptionInfo
;
NonbondedMethod
nonbondedMethod
;
NonbondedMethod
nonbondedMethod
;
double
cutoffDistance
;
double
cutoffDistance
;
Vec3
periodicBoxVectors
[
3
];
Vec3
periodicBoxVectors
[
3
];
std
::
string
energyExpression
;
std
::
string
energyExpression
;
std
::
vector
<
ParameterInfo
>
parameters
;
std
::
vector
<
ParameterInfo
>
parameters
;
std
::
vector
<
std
::
string
>
globalParameters
;
std
::
vector
<
GlobalParameterInfo
>
globalParameters
;
std
::
vector
<
ParticleInfo
>
particles
;
std
::
vector
<
ParticleInfo
>
particles
;
std
::
vector
<
ExceptionInfo
>
exceptions
;
std
::
vector
<
ExceptionInfo
>
exceptions
;
std
::
map
<
std
::
pair
<
int
,
int
>
,
int
>
exceptionMap
;
std
::
map
<
std
::
pair
<
int
,
int
>
,
int
>
exceptionMap
;
...
@@ -293,6 +309,16 @@ public:
...
@@ -293,6 +309,16 @@ public:
}
}
};
};
class
CustomNonbondedForce
::
GlobalParameterInfo
{
public:
std
::
string
name
;
double
defaultValue
;
GlobalParameterInfo
()
{
}
GlobalParameterInfo
(
const
std
::
string
&
name
,
double
defaultValue
)
:
name
(
name
),
defaultValue
(
defaultValue
)
{
}
};
class
CustomNonbondedForce
::
ExceptionInfo
{
class
CustomNonbondedForce
::
ExceptionInfo
{
public:
public:
int
particle1
,
particle2
;
int
particle1
,
particle2
;
...
...
openmmapi/include/openmm/Force.h
View file @
d099819a
...
@@ -55,7 +55,7 @@ class ForceImpl;
...
@@ -55,7 +55,7 @@ class ForceImpl;
class
OPENMM_EXPORT
Force
{
class
OPENMM_EXPORT
Force
{
public:
public:
Force
()
{}
Force
()
{}
virtual
~
Force
()
{
virtual
~
Force
()
{
}
}
protected:
protected:
...
@@ -68,8 +68,8 @@ protected:
...
@@ -68,8 +68,8 @@ protected:
virtual
ForceImpl
*
createImpl
()
=
0
;
virtual
ForceImpl
*
createImpl
()
=
0
;
private:
private:
Force
&
operator
=
(
const
Force
&
rhs
);
Force
&
operator
=
(
const
Force
&
rhs
);
Force
(
const
Force
&
rhs
);
Force
(
const
Force
&
rhs
);
};
};
}
// namespace OpenMM
}
// namespace OpenMM
...
...
openmmapi/src/CustomNonbondedForce.cpp
View file @
d099819a
...
@@ -115,17 +115,25 @@ void CustomNonbondedForce::setParameterCombiningRule(int index, const string& co
...
@@ -115,17 +115,25 @@ void CustomNonbondedForce::setParameterCombiningRule(int index, const string& co
parameters
[
index
].
combiningRule
=
combiningRule
;
parameters
[
index
].
combiningRule
=
combiningRule
;
}
}
int
CustomNonbondedForce
::
addGlobalParameter
(
const
string
&
name
)
{
int
CustomNonbondedForce
::
addGlobalParameter
(
const
string
&
name
,
double
defaultValue
)
{
globalParameters
.
push_back
(
name
);
globalParameters
.
push_back
(
GlobalParameterInfo
(
name
,
defaultValue
)
);
return
globalParameters
.
size
()
-
1
;
return
globalParameters
.
size
()
-
1
;
}
}
const
string
&
CustomNonbondedForce
::
getGlobalParameterName
(
int
index
)
const
{
const
string
&
CustomNonbondedForce
::
getGlobalParameterName
(
int
index
)
const
{
return
globalParameters
[
index
];
return
globalParameters
[
index
]
.
name
;
}
}
void
CustomNonbondedForce
::
setGlobalParameterName
(
int
index
,
const
string
&
name
)
{
void
CustomNonbondedForce
::
setGlobalParameterName
(
int
index
,
const
string
&
name
)
{
globalParameters
[
index
]
=
name
;
globalParameters
[
index
].
name
=
name
;
}
double
CustomNonbondedForce
::
getGlobalParameterDefaultValue
(
int
index
)
const
{
return
globalParameters
[
index
].
defaultValue
;
}
void
CustomNonbondedForce
::
setGlobalParameterDefaultValue
(
int
index
,
double
defaultValue
)
{
globalParameters
[
index
].
defaultValue
=
defaultValue
;
}
}
int
CustomNonbondedForce
::
addParticle
(
const
vector
<
double
>&
parameters
)
{
int
CustomNonbondedForce
::
addParticle
(
const
vector
<
double
>&
parameters
)
{
...
...
openmmapi/src/CustomNonbondedForceImpl.cpp
View file @
d099819a
...
@@ -121,6 +121,6 @@ vector<string> CustomNonbondedForceImpl::getKernelNames() {
...
@@ -121,6 +121,6 @@ vector<string> CustomNonbondedForceImpl::getKernelNames() {
map
<
string
,
double
>
CustomNonbondedForceImpl
::
getDefaultParameters
()
{
map
<
string
,
double
>
CustomNonbondedForceImpl
::
getDefaultParameters
()
{
map
<
string
,
double
>
parameters
;
map
<
string
,
double
>
parameters
;
for
(
int
i
=
0
;
i
<
owner
.
getNumGlobalParameters
();
i
++
)
for
(
int
i
=
0
;
i
<
owner
.
getNumGlobalParameters
();
i
++
)
parameters
[
owner
.
getGlobalParameterName
(
i
)]
=
0.0
;
parameters
[
owner
.
getGlobalParameterName
(
i
)]
=
owner
.
getGlobalParameterDefaultValue
(
i
)
;
return
parameters
;
return
parameters
;
}
}
platforms/reference/tests/TestReferenceCustomNonbondedForce.cpp
View file @
d099819a
...
@@ -80,8 +80,8 @@ void testParameters() {
...
@@ -80,8 +80,8 @@ void testParameters() {
CustomNonbondedForce
*
forceField
=
new
CustomNonbondedForce
(
"scale*a*(r*b)^3"
);
CustomNonbondedForce
*
forceField
=
new
CustomNonbondedForce
(
"scale*a*(r*b)^3"
);
forceField
->
addParameter
(
"a"
,
"a1*a2"
);
forceField
->
addParameter
(
"a"
,
"a1*a2"
);
forceField
->
addParameter
(
"b"
,
"c+b1+b2"
);
forceField
->
addParameter
(
"b"
,
"c+b1+b2"
);
forceField
->
addGlobalParameter
(
"scale"
);
forceField
->
addGlobalParameter
(
"scale"
,
3.0
);
forceField
->
addGlobalParameter
(
"c"
);
forceField
->
addGlobalParameter
(
"c"
,
-
1.0
);
vector
<
double
>
params
(
2
);
vector
<
double
>
params
(
2
);
params
[
0
]
=
1.5
;
params
[
0
]
=
1.5
;
params
[
1
]
=
2.0
;
params
[
1
]
=
2.0
;
...
...
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