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
6776f49e
Commit
6776f49e
authored
May 27, 2020
by
peastman
Browse files
A few more changes related to setIntegrationForceGroups()
parent
4a30156a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
1 deletion
+59
-1
openmmapi/include/openmm/LocalEnergyMinimizer.h
openmmapi/include/openmm/LocalEnergyMinimizer.h
+4
-0
tests/TestBrownianIntegrator.h
tests/TestBrownianIntegrator.h
+28
-1
wrappers/python/src/swig_doxygen/swig_lib/python/extend.i
wrappers/python/src/swig_doxygen/swig_lib/python/extend.i
+27
-0
No files found.
openmmapi/include/openmm/LocalEnergyMinimizer.h
View file @
6776f49e
...
@@ -43,6 +43,10 @@ namespace OpenMM {
...
@@ -43,6 +43,10 @@ namespace OpenMM {
* force to the potential function. The strength of the restraining force is steadily increased
* force to the potential function. The strength of the restraining force is steadily increased
* until the minimum energy configuration satisfies all constraints to within the tolerance
* until the minimum energy configuration satisfies all constraints to within the tolerance
* specified by the Context's Integrator.
* specified by the Context's Integrator.
*
* Energy minimization is done using the force groups defined by the Integrator.
* If you have called setIntegrationForceGroups() on it to restrict the set of forces
* used for integration, only the energy of the included forces will be minimized.
*/
*/
class
OPENMM_EXPORT
LocalEnergyMinimizer
{
class
OPENMM_EXPORT
LocalEnergyMinimizer
{
...
...
tests/TestBrownianIntegrator.h
View file @
6776f49e
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2008-20
15
Stanford University and the Authors. *
* Portions copyright (c) 2008-20
20
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/Context.h"
#include "openmm/Context.h"
#include "openmm/CustomExternalForce.h"
#include "openmm/HarmonicBondForce.h"
#include "openmm/HarmonicBondForce.h"
#include "openmm/NonbondedForce.h"
#include "openmm/NonbondedForce.h"
#include "openmm/System.h"
#include "openmm/System.h"
...
@@ -279,6 +280,31 @@ void testInitialTemperature() {
...
@@ -279,6 +280,31 @@ void testInitialTemperature() {
ASSERT_USUALLY_EQUAL_TOL
(
targetTemperature
,
temperature
,
0.01
);
ASSERT_USUALLY_EQUAL_TOL
(
targetTemperature
,
temperature
,
0.01
);
}
}
void
testForceGroups
()
{
System
system
;
system
.
addParticle
(
1.0
);
BrownianIntegrator
integrator
(
0
,
1.0
,
0.001
);
integrator
.
setIntegrationForceGroups
(
1
<<
1
);
CustomExternalForce
*
f1
=
new
CustomExternalForce
(
"x"
);
f1
->
addParticle
(
0
);
f1
->
setForceGroup
(
1
);
CustomExternalForce
*
f2
=
new
CustomExternalForce
(
"y"
);
f2
->
addParticle
(
0
);
f2
->
setForceGroup
(
2
);
system
.
addForce
(
f1
);
system
.
addForce
(
f2
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
vector
<
Vec3
>
(
1
));
// Take one step and verify that the position was updated based only on f1.
integrator
.
step
(
1
);
Vec3
pos
=
context
.
getState
(
State
::
Positions
).
getPositions
()[
0
];
ASSERT
(
pos
[
0
]
<
0
);
ASSERT
(
pos
[
1
]
==
0
);
ASSERT
(
pos
[
2
]
==
0
);
}
void
runPlatformTests
();
void
runPlatformTests
();
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
...
@@ -290,6 +316,7 @@ int main(int argc, char* argv[]) {
...
@@ -290,6 +316,7 @@ int main(int argc, char* argv[]) {
testConstrainedMasslessParticles
();
testConstrainedMasslessParticles
();
testRandomSeed
();
testRandomSeed
();
testInitialTemperature
();
testInitialTemperature
();
testForceGroups
();
runPlatformTests
();
runPlatformTests
();
}
}
catch
(
const
exception
&
e
)
{
catch
(
const
exception
&
e
)
{
...
...
wrappers/python/src/swig_doxygen/swig_lib/python/extend.i
View file @
6776f49e
...
@@ -106,6 +106,33 @@ Parameters:
...
@@ -106,6 +106,33 @@ Parameters:
}
}
}
}
%
extend
OpenMM
::
Integrator
{
%
pythoncode
%
{
def
setIntegrationForceGroups
(
self
,
groups
)
:
"""Set which force groups to use for integration. By default, all force groups are included.
Parameters
----------
groups : set or int
a set of indices for which force groups to include when integrating the equations of motion.
Alternatively, the groups can be passed as a single unsigned integer interpreted as a bitmask,
in which case group i will be included if (groups&(1<<i)) != 0.
"""
try
:
#
is
the
input
integer-like
?
groups_mask
=
int
(
groups
)
except
TypeError
:
if
isinstance
(
groups
,
set
)
:
groups_mask
=
functools
.
reduce
(
operator
.
or_
,
((
1
<<
x
)
&
0xffffffff
for
x
in
groups
))
else
:
raise
TypeError
(
'
%
s
is
neither
an
int
nor
set
'
%
groups
)
if
groups_mask
>=
0x80000000
:
groups_mask
-=
0x100000000
_openmm
.
Integrator_setIntegrationForceGroups
(
self
,
groups_mask
)
%
}
}
%
extend
OpenMM
::
RPMDIntegrator
{
%
extend
OpenMM
::
RPMDIntegrator
{
%
pythoncode
%
{
%
pythoncode
%
{
def
getState
(
self
,
def
getState
(
self
,
...
...
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