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
d547601c
Commit
d547601c
authored
Mar 17, 2014
by
peastman
Browse files
Merge pull request #369 from peastman/rpmd
Created RPMDIntegrator::getTotalEnergy()
parents
e94afeaf
efbcb899
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
71 deletions
+39
-71
plugins/rpmd/openmmapi/include/openmm/RPMDIntegrator.h
plugins/rpmd/openmmapi/include/openmm/RPMDIntegrator.h
+6
-1
plugins/rpmd/openmmapi/src/RPMDIntegrator.cpp
plugins/rpmd/openmmapi/src/RPMDIntegrator.cpp
+26
-1
plugins/rpmd/platforms/cuda/tests/TestCudaRpmd.cpp
plugins/rpmd/platforms/cuda/tests/TestCudaRpmd.cpp
+2
-23
plugins/rpmd/platforms/opencl/tests/TestOpenCLRpmd.cpp
plugins/rpmd/platforms/opencl/tests/TestOpenCLRpmd.cpp
+2
-23
plugins/rpmd/platforms/reference/tests/TestReferenceRpmd.cpp
plugins/rpmd/platforms/reference/tests/TestReferenceRpmd.cpp
+2
-23
wrappers/python/src/swig_doxygen/swigInputConfig.py
wrappers/python/src/swig_doxygen/swigInputConfig.py
+1
-0
No files found.
plugins/rpmd/openmmapi/include/openmm/RPMDIntegrator.h
View file @
d547601c
...
@@ -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) 2008-201
3
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
4
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -195,6 +195,11 @@ public:
...
@@ -195,6 +195,11 @@ public:
* and energies. Group i will be included if (groups&(1<<i)) != 0. The default value includes all groups.
* and energies. Group i will be included if (groups&(1<<i)) != 0. The default value includes all groups.
*/
*/
State
getState
(
int
copy
,
int
types
,
bool
enforcePeriodicBox
=
false
,
int
groups
=
0xFFFFFFFF
);
State
getState
(
int
copy
,
int
types
,
bool
enforcePeriodicBox
=
false
,
int
groups
=
0xFFFFFFFF
);
/**
* Get the total energy of the ring polymer. This includes the potential and kinetic energies of all copies,
* plus the potential energy of the harmonic springs that link copies together.
*/
double
getTotalEnergy
();
/**
/**
* Advance a simulation through time by taking a series of time steps.
* Advance a simulation through time by taking a series of time steps.
*
*
...
...
plugins/rpmd/openmmapi/src/RPMDIntegrator.cpp
View file @
d547601c
...
@@ -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-201
3
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
4
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "openmm/OpenMMException.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/RpmdKernels.h"
#include "openmm/RpmdKernels.h"
#include "SimTKOpenMMRealType.h"
#include <cmath>
#include <cmath>
#include <ctime>
#include <ctime>
#include <string>
#include <string>
...
@@ -195,3 +196,27 @@ void RPMDIntegrator::step(int steps) {
...
@@ -195,3 +196,27 @@ void RPMDIntegrator::step(int steps) {
forcesAreValid
=
true
;
forcesAreValid
=
true
;
}
}
}
}
double
RPMDIntegrator
::
getTotalEnergy
()
{
const
System
&
system
=
owner
->
getSystem
();
int
numParticles
=
system
.
getNumParticles
();
double
energy
=
0.0
;
const
double
hbar
=
1.054571628e-34
*
AVOGADRO
/
(
1000
*
1e-12
);
const
double
wn
=
numCopies
*
BOLTZ
*
temperature
/
hbar
;
State
prevState
=
getState
(
numCopies
-
1
,
State
::
Positions
);
for
(
int
i
=
0
;
i
<
numCopies
;
i
++
)
{
// Add the energy of this copy.
State
state
=
getState
(
i
,
State
::
Positions
|
State
::
Energy
);
energy
+=
state
.
getKineticEnergy
()
+
state
.
getPotentialEnergy
();
// Add the energy from the springs connecting it to the previous copy.
for
(
int
j
=
0
;
j
<
numParticles
;
j
++
)
{
Vec3
delta
=
state
.
getPositions
()[
j
]
-
prevState
.
getPositions
()[
j
];
energy
+=
0.5
*
wn
*
wn
*
system
.
getParticleMass
(
j
)
*
delta
.
dot
(
delta
);
}
prevState
=
state
;
}
return
energy
;
}
plugins/rpmd/platforms/cuda/tests/TestCudaRpmd.cpp
View file @
d547601c
...
@@ -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) 2011-201
3
Stanford University and the Authors. *
* Portions copyright (c) 2011-201
4
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -466,30 +466,9 @@ void testWithoutThermostat() {
...
@@ -466,30 +466,9 @@ void testWithoutThermostat() {
double
initialEnergy
;
double
initialEnergy
;
int
numSteps
=
100
;
int
numSteps
=
100
;
const
double
hbar
=
1.054571628e-34
*
AVOGADRO
/
(
1000
*
1e-12
);
const
double
wn
=
numCopies
*
BOLTZ
*
temperature
/
hbar
;
const
double
springConstant
=
mass
*
wn
*
wn
;
for
(
int
i
=
0
;
i
<
numSteps
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numSteps
;
i
++
)
{
integ
.
step
(
1
);
integ
.
step
(
1
);
double
energy
=
integ
.
getTotalEnergy
();
// Sum the energies of all the copies.
double
energy
=
0.0
;
for
(
int
j
=
0
;
j
<
numCopies
;
j
++
)
{
State
state
=
integ
.
getState
(
j
,
State
::
Positions
|
State
::
Energy
);
positions
[
j
]
=
state
.
getPositions
();
energy
+=
state
.
getPotentialEnergy
()
+
state
.
getKineticEnergy
();
}
// Add the energy from the springs connecting copies.
for
(
int
j
=
0
;
j
<
numCopies
;
j
++
)
{
int
previous
=
(
j
==
0
?
numCopies
-
1
:
j
-
1
);
for
(
int
k
=
0
;
k
<
numParticles
;
k
++
)
{
Vec3
delta
=
positions
[
j
][
k
]
-
positions
[
previous
][
k
];
energy
+=
0.5
*
springConstant
*
delta
.
dot
(
delta
);
}
}
if
(
i
==
0
)
if
(
i
==
0
)
initialEnergy
=
energy
;
initialEnergy
=
energy
;
else
else
...
...
plugins/rpmd/platforms/opencl/tests/TestOpenCLRpmd.cpp
View file @
d547601c
...
@@ -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) 2011-201
3
Stanford University and the Authors. *
* Portions copyright (c) 2011-201
4
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -467,30 +467,9 @@ void testWithoutThermostat() {
...
@@ -467,30 +467,9 @@ void testWithoutThermostat() {
double
initialEnergy
;
double
initialEnergy
;
int
numSteps
=
100
;
int
numSteps
=
100
;
const
double
hbar
=
1.054571628e-34
*
AVOGADRO
/
(
1000
*
1e-12
);
const
double
wn
=
numCopies
*
BOLTZ
*
temperature
/
hbar
;
const
double
springConstant
=
mass
*
wn
*
wn
;
for
(
int
i
=
0
;
i
<
numSteps
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numSteps
;
i
++
)
{
integ
.
step
(
1
);
integ
.
step
(
1
);
double
energy
=
integ
.
getTotalEnergy
();
// Sum the energies of all the copies.
double
energy
=
0.0
;
for
(
int
j
=
0
;
j
<
numCopies
;
j
++
)
{
State
state
=
integ
.
getState
(
j
,
State
::
Positions
|
State
::
Energy
);
positions
[
j
]
=
state
.
getPositions
();
energy
+=
state
.
getPotentialEnergy
()
+
state
.
getKineticEnergy
();
}
// Add the energy from the springs connecting copies.
for
(
int
j
=
0
;
j
<
numCopies
;
j
++
)
{
int
previous
=
(
j
==
0
?
numCopies
-
1
:
j
-
1
);
for
(
int
k
=
0
;
k
<
numParticles
;
k
++
)
{
Vec3
delta
=
positions
[
j
][
k
]
-
positions
[
previous
][
k
];
energy
+=
0.5
*
springConstant
*
delta
.
dot
(
delta
);
}
}
if
(
i
==
0
)
if
(
i
==
0
)
initialEnergy
=
energy
;
initialEnergy
=
energy
;
else
else
...
...
plugins/rpmd/platforms/reference/tests/TestReferenceRpmd.cpp
View file @
d547601c
...
@@ -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) 2011-201
3
Stanford University and the Authors. *
* Portions copyright (c) 2011-201
4
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -350,30 +350,9 @@ void testWithoutThermostat() {
...
@@ -350,30 +350,9 @@ void testWithoutThermostat() {
double
initialEnergy
;
double
initialEnergy
;
int
numSteps
=
100
;
int
numSteps
=
100
;
const
double
hbar
=
1.054571628e-34
*
AVOGADRO
/
(
1000
*
1e-12
);
const
double
wn
=
numCopies
*
BOLTZ
*
temperature
/
hbar
;
const
double
springConstant
=
mass
*
wn
*
wn
;
for
(
int
i
=
0
;
i
<
numSteps
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numSteps
;
i
++
)
{
integ
.
step
(
1
);
integ
.
step
(
1
);
double
energy
=
integ
.
getTotalEnergy
();
// Sum the energies of all the copies.
double
energy
=
0.0
;
for
(
int
j
=
0
;
j
<
numCopies
;
j
++
)
{
State
state
=
integ
.
getState
(
j
,
State
::
Positions
|
State
::
Energy
);
positions
[
j
]
=
state
.
getPositions
();
energy
+=
state
.
getPotentialEnergy
()
+
state
.
getKineticEnergy
();
}
// Add the energy from the springs connecting copies.
for
(
int
j
=
0
;
j
<
numCopies
;
j
++
)
{
int
previous
=
(
j
==
0
?
numCopies
-
1
:
j
-
1
);
for
(
int
k
=
0
;
k
<
numParticles
;
k
++
)
{
Vec3
delta
=
positions
[
j
][
k
]
-
positions
[
previous
][
k
];
energy
+=
0.5
*
springConstant
*
delta
.
dot
(
delta
);
}
}
if
(
i
==
0
)
if
(
i
==
0
)
initialEnergy
=
energy
;
initialEnergy
=
energy
;
else
else
...
...
wrappers/python/src/swig_doxygen/swigInputConfig.py
View file @
d547601c
...
@@ -424,5 +424,6 @@ UNITS = {
...
@@ -424,5 +424,6 @@ UNITS = {
(
"DrudeLangevinIntegrator"
,
"getDrudeFriction"
)
:
(
"1/unit.picosecond"
,
()),
(
"DrudeLangevinIntegrator"
,
"getDrudeFriction"
)
:
(
"1/unit.picosecond"
,
()),
(
"DrudeSCFIntegrator"
,
"getMinimizationErrorTolerance"
)
:
(
"unit.kilojoules_per_mole/unit.nanometer"
,
()),
(
"DrudeSCFIntegrator"
,
"getMinimizationErrorTolerance"
)
:
(
"unit.kilojoules_per_mole/unit.nanometer"
,
()),
(
"RPMDIntegrator"
,
"getContractions"
)
:
(
None
,
()),
(
"RPMDIntegrator"
,
"getContractions"
)
:
(
None
,
()),
(
"RPMDIntegrator"
,
"getTotalEnergy"
)
:
(
"unit.kilojoules_per_mole"
,
()),
}
}
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