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
b815ce03
"...ssh:/git@developer.sourcefind.cn:2222/tsoc/openmm.git" did not exist on "076f8d7b71e8ed6c47a67aed3aab9cdf2bd6edf0"
Commit
b815ce03
authored
Mar 12, 2020
by
peastman
Browse files
setVelocitiesToTemperature() applies offset for leapfrog integrators
parent
7398e5a3
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
65 additions
and
18 deletions
+65
-18
openmmapi/include/openmm/CompoundIntegrator.h
openmmapi/include/openmm/CompoundIntegrator.h
+7
-0
openmmapi/include/openmm/Integrator.h
openmmapi/include/openmm/Integrator.h
+8
-1
openmmapi/include/openmm/LangevinIntegrator.h
openmmapi/include/openmm/LangevinIntegrator.h
+8
-1
openmmapi/include/openmm/LangevinMiddleIntegrator.h
openmmapi/include/openmm/LangevinMiddleIntegrator.h
+7
-0
openmmapi/include/openmm/VerletIntegrator.h
openmmapi/include/openmm/VerletIntegrator.h
+8
-1
openmmapi/src/Context.cpp
openmmapi/src/Context.cpp
+13
-1
plugins/drude/platforms/common/src/CommonDrudeKernels.cpp
plugins/drude/platforms/common/src/CommonDrudeKernels.cpp
+3
-3
plugins/drude/tests/TestDrudeLangevinIntegrator.h
plugins/drude/tests/TestDrudeLangevinIntegrator.h
+1
-1
plugins/drude/tests/TestDrudeNoseHoover.h
plugins/drude/tests/TestDrudeNoseHoover.h
+1
-1
plugins/drude/tests/TestDrudeSCFIntegrator.h
plugins/drude/tests/TestDrudeSCFIntegrator.h
+1
-1
tests/TestBrownianIntegrator.h
tests/TestBrownianIntegrator.h
+1
-1
tests/TestCustomIntegrator.h
tests/TestCustomIntegrator.h
+1
-1
tests/TestLangevinIntegrator.h
tests/TestLangevinIntegrator.h
+1
-1
tests/TestLangevinMiddleIntegrator.h
tests/TestLangevinMiddleIntegrator.h
+1
-1
tests/TestNoseHooverIntegrator.h
tests/TestNoseHooverIntegrator.h
+1
-1
tests/TestVariableLangevinIntegrator.h
tests/TestVariableLangevinIntegrator.h
+1
-1
tests/TestVariableVerletIntegrator.h
tests/TestVariableVerletIntegrator.h
+1
-1
tests/TestVerletIntegrator.h
tests/TestVerletIntegrator.h
+1
-1
No files found.
openmmapi/include/openmm/CompoundIntegrator.h
View file @
b815ce03
...
@@ -187,6 +187,13 @@ protected:
...
@@ -187,6 +187,13 @@ protected:
* The implementation calls computeKineticEnergy() on whichever Integrator has been set as current.
* The implementation calls computeKineticEnergy() on whichever Integrator has been set as current.
*/
*/
double
computeKineticEnergy
();
double
computeKineticEnergy
();
/**
* Get the time interval by which velocities are offset from positions. This is used to
* adjust velocities when setVelocitiesToTemperature() is called on a Context.
*/
double
getVelocityTimeOffset
()
const
{
return
getIntegrator
(
0
).
getVelocityTimeOffset
();
}
private:
private:
int
currentIntegrator
;
int
currentIntegrator
;
std
::
vector
<
Integrator
*>
integrators
;
std
::
vector
<
Integrator
*>
integrators
;
...
...
openmmapi/include/openmm/Integrator.h
View file @
b815ce03
...
@@ -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-20
19
Stanford University and the Authors. *
* Portions copyright (c) 2008-20
20
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -144,6 +144,13 @@ protected:
...
@@ -144,6 +144,13 @@ protected:
* @param randomSeed the random number seed to use when selecting velocities
* @param randomSeed the random number seed to use when selecting velocities
*/
*/
virtual
std
::
vector
<
Vec3
>
getVelocitiesForTemperature
(
const
System
&
system
,
double
temperature
,
int
randomSeed
)
const
;
virtual
std
::
vector
<
Vec3
>
getVelocitiesForTemperature
(
const
System
&
system
,
double
temperature
,
int
randomSeed
)
const
;
/**
* Get the time interval by which velocities are offset from positions. This is used to
* adjust velocities when setVelocitiesToTemperature() is called on a Context.
*/
virtual
double
getVelocityTimeOffset
()
const
{
return
0.0
;
}
private:
private:
double
stepSize
,
constraintTol
;
double
stepSize
,
constraintTol
;
};
};
...
...
openmmapi/include/openmm/LangevinIntegrator.h
View file @
b815ce03
...
@@ -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-20
1
2 Stanford University and the Authors. *
* Portions copyright (c) 2008-202
0
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -133,6 +133,13 @@ protected:
...
@@ -133,6 +133,13 @@ protected:
* Compute the kinetic energy of the system at the current time.
* Compute the kinetic energy of the system at the current time.
*/
*/
double
computeKineticEnergy
();
double
computeKineticEnergy
();
/**
* Get the time interval by which velocities are offset from positions. This is used to
* adjust velocities when setVelocitiesToTemperature() is called on a Context.
*/
double
getVelocityTimeOffset
()
const
{
return
getStepSize
()
/
2
;
}
private:
private:
double
temperature
,
friction
;
double
temperature
,
friction
;
int
randomNumberSeed
;
int
randomNumberSeed
;
...
...
openmmapi/include/openmm/LangevinMiddleIntegrator.h
View file @
b815ce03
...
@@ -140,6 +140,13 @@ protected:
...
@@ -140,6 +140,13 @@ protected:
* Computing kinetic energy for this integrator does not require forces.
* Computing kinetic energy for this integrator does not require forces.
*/
*/
bool
kineticEnergyRequiresForce
()
const
;
bool
kineticEnergyRequiresForce
()
const
;
/**
* Get the time interval by which velocities are offset from positions. This is used to
* adjust velocities when setVelocitiesToTemperature() is called on a Context.
*/
double
getVelocityTimeOffset
()
const
{
return
getStepSize
()
/
2
;
}
private:
private:
double
temperature
,
friction
;
double
temperature
,
friction
;
int
randomNumberSeed
;
int
randomNumberSeed
;
...
...
openmmapi/include/openmm/VerletIntegrator.h
View file @
b815ce03
...
@@ -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-20
1
2 Stanford University and the Authors. *
* Portions copyright (c) 2008-202
0
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -76,6 +76,13 @@ protected:
...
@@ -76,6 +76,13 @@ protected:
* Compute the kinetic energy of the system at the current time.
* Compute the kinetic energy of the system at the current time.
*/
*/
double
computeKineticEnergy
();
double
computeKineticEnergy
();
/**
* Get the time interval by which velocities are offset from positions. This is used to
* adjust velocities when setVelocitiesToTemperature() is called on a Context.
*/
double
getVelocityTimeOffset
()
const
{
return
getStepSize
()
/
2
;
}
private:
private:
Kernel
kernel
;
Kernel
kernel
;
};
};
...
...
openmmapi/src/Context.cpp
View file @
b815ce03
...
@@ -183,7 +183,19 @@ void Context::setVelocities(const vector<Vec3>& velocities) {
...
@@ -183,7 +183,19 @@ void Context::setVelocities(const vector<Vec3>& velocities) {
void
Context
::
setVelocitiesToTemperature
(
double
temperature
,
int
randomSeed
)
{
void
Context
::
setVelocitiesToTemperature
(
double
temperature
,
int
randomSeed
)
{
const
Integrator
&
integrator
=
impl
->
getIntegrator
();
const
Integrator
&
integrator
=
impl
->
getIntegrator
();
const
System
&
system
=
impl
->
getSystem
();
const
System
&
system
=
impl
->
getSystem
();
setVelocities
(
integrator
.
getVelocitiesForTemperature
(
system
,
temperature
,
randomSeed
));
vector
<
Vec3
>
velocities
=
integrator
.
getVelocitiesForTemperature
(
system
,
temperature
,
randomSeed
);
double
offset
=
integrator
.
getVelocityTimeOffset
();
if
(
offset
!=
0.0
)
{
impl
->
calcForcesAndEnergy
(
true
,
false
,
-
1
);
vector
<
Vec3
>
forces
;
impl
->
getForces
(
forces
);
for
(
int
i
=
0
;
i
<
system
.
getNumParticles
();
i
++
)
{
double
mass
=
system
.
getParticleMass
(
i
);
if
(
mass
!=
0.0
)
velocities
[
i
]
-=
(
offset
/
mass
)
*
forces
[
i
];
}
}
setVelocities
(
velocities
);
impl
->
applyVelocityConstraints
(
1e-5
);
impl
->
applyVelocityConstraints
(
1e-5
);
}
}
...
...
plugins/drude/platforms/common/src/CommonDrudeKernels.cpp
View file @
b815ce03
...
@@ -121,12 +121,12 @@ void CommonCalcDrudeForceKernel::initialize(const System& system, const DrudeFor
...
@@ -121,12 +121,12 @@ void CommonCalcDrudeForceKernel::initialize(const System& system, const DrudeFor
double
k1
=
ONE_4PI_EPS0
*
charge
*
charge
/
(
polarizability
*
a1
)
-
k3
;
double
k1
=
ONE_4PI_EPS0
*
charge
*
charge
/
(
polarizability
*
a1
)
-
k3
;
double
k2
=
ONE_4PI_EPS0
*
charge
*
charge
/
(
polarizability
*
a2
)
-
k3
;
double
k2
=
ONE_4PI_EPS0
*
charge
*
charge
/
(
polarizability
*
a2
)
-
k3
;
if
(
atoms
[
i
][
2
]
==
-
1
)
{
if
(
atoms
[
i
][
2
]
==
-
1
)
{
atoms
[
i
][
2
]
=
0
;
atoms
[
i
][
2
]
=
atoms
[
i
][
0
]
;
k1
=
0
;
k1
=
0
;
}
}
if
(
atoms
[
i
][
3
]
==
-
1
||
atoms
[
i
][
4
]
==
-
1
)
{
if
(
atoms
[
i
][
3
]
==
-
1
||
atoms
[
i
][
4
]
==
-
1
)
{
atoms
[
i
][
3
]
=
0
;
atoms
[
i
][
3
]
=
atoms
[
i
][
0
]
;
atoms
[
i
][
4
]
=
0
;
atoms
[
i
][
4
]
=
atoms
[
i
][
0
]
;
k2
=
0
;
k2
=
0
;
}
}
paramVector
[
i
]
=
mm_float4
((
float
)
k1
,
(
float
)
k2
,
(
float
)
k3
,
0.0
f
);
paramVector
[
i
]
=
mm_float4
((
float
)
k1
,
(
float
)
k2
,
(
float
)
k3
,
0.0
f
);
...
...
plugins/drude/tests/TestDrudeLangevinIntegrator.h
View file @
b815ce03
...
@@ -231,7 +231,7 @@ void testForceEnergyConsistency() {
...
@@ -231,7 +231,7 @@ void testForceEnergyConsistency() {
void
testInitialTemperature
()
{
void
testInitialTemperature
()
{
// Check temperature initialization for a collection of randomly placed particles
// Check temperature initialization for a collection of randomly placed particles
const
int
numRealParticles
=
50000
0
;
const
int
numRealParticles
=
50000
;
const
int
numParticles
=
2
*
numRealParticles
;
const
int
numParticles
=
2
*
numRealParticles
;
const
int
nDoF
=
3
*
numRealParticles
;
const
int
nDoF
=
3
*
numRealParticles
;
const
double
targetTemperature
=
300
;
const
double
targetTemperature
=
300
;
...
...
plugins/drude/tests/TestDrudeNoseHoover.h
View file @
b815ce03
...
@@ -227,7 +227,7 @@ double testWaterBoxWithHardWallConstraint(double hardWallConstraint){
...
@@ -227,7 +227,7 @@ double testWaterBoxWithHardWallConstraint(double hardWallConstraint){
void
testInitialTemperature
()
{
void
testInitialTemperature
()
{
// Check temperature initialization for a collection of randomly placed particles
// Check temperature initialization for a collection of randomly placed particles
const
int
numRealParticles
=
50000
0
;
const
int
numRealParticles
=
50000
;
const
int
numParticles
=
2
*
numRealParticles
;
const
int
numParticles
=
2
*
numRealParticles
;
const
int
nDoF
=
3
*
numRealParticles
;
const
int
nDoF
=
3
*
numRealParticles
;
const
double
targetTemperature
=
300
;
const
double
targetTemperature
=
300
;
...
...
plugins/drude/tests/TestDrudeSCFIntegrator.h
View file @
b815ce03
...
@@ -135,7 +135,7 @@ void testWater() {
...
@@ -135,7 +135,7 @@ void testWater() {
void
testInitialTemperature
()
{
void
testInitialTemperature
()
{
// Check temperature initialization for a collection of randomly placed particles
// Check temperature initialization for a collection of randomly placed particles
const
int
numRealParticles
=
50000
0
;
const
int
numRealParticles
=
50000
;
const
int
numParticles
=
2
*
numRealParticles
;
const
int
numParticles
=
2
*
numRealParticles
;
const
int
nDoF
=
3
*
numRealParticles
;
const
int
nDoF
=
3
*
numRealParticles
;
const
double
targetTemperature
=
300
;
const
double
targetTemperature
=
300
;
...
...
tests/TestBrownianIntegrator.h
View file @
b815ce03
...
@@ -253,7 +253,7 @@ void testRandomSeed() {
...
@@ -253,7 +253,7 @@ void testRandomSeed() {
void
testInitialTemperature
()
{
void
testInitialTemperature
()
{
// Check temperature initialization for a collection of randomly placed particles
// Check temperature initialization for a collection of randomly placed particles
const
int
numParticles
=
50000
0
;
const
int
numParticles
=
50000
;
const
int
nDoF
=
3
*
numParticles
;
const
int
nDoF
=
3
*
numParticles
;
const
double
targetTemperature
=
300
;
const
double
targetTemperature
=
300
;
System
system
;
System
system
;
...
...
tests/TestCustomIntegrator.h
View file @
b815ce03
...
@@ -1130,7 +1130,7 @@ void testRecordEnergy() {
...
@@ -1130,7 +1130,7 @@ void testRecordEnergy() {
void
testInitialTemperature
()
{
void
testInitialTemperature
()
{
// Check temperature initialization for a collection of randomly placed particles
// Check temperature initialization for a collection of randomly placed particles
const
int
numParticles
=
50000
0
;
const
int
numParticles
=
50000
;
const
int
nDoF
=
3
*
numParticles
;
const
int
nDoF
=
3
*
numParticles
;
const
double
targetTemperature
=
300
;
const
double
targetTemperature
=
300
;
System
system
;
System
system
;
...
...
tests/TestLangevinIntegrator.h
View file @
b815ce03
...
@@ -260,7 +260,7 @@ void testRandomSeed() {
...
@@ -260,7 +260,7 @@ void testRandomSeed() {
void
testInitialTemperature
()
{
void
testInitialTemperature
()
{
// Check temperature initialization for a collection of randomly placed particles
// Check temperature initialization for a collection of randomly placed particles
const
int
numParticles
=
50000
0
;
const
int
numParticles
=
50000
;
const
int
nDoF
=
3
*
numParticles
;
const
int
nDoF
=
3
*
numParticles
;
const
double
targetTemperature
=
300
;
const
double
targetTemperature
=
300
;
System
system
;
System
system
;
...
...
tests/TestLangevinMiddleIntegrator.h
View file @
b815ce03
...
@@ -263,7 +263,7 @@ void testRandomSeed() {
...
@@ -263,7 +263,7 @@ void testRandomSeed() {
void
testInitialTemperature
()
{
void
testInitialTemperature
()
{
// Check temperature initialization for a collection of randomly placed particles
// Check temperature initialization for a collection of randomly placed particles
const
int
numParticles
=
50000
0
;
const
int
numParticles
=
50000
;
const
int
nDoF
=
3
*
numParticles
;
const
int
nDoF
=
3
*
numParticles
;
const
double
targetTemperature
=
300
;
const
double
targetTemperature
=
300
;
System
system
;
System
system
;
...
...
tests/TestNoseHooverIntegrator.h
View file @
b815ce03
...
@@ -271,7 +271,7 @@ void testThreeParticleVirtualSite() {
...
@@ -271,7 +271,7 @@ void testThreeParticleVirtualSite() {
void
testInitialTemperature
()
{
void
testInitialTemperature
()
{
// Check temperature initialization for a collection of randomly placed particles
// Check temperature initialization for a collection of randomly placed particles
const
int
numParticles
=
50000
0
;
const
int
numParticles
=
50000
;
const
int
nDoF
=
3
*
numParticles
;
const
int
nDoF
=
3
*
numParticles
;
const
double
targetTemperature
=
300
;
const
double
targetTemperature
=
300
;
System
system
;
System
system
;
...
...
tests/TestVariableLangevinIntegrator.h
View file @
b815ce03
...
@@ -332,7 +332,7 @@ void testArgonBox() {
...
@@ -332,7 +332,7 @@ void testArgonBox() {
void
testInitialTemperature
()
{
void
testInitialTemperature
()
{
// Check temperature initialization for a collection of randomly placed particles
// Check temperature initialization for a collection of randomly placed particles
const
int
numParticles
=
50000
0
;
const
int
numParticles
=
50000
;
const
int
nDoF
=
3
*
numParticles
;
const
int
nDoF
=
3
*
numParticles
;
const
double
targetTemperature
=
300
;
const
double
targetTemperature
=
300
;
System
system
;
System
system
;
...
...
tests/TestVariableVerletIntegrator.h
View file @
b815ce03
...
@@ -311,7 +311,7 @@ void testArgonBox() {
...
@@ -311,7 +311,7 @@ void testArgonBox() {
void
testInitialTemperature
()
{
void
testInitialTemperature
()
{
// Check temperature initialization for a collection of randomly placed particles
// Check temperature initialization for a collection of randomly placed particles
const
int
numParticles
=
50000
0
;
const
int
numParticles
=
50000
;
const
int
nDoF
=
3
*
numParticles
;
const
int
nDoF
=
3
*
numParticles
;
const
double
targetTemperature
=
300
;
const
double
targetTemperature
=
300
;
System
system
;
System
system
;
...
...
tests/TestVerletIntegrator.h
View file @
b815ce03
...
@@ -228,7 +228,7 @@ void testConstrainedMasslessParticles() {
...
@@ -228,7 +228,7 @@ void testConstrainedMasslessParticles() {
void
testInitialTemperature
()
{
void
testInitialTemperature
()
{
// Check temperature initialization for a collection of randomly placed particles
// Check temperature initialization for a collection of randomly placed particles
const
int
numParticles
=
50000
0
;
const
int
numParticles
=
50000
;
const
int
nDoF
=
3
*
numParticles
;
const
int
nDoF
=
3
*
numParticles
;
const
double
targetTemperature
=
300
;
const
double
targetTemperature
=
300
;
System
system
;
System
system
;
...
...
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