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
19d2885a
Commit
19d2885a
authored
Jan 23, 2014
by
Lee-Ping
Browse files
Merge github.com:SimTk/openmm
parents
99ef4344
57a6768e
Changes
310
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
116 additions
and
247 deletions
+116
-247
platforms/reference/include/ReferenceBondIxn.h
platforms/reference/include/ReferenceBondIxn.h
+3
-1
platforms/reference/include/ReferenceBrownianDynamics.h
platforms/reference/include/ReferenceBrownianDynamics.h
+2
-1
platforms/reference/include/ReferenceCCMAAlgorithm.h
platforms/reference/include/ReferenceCCMAAlgorithm.h
+6
-16
platforms/reference/include/ReferenceConstraintAlgorithm.h
platforms/reference/include/ReferenceConstraintAlgorithm.h
+4
-12
platforms/reference/include/ReferenceConstraints.h
platforms/reference/include/ReferenceConstraints.h
+8
-19
platforms/reference/include/ReferenceCustomDynamics.h
platforms/reference/include/ReferenceCustomDynamics.h
+2
-1
platforms/reference/include/ReferenceDynamics.h
platforms/reference/include/ReferenceDynamics.h
+2
-1
platforms/reference/include/ReferenceKernelFactory.h
platforms/reference/include/ReferenceKernelFactory.h
+1
-1
platforms/reference/include/ReferenceKernels.h
platforms/reference/include/ReferenceKernels.h
+7
-23
platforms/reference/include/ReferenceLJCoulomb14.h
platforms/reference/include/ReferenceLJCoulomb14.h
+2
-1
platforms/reference/include/ReferencePME.h
platforms/reference/include/ReferencePME.h
+6
-5
platforms/reference/include/ReferencePlatform.h
platforms/reference/include/ReferencePlatform.h
+3
-1
platforms/reference/include/ReferenceSETTLEAlgorithm.h
platforms/reference/include/ReferenceSETTLEAlgorithm.h
+17
-10
platforms/reference/include/ReferenceStochasticDynamics.h
platforms/reference/include/ReferenceStochasticDynamics.h
+7
-5
platforms/reference/include/ReferenceVariableStochasticDynamics.h
...s/reference/include/ReferenceVariableStochasticDynamics.h
+2
-1
platforms/reference/include/ReferenceVariableVerletDynamics.h
...forms/reference/include/ReferenceVariableVerletDynamics.h
+2
-1
platforms/reference/include/ReferenceVerletDynamics.h
platforms/reference/include/ReferenceVerletDynamics.h
+2
-1
platforms/reference/src/ReferenceKernels.cpp
platforms/reference/src/ReferenceKernels.cpp
+29
-141
platforms/reference/src/ReferencePlatform.cpp
platforms/reference/src/ReferencePlatform.cpp
+5
-2
platforms/reference/src/SimTKReference/ReferenceAndersenThermostat.cpp
...erence/src/SimTKReference/ReferenceAndersenThermostat.cpp
+6
-4
No files found.
platforms/reference/include/ReferenceBondIxn.h
View file @
19d2885a
...
...
@@ -25,7 +25,9 @@
#ifndef __ReferenceBondIxn_H__
#define __ReferenceBondIxn_H__
// #include "ReferenceIxn.h"
#include "RealVec.h"
#include "openmm/internal/windowsExport.h"
#include <vector>
// ---------------------------------------------------------------------------------------
...
...
platforms/reference/include/ReferenceBrownianDynamics.h
View file @
19d2885a
...
...
@@ -79,11 +79,12 @@ class ReferenceBrownianDynamics : public ReferenceDynamics {
@param velocities velocities
@param forces forces
@param masses atom masses
@param tolerance the constraint tolerance
--------------------------------------------------------------------------------------- */
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
tolerance
);
};
...
...
platforms/reference/include/ReferenceCCMAAlgorithm.h
View file @
19d2885a
...
...
@@ -37,7 +37,6 @@ class OPENMM_EXPORT ReferenceCCMAAlgorithm : public ReferenceConstraintAlgorithm
protected:
int
_maximumNumberOfIterations
;
RealOpenMM
_tolerance
;
int
_numberOfConstraints
;
std
::
vector
<
std
::
pair
<
int
,
int
>
>
_atomIndices
;
...
...
@@ -53,7 +52,7 @@ protected:
private:
void
applyConstraints
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
bool
constrainingVelocities
);
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
bool
constrainingVelocities
,
RealOpenMM
tolerance
);
public:
class
AngleInfo
;
...
...
@@ -67,9 +66,8 @@ public:
* @param distance distances for constraints
* @param masses atom masses
* @param angles angle force field terms
* @param tolerance constraint tolerance
*/
ReferenceCCMAAlgorithm
(
int
numberOfAtoms
,
int
numberOfConstraints
,
const
std
::
vector
<
std
::
pair
<
int
,
int
>
>&
atomIndices
,
const
std
::
vector
<
RealOpenMM
>&
distance
,
std
::
vector
<
RealOpenMM
>&
masses
,
std
::
vector
<
AngleInfo
>&
angles
,
RealOpenMM
tolerance
);
ReferenceCCMAAlgorithm
(
int
numberOfAtoms
,
int
numberOfConstraints
,
const
std
::
vector
<
std
::
pair
<
int
,
int
>
>&
atomIndices
,
const
std
::
vector
<
RealOpenMM
>&
distance
,
std
::
vector
<
RealOpenMM
>&
masses
,
std
::
vector
<
AngleInfo
>&
angles
);
~
ReferenceCCMAAlgorithm
(
);
...
...
@@ -88,25 +86,16 @@ public:
*/
void
setMaximumNumberOfIterations
(
int
maximumNumberOfIterations
);
/**
* Get the constraint tolerance.
*/
RealOpenMM
getTolerance
(
void
)
const
;
/**
* Set the constraint tolerance.
*/
void
setTolerance
(
RealOpenMM
tolerance
);
/**
* Apply the constraint algorithm.
*
* @param atomCoordinates the original atom coordinates
* @param atomCoordinatesP the new atom coordinates
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
void
apply
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
);
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
);
/**
* Apply the constraint algorithm to velocities.
...
...
@@ -114,9 +103,10 @@ public:
* @param atomCoordinates the atom coordinates
* @param atomCoordinatesP the velocities to modify
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
void
applyToVelocities
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
);
};
class
ReferenceCCMAAlgorithm
::
AngleInfo
...
...
platforms/reference/include/ReferenceConstraintAlgorithm.h
View file @
19d2885a
...
...
@@ -36,25 +36,16 @@ public:
virtual
~
ReferenceConstraintAlgorithm
()
{};
/**
* Get the constraint tolerance.
*/
virtual
RealOpenMM
getTolerance
()
const
=
0
;
/**
* Set the constraint tolerance.
*/
virtual
void
setTolerance
(
RealOpenMM
tolerance
)
=
0
;
/**
* Apply the constraint algorithm.
*
* @param atomCoordinates the original atom coordinates
* @param atomCoordinatesP the new atom coordinates
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
virtual
void
apply
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
)
=
0
;
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
)
=
0
;
/**
* Apply the constraint algorithm to velocities.
...
...
@@ -62,9 +53,10 @@ public:
* @param atomCoordinates the atom coordinates
* @param atomCoordinatesP the velocities to modify
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
virtual
void
applyToVelocities
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
)
=
0
;
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
)
=
0
;
};
// ---------------------------------------------------------------------------------------
...
...
platforms/reference/include/ReferenceConstraints.h
View file @
19d2885a
...
...
@@ -33,8 +33,6 @@
* -------------------------------------------------------------------------- */
#include "ReferenceConstraintAlgorithm.h"
#include "ReferenceCCMAAlgorithm.h"
#include "ReferenceSETTLEAlgorithm.h"
#include "openmm/System.h"
namespace
OpenMM
{
...
...
@@ -46,17 +44,8 @@ namespace OpenMM {
*/
class
OPENMM_EXPORT
ReferenceConstraints
:
public
ReferenceConstraintAlgorithm
{
public:
ReferenceConstraints
(
const
System
&
system
,
RealOpenMM
tolerance
);
~
ReferenceConstraints
();
/**
* Get the constraint tolerance.
*/
RealOpenMM
getTolerance
()
const
;
/**
* Set the constraint tolerance.
*/
void
setTolerance
(
RealOpenMM
tolerance
);
ReferenceConstraints
(
const
System
&
system
);
virtual
~
ReferenceConstraints
();
/**
* Apply the constraint algorithm.
...
...
@@ -64,8 +53,9 @@ public:
* @param atomCoordinates the original atom coordinates
* @param atomCoordinatesP the new atom coordinates
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
void
apply
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
);
void
apply
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
);
/**
* Apply the constraint algorithm to velocities.
...
...
@@ -73,12 +63,11 @@ public:
* @param atomCoordinates the atom coordinates
* @param atomCoordinatesP the velocities to modify
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
void
applyToVelocities
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
);
private:
RealOpenMM
tolerance
;
ReferenceCCMAAlgorithm
*
ccma
;
ReferenceSETTLEAlgorithm
*
settle
;
void
applyToVelocities
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
);
ReferenceConstraintAlgorithm
*
ccma
;
ReferenceConstraintAlgorithm
*
settle
;
};
}
// namespace OpenMM
...
...
platforms/reference/include/ReferenceCustomDynamics.h
View file @
19d2885a
...
...
@@ -92,12 +92,13 @@ public:
@param globals a map containing values of global variables
@param perDof the values of per-DOF variables
@param forcesAreValid whether the current forces are valid or need to be recomputed
@param tolerance the constraint tolerance
--------------------------------------------------------------------------------------- */
void
update
(
OpenMM
::
ContextImpl
&
context
,
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
std
::
map
<
std
::
string
,
RealOpenMM
>&
globals
,
std
::
vector
<
std
::
vector
<
OpenMM
::
RealVec
>
>&
perDof
,
bool
&
forcesAreValid
);
std
::
map
<
std
::
string
,
RealOpenMM
>&
globals
,
std
::
vector
<
std
::
vector
<
OpenMM
::
RealVec
>
>&
perDof
,
bool
&
forcesAreValid
,
RealOpenMM
tolerance
);
/**---------------------------------------------------------------------------------------
...
...
platforms/reference/include/ReferenceDynamics.h
View file @
19d2885a
...
...
@@ -145,11 +145,12 @@ class OPENMM_EXPORT ReferenceDynamics {
@param velocities velocities
@param forces forces
@param masses atom masses
@param tolerance the constraint tolerance
--------------------------------------------------------------------------------------- */
virtual
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
tolerance
);
/**---------------------------------------------------------------------------------------
...
...
platforms/reference/include/ReferenceKernelFactory.h
View file @
19d2885a
...
...
@@ -40,7 +40,7 @@ namespace OpenMM {
* This KernelFactory creates all kernels for ReferencePlatform.
*/
class
ReferenceKernelFactory
:
public
KernelFactory
{
class
OPENMM_EXPORT
ReferenceKernelFactory
:
public
KernelFactory
{
public:
KernelImpl
*
createKernelImpl
(
std
::
string
name
,
const
Platform
&
platform
,
ContextImpl
&
context
)
const
;
};
...
...
platforms/reference/include/ReferenceKernels.h
View file @
19d2885a
...
...
@@ -191,7 +191,7 @@ private:
class
ReferenceApplyConstraintsKernel
:
public
ApplyConstraintsKernel
{
public:
ReferenceApplyConstraintsKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
ApplyConstraintsKernel
(
name
,
platform
),
data
(
data
)
,
constraints
(
0
)
{
ApplyConstraintsKernel
(
name
,
platform
),
data
(
data
)
{
}
~
ReferenceApplyConstraintsKernel
();
/**
...
...
@@ -216,12 +216,8 @@ public:
void
applyToVelocities
(
ContextImpl
&
context
,
double
tol
);
private:
ReferencePlatform
::
PlatformData
&
data
;
ReferenceConstraintAlgorithm
*
constraints
;
std
::
vector
<
RealOpenMM
>
masses
;
std
::
vector
<
RealOpenMM
>
inverseMasses
;
std
::
vector
<
std
::
pair
<
int
,
int
>
>
constraintIndices
;
std
::
vector
<
RealOpenMM
>
constraintDistances
;
int
numConstraints
;
};
/**
...
...
@@ -871,7 +867,7 @@ private:
class
ReferenceIntegrateVerletStepKernel
:
public
IntegrateVerletStepKernel
{
public:
ReferenceIntegrateVerletStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateVerletStepKernel
(
name
,
platform
),
data
(
data
),
dynamics
(
0
)
,
constraints
(
0
)
{
data
(
data
),
dynamics
(
0
)
{
}
~
ReferenceIntegrateVerletStepKernel
();
/**
...
...
@@ -898,9 +894,7 @@ public:
private:
ReferencePlatform
::
PlatformData
&
data
;
ReferenceVerletDynamics
*
dynamics
;
ReferenceConstraintAlgorithm
*
constraints
;
std
::
vector
<
RealOpenMM
>
masses
;
int
numConstraints
;
double
prevStepSize
;
};
...
...
@@ -910,7 +904,7 @@ private:
class
ReferenceIntegrateLangevinStepKernel
:
public
IntegrateLangevinStepKernel
{
public:
ReferenceIntegrateLangevinStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateLangevinStepKernel
(
name
,
platform
),
data
(
data
),
dynamics
(
0
)
,
constraints
(
0
)
{
data
(
data
),
dynamics
(
0
)
{
}
~
ReferenceIntegrateLangevinStepKernel
();
/**
...
...
@@ -937,9 +931,7 @@ public:
private:
ReferencePlatform
::
PlatformData
&
data
;
ReferenceStochasticDynamics
*
dynamics
;
ReferenceConstraintAlgorithm
*
constraints
;
std
::
vector
<
RealOpenMM
>
masses
;
int
numConstraints
;
double
prevTemp
,
prevFriction
,
prevStepSize
;
};
...
...
@@ -949,7 +941,7 @@ private:
class
ReferenceIntegrateBrownianStepKernel
:
public
IntegrateBrownianStepKernel
{
public:
ReferenceIntegrateBrownianStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateBrownianStepKernel
(
name
,
platform
),
data
(
data
),
dynamics
(
0
)
,
constraints
(
0
)
{
data
(
data
),
dynamics
(
0
)
{
}
~
ReferenceIntegrateBrownianStepKernel
();
/**
...
...
@@ -976,9 +968,7 @@ public:
private:
ReferencePlatform
::
PlatformData
&
data
;
ReferenceBrownianDynamics
*
dynamics
;
ReferenceConstraintAlgorithm
*
constraints
;
std
::
vector
<
RealOpenMM
>
masses
;
int
numConstraints
;
double
prevTemp
,
prevFriction
,
prevStepSize
;
};
...
...
@@ -988,7 +978,7 @@ private:
class
ReferenceIntegrateVariableLangevinStepKernel
:
public
IntegrateVariableLangevinStepKernel
{
public:
ReferenceIntegrateVariableLangevinStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateVariableLangevinStepKernel
(
name
,
platform
),
data
(
data
),
dynamics
(
0
)
,
constraints
(
0
)
{
data
(
data
),
dynamics
(
0
)
{
}
~
ReferenceIntegrateVariableLangevinStepKernel
();
/**
...
...
@@ -1017,9 +1007,7 @@ public:
private:
ReferencePlatform
::
PlatformData
&
data
;
ReferenceVariableStochasticDynamics
*
dynamics
;
ReferenceConstraintAlgorithm
*
constraints
;
std
::
vector
<
RealOpenMM
>
masses
;
int
numConstraints
;
double
prevTemp
,
prevFriction
,
prevErrorTol
;
};
...
...
@@ -1029,7 +1017,7 @@ private:
class
ReferenceIntegrateVariableVerletStepKernel
:
public
IntegrateVariableVerletStepKernel
{
public:
ReferenceIntegrateVariableVerletStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateVariableVerletStepKernel
(
name
,
platform
),
data
(
data
),
dynamics
(
0
)
,
constraints
(
0
)
{
data
(
data
),
dynamics
(
0
)
{
}
~
ReferenceIntegrateVariableVerletStepKernel
();
/**
...
...
@@ -1058,9 +1046,7 @@ public:
private:
ReferencePlatform
::
PlatformData
&
data
;
ReferenceVariableVerletDynamics
*
dynamics
;
ReferenceConstraintAlgorithm
*
constraints
;
std
::
vector
<
RealOpenMM
>
masses
;
int
numConstraints
;
double
prevErrorTol
;
};
...
...
@@ -1070,7 +1056,7 @@ private:
class
ReferenceIntegrateCustomStepKernel
:
public
IntegrateCustomStepKernel
{
public:
ReferenceIntegrateCustomStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
IntegrateCustomStepKernel
(
name
,
platform
),
data
(
data
),
dynamics
(
0
)
,
constraints
(
0
)
{
data
(
data
),
dynamics
(
0
)
{
}
~
ReferenceIntegrateCustomStepKernel
();
/**
...
...
@@ -1135,10 +1121,8 @@ public:
private:
ReferencePlatform
::
PlatformData
&
data
;
ReferenceCustomDynamics
*
dynamics
;
ReferenceConstraintAlgorithm
*
constraints
;
std
::
vector
<
RealOpenMM
>
masses
,
globalValues
;
std
::
vector
<
std
::
vector
<
OpenMM
::
RealVec
>
>
perDofValues
;
int
numConstraints
;
};
/**
...
...
platforms/reference/include/ReferenceLJCoulomb14.h
View file @
19d2885a
...
...
@@ -26,10 +26,11 @@
#define __ReferenceLJCoulomb14_H__
#include "ReferenceBondIxn.h"
#include "openmm/internal/windowsExport.h"
// ---------------------------------------------------------------------------------------
class
ReferenceLJCoulomb14
:
public
ReferenceBondIxn
{
class
OPENMM_EXPORT
ReferenceLJCoulomb14
:
public
ReferenceBondIxn
{
public:
...
...
platforms/reference/include/ReferencePME.h
View file @
19d2885a
...
...
@@ -30,6 +30,7 @@
*/
#include "SimTKOpenMMCommon.h"
#include "openmm/internal/windowsExport.h"
#include <vector>
typedef
RealOpenMM
rvec
[
3
];
...
...
@@ -52,7 +53,7 @@ pme_t;
* pme_order Interpolation order, almost always 4
* epsilon_r Dielectric coefficient, typically 1.0.
*/
int
int
OPENMM_EXPORT
pme_init
(
pme_t
*
ppme
,
RealOpenMM
ewaldcoeff
,
int
natoms
,
...
...
@@ -73,11 +74,11 @@ pme_init(pme_t * ppme,
* energy Total energy (will be written in units of kJ/mol)
* pme_virial Long-range part of the virial, output.
*/
int
int
OPENMM_EXPORT
pme_exec
(
pme_t
pme
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
const
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
charges
,
const
std
::
vector
<
RealOpenMM
>&
charges
,
const
RealOpenMM
periodicBoxSize
[
3
],
RealOpenMM
*
energy
,
RealOpenMM
pme_virial
[
3
][
3
]);
...
...
@@ -85,5 +86,5 @@ pme_exec(pme_t pme,
/* Release all memory in pme structure */
int
int
OPENMM_EXPORT
pme_destroy
(
pme_t
pme
);
platforms/reference/include/ReferencePlatform.h
View file @
19d2885a
...
...
@@ -33,6 +33,7 @@
* -------------------------------------------------------------------------- */
#include "openmm/Platform.h"
#include "openmm/System.h"
#include "openmm/internal/windowsExport.h"
namespace
OpenMM
{
...
...
@@ -57,7 +58,7 @@ public:
class
ReferencePlatform
::
PlatformData
{
public:
PlatformData
(
int
numParticles
);
PlatformData
(
const
System
&
system
);
~
PlatformData
();
int
numParticles
,
stepCount
;
double
time
;
...
...
@@ -65,6 +66,7 @@ public:
void
*
velocities
;
void
*
forces
;
void
*
periodicBoxSize
;
void
*
constraints
;
};
}
// namespace OpenMM
...
...
platforms/reference/include/ReferenceSETTLEAlgorithm.h
View file @
19d2885a
...
...
@@ -44,25 +44,32 @@ namespace OpenMM {
class
OPENMM_EXPORT
ReferenceSETTLEAlgorithm
:
public
ReferenceConstraintAlgorithm
{
public:
ReferenceSETTLEAlgorithm
(
const
std
::
vector
<
int
>&
atom1
,
const
std
::
vector
<
int
>&
atom2
,
const
std
::
vector
<
int
>&
atom3
,
const
std
::
vector
<
RealOpenMM
>&
distance1
,
const
std
::
vector
<
RealOpenMM
>&
distance2
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
tolerance
);
const
std
::
vector
<
RealOpenMM
>&
distance1
,
const
std
::
vector
<
RealOpenMM
>&
distance2
,
std
::
vector
<
RealOpenMM
>&
masses
);
/**
* Get the
constraint tolerance
.
* Get the
number of clusters
.
*/
RealOpenMM
getTolerance
()
const
;
int
getNumClusters
()
const
;
/**
* Set the constraint tolerance.
* Get the parameters describing one cluster.
*
* @param index the index of the cluster to get
* @param atom1 the index of the first atom in the cluster
* @param atom2 the index of the second atom in the cluster
* @param atom3 the index of the third atom in the cluster
* @param distance1 the distance between atoms 1 and 2
* @param distance2 the distance between atoms 2 and 3
*/
void
setTolerance
(
RealOpenMM
tolerance
);
void
getClusterParameters
(
int
index
,
int
&
atom1
,
int
&
atom2
,
int
&
atom3
,
RealOpenMM
&
distance1
,
RealOpenMM
&
distance2
)
const
;
/**
* Apply the constraint algorithm.
*
* @param atomCoordinates the original atom coordinates
* @param atomCoordinatesP the new atom coordinates
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
void
apply
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
);
void
apply
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinatesP
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
);
/**
* Apply the constraint algorithm to velocities.
...
...
@@ -70,10 +77,10 @@ public:
* @param atomCoordinates the atom coordinates
* @param atomCoordinatesP the velocities to modify
* @param inverseMasses 1/mass
* @param tolerance the constraint tolerance
*/
void
applyToVelocities
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
);
void
applyToVelocities
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
tolerance
);
private:
RealOpenMM
tolerance
;
std
::
vector
<
int
>
atom1
;
std
::
vector
<
int
>
atom2
;
std
::
vector
<
int
>
atom3
;
...
...
platforms/reference/include/ReferenceStochasticDynamics.h
View file @
19d2885a
...
...
@@ -26,12 +26,13 @@
#define __ReferenceStochasticDynamics_H__
#include "ReferenceDynamics.h"
#include "openmm/internal/windowsExport.h"
// ---------------------------------------------------------------------------------------
class
ReferenceStochasticDynamics
:
public
ReferenceDynamics
{
class
OPENMM_EXPORT
ReferenceStochasticDynamics
:
public
ReferenceDynamics
{
pr
ivate
:
pr
otected
:
std
::
vector
<
OpenMM
::
RealVec
>
xPrime
;
std
::
vector
<
RealOpenMM
>
inverseMasses
;
...
...
@@ -79,11 +80,12 @@ class ReferenceStochasticDynamics : public ReferenceDynamics {
@param velocities velocities
@param forces forces
@param masses atom masses
@param tolerance the constraint tolerance
--------------------------------------------------------------------------------------- */
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
tolerance
);
/**---------------------------------------------------------------------------------------
...
...
@@ -98,7 +100,7 @@ class ReferenceStochasticDynamics : public ReferenceDynamics {
--------------------------------------------------------------------------------------- */
void
updatePart1
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
virtual
void
updatePart1
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
std
::
vector
<
OpenMM
::
RealVec
>&
xPrime
);
/**---------------------------------------------------------------------------------------
...
...
@@ -113,7 +115,7 @@ class ReferenceStochasticDynamics : public ReferenceDynamics {
--------------------------------------------------------------------------------------- */
void
updatePart2
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
virtual
void
updatePart2
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
std
::
vector
<
OpenMM
::
RealVec
>&
xPrime
);
};
...
...
platforms/reference/include/ReferenceVariableStochasticDynamics.h
View file @
19d2885a
...
...
@@ -98,11 +98,12 @@ class ReferenceVariableStochasticDynamics : public ReferenceDynamics {
@param forces forces
@param masses atom masses
@param maxStepSize maximum time step
@param tolerance the constraint tolerance
--------------------------------------------------------------------------------------- */
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
maxStepSize
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
maxStepSize
,
RealOpenMM
tolerance
);
/**---------------------------------------------------------------------------------------
...
...
platforms/reference/include/ReferenceVariableVerletDynamics.h
View file @
19d2885a
...
...
@@ -86,11 +86,12 @@ class ReferenceVariableVerletDynamics : public ReferenceDynamics {
@param forces forces
@param masses atom masses
@param maxStepSize maximum time step
@param tolerance the constraint tolerance
--------------------------------------------------------------------------------------- */
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
maxStepSize
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
maxStepSize
,
RealOpenMM
tolerance
);
};
...
...
platforms/reference/include/ReferenceVerletDynamics.h
View file @
19d2885a
...
...
@@ -68,11 +68,12 @@ class ReferenceVerletDynamics : public ReferenceDynamics {
@param velocities velocities
@param forces forces
@param masses atom masses
@param tolerance the constraint tolerance
--------------------------------------------------------------------------------------- */
void
update
(
const
OpenMM
::
System
&
system
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
tolerance
);
};
...
...
platforms/reference/src/ReferenceKernels.cpp
View file @
19d2885a
...
...
@@ -133,11 +133,16 @@ static RealVec& extractBoxSize(ContextImpl& context) {
return
*
(
RealVec
*
)
data
->
periodicBoxSize
;
}
static
ReferenceConstraints
&
extractConstraints
(
ContextImpl
&
context
)
{
ReferencePlatform
::
PlatformData
*
data
=
reinterpret_cast
<
ReferencePlatform
::
PlatformData
*>
(
context
.
getPlatformData
());
return
*
(
ReferenceConstraints
*
)
data
->
constraints
;
}
/**
* Compute the kinetic energy of the system, possibly shifting the velocities in time to account
* for a leapfrog integrator.
*/
static
double
computeShiftedKineticEnergy
(
ContextImpl
&
context
,
vector
<
double
>&
masses
,
double
timeShift
,
ReferenceConstraintAlgorithm
*
constraints
)
{
static
double
computeShiftedKineticEnergy
(
ContextImpl
&
context
,
vector
<
double
>&
masses
,
double
timeShift
)
{
vector
<
RealVec
>&
posData
=
extractPositions
(
context
);
vector
<
RealVec
>&
velData
=
extractVelocities
(
context
);
vector
<
RealVec
>&
forceData
=
extractForces
(
context
);
...
...
@@ -155,13 +160,10 @@ static double computeShiftedKineticEnergy(ContextImpl& context, vector<double>&
// Apply constraints to them.
if
(
constraints
!=
NULL
)
{
vector
<
double
>
inverseMasses
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
inverseMasses
[
i
]
=
(
masses
[
i
]
==
0
?
0
:
1
/
masses
[
i
]);
constraints
->
setTolerance
(
1e-4
);
constraints
->
applyToVelocities
(
posData
,
shiftedVel
,
inverseMasses
);
}
vector
<
double
>
inverseMasses
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
inverseMasses
[
i
]
=
(
masses
[
i
]
==
0
?
0
:
1
/
masses
[
i
]);
extractConstraints
(
context
).
applyToVelocities
(
posData
,
shiftedVel
,
inverseMasses
,
1e-4
);
// Compute the kinetic energy.
...
...
@@ -302,39 +304,21 @@ void ReferenceApplyConstraintsKernel::initialize(const System& system) {
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
inverseMasses
[
i
]
=
1.0
/
masses
[
i
];
}
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
++
i
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
if
(
system
.
getParticleMass
(
particle1
)
!=
0
||
system
.
getParticleMass
(
particle2
)
!=
0
)
{
constraintIndices
.
push_back
(
make_pair
(
particle1
,
particle2
));
constraintDistances
.
push_back
(
distance
);
}
}
numConstraints
=
constraintIndices
.
size
();
}
ReferenceApplyConstraintsKernel
::~
ReferenceApplyConstraintsKernel
()
{
if
(
constraints
)
delete
constraints
;
}
void
ReferenceApplyConstraintsKernel
::
apply
(
ContextImpl
&
context
,
double
tol
)
{
if
(
constraints
==
NULL
)
constraints
=
new
ReferenceConstraints
(
context
.
getSystem
(),
(
RealOpenMM
)
tol
);
vector
<
RealVec
>&
positions
=
extractPositions
(
context
);
constraints
->
setTolerance
(
tol
);
constraints
->
apply
(
positions
,
positions
,
inverseMasses
);
extractConstraints
(
context
).
apply
(
positions
,
positions
,
inverseMasses
,
tol
);
ReferenceVirtualSites
::
computePositions
(
context
.
getSystem
(),
positions
);
}
void
ReferenceApplyConstraintsKernel
::
applyToVelocities
(
ContextImpl
&
context
,
double
tol
)
{
if
(
constraints
==
NULL
)
constraints
=
new
ReferenceConstraints
(
context
.
getSystem
(),
(
RealOpenMM
)
tol
);
vector
<
RealVec
>&
positions
=
extractPositions
(
context
);
vector
<
RealVec
>&
velocities
=
extractVelocities
(
context
);
constraints
->
setTolerance
(
tol
);
constraints
->
applyToVelocities
(
positions
,
velocities
,
inverseMasses
);
extractConstraints
(
context
).
applyToVelocities
(
positions
,
velocities
,
inverseMasses
,
tol
);
}
void
ReferenceVirtualSitesKernel
::
initialize
(
const
System
&
system
)
{
...
...
@@ -1686,8 +1670,6 @@ void ReferenceCalcCustomCompoundBondForceKernel::copyParametersToContext(Context
ReferenceIntegrateVerletStepKernel
::~
ReferenceIntegrateVerletStepKernel
()
{
if
(
dynamics
)
delete
dynamics
;
if
(
constraints
)
delete
constraints
;
}
void
ReferenceIntegrateVerletStepKernel
::
initialize
(
const
System
&
system
,
const
VerletIntegrator
&
integrator
)
{
...
...
@@ -1695,19 +1677,6 @@ void ReferenceIntegrateVerletStepKernel::initialize(const System& system, const
masses
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
vector
<
pair
<
int
,
int
>
>
constraintIndices
;
vector
<
RealOpenMM
>
constraintDistances
;
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
++
i
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
if
(
system
.
getParticleMass
(
particle1
)
!=
0
||
system
.
getParticleMass
(
particle2
)
!=
0
)
{
constraintIndices
.
push_back
(
make_pair
(
particle1
,
particle2
));
constraintDistances
.
push_back
(
distance
);
}
}
numConstraints
=
constraintIndices
.
size
();
constraints
=
new
ReferenceConstraints
(
system
,
(
RealOpenMM
)
integrator
.
getConstraintTolerance
());
}
void
ReferenceIntegrateVerletStepKernel
::
execute
(
ContextImpl
&
context
,
const
VerletIntegrator
&
integrator
)
{
...
...
@@ -1721,24 +1690,21 @@ void ReferenceIntegrateVerletStepKernel::execute(ContextImpl& context, const Ver
if
(
dynamics
)
delete
dynamics
;
dynamics
=
new
ReferenceVerletDynamics
(
context
.
getSystem
().
getNumParticles
(),
static_cast
<
RealOpenMM
>
(
stepSize
)
);
dynamics
->
setReferenceConstraintAlgorithm
(
c
onstraints
);
dynamics
->
setReferenceConstraintAlgorithm
(
&
extractC
onstraints
(
context
)
);
prevStepSize
=
stepSize
;
}
constraints
->
setTolerance
(
integrator
.
getConstraintTolerance
());
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
);
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
,
integrator
.
getConstraintTolerance
());
data
.
time
+=
stepSize
;
data
.
stepCount
++
;
}
double
ReferenceIntegrateVerletStepKernel
::
computeKineticEnergy
(
ContextImpl
&
context
,
const
VerletIntegrator
&
integrator
)
{
return
computeShiftedKineticEnergy
(
context
,
masses
,
0.5
*
integrator
.
getStepSize
()
,
constraints
);
return
computeShiftedKineticEnergy
(
context
,
masses
,
0.5
*
integrator
.
getStepSize
());
}
ReferenceIntegrateLangevinStepKernel
::~
ReferenceIntegrateLangevinStepKernel
()
{
if
(
dynamics
)
delete
dynamics
;
if
(
constraints
)
delete
constraints
;
}
void
ReferenceIntegrateLangevinStepKernel
::
initialize
(
const
System
&
system
,
const
LangevinIntegrator
&
integrator
)
{
...
...
@@ -1746,20 +1712,7 @@ void ReferenceIntegrateLangevinStepKernel::initialize(const System& system, cons
masses
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
vector
<
pair
<
int
,
int
>
>
constraintIndices
;
vector
<
RealOpenMM
>
constraintDistances
;
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
++
i
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
if
(
system
.
getParticleMass
(
particle1
)
!=
0
||
system
.
getParticleMass
(
particle2
)
!=
0
)
{
constraintIndices
.
push_back
(
make_pair
(
particle1
,
particle2
));
constraintDistances
.
push_back
(
distance
);
}
}
numConstraints
=
constraintIndices
.
size
();
SimTKOpenMMUtilities
::
setRandomNumberSeed
((
unsigned
int
)
integrator
.
getRandomNumberSeed
());
constraints
=
new
ReferenceConstraints
(
system
,
(
RealOpenMM
)
integrator
.
getConstraintTolerance
());
}
void
ReferenceIntegrateLangevinStepKernel
::
execute
(
ContextImpl
&
context
,
const
LangevinIntegrator
&
integrator
)
{
...
...
@@ -1780,26 +1733,23 @@ void ReferenceIntegrateLangevinStepKernel::execute(ContextImpl& context, const L
static_cast
<
RealOpenMM
>
(
stepSize
),
static_cast
<
RealOpenMM
>
(
tau
),
static_cast
<
RealOpenMM
>
(
temperature
)
);
dynamics
->
setReferenceConstraintAlgorithm
(
c
onstraints
);
dynamics
->
setReferenceConstraintAlgorithm
(
&
extractC
onstraints
(
context
)
);
prevTemp
=
temperature
;
prevFriction
=
friction
;
prevStepSize
=
stepSize
;
}
constraints
->
setTolerance
(
integrator
.
getConstraintTolerance
());
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
);
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
,
integrator
.
getConstraintTolerance
());
data
.
time
+=
stepSize
;
data
.
stepCount
++
;
}
double
ReferenceIntegrateLangevinStepKernel
::
computeKineticEnergy
(
ContextImpl
&
context
,
const
LangevinIntegrator
&
integrator
)
{
return
computeShiftedKineticEnergy
(
context
,
masses
,
0.5
*
integrator
.
getStepSize
()
,
constraints
);
return
computeShiftedKineticEnergy
(
context
,
masses
,
0.5
*
integrator
.
getStepSize
());
}
ReferenceIntegrateBrownianStepKernel
::~
ReferenceIntegrateBrownianStepKernel
()
{
if
(
dynamics
)
delete
dynamics
;
if
(
constraints
)
delete
constraints
;
}
void
ReferenceIntegrateBrownianStepKernel
::
initialize
(
const
System
&
system
,
const
BrownianIntegrator
&
integrator
)
{
...
...
@@ -1807,20 +1757,7 @@ void ReferenceIntegrateBrownianStepKernel::initialize(const System& system, cons
masses
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
vector
<
pair
<
int
,
int
>
>
constraintIndices
;
vector
<
RealOpenMM
>
constraintDistances
;
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
++
i
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
if
(
system
.
getParticleMass
(
particle1
)
!=
0
||
system
.
getParticleMass
(
particle2
)
!=
0
)
{
constraintIndices
.
push_back
(
make_pair
(
particle1
,
particle2
));
constraintDistances
.
push_back
(
distance
);
}
}
numConstraints
=
constraintIndices
.
size
();
SimTKOpenMMUtilities
::
setRandomNumberSeed
((
unsigned
int
)
integrator
.
getRandomNumberSeed
());
constraints
=
new
ReferenceConstraints
(
system
,
(
RealOpenMM
)
integrator
.
getConstraintTolerance
());
}
void
ReferenceIntegrateBrownianStepKernel
::
execute
(
ContextImpl
&
context
,
const
BrownianIntegrator
&
integrator
)
{
...
...
@@ -1840,26 +1777,23 @@ void ReferenceIntegrateBrownianStepKernel::execute(ContextImpl& context, const B
static_cast
<
RealOpenMM
>
(
stepSize
),
static_cast
<
RealOpenMM
>
(
friction
),
static_cast
<
RealOpenMM
>
(
temperature
)
);
dynamics
->
setReferenceConstraintAlgorithm
(
c
onstraints
);
dynamics
->
setReferenceConstraintAlgorithm
(
&
extractC
onstraints
(
context
)
);
prevTemp
=
temperature
;
prevFriction
=
friction
;
prevStepSize
=
stepSize
;
}
constraints
->
setTolerance
(
integrator
.
getConstraintTolerance
());
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
);
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
,
integrator
.
getConstraintTolerance
());
data
.
time
+=
stepSize
;
data
.
stepCount
++
;
}
double
ReferenceIntegrateBrownianStepKernel
::
computeKineticEnergy
(
ContextImpl
&
context
,
const
BrownianIntegrator
&
integrator
)
{
return
computeShiftedKineticEnergy
(
context
,
masses
,
0
,
constraints
);
return
computeShiftedKineticEnergy
(
context
,
masses
,
0
);
}
ReferenceIntegrateVariableLangevinStepKernel
::~
ReferenceIntegrateVariableLangevinStepKernel
()
{
if
(
dynamics
)
delete
dynamics
;
if
(
constraints
)
delete
constraints
;
}
void
ReferenceIntegrateVariableLangevinStepKernel
::
initialize
(
const
System
&
system
,
const
VariableLangevinIntegrator
&
integrator
)
{
...
...
@@ -1867,20 +1801,7 @@ void ReferenceIntegrateVariableLangevinStepKernel::initialize(const System& syst
masses
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
vector
<
pair
<
int
,
int
>
>
constraintIndices
;
vector
<
RealOpenMM
>
constraintDistances
;
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
++
i
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
if
(
system
.
getParticleMass
(
particle1
)
!=
0
||
system
.
getParticleMass
(
particle2
)
!=
0
)
{
constraintIndices
.
push_back
(
make_pair
(
particle1
,
particle2
));
constraintDistances
.
push_back
(
distance
);
}
}
numConstraints
=
constraintIndices
.
size
();
SimTKOpenMMUtilities
::
setRandomNumberSeed
((
unsigned
int
)
integrator
.
getRandomNumberSeed
());
constraints
=
new
ReferenceConstraints
(
system
,
(
RealOpenMM
)
integrator
.
getConstraintTolerance
());
}
double
ReferenceIntegrateVariableLangevinStepKernel
::
execute
(
ContextImpl
&
context
,
const
VariableLangevinIntegrator
&
integrator
,
double
maxTime
)
{
...
...
@@ -1897,14 +1818,13 @@ double ReferenceIntegrateVariableLangevinStepKernel::execute(ContextImpl& contex
delete
dynamics
;
RealOpenMM
tau
=
static_cast
<
RealOpenMM
>
(
friction
==
0.0
?
0.0
:
1.0
/
friction
);
dynamics
=
new
ReferenceVariableStochasticDynamics
(
context
.
getSystem
().
getNumParticles
(),
(
RealOpenMM
)
tau
,
(
RealOpenMM
)
temperature
,
(
RealOpenMM
)
errorTol
);
dynamics
->
setReferenceConstraintAlgorithm
(
c
onstraints
);
dynamics
->
setReferenceConstraintAlgorithm
(
&
extractC
onstraints
(
context
)
);
prevTemp
=
temperature
;
prevFriction
=
friction
;
prevErrorTol
=
errorTol
;
}
constraints
->
setTolerance
(
integrator
.
getConstraintTolerance
());
RealOpenMM
maxStepSize
=
(
RealOpenMM
)
(
maxTime
-
data
.
time
);
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
,
maxStepSize
);
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
,
maxStepSize
,
integrator
.
getConstraintTolerance
()
);
data
.
time
+=
dynamics
->
getDeltaT
();
if
(
dynamics
->
getDeltaT
()
==
maxStepSize
)
data
.
time
=
maxTime
;
// Avoid round-off error
...
...
@@ -1913,14 +1833,12 @@ double ReferenceIntegrateVariableLangevinStepKernel::execute(ContextImpl& contex
}
double
ReferenceIntegrateVariableLangevinStepKernel
::
computeKineticEnergy
(
ContextImpl
&
context
,
const
VariableLangevinIntegrator
&
integrator
)
{
return
computeShiftedKineticEnergy
(
context
,
masses
,
0.5
*
integrator
.
getStepSize
()
,
constraints
);
return
computeShiftedKineticEnergy
(
context
,
masses
,
0.5
*
integrator
.
getStepSize
());
}
ReferenceIntegrateVariableVerletStepKernel
::~
ReferenceIntegrateVariableVerletStepKernel
()
{
if
(
dynamics
)
delete
dynamics
;
if
(
constraints
)
delete
constraints
;
}
void
ReferenceIntegrateVariableVerletStepKernel
::
initialize
(
const
System
&
system
,
const
VariableVerletIntegrator
&
integrator
)
{
...
...
@@ -1928,19 +1846,6 @@ void ReferenceIntegrateVariableVerletStepKernel::initialize(const System& system
masses
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
vector
<
pair
<
int
,
int
>
>
constraintIndices
;
vector
<
RealOpenMM
>
constraintDistances
;
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
++
i
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
if
(
system
.
getParticleMass
(
particle1
)
!=
0
||
system
.
getParticleMass
(
particle2
)
!=
0
)
{
constraintIndices
.
push_back
(
make_pair
(
particle1
,
particle2
));
constraintDistances
.
push_back
(
distance
);
}
}
numConstraints
=
constraintIndices
.
size
();
constraints
=
new
ReferenceConstraints
(
system
,
(
RealOpenMM
)
integrator
.
getConstraintTolerance
());
}
double
ReferenceIntegrateVariableVerletStepKernel
::
execute
(
ContextImpl
&
context
,
const
VariableVerletIntegrator
&
integrator
,
double
maxTime
)
{
...
...
@@ -1954,12 +1859,11 @@ double ReferenceIntegrateVariableVerletStepKernel::execute(ContextImpl& context,
if
(
dynamics
)
delete
dynamics
;
dynamics
=
new
ReferenceVariableVerletDynamics
(
context
.
getSystem
().
getNumParticles
(),
(
RealOpenMM
)
errorTol
);
dynamics
->
setReferenceConstraintAlgorithm
(
c
onstraints
);
dynamics
->
setReferenceConstraintAlgorithm
(
&
extractC
onstraints
(
context
)
);
prevErrorTol
=
errorTol
;
}
constraints
->
setTolerance
(
integrator
.
getConstraintTolerance
());
RealOpenMM
maxStepSize
=
(
RealOpenMM
)
(
maxTime
-
data
.
time
);
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
,
maxStepSize
);
dynamics
->
update
(
context
.
getSystem
(),
posData
,
velData
,
forceData
,
masses
,
maxStepSize
,
integrator
.
getConstraintTolerance
()
);
data
.
time
+=
dynamics
->
getDeltaT
();
if
(
dynamics
->
getDeltaT
()
==
maxStepSize
)
data
.
time
=
maxTime
;
// Avoid round-off error
...
...
@@ -1968,14 +1872,12 @@ double ReferenceIntegrateVariableVerletStepKernel::execute(ContextImpl& context,
}
double
ReferenceIntegrateVariableVerletStepKernel
::
computeKineticEnergy
(
ContextImpl
&
context
,
const
VariableVerletIntegrator
&
integrator
)
{
return
computeShiftedKineticEnergy
(
context
,
masses
,
0.5
*
integrator
.
getStepSize
()
,
constraints
);
return
computeShiftedKineticEnergy
(
context
,
masses
,
0.5
*
integrator
.
getStepSize
());
}
ReferenceIntegrateCustomStepKernel
::~
ReferenceIntegrateCustomStepKernel
()
{
if
(
dynamics
)
delete
dynamics
;
if
(
constraints
)
delete
constraints
;
}
void
ReferenceIntegrateCustomStepKernel
::
initialize
(
const
System
&
system
,
const
CustomIntegrator
&
integrator
)
{
...
...
@@ -1983,18 +1885,6 @@ void ReferenceIntegrateCustomStepKernel::initialize(const System& system, const
masses
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
masses
[
i
]
=
static_cast
<
RealOpenMM
>
(
system
.
getParticleMass
(
i
));
vector
<
pair
<
int
,
int
>
>
constraintIndices
;
vector
<
RealOpenMM
>
constraintDistances
;
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
++
i
)
{
int
particle1
,
particle2
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
if
(
system
.
getParticleMass
(
particle1
)
!=
0
||
system
.
getParticleMass
(
particle2
)
!=
0
)
{
constraintIndices
.
push_back
(
make_pair
(
particle1
,
particle2
));
constraintDistances
.
push_back
(
distance
);
}
}
numConstraints
=
constraintIndices
.
size
();
perDofValues
.
resize
(
integrator
.
getNumPerDofVariables
());
for
(
int
i
=
0
;
i
<
(
int
)
perDofValues
.
size
();
i
++
)
perDofValues
[
i
].
resize
(
numParticles
);
...
...
@@ -2003,8 +1893,6 @@ void ReferenceIntegrateCustomStepKernel::initialize(const System& system, const
dynamics
=
new
ReferenceCustomDynamics
(
system
.
getNumParticles
(),
integrator
);
SimTKOpenMMUtilities
::
setRandomNumberSeed
((
unsigned
int
)
integrator
.
getRandomNumberSeed
());
constraints
=
new
ReferenceConstraints
(
system
,
(
RealOpenMM
)
integrator
.
getConstraintTolerance
());
dynamics
->
setReferenceConstraintAlgorithm
(
constraints
);
}
void
ReferenceIntegrateCustomStepKernel
::
execute
(
ContextImpl
&
context
,
CustomIntegrator
&
integrator
,
bool
&
forcesAreValid
)
{
...
...
@@ -2021,8 +1909,8 @@ void ReferenceIntegrateCustomStepKernel::execute(ContextImpl& context, CustomInt
// Execute the step.
constraint
s
->
set
Tol
er
a
nce
(
integrator
.
ge
tConstraint
Tolerance
(
));
dynamics
->
update
(
context
,
context
.
getSystem
().
getNumParticles
(),
posData
,
velData
,
forceData
,
masses
,
globals
,
perDofValues
,
forcesAreValid
);
dynamic
s
->
set
Ref
er
e
nce
ConstraintAlgorithm
(
&
extrac
tConstraint
s
(
context
));
dynamics
->
update
(
context
,
context
.
getSystem
().
getNumParticles
(),
posData
,
velData
,
forceData
,
masses
,
globals
,
perDofValues
,
forcesAreValid
,
integrator
.
getConstraintTolerance
()
);
// Record changed global variables.
...
...
platforms/reference/src/ReferencePlatform.cpp
View file @
19d2885a
...
...
@@ -30,6 +30,7 @@
* -------------------------------------------------------------------------- */
#include "ReferencePlatform.h"
#include "ReferenceConstraints.h"
#include "ReferenceKernelFactory.h"
#include "ReferenceKernels.h"
#include "openmm/internal/ContextImpl.h"
...
...
@@ -82,7 +83,7 @@ bool ReferencePlatform::supportsDoublePrecision() const {
}
void
ReferencePlatform
::
contextCreated
(
ContextImpl
&
context
,
const
map
<
string
,
string
>&
properties
)
const
{
context
.
setPlatformData
(
new
PlatformData
(
context
.
getSystem
()
.
getNumParticles
()
));
context
.
setPlatformData
(
new
PlatformData
(
context
.
getSystem
()));
}
void
ReferencePlatform
::
contextDestroyed
(
ContextImpl
&
context
)
const
{
...
...
@@ -90,11 +91,12 @@ void ReferencePlatform::contextDestroyed(ContextImpl& context) const {
delete
data
;
}
ReferencePlatform
::
PlatformData
::
PlatformData
(
int
numParticles
)
:
time
(
0.0
),
stepCount
(
0
),
numParticles
(
n
umParticles
)
{
ReferencePlatform
::
PlatformData
::
PlatformData
(
const
System
&
system
)
:
time
(
0.0
),
stepCount
(
0
),
numParticles
(
system
.
getN
umParticles
()
)
{
positions
=
new
vector
<
RealVec
>
(
numParticles
);
velocities
=
new
vector
<
RealVec
>
(
numParticles
);
forces
=
new
vector
<
RealVec
>
(
numParticles
);
periodicBoxSize
=
new
RealVec
();
constraints
=
new
ReferenceConstraints
(
system
);
}
ReferencePlatform
::
PlatformData
::~
PlatformData
()
{
...
...
@@ -102,4 +104,5 @@ ReferencePlatform::PlatformData::~PlatformData() {
delete
(
vector
<
RealVec
>*
)
velocities
;
delete
(
vector
<
RealVec
>*
)
forces
;
delete
(
RealVec
*
)
periodicBoxSize
;
delete
(
ReferenceConstraints
*
)
constraints
;
}
platforms/reference/src/SimTKReference/ReferenceAndersenThermostat.cpp
View file @
19d2885a
...
...
@@ -72,10 +72,12 @@ using OpenMM::RealVec;
for
(
int
j
=
0
;
j
<
(
int
)
atomGroups
[
i
].
size
();
j
++
)
{
int
atom
=
atomGroups
[
i
][
j
];
const
RealOpenMM
velocityScale
=
static_cast
<
RealOpenMM
>
(
sqrt
(
BOLTZ
*
temperature
/
atomMasses
[
atom
]));
atomVelocities
[
atom
][
0
]
=
velocityScale
*
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
();
atomVelocities
[
atom
][
1
]
=
velocityScale
*
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
();
atomVelocities
[
atom
][
2
]
=
velocityScale
*
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
();
if
(
atomMasses
[
atom
]
!=
0
)
{
const
RealOpenMM
velocityScale
=
static_cast
<
RealOpenMM
>
(
sqrt
(
BOLTZ
*
temperature
/
atomMasses
[
atom
]));
atomVelocities
[
atom
][
0
]
=
velocityScale
*
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
();
atomVelocities
[
atom
][
1
]
=
velocityScale
*
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
();
atomVelocities
[
atom
][
2
]
=
velocityScale
*
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
();
}
}
}
}
...
...
Prev
1
…
4
5
6
7
8
9
10
11
12
…
16
Next
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