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
b3be7aec
Unverified
Commit
b3be7aec
authored
Nov 01, 2019
by
Andy Simmonett
Browse files
Clean up NHC interface and fix bug in swig generator
parent
75104c41
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
104 additions
and
78 deletions
+104
-78
openmmapi/include/openmm/NoseHooverIntegrator.h
openmmapi/include/openmm/NoseHooverIntegrator.h
+7
-25
openmmapi/src/NoseHooverIntegrator.cpp
openmmapi/src/NoseHooverIntegrator.cpp
+36
-36
plugins/drude/openmmapi/include/OpenMMDrude.h
plugins/drude/openmmapi/include/OpenMMDrude.h
+1
-1
plugins/drude/openmmapi/include/openmm/DrudeNoseHooverIntegrator.h
...rude/openmmapi/include/openmm/DrudeNoseHooverIntegrator.h
+4
-4
plugins/drude/openmmapi/src/DrudeNoseHooverIntegrator.cpp
plugins/drude/openmmapi/src/DrudeNoseHooverIntegrator.cpp
+6
-5
wrappers/python/src/swig_doxygen/swigInputBuilder.py
wrappers/python/src/swig_doxygen/swigInputBuilder.py
+16
-4
wrappers/python/src/swig_doxygen/swigInputConfig.py
wrappers/python/src/swig_doxygen/swigInputConfig.py
+19
-3
wrappers/python/tests/TestAPIUnits.py
wrappers/python/tests/TestAPIUnits.py
+15
-0
No files found.
openmmapi/include/openmm/NoseHooverIntegrator.h
View file @
b3be7aec
...
@@ -58,15 +58,15 @@ public:
...
@@ -58,15 +58,15 @@ public:
/**
/**
* Create a NoseHooverIntegrator.
* Create a NoseHooverIntegrator.
*
*
* @param temperature the target temperature for the system.
* @param temperature the target temperature for the system
(in Kelvin)
.
* @param collisionFrequency the frequency of the interaction with the heat bath (in
1/p
s).
* @param collisionFrequency the frequency of the interaction with the heat bath (in
inverse picosecond
s).
* @param stepSize the step size with which to integrate the system (in picoseconds)
* @param stepSize the step size with which to integrate the system (in picoseconds)
* @param chainLength the number of beads in the Nose-Hoover chain.
* @param chainLength the number of beads in the Nose-Hoover chain.
* @param numMTS the number of step in the multiple time step chain propagation algorithm.
* @param numMTS the number of step in the multiple time step chain propagation algorithm.
* @param numYoshidaSuzuki the number of terms in the Yoshida-Suzuki multi time step decomposition
* @param numYoshidaSuzuki the number of terms in the Yoshida-Suzuki multi time step decomposition
* used in the chain propagation algorithm (must be 1, 3, or 5).
* used in the chain propagation algorithm (must be 1, 3, or 5).
*/
*/
explicit
NoseHooverIntegrator
(
double
temperature
,
int
collisionFrequ
n
ency
,
double
stepSize
,
explicit
NoseHooverIntegrator
(
double
temperature
,
double
collisionFrequency
,
double
stepSize
,
int
chainLength
=
3
,
int
numMTS
=
3
,
int
numYoshidaSuzuki
=
3
);
int
chainLength
=
3
,
int
numMTS
=
3
,
int
numYoshidaSuzuki
=
3
);
virtual
~
NoseHooverIntegrator
();
virtual
~
NoseHooverIntegrator
();
...
@@ -81,7 +81,7 @@ public:
...
@@ -81,7 +81,7 @@ public:
*
*
* @param temperature the target temperature for the system.
* @param temperature the target temperature for the system.
* @param collisionFrequency the frequency of the interaction with the heat bath (in 1/ps).
* @param collisionFrequency the frequency of the interaction with the heat bath (in 1/ps).
* @param chainLength the number of beads in the Nose-Hoover chain
.
* @param chainLength the number of beads in the Nose-Hoover chain
* @param numMTS the number of step in the multiple time step chain propagation algorithm.
* @param numMTS the number of step in the multiple time step chain propagation algorithm.
* @param numYoshidaSuzuki the number of terms in the Yoshida-Suzuki multi time step decomposition
* @param numYoshidaSuzuki the number of terms in the Yoshida-Suzuki multi time step decomposition
* used in the chain propagation algorithm (must be 1, 3, or 5).
* used in the chain propagation algorithm (must be 1, 3, or 5).
...
@@ -94,6 +94,7 @@ public:
...
@@ -94,6 +94,7 @@ public:
* provided and the thermostat will only control members of that list. Additionally a list of pairs of
* provided and the thermostat will only control members of that list. Additionally a list of pairs of
* connected atoms may be provided; in this case both the center of mass absolute motion of each pair is
* connected atoms may be provided; in this case both the center of mass absolute motion of each pair is
* controlled as well as their motion relative to each other, which is independently thermostated.
* controlled as well as their motion relative to each other, which is independently thermostated.
* If both the list of thermostated particles and thermostated pairs are empty all particles will be thermostated.
*
*
* @param thermostatedParticles list of particle ids to be thermostated.
* @param thermostatedParticles list of particle ids to be thermostated.
* @param thermostatedPairs a list of pairs of connected atoms whose absolute center of mass motion
* @param thermostatedPairs a list of pairs of connected atoms whose absolute center of mass motion
...
@@ -215,9 +216,9 @@ protected:
...
@@ -215,9 +216,9 @@ protected:
*/
*/
void
initialize
(
ContextImpl
&
context
);
void
initialize
(
ContextImpl
&
context
);
/**
/**
* Goes through the list of
requested thermostat data and creates
the thermostat
chain
s.
* Goes through the list of
thermostats, sets the number of DOFs, and checks for errors in
the thermostats.
*/
*/
void
creat
eThermostats
(
const
System
&
system
);
void
initializ
eThermostats
(
const
System
&
system
);
/**
/**
* This will be called by the Context when it is destroyed to let the Integrator do any necessary
* This will be called by the Context when it is destroyed to let the Integrator do any necessary
* cleanup. It will also get called again if the application calls reinitialize() on the Context.
* cleanup. It will also get called again if the application calls reinitialize() on the Context.
...
@@ -232,25 +233,6 @@ protected:
...
@@ -232,25 +233,6 @@ protected:
*/
*/
virtual
double
computeKineticEnergy
();
virtual
double
computeKineticEnergy
();
struct
ThermostatData
{
std
::
vector
<
int
>
thermostatedParticles
;
std
::
vector
<
std
::
pair
<
int
,
int
>
>
thermostatedPairs
;
double
temperature
;
double
relativeTemperature
;
double
collisionFrequency
;
double
relativeCollisionFrequency
;
int
chainLength
;
int
numMTS
;
int
numYoshidaSuzuki
;
ThermostatData
(
const
std
::
vector
<
int
>&
particles
,
const
std
::
vector
<
std
::
pair
<
int
,
int
>>
&
pairs
,
double
temp
,
double
relTemp
,
double
freq
,
double
relFreq
,
int
length
,
int
MTS
,
int
YS
)
:
thermostatedParticles
(
particles
),
thermostatedPairs
(
pairs
),
temperature
(
temp
),
relativeTemperature
(
relTemp
),
collisionFrequency
(
freq
),
relativeCollisionFrequency
(
relFreq
),
chainLength
(
length
),
numMTS
(
MTS
),
numYoshidaSuzuki
(
YS
)
{}
};
std
::
vector
<
ThermostatData
>
thermostatData
;
std
::
vector
<
NoseHooverChain
>
noseHooverChains
;
std
::
vector
<
NoseHooverChain
>
noseHooverChains
;
bool
forcesAreValid
;
bool
forcesAreValid
;
Kernel
vvKernel
,
nhcKernel
;
Kernel
vvKernel
,
nhcKernel
;
...
...
openmmapi/src/NoseHooverIntegrator.cpp
View file @
b3be7aec
...
@@ -53,11 +53,11 @@ NoseHooverIntegrator::NoseHooverIntegrator(double stepSize):
...
@@ -53,11 +53,11 @@ NoseHooverIntegrator::NoseHooverIntegrator(double stepSize):
setStepSize
(
stepSize
);
setStepSize
(
stepSize
);
setConstraintTolerance
(
1e-5
);
setConstraintTolerance
(
1e-5
);
}
}
NoseHooverIntegrator
::
NoseHooverIntegrator
(
double
temperature
,
int
collisionFrequ
n
ency
,
double
stepSize
,
NoseHooverIntegrator
::
NoseHooverIntegrator
(
double
temperature
,
double
collisionFrequency
,
double
stepSize
,
int
chainLength
,
int
numMTS
,
int
numYoshidaSuzuki
)
:
forcesAreValid
(
false
)
{
int
chainLength
,
int
numMTS
,
int
numYoshidaSuzuki
)
:
forcesAreValid
(
false
)
{
setStepSize
(
stepSize
);
setStepSize
(
stepSize
);
setConstraintTolerance
(
1e-5
);
setConstraintTolerance
(
1e-5
);
addThermostat
(
temperature
,
collisionFrequ
n
ency
,
chainLength
,
numMTS
,
numYoshidaSuzuki
);
addThermostat
(
temperature
,
collisionFrequency
,
chainLength
,
numMTS
,
numYoshidaSuzuki
);
}
}
NoseHooverIntegrator
::~
NoseHooverIntegrator
()
{}
NoseHooverIntegrator
::~
NoseHooverIntegrator
()
{}
...
@@ -79,40 +79,45 @@ int NoseHooverIntegrator::addSubsystemThermostat(const std::vector<int>& thermos
...
@@ -79,40 +79,45 @@ int NoseHooverIntegrator::addSubsystemThermostat(const std::vector<int>& thermos
double
temperature
,
double
collisionFrequency
,
double
temperature
,
double
collisionFrequency
,
double
relativeTemperature
,
double
relativeCollisionFrequency
,
double
relativeTemperature
,
double
relativeCollisionFrequency
,
int
chainLength
,
int
numMTS
,
int
numYoshidaSuzuki
)
{
int
chainLength
,
int
numMTS
,
int
numYoshidaSuzuki
)
{
auto
data
=
ThermostatData
(
thermostatedParticles
,
thermostatedPairs
,
temperature
,
int
chainID
=
noseHooverChains
.
size
();
relativeTemperature
,
collisionFrequency
,
int
nDOF
=
0
;
// is set in initializeThermostats()
relativeCollisionFrequency
,
chainLength
,
numMTS
,
numYoshidaSuzuki
);
noseHooverChains
.
emplace_back
(
temperature
,
relativeTemperature
,
thermostatData
.
push_back
(
data
);
collisionFrequency
,
relativeCollisionFrequency
,
return
thermostatData
.
size
()
-
1
;
nDOF
,
chainLength
,
numMTS
,
numYoshidaSuzuki
,
chainID
,
thermostatedParticles
,
thermostatedPairs
);
return
chainID
;
}
}
void
NoseHooverIntegrator
::
creat
eThermostats
(
const
System
&
system
)
{
void
NoseHooverIntegrator
::
initializ
eThermostats
(
const
System
&
system
)
{
for
(
const
auto
&
thermostat
:
thermostatData
)
{
for
(
auto
&
thermostat
:
noseHooverChains
)
{
const
auto
&
thermostatedParticles
=
thermostat
.
getThermostatedAtoms
();
const
auto
&
thermostatedPairs
=
thermostat
.
getThermostatedPairs
();
// figure out the number of DOFs
// figure out the number of DOFs
int
nDOF
=
3
*
(
thermostat
.
thermostatedParticles
.
size
()
+
thermostat
.
thermostatedPairs
.
size
());
int
nDOF
=
3
*
(
thermostatedParticles
.
size
()
+
thermostatedPairs
.
size
());
for
(
int
constraintNum
=
0
;
constraintNum
<
system
.
getNumConstraints
();
constraintNum
++
)
{
for
(
int
constraintNum
=
0
;
constraintNum
<
system
.
getNumConstraints
();
constraintNum
++
)
{
int
particle1
,
particle2
;
int
particle1
,
particle2
;
double
distance
;
double
distance
;
system
.
getConstraintParameters
(
constraintNum
,
particle1
,
particle2
,
distance
);
system
.
getConstraintParameters
(
constraintNum
,
particle1
,
particle2
,
distance
);
bool
particle1_in_thermostatedParticles
=
((
std
::
find
(
thermostat
.
thermostatedParticles
.
begin
(),
bool
particle1_in_thermostatedParticles
=
((
std
::
find
(
thermostatedParticles
.
begin
(),
thermostat
.
thermostatedParticles
.
end
(),
particle1
)
thermostatedParticles
.
end
(),
particle1
)
!=
thermostat
.
thermostatedParticles
.
end
()))
||
!=
thermostatedParticles
.
end
()))
||
(
std
::
find_if
(
thermostat
.
thermostatedPairs
.
begin
(),
(
std
::
find_if
(
thermostatedPairs
.
begin
(),
thermostat
.
thermostatedPairs
.
end
(),
thermostatedPairs
.
end
(),
[
&
particle1
](
const
std
::
pair
<
int
,
int
>&
pair
){
[
&
particle1
](
const
std
::
pair
<
int
,
int
>&
pair
){
return
pair
.
first
==
particle1
||
pair
.
second
==
particle1
;})
return
pair
.
first
==
particle1
||
pair
.
second
==
particle1
;})
!=
thermostat
.
thermostatedPairs
.
end
());
!=
thermostatedPairs
.
end
());
bool
particle2_in_thermostatedParticles
=
((
std
::
find
(
thermostat
.
thermostatedParticles
.
begin
(),
bool
particle2_in_thermostatedParticles
=
((
std
::
find
(
thermostatedParticles
.
begin
(),
thermostat
.
thermostatedParticles
.
end
(),
particle2
)
thermostatedParticles
.
end
(),
particle2
)
!=
thermostat
.
thermostatedParticles
.
end
()))
||
!=
thermostatedParticles
.
end
()))
||
(
std
::
find_if
(
thermostat
.
thermostatedPairs
.
begin
(),
(
std
::
find_if
(
thermostatedPairs
.
begin
(),
thermostat
.
thermostatedPairs
.
end
(),
thermostatedPairs
.
end
(),
[
&
particle2
](
const
std
::
pair
<
int
,
int
>&
pair
){
[
&
particle2
](
const
std
::
pair
<
int
,
int
>&
pair
){
return
pair
.
first
==
particle2
||
pair
.
second
==
particle2
;})
return
pair
.
first
==
particle2
||
pair
.
second
==
particle2
;})
!=
thermostat
.
thermostatedPairs
.
end
());
!=
thermostatedPairs
.
end
());
if
((
system
.
getParticleMass
(
particle1
)
>
0
)
&&
(
system
.
getParticleMass
(
particle2
)
>
0
)){
if
((
system
.
getParticleMass
(
particle1
)
>
0
)
&&
(
system
.
getParticleMass
(
particle2
)
>
0
)){
if
((
particle1_in_thermostatedParticles
&&
!
particle2_in_thermostatedParticles
)
||
if
((
particle1_in_thermostatedParticles
&&
!
particle2_in_thermostatedParticles
)
||
(
!
particle1_in_thermostatedParticles
&&
particle2_in_thermostatedParticles
)){
(
!
particle1_in_thermostatedParticles
&&
particle2_in_thermostatedParticles
)){
...
@@ -127,21 +132,14 @@ void NoseHooverIntegrator::createThermostats(const System &system) {
...
@@ -127,21 +132,14 @@ void NoseHooverIntegrator::createThermostats(const System &system) {
// remove 3 degrees of freedom from thermostats that act on absolute motions
// remove 3 degrees of freedom from thermostats that act on absolute motions
int
numForces
=
system
.
getNumForces
();
int
numForces
=
system
.
getNumForces
();
if
(
thermostat
.
thermostatedPairs
.
size
()
==
0
){
if
(
thermostatedPairs
.
size
()
==
0
){
for
(
int
forceNum
=
0
;
forceNum
<
numForces
;
++
forceNum
)
{
for
(
int
forceNum
=
0
;
forceNum
<
numForces
;
++
forceNum
)
{
if
(
dynamic_cast
<
const
CMMotionRemover
*>
(
&
system
.
getForce
(
forceNum
)))
nDOF
-=
3
;
if
(
dynamic_cast
<
const
CMMotionRemover
*>
(
&
system
.
getForce
(
forceNum
)))
nDOF
-=
3
;
}
}
}
}
// create and add new chain
// set number of DoFs for chain
int
chainID
=
noseHooverChains
.
size
();
thermostat
.
setDefaultNumDegreesOfFreedom
(
nDOF
);
auto
chain
=
NoseHooverChain
(
thermostat
.
temperature
,
thermostat
.
relativeTemperature
,
thermostat
.
collisionFrequency
,
thermostat
.
relativeCollisionFrequency
,
nDOF
,
thermostat
.
chainLength
,
thermostat
.
numMTS
,
thermostat
.
numYoshidaSuzuki
,
chainID
,
thermostat
.
thermostatedParticles
,
thermostat
.
thermostatedPairs
);
noseHooverChains
.
push_back
(
chain
);
}
}
...
@@ -271,9 +269,10 @@ void NoseHooverIntegrator::initialize(ContextImpl& contextRef) {
...
@@ -271,9 +269,10 @@ void NoseHooverIntegrator::initialize(ContextImpl& contextRef) {
// check for drude particles and build the Nose-Hoover Chains
// check for drude particles and build the Nose-Hoover Chains
const
System
&
system
=
context
->
getSystem
();
const
System
&
system
=
context
->
getSystem
();
for
(
auto
&
thermostat
:
thermostatData
){
for
(
auto
&
thermostat
:
noseHooverChains
){
// if there are no thermostated particles or pairs in the lists this is a regular thermostat for the whole (non-Drude) system
// if there are no thermostated particles or pairs in the lists this is a regular thermostat for the whole (non-Drude) system
if
(
(
thermostat
.
thermostatedParticles
.
size
()
==
0
)
&&
(
thermostat
.
thermostatedPairs
.
size
()
==
0
)
){
if
(
(
thermostat
.
getThermostatedAtoms
().
size
()
==
0
)
&&
(
thermostat
.
getThermostatedPairs
().
size
()
==
0
)
){
std
::
vector
<
int
>
thermostatedParticles
;
for
(
int
particle
=
0
;
particle
<
system
.
getNumParticles
();
++
particle
)
{
for
(
int
particle
=
0
;
particle
<
system
.
getNumParticles
();
++
particle
)
{
double
mass
=
system
.
getParticleMass
(
particle
);
double
mass
=
system
.
getParticleMass
(
particle
);
if
(
(
mass
>
0
)
&&
(
mass
<
0.8
)
){
if
(
(
mass
>
0
)
&&
(
mass
<
0.8
)
){
...
@@ -281,13 +280,14 @@ void NoseHooverIntegrator::initialize(ContextImpl& contextRef) {
...
@@ -281,13 +280,14 @@ void NoseHooverIntegrator::initialize(ContextImpl& contextRef) {
"The thermostat you are about to use will not treat these particles as Drude particles!"
<<
std
::
endl
;
"The thermostat you are about to use will not treat these particles as Drude particles!"
<<
std
::
endl
;
}
}
if
(
system
.
getParticleMass
(
particle
)
>
0
)
{
if
(
system
.
getParticleMass
(
particle
)
>
0
)
{
thermostat
.
thermostatedParticles
.
push_back
(
particle
);
thermostatedParticles
.
push_back
(
particle
);
}
}
}
}
thermostat
.
setThermostatedAtoms
(
thermostatedParticles
);
}
}
}
}
creat
eThermostats
(
system
);
initializ
eThermostats
(
system
);
}
}
void
NoseHooverIntegrator
::
cleanup
()
{
void
NoseHooverIntegrator
::
cleanup
()
{
...
...
plugins/drude/openmmapi/include/OpenMMDrude.h
View file @
b3be7aec
...
@@ -35,6 +35,6 @@
...
@@ -35,6 +35,6 @@
#include "openmm/DrudeForce.h"
#include "openmm/DrudeForce.h"
#include "openmm/DrudeLangevinIntegrator.h"
#include "openmm/DrudeLangevinIntegrator.h"
#include "openmm/DrudeSCFIntegrator.h"
#include "openmm/DrudeSCFIntegrator.h"
#include "openmm/DrudeNIntegrator.h"
#include "openmm/DrudeN
oseHoover
Integrator.h"
#endif
/*OPENMM_DRUDE_H_*/
#endif
/*OPENMM_DRUDE_H_*/
plugins/drude/openmmapi/include/openmm/DrudeNoseHooverIntegrator.h
View file @
b3be7aec
...
@@ -54,10 +54,10 @@ public:
...
@@ -54,10 +54,10 @@ public:
/**
/**
* Create a DrudeNoseHooverIntegrator.
* Create a DrudeNoseHooverIntegrator.
*
*
* @param temperature the target temperature for the system.
* @param temperature the target temperature for the system
(in Kelvin)
.
* @param collisionFrequency the frequency of the system's interaction with the heat bath (in
1/p
s).
* @param collisionFrequency the frequency of the system's interaction with the heat bath (in
inverse picosecond
s).
* @param drudeTemperature the target temperature for the Drude particles, relative to their parent atom.
* @param drudeTemperature the target temperature for the Drude particles, relative to their parent atom
(in Kelvin)
.
* @param drudeCollisionFrequency the frequency of the drude particles' interaction with the heat bath (in
1/p
s).
* @param drudeCollisionFrequency the frequency of the drude particles' interaction with the heat bath (in
inverse picosecond
s).
* @param stepSize the step size with which to integrator the system (in picoseconds)
* @param stepSize the step size with which to integrator the system (in picoseconds)
* @param chainLength the number of beads in the Nose-Hoover chain.
* @param chainLength the number of beads in the Nose-Hoover chain.
* @param numMTS the number of step in the multiple time step chain propagation algorithm.
* @param numMTS the number of step in the multiple time step chain propagation algorithm.
...
...
plugins/drude/openmmapi/src/DrudeNoseHooverIntegrator.cpp
View file @
b3be7aec
...
@@ -94,8 +94,8 @@ void DrudeNoseHooverIntegrator::initialize(ContextImpl& contextRef) {
...
@@ -94,8 +94,8 @@ void DrudeNoseHooverIntegrator::initialize(ContextImpl& contextRef) {
std
::
cout
<<
"Warning: Did not find a center-of-mass motion remover in the system. "
std
::
cout
<<
"Warning: Did not find a center-of-mass motion remover in the system. "
"This is problematic when using Drude."
<<
std
::
endl
;
"This is problematic when using Drude."
<<
std
::
endl
;
}
}
for
(
auto
&
thermostat
:
thermostatData
){
for
(
auto
&
thermostat
:
noseHooverChains
){
if
(
(
thermostat
.
t
hermostated
Particles
.
size
()
==
0
)
&&
(
thermostat
.
t
hermostatedPairs
.
size
()
==
0
)
){
if
(
(
thermostat
.
getT
hermostated
Atoms
()
.
size
()
==
0
)
&&
(
thermostat
.
getT
hermostatedPairs
()
.
size
()
==
0
)
){
std
::
set
<
int
>
realParticlesSet
;
std
::
set
<
int
>
realParticlesSet
;
vector
<
int
>
realParticles
,
drudeParticles
,
drudeParents
;
vector
<
int
>
realParticles
,
drudeParticles
,
drudeParents
;
vector
<
std
::
pair
<
int
,
int
>>
drudePairs
;
vector
<
std
::
pair
<
int
,
int
>>
drudePairs
;
...
@@ -108,13 +108,14 @@ void DrudeNoseHooverIntegrator::initialize(ContextImpl& contextRef) {
...
@@ -108,13 +108,14 @@ void DrudeNoseHooverIntegrator::initialize(ContextImpl& contextRef) {
drudeForce
->
getParticleParameters
(
i
,
p
,
p1
,
p2
,
p3
,
p4
,
charge
,
polarizability
,
aniso12
,
aniso34
);
drudeForce
->
getParticleParameters
(
i
,
p
,
p1
,
p2
,
p3
,
p4
,
charge
,
polarizability
,
aniso12
,
aniso34
);
realParticlesSet
.
erase
(
p
);
realParticlesSet
.
erase
(
p
);
realParticlesSet
.
erase
(
p1
);
realParticlesSet
.
erase
(
p1
);
thermostat
.
thermostated
Pairs
.
push_back
({
p
,
p1
});
drude
Pairs
.
push_back
({
p
,
p1
});
}
}
for
(
const
auto
&
p
:
realParticlesSet
)
thermostat
.
thermostatedParticles
.
push_back
(
p
);
thermostat
.
setThermostatedPairs
(
drudePairs
);
thermostat
.
setThermostatedAtoms
(
std
::
vector
<
int
>
(
realParticlesSet
.
begin
(),
realParticlesSet
.
end
()));
}
}
}
}
creat
eThermostats
(
system
);
initializ
eThermostats
(
system
);
}
}
double
DrudeNoseHooverIntegrator
::
computeDrudeKineticEnergy
()
{
double
DrudeNoseHooverIntegrator
::
computeDrudeKineticEnergy
()
{
...
...
wrappers/python/src/swig_doxygen/swigInputBuilder.py
View file @
b3be7aec
...
@@ -21,6 +21,9 @@ except ImportError:
...
@@ -21,6 +21,9 @@ except ImportError:
INDENT
=
" "
INDENT
=
" "
docTags
=
{
'emphasis'
:
'i'
,
'bold'
:
'b'
,
'itemizedlist'
:
'ul'
,
'listitem'
:
'li'
,
'preformatted'
:
'pre'
,
'computeroutput'
:
'tt'
,
'subscript'
:
'sub'
}
docTags
=
{
'emphasis'
:
'i'
,
'bold'
:
'b'
,
'itemizedlist'
:
'ul'
,
'listitem'
:
'li'
,
'preformatted'
:
'pre'
,
'computeroutput'
:
'tt'
,
'subscript'
:
'sub'
}
def
is_method_abstract
(
argstring
):
return
argstring
.
split
(
")"
)[
-
1
].
find
(
"=0"
)
>=
0
def
striphtmltags
(
s
):
def
striphtmltags
(
s
):
"""Strip a couple html tags used inside docstrings in the C++ source
"""Strip a couple html tags used inside docstrings in the C++ source
to produce something more easily read as plain text.
to produce something more easily read as plain text.
...
@@ -511,7 +514,7 @@ class SwigInputBuilder:
...
@@ -511,7 +514,7 @@ class SwigInputBuilder:
mArgsstring
=
getText
(
"argsstring"
,
memberNode
)
mArgsstring
=
getText
(
"argsstring"
,
memberNode
)
if
self
.
fOutPythonprepend
and
\
if
self
.
fOutPythonprepend
and
\
len
(
paramList
)
and
\
len
(
paramList
)
and
\
mArgsstring
.
find
(
'=0'
)
<
0
:
not
is_method_abstract
(
mArgsstring
)
:
text
=
'''
text
=
'''
%pythonprepend OpenMM::{shortClassName}::{methName}{mArgsstring} %{{{{{{0}}
%pythonprepend OpenMM::{shortClassName}::{methName}{mArgsstring} %{{{{{{0}}
%}}}}'''
.
format
(
shortClassName
=
shortClassName
,
methName
=
methName
,
mArgsstring
=
mArgsstring
)
%}}}}'''
.
format
(
shortClassName
=
shortClassName
,
methName
=
methName
,
mArgsstring
=
mArgsstring
)
...
@@ -529,6 +532,7 @@ class SwigInputBuilder:
...
@@ -529,6 +532,7 @@ class SwigInputBuilder:
% self.__class__.__name__)
% self.__class__.__name__)
raise Exception(s)'''
.
format
(
argName
=
argName
)
raise Exception(s)'''
.
format
(
argName
=
argName
)
# Convert input arguments to the proper units, if specified.
# Convert input arguments to the proper units, if specified.
if
key
not
in
methodsWithOutputArgs
:
if
key
not
in
methodsWithOutputArgs
:
if
key
in
self
.
configModule
.
UNITS
:
if
key
in
self
.
configModule
.
UNITS
:
...
@@ -563,9 +567,10 @@ class SwigInputBuilder:
...
@@ -563,9 +567,10 @@ class SwigInputBuilder:
# write pythonappend blocks
# write pythonappend blocks
if
self
.
fOutPythonappend
\
if
self
.
fOutPythonappend
\
and
mArgsstring
.
find
(
'=0'
)
<
0
:
and
not
is_method_abstract
(
mArgsstring
)
:
key
=
(
shortClassName
,
methName
)
key
=
(
shortClassName
,
methName
)
#print "key %s %s \n" % (shortClassName, methName)
#sys.stdout.write("key %s %s \n" % (shortClassName, methName))
addText
=
''
addText
=
''
returnType
=
getText
(
"type"
,
memberNode
)
returnType
=
getText
(
"type"
,
memberNode
)
...
@@ -619,8 +624,15 @@ class SwigInputBuilder:
...
@@ -619,8 +624,15 @@ class SwigInputBuilder:
pType
=
getText
(
'type'
,
pNode
)
pType
=
getText
(
'type'
,
pNode
)
except
IndexError
:
except
IndexError
:
pType
=
getText
(
'type/ref'
,
pNode
)
pType
=
getText
(
'type/ref'
,
pNode
)
# parse default arguments
try
:
defaultValue
=
getText
(
'defval'
,
pNode
)
except
:
defaultValue
=
""
if
defaultValue
!=
""
:
defaultValue
=
"=%s"
%
defaultValue
pName
=
getText
(
'declname'
,
pNode
)
pName
=
getText
(
'declname'
,
pNode
)
self
.
fOutPythonappend
.
write
(
"%s%s %s"
%
(
sepChar
,
pType
,
pName
))
self
.
fOutPythonappend
.
write
(
"%s%s
%s
%s"
%
(
sepChar
,
pType
,
pName
,
defaultValue
))
sepChar
=
', '
sepChar
=
', '
if
pType
.
find
(
'&'
)
>=
0
and
\
if
pType
.
find
(
'&'
)
>=
0
and
\
...
...
wrappers/python/src/swig_doxygen/swigInputConfig.py
View file @
b3be7aec
...
@@ -217,6 +217,9 @@ UNITS = {
...
@@ -217,6 +217,9 @@ UNITS = {
(
"*"
,
"getTabulatedFunction"
)
:
(
None
,
()),
(
"*"
,
"getTabulatedFunction"
)
:
(
None
,
()),
(
"*"
,
"getUseDispersionCorrection"
)
:
(
None
,
()),
(
"*"
,
"getUseDispersionCorrection"
)
:
(
None
,
()),
(
"*"
,
"getTemperature"
)
:
(
"unit.kelvin"
,
()),
(
"*"
,
"getTemperature"
)
:
(
"unit.kelvin"
,
()),
(
"*"
,
"getRelativeTemperature"
)
:
(
"unit.kelvin"
,
()),
(
"*"
,
"getCollisionFrequency"
)
:
(
"1/unit.picosecond"
,
()),
(
"*"
,
"getRelativeCollisionFrequency"
)
:
(
"1/unit.picosecond"
,
()),
(
"*"
,
"getUseDispersionCorrection"
)
:
(
None
,
()),
(
"*"
,
"getUseDispersionCorrection"
)
:
(
None
,
()),
(
"*"
,
"getWeight"
)
:
(
None
,
()),
(
"*"
,
"getWeight"
)
:
(
None
,
()),
(
"*"
,
"getWeight12"
)
:
(
None
,
()),
(
"*"
,
"getWeight12"
)
:
(
None
,
()),
...
@@ -343,9 +346,11 @@ UNITS = {
...
@@ -343,9 +346,11 @@ UNITS = {
(
"HippoNonbondedForce"
,
"getInducedDipoles"
)
:
(
None
,
()),
(
"HippoNonbondedForce"
,
"getInducedDipoles"
)
:
(
None
,
()),
(
"HippoNonbondedForce"
,
"getLabFramePermanentDipoles"
)
:
(
None
,
()),
(
"HippoNonbondedForce"
,
"getLabFramePermanentDipoles"
)
:
(
None
,
()),
(
"Context"
,
"getParameter"
)
:
(
None
,
()),
(
"Context"
,
"getParameter"
)
:
(
None
,
()),
(
"Context"
,
"getParameters"
)
:
(
None
,
()),
(
"Context"
,
"getParameters"
)
:
(
None
,
()),
(
"Context"
,
"getMolecules"
)
:
(
None
,
()),
(
"Context"
,
"getMolecules"
)
:
(
None
,
()),
(
"Context"
,
"getState"
)
:
(
None
,
(
None
,
None
,
None
)),
(
"CMAPTorsionForce"
,
"getMapParameters"
)
:
(
None
,
(
None
,
'unit.kilojoule_per_mole'
)),
(
"CMAPTorsionForce"
,
"getMapParameters"
)
:
(
None
,
(
None
,
'unit.kilojoule_per_mole'
)),
(
"CMAPTorsionForce"
,
"getTorsionParameters"
)
:
(
None
,
()),
(
"CMAPTorsionForce"
,
"getTorsionParameters"
)
:
(
None
,
()),
(
"CMMotionRemover"
,
"getFrequency"
)
:
(
None
,
()),
(
"CMMotionRemover"
,
"getFrequency"
)
:
(
None
,
()),
...
@@ -466,17 +471,28 @@ UNITS = {
...
@@ -466,17 +471,28 @@ UNITS = {
(
"System"
,
"getVirtualSite"
)
:
(
None
,
()),
(
"System"
,
"getVirtualSite"
)
:
(
None
,
()),
(
"DrudeLangevinIntegrator"
,
"getDrudeTemperature"
)
:
(
"unit.kelvin"
,
()),
(
"DrudeLangevinIntegrator"
,
"getDrudeTemperature"
)
:
(
"unit.kelvin"
,
()),
(
"DrudeLangevinIntegrator"
,
"getMaxDrudeDistance"
)
:
(
"unit.nanometer"
,
()),
(
"DrudeLangevinIntegrator"
,
"getMaxDrudeDistance"
)
:
(
"unit.nanometer"
,
()),
(
"MonteCarloMembraneBarostat"
,
"MonteCarloMembraneBarostat"
)
:
(
None
,
(
"unit.bar"
,
"unit.bar*unit.nanometer"
,
"unit.kelvin"
,
None
,
None
,
None
)),
(
"MonteCarloMembraneBarostat"
,
"MonteCarloMembraneBarostat"
)
:
(
None
,
(
"unit.bar"
,
"unit.bar*unit.nanometer"
,
"unit.kelvin"
,
None
,
None
,
None
)),
(
"MonteCarloMembraneBarostat"
,
"getXYMode"
)
:
(
None
,
()),
(
"MonteCarloMembraneBarostat"
,
"getXYMode"
)
:
(
None
,
()),
(
"MonteCarloMembraneBarostat"
,
"getZMode"
)
:
(
None
,
()),
(
"MonteCarloMembraneBarostat"
,
"getZMode"
)
:
(
None
,
()),
(
"DrudeLangevinIntegrator"
,
"getDrudeFriction"
)
:
(
"1/unit.picosecond"
,
()),
(
"DrudeLangevinIntegrator"
,
"getDrudeFriction"
)
:
(
"1/unit.picosecond"
,
()),
(
"NoseHooverChain"
,
"getThermostatedPairs"
)
:
(
None
,
()),
(
"NoseHooverChain"
,
"getThermostatedAtoms"
)
:
(
None
,
()),
(
"NoseHooverChain"
,
"getDefaultYoshidaSuzukiWeights"
)
:
(
None
,
()),
(
"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"
,
()),
(
"RPMDIntegrator"
,
"getTotalEnergy"
)
:
(
"unit.kilojoules_per_mole"
,
()),
(
"RPMDIntegrator"
,
"getState"
):
(
None
,(
None
,
None
,
None
,
None
)),
(
"RMSDForce"
,
"getReferencePositions"
)
:
(
"unit.nanometer"
,
()),
(
"RMSDForce"
,
"getReferencePositions"
)
:
(
"unit.nanometer"
,
()),
(
"RMSDForce"
,
"getParticles"
)
:
(
None
,
()),
(
"RMSDForce"
,
"getParticles"
)
:
(
None
,
()),
#("NoseHooverChain", "getThermostatedPairs") : (None, ()),
#("NoseHooverChain", "getThermostatedAtoms") : (None, ()),
#("NoseHooverChain", "getDefaultYoshidaSuzukiWeights") : (None, ()),
#("NoseHooverIntegrator", "NoseHooverIntegrator") : (None, ("unit.kelvin", "1/unit.picosecond", "unit,picosecond", None, None, None)),
(
"NoseHooverIntegrator"
,
"setTemperature"
)
:
(
None
,
(
"unit.kelvin"
,
None
)),
(
"NoseHooverIntegrator"
,
"setRelativeTemperature"
)
:
(
None
,
(
"unit.kelvin"
,
None
)
),
(
"NoseHooverIntegrator"
,
"setCollisionFrequency"
)
:
(
None
,
(
"1/unit.picosecond"
,
None
)),
(
"NoseHooverIntegrator"
,
"setRelativeCollisionFrequency"
)
:
(
None
,
(
"1/unit.picosecond"
,
None
)),
(
"NoseHooverIntegrator"
,
"computeHeatBathEnergy"
)
:
(
"unit.kilojoules_per_mole"
,
()),
(
"NoseHooverIntegrator"
,
"addThermostat"
):
(
None
,
(
"unit.kelvin"
,
"1/unit.picosecond"
,
None
,
None
,
None
)),
(
"NoseHooverIntegrator"
,
"addSubsystemThermostat"
):
(
None
,
(
None
,
None
,
"unit.kelvin"
,
"1/unit.picosecond"
,
"unit.kelvin"
,
"1/unit.picosecond"
,
None
,
None
,
None
))
}
}
wrappers/python/tests/TestAPIUnits.py
View file @
b3be7aec
...
@@ -1165,6 +1165,21 @@ class TestAPIUnits(unittest.TestCase):
...
@@ -1165,6 +1165,21 @@ class TestAPIUnits(unittest.TestCase):
self
.
assertAlmostEqualUnit
(
integrator
.
getFriction
(),
0.1
/
microsecond
)
self
.
assertAlmostEqualUnit
(
integrator
.
getFriction
(),
0.1
/
microsecond
)
self
.
assertEqual
(
integrator
.
getStepSize
(),
1
*
femtosecond
)
self
.
assertEqual
(
integrator
.
getStepSize
(),
1
*
femtosecond
)
def
testNoseHooverIntegrator
(
self
):
""" Tests the NoseHooverIntegrator API features """
integrator
=
NoseHooverIntegrator
(
300
,
0.1
,
1
)
self
.
assertEqual
(
integrator
.
getTemperature
(
0
),
300
*
kelvin
)
self
.
assertEqual
(
integrator
.
getCollisionFrequency
(),
0.1
/
picosecond
)
self
.
assertEqual
(
integrator
.
getStepSize
(),
1
*
picosecond
)
integrator
=
NoseHooverIntegrator
(
300
*
kelvin
,
0.1
/
microsecond
,
1
*
femtosecond
)
self
.
assertEqual
(
integrator
.
getTemperature
(),
300
*
kelvin
)
self
.
assertAlmostEqualUnit
(
integrator
.
getCollisionFrequency
(),
0.1
/
microsecond
)
self
.
assertEqual
(
integrator
.
getStepSize
(),
1
*
femtosecond
)
integrator
=
NoseHooverIntegrator
(
1
*
femtosecond
)
self
.
assertEqual
(
integrator
.
getStepSize
(),
1
*
femtosecond
)
def
testAndersenThermostat
(
self
):
def
testAndersenThermostat
(
self
):
""" Tests the AndersenThermostat API features """
""" Tests the AndersenThermostat API features """
force
=
AndersenThermostat
(
300
*
kelvin
,
1
/
microsecond
)
force
=
AndersenThermostat
(
300
*
kelvin
,
1
/
microsecond
)
...
...
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