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
dca54ec7
Commit
dca54ec7
authored
Jun 30, 2016
by
Saurabh Belsare
Browse files
Merged fork with latest original master
parents
cace5edf
01f9e415
Changes
384
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
369 additions
and
207 deletions
+369
-207
platforms/reference/src/SimTKReference/ReferenceCustomCentroidBondIxn.cpp
...nce/src/SimTKReference/ReferenceCustomCentroidBondIxn.cpp
+13
-3
platforms/reference/src/SimTKReference/ReferenceCustomCompoundBondIxn.cpp
...nce/src/SimTKReference/ReferenceCustomCompoundBondIxn.cpp
+13
-3
platforms/reference/src/SimTKReference/ReferenceCustomDynamics.cpp
.../reference/src/SimTKReference/ReferenceCustomDynamics.cpp
+116
-89
platforms/reference/src/SimTKReference/ReferenceCustomTorsionIxn.cpp
...eference/src/SimTKReference/ReferenceCustomTorsionIxn.cpp
+18
-11
platforms/reference/src/SimTKReference/ReferenceForce.cpp
platforms/reference/src/SimTKReference/ReferenceForce.cpp
+13
-0
platforms/reference/src/SimTKReference/ReferenceHarmonicBondIxn.cpp
...reference/src/SimTKReference/ReferenceHarmonicBondIxn.cpp
+12
-16
platforms/reference/src/SimTKReference/ReferenceLJCoulombIxn.cpp
...ms/reference/src/SimTKReference/ReferenceLJCoulombIxn.cpp
+9
-5
platforms/reference/src/SimTKReference/ReferenceProperDihedralBond.cpp
...erence/src/SimTKReference/ReferenceProperDihedralBond.cpp
+18
-18
platforms/reference/src/SimTKReference/ReferenceRbDihedralBond.cpp
.../reference/src/SimTKReference/ReferenceRbDihedralBond.cpp
+18
-18
platforms/reference/src/SimTKReference/SimTKOpenMMUtilities.cpp
...rms/reference/src/SimTKReference/SimTKOpenMMUtilities.cpp
+3
-0
platforms/reference/tests/TestReferenceCheckpoints.cpp
platforms/reference/tests/TestReferenceCheckpoints.cpp
+9
-0
platforms/reference/tests/TestReferenceMonteCarloMembraneBarostat.cpp
...ference/tests/TestReferenceMonteCarloMembraneBarostat.cpp
+2
-2
plugins/amoeba/openmmapi/include/openmm/AmoebaAngleForce.h
plugins/amoeba/openmmapi/include/openmm/AmoebaAngleForce.h
+9
-5
plugins/amoeba/openmmapi/include/openmm/AmoebaBondForce.h
plugins/amoeba/openmmapi/include/openmm/AmoebaBondForce.h
+9
-5
plugins/amoeba/openmmapi/include/openmm/AmoebaInPlaneAngleForce.h
...amoeba/openmmapi/include/openmm/AmoebaInPlaneAngleForce.h
+9
-5
plugins/amoeba/openmmapi/include/openmm/AmoebaMultipoleForce.h
...ns/amoeba/openmmapi/include/openmm/AmoebaMultipoleForce.h
+62
-7
plugins/amoeba/openmmapi/include/openmm/AmoebaOutOfPlaneBendForce.h
...oeba/openmmapi/include/openmm/AmoebaOutOfPlaneBendForce.h
+9
-5
plugins/amoeba/openmmapi/include/openmm/AmoebaPiTorsionForce.h
...ns/amoeba/openmmapi/include/openmm/AmoebaPiTorsionForce.h
+9
-5
plugins/amoeba/openmmapi/include/openmm/AmoebaStretchBendForce.h
.../amoeba/openmmapi/include/openmm/AmoebaStretchBendForce.h
+9
-5
plugins/amoeba/openmmapi/include/openmm/AmoebaTorsionTorsionForce.h
...oeba/openmmapi/include/openmm/AmoebaTorsionTorsionForce.h
+9
-5
No files found.
platforms/reference/src/SimTKReference/ReferenceCustomCentroidBondIxn.cpp
View file @
dca54ec7
/* Portions copyright (c) 2009-201
5
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -41,7 +41,7 @@ ReferenceCustomCentroidBondIxn::ReferenceCustomCentroidBondIxn(int numGroupsPerB
const
vector
<
vector
<
double
>
>&
normalizedWeights
,
const
vector
<
vector
<
int
>
>&
bondGroups
,
const
Lepton
::
ParsedExpression
&
energyExpression
,
const
vector
<
string
>&
bondParameterNames
,
const
map
<
string
,
vector
<
int
>
>&
distances
,
const
map
<
string
,
vector
<
int
>
>&
angles
,
const
map
<
string
,
vector
<
int
>
>&
dihedrals
)
:
groupAtoms
(
groupAtoms
),
normalizedWeights
(
normalizedWeights
),
bondGroups
(
bondGroups
),
energyExpression
(
energyExpression
.
createProgram
()),
bondParamNames
(
bondParameterNames
)
{
groupAtoms
(
groupAtoms
),
normalizedWeights
(
normalizedWeights
),
bondGroups
(
bondGroups
),
energyExpression
(
energyExpression
.
createProgram
()),
bondParamNames
(
bondParameterNames
)
,
usePeriodic
(
false
)
{
for
(
int
i
=
0
;
i
<
numGroupsPerBond
;
i
++
)
{
stringstream
xname
,
yname
,
zname
;
xname
<<
'x'
<<
(
i
+
1
);
...
...
@@ -62,6 +62,13 @@ ReferenceCustomCentroidBondIxn::ReferenceCustomCentroidBondIxn(int numGroupsPerB
ReferenceCustomCentroidBondIxn
::~
ReferenceCustomCentroidBondIxn
()
{
}
void
ReferenceCustomCentroidBondIxn
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
void
ReferenceCustomCentroidBondIxn
::
calculatePairIxn
(
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
**
bondParameters
,
const
map
<
string
,
double
>&
globalParameters
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
{
...
...
@@ -215,7 +222,10 @@ void ReferenceCustomCentroidBondIxn::calculateOneIxn(int bond, vector<RealVec>&
}
void
ReferenceCustomCentroidBondIxn
::
computeDelta
(
int
group1
,
int
group2
,
RealOpenMM
*
delta
,
vector
<
RealVec
>&
groupCenters
)
const
{
ReferenceForce
::
getDeltaR
(
groupCenters
[
group1
],
groupCenters
[
group2
],
delta
);
if
(
usePeriodic
)
ReferenceForce
::
getDeltaRPeriodic
(
groupCenters
[
group1
],
groupCenters
[
group2
],
boxVectors
,
delta
);
else
ReferenceForce
::
getDeltaR
(
groupCenters
[
group1
],
groupCenters
[
group2
],
delta
);
}
RealOpenMM
ReferenceCustomCentroidBondIxn
::
computeAngle
(
RealOpenMM
*
vec1
,
RealOpenMM
*
vec2
)
{
...
...
platforms/reference/src/SimTKReference/ReferenceCustomCompoundBondIxn.cpp
View file @
dca54ec7
/* Portions copyright (c) 2009-201
5
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -46,7 +46,7 @@ using namespace OpenMM;
ReferenceCustomCompoundBondIxn
::
ReferenceCustomCompoundBondIxn
(
int
numParticlesPerBond
,
const
vector
<
vector
<
int
>
>&
bondAtoms
,
const
Lepton
::
ParsedExpression
&
energyExpression
,
const
vector
<
string
>&
bondParameterNames
,
const
map
<
string
,
vector
<
int
>
>&
distances
,
const
map
<
string
,
vector
<
int
>
>&
angles
,
const
map
<
string
,
vector
<
int
>
>&
dihedrals
)
:
bondAtoms
(
bondAtoms
),
energyExpression
(
energyExpression
.
createProgram
()),
bondParamNames
(
bondParameterNames
)
{
bondAtoms
(
bondAtoms
),
energyExpression
(
energyExpression
.
createProgram
()),
bondParamNames
(
bondParameterNames
)
,
usePeriodic
(
false
)
{
for
(
int
i
=
0
;
i
<
numParticlesPerBond
;
i
++
)
{
stringstream
xname
,
yname
,
zname
;
xname
<<
'x'
<<
(
i
+
1
);
...
...
@@ -73,6 +73,13 @@ ReferenceCustomCompoundBondIxn::ReferenceCustomCompoundBondIxn(int numParticlesP
ReferenceCustomCompoundBondIxn
::~
ReferenceCustomCompoundBondIxn
()
{
}
void
ReferenceCustomCompoundBondIxn
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
Calculate custom hbond interaction
...
...
@@ -232,7 +239,10 @@ void ReferenceCustomCompoundBondIxn::calculateOneIxn(int bond, vector<RealVec>&
}
void
ReferenceCustomCompoundBondIxn
::
computeDelta
(
int
atom1
,
int
atom2
,
RealOpenMM
*
delta
,
vector
<
RealVec
>&
atomCoordinates
)
const
{
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atom1
],
atomCoordinates
[
atom2
],
delta
);
if
(
usePeriodic
)
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atom1
],
atomCoordinates
[
atom2
],
boxVectors
,
delta
);
else
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atom1
],
atomCoordinates
[
atom2
],
delta
);
}
RealOpenMM
ReferenceCustomCompoundBondIxn
::
computeAngle
(
RealOpenMM
*
vec1
,
RealOpenMM
*
vec2
)
{
...
...
platforms/reference/src/SimTKReference/ReferenceCustomDynamics.cpp
View file @
dca54ec7
/* Portions copyright (c) 2011-201
5
Stanford University and Simbios.
/* Portions copyright (c) 2011-201
6
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -56,13 +56,11 @@ ReferenceCustomDynamics::ReferenceCustomDynamics(int numberOfAtoms, const Custom
string
expression
;
integrator
.
getComputationStep
(
i
,
stepType
[
i
],
stepVariable
[
i
],
expression
);
}
kineticEnergyExpression
=
Lepton
::
Parser
::
parse
(
integrator
.
getKineticEnergyExpression
()).
optimize
().
createProgram
();
kineticEnergyExpression
=
Lepton
::
Parser
::
parse
(
integrator
.
getKineticEnergyExpression
()).
optimize
().
createCompiledExpression
();
expressionSet
.
registerExpression
(
kineticEnergyExpression
);
kineticEnergyNeedsForce
=
false
;
for
(
int
i
=
0
;
i
<
kineticEnergyExpression
.
getNumOperations
();
i
++
)
{
const
Lepton
::
Operation
&
op
=
kineticEnergyExpression
.
getOperation
(
i
);
if
(
op
.
getId
()
==
Lepton
::
Operation
::
VARIABLE
&&
op
.
getName
()
==
"f"
)
kineticEnergyNeedsForce
=
true
;
}
if
(
kineticEnergyExpression
.
getVariables
().
find
(
"f"
)
!=
kineticEnergyExpression
.
getVariables
().
end
())
kineticEnergyNeedsForce
=
true
;
}
/**---------------------------------------------------------------------------------------
...
...
@@ -74,6 +72,75 @@ ReferenceCustomDynamics::ReferenceCustomDynamics(int numberOfAtoms, const Custom
ReferenceCustomDynamics
::~
ReferenceCustomDynamics
()
{
}
void
ReferenceCustomDynamics
::
initialize
(
ContextImpl
&
context
,
vector
<
RealOpenMM
>&
masses
,
map
<
string
,
RealOpenMM
>&
globals
)
{
// Some initialization can't be done in the constructor, since we need a ContextImpl from which to get the list of
// Context parameters. Instead, we do it the first time update() or computeKineticEnergy() is called.
int
numSteps
=
stepType
.
size
();
vector
<
int
>
forceGroup
;
vector
<
vector
<
Lepton
::
ParsedExpression
>
>
expressions
;
CustomIntegratorUtilities
::
analyzeComputations
(
context
,
integrator
,
expressions
,
comparisons
,
blockEnd
,
invalidatesForces
,
needsForces
,
needsEnergy
,
computeBothForceAndEnergy
,
forceGroup
);
stepExpressions
.
resize
(
expressions
.
size
());
for
(
int
i
=
0
;
i
<
numSteps
;
i
++
)
{
stepExpressions
[
i
].
resize
(
expressions
[
i
].
size
());
for
(
int
j
=
0
;
j
<
(
int
)
expressions
[
i
].
size
();
j
++
)
{
stepExpressions
[
i
][
j
]
=
expressions
[
i
][
j
].
createCompiledExpression
();
expressionSet
.
registerExpression
(
stepExpressions
[
i
][
j
]);
}
if
(
stepType
[
i
]
==
CustomIntegrator
::
WhileBlockStart
)
blockEnd
[
blockEnd
[
i
]]
=
i
;
// Record where to branch back to.
}
// Record the variable names and flags for the force and energy in each step.
forceGroupFlags
.
resize
(
numSteps
,
-
1
);
fIndex
=
expressionSet
.
getVariableIndex
(
"f"
);
energyIndex
=
expressionSet
.
getVariableIndex
(
"energy"
);
forceVariableIndex
.
resize
(
numSteps
,
fIndex
);
energyVariableIndex
.
resize
(
numSteps
,
energyIndex
);
vector
<
string
>
forceGroupName
;
vector
<
string
>
energyGroupName
;
for
(
int
i
=
0
;
i
<
32
;
i
++
)
{
stringstream
fname
;
fname
<<
"f"
<<
i
;
forceGroupName
.
push_back
(
fname
.
str
());
stringstream
ename
;
ename
<<
"energy"
<<
i
;
energyGroupName
.
push_back
(
ename
.
str
());
}
for
(
int
i
=
0
;
i
<
numSteps
;
i
++
)
{
if
(
needsForces
[
i
]
&&
forceGroup
[
i
]
>
-
1
)
forceVariableIndex
[
i
]
=
expressionSet
.
getVariableIndex
(
forceGroupName
[
forceGroup
[
i
]]);
if
(
needsEnergy
[
i
]
&&
forceGroup
[
i
]
>
-
1
)
energyVariableIndex
[
i
]
=
expressionSet
.
getVariableIndex
(
energyGroupName
[
forceGroup
[
i
]]);
if
(
forceGroup
[
i
]
>
-
1
)
forceGroupFlags
[
i
]
=
1
<<
forceGroup
[
i
];
}
// Build the list of inverse masses.
int
numberOfAtoms
=
masses
.
size
();
inverseMasses
.
resize
(
numberOfAtoms
);
for
(
int
i
=
0
;
i
<
numberOfAtoms
;
i
++
)
{
if
(
masses
[
i
]
==
0.0
)
inverseMasses
[
i
]
=
0.0
;
else
inverseMasses
[
i
]
=
1.0
/
masses
[
i
];
}
// Record indices of other variables.
xIndex
=
expressionSet
.
getVariableIndex
(
"x"
);
vIndex
=
expressionSet
.
getVariableIndex
(
"v"
);
mIndex
=
expressionSet
.
getVariableIndex
(
"m"
);
gaussianIndex
=
expressionSet
.
getVariableIndex
(
"gaussian"
);
uniformIndex
=
expressionSet
.
getVariableIndex
(
"uniform"
);
for
(
int
i
=
0
;
i
<
integrator
.
getNumPerDofVariables
();
i
++
)
perDofVariableIndex
.
push_back
(
expressionSet
.
getVariableIndex
(
integrator
.
getPerDofVariableName
(
i
)));
for
(
int
i
=
0
;
i
<
stepVariable
.
size
();
i
++
)
stepVariableIndex
.
push_back
(
expressionSet
.
getVariableIndex
(
stepVariable
[
i
]));
}
/**---------------------------------------------------------------------------------------
Update -- driver routine for performing Custom dynamics update of coordinates
...
...
@@ -93,58 +160,13 @@ ReferenceCustomDynamics::~ReferenceCustomDynamics() {
void
ReferenceCustomDynamics
::
update
(
ContextImpl
&
context
,
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealVec
>&
velocities
,
vector
<
RealVec
>&
forces
,
vector
<
RealOpenMM
>&
masses
,
map
<
string
,
RealOpenMM
>&
globals
,
vector
<
vector
<
RealVec
>
>&
perDof
,
bool
&
forcesAreValid
,
RealOpenMM
tolerance
)
{
if
(
invalidatesForces
.
size
()
==
0
)
initialize
(
context
,
masses
,
globals
);
int
numSteps
=
stepType
.
size
();
globals
.
insert
(
context
.
getParameters
().
begin
(),
context
.
getParameters
().
end
());
for
(
map
<
string
,
RealOpenMM
>::
const_iterator
iter
=
globals
.
begin
();
iter
!=
globals
.
end
();
++
iter
)
expressionSet
.
setVariable
(
expressionSet
.
getVariableIndex
(
iter
->
first
),
iter
->
second
);
oldPos
=
atomCoordinates
;
if
(
invalidatesForces
.
size
()
==
0
)
{
// Some initialization can't be done in the constructor, since we need a ContextImpl from which to get the list of
// Context parameters. Instead, we do it the first time this method is called.
vector
<
int
>
forceGroup
;
vector
<
vector
<
Lepton
::
ParsedExpression
>
>
expressions
;
CustomIntegratorUtilities
::
analyzeComputations
(
context
,
integrator
,
expressions
,
comparisons
,
blockEnd
,
invalidatesForces
,
needsForces
,
needsEnergy
,
computeBothForceAndEnergy
,
forceGroup
);
stepExpressions
.
resize
(
expressions
.
size
());
for
(
int
i
=
0
;
i
<
numSteps
;
i
++
)
{
for
(
int
j
=
0
;
j
<
(
int
)
expressions
[
i
].
size
();
j
++
)
stepExpressions
[
i
].
push_back
(
expressions
[
i
][
j
].
createProgram
());
if
(
stepType
[
i
]
==
CustomIntegrator
::
BeginWhileBlock
)
blockEnd
[
blockEnd
[
i
]]
=
i
;
// Record where to branch back to.
}
// Record the variable names and flags for the force and energy in each step.
forceGroupFlags
.
resize
(
numSteps
,
-
1
);
forceName
.
resize
(
numSteps
,
"f"
);
energyName
.
resize
(
numSteps
,
"energy"
);
vector
<
string
>
forceGroupName
;
vector
<
string
>
energyGroupName
;
for
(
int
i
=
0
;
i
<
32
;
i
++
)
{
stringstream
fname
;
fname
<<
"f"
<<
i
;
forceGroupName
.
push_back
(
fname
.
str
());
stringstream
ename
;
ename
<<
"energy"
<<
i
;
energyGroupName
.
push_back
(
ename
.
str
());
}
for
(
int
i
=
0
;
i
<
numSteps
;
i
++
)
{
if
(
needsForces
[
i
]
&&
forceGroup
[
i
]
>
-
1
)
forceName
[
i
]
=
forceGroupName
[
forceGroup
[
i
]];
if
(
needsEnergy
[
i
]
&&
forceGroup
[
i
]
>
-
1
)
energyName
[
i
]
=
energyGroupName
[
forceGroup
[
i
]];
if
(
forceGroup
[
i
]
>
-
1
)
forceGroupFlags
[
i
]
=
1
<<
forceGroup
[
i
];
}
// Build the list of inverse masses.
inverseMasses
.
resize
(
numberOfAtoms
);
for
(
int
i
=
0
;
i
<
numberOfAtoms
;
i
++
)
{
if
(
masses
[
i
]
==
0.0
)
inverseMasses
[
i
]
=
0.0
;
else
inverseMasses
[
i
]
=
1.0
/
masses
[
i
];
}
}
// Loop over steps and execute them.
...
...
@@ -160,42 +182,44 @@ void ReferenceCustomDynamics::update(ContextImpl& context, int numberOfAtoms, ve
energy
=
e
;
forcesAreValid
=
true
;
}
globals
[
energyName
[
step
]
]
=
energy
;
expressionSet
.
setVariable
(
energyVariableIndex
[
step
]
,
energy
)
;
// Execute the step.
int
nextStep
=
step
+
1
;
switch
(
stepType
[
step
])
{
case
CustomIntegrator
::
ComputeGlobal
:
{
map
<
string
,
RealOpenMM
>
variables
=
globals
;
variables
[
"uniform"
]
=
SimTKOpenMMUtilities
::
getUniformlyDistributedRandomNumber
();
variables
[
"gaussian"
]
=
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
();
globals
[
stepVariable
[
step
]]
=
stepExpressions
[
step
][
0
].
evaluate
(
variables
);
expressionSet
.
setVariable
(
uniformIndex
,
SimTKOpenMMUtilities
::
getUniformlyDistributedRandomNumber
());
expressionSet
.
setVariable
(
gaussianIndex
,
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
());
RealOpenMM
result
=
stepExpressions
[
step
][
0
].
evaluate
();
globals
[
stepVariable
[
step
]]
=
result
;
expressionSet
.
setVariable
(
stepVariableIndex
[
step
],
result
);
break
;
}
case
CustomIntegrator
::
ComputePerDof
:
{
vector
<
RealVec
>*
results
=
NULL
;
if
(
stepVariable
[
step
]
==
"x"
)
if
(
stepVariable
Index
[
step
]
==
xIndex
)
results
=
&
atomCoordinates
;
else
if
(
stepVariable
[
step
]
==
"v"
)
else
if
(
stepVariable
Index
[
step
]
==
vIndex
)
results
=
&
velocities
;
else
{
for
(
int
j
=
0
;
j
<
integrator
.
getNumPerDofVariables
();
j
++
)
if
(
stepVariable
[
step
]
==
integrator
.
getP
erDofVariable
Name
(
j
)
)
if
(
stepVariable
Index
[
step
]
==
p
erDofVariable
Index
[
j
]
)
results
=
&
perDof
[
j
];
}
if
(
results
==
NULL
)
throw
OpenMMException
(
"Illegal per-DOF output variable: "
+
stepVariable
[
step
]);
computePerDof
(
numberOfAtoms
,
*
results
,
atomCoordinates
,
velocities
,
forces
,
masses
,
globals
,
perDof
,
stepExpressions
[
step
][
0
],
force
Name
[
step
]);
computePerDof
(
numberOfAtoms
,
*
results
,
atomCoordinates
,
velocities
,
forces
,
masses
,
perDof
,
stepExpressions
[
step
][
0
],
force
VariableIndex
[
step
]);
break
;
}
case
CustomIntegrator
::
ComputeSum
:
{
computePerDof
(
numberOfAtoms
,
sumBuffer
,
atomCoordinates
,
velocities
,
forces
,
masses
,
globals
,
perDof
,
stepExpressions
[
step
][
0
],
force
Name
[
step
]);
computePerDof
(
numberOfAtoms
,
sumBuffer
,
atomCoordinates
,
velocities
,
forces
,
masses
,
perDof
,
stepExpressions
[
step
][
0
],
force
VariableIndex
[
step
]);
RealOpenMM
sum
=
0.0
;
for
(
int
j
=
0
;
j
<
numberOfAtoms
;
j
++
)
if
(
masses
[
j
]
!=
0.0
)
sum
+=
sumBuffer
[
j
][
0
]
+
sumBuffer
[
j
][
1
]
+
sumBuffer
[
j
][
2
];
globals
[
stepVariable
[
step
]]
=
sum
;
expressionSet
.
setVariable
(
stepVariableIndex
[
step
],
sum
);
break
;
}
case
CustomIntegrator
::
ConstrainPositions
:
{
...
...
@@ -211,19 +235,21 @@ void ReferenceCustomDynamics::update(ContextImpl& context, int numberOfAtoms, ve
recordChangedParameters
(
context
,
globals
);
context
.
updateContextState
();
globals
.
insert
(
context
.
getParameters
().
begin
(),
context
.
getParameters
().
end
());
for
(
map
<
string
,
RealOpenMM
>::
const_iterator
iter
=
globals
.
begin
();
iter
!=
globals
.
end
();
++
iter
)
expressionSet
.
setVariable
(
expressionSet
.
getVariableIndex
(
iter
->
first
),
iter
->
second
);
break
;
}
case
CustomIntegrator
::
Begin
IfBlock
:
{
if
(
!
evaluateCondition
(
step
,
globals
))
case
CustomIntegrator
::
IfBlock
Start
:
{
if
(
!
evaluateCondition
(
step
))
nextStep
=
blockEnd
[
step
]
+
1
;
break
;
}
case
CustomIntegrator
::
Begin
WhileBlock
:
{
if
(
!
evaluateCondition
(
step
,
globals
))
case
CustomIntegrator
::
WhileBlock
Start
:
{
if
(
!
evaluateCondition
(
step
))
nextStep
=
blockEnd
[
step
]
+
1
;
break
;
}
case
CustomIntegrator
::
End
Block
:
{
case
CustomIntegrator
::
Block
End
:
{
if
(
blockEnd
[
step
]
!=
-
1
)
nextStep
=
blockEnd
[
step
];
// Return to the start of a while block.
break
;
...
...
@@ -240,36 +266,33 @@ void ReferenceCustomDynamics::update(ContextImpl& context, int numberOfAtoms, ve
void
ReferenceCustomDynamics
::
computePerDof
(
int
numberOfAtoms
,
vector
<
RealVec
>&
results
,
const
vector
<
RealVec
>&
atomCoordinates
,
const
vector
<
RealVec
>&
velocities
,
const
vector
<
RealVec
>&
forces
,
const
vector
<
RealOpenMM
>&
masses
,
const
map
<
string
,
RealOpenMM
>&
globals
,
const
vector
<
vector
<
RealVec
>
>&
perDof
,
const
Lepton
::
ExpressionProgram
&
expression
,
const
std
::
string
&
forceName
)
{
const
vector
<
vector
<
RealVec
>
>&
perDof
,
const
Lepton
::
CompiledExpression
&
expression
,
int
forceIndex
)
{
// Loop over all degrees of freedom.
map
<
string
,
RealOpenMM
>
variables
=
globals
;
for
(
int
i
=
0
;
i
<
numberOfAtoms
;
i
++
)
{
if
(
masses
[
i
]
!=
0.0
)
{
variables
[
"m"
]
=
masses
[
i
];
expressionSet
.
setVariable
(
mIndex
,
masses
[
i
]
)
;
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
// Compute the expression.
variables
[
"x"
]
=
atomCoordinates
[
i
][
j
];
variables
[
"v"
]
=
velocities
[
i
][
j
];
v
ariable
s
[
force
Name
]
=
forces
[
i
][
j
];
v
ariable
s
[
"
uniform
"
]
=
SimTKOpenMMUtilities
::
getUniformlyDistributedRandomNumber
();
v
ariable
s
[
"
gaussian
"
]
=
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
();
expressionSet
.
setVariable
(
xIndex
,
atomCoordinates
[
i
][
j
]
)
;
expressionSet
.
setVariable
(
vIndex
,
velocities
[
i
][
j
]
)
;
expressionSet
.
setV
ariable
(
force
Index
,
forces
[
i
][
j
]
)
;
expressionSet
.
setV
ariable
(
uniform
Index
,
SimTKOpenMMUtilities
::
getUniformlyDistributedRandomNumber
()
)
;
expressionSet
.
setV
ariable
(
gaussian
Index
,
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
()
)
;
for
(
int
k
=
0
;
k
<
(
int
)
perDof
.
size
();
k
++
)
variables
[
integrator
.
getP
erDofVariable
Name
(
k
)]
=
perDof
[
k
][
i
][
j
];
results
[
i
][
j
]
=
expression
.
evaluate
(
variables
);
expressionSet
.
setVariable
(
p
erDofVariable
Index
[
k
],
perDof
[
k
][
i
][
j
]
)
;
results
[
i
][
j
]
=
expression
.
evaluate
();
}
}
}
}
bool
ReferenceCustomDynamics
::
evaluateCondition
(
int
step
,
map
<
string
,
RealOpenMM
>&
globals
)
{
map
<
string
,
RealOpenMM
>
variables
=
globals
;
variables
[
"uniform"
]
=
SimTKOpenMMUtilities
::
getUniformlyDistributedRandomNumber
();
variables
[
"gaussian"
]
=
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
();
double
lhs
=
stepExpressions
[
step
][
0
].
evaluate
(
variables
);
double
rhs
=
stepExpressions
[
step
][
1
].
evaluate
(
variables
);
bool
ReferenceCustomDynamics
::
evaluateCondition
(
int
step
)
{
expressionSet
.
setVariable
(
uniformIndex
,
SimTKOpenMMUtilities
::
getUniformlyDistributedRandomNumber
());
expressionSet
.
setVariable
(
gaussianIndex
,
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
());
double
lhs
=
stepExpressions
[
step
][
0
].
evaluate
();
double
rhs
=
stepExpressions
[
step
][
1
].
evaluate
();
switch
(
comparisons
[
step
])
{
case
CustomIntegratorUtilities
::
EQUAL
:
return
(
lhs
==
rhs
);
...
...
@@ -318,12 +341,16 @@ void ReferenceCustomDynamics::recordChangedParameters(OpenMM::ContextImpl& conte
double
ReferenceCustomDynamics
::
computeKineticEnergy
(
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
)
{
if
(
invalidatesForces
.
size
()
==
0
)
initialize
(
context
,
masses
,
globals
);
globals
.
insert
(
context
.
getParameters
().
begin
(),
context
.
getParameters
().
end
());
for
(
map
<
string
,
RealOpenMM
>::
const_iterator
iter
=
globals
.
begin
();
iter
!=
globals
.
end
();
++
iter
)
expressionSet
.
setVariable
(
expressionSet
.
getVariableIndex
(
iter
->
first
),
iter
->
second
);
if
(
kineticEnergyNeedsForce
)
{
energy
=
context
.
calcForcesAndEnergy
(
true
,
true
,
-
1
);
forcesAreValid
=
true
;
}
computePerDof
(
numberOfAtoms
,
sumBuffer
,
atomCoordinates
,
velocities
,
forces
,
masses
,
globals
,
perDof
,
kineticEnergyExpression
,
"f"
);
computePerDof
(
numberOfAtoms
,
sumBuffer
,
atomCoordinates
,
velocities
,
forces
,
masses
,
perDof
,
kineticEnergyExpression
,
fIndex
);
RealOpenMM
sum
=
0.0
;
for
(
int
j
=
0
;
j
<
numberOfAtoms
;
j
++
)
if
(
masses
[
j
]
!=
0.0
)
...
...
platforms/reference/src/SimTKReference/ReferenceCustomTorsionIxn.cpp
View file @
dca54ec7
/* Portions copyright (c) 2010-201
3
Stanford University and Simbios.
/* Portions copyright (c) 2010-201
6
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -39,7 +39,7 @@ using namespace OpenMM;
ReferenceCustomTorsionIxn
::
ReferenceCustomTorsionIxn
(
const
Lepton
::
CompiledExpression
&
energyExpression
,
const
Lepton
::
CompiledExpression
&
forceExpression
,
const
vector
<
string
>&
parameterNames
,
map
<
string
,
double
>
globalParameters
)
:
energyExpression
(
energyExpression
),
forceExpression
(
forceExpression
)
{
energyExpression
(
energyExpression
),
forceExpression
(
forceExpression
)
,
usePeriodic
(
false
)
{
energyTheta
=
ReferenceForce
::
getVariablePointer
(
this
->
energyExpression
,
"theta"
);
forceTheta
=
ReferenceForce
::
getVariablePointer
(
this
->
forceExpression
,
"theta"
);
...
...
@@ -61,13 +61,13 @@ ReferenceCustomTorsionIxn::ReferenceCustomTorsionIxn(const Lepton::CompiledExpre
--------------------------------------------------------------------------------------- */
ReferenceCustomTorsionIxn
::~
ReferenceCustomTorsionIxn
()
{
}
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceCustomTorsionIxn::~ReferenceCustomTorsionIxn";
// ---------------------------------------------------------------------------------------
void
ReferenceCustomTorsionIxn
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
...
...
@@ -107,9 +107,16 @@ void ReferenceCustomTorsionIxn::calculateBondIxn(int* atomIndices,
int
atomBIndex
=
atomIndices
[
1
];
int
atomCIndex
=
atomIndices
[
2
];
int
atomDIndex
=
atomIndices
[
3
];
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
deltaR
[
0
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
1
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
2
]);
if
(
usePeriodic
)
{
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
boxVectors
,
deltaR
[
0
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
boxVectors
,
deltaR
[
1
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
boxVectors
,
deltaR
[
2
]);
}
else
{
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
deltaR
[
0
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
1
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
2
]);
}
// Visual Studio complains if crossProduct declared as 'crossProduct[2][3]'
...
...
platforms/reference/src/SimTKReference/ReferenceForce.cpp
View file @
dca54ec7
...
...
@@ -73,6 +73,10 @@ void ReferenceForce::getDeltaR(const RealVec& atomCoordinatesI, const RealVec& a
deltaR
[
RIndex
]
=
(
RealOpenMM
)
SQRT
(
deltaR
[
R2Index
]);
}
RealVec
ReferenceForce
::
getDeltaR
(
const
RealVec
&
atomCoordinatesI
,
const
RealVec
&
atomCoordinatesJ
)
{
return
atomCoordinatesJ
-
atomCoordinatesI
;
}
void
ReferenceForce
::
getDeltaRPeriodic
(
const
RealVec
&
atomCoordinatesI
,
const
RealVec
&
atomCoordinatesJ
,
const
RealOpenMM
*
boxSize
,
RealOpenMM
*
deltaR
)
{
deltaR
[
XIndex
]
=
periodicDifference
(
atomCoordinatesJ
[
0
],
atomCoordinatesI
[
0
],
boxSize
[
0
]);
...
...
@@ -96,6 +100,15 @@ void ReferenceForce::getDeltaRPeriodic(const RealVec& atomCoordinatesI, const Re
deltaR
[
RIndex
]
=
SQRT
(
deltaR
[
R2Index
]);
}
RealVec
ReferenceForce
::
getDeltaRPeriodic
(
const
RealVec
&
atomCoordinatesI
,
const
RealVec
&
atomCoordinatesJ
,
const
RealVec
*
boxVectors
)
{
RealVec
diff
=
atomCoordinatesJ
-
atomCoordinatesI
;
diff
-=
boxVectors
[
2
]
*
floor
(
diff
[
2
]
/
boxVectors
[
2
][
2
]
+
0.5
);
diff
-=
boxVectors
[
1
]
*
floor
(
diff
[
1
]
/
boxVectors
[
1
][
1
]
+
0.5
);
diff
-=
boxVectors
[
0
]
*
floor
(
diff
[
0
]
/
boxVectors
[
0
][
0
]
+
0.5
);
return
diff
;
}
double
*
ReferenceForce
::
getVariablePointer
(
Lepton
::
CompiledExpression
&
expression
,
const
std
::
string
&
name
)
{
if
(
expression
.
getVariables
().
find
(
name
)
==
expression
.
getVariables
().
end
())
return
NULL
;
...
...
platforms/reference/src/SimTKReference/ReferenceHarmonicBondIxn.cpp
View file @
dca54ec7
/* Portions copyright (c) 2006 Stanford University and Simbios.
/* Portions copyright (c) 2006
-2016
Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -38,14 +38,7 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */
ReferenceHarmonicBondIxn
::
ReferenceHarmonicBondIxn
()
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceHarmonicBondIxn::ReferenceHarmonicBondIxn";
// ---------------------------------------------------------------------------------------
ReferenceHarmonicBondIxn
::
ReferenceHarmonicBondIxn
()
:
usePeriodic
(
false
)
{
}
/**---------------------------------------------------------------------------------------
...
...
@@ -55,13 +48,13 @@ ReferenceHarmonicBondIxn::ReferenceHarmonicBondIxn() {
--------------------------------------------------------------------------------------- */
ReferenceHarmonicBondIxn
::~
ReferenceHarmonicBondIxn
()
{
}
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceHarmonicBondIxn::~ReferenceHarmonicBondIxn";
// ---------------------------------------------------------------------------------------
void
ReferenceHarmonicBondIxn
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
...
...
@@ -99,7 +92,10 @@ void ReferenceHarmonicBondIxn::calculateBondIxn(int* atomIndices,
int
atomAIndex
=
atomIndices
[
0
];
int
atomBIndex
=
atomIndices
[
1
];
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
);
if
(
usePeriodic
)
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
boxVectors
,
deltaR
);
else
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
);
// deltaIdeal = r - r_0
...
...
platforms/reference/src/SimTKReference/ReferenceLJCoulombIxn.cpp
View file @
dca54ec7
...
...
@@ -420,6 +420,7 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
// Now subtract off the exclusions, since they were implicitly included in the reciprocal space sum.
RealOpenMM
totalExclusionEnergy
=
0.0
f
;
const
double
TWO_OVER_SQRT_PI
=
2
/
sqrt
(
PI_M
);
for
(
int
i
=
0
;
i
<
numberOfAtoms
;
i
++
)
for
(
set
<
int
>::
const_iterator
iter
=
exclusions
[
i
].
begin
();
iter
!=
exclusions
[
i
].
end
();
++
iter
)
{
if
(
*
iter
>
i
)
{
...
...
@@ -446,12 +447,15 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
// accumulate energies
realSpaceEwaldEnergy
=
(
RealOpenMM
)
(
ONE_4PI_EPS0
*
atomParameters
[
ii
][
QIndex
]
*
atomParameters
[
jj
][
QIndex
]
*
inverseR
*
erf
(
alphaR
));
}
else
{
realSpaceEwaldEnergy
=
(
RealOpenMM
)
(
alphaEwald
*
TWO_OVER_SQRT_PI
*
ONE_4PI_EPS0
*
atomParameters
[
ii
][
QIndex
]
*
atomParameters
[
jj
][
QIndex
]);
}
totalExclusionEnergy
+=
realSpaceEwaldEnergy
;
if
(
energyByAtom
)
{
energyByAtom
[
ii
]
-=
realSpaceEwaldEnergy
;
energyByAtom
[
jj
]
-=
realSpaceEwaldEnergy
;
}
totalExclusionEnergy
+=
realSpaceEwaldEnergy
;
if
(
energyByAtom
)
{
energyByAtom
[
ii
]
-=
realSpaceEwaldEnergy
;
energyByAtom
[
jj
]
-=
realSpaceEwaldEnergy
;
}
}
}
...
...
platforms/reference/src/SimTKReference/ReferenceProperDihedralBond.cpp
View file @
dca54ec7
/* Portions copyright (c) 2006 Stanford University and Simbios.
/* Portions copyright (c) 2006
-2016
Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -38,14 +38,7 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */
ReferenceProperDihedralBond
::
ReferenceProperDihedralBond
()
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceProperDihedralBond::ReferenceProperDihedralBond";
// ---------------------------------------------------------------------------------------
ReferenceProperDihedralBond
::
ReferenceProperDihedralBond
()
:
usePeriodic
(
false
)
{
}
/**---------------------------------------------------------------------------------------
...
...
@@ -55,13 +48,13 @@ ReferenceProperDihedralBond::ReferenceProperDihedralBond() {
--------------------------------------------------------------------------------------- */
ReferenceProperDihedralBond
::~
ReferenceProperDihedralBond
()
{
}
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceProperDihedralBond::~ReferenceProperDihedralBond";
// ---------------------------------------------------------------------------------------
void
ReferenceProperDihedralBond
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
...
...
@@ -110,9 +103,16 @@ void ReferenceProperDihedralBond::calculateBondIxn(int* atomIndices,
int
atomBIndex
=
atomIndices
[
1
];
int
atomCIndex
=
atomIndices
[
2
];
int
atomDIndex
=
atomIndices
[
3
];
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
deltaR
[
0
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
1
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
2
]);
if
(
usePeriodic
)
{
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
boxVectors
,
deltaR
[
0
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
boxVectors
,
deltaR
[
1
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
boxVectors
,
deltaR
[
2
]);
}
else
{
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
deltaR
[
0
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
1
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
2
]);
}
RealOpenMM
dotDihedral
;
RealOpenMM
signOfAngle
;
...
...
platforms/reference/src/SimTKReference/ReferenceRbDihedralBond.cpp
View file @
dca54ec7
/* Portions copyright (c) 2006 Stanford University and Simbios.
/* Portions copyright (c) 2006
-2016
Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -38,14 +38,7 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */
ReferenceRbDihedralBond
::
ReferenceRbDihedralBond
()
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceRbDihedralBond::ReferenceRbDihedralBond";
// ---------------------------------------------------------------------------------------
ReferenceRbDihedralBond
::
ReferenceRbDihedralBond
()
:
usePeriodic
(
false
)
{
}
/**---------------------------------------------------------------------------------------
...
...
@@ -55,13 +48,13 @@ ReferenceRbDihedralBond::ReferenceRbDihedralBond() {
--------------------------------------------------------------------------------------- */
ReferenceRbDihedralBond
::~
ReferenceRbDihedralBond
()
{
}
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceRbDihedralBond::~ReferenceRbDihedralBond";
// ---------------------------------------------------------------------------------------
void
ReferenceRbDihedralBond
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
...
...
@@ -112,9 +105,16 @@ void ReferenceRbDihedralBond::calculateBondIxn(int* atomIndices,
int
atomBIndex
=
atomIndices
[
1
];
int
atomCIndex
=
atomIndices
[
2
];
int
atomDIndex
=
atomIndices
[
3
];
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
deltaR
[
0
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
1
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
2
]);
if
(
usePeriodic
)
{
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
boxVectors
,
deltaR
[
0
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
boxVectors
,
deltaR
[
1
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
boxVectors
,
deltaR
[
2
]);
}
else
{
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
deltaR
[
0
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
1
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
2
]);
}
RealOpenMM
cosPhi
;
RealOpenMM
signOfAngle
;
...
...
platforms/reference/src/SimTKReference/SimTKOpenMMUtilities.cpp
View file @
dca54ec7
...
...
@@ -383,8 +383,11 @@ void SimTKOpenMMUtilities::createCheckpoint(std::ostream& stream) {
void
SimTKOpenMMUtilities
::
loadCheckpoint
(
std
::
istream
&
stream
)
{
stream
.
read
((
char
*
)
&
_randomNumberSeed
,
sizeof
(
uint32_t
));
bool
prevInitialized
=
_randomInitialized
;
stream
.
read
((
char
*
)
&
_randomInitialized
,
sizeof
(
bool
));
if
(
_randomInitialized
)
{
if
(
!
prevInitialized
)
init_gen_rand
(
0
,
sfmt
);
stream
.
read
((
char
*
)
&
nextGaussianIsValid
,
sizeof
(
bool
));
stream
.
read
((
char
*
)
&
nextGaussian
,
sizeof
(
RealOpenMM
));
sfmt
.
loadCheckpoint
(
stream
);
...
...
platforms/reference/tests/TestReferenceCheckpoints.cpp
View file @
dca54ec7
...
...
@@ -92,6 +92,15 @@ void testCheckpoint() {
integrator
.
step
(
10
);
State
s4
=
context
.
getState
(
State
::
Positions
|
State
::
Velocities
|
State
::
Parameters
);
compareStates
(
s2
,
s4
);
// See if a checkpoint created from one Context can be loaded into a different one.
VerletIntegrator
integrator2
(
0.001
);
Context
context2
(
system
,
integrator2
,
platform
);
stream1
.
seekg
(
0
,
stream1
.
beg
);
context2
.
loadCheckpoint
(
stream1
);
State
s5
=
context2
.
getState
(
State
::
Positions
|
State
::
Velocities
|
State
::
Parameters
|
State
::
Energy
);
compareStates
(
s1
,
s5
);
}
void
runPlatformTests
()
{
...
...
platforms/reference/tests/TestReferenceMonteCarloMembraneBarostat.cpp
View file @
dca54ec7
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-201
4
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -82,7 +82,7 @@ void testIdealGas(MonteCarloMembraneBarostat::XYMode xymode, MonteCarloMembraneB
// Test it for three different temperatures.
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
barostat
->
setTemperature
(
temp
[
i
]);
barostat
->
set
Default
Temperature
(
temp
[
i
]);
LangevinIntegrator
integrator
(
temp
[
i
],
0.1
,
0.01
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
...
...
plugins/amoeba/openmmapi/include/openmm/AmoebaAngleForce.h
View file @
dca54ec7
...
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-201
2
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
6
Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman *
* Contributors: *
* *
...
...
@@ -166,21 +166,25 @@ public:
* in an angle cannot be changed, nor can new angles be added.
*/
void
updateParametersInContext
(
Context
&
context
);
/**
* Set whether this force should apply periodic boundary conditions when calculating displacements.
* Usually this is not appropriate for bonded forces, but there are situations when it can be useful.
*/
void
setUsesPeriodicBoundaryConditions
(
bool
periodic
);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if
nonbondedMethod
uses PBC and false otherwise
* @returns true if
force
uses PBC and false otherwise
*/
bool
usesPeriodicBoundaryConditions
()
const
{
return
false
;
}
bool
usesPeriodicBoundaryConditions
()
const
;
protected:
ForceImpl
*
createImpl
()
const
;
double
_globalCubicK
,
_globalQuarticK
,
_globalPenticK
,
_globalSexticK
;
private:
class
AngleInfo
;
std
::
vector
<
AngleInfo
>
angles
;
bool
usePeriodic
;
};
/**
...
...
plugins/amoeba/openmmapi/include/openmm/AmoebaBondForce.h
View file @
dca54ec7
...
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-201
2
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
6
Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman *
* Contributors: *
* *
...
...
@@ -138,21 +138,25 @@ public:
* in a bond cannot be changed, nor can new bonds be added.
*/
void
updateParametersInContext
(
Context
&
context
);
/**
* Set whether this force should apply periodic boundary conditions when calculating displacements.
* Usually this is not appropriate for bonded forces, but there are situations when it can be useful.
*/
void
setUsesPeriodicBoundaryConditions
(
bool
periodic
);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if
nonbondedMethod
uses PBC and false otherwise
* @returns true if
force
uses PBC and false otherwise
*/
bool
usesPeriodicBoundaryConditions
()
const
{
return
false
;
}
bool
usesPeriodicBoundaryConditions
()
const
;
protected:
double
_globalQuarticK
,
_globalCubicK
;
ForceImpl
*
createImpl
()
const
;
private:
class
BondInfo
;
std
::
vector
<
BondInfo
>
bonds
;
bool
usePeriodic
;
};
/**
...
...
plugins/amoeba/openmmapi/include/openmm/AmoebaInPlaneAngleForce.h
View file @
dca54ec7
...
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-201
2
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
6
Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman *
* Contributors: *
* *
...
...
@@ -171,21 +171,25 @@ public:
* in an angle cannot be changed, nor can new angles be added.
*/
void
updateParametersInContext
(
Context
&
context
);
/**
* Set whether this force should apply periodic boundary conditions when calculating displacements.
* Usually this is not appropriate for bonded forces, but there are situations when it can be useful.
*/
void
setUsesPeriodicBoundaryConditions
(
bool
periodic
);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if
nonbondedMethod
uses PBC and false otherwise
* @returns true if
force
uses PBC and false otherwise
*/
bool
usesPeriodicBoundaryConditions
()
const
{
return
false
;
}
bool
usesPeriodicBoundaryConditions
()
const
;
protected:
ForceImpl
*
createImpl
()
const
;
double
_globalCubicK
,
_globalQuarticK
,
_globalPenticK
,
_globalSexticK
;
private:
class
AngleInfo
;
std
::
vector
<
AngleInfo
>
angles
;
bool
usePeriodic
;
};
/**
...
...
plugins/amoeba/openmmapi/include/openmm/AmoebaMultipoleForce.h
View file @
dca54ec7
...
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-201
2
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
6
Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman *
* Contributors: *
* *
...
...
@@ -72,14 +72,25 @@ public:
enum
PolarizationType
{
/**
* Mutual polarization
* Full mutually induced polarization. The dipoles are iterated until the converge to the accuracy specified
* by getMutualInducedTargetEpsilon().
*/
Mutual
=
0
,
/**
* Direct polarization
* Direct polarization approximation. The induced dipoles depend only on the fixed multipoles, not on other
* induced dipoles.
*/
Direct
=
1
Direct
=
1
,
/**
* Extrapolated perturbation theory approximation. The dipoles are iterated a few times, and then an analytic
* approximation is used to extrapolate to the fully converged values. Call setExtrapolationCoefficients()
* to set the coefficients used for the extrapolation. The default coefficients used in this release are
* [-0.154, 0.017, 0.658, 0.474], but be aware that those may change in a future release.
*/
Extrapolated
=
2
};
enum
MultipoleAxisTypes
{
ZThenX
=
0
,
Bisector
=
1
,
ZBisect
=
2
,
ThreeFold
=
3
,
ZOnly
=
4
,
NoAxisType
=
5
,
LastAxisTypeIndex
=
6
};
...
...
@@ -136,11 +147,34 @@ public:
*/
void
setCutoffDistance
(
double
distance
);
/**
* Get the parameters to use for PME calculations. If alpha is 0 (the default), these parameters are
* ignored and instead their values are chosen based on the Ewald error tolerance.
*
* @param[out] alpha the separation parameter
* @param[out] nx the number of grid points along the X axis
* @param[out] ny the number of grid points along the Y axis
* @param[out] nz the number of grid points along the Z axis
*/
void
getPMEParameters
(
double
&
alpha
,
int
&
nx
,
int
&
ny
,
int
&
nz
)
const
;
/**
* Set the parameters to use for PME calculations. If alpha is 0 (the default), these parameters are
* ignored and instead their values are chosen based on the Ewald error tolerance.
*
* @param alpha the separation parameter
* @param nx the number of grid points along the X axis
* @param ny the number of grid points along the Y axis
* @param nz the number of grid points along the Z axis
*/
void
setPMEParameters
(
double
alpha
,
int
nx
,
int
ny
,
int
nz
);
/**
* Get the Ewald alpha parameter. If this is 0 (the default), a value is chosen automatically
* based on the Ewald error tolerance.
*
* @return the Ewald alpha parameter
* @deprecated This method exists only for backward compatibility. Use getPMEParameters() instead.
*/
double
getAEwald
()
const
;
...
...
@@ -149,6 +183,7 @@ public:
* based on the Ewald error tolerance.
*
* @param aewald alpha parameter
* @deprecated This method exists only for backward compatibility. Use setPMEParameters() instead.
*/
void
setAEwald
(
double
aewald
);
...
...
@@ -164,6 +199,7 @@ public:
* are chosen automatically based on the Ewald error tolerance.
*
* @return the PME grid dimensions
* @deprecated This method exists only for backward compatibility. Use getPMEParameters() instead.
*/
void
getPmeGridDimensions
(
std
::
vector
<
int
>&
gridDimension
)
const
;
...
...
@@ -172,6 +208,7 @@ public:
* are chosen automatically based on the Ewald error tolerance.
*
* @param gridDimension the PME grid dimensions
* @deprecated This method exists only for backward compatibility. Use setPMEParameters() instead.
*/
void
setPmeGridDimensions
(
const
std
::
vector
<
int
>&
gridDimension
);
...
...
@@ -298,6 +335,23 @@ public:
*/
void
setMutualInducedTargetEpsilon
(
double
inputMutualInducedTargetEpsilon
);
/**
* Set the coefficients for the mu_0, mu_1, mu_2, ..., mu_n terms in the extrapolation
* algorithm for induced dipoles.
*
* @param coefficients a vector whose mth entry specifies the coefficient for mu_m. The length of this
* vector determines how many iterations are performed.
*
*/
void
setExtrapolationCoefficients
(
const
std
::
vector
<
double
>
&
coefficients
);
/**
* Get the coefficients for the mu_0, mu_1, mu_2, ..., mu_n terms in the extrapolation
* algorithm for induced dipoles. In this release, the default values for the coefficients are
* [-0.154, 0.017, 0.658, 0.474], but be aware that those may change in a future release.
*/
const
std
::
vector
<
double
>&
getExtrapolationCoefficients
()
const
;
/**
* Get the error tolerance for Ewald summation. This corresponds to the fractional error in the forces
* which is acceptable. This value is used to select the grid dimensions and separation (alpha)
...
...
@@ -394,10 +448,11 @@ private:
NonbondedMethod
nonbondedMethod
;
PolarizationType
polarizationType
;
double
cutoffDistance
;
double
aewald
;
int
pmeBSplineOrder
;
std
::
vector
<
int
>
pmeGridDimension
;
double
alpha
;
int
pmeBSplineOrder
,
nx
,
ny
,
nz
;
int
mutualInducedMaxIterations
;
std
::
vector
<
double
>
extrapolationCoefficients
;
double
mutualInducedTargetEpsilon
;
double
scalingDistanceCutoff
;
double
electricConstant
;
...
...
plugins/amoeba/openmmapi/include/openmm/AmoebaOutOfPlaneBendForce.h
View file @
dca54ec7
...
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-201
2
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
6
Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman *
* Contributors: *
* *
...
...
@@ -163,21 +163,25 @@ public:
* in a term cannot be changed, nor can new terms be added.
*/
void
updateParametersInContext
(
Context
&
context
);
/**
* Set whether this force should apply periodic boundary conditions when calculating displacements.
* Usually this is not appropriate for bonded forces, but there are situations when it can be useful.
*/
void
setUsesPeriodicBoundaryConditions
(
bool
periodic
);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if
nonbondedMethod
uses PBC and false otherwise
* @returns true if
force
uses PBC and false otherwise
*/
bool
usesPeriodicBoundaryConditions
()
const
{
return
false
;
}
bool
usesPeriodicBoundaryConditions
()
const
;
protected:
ForceImpl
*
createImpl
()
const
;
double
_globalCubicK
,
_globalQuarticK
,
_globalPenticK
,
_globalSexticK
;
private:
class
OutOfPlaneBendInfo
;
std
::
vector
<
OutOfPlaneBendInfo
>
outOfPlaneBends
;
bool
usePeriodic
;
};
/**
...
...
plugins/amoeba/openmmapi/include/openmm/AmoebaPiTorsionForce.h
View file @
dca54ec7
...
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-201
2
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
6
Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman *
* Contributors: *
* *
...
...
@@ -113,20 +113,24 @@ public:
* in a torsion cannot be changed, nor can new torsions be added.
*/
void
updateParametersInContext
(
Context
&
context
);
/**
* Set whether this force should apply periodic boundary conditions when calculating displacements.
* Usually this is not appropriate for bonded forces, but there are situations when it can be useful.
*/
void
setUsesPeriodicBoundaryConditions
(
bool
periodic
);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if
nonbondedMethod
uses PBC and false otherwise
* @returns true if
force
uses PBC and false otherwise
*/
bool
usesPeriodicBoundaryConditions
()
const
{
return
false
;
}
bool
usesPeriodicBoundaryConditions
()
const
;
protected:
ForceImpl
*
createImpl
()
const
;
private:
class
PiTorsionInfo
;
std
::
vector
<
PiTorsionInfo
>
piTorsions
;
bool
usePeriodic
;
};
/**
...
...
plugins/amoeba/openmmapi/include/openmm/AmoebaStretchBendForce.h
View file @
dca54ec7
...
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-201
2
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
6
Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman *
* Contributors: *
* *
...
...
@@ -119,20 +119,24 @@ public:
* in a term cannot be changed, nor can new terms be added.
*/
void
updateParametersInContext
(
Context
&
context
);
/**
* Set whether this force should apply periodic boundary conditions when calculating displacements.
* Usually this is not appropriate for bonded forces, but there are situations when it can be useful.
*/
void
setUsesPeriodicBoundaryConditions
(
bool
periodic
);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if
nonbondedMethod
uses PBC and false otherwise
* @returns true if
force
uses PBC and false otherwise
*/
bool
usesPeriodicBoundaryConditions
()
const
{
return
false
;
}
bool
usesPeriodicBoundaryConditions
()
const
;
protected:
ForceImpl
*
createImpl
()
const
;
private:
class
StretchBendInfo
;
std
::
vector
<
StretchBendInfo
>
stretchBends
;
bool
usePeriodic
;
};
/**
...
...
plugins/amoeba/openmmapi/include/openmm/AmoebaTorsionTorsionForce.h
View file @
dca54ec7
...
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-201
2
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
6
Stanford University and the Authors. *
* Authors: Mark Friedrichs, Peter Eastman *
* Contributors: *
* *
...
...
@@ -137,15 +137,18 @@ public:
* grid[x][y][5] = dEd(xy) value
*/
void
setTorsionTorsionGrid
(
int
index
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
double
>
>
>&
grid
);
/**
* Set whether this force should apply periodic boundary conditions when calculating displacements.
* Usually this is not appropriate for bonded forces, but there are situations when it can be useful.
*/
void
setUsesPeriodicBoundaryConditions
(
bool
periodic
);
/**
* Returns whether or not this force makes use of periodic boundary
* conditions.
*
* @returns true if
nonbondedMethod
uses PBC and false otherwise
* @returns true if
force
uses PBC and false otherwise
*/
bool
usesPeriodicBoundaryConditions
()
const
{
return
false
;
}
bool
usesPeriodicBoundaryConditions
()
const
;
protected:
ForceImpl
*
createImpl
()
const
;
private:
...
...
@@ -153,6 +156,7 @@ private:
class
TorsionTorsionGridInfo
;
std
::
vector
<
TorsionTorsionInfo
>
torsionTorsions
;
std
::
vector
<
TorsionTorsionGridInfo
>
torsionTorsionGrids
;
bool
usePeriodic
;
};
/**
...
...
Prev
1
…
6
7
8
9
10
11
12
13
14
…
20
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