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
5003591d
Commit
5003591d
authored
Jul 21, 2010
by
Peter Eastman
Browse files
Simplified reference code for accumulating energies
parent
b8c624fa
Changes
28
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
78 additions
and
278 deletions
+78
-278
platforms/reference/src/ReferenceKernels.cpp
platforms/reference/src/ReferenceKernels.cpp
+16
-48
platforms/reference/src/SimTKReference/ReferenceAngleBondIxn.cpp
...ms/reference/src/SimTKReference/ReferenceAngleBondIxn.cpp
+5
-18
platforms/reference/src/SimTKReference/ReferenceAngleBondIxn.h
...orms/reference/src/SimTKReference/ReferenceAngleBondIxn.h
+3
-6
platforms/reference/src/SimTKReference/ReferenceBondForce.cpp
...forms/reference/src/SimTKReference/ReferenceBondForce.cpp
+3
-15
platforms/reference/src/SimTKReference/ReferenceBondForce.h
platforms/reference/src/SimTKReference/ReferenceBondForce.h
+2
-7
platforms/reference/src/SimTKReference/ReferenceBondIxn.cpp
platforms/reference/src/SimTKReference/ReferenceBondIxn.cpp
+3
-42
platforms/reference/src/SimTKReference/ReferenceBondIxn.h
platforms/reference/src/SimTKReference/ReferenceBondIxn.h
+3
-22
platforms/reference/src/SimTKReference/ReferenceCMAPTorsionIxn.cpp
.../reference/src/SimTKReference/ReferenceCMAPTorsionIxn.cpp
+2
-3
platforms/reference/src/SimTKReference/ReferenceCMAPTorsionIxn.h
...ms/reference/src/SimTKReference/ReferenceCMAPTorsionIxn.h
+2
-2
platforms/reference/src/SimTKReference/ReferenceCustomAngleIxn.cpp
.../reference/src/SimTKReference/ReferenceCustomAngleIxn.cpp
+5
-16
platforms/reference/src/SimTKReference/ReferenceCustomAngleIxn.h
...ms/reference/src/SimTKReference/ReferenceCustomAngleIxn.h
+3
-4
platforms/reference/src/SimTKReference/ReferenceCustomBondIxn.cpp
...s/reference/src/SimTKReference/ReferenceCustomBondIxn.cpp
+5
-17
platforms/reference/src/SimTKReference/ReferenceCustomBondIxn.h
...rms/reference/src/SimTKReference/ReferenceCustomBondIxn.h
+3
-4
platforms/reference/src/SimTKReference/ReferenceCustomExternalIxn.cpp
...ference/src/SimTKReference/ReferenceCustomExternalIxn.cpp
+1
-11
platforms/reference/src/SimTKReference/ReferenceCustomExternalIxn.h
...reference/src/SimTKReference/ReferenceCustomExternalIxn.h
+1
-1
platforms/reference/src/SimTKReference/ReferenceCustomTorsionIxn.cpp
...eference/src/SimTKReference/ReferenceCustomTorsionIxn.cpp
+5
-17
platforms/reference/src/SimTKReference/ReferenceCustomTorsionIxn.h
.../reference/src/SimTKReference/ReferenceCustomTorsionIxn.h
+3
-4
platforms/reference/src/SimTKReference/ReferenceHarmonicBondIxn.cpp
...reference/src/SimTKReference/ReferenceHarmonicBondIxn.cpp
+5
-17
platforms/reference/src/SimTKReference/ReferenceHarmonicBondIxn.h
...s/reference/src/SimTKReference/ReferenceHarmonicBondIxn.h
+3
-5
platforms/reference/src/SimTKReference/ReferenceLJCoulomb14.cpp
...rms/reference/src/SimTKReference/ReferenceLJCoulomb14.cpp
+5
-19
No files found.
platforms/reference/src/ReferenceKernels.cpp
View file @
5003591d
...
@@ -320,21 +320,17 @@ void ReferenceCalcHarmonicBondForceKernel::executeForces(ContextImpl& context) {
...
@@ -320,21 +320,17 @@ void ReferenceCalcHarmonicBondForceKernel::executeForces(ContextImpl& context) {
RealOpenMM
**
forceData
=
extractForces
(
context
);
RealOpenMM
**
forceData
=
extractForces
(
context
);
ReferenceBondForce
refBondForce
;
ReferenceBondForce
refBondForce
;
ReferenceHarmonicBondIxn
harmonicBond
;
ReferenceHarmonicBondIxn
harmonicBond
;
refBondForce
.
calculateForce
(
numBonds
,
bondIndexArray
,
posData
,
bondParamArray
,
forceData
,
0
,
0
,
0
,
harmonicBond
);
refBondForce
.
calculateForce
(
numBonds
,
bondIndexArray
,
posData
,
bondParamArray
,
forceData
,
0
,
harmonicBond
);
}
}
double
ReferenceCalcHarmonicBondForceKernel
::
executeEnergy
(
ContextImpl
&
context
)
{
double
ReferenceCalcHarmonicBondForceKernel
::
executeEnergy
(
ContextImpl
&
context
)
{
RealOpenMM
**
posData
=
extractPositions
(
context
);
RealOpenMM
**
posData
=
extractPositions
(
context
);
RealOpenMM
**
forceData
=
allocateRealArray
(
context
.
getSystem
().
getNumParticles
(),
3
);
RealOpenMM
**
forceData
=
allocateRealArray
(
context
.
getSystem
().
getNumParticles
(),
3
);
RealOpenMM
*
energyArray
=
new
RealOpenMM
[
numBonds
];
RealOpenMM
energy
=
0
;
RealOpenMM
energy
=
0
;
ReferenceBondForce
refBondForce
;
ReferenceBondForce
refBondForce
;
ReferenceHarmonicBondIxn
harmonicBond
;
ReferenceHarmonicBondIxn
harmonicBond
;
for
(
int
i
=
0
;
i
<
numBonds
;
++
i
)
refBondForce
.
calculateForce
(
numBonds
,
bondIndexArray
,
posData
,
bondParamArray
,
forceData
,
&
energy
,
harmonicBond
);
energyArray
[
i
]
=
0
;
refBondForce
.
calculateForce
(
numBonds
,
bondIndexArray
,
posData
,
bondParamArray
,
forceData
,
energyArray
,
0
,
&
energy
,
harmonicBond
);
disposeRealArray
(
forceData
,
context
.
getSystem
().
getNumParticles
());
disposeRealArray
(
forceData
,
context
.
getSystem
().
getNumParticles
());
delete
[]
energyArray
;
return
energy
;
return
energy
;
}
}
...
@@ -380,24 +376,20 @@ void ReferenceCalcCustomBondForceKernel::executeForces(ContextImpl& context) {
...
@@ -380,24 +376,20 @@ void ReferenceCalcCustomBondForceKernel::executeForces(ContextImpl& context) {
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
ReferenceBondForce
refBondForce
;
ReferenceBondForce
refBondForce
;
ReferenceCustomBondIxn
harmonicBond
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
);
ReferenceCustomBondIxn
harmonicBond
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
);
refBondForce
.
calculateForce
(
numBonds
,
bondIndexArray
,
posData
,
bondParamArray
,
forceData
,
0
,
0
,
0
,
harmonicBond
);
refBondForce
.
calculateForce
(
numBonds
,
bondIndexArray
,
posData
,
bondParamArray
,
forceData
,
0
,
harmonicBond
);
}
}
double
ReferenceCalcCustomBondForceKernel
::
executeEnergy
(
ContextImpl
&
context
)
{
double
ReferenceCalcCustomBondForceKernel
::
executeEnergy
(
ContextImpl
&
context
)
{
RealOpenMM
**
posData
=
extractPositions
(
context
);
RealOpenMM
**
posData
=
extractPositions
(
context
);
RealOpenMM
**
forceData
=
allocateRealArray
(
context
.
getSystem
().
getNumParticles
(),
3
);
RealOpenMM
**
forceData
=
allocateRealArray
(
context
.
getSystem
().
getNumParticles
(),
3
);
RealOpenMM
*
energyArray
=
new
RealOpenMM
[
numBonds
];
RealOpenMM
energy
=
0
;
RealOpenMM
energy
=
0
;
map
<
string
,
double
>
globalParameters
;
map
<
string
,
double
>
globalParameters
;
for
(
int
i
=
0
;
i
<
(
int
)
globalParameterNames
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
globalParameterNames
.
size
();
i
++
)
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
ReferenceBondForce
refBondForce
;
ReferenceBondForce
refBondForce
;
ReferenceCustomBondIxn
harmonicBond
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
);
ReferenceCustomBondIxn
harmonicBond
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
);
for
(
int
i
=
0
;
i
<
numBonds
;
++
i
)
refBondForce
.
calculateForce
(
numBonds
,
bondIndexArray
,
posData
,
bondParamArray
,
forceData
,
&
energy
,
harmonicBond
);
energyArray
[
i
]
=
0
;
refBondForce
.
calculateForce
(
numBonds
,
bondIndexArray
,
posData
,
bondParamArray
,
forceData
,
energyArray
,
0
,
&
energy
,
harmonicBond
);
disposeRealArray
(
forceData
,
context
.
getSystem
().
getNumParticles
());
disposeRealArray
(
forceData
,
context
.
getSystem
().
getNumParticles
());
delete
[]
energyArray
;
return
energy
;
return
energy
;
}
}
...
@@ -427,21 +419,17 @@ void ReferenceCalcHarmonicAngleForceKernel::executeForces(ContextImpl& context)
...
@@ -427,21 +419,17 @@ void ReferenceCalcHarmonicAngleForceKernel::executeForces(ContextImpl& context)
RealOpenMM
**
forceData
=
extractForces
(
context
);
RealOpenMM
**
forceData
=
extractForces
(
context
);
ReferenceBondForce
refBondForce
;
ReferenceBondForce
refBondForce
;
ReferenceAngleBondIxn
angleBond
;
ReferenceAngleBondIxn
angleBond
;
refBondForce
.
calculateForce
(
numAngles
,
angleIndexArray
,
posData
,
angleParamArray
,
forceData
,
0
,
0
,
0
,
angleBond
);
refBondForce
.
calculateForce
(
numAngles
,
angleIndexArray
,
posData
,
angleParamArray
,
forceData
,
0
,
angleBond
);
}
}
double
ReferenceCalcHarmonicAngleForceKernel
::
executeEnergy
(
ContextImpl
&
context
)
{
double
ReferenceCalcHarmonicAngleForceKernel
::
executeEnergy
(
ContextImpl
&
context
)
{
RealOpenMM
**
posData
=
extractPositions
(
context
);
RealOpenMM
**
posData
=
extractPositions
(
context
);
RealOpenMM
**
forceData
=
allocateRealArray
(
context
.
getSystem
().
getNumParticles
(),
3
);
RealOpenMM
**
forceData
=
allocateRealArray
(
context
.
getSystem
().
getNumParticles
(),
3
);
RealOpenMM
*
energyArray
=
new
RealOpenMM
[
numAngles
];
RealOpenMM
energy
=
0
;
RealOpenMM
energy
=
0
;
ReferenceBondForce
refBondForce
;
ReferenceBondForce
refBondForce
;
ReferenceAngleBondIxn
angleBond
;
ReferenceAngleBondIxn
angleBond
;
for
(
int
i
=
0
;
i
<
numAngles
;
++
i
)
refBondForce
.
calculateForce
(
numAngles
,
angleIndexArray
,
posData
,
angleParamArray
,
forceData
,
&
energy
,
angleBond
);
energyArray
[
i
]
=
0
;
refBondForce
.
calculateForce
(
numAngles
,
angleIndexArray
,
posData
,
angleParamArray
,
forceData
,
energyArray
,
0
,
&
energy
,
angleBond
);
disposeRealArray
(
forceData
,
context
.
getSystem
().
getNumParticles
());
disposeRealArray
(
forceData
,
context
.
getSystem
().
getNumParticles
());
delete
[]
energyArray
;
return
energy
;
return
energy
;
}
}
...
@@ -488,24 +476,20 @@ void ReferenceCalcCustomAngleForceKernel::executeForces(ContextImpl& context) {
...
@@ -488,24 +476,20 @@ void ReferenceCalcCustomAngleForceKernel::executeForces(ContextImpl& context) {
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
ReferenceBondForce
refBondForce
;
ReferenceBondForce
refBondForce
;
ReferenceCustomAngleIxn
customAngle
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
);
ReferenceCustomAngleIxn
customAngle
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
);
refBondForce
.
calculateForce
(
numAngles
,
angleIndexArray
,
posData
,
angleParamArray
,
forceData
,
0
,
0
,
0
,
customAngle
);
refBondForce
.
calculateForce
(
numAngles
,
angleIndexArray
,
posData
,
angleParamArray
,
forceData
,
0
,
customAngle
);
}
}
double
ReferenceCalcCustomAngleForceKernel
::
executeEnergy
(
ContextImpl
&
context
)
{
double
ReferenceCalcCustomAngleForceKernel
::
executeEnergy
(
ContextImpl
&
context
)
{
RealOpenMM
**
posData
=
extractPositions
(
context
);
RealOpenMM
**
posData
=
extractPositions
(
context
);
RealOpenMM
**
forceData
=
allocateRealArray
(
context
.
getSystem
().
getNumParticles
(),
3
);
RealOpenMM
**
forceData
=
allocateRealArray
(
context
.
getSystem
().
getNumParticles
(),
3
);
RealOpenMM
*
energyArray
=
new
RealOpenMM
[
numAngles
];
RealOpenMM
energy
=
0
;
RealOpenMM
energy
=
0
;
map
<
string
,
double
>
globalParameters
;
map
<
string
,
double
>
globalParameters
;
for
(
int
i
=
0
;
i
<
(
int
)
globalParameterNames
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
globalParameterNames
.
size
();
i
++
)
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
ReferenceBondForce
refBondForce
;
ReferenceBondForce
refBondForce
;
ReferenceCustomAngleIxn
customAngle
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
);
ReferenceCustomAngleIxn
customAngle
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
);
for
(
int
i
=
0
;
i
<
numAngles
;
++
i
)
refBondForce
.
calculateForce
(
numAngles
,
angleIndexArray
,
posData
,
angleParamArray
,
forceData
,
&
energy
,
customAngle
);
energyArray
[
i
]
=
0
;
refBondForce
.
calculateForce
(
numAngles
,
angleIndexArray
,
posData
,
angleParamArray
,
forceData
,
energyArray
,
0
,
&
energy
,
customAngle
);
disposeRealArray
(
forceData
,
context
.
getSystem
().
getNumParticles
());
disposeRealArray
(
forceData
,
context
.
getSystem
().
getNumParticles
());
delete
[]
energyArray
;
return
energy
;
return
energy
;
}
}
...
@@ -537,21 +521,17 @@ void ReferenceCalcPeriodicTorsionForceKernel::executeForces(ContextImpl& context
...
@@ -537,21 +521,17 @@ void ReferenceCalcPeriodicTorsionForceKernel::executeForces(ContextImpl& context
RealOpenMM
**
forceData
=
extractForces
(
context
);
RealOpenMM
**
forceData
=
extractForces
(
context
);
ReferenceBondForce
refBondForce
;
ReferenceBondForce
refBondForce
;
ReferenceProperDihedralBond
periodicTorsionBond
;
ReferenceProperDihedralBond
periodicTorsionBond
;
refBondForce
.
calculateForce
(
numTorsions
,
torsionIndexArray
,
posData
,
torsionParamArray
,
forceData
,
0
,
0
,
0
,
periodicTorsionBond
);
refBondForce
.
calculateForce
(
numTorsions
,
torsionIndexArray
,
posData
,
torsionParamArray
,
forceData
,
0
,
periodicTorsionBond
);
}
}
double
ReferenceCalcPeriodicTorsionForceKernel
::
executeEnergy
(
ContextImpl
&
context
)
{
double
ReferenceCalcPeriodicTorsionForceKernel
::
executeEnergy
(
ContextImpl
&
context
)
{
RealOpenMM
**
posData
=
extractPositions
(
context
);
RealOpenMM
**
posData
=
extractPositions
(
context
);
RealOpenMM
**
forceData
=
allocateRealArray
(
context
.
getSystem
().
getNumParticles
(),
3
);
RealOpenMM
**
forceData
=
allocateRealArray
(
context
.
getSystem
().
getNumParticles
(),
3
);
RealOpenMM
*
energyArray
=
new
RealOpenMM
[
numTorsions
];
RealOpenMM
energy
=
0
;
RealOpenMM
energy
=
0
;
ReferenceBondForce
refBondForce
;
ReferenceBondForce
refBondForce
;
ReferenceProperDihedralBond
periodicTorsionBond
;
ReferenceProperDihedralBond
periodicTorsionBond
;
for
(
int
i
=
0
;
i
<
numTorsions
;
++
i
)
refBondForce
.
calculateForce
(
numTorsions
,
torsionIndexArray
,
posData
,
torsionParamArray
,
forceData
,
&
energy
,
periodicTorsionBond
);
energyArray
[
i
]
=
0
;
refBondForce
.
calculateForce
(
numTorsions
,
torsionIndexArray
,
posData
,
torsionParamArray
,
forceData
,
energyArray
,
0
,
&
energy
,
periodicTorsionBond
);
disposeRealArray
(
forceData
,
context
.
getSystem
().
getNumParticles
());
disposeRealArray
(
forceData
,
context
.
getSystem
().
getNumParticles
());
delete
[]
energyArray
;
return
energy
;
return
energy
;
}
}
...
@@ -586,21 +566,17 @@ void ReferenceCalcRBTorsionForceKernel::executeForces(ContextImpl& context) {
...
@@ -586,21 +566,17 @@ void ReferenceCalcRBTorsionForceKernel::executeForces(ContextImpl& context) {
RealOpenMM
**
forceData
=
extractForces
(
context
);
RealOpenMM
**
forceData
=
extractForces
(
context
);
ReferenceBondForce
refBondForce
;
ReferenceBondForce
refBondForce
;
ReferenceRbDihedralBond
rbTorsionBond
;
ReferenceRbDihedralBond
rbTorsionBond
;
refBondForce
.
calculateForce
(
numTorsions
,
torsionIndexArray
,
posData
,
torsionParamArray
,
forceData
,
0
,
0
,
0
,
rbTorsionBond
);
refBondForce
.
calculateForce
(
numTorsions
,
torsionIndexArray
,
posData
,
torsionParamArray
,
forceData
,
0
,
rbTorsionBond
);
}
}
double
ReferenceCalcRBTorsionForceKernel
::
executeEnergy
(
ContextImpl
&
context
)
{
double
ReferenceCalcRBTorsionForceKernel
::
executeEnergy
(
ContextImpl
&
context
)
{
RealOpenMM
**
posData
=
extractPositions
(
context
);
RealOpenMM
**
posData
=
extractPositions
(
context
);
RealOpenMM
**
forceData
=
allocateRealArray
(
context
.
getSystem
().
getNumParticles
(),
3
);
RealOpenMM
**
forceData
=
allocateRealArray
(
context
.
getSystem
().
getNumParticles
(),
3
);
RealOpenMM
*
energyArray
=
new
RealOpenMM
[
numTorsions
];
RealOpenMM
energy
=
0
;
RealOpenMM
energy
=
0
;
ReferenceBondForce
refBondForce
;
ReferenceBondForce
refBondForce
;
ReferenceRbDihedralBond
rbTorsionBond
;
ReferenceRbDihedralBond
rbTorsionBond
;
for
(
int
i
=
0
;
i
<
numTorsions
;
++
i
)
refBondForce
.
calculateForce
(
numTorsions
,
torsionIndexArray
,
posData
,
torsionParamArray
,
forceData
,
&
energy
,
rbTorsionBond
);
energyArray
[
i
]
=
0
;
refBondForce
.
calculateForce
(
numTorsions
,
torsionIndexArray
,
posData
,
torsionParamArray
,
forceData
,
energyArray
,
0
,
&
energy
,
rbTorsionBond
);
disposeRealArray
(
forceData
,
context
.
getSystem
().
getNumParticles
());
disposeRealArray
(
forceData
,
context
.
getSystem
().
getNumParticles
());
delete
[]
energyArray
;
return
energy
;
return
energy
;
}
}
...
@@ -690,24 +666,20 @@ void ReferenceCalcCustomTorsionForceKernel::executeForces(ContextImpl& context)
...
@@ -690,24 +666,20 @@ void ReferenceCalcCustomTorsionForceKernel::executeForces(ContextImpl& context)
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
ReferenceBondForce
refBondForce
;
ReferenceBondForce
refBondForce
;
ReferenceCustomTorsionIxn
customTorsion
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
);
ReferenceCustomTorsionIxn
customTorsion
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
);
refBondForce
.
calculateForce
(
numTorsions
,
torsionIndexArray
,
posData
,
torsionParamArray
,
forceData
,
0
,
0
,
0
,
customTorsion
);
refBondForce
.
calculateForce
(
numTorsions
,
torsionIndexArray
,
posData
,
torsionParamArray
,
forceData
,
0
,
customTorsion
);
}
}
double
ReferenceCalcCustomTorsionForceKernel
::
executeEnergy
(
ContextImpl
&
context
)
{
double
ReferenceCalcCustomTorsionForceKernel
::
executeEnergy
(
ContextImpl
&
context
)
{
RealOpenMM
**
posData
=
extractPositions
(
context
);
RealOpenMM
**
posData
=
extractPositions
(
context
);
RealOpenMM
**
forceData
=
allocateRealArray
(
context
.
getSystem
().
getNumParticles
(),
3
);
RealOpenMM
**
forceData
=
allocateRealArray
(
context
.
getSystem
().
getNumParticles
(),
3
);
RealOpenMM
*
energyArray
=
new
RealOpenMM
[
numTorsions
];
RealOpenMM
energy
=
0
;
RealOpenMM
energy
=
0
;
map
<
string
,
double
>
globalParameters
;
map
<
string
,
double
>
globalParameters
;
for
(
int
i
=
0
;
i
<
(
int
)
globalParameterNames
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
globalParameterNames
.
size
();
i
++
)
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
ReferenceBondForce
refBondForce
;
ReferenceBondForce
refBondForce
;
ReferenceCustomTorsionIxn
customTorsion
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
);
ReferenceCustomTorsionIxn
customTorsion
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
);
for
(
int
i
=
0
;
i
<
numTorsions
;
++
i
)
refBondForce
.
calculateForce
(
numTorsions
,
torsionIndexArray
,
posData
,
torsionParamArray
,
forceData
,
&
energy
,
customTorsion
);
energyArray
[
i
]
=
0
;
refBondForce
.
calculateForce
(
numTorsions
,
torsionIndexArray
,
posData
,
torsionParamArray
,
forceData
,
energyArray
,
0
,
&
energy
,
customTorsion
);
disposeRealArray
(
forceData
,
context
.
getSystem
().
getNumParticles
());
disposeRealArray
(
forceData
,
context
.
getSystem
().
getNumParticles
());
delete
[]
energyArray
;
return
energy
;
return
energy
;
}
}
...
@@ -812,7 +784,7 @@ void ReferenceCalcNonbondedForceKernel::executeForces(ContextImpl& context) {
...
@@ -812,7 +784,7 @@ void ReferenceCalcNonbondedForceKernel::executeForces(ContextImpl& context) {
clj
.
calculatePairIxn
(
numParticles
,
posData
,
particleParamArray
,
exclusionArray
,
0
,
forceData
,
0
,
0
);
clj
.
calculatePairIxn
(
numParticles
,
posData
,
particleParamArray
,
exclusionArray
,
0
,
forceData
,
0
,
0
);
ReferenceBondForce
refBondForce
;
ReferenceBondForce
refBondForce
;
ReferenceLJCoulomb14
nonbonded14
;
ReferenceLJCoulomb14
nonbonded14
;
refBondForce
.
calculateForce
(
num14
,
bonded14IndexArray
,
posData
,
bonded14ParamArray
,
forceData
,
0
,
0
,
0
,
nonbonded14
);
refBondForce
.
calculateForce
(
num14
,
bonded14IndexArray
,
posData
,
bonded14ParamArray
,
forceData
,
0
,
nonbonded14
);
}
}
double
ReferenceCalcNonbondedForceKernel
::
executeEnergy
(
ContextImpl
&
context
)
{
double
ReferenceCalcNonbondedForceKernel
::
executeEnergy
(
ContextImpl
&
context
)
{
...
@@ -836,12 +808,8 @@ double ReferenceCalcNonbondedForceKernel::executeEnergy(ContextImpl& context) {
...
@@ -836,12 +808,8 @@ double ReferenceCalcNonbondedForceKernel::executeEnergy(ContextImpl& context) {
clj
.
calculatePairIxn
(
numParticles
,
posData
,
particleParamArray
,
exclusionArray
,
0
,
forceData
,
0
,
&
energy
);
clj
.
calculatePairIxn
(
numParticles
,
posData
,
particleParamArray
,
exclusionArray
,
0
,
forceData
,
0
,
&
energy
);
ReferenceBondForce
refBondForce
;
ReferenceBondForce
refBondForce
;
ReferenceLJCoulomb14
nonbonded14
;
ReferenceLJCoulomb14
nonbonded14
;
RealOpenMM
*
energyArray
=
new
RealOpenMM
[
num14
];
refBondForce
.
calculateForce
(
num14
,
bonded14IndexArray
,
posData
,
bonded14ParamArray
,
forceData
,
&
energy
,
nonbonded14
);
for
(
int
i
=
0
;
i
<
num14
;
++
i
)
energyArray
[
i
]
=
0
;
refBondForce
.
calculateForce
(
num14
,
bonded14IndexArray
,
posData
,
bonded14ParamArray
,
forceData
,
energyArray
,
0
,
&
energy
,
nonbonded14
);
disposeRealArray
(
forceData
,
numParticles
);
disposeRealArray
(
forceData
,
numParticles
);
delete
[]
energyArray
;
if
(
periodic
||
ewald
||
pme
)
{
if
(
periodic
||
ewald
||
pme
)
{
RealOpenMM
*
boxSize
=
extractBoxSize
(
context
);
RealOpenMM
*
boxSize
=
extractBoxSize
(
context
);
energy
+=
dispersionCoefficient
/
(
boxSize
[
0
]
*
boxSize
[
1
]
*
boxSize
[
2
]);
energy
+=
dispersionCoefficient
/
(
boxSize
[
0
]
*
boxSize
[
1
]
*
boxSize
[
2
]);
...
...
platforms/reference/src/SimTKReference/ReferenceAngleBondIxn.cpp
View file @
5003591d
...
@@ -117,27 +117,15 @@ int ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine( RealOpenMM cosine, Rea
...
@@ -117,27 +117,15 @@ int ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine( RealOpenMM cosine, Rea
@param parameters parameters: parameters[0] = ideal bond length
@param parameters parameters: parameters[0] = ideal bond length
parameters[1] = bond k (includes factor of 2)
parameters[1] = bond k (includes factor of 2)
@param forces force array (forces added)
@param forces force array (forces added)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param totalEnergy if not null, the energy will be added to this
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceAngleBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceAngleBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
totalEnergy
)
const
{
RealOpenMM
*
energiesByAtom
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceAngleBondIxn::calculateBondIxn";
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"
\n
ReferenceAngleBondIxn::calculateBondIxn"
;
// constants -- reduce Visual Studio warnings regarding conversions between float & double
// constants -- reduce Visual Studio warnings regarding conversions between float & double
...
@@ -200,7 +188,6 @@ int ReferenceAngleBondIxn::calculateBondIxn( int* atomIndices,
...
@@ -200,7 +188,6 @@ int ReferenceAngleBondIxn::calculateBondIxn( int* atomIndices,
// accumulate energies
// accumulate energies
updateEnergy
(
energy
,
energiesByBond
,
LastAtomIndex
,
atomIndices
,
energiesByAtom
);
if
(
totalEnergy
!=
NULL
)
*
totalEnergy
+=
energy
;
return
ReferenceForce
::
DefaultReturn
;
}
}
platforms/reference/src/SimTKReference/ReferenceAngleBondIxn.h
View file @
5003591d
...
@@ -77,16 +77,13 @@ class ReferenceAngleBondIxn : public ReferenceBondIxn {
...
@@ -77,16 +77,13 @@ class ReferenceAngleBondIxn : public ReferenceBondIxn {
@param parameters parameters: parameters[0] = ideal bond length
@param parameters parameters: parameters[0] = ideal bond length
parameters[1] = bond k (includes factor of 2)
parameters[1] = bond k (includes factor of 2)
@param forces force array (forces added)
@param forces force array (forces added)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param totalEnergy if not null, the energy will be added to this
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
void
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
energiesByAtom
)
const
;
RealOpenMM
*
totalEnergy
)
const
;
};
};
...
...
platforms/reference/src/SimTKReference/ReferenceBondForce.cpp
View file @
5003591d
...
@@ -72,21 +72,15 @@ ReferenceBondForce::~ReferenceBondForce( ){
...
@@ -72,21 +72,15 @@ ReferenceBondForce::~ReferenceBondForce( ){
@param parameters parameters: parameters[bondIndex][*]; contents of array
@param parameters parameters: parameters[bondIndex][*]; contents of array
depend on ixn
depend on ixn
@param forces force array (forces added to current values): forces[atomIndex][3]
@param forces force array (forces added to current values): forces[atomIndex][3]
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param totalEnergy if not null, the energy will be added to this
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@param totalEnergy totalEnergy: sum over { energies[atomIndex] }
@param ReferenceBondIxn ixn to be calculated
@param ReferenceBondIxn ixn to be calculated
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceBondForce
::
calculateForce
(
int
numberOfBonds
,
int
**
atomIndices
,
void
ReferenceBondForce
::
calculateForce
(
int
numberOfBonds
,
int
**
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
parameters
,
RealOpenMM
**
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
energiesByAtom
,
RealOpenMM
*
totalEnergy
,
RealOpenMM
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
){
ReferenceBondIxn
&
referenceBondIxn
){
...
@@ -102,13 +96,7 @@ int ReferenceBondForce::calculateForce( int numberOfBonds, int** atomIndices,
...
@@ -102,13 +96,7 @@ int ReferenceBondForce::calculateForce( int numberOfBonds, int** atomIndices,
// calculate bond ixn
// calculate bond ixn
referenceBondIxn
.
calculateBondIxn
(
atomIndices
[
ii
],
atomCoordinates
,
parameters
[
ii
],
referenceBondIxn
.
calculateBondIxn
(
atomIndices
[
ii
],
atomCoordinates
,
parameters
[
ii
],
forces
,
(
energiesByBond
==
NULL
?
NULL
:
energiesByBond
+
ii
),
energiesByAtom
);
forces
,
totalEnergy
);
if
(
energiesByBond
!=
NULL
){
*
totalEnergy
+=
energiesByBond
[
ii
];
}
}
}
return
ReferenceForce
::
DefaultReturn
;
}
}
platforms/reference/src/SimTKReference/ReferenceBondForce.h
View file @
5003591d
...
@@ -62,19 +62,14 @@ class OPENMM_EXPORT ReferenceBondForce : public ReferenceForce {
...
@@ -62,19 +62,14 @@ class OPENMM_EXPORT ReferenceBondForce : public ReferenceForce {
@param parameters parameters: parameters[bondIndex][*]; contents of array
@param parameters parameters: parameters[bondIndex][*]; contents of array
depend on ixn
depend on ixn
@param forces force array (forces added to current values): forces[atomIndex][3]
@param forces force array (forces added to current values): forces[atomIndex][3]
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param totalEnergy if not null, the energy will be added to this
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@param totalEnergy totalEnergy: sum over { energies[atomIndex] }
@param ReferenceBondIxn ixn to be calculated
@param ReferenceBondIxn ixn to be calculated
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
calculateForce
(
int
numberOfBonds
,
int
**
atomIndices
,
void
calculateForce
(
int
numberOfBonds
,
int
**
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
**
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
energiesByAtom
,
RealOpenMM
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
);
RealOpenMM
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
);
};
};
...
...
platforms/reference/src/SimTKReference/ReferenceBondIxn.cpp
View file @
5003591d
...
@@ -63,42 +63,6 @@ ReferenceBondIxn::~ReferenceBondIxn( ){
...
@@ -63,42 +63,6 @@ ReferenceBondIxn::~ReferenceBondIxn( ){
}
}
/**---------------------------------------------------------------------------------------
Update energy
@param energy energy value to update
@param energyByBond ptr to energyByBond accumulator (may be null)
@param numberOfAtomIndices number of atoms in bond
@param atomIndices array of atom indices of size 'numberOfAtomIndices'
@param energyByAtom array of energies by atom (may be null)
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceBondIxn
::
updateEnergy
(
RealOpenMM
energy
,
RealOpenMM
*
energyByBond
,
int
numberOfAtomIndices
,
int
*
atomIndices
,
RealOpenMM
*
energyByAtom
)
const
{
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceBondIxn::updateEnergy";
// ---------------------------------------------------------------------------------------
if
(
energyByBond
){
*
energyByBond
+=
energy
;
}
if
(
energyByAtom
){
for
(
int
ii
=
0
;
ii
<
numberOfAtomIndices
;
ii
++
){
energyByAtom
[
atomIndices
[
ii
]]
+=
energy
;
}
}
return
ReferenceForce
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Calculate Bond Ixn -- virtual method -- does nothing
Calculate Bond Ixn -- virtual method -- does nothing
...
@@ -107,22 +71,19 @@ int ReferenceBondIxn::updateEnergy( RealOpenMM energy, RealOpenMM* energyByBond,
...
@@ -107,22 +71,19 @@ int ReferenceBondIxn::updateEnergy( RealOpenMM energy, RealOpenMM* energyByBond,
@param atomCoordinates atom coordinates
@param atomCoordinates atom coordinates
@param parameters parameters
@param parameters parameters
@param forces force array (forces added)
@param forces force array (forces added)
@param energyByBond bond energy
@param totalEnergy if not null, the energy will be added to this
@param energy atom energy
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
void
ReferenceBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energyByBond
,
RealOpenMM
*
energyByAtom
)
const
{
RealOpenMM
*
totalEnergy
)
const
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceBondIxn::calculateBondIxn";
// static const std::string methodName = "\nReferenceBondIxn::calculateBondIxn";
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
return
ReferenceForce
::
DefaultReturn
;
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
...
platforms/reference/src/SimTKReference/ReferenceBondIxn.h
View file @
5003591d
...
@@ -59,32 +59,13 @@ class OPENMM_EXPORT ReferenceBondIxn {
...
@@ -59,32 +59,13 @@ class OPENMM_EXPORT ReferenceBondIxn {
@param atomCoordinates atom coordinates
@param atomCoordinates atom coordinates
@param parameters parameters
@param parameters parameters
@param forces force array (forces added)
@param forces force array (forces added)
@param energyByBond bond energy
@param totalEnergy if not null, the energy will be added to this
@param energy atom energy
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
virtual
int
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
virtual
void
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energyByBond
,
RealOpenMM
*
energyByAtom
)
const
;
RealOpenMM
*
totalEnergy
)
const
;
/**---------------------------------------------------------------------------------------
Update energy
@param energy energy value to update
@param energyByBond ptr to energyByBond accumulator (may be null)
@param numberOfAtomIndices number of atoms in bond
@param atomIndices array of atom indices of size 'numberOfAtomIndices'
@param energyByAtom array of energies by atom (may be null)
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
updateEnergy
(
RealOpenMM
energy
,
RealOpenMM
*
energyByBond
,
int
numberOfAtomIndices
,
int
*
atomIndices
,
RealOpenMM
*
energyByAtom
)
const
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
...
platforms/reference/src/SimTKReference/ReferenceCMAPTorsionIxn.cpp
View file @
5003591d
...
@@ -188,7 +188,6 @@ void ReferenceCMAPTorsionIxn::calculateOneIxn(int index, RealOpenMM** atomCoordi
...
@@ -188,7 +188,6 @@ void ReferenceCMAPTorsionIxn::calculateOneIxn(int index, RealOpenMM** atomCoordi
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceCMAPTorsionIxn
::
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
void
ReferenceCMAPTorsionIxn
::
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energyByBond
,
RealOpenMM
*
energyByAtom
)
const
{
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
totalEnergy
)
const
{
return
ReferenceForce
::
DefaultReturn
;
}
}
platforms/reference/src/SimTKReference/ReferenceCMAPTorsionIxn.h
View file @
5003591d
...
@@ -84,9 +84,9 @@ public:
...
@@ -84,9 +84,9 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
void
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energyByBond
,
RealOpenMM
*
energyByAtom
)
const
;
RealOpenMM
*
totalEnergy
)
const
;
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
...
platforms/reference/src/SimTKReference/ReferenceCustomAngleIxn.cpp
View file @
5003591d
...
@@ -74,25 +74,15 @@ ReferenceCustomAngleIxn::~ReferenceCustomAngleIxn( ){
...
@@ -74,25 +74,15 @@ ReferenceCustomAngleIxn::~ReferenceCustomAngleIxn( ){
@param atomCoordinates atom coordinates
@param atomCoordinates atom coordinates
@param parameters parameters values
@param parameters parameters values
@param forces force array (forces added to input values)
@param forces force array (forces added to input values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param totalEnergy if not null, the energy will be added to this
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceCustomAngleIxn
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceCustomAngleIxn
::
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
totalEnergy
)
const
{
RealOpenMM
*
energiesByAtom
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceCustomAngleIxn::calculateAngleIxn";
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"
\n
ReferenceCustomAngleIxn::calculateAngleIxn"
;
static
const
std
::
string
methodName
=
"
\n
ReferenceCustomAngleIxn::calculateAngleIxn"
;
...
@@ -156,8 +146,7 @@ int ReferenceCustomAngleIxn::calculateBondIxn( int* atomIndices,
...
@@ -156,8 +146,7 @@ int ReferenceCustomAngleIxn::calculateBondIxn( int* atomIndices,
// accumulate energies
// accumulate energies
updateEnergy
(
energy
,
energiesByBond
,
3
,
atomIndices
,
energiesByAtom
);
if
(
totalEnergy
!=
NULL
)
*
totalEnergy
+=
energy
;
return
ReferenceForce
::
DefaultReturn
;
}
}
platforms/reference/src/SimTKReference/ReferenceCustomAngleIxn.h
View file @
5003591d
...
@@ -64,14 +64,13 @@ class ReferenceCustomAngleIxn : public ReferenceBondIxn {
...
@@ -64,14 +64,13 @@ class ReferenceCustomAngleIxn : public ReferenceBondIxn {
@param atomCoordinates atom coordinates
@param atomCoordinates atom coordinates
@param parameters parameter values
@param parameters parameter values
@param forces force array (forces added)
@param forces force array (forces added)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param totalEnergy if not null, the energy will be added to this
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
void
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
energiesByAtom
)
const
;
RealOpenMM
*
totalEnergy
)
const
;
};
};
...
...
platforms/reference/src/SimTKReference/ReferenceCustomBondIxn.cpp
View file @
5003591d
...
@@ -75,25 +75,15 @@ ReferenceCustomBondIxn::~ReferenceCustomBondIxn( ){
...
@@ -75,25 +75,15 @@ ReferenceCustomBondIxn::~ReferenceCustomBondIxn( ){
@param atomCoordinates atom coordinates
@param atomCoordinates atom coordinates
@param parameters parameters values
@param parameters parameters values
@param forces force array (forces added to input values)
@param forces force array (forces added to input values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param totalEnergy if not null, the energy will be added to this
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceCustomBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceCustomBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
totalEnergy
)
const
{
RealOpenMM
*
energiesByAtom
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceCustomBondIxn::calculateBondIxn";
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"
\n
ReferenceCustomBondIxn::calculateBondIxn"
;
static
const
std
::
string
methodName
=
"
\n
ReferenceCustomBondIxn::calculateBondIxn"
;
...
@@ -127,8 +117,6 @@ int ReferenceCustomBondIxn::calculateBondIxn( int* atomIndices,
...
@@ -127,8 +117,6 @@ int ReferenceCustomBondIxn::calculateBondIxn( int* atomIndices,
forces
[
atomBIndex
][
1
]
-=
dEdR
*
deltaR
[
ReferenceForce
::
YIndex
];
forces
[
atomBIndex
][
1
]
-=
dEdR
*
deltaR
[
ReferenceForce
::
YIndex
];
forces
[
atomBIndex
][
2
]
-=
dEdR
*
deltaR
[
ReferenceForce
::
ZIndex
];
forces
[
atomBIndex
][
2
]
-=
dEdR
*
deltaR
[
ReferenceForce
::
ZIndex
];
RealOpenMM
energy
=
(
RealOpenMM
)
energyExpression
.
evaluate
(
variables
);
if
(
totalEnergy
!=
NULL
)
updateEnergy
(
energy
,
energiesByBond
,
twoI
,
atomIndices
,
energiesByAtom
);
*
totalEnergy
+=
(
RealOpenMM
)
energyExpression
.
evaluate
(
variables
);
return
ReferenceForce
::
DefaultReturn
;
}
}
platforms/reference/src/SimTKReference/ReferenceCustomBondIxn.h
View file @
5003591d
...
@@ -65,14 +65,13 @@ class ReferenceCustomBondIxn : public ReferenceBondIxn {
...
@@ -65,14 +65,13 @@ class ReferenceCustomBondIxn : public ReferenceBondIxn {
@param atomCoordinates atom coordinates
@param atomCoordinates atom coordinates
@param parameters parameter values
@param parameters parameter values
@param forces force array (forces added)
@param forces force array (forces added)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param totalEnergy if not null, the energy will be added to this
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
void
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
energiesByAtom
)
const
;
RealOpenMM
*
totalEnergy
)
const
;
};
};
...
...
platforms/reference/src/SimTKReference/ReferenceCustomExternalIxn.cpp
View file @
5003591d
...
@@ -79,22 +79,14 @@ ReferenceCustomExternalIxn::~ReferenceCustomExternalIxn( ){
...
@@ -79,22 +79,14 @@ ReferenceCustomExternalIxn::~ReferenceCustomExternalIxn( ){
@param forces force array (forces added to input values)
@param forces force array (forces added to input values)
@param energy energy is added to this
@param energy energy is added to this
@return ReferenceForce::DefaultReturn;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceCustomExternalIxn
::
calculateForce
(
int
atomIndex
,
void
ReferenceCustomExternalIxn
::
calculateForce
(
int
atomIndex
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
**
forces
,
RealOpenMM
*
energy
)
const
{
RealOpenMM
*
energy
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceCustomExternalIxn::calculateBondIxn";
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"
\n
ReferenceCustomExternalIxn::calculateBondIxn"
;
static
const
std
::
string
methodName
=
"
\n
ReferenceCustomExternalIxn::calculateBondIxn"
;
map
<
string
,
double
>
variables
=
globalParameters
;
map
<
string
,
double
>
variables
=
globalParameters
;
...
@@ -111,6 +103,4 @@ int ReferenceCustomExternalIxn::calculateForce( int atomIndex,
...
@@ -111,6 +103,4 @@ int ReferenceCustomExternalIxn::calculateForce( int atomIndex,
forces
[
atomIndex
][
2
]
-=
(
RealOpenMM
)
forceExpressionZ
.
evaluate
(
variables
);
forces
[
atomIndex
][
2
]
-=
(
RealOpenMM
)
forceExpressionZ
.
evaluate
(
variables
);
if
(
energy
!=
NULL
)
if
(
energy
!=
NULL
)
*
energy
+=
(
RealOpenMM
)
energyExpression
.
evaluate
(
variables
);
*
energy
+=
(
RealOpenMM
)
energyExpression
.
evaluate
(
variables
);
return
ReferenceForce
::
DefaultReturn
;
}
}
platforms/reference/src/SimTKReference/ReferenceCustomExternalIxn.h
View file @
5003591d
...
@@ -72,7 +72,7 @@ class ReferenceCustomExternalIxn {
...
@@ -72,7 +72,7 @@ class ReferenceCustomExternalIxn {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
calculateForce
(
int
atomIndex
,
RealOpenMM
**
atomCoordinates
,
void
calculateForce
(
int
atomIndex
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energy
)
const
;
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energy
)
const
;
...
...
platforms/reference/src/SimTKReference/ReferenceCustomTorsionIxn.cpp
View file @
5003591d
...
@@ -74,25 +74,15 @@ ReferenceCustomTorsionIxn::~ReferenceCustomTorsionIxn( ){
...
@@ -74,25 +74,15 @@ ReferenceCustomTorsionIxn::~ReferenceCustomTorsionIxn( ){
@param atomCoordinates atom coordinates
@param atomCoordinates atom coordinates
@param parameters parameters values
@param parameters parameters values
@param forces force array (forces added to input values)
@param forces force array (forces added to input values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param totalEnergy if not null, the energy will be added to this
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceCustomTorsionIxn
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceCustomTorsionIxn
::
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
totalEnergy
)
const
{
RealOpenMM
*
energiesByAtom
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceCustomTorsionIxn::calculateTorsionIxn";
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"
\n
ReferenceCustomTorsionIxn::calculateTorsionIxn"
;
static
const
std
::
string
methodName
=
"
\n
ReferenceCustomTorsionIxn::calculateTorsionIxn"
;
...
@@ -133,7 +123,6 @@ int ReferenceCustomTorsionIxn::calculateBondIxn( int* atomIndices,
...
@@ -133,7 +123,6 @@ int ReferenceCustomTorsionIxn::calculateBondIxn( int* atomIndices,
// evaluate delta angle, dE/d(angle)
// evaluate delta angle, dE/d(angle)
RealOpenMM
energy
=
(
RealOpenMM
)
energyExpression
.
evaluate
(
variables
);
RealOpenMM
dEdAngle
=
(
RealOpenMM
)
forceExpression
.
evaluate
(
variables
);
RealOpenMM
dEdAngle
=
(
RealOpenMM
)
forceExpression
.
evaluate
(
variables
);
// compute force
// compute force
...
@@ -175,8 +164,7 @@ int ReferenceCustomTorsionIxn::calculateBondIxn( int* atomIndices,
...
@@ -175,8 +164,7 @@ int ReferenceCustomTorsionIxn::calculateBondIxn( int* atomIndices,
// accumulate energies
// accumulate energies
updateEnergy
(
energy
,
energiesByBond
,
4
,
atomIndices
,
energiesByAtom
);
if
(
totalEnergy
!=
NULL
)
*
totalEnergy
+=
(
RealOpenMM
)
energyExpression
.
evaluate
(
variables
);
return
ReferenceForce
::
DefaultReturn
;
}
}
platforms/reference/src/SimTKReference/ReferenceCustomTorsionIxn.h
View file @
5003591d
...
@@ -64,14 +64,13 @@ class ReferenceCustomTorsionIxn : public ReferenceBondIxn {
...
@@ -64,14 +64,13 @@ class ReferenceCustomTorsionIxn : public ReferenceBondIxn {
@param atomCoordinates atom coordinates
@param atomCoordinates atom coordinates
@param parameters parameter values
@param parameters parameter values
@param forces force array (forces added)
@param forces force array (forces added)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param totalEnergy if not null, the energy will be added to this
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
void
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
energiesByAtom
)
const
;
RealOpenMM
*
totalEnergy
)
const
;
};
};
...
...
platforms/reference/src/SimTKReference/ReferenceHarmonicBondIxn.cpp
View file @
5003591d
...
@@ -72,25 +72,15 @@ ReferenceHarmonicBondIxn::~ReferenceHarmonicBondIxn( ){
...
@@ -72,25 +72,15 @@ ReferenceHarmonicBondIxn::~ReferenceHarmonicBondIxn( ){
@param parameters parameters: parameters[0] = ideal bond length
@param parameters parameters: parameters[0] = ideal bond length
parameters[1] = bond k
parameters[1] = bond k
@param forces force array (forces added to input values)
@param forces force array (forces added to input values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param totalEnergy if not null, the energy will be added to this
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceHarmonicBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceHarmonicBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
totalEnergy
)
const
{
RealOpenMM
*
energiesByAtom
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceHarmonicBondIxn::calculateBondIxn";
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"
\n
ReferenceHarmonicBondIxn::calculateBondIxn"
;
static
const
std
::
string
methodName
=
"
\n
ReferenceHarmonicBondIxn::calculateBondIxn"
;
...
@@ -129,8 +119,6 @@ int ReferenceHarmonicBondIxn::calculateBondIxn( int* atomIndices,
...
@@ -129,8 +119,6 @@ int ReferenceHarmonicBondIxn::calculateBondIxn( int* atomIndices,
forces
[
atomBIndex
][
1
]
-=
dEdR
*
deltaR
[
ReferenceForce
::
YIndex
];
forces
[
atomBIndex
][
1
]
-=
dEdR
*
deltaR
[
ReferenceForce
::
YIndex
];
forces
[
atomBIndex
][
2
]
-=
dEdR
*
deltaR
[
ReferenceForce
::
ZIndex
];
forces
[
atomBIndex
][
2
]
-=
dEdR
*
deltaR
[
ReferenceForce
::
ZIndex
];
RealOpenMM
energy
=
half
*
parameters
[
1
]
*
deltaIdeal2
;
if
(
totalEnergy
!=
NULL
)
updateEnergy
(
energy
,
energiesByBond
,
twoI
,
atomIndices
,
energiesByAtom
);
*
totalEnergy
+=
half
*
parameters
[
1
]
*
deltaIdeal2
;
return
ReferenceForce
::
DefaultReturn
;
}
}
platforms/reference/src/SimTKReference/ReferenceHarmonicBondIxn.h
View file @
5003591d
...
@@ -60,15 +60,13 @@ class ReferenceHarmonicBondIxn : public ReferenceBondIxn {
...
@@ -60,15 +60,13 @@ class ReferenceHarmonicBondIxn : public ReferenceBondIxn {
@param parameters parameters: parameters[0] = ideal bond length
@param parameters parameters: parameters[0] = ideal bond length
parameters[1] = bond k
parameters[1] = bond k
@param forces force array (forces added)
@param forces force array (forces added)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param totalEnergy if not null, the energy will be added to this
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
void
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
energiesByAtom
)
const
;
RealOpenMM
*
totalEnergy
)
const
;
};
};
...
...
platforms/reference/src/SimTKReference/ReferenceLJCoulomb14.cpp
View file @
5003591d
...
@@ -74,23 +74,13 @@ ReferenceLJCoulomb14::~ReferenceLJCoulomb14( ){
...
@@ -74,23 +74,13 @@ ReferenceLJCoulomb14::~ReferenceLJCoulomb14( ){
parameters[1]= c6*c6/c12 (4*epsilon)
parameters[1]= c6*c6/c12 (4*epsilon)
parameters[2]= epsfac*q1*q2
parameters[2]= epsfac*q1*q2
@param forces force array (forces added to current values)
@param forces force array (forces added to current values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param totalEnergy if not null, the energy will be added to this
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceLJCoulomb14
::
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
void
ReferenceLJCoulomb14
::
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
totalEnergy
)
const
{
RealOpenMM
*
energiesByAtom
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJCoulomb14::calculateBondIxn";
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"
\n
ReferenceLJCoulomb14::calculateBondIxn"
;
static
const
std
::
string
methodName
=
"
\n
ReferenceLJCoulomb14::calculateBondIxn"
;
...
@@ -140,12 +130,8 @@ int ReferenceLJCoulomb14::calculateBondIxn( int* atomIndices, RealOpenMM** atomC
...
@@ -140,12 +130,8 @@ int ReferenceLJCoulomb14::calculateBondIxn( int* atomIndices, RealOpenMM** atomC
forces
[
atomBIndex
][
ii
]
-=
force
;
forces
[
atomBIndex
][
ii
]
-=
force
;
}
}
RealOpenMM
energy
=
parameters
[
1
]
*
(
sig6
-
one
)
*
sig6
;
energy
+=
(
RealOpenMM
)
(
ONE_4PI_EPS0
*
parameters
[
2
]
*
inverseR
);
// accumulate energies
// accumulate energies
updateEnergy
(
energy
,
energiesByBond
,
LastAtomIndex
,
atomIndices
,
energiesByAtom
);
if
(
totalEnergy
!=
NULL
)
*
totalEnergy
+=
parameters
[
1
]
*
(
sig6
-
one
)
*
sig6
+
(
ONE_4PI_EPS0
*
parameters
[
2
]
*
inverseR
);
return
ReferenceForce
::
DefaultReturn
;
}
}
Prev
1
2
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