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
8f8aa247
Unverified
Commit
8f8aa247
authored
Jul 06, 2018
by
peastman
Committed by
GitHub
Jul 06, 2018
Browse files
Merge pull request #2112 from peastman/cleanup
Code cleanup
parents
0d13f9cd
c0e862f6
Changes
63
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
103 additions
and
256 deletions
+103
-256
platforms/reference/include/ReferenceRbDihedralBond.h
platforms/reference/include/ReferenceRbDihedralBond.h
+2
-2
platforms/reference/src/ReferenceKernels.cpp
platforms/reference/src/ReferenceKernels.cpp
+40
-148
platforms/reference/src/SimTKReference/ReferenceAngleBondIxn.cpp
...ms/reference/src/SimTKReference/ReferenceAngleBondIxn.cpp
+3
-3
platforms/reference/src/SimTKReference/ReferenceBondForce.cpp
...forms/reference/src/SimTKReference/ReferenceBondForce.cpp
+2
-2
platforms/reference/src/SimTKReference/ReferenceBondIxn.cpp
platforms/reference/src/SimTKReference/ReferenceBondIxn.cpp
+2
-2
platforms/reference/src/SimTKReference/ReferenceCMAPTorsionIxn.cpp
.../reference/src/SimTKReference/ReferenceCMAPTorsionIxn.cpp
+2
-2
platforms/reference/src/SimTKReference/ReferenceCustomAngleIxn.cpp
.../reference/src/SimTKReference/ReferenceCustomAngleIxn.cpp
+2
-2
platforms/reference/src/SimTKReference/ReferenceCustomBondIxn.cpp
...s/reference/src/SimTKReference/ReferenceCustomBondIxn.cpp
+2
-2
platforms/reference/src/SimTKReference/ReferenceCustomCentroidBondIxn.cpp
...nce/src/SimTKReference/ReferenceCustomCentroidBondIxn.cpp
+2
-2
platforms/reference/src/SimTKReference/ReferenceCustomCompoundBondIxn.cpp
...nce/src/SimTKReference/ReferenceCustomCompoundBondIxn.cpp
+1
-1
platforms/reference/src/SimTKReference/ReferenceCustomExternalIxn.cpp
...ference/src/SimTKReference/ReferenceCustomExternalIxn.cpp
+2
-2
platforms/reference/src/SimTKReference/ReferenceCustomGBIxn.cpp
...rms/reference/src/SimTKReference/ReferenceCustomGBIxn.cpp
+10
-10
platforms/reference/src/SimTKReference/ReferenceCustomHbondIxn.cpp
.../reference/src/SimTKReference/ReferenceCustomHbondIxn.cpp
+1
-1
platforms/reference/src/SimTKReference/ReferenceCustomManyParticleIxn.cpp
...nce/src/SimTKReference/ReferenceCustomManyParticleIxn.cpp
+4
-4
platforms/reference/src/SimTKReference/ReferenceCustomNonbondedIxn.cpp
...erence/src/SimTKReference/ReferenceCustomNonbondedIxn.cpp
+10
-20
platforms/reference/src/SimTKReference/ReferenceCustomTorsionIxn.cpp
...eference/src/SimTKReference/ReferenceCustomTorsionIxn.cpp
+2
-2
platforms/reference/src/SimTKReference/ReferenceHarmonicBondIxn.cpp
...reference/src/SimTKReference/ReferenceHarmonicBondIxn.cpp
+2
-2
platforms/reference/src/SimTKReference/ReferenceLJCoulomb14.cpp
...rms/reference/src/SimTKReference/ReferenceLJCoulomb14.cpp
+2
-2
platforms/reference/src/SimTKReference/ReferenceLJCoulombIxn.cpp
...ms/reference/src/SimTKReference/ReferenceLJCoulombIxn.cpp
+10
-45
platforms/reference/src/SimTKReference/ReferenceProperDihedralBond.cpp
...erence/src/SimTKReference/ReferenceProperDihedralBond.cpp
+2
-2
No files found.
platforms/reference/include/ReferenceRbDihedralBond.h
View file @
8f8aa247
...
...
@@ -76,8 +76,8 @@ class OPENMM_EXPORT ReferenceRbDihedralBond : public ReferenceBondIxn {
--------------------------------------------------------------------------------------- */
void
calculateBondIxn
(
int
*
atomIndices
,
std
::
vector
<
OpenMM
::
Vec3
>&
atomCoordinates
,
double
*
parameters
,
std
::
vector
<
OpenMM
::
Vec3
>&
forces
,
void
calculateBondIxn
(
std
::
vector
<
int
>&
atomIndices
,
std
::
vector
<
OpenMM
::
Vec3
>&
atomCoordinates
,
std
::
vector
<
double
>&
parameters
,
std
::
vector
<
OpenMM
::
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
);
};
...
...
platforms/reference/src/ReferenceKernels.cpp
View file @
8f8aa247
...
...
@@ -89,36 +89,6 @@
using
namespace
OpenMM
;
using
namespace
std
;
static
int
**
allocateIntArray
(
int
length
,
int
width
)
{
int
**
array
=
new
int
*
[
length
];
for
(
int
i
=
0
;
i
<
length
;
++
i
)
array
[
i
]
=
new
int
[
width
];
return
array
;
}
static
double
**
allocateRealArray
(
int
length
,
int
width
)
{
double
**
array
=
new
double
*
[
length
];
for
(
int
i
=
0
;
i
<
length
;
++
i
)
array
[
i
]
=
new
double
[
width
];
return
array
;
}
static
void
disposeIntArray
(
int
**
array
,
int
size
)
{
if
(
array
)
{
for
(
int
i
=
0
;
i
<
size
;
++
i
)
delete
[]
array
[
i
];
delete
[]
array
;
}
}
static
void
disposeRealArray
(
double
**
array
,
int
size
)
{
if
(
array
)
{
for
(
int
i
=
0
;
i
<
size
;
++
i
)
delete
[]
array
[
i
];
delete
[]
array
;
}
}
static
vector
<
Vec3
>&
extractPositions
(
ContextImpl
&
context
)
{
ReferencePlatform
::
PlatformData
*
data
=
reinterpret_cast
<
ReferencePlatform
::
PlatformData
*>
(
context
.
getPlatformData
());
return
*
((
vector
<
Vec3
>*
)
data
->
positions
);
...
...
@@ -366,15 +336,10 @@ void ReferenceVirtualSitesKernel::computePositions(ContextImpl& context) {
ReferenceVirtualSites
::
computePositions
(
context
.
getSystem
(),
positions
);
}
ReferenceCalcHarmonicBondForceKernel
::~
ReferenceCalcHarmonicBondForceKernel
()
{
disposeIntArray
(
bondIndexArray
,
numBonds
);
disposeRealArray
(
bondParamArray
,
numBonds
);
}
void
ReferenceCalcHarmonicBondForceKernel
::
initialize
(
const
System
&
system
,
const
HarmonicBondForce
&
force
)
{
numBonds
=
force
.
getNumBonds
();
bondIndexArray
=
allocateIntArray
(
numBonds
,
2
);
bondParamArray
=
allocateRealArray
(
numBonds
,
2
);
bondIndexArray
.
resize
(
numBonds
,
vector
<
int
>
(
2
)
);
bondParamArray
.
resize
(
numBonds
,
vector
<
double
>
(
2
)
);
for
(
int
i
=
0
;
i
<
numBonds
;
++
i
)
{
int
particle1
,
particle2
;
double
length
,
k
;
...
...
@@ -418,11 +383,6 @@ void ReferenceCalcHarmonicBondForceKernel::copyParametersToContext(ContextImpl&
}
}
ReferenceCalcCustomBondForceKernel
::~
ReferenceCalcCustomBondForceKernel
()
{
disposeIntArray
(
bondIndexArray
,
numBonds
);
disposeRealArray
(
bondParamArray
,
numBonds
);
}
void
ReferenceCalcCustomBondForceKernel
::
initialize
(
const
System
&
system
,
const
CustomBondForce
&
force
)
{
numBonds
=
force
.
getNumBonds
();
int
numParameters
=
force
.
getNumPerBondParameters
();
...
...
@@ -430,8 +390,8 @@ void ReferenceCalcCustomBondForceKernel::initialize(const System& system, const
// Build the arrays.
bondIndexArray
=
allocateIntArray
(
numBonds
,
2
);
bondParamArray
=
allocateRealArray
(
numBonds
,
numParameters
);
bondIndexArray
.
resize
(
numBonds
,
vector
<
int
>
(
2
)
);
bondParamArray
.
resize
(
numBonds
,
vector
<
double
>
(
numParameters
)
)
;
vector
<
double
>
params
;
for
(
int
i
=
0
;
i
<
numBonds
;
++
i
)
{
int
particle1
,
particle2
;
...
...
@@ -500,15 +460,10 @@ void ReferenceCalcCustomBondForceKernel::copyParametersToContext(ContextImpl& co
}
}
ReferenceCalcHarmonicAngleForceKernel
::~
ReferenceCalcHarmonicAngleForceKernel
()
{
disposeIntArray
(
angleIndexArray
,
numAngles
);
disposeRealArray
(
angleParamArray
,
numAngles
);
}
void
ReferenceCalcHarmonicAngleForceKernel
::
initialize
(
const
System
&
system
,
const
HarmonicAngleForce
&
force
)
{
numAngles
=
force
.
getNumAngles
();
angleIndexArray
=
allocateIntArray
(
numAngles
,
3
);
angleParamArray
=
allocateRealArray
(
numAngles
,
2
);
angleIndexArray
.
resize
(
numAngles
,
vector
<
int
>
(
3
)
);
angleParamArray
.
resize
(
numAngles
,
vector
<
double
>
(
2
)
);
for
(
int
i
=
0
;
i
<
numAngles
;
++
i
)
{
int
particle1
,
particle2
,
particle3
;
double
angle
,
k
;
...
...
@@ -551,11 +506,6 @@ void ReferenceCalcHarmonicAngleForceKernel::copyParametersToContext(ContextImpl&
}
}
ReferenceCalcCustomAngleForceKernel
::~
ReferenceCalcCustomAngleForceKernel
()
{
disposeIntArray
(
angleIndexArray
,
numAngles
);
disposeRealArray
(
angleParamArray
,
numAngles
);
}
void
ReferenceCalcCustomAngleForceKernel
::
initialize
(
const
System
&
system
,
const
CustomAngleForce
&
force
)
{
numAngles
=
force
.
getNumAngles
();
int
numParameters
=
force
.
getNumPerAngleParameters
();
...
...
@@ -563,8 +513,8 @@ void ReferenceCalcCustomAngleForceKernel::initialize(const System& system, const
// Build the arrays.
angleIndexArray
=
allocateIntArray
(
numAngles
,
3
);
angleParamArray
=
allocateRealArray
(
numAngles
,
numParameters
);
angleIndexArray
.
resize
(
numAngles
,
vector
<
int
>
(
3
)
);
angleParamArray
.
resize
(
numAngles
,
vector
<
double
>
(
numParameters
)
)
;
vector
<
double
>
params
;
for
(
int
i
=
0
;
i
<
numAngles
;
++
i
)
{
int
particle1
,
particle2
,
particle3
;
...
...
@@ -634,15 +584,10 @@ void ReferenceCalcCustomAngleForceKernel::copyParametersToContext(ContextImpl& c
}
}
ReferenceCalcPeriodicTorsionForceKernel
::~
ReferenceCalcPeriodicTorsionForceKernel
()
{
disposeIntArray
(
torsionIndexArray
,
numTorsions
);
disposeRealArray
(
torsionParamArray
,
numTorsions
);
}
void
ReferenceCalcPeriodicTorsionForceKernel
::
initialize
(
const
System
&
system
,
const
PeriodicTorsionForce
&
force
)
{
numTorsions
=
force
.
getNumTorsions
();
torsionIndexArray
=
allocateIntArray
(
numTorsions
,
4
);
torsionParamArray
=
allocateRealArray
(
numTorsions
,
3
);
torsionIndexArray
.
resize
(
numTorsions
,
vector
<
int
>
(
4
)
);
torsionParamArray
.
resize
(
numTorsions
,
vector
<
double
>
(
3
)
);
for
(
int
i
=
0
;
i
<
numTorsions
;
++
i
)
{
int
particle1
,
particle2
,
particle3
,
particle4
,
periodicity
;
double
phase
,
k
;
...
...
@@ -688,15 +633,10 @@ void ReferenceCalcPeriodicTorsionForceKernel::copyParametersToContext(ContextImp
}
}
ReferenceCalcRBTorsionForceKernel
::~
ReferenceCalcRBTorsionForceKernel
()
{
disposeIntArray
(
torsionIndexArray
,
numTorsions
);
disposeRealArray
(
torsionParamArray
,
numTorsions
);
}
void
ReferenceCalcRBTorsionForceKernel
::
initialize
(
const
System
&
system
,
const
RBTorsionForce
&
force
)
{
numTorsions
=
force
.
getNumTorsions
();
torsionIndexArray
=
allocateIntArray
(
numTorsions
,
4
);
torsionParamArray
=
allocateRealArray
(
numTorsions
,
6
);
torsionIndexArray
.
resize
(
numTorsions
,
vector
<
int
>
(
4
)
);
torsionParamArray
.
resize
(
numTorsions
,
vector
<
double
>
(
6
)
);
for
(
int
i
=
0
;
i
<
numTorsions
;
++
i
)
{
int
particle1
,
particle2
,
particle3
,
particle4
;
double
c0
,
c1
,
c2
,
c3
,
c4
,
c5
;
...
...
@@ -820,11 +760,6 @@ void ReferenceCalcCMAPTorsionForceKernel::copyParametersToContext(ContextImpl& c
}
}
ReferenceCalcCustomTorsionForceKernel
::~
ReferenceCalcCustomTorsionForceKernel
()
{
disposeIntArray
(
torsionIndexArray
,
numTorsions
);
disposeRealArray
(
torsionParamArray
,
numTorsions
);
}
void
ReferenceCalcCustomTorsionForceKernel
::
initialize
(
const
System
&
system
,
const
CustomTorsionForce
&
force
)
{
numTorsions
=
force
.
getNumTorsions
();
int
numParameters
=
force
.
getNumPerTorsionParameters
();
...
...
@@ -832,8 +767,8 @@ void ReferenceCalcCustomTorsionForceKernel::initialize(const System& system, con
// Build the arrays.
torsionIndexArray
=
allocateIntArray
(
numTorsions
,
4
);
torsionParamArray
=
allocateRealArray
(
numTorsions
,
numParameters
);
torsionIndexArray
.
resize
(
numTorsions
,
vector
<
int
>
(
4
)
);
torsionParamArray
.
resize
(
numTorsions
,
vector
<
double
>
(
numParameters
)
)
;
vector
<
double
>
params
;
for
(
int
i
=
0
;
i
<
numTorsions
;
++
i
)
{
int
particle1
,
particle2
,
particle3
,
particle4
;
...
...
@@ -905,9 +840,6 @@ void ReferenceCalcCustomTorsionForceKernel::copyParametersToContext(ContextImpl&
}
ReferenceCalcNonbondedForceKernel
::~
ReferenceCalcNonbondedForceKernel
()
{
disposeRealArray
(
particleParamArray
,
numParticles
);
disposeIntArray
(
bonded14IndexArray
,
num14
);
disposeRealArray
(
bonded14ParamArray
,
num14
);
if
(
neighborList
!=
NULL
)
delete
neighborList
;
}
...
...
@@ -932,9 +864,9 @@ void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const N
// Build the arrays.
num14
=
nb14s
.
size
();
bonded14IndexArray
=
allocateIntArray
(
num14
,
2
);
bonded14ParamArray
=
allocateRealArray
(
num14
,
3
);
particleParamArray
=
allocateRealArray
(
numParticles
,
3
);
bonded14IndexArray
.
resize
(
num14
,
vector
<
int
>
(
2
)
);
bonded14ParamArray
.
resize
(
num14
,
vector
<
double
>
(
3
)
);
particleParamArray
.
resize
(
numParticles
,
vector
<
double
>
(
3
)
);
baseParticleParams
.
resize
(
numParticles
);
baseExceptionParams
.
resize
(
num14
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
...
...
@@ -1027,7 +959,7 @@ double ReferenceCalcNonbondedForceKernel::execute(ContextImpl& context, bool inc
}
if
(
useSwitchingFunction
)
clj
.
setUseSwitchingFunction
(
switchingDistance
);
clj
.
calculatePairIxn
(
numParticles
,
posData
,
particleParamArray
,
exclusions
,
0
,
forceData
,
0
,
includeEnergy
?
&
energy
:
NULL
,
includeDirect
,
includeReciprocal
);
clj
.
calculatePairIxn
(
numParticles
,
posData
,
particleParamArray
,
exclusions
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
includeDirect
,
includeReciprocal
);
if
(
includeDirect
)
{
ReferenceBondForce
refBondForce
;
ReferenceLJCoulomb14
nonbonded14
;
...
...
@@ -1137,7 +1069,6 @@ void ReferenceCalcNonbondedForceKernel::computeParameters(ContextImpl& context)
}
ReferenceCalcCustomNonbondedForceKernel
::~
ReferenceCalcCustomNonbondedForceKernel
()
{
disposeRealArray
(
particleParamArray
,
numParticles
);
if
(
neighborList
!=
NULL
)
delete
neighborList
;
if
(
forceCopy
!=
NULL
)
...
...
@@ -1160,13 +1091,9 @@ void ReferenceCalcCustomNonbondedForceKernel::initialize(const System& system, c
// Build the arrays.
int
numParameters
=
force
.
getNumPerParticleParameters
();
particleParamArray
=
allocateRealArray
(
numParticles
,
numParameters
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
vector
<
double
>
parameters
;
force
.
getParticleParameters
(
i
,
parameters
);
for
(
int
j
=
0
;
j
<
numParameters
;
j
++
)
particleParamArray
[
i
][
j
]
=
parameters
[
j
];
}
particleParamArray
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
force
.
getParticleParameters
(
i
,
particleParamArray
[
i
]);
nonbondedMethod
=
CalcCustomNonbondedForceKernel
::
NonbondedMethod
(
force
.
getNonbondedMethod
());
nonbondedCutoff
=
force
.
getCutoffDistance
();
if
(
nonbondedMethod
==
NoCutoff
)
{
...
...
@@ -1264,7 +1191,7 @@ double ReferenceCalcCustomNonbondedForceKernel::execute(ContextImpl& context, bo
if
(
useSwitchingFunction
)
ixn
.
setUseSwitchingFunction
(
switchingDistance
);
vector
<
double
>
energyParamDerivValues
(
energyParamDerivNames
.
size
()
+
1
,
0.0
);
ixn
.
calculatePairIxn
(
numParticles
,
posData
,
particleParamArray
,
exclusions
,
0
,
globalParamValues
,
forceData
,
0
,
includeEnergy
?
&
energy
:
NULL
,
&
energyParamDerivValues
[
0
]);
ixn
.
calculatePairIxn
(
numParticles
,
posData
,
particleParamArray
,
exclusions
,
globalParamValues
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
&
energyParamDerivValues
[
0
]);
map
<
string
,
double
>&
energyParamDerivs
=
extractEnergyParameterDerivatives
(
context
);
for
(
int
i
=
0
;
i
<
energyParamDerivNames
.
size
();
i
++
)
energyParamDerivs
[
energyParamDerivNames
[
i
]]
+=
energyParamDerivValues
[
i
];
...
...
@@ -1368,7 +1295,6 @@ void ReferenceCalcGBSAOBCForceKernel::copyParametersToContext(ContextImpl& conte
}
ReferenceCalcCustomGBForceKernel
::~
ReferenceCalcCustomGBForceKernel
()
{
disposeRealArray
(
particleParamArray
,
numParticles
);
if
(
neighborList
!=
NULL
)
delete
neighborList
;
}
...
...
@@ -1401,13 +1327,9 @@ void ReferenceCalcCustomGBForceKernel::initialize(const System& system, const Cu
// Build the arrays.
int
numPerParticleParameters
=
force
.
getNumPerParticleParameters
();
particleParamArray
=
allocateRealArray
(
numParticles
,
numPerParticleParameters
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
vector
<
double
>
parameters
;
force
.
getParticleParameters
(
i
,
parameters
);
for
(
int
j
=
0
;
j
<
numPerParticleParameters
;
j
++
)
particleParamArray
[
i
][
j
]
=
parameters
[
j
];
}
particleParamArray
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
force
.
getParticleParameters
(
i
,
particleParamArray
[
i
]);
for
(
int
i
=
0
;
i
<
numPerParticleParameters
;
i
++
)
particleParameterNames
.
push_back
(
force
.
getPerParticleParameterName
(
i
));
for
(
int
i
=
0
;
i
<
force
.
getNumGlobalParameters
();
i
++
)
...
...
@@ -1593,10 +1515,6 @@ Lepton::CustomFunction* ReferenceCalcCustomExternalForceKernel::PeriodicDistance
return
new
PeriodicDistanceFunction
(
boxVectorHandle
);
}
ReferenceCalcCustomExternalForceKernel
::~
ReferenceCalcCustomExternalForceKernel
()
{
disposeRealArray
(
particleParamArray
,
numParticles
);
}
void
ReferenceCalcCustomExternalForceKernel
::
initialize
(
const
System
&
system
,
const
CustomExternalForce
&
force
)
{
numParticles
=
force
.
getNumParticles
();
int
numParameters
=
force
.
getNumPerParticleParameters
();
...
...
@@ -1604,13 +1522,9 @@ void ReferenceCalcCustomExternalForceKernel::initialize(const System& system, co
// Build the arrays.
particles
.
resize
(
numParticles
);
particleParamArray
=
allocateRealArray
(
numParticles
,
numParameters
);
vector
<
double
>
params
;
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
force
.
getParticleParameters
(
i
,
particles
[
i
],
params
);
for
(
int
j
=
0
;
j
<
numParameters
;
j
++
)
particleParamArray
[
i
][
j
]
=
params
[
j
];
}
particleParamArray
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
force
.
getParticleParameters
(
i
,
particles
[
i
],
particleParamArray
[
i
]);
// Parse the expression used to calculate the force.
...
...
@@ -1669,8 +1583,6 @@ void ReferenceCalcCustomExternalForceKernel::copyParametersToContext(ContextImpl
}
ReferenceCalcCustomHbondForceKernel
::~
ReferenceCalcCustomHbondForceKernel
()
{
disposeRealArray
(
donorParamArray
,
numDonors
);
disposeRealArray
(
acceptorParamArray
,
numAcceptors
);
if
(
ixn
!=
NULL
)
delete
ixn
;
}
...
...
@@ -1693,29 +1605,23 @@ void ReferenceCalcCustomHbondForceKernel::initialize(const System& system, const
vector
<
vector
<
int
>
>
donorParticles
(
numDonors
);
int
numDonorParameters
=
force
.
getNumPerDonorParameters
();
donorParamArray
=
allocateRealArray
(
numDonors
,
numDonorParamete
rs
);
donorParamArray
.
resize
(
numDono
rs
);
for
(
int
i
=
0
;
i
<
numDonors
;
++
i
)
{
vector
<
double
>
parameters
;
int
d1
,
d2
,
d3
;
force
.
getDonorParameters
(
i
,
d1
,
d2
,
d3
,
parameters
);
force
.
getDonorParameters
(
i
,
d1
,
d2
,
d3
,
donorParamArray
[
i
]
);
donorParticles
[
i
].
push_back
(
d1
);
donorParticles
[
i
].
push_back
(
d2
);
donorParticles
[
i
].
push_back
(
d3
);
for
(
int
j
=
0
;
j
<
numDonorParameters
;
j
++
)
donorParamArray
[
i
][
j
]
=
parameters
[
j
];
}
vector
<
vector
<
int
>
>
acceptorParticles
(
numAcceptors
);
int
numAcceptorParameters
=
force
.
getNumPerAcceptorParameters
();
acceptorParamArray
=
allocateRealArray
(
numAcceptors
,
numAcceptor
Parameter
s
);
acceptorParamArray
.
resize
(
numAcceptors
);
for
(
int
i
=
0
;
i
<
numAcceptors
;
++
i
)
{
vector
<
double
>
parameters
;
int
a1
,
a2
,
a3
;
force
.
getAcceptorParameters
(
i
,
a1
,
a2
,
a3
,
parameters
);
force
.
getAcceptorParameters
(
i
,
a1
,
a2
,
a3
,
acceptorParamArray
[
i
]
);
acceptorParticles
[
i
].
push_back
(
a1
);
acceptorParticles
[
i
].
push_back
(
a2
);
acceptorParticles
[
i
].
push_back
(
a3
);
for
(
int
j
=
0
;
j
<
numAcceptorParameters
;
j
++
)
acceptorParamArray
[
i
][
j
]
=
parameters
[
j
];
}
NonbondedMethod
nonbondedMethod
=
CalcCustomHbondForceKernel
::
NonbondedMethod
(
force
.
getNonbondedMethod
());
nonbondedCutoff
=
force
.
getCutoffDistance
();
...
...
@@ -1796,7 +1702,6 @@ void ReferenceCalcCustomHbondForceKernel::copyParametersToContext(ContextImpl& c
}
ReferenceCalcCustomCentroidBondForceKernel
::~
ReferenceCalcCustomCentroidBondForceKernel
()
{
disposeRealArray
(
bondParamArray
,
numBonds
);
if
(
ixn
!=
NULL
)
delete
ixn
;
}
...
...
@@ -1816,13 +1721,9 @@ void ReferenceCalcCustomCentroidBondForceKernel::initialize(const System& system
numBonds
=
force
.
getNumBonds
();
vector
<
vector
<
int
>
>
bondGroups
(
numBonds
);
int
numBondParameters
=
force
.
getNumPerBondParameters
();
bondParamArray
=
allocateRealArray
(
numBonds
,
numBondParameters
);
for
(
int
i
=
0
;
i
<
numBonds
;
++
i
)
{
vector
<
double
>
parameters
;
force
.
getBondParameters
(
i
,
bondGroups
[
i
],
parameters
);
for
(
int
j
=
0
;
j
<
numBondParameters
;
j
++
)
bondParamArray
[
i
][
j
]
=
parameters
[
j
];
}
bondParamArray
.
resize
(
numBonds
);
for
(
int
i
=
0
;
i
<
numBonds
;
++
i
)
force
.
getBondParameters
(
i
,
bondGroups
[
i
],
bondParamArray
[
i
]);
// Create custom functions for the tabulated functions.
...
...
@@ -1893,7 +1794,6 @@ void ReferenceCalcCustomCentroidBondForceKernel::copyParametersToContext(Context
}
ReferenceCalcCustomCompoundBondForceKernel
::~
ReferenceCalcCustomCompoundBondForceKernel
()
{
disposeRealArray
(
bondParamArray
,
numBonds
);
if
(
ixn
!=
NULL
)
delete
ixn
;
}
...
...
@@ -1906,13 +1806,9 @@ void ReferenceCalcCustomCompoundBondForceKernel::initialize(const System& system
numBonds
=
force
.
getNumBonds
();
vector
<
vector
<
int
>
>
bondParticles
(
numBonds
);
int
numBondParameters
=
force
.
getNumPerBondParameters
();
bondParamArray
=
allocateRealArray
(
numBonds
,
numBondParameters
);
for
(
int
i
=
0
;
i
<
numBonds
;
++
i
)
{
vector
<
double
>
parameters
;
force
.
getBondParameters
(
i
,
bondParticles
[
i
],
parameters
);
for
(
int
j
=
0
;
j
<
numBondParameters
;
j
++
)
bondParamArray
[
i
][
j
]
=
parameters
[
j
];
}
bondParamArray
.
resize
(
numBonds
);
for
(
int
i
=
0
;
i
<
numBonds
;
++
i
)
force
.
getBondParameters
(
i
,
bondParticles
[
i
],
bondParamArray
[
i
]);
// Create custom functions for the tabulated functions.
...
...
@@ -1983,7 +1879,6 @@ void ReferenceCalcCustomCompoundBondForceKernel::copyParametersToContext(Context
}
ReferenceCalcCustomManyParticleForceKernel
::~
ReferenceCalcCustomManyParticleForceKernel
()
{
disposeRealArray
(
particleParamArray
,
numParticles
);
if
(
ixn
!=
NULL
)
delete
ixn
;
}
...
...
@@ -1994,13 +1889,10 @@ void ReferenceCalcCustomManyParticleForceKernel::initialize(const System& system
numParticles
=
system
.
getNumParticles
();
int
numParticleParameters
=
force
.
getNumPerParticleParameters
();
particleParamArray
=
allocateRealArray
(
numParticles
,
numParticle
Parameter
s
);
particleParamArray
.
resize
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
vector
<
double
>
parameters
;
int
type
;
force
.
getParticleParameters
(
i
,
parameters
,
type
);
for
(
int
j
=
0
;
j
<
numParticleParameters
;
j
++
)
particleParamArray
[
i
][
j
]
=
parameters
[
j
];
force
.
getParticleParameters
(
i
,
particleParamArray
[
i
],
type
);
}
for
(
int
i
=
0
;
i
<
force
.
getNumGlobalParameters
();
i
++
)
globalParameterNames
.
push_back
(
force
.
getGlobalParameterName
(
i
));
...
...
platforms/reference/src/SimTKReference/ReferenceAngleBondIxn.cpp
View file @
8f8aa247
...
...
@@ -69,7 +69,7 @@ void ReferenceAngleBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */
void
ReferenceAngleBondIxn
::
getPrefactorsGivenAngleCosine
(
double
cosine
,
double
*
angleParameters
,
void
ReferenceAngleBondIxn
::
getPrefactorsGivenAngleCosine
(
double
cosine
,
vector
<
double
>&
angleParameters
,
double
*
dEdR
,
double
*
energyTerm
)
const
{
double
angle
;
...
...
@@ -101,9 +101,9 @@ void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine(double cosine, double*
--------------------------------------------------------------------------------------- */
void
ReferenceAngleBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceAngleBondIxn
::
calculateBondIxn
(
vector
<
int
>&
atomIndices
,
vector
<
Vec3
>&
atomCoordinates
,
double
*
parameters
,
vector
<
double
>&
parameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
...
...
platforms/reference/src/SimTKReference/ReferenceBondForce.cpp
View file @
8f8aa247
...
...
@@ -64,9 +64,9 @@ ReferenceBondForce::~ReferenceBondForce() {
--------------------------------------------------------------------------------------- */
void
ReferenceBondForce
::
calculateForce
(
int
numberOfBonds
,
int
**
atomIndices
,
void
ReferenceBondForce
::
calculateForce
(
int
numberOfBonds
,
vector
<
vector
<
int
>
>&
atomIndices
,
vector
<
Vec3
>&
atomCoordinates
,
double
**
parameters
,
vector
<
vector
<
double
>
>&
parameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
)
{
...
...
platforms/reference/src/SimTKReference/ReferenceBondIxn.cpp
View file @
8f8aa247
...
...
@@ -62,8 +62,8 @@ ReferenceBondIxn::~ReferenceBondIxn() {
--------------------------------------------------------------------------------------- */
void
ReferenceBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
vector
<
Vec3
>&
atomCoordinates
,
double
*
parameters
,
vector
<
Vec3
>&
forces
,
void
ReferenceBondIxn
::
calculateBondIxn
(
vector
<
int
>&
atomIndices
,
vector
<
Vec3
>&
atomCoordinates
,
vector
<
double
>&
parameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
}
...
...
platforms/reference/src/SimTKReference/ReferenceCMAPTorsionIxn.cpp
View file @
8f8aa247
...
...
@@ -206,6 +206,6 @@ void ReferenceCMAPTorsionIxn::calculateOneIxn(int index, vector<Vec3>& atomCoord
--------------------------------------------------------------------------------------- */
void
ReferenceCMAPTorsionIxn
::
calculateBondIxn
(
int
*
atomIndices
,
vector
<
Vec3
>&
atomCoordinates
,
double
*
parameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
void
ReferenceCMAPTorsionIxn
::
calculateBondIxn
(
vector
<
int
>&
atomIndices
,
vector
<
Vec3
>&
atomCoordinates
,
vector
<
double
>&
parameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
}
platforms/reference/src/SimTKReference/ReferenceCustomAngleIxn.cpp
View file @
8f8aa247
...
...
@@ -81,9 +81,9 @@ void ReferenceCustomAngleIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */
void
ReferenceCustomAngleIxn
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceCustomAngleIxn
::
calculateBondIxn
(
vector
<
int
>&
atomIndices
,
vector
<
Vec3
>&
atomCoordinates
,
double
*
parameters
,
vector
<
double
>&
parameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
double
deltaR
[
2
][
ReferenceForce
::
LastDeltaRIndex
];
...
...
platforms/reference/src/SimTKReference/ReferenceCustomBondIxn.cpp
View file @
8f8aa247
...
...
@@ -82,9 +82,9 @@ void ReferenceCustomBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */
void
ReferenceCustomBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceCustomBondIxn
::
calculateBondIxn
(
vector
<
int
>&
atomIndices
,
vector
<
Vec3
>&
atomCoordinates
,
double
*
parameters
,
vector
<
double
>&
parameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
double
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
...
...
platforms/reference/src/SimTKReference/ReferenceCustomCentroidBondIxn.cpp
View file @
8f8aa247
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
8
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -93,7 +93,7 @@ void ReferenceCustomCentroidBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
boxVectors
[
2
]
=
vectors
[
2
];
}
void
ReferenceCustomCentroidBondIxn
::
calculatePairIxn
(
vector
<
Vec3
>&
atomCoordinates
,
double
**
bondParameters
,
void
ReferenceCustomCentroidBondIxn
::
calculatePairIxn
(
vector
<
Vec3
>&
atomCoordinates
,
vector
<
vector
<
double
>
>&
bondParameters
,
const
map
<
string
,
double
>&
globalParameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
...
...
platforms/reference/src/SimTKReference/ReferenceCustomCompoundBondIxn.cpp
View file @
8f8aa247
...
...
@@ -116,7 +116,7 @@ void ReferenceCustomCompoundBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */
void
ReferenceCustomCompoundBondIxn
::
calculatePairIxn
(
vector
<
Vec3
>&
atomCoordinates
,
double
**
bondParameters
,
void
ReferenceCustomCompoundBondIxn
::
calculatePairIxn
(
vector
<
Vec3
>&
atomCoordinates
,
vector
<
vector
<
double
>
>&
bondParameters
,
const
map
<
string
,
double
>&
globalParameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
for
(
auto
&
param
:
globalParameters
)
...
...
platforms/reference/src/SimTKReference/ReferenceCustomExternalIxn.cpp
View file @
8f8aa247
/* Portions copyright (c) 2009-201
3
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
8
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -94,7 +94,7 @@ ReferenceCustomExternalIxn::~ReferenceCustomExternalIxn() {
void
ReferenceCustomExternalIxn
::
calculateForce
(
int
atomIndex
,
vector
<
Vec3
>&
atomCoordinates
,
double
*
parameters
,
vector
<
double
>&
parameters
,
vector
<
Vec3
>&
forces
,
double
*
energy
)
const
{
...
...
platforms/reference/src/SimTKReference/ReferenceCustomGBIxn.cpp
View file @
8f8aa247
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
8
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -150,7 +150,7 @@ ReferenceCustomGBIxn::~ReferenceCustomGBIxn() {
periodicBoxVectors
[
2
]
=
vectors
[
2
];
}
void
ReferenceCustomGBIxn
::
calculateIxn
(
int
numberOfAtoms
,
vector
<
Vec3
>&
atomCoordinates
,
double
**
atomParameters
,
void
ReferenceCustomGBIxn
::
calculateIxn
(
int
numberOfAtoms
,
vector
<
Vec3
>&
atomCoordinates
,
vector
<
vector
<
double
>
>&
atomParameters
,
const
vector
<
set
<
int
>
>&
exclusions
,
map
<
string
,
double
>&
globalParameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
for
(
auto
&
param
:
globalParameters
)
...
...
@@ -193,7 +193,7 @@ void ReferenceCustomGBIxn::calculateIxn(int numberOfAtoms, vector<Vec3>& atomCoo
calculateChainRuleForces
(
numberOfAtoms
,
atomCoordinates
,
atomParameters
,
exclusions
,
forces
,
energyParamDerivs
);
}
void
ReferenceCustomGBIxn
::
calculateSingleParticleValue
(
int
index
,
int
numAtoms
,
vector
<
Vec3
>&
atomCoordinates
,
double
**
atomParameters
)
{
void
ReferenceCustomGBIxn
::
calculateSingleParticleValue
(
int
index
,
int
numAtoms
,
vector
<
Vec3
>&
atomCoordinates
,
vector
<
vector
<
double
>
>&
atomParameters
)
{
values
[
index
].
resize
(
numAtoms
);
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
)
{
expressionSet
.
setVariable
(
xIndex
,
atomCoordinates
[
i
][
0
]);
...
...
@@ -217,7 +217,7 @@ void ReferenceCustomGBIxn::calculateSingleParticleValue(int index, int numAtoms,
}
}
void
ReferenceCustomGBIxn
::
calculateParticlePairValue
(
int
index
,
int
numAtoms
,
vector
<
Vec3
>&
atomCoordinates
,
double
**
atomParameters
,
void
ReferenceCustomGBIxn
::
calculateParticlePairValue
(
int
index
,
int
numAtoms
,
vector
<
Vec3
>&
atomCoordinates
,
vector
<
vector
<
double
>
>&
atomParameters
,
const
vector
<
set
<
int
>
>&
exclusions
,
bool
useExclusions
)
{
values
[
index
].
resize
(
numAtoms
);
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
)
...
...
@@ -246,7 +246,7 @@ void ReferenceCustomGBIxn::calculateParticlePairValue(int index, int numAtoms, v
}
}
void
ReferenceCustomGBIxn
::
calculateOnePairValue
(
int
index
,
int
atom1
,
int
atom2
,
vector
<
Vec3
>&
atomCoordinates
,
double
**
atomParameters
)
{
void
ReferenceCustomGBIxn
::
calculateOnePairValue
(
int
index
,
int
atom1
,
int
atom2
,
vector
<
Vec3
>&
atomCoordinates
,
vector
<
vector
<
double
>
>&
atomParameters
)
{
double
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
if
(
periodic
)
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atom2
],
atomCoordinates
[
atom1
],
periodicBoxVectors
,
deltaR
);
...
...
@@ -273,7 +273,7 @@ void ReferenceCustomGBIxn::calculateOnePairValue(int index, int atom1, int atom2
}
void
ReferenceCustomGBIxn
::
calculateSingleParticleEnergyTerm
(
int
index
,
int
numAtoms
,
vector
<
Vec3
>&
atomCoordinates
,
double
**
atomParameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
vector
<
vector
<
double
>
>&
atomParameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
)
{
expressionSet
.
setVariable
(
xIndex
,
atomCoordinates
[
i
][
0
]);
expressionSet
.
setVariable
(
yIndex
,
atomCoordinates
[
i
][
1
]);
...
...
@@ -300,7 +300,7 @@ void ReferenceCustomGBIxn::calculateSingleParticleEnergyTerm(int index, int numA
}
}
void
ReferenceCustomGBIxn
::
calculateParticlePairEnergyTerm
(
int
index
,
int
numAtoms
,
vector
<
Vec3
>&
atomCoordinates
,
double
**
atomParameters
,
void
ReferenceCustomGBIxn
::
calculateParticlePairEnergyTerm
(
int
index
,
int
numAtoms
,
vector
<
Vec3
>&
atomCoordinates
,
vector
<
vector
<
double
>
>&
atomParameters
,
const
vector
<
set
<
int
>
>&
exclusions
,
bool
useExclusions
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
if
(
cutoff
)
{
// Loop over all pairs in the neighbor list.
...
...
@@ -324,7 +324,7 @@ void ReferenceCustomGBIxn::calculateParticlePairEnergyTerm(int index, int numAto
}
}
void
ReferenceCustomGBIxn
::
calculateOnePairEnergyTerm
(
int
index
,
int
atom1
,
int
atom2
,
vector
<
Vec3
>&
atomCoordinates
,
double
**
atomParameters
,
void
ReferenceCustomGBIxn
::
calculateOnePairEnergyTerm
(
int
index
,
int
atom1
,
int
atom2
,
vector
<
Vec3
>&
atomCoordinates
,
vector
<
vector
<
double
>
>&
atomParameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
// Compute the displacement.
...
...
@@ -370,7 +370,7 @@ void ReferenceCustomGBIxn::calculateOnePairEnergyTerm(int index, int atom1, int
energyParamDerivs
[
i
]
+=
energyParamDerivExpressions
[
index
][
i
].
evaluate
();
}
void
ReferenceCustomGBIxn
::
calculateChainRuleForces
(
int
numAtoms
,
vector
<
Vec3
>&
atomCoordinates
,
double
**
atomParameters
,
void
ReferenceCustomGBIxn
::
calculateChainRuleForces
(
int
numAtoms
,
vector
<
Vec3
>&
atomCoordinates
,
vector
<
vector
<
double
>
>&
atomParameters
,
const
vector
<
set
<
int
>
>&
exclusions
,
vector
<
Vec3
>&
forces
,
double
*
energyParamDerivs
)
{
if
(
cutoff
)
{
// Loop over all pairs in the neighbor list.
...
...
@@ -429,7 +429,7 @@ void ReferenceCustomGBIxn::calculateChainRuleForces(int numAtoms, vector<Vec3>&
energyParamDerivs
[
k
]
+=
dEdV
[
j
][
i
]
*
dValuedParam
[
j
][
k
][
i
];
}
void
ReferenceCustomGBIxn
::
calculateOnePairChainRule
(
int
atom1
,
int
atom2
,
vector
<
Vec3
>&
atomCoordinates
,
double
**
atomParameters
,
void
ReferenceCustomGBIxn
::
calculateOnePairChainRule
(
int
atom1
,
int
atom2
,
vector
<
Vec3
>&
atomCoordinates
,
vector
<
vector
<
double
>
>&
atomParameters
,
vector
<
Vec3
>&
forces
,
bool
isExcluded
)
{
// Compute the displacement.
...
...
platforms/reference/src/SimTKReference/ReferenceCustomHbondIxn.cpp
View file @
8f8aa247
...
...
@@ -116,7 +116,7 @@ void ReferenceCustomHbondIxn::setPeriodic(Vec3* vectors) {
--------------------------------------------------------------------------------------- */
void
ReferenceCustomHbondIxn
::
calculatePairIxn
(
vector
<
Vec3
>&
atomCoordinates
,
double
**
donorParameters
,
double
**
acceptorParameters
,
void
ReferenceCustomHbondIxn
::
calculatePairIxn
(
vector
<
Vec3
>&
atomCoordinates
,
vector
<
vector
<
double
>
>&
donorParameters
,
vector
<
vector
<
double
>
>&
acceptorParameters
,
vector
<
set
<
int
>
>&
exclusions
,
const
map
<
string
,
double
>&
globalParameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
)
const
{
...
...
platforms/reference/src/SimTKReference/ReferenceCustomManyParticleIxn.cpp
View file @
8f8aa247
/* Portions copyright (c) 2009-201
4
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
8
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -105,7 +105,7 @@ ReferenceCustomManyParticleIxn::ReferenceCustomManyParticleIxn(const CustomManyP
ReferenceCustomManyParticleIxn
::~
ReferenceCustomManyParticleIxn
()
{
}
void
ReferenceCustomManyParticleIxn
::
calculateIxn
(
vector
<
Vec3
>&
atomCoordinates
,
double
**
particleParameters
,
void
ReferenceCustomManyParticleIxn
::
calculateIxn
(
vector
<
Vec3
>&
atomCoordinates
,
vector
<
vector
<
double
>
>&
particleParameters
,
const
map
<
string
,
double
>&
globalParameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
)
const
{
map
<
string
,
double
>
variables
=
globalParameters
;
...
...
@@ -130,7 +130,7 @@ void ReferenceCustomManyParticleIxn::setPeriodic(Vec3* vectors) {
}
void
ReferenceCustomManyParticleIxn
::
loopOverInteractions
(
vector
<
int
>&
particles
,
int
loopIndex
,
vector
<
OpenMM
::
Vec3
>&
atomCoordinates
,
double
**
particleParameters
,
map
<
string
,
double
>&
variables
,
vector
<
OpenMM
::
Vec3
>&
forces
,
vector
<
vector
<
double
>
>&
particleParameters
,
map
<
string
,
double
>&
variables
,
vector
<
OpenMM
::
Vec3
>&
forces
,
double
*
totalEnergy
)
const
{
int
numParticles
=
atomCoordinates
.
size
();
int
firstPartialLoop
=
(
centralParticleMode
?
2
:
1
);
...
...
@@ -147,7 +147,7 @@ void ReferenceCustomManyParticleIxn::loopOverInteractions(vector<int>& particles
}
void
ReferenceCustomManyParticleIxn
::
calculateOneIxn
(
const
vector
<
int
>&
particles
,
vector
<
Vec3
>&
atomCoordinates
,
double
**
particleParameters
,
map
<
string
,
double
>&
variables
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
)
const
{
vector
<
vector
<
double
>
>&
particleParameters
,
map
<
string
,
double
>&
variables
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
)
const
{
// Select the ordering to use for the particles.
vector
<
int
>
permutedParticles
(
numParticlesPerSet
);
...
...
platforms/reference/src/SimTKReference/ReferenceCustomNonbondedIxn.cpp
View file @
8f8aa247
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
8
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -146,18 +146,16 @@ void ReferenceCustomNonbondedIxn::setUseSwitchingFunction(double distance) {
@param atomParameters atom parameters atomParameters[atomIndex][paramterIndex]
@param exclusions atom exclusion indices
exclusions[atomIndex] contains the list of exclusions for that atom
@param fixedParameters non atom parameters (not currently used)
@param globalParameters the values of global parameters
@param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy
--------------------------------------------------------------------------------------- */
void
ReferenceCustomNonbondedIxn
::
calculatePairIxn
(
int
numberOfAtoms
,
vector
<
Vec3
>&
atomCoordinates
,
double
**
atomParameters
,
vector
<
set
<
int
>
>&
exclusions
,
double
*
fixedParameters
,
const
map
<
string
,
double
>&
globalParameters
,
vector
<
Vec3
>&
forces
,
double
*
energyByAtom
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
vector
<
vector
<
double
>
>&
atomParameters
,
vector
<
set
<
int
>
>&
exclusions
,
const
map
<
string
,
double
>&
globalParameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
for
(
auto
&
param
:
globalParameters
)
expressionSet
.
setVariable
(
expressionSet
.
getVariableIndex
(
param
.
first
),
param
.
second
);
...
...
@@ -177,7 +175,7 @@ void ReferenceCustomNonbondedIxn::calculatePairIxn(int numberOfAtoms, vector<Vec
expressionSet
.
setVariable
(
particleParamIndex
[
j
*
2
],
atomParameters
[
*
atom1
][
j
]);
expressionSet
.
setVariable
(
particleParamIndex
[
j
*
2
+
1
],
atomParameters
[
*
atom2
][
j
]);
}
calculateOneIxn
(
*
atom1
,
*
atom2
,
atomCoordinates
,
forces
,
energyByAtom
,
totalEnergy
,
energyParamDerivs
);
calculateOneIxn
(
*
atom1
,
*
atom2
,
atomCoordinates
,
forces
,
totalEnergy
,
energyParamDerivs
);
}
}
}
...
...
@@ -190,7 +188,7 @@ void ReferenceCustomNonbondedIxn::calculatePairIxn(int numberOfAtoms, vector<Vec
expressionSet
.
setVariable
(
particleParamIndex
[
j
*
2
],
atomParameters
[
pair
.
first
][
j
]);
expressionSet
.
setVariable
(
particleParamIndex
[
j
*
2
+
1
],
atomParameters
[
pair
.
second
][
j
]);
}
calculateOneIxn
(
pair
.
first
,
pair
.
second
,
atomCoordinates
,
forces
,
energyByAtom
,
totalEnergy
,
energyParamDerivs
);
calculateOneIxn
(
pair
.
first
,
pair
.
second
,
atomCoordinates
,
forces
,
totalEnergy
,
energyParamDerivs
);
}
}
else
{
...
...
@@ -203,7 +201,7 @@ void ReferenceCustomNonbondedIxn::calculatePairIxn(int numberOfAtoms, vector<Vec
expressionSet
.
setVariable
(
particleParamIndex
[
j
*
2
],
atomParameters
[
ii
][
j
]);
expressionSet
.
setVariable
(
particleParamIndex
[
j
*
2
+
1
],
atomParameters
[
jj
][
j
]);
}
calculateOneIxn
(
ii
,
jj
,
atomCoordinates
,
forces
,
energyByAtom
,
totalEnergy
,
energyParamDerivs
);
calculateOneIxn
(
ii
,
jj
,
atomCoordinates
,
forces
,
totalEnergy
,
energyParamDerivs
);
}
}
}
...
...
@@ -217,15 +215,13 @@ void ReferenceCustomNonbondedIxn::calculatePairIxn(int numberOfAtoms, vector<Vec
@param ii the index of the first atom
@param jj the index of the second atom
@param atomCoordinates atom coordinates
@param atomParameters atom parameters (charges, c6, c12, ...) atomParameters[atomIndex][paramterIndex]
@param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy
--------------------------------------------------------------------------------------- */
void
ReferenceCustomNonbondedIxn
::
calculateOneIxn
(
int
ii
,
int
jj
,
vector
<
Vec3
>&
atomCoordinates
,
vector
<
Vec3
>&
forces
,
double
*
energyByAtom
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
// get deltaR, R2, and R between 2 atoms
double
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
...
...
@@ -262,14 +258,8 @@ void ReferenceCustomNonbondedIxn::calculateOneIxn(int ii, int jj, vector<Vec3>&
// accumulate energies
if
(
totalEnergy
||
energyByAtom
)
{
if
(
totalEnergy
)
*
totalEnergy
+=
energy
;
if
(
energyByAtom
)
{
energyByAtom
[
ii
]
+=
energy
;
energyByAtom
[
jj
]
+=
energy
;
}
}
}
platforms/reference/src/SimTKReference/ReferenceCustomTorsionIxn.cpp
View file @
8f8aa247
...
...
@@ -81,9 +81,9 @@ void ReferenceCustomTorsionIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */
void
ReferenceCustomTorsionIxn
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceCustomTorsionIxn
::
calculateBondIxn
(
vector
<
int
>&
atomIndices
,
vector
<
Vec3
>&
atomCoordinates
,
double
*
parameters
,
vector
<
double
>&
parameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
double
deltaR
[
3
][
ReferenceForce
::
LastDeltaRIndex
];
...
...
platforms/reference/src/SimTKReference/ReferenceHarmonicBondIxn.cpp
View file @
8f8aa247
...
...
@@ -70,9 +70,9 @@ void ReferenceHarmonicBondIxn::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */
void
ReferenceHarmonicBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceHarmonicBondIxn
::
calculateBondIxn
(
vector
<
int
>&
atomIndices
,
vector
<
Vec3
>&
atomCoordinates
,
double
*
parameters
,
vector
<
double
>&
parameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
double
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
...
...
platforms/reference/src/SimTKReference/ReferenceLJCoulomb14.cpp
View file @
8f8aa247
...
...
@@ -65,8 +65,8 @@ ReferenceLJCoulomb14::~ReferenceLJCoulomb14() {
--------------------------------------------------------------------------------------- */
void
ReferenceLJCoulomb14
::
calculateBondIxn
(
int
*
atomIndices
,
vector
<
Vec3
>&
atomCoordinates
,
double
*
parameters
,
vector
<
Vec3
>&
forces
,
void
ReferenceLJCoulomb14
::
calculateBondIxn
(
vector
<
int
>&
atomIndices
,
vector
<
Vec3
>&
atomCoordinates
,
vector
<
double
>&
parameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
double
deltaR
[
2
][
ReferenceForce
::
LastDeltaRIndex
];
...
...
platforms/reference/src/SimTKReference/ReferenceLJCoulombIxn.cpp
View file @
8f8aa247
/* Portions copyright (c) 2006-201
3
Stanford University and Simbios.
/* Portions copyright (c) 2006-201
8
Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -176,9 +176,7 @@ void ReferenceLJCoulombIxn::setUseLJPME(double alpha, int meshSize[3]) {
@param atomParameters atom parameters atomParameters[atomIndex][paramterIndex]
@param exclusions atom exclusion indices
exclusions[atomIndex] contains the list of exclusions for that atom
@param fixedParameters non atom parameters (not currently used)
@param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy
@param includeDirect true if direct space interactions should be included
@param includeReciprocal true if reciprocal space interactions should be included
...
...
@@ -186,9 +184,8 @@ void ReferenceLJCoulombIxn::setUseLJPME(double alpha, int meshSize[3]) {
--------------------------------------------------------------------------------------- */
void
ReferenceLJCoulombIxn
::
calculateEwaldIxn
(
int
numberOfAtoms
,
vector
<
Vec3
>&
atomCoordinates
,
double
**
atomParameters
,
vector
<
set
<
int
>
>&
exclusions
,
double
*
fixedParameters
,
vector
<
Vec3
>&
forces
,
double
*
energyByAtom
,
double
*
totalEnergy
,
bool
includeDirect
,
bool
includeReciprocal
)
const
{
vector
<
vector
<
double
>
>&
atomParameters
,
vector
<
set
<
int
>
>&
exclusions
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
bool
includeDirect
,
bool
includeReciprocal
)
const
{
typedef
std
::
complex
<
double
>
d_complex
;
static
const
double
epsilon
=
1.0
;
...
...
@@ -224,9 +221,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a
selfEwaldEnergy
-=
pow
(
alphaDispersionEwald
,
6.0
)
*
64.0
*
pow
(
atomParameters
[
atomID
][
SigIndex
],
6.0
)
*
pow
(
atomParameters
[
atomID
][
EpsIndex
],
2.0
)
/
12.0
;
}
totalSelfEwaldEnergy
-=
selfEwaldEnergy
;
if
(
energyByAtom
)
{
energyByAtom
[
atomID
]
-=
selfEwaldEnergy
;
}
}
}
...
...
@@ -252,10 +246,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a
if
(
totalEnergy
)
*
totalEnergy
+=
recipEnergy
;
if
(
energyByAtom
)
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
energyByAtom
[
n
]
+=
recipEnergy
;
pme_destroy
(
pmedata
);
if
(
ljpme
)
{
...
...
@@ -275,10 +265,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a
}
if
(
totalEnergy
)
*
totalEnergy
+=
recipDispersionEnergy
;
if
(
energyByAtom
)
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
energyByAtom
[
n
]
+=
recipDispersionEnergy
;
pme_destroy
(
pmedata
);
}
}
...
...
@@ -374,10 +360,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a
if
(
totalEnergy
)
*
totalEnergy
+=
recipEnergy
;
if
(
energyByAtom
)
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
energyByAtom
[
n
]
+=
recipEnergy
;
lowrz
=
1
-
numRz
;
}
lowry
=
1
-
numRy
;
...
...
@@ -473,11 +455,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a
totalVdwEnergy
+=
vdwEnergy
;
totalRealSpaceEwaldEnergy
+=
realSpaceEwaldEnergy
;
if
(
energyByAtom
)
{
energyByAtom
[
ii
]
+=
realSpaceEwaldEnergy
+
vdwEnergy
;
energyByAtom
[
jj
]
+=
realSpaceEwaldEnergy
+
vdwEnergy
;
}
}
if
(
totalEnergy
)
...
...
@@ -537,10 +514,6 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a
}
totalExclusionEnergy
+=
realSpaceEwaldEnergy
;
if
(
energyByAtom
)
{
energyByAtom
[
ii
]
-=
realSpaceEwaldEnergy
;
energyByAtom
[
jj
]
-=
realSpaceEwaldEnergy
;
}
}
}
...
...
@@ -558,9 +531,7 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a
@param atomParameters atom parameters atomParameters[atomIndex][paramterIndex]
@param exclusions atom exclusion indices
exclusions[atomIndex] contains the list of exclusions for that atom
@param fixedParameters non atom parameters (not currently used)
@param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy
@param includeDirect true if direct space interactions should be included
@param includeReciprocal true if reciprocal space interactions should be included
...
...
@@ -568,12 +539,11 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<Vec3>& a
--------------------------------------------------------------------------------------- */
void
ReferenceLJCoulombIxn
::
calculatePairIxn
(
int
numberOfAtoms
,
vector
<
Vec3
>&
atomCoordinates
,
double
**
atomParameters
,
vector
<
set
<
int
>
>&
exclusions
,
double
*
fixedParameters
,
vector
<
Vec3
>&
forces
,
double
*
energyByAtom
,
double
*
totalEnergy
,
bool
includeDirect
,
bool
includeReciprocal
)
const
{
vector
<
vector
<
double
>
>&
atomParameters
,
vector
<
set
<
int
>
>&
exclusions
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
bool
includeDirect
,
bool
includeReciprocal
)
const
{
if
(
ewald
||
pme
||
ljpme
)
{
calculateEwaldIxn
(
numberOfAtoms
,
atomCoordinates
,
atomParameters
,
exclusions
,
f
ixedParameters
,
forces
,
energyByAtom
,
calculateEwaldIxn
(
numberOfAtoms
,
atomCoordinates
,
atomParameters
,
exclusions
,
f
orces
,
totalEnergy
,
includeDirect
,
includeReciprocal
);
return
;
}
...
...
@@ -581,7 +551,7 @@ void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<Vec3>& at
return
;
if
(
cutoff
)
{
for
(
auto
&
pair
:
*
neighborList
)
calculateOneIxn
(
pair
.
first
,
pair
.
second
,
atomCoordinates
,
atomParameters
,
forces
,
energyByAtom
,
totalEnergy
);
calculateOneIxn
(
pair
.
first
,
pair
.
second
,
atomCoordinates
,
atomParameters
,
forces
,
totalEnergy
);
}
else
{
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
)
{
...
...
@@ -589,7 +559,7 @@ void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<Vec3>& at
for
(
int
jj
=
ii
+
1
;
jj
<
numberOfAtoms
;
jj
++
)
if
(
exclusions
[
jj
].
find
(
ii
)
==
exclusions
[
jj
].
end
())
calculateOneIxn
(
ii
,
jj
,
atomCoordinates
,
atomParameters
,
forces
,
energyByAtom
,
totalEnergy
);
calculateOneIxn
(
ii
,
jj
,
atomCoordinates
,
atomParameters
,
forces
,
totalEnergy
);
}
}
}
...
...
@@ -603,14 +573,13 @@ void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<Vec3>& at
@param atomCoordinates atom coordinates
@param atomParameters atom parameters (charges, c6, c12, ...) atomParameters[atomIndex][paramterIndex]
@param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy
--------------------------------------------------------------------------------------- */
void
ReferenceLJCoulombIxn
::
calculateOneIxn
(
int
ii
,
int
jj
,
vector
<
Vec3
>&
atomCoordinates
,
double
**
atomParameters
,
vector
<
Vec3
>&
forces
,
double
*
energyByAtom
,
double
*
totalEnergy
)
const
{
vector
<
vector
<
double
>
>&
atomParameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
)
const
{
double
deltaR
[
2
][
ReferenceForce
::
LastDeltaRIndex
];
// get deltaR, R2, and R between 2 atoms
...
...
@@ -665,9 +634,5 @@ void ReferenceLJCoulombIxn::calculateOneIxn(int ii, int jj, vector<Vec3>& atomCo
if
(
totalEnergy
)
*
totalEnergy
+=
energy
;
if
(
energyByAtom
)
{
energyByAtom
[
ii
]
+=
energy
;
energyByAtom
[
jj
]
+=
energy
;
}
}
platforms/reference/src/SimTKReference/ReferenceProperDihedralBond.cpp
View file @
8f8aa247
...
...
@@ -71,9 +71,9 @@ void ReferenceProperDihedralBond::setPeriodic(OpenMM::Vec3* vectors) {
--------------------------------------------------------------------------------------- */
void
ReferenceProperDihedralBond
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceProperDihedralBond
::
calculateBondIxn
(
vector
<
int
>&
atomIndices
,
vector
<
Vec3
>&
atomCoordinates
,
double
*
parameters
,
vector
<
double
>&
parameters
,
vector
<
Vec3
>&
forces
,
double
*
totalEnergy
,
double
*
energyParamDerivs
)
{
double
deltaR
[
3
][
ReferenceForce
::
LastDeltaRIndex
];
...
...
Prev
1
2
3
4
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