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
1f7866ad
Commit
1f7866ad
authored
Jul 29, 2016
by
peastman
Committed by
GitHub
Jul 29, 2016
Browse files
Merge pull request #1547 from peastman/paramderivs
Energy derivatives with respect to global parameters
parents
37787af9
7851bad8
Changes
128
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
208 additions
and
160 deletions
+208
-160
platforms/opencl/src/kernels/customCentroidBond.cl
platforms/opencl/src/kernels/customCentroidBond.cl
+2
-0
platforms/opencl/src/kernels/customGBEnergyN2.cl
platforms/opencl/src/kernels/customGBEnergyN2.cl
+6
-0
platforms/opencl/src/kernels/customGBEnergyN2_cpu.cl
platforms/opencl/src/kernels/customGBEnergyN2_cpu.cl
+6
-0
platforms/opencl/src/kernels/customGBEnergyPerParticle.cl
platforms/opencl/src/kernels/customGBEnergyPerParticle.cl
+2
-0
platforms/opencl/src/kernels/customGBGradientChainRule.cl
platforms/opencl/src/kernels/customGBGradientChainRule.cl
+2
-0
platforms/opencl/src/kernels/customGBValueN2.cl
platforms/opencl/src/kernels/customGBValueN2.cl
+30
-10
platforms/opencl/src/kernels/customGBValueN2_cpu.cl
platforms/opencl/src/kernels/customGBValueN2_cpu.cl
+37
-19
platforms/opencl/src/kernels/customGBValuePerParticle.cl
platforms/opencl/src/kernels/customGBValuePerParticle.cl
+1
-0
platforms/opencl/src/kernels/customIntegratorPerDof.cl
platforms/opencl/src/kernels/customIntegratorPerDof.cl
+2
-1
platforms/opencl/src/kernels/customNonbonded.cl
platforms/opencl/src/kernels/customNonbonded.cl
+8
-5
platforms/opencl/src/kernels/nonbonded.cl
platforms/opencl/src/kernels/nonbonded.cl
+6
-0
platforms/reference/include/ReferenceAngleBondIxn.h
platforms/reference/include/ReferenceAngleBondIxn.h
+2
-2
platforms/reference/include/ReferenceBondIxn.h
platforms/reference/include/ReferenceBondIxn.h
+2
-2
platforms/reference/include/ReferenceCMAPTorsionIxn.h
platforms/reference/include/ReferenceCMAPTorsionIxn.h
+2
-2
platforms/reference/include/ReferenceCustomAngleIxn.h
platforms/reference/include/ReferenceCustomAngleIxn.h
+8
-7
platforms/reference/include/ReferenceCustomBondIxn.h
platforms/reference/include/ReferenceCustomBondIxn.h
+8
-7
platforms/reference/include/ReferenceCustomCentroidBondIxn.h
platforms/reference/include/ReferenceCustomCentroidBondIxn.h
+22
-20
platforms/reference/include/ReferenceCustomCompoundBondIxn.h
platforms/reference/include/ReferenceCustomCompoundBondIxn.h
+22
-20
platforms/reference/include/ReferenceCustomDynamics.h
platforms/reference/include/ReferenceCustomDynamics.h
+4
-0
platforms/reference/include/ReferenceCustomGBIxn.h
platforms/reference/include/ReferenceCustomGBIxn.h
+36
-65
No files found.
platforms/opencl/src/kernels/customCentroidBond.cl
View file @
1f7866ad
...
...
@@ -116,10 +116,12 @@ __kernel void computeGroupForces(__global long* restrict groupForce, __global mi
__global
const
int*
restrict
bondGroups,
real4
periodicBoxSize,
real4
invPeriodicBoxSize,
real4
periodicBoxVecX,
real4
periodicBoxVecY,
real4
periodicBoxVecZ
EXTRA_ARGS
)
{
mixed
energy
=
0
;
INIT_PARAM_DERIVS
for
(
int
index
=
get_global_id
(
0
)
; index < NUM_BONDS; index += get_global_size(0)) {
COMPUTE_FORCE
}
energyBuffer[get_global_id
(
0
)
]
+=
energy
;
SAVE_PARAM_DERIVS
}
/**
...
...
platforms/opencl/src/kernels/customGBEnergyN2.cl
View file @
1f7866ad
...
...
@@ -32,6 +32,7 @@ __kernel void computeN2Energy(
const
unsigned
int
tgx
=
get_local_id
(
0
)
&
(
TILE_SIZE-1
)
;
const
unsigned
int
tbx
=
get_local_id
(
0
)
-
tgx
;
mixed
energy
=
0
;
INIT_PARAM_DERIVS
//
First
loop:
process
tiles
that
contain
exclusions.
...
...
@@ -73,6 +74,7 @@ __kernel void computeN2Energy(
atom2
=
y*TILE_SIZE+j
;
real
dEdR
=
0
;
real
tempEnergy
=
0
;
const
real
interactionScale
=
0.5f
;
#
ifdef
USE_EXCLUSIONS
bool
isExcluded
=
!
(
excl
&
0x1
)
;
#
endif
...
...
@@ -123,6 +125,7 @@ __kernel void computeN2Energy(
atom2 = y*TILE_SIZE+tj;
real dEdR = 0;
real tempEnergy = 0;
const real interactionScale = 1.0f;
#ifdef USE_EXCLUSIONS
bool isExcluded = !(excl & 0x1);
#endif
...
...
@@ -281,6 +284,7 @@ __kernel void computeN2Energy(
atom2
=
atomIndices[tbx+tj]
;
real
dEdR
=
0
;
real
tempEnergy
=
0
;
const
real
interactionScale
=
1.0f
;
if
(
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
COMPUTE_INTERACTION
dEdR
/=
-r
;
...
...
@@ -319,6 +323,7 @@ __kernel void computeN2Energy(
atom2
=
atomIndices[tbx+tj]
;
real
dEdR
=
0
;
real
tempEnergy
=
0
;
const
real
interactionScale
=
1.0f
;
if
(
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
COMPUTE_INTERACTION
dEdR
/=
-r
;
...
...
@@ -373,4 +378,5 @@ __kernel void computeN2Energy(
pos++
;
}
energyBuffer[get_global_id
(
0
)
]
+=
energy
;
SAVE_PARAM_DERIVS
}
platforms/opencl/src/kernels/customGBEnergyN2_cpu.cl
View file @
1f7866ad
...
...
@@ -28,6 +28,7 @@ __kernel void computeN2Energy(
#
endif
PARAMETER_ARGUMENTS
)
{
mixed
energy
=
0
;
INIT_PARAM_DERIVS
//
First
loop:
process
tiles
that
contain
exclusions.
...
...
@@ -74,6 +75,7 @@ __kernel void computeN2Energy(
atom2
=
y*TILE_SIZE+j
;
real
dEdR
=
0
;
real
tempEnergy
=
0
;
const
real
interactionScale
=
0.5f
;
#
ifdef
USE_EXCLUSIONS
bool
isExcluded
=
!
(
excl
&
0x1
)
;
#
endif
...
...
@@ -140,6 +142,7 @@ __kernel void computeN2Energy(
atom2
=
y*TILE_SIZE+j
;
real
dEdR
=
0
;
real
tempEnergy
=
0
;
const
real
interactionScale
=
1.0f
;
#
ifdef
USE_EXCLUSIONS
bool
isExcluded
=
(
atom1
>=
NUM_ATOMS
|
| atom2 >= NUM_ATOMS || !(excl & 0x1));
if (!isExcluded) {
...
...
@@ -291,6 +294,7 @@ __kernel void computeN2Energy(
atom2
=
atomIndices[j]
;
real
dEdR
=
0
;
real
tempEnergy
=
0
;
const
real
interactionScale
=
1.0f
;
COMPUTE_INTERACTION
dEdR
/=
-r
;
energy
+=
tempEnergy
;
...
...
@@ -347,6 +351,7 @@ __kernel void computeN2Energy(
atom2
=
atomIndices[j]
;
real
dEdR
=
0
;
real
tempEnergy
=
0
;
const
real
interactionScale
=
1.0f
;
COMPUTE_INTERACTION
dEdR
/=
-r
;
energy
+=
tempEnergy
;
...
...
@@ -400,4 +405,5 @@ __kernel void computeN2Energy(
pos++
;
}
energyBuffer[get_global_id
(
0
)
]
+=
energy
;
SAVE_PARAM_DERIVS
}
platforms/opencl/src/kernels/customGBEnergyPerParticle.cl
View file @
1f7866ad
...
...
@@ -12,6 +12,7 @@
__kernel
void
computePerParticleEnergy
(
int
bufferSize,
int
numBuffers,
__global
real4*
restrict
forceBuffers,
__global
mixed*
restrict
energyBuffer,
__global
const
real4*
restrict
posq
PARAMETER_ARGUMENTS
)
{
mixed
energy
=
0
;
INIT_PARAM_DERIVS
unsigned
int
index
=
get_global_id
(
0
)
;
while
(
index
<
NUM_ATOMS
)
{
//
Reduce
the
derivatives
...
...
@@ -27,4 +28,5 @@ __kernel void computePerParticleEnergy(int bufferSize, int numBuffers, __global
index
+=
get_global_size
(
0
)
;
}
energyBuffer[get_global_id
(
0
)
]
+=
energy
;
SAVE_PARAM_DERIVS
}
platforms/opencl/src/kernels/customGBGradientChainRule.cl
View file @
1f7866ad
...
...
@@ -4,6 +4,7 @@
__kernel
void
computeGradientChainRuleTerms
(
__global
real4*
restrict
forceBuffers,
__global
const
real4*
restrict
posq
PARAMETER_ARGUMENTS
)
{
INIT_PARAM_DERIVS
unsigned
int
index
=
get_global_id
(
0
)
;
while
(
index
<
NUM_ATOMS
)
{
real4
pos
=
posq[index]
;
...
...
@@ -12,4 +13,5 @@ __kernel void computeGradientChainRuleTerms(__global real4* restrict forceBuffer
forceBuffers[index]
=
force
;
index
+=
get_global_size
(
0
)
;
}
SAVE_PARAM_DERIVS
}
platforms/opencl/src/kernels/customGBValueN2.cl
View file @
1f7866ad
...
...
@@ -74,6 +74,7 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
COMPUTE_VALUE
}
value += tempValue1;
ADD_TEMP_DERIVS1
#ifdef USE_CUTOFF
}
#endif
...
...
@@ -123,6 +124,8 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
}
value += tempValue1;
local_value[tbx+tj] += tempValue2;
ADD_TEMP_DERIVS1
ADD_TEMP_DERIVS2
#ifdef USE_CUTOFF
}
#endif
...
...
@@ -137,18 +140,23 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
// Write results.
#ifdef SUPPORTS_64_BIT_ATOMICS
unsigned int offset = x*TILE_SIZE + tgx;
atom_add(&global_value[offset], (long) (value*0x100000000));
unsigned int offset1 = x*TILE_SIZE + tgx;
atom_add(&global_value[offset1], (long) (value*0x100000000));
STORE_PARAM_DERIVS1
if (x != y) {
offset = y*TILE_SIZE + tgx;
atom_add(&global_value[offset], (long) (local_value[get_local_id(0)]*0x100000000));
unsigned int offset2 = y*TILE_SIZE + tgx;
atom_add(&global_value[offset2], (long) (local_value[get_local_id(0)]*0x100000000));
STORE_PARAM_DERIVS2
}
#else
unsigned int offset1 = x*TILE_SIZE + tgx + warp*PADDED_NUM_ATOMS;
unsigned int offset2 = y*TILE_SIZE + tgx + warp*PADDED_NUM_ATOMS;
global_value[offset1] += value;
if (x != y)
STORE_PARAM_DERIVS1
if (x != y) {
global_value[offset2] += local_value[get_local_id(0)];
STORE_PARAM_DERIVS2
}
#endif
}
...
...
@@ -259,6 +267,8 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
}
value
+=
tempValue1
;
local_value[tbx+tj]
+=
tempValue2
;
ADD_TEMP_DERIVS1
ADD_TEMP_DERIVS2
}
tj
=
(
tj
+
1
)
&
(
TILE_SIZE
-
1
)
;
SYNC_WARPS
;
...
...
@@ -292,6 +302,8 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
}
value
+=
tempValue1
;
local_value[tbx+tj]
+=
tempValue2
;
ADD_TEMP_DERIVS1
ADD_TEMP_DERIVS2
#
ifdef
USE_CUTOFF
}
#
endif
...
...
@@ -308,15 +320,23 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
unsigned
int
atom2
=
y*TILE_SIZE
+
tgx
;
#
endif
#
ifdef
SUPPORTS_64_BIT_ATOMICS
atom_add
(
&global_value[atom1],
(
long
)
(
value*0x100000000
))
;
if
(
atom2
<
PADDED_NUM_ATOMS
)
atom_add
(
&global_value[atom2],
(
long
)
(
local_value[get_local_id
(
0
)
]*0x100000000
))
;
unsigned
int
offset1
=
atom1
;
atom_add
(
&global_value[offset1],
(
long
)
(
value*0x100000000
))
;
STORE_PARAM_DERIVS1
if
(
atom2
<
PADDED_NUM_ATOMS
)
{
unsigned
int
offset2
=
atom2
;
atom_add
(
&global_value[offset2],
(
long
)
(
local_value[get_local_id
(
0
)
]*0x100000000
))
;
STORE_PARAM_DERIVS2
}
#
else
unsigned
int
offset1
=
atom1
+
warp*PADDED_NUM_ATOMS
;
unsigned
int
offset2
=
atom2
+
warp*PADDED_NUM_ATOMS
;
global_value[offset1]
+=
value
;
if
(
atom2
<
PADDED_NUM_ATOMS
)
STORE_PARAM_DERIVS1
if
(
atom2
<
PADDED_NUM_ATOMS
)
{
unsigned
int
offset2
=
atom2
+
warp*PADDED_NUM_ATOMS
;
global_value[offset2]
+=
local_value[get_local_id
(
0
)
]
;
STORE_PARAM_DERIVS2
}
#
endif
}
pos++
;
...
...
platforms/opencl/src/kernels/customGBValueN2_cpu.cl
View file @
1f7866ad
...
...
@@ -75,6 +75,7 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
COMPUTE_VALUE
}
value += tempValue1;
ADD_TEMP_DERIVS1
#ifdef USE_CUTOFF
}
#endif
...
...
@@ -86,11 +87,13 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
// Write results.
#ifdef SUPPORTS_64_BIT_ATOMICS
atom_add(&global_value[atom1], (long) (value*0x100000000));
unsigned int offset1 = atom1;
atom_add(&global_value[offset1], (long) (value*0x100000000));
#else
unsigned int offset = atom1 + get_group_id(0)*PADDED_NUM_ATOMS;
global_value[offset] += value;
unsigned int offset
1
= atom1 + get_group_id(0)*PADDED_NUM_ATOMS;
global_value[offset
1
] += value;
#endif
STORE_PARAM_DERIVS1
}
}
else {
...
...
@@ -133,6 +136,8 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
}
value += tempValue1;
local_value[j] += tempValue2;
ADD_TEMP_DERIVS1
ADD_TEMP_DERIVS2
#ifdef USE_CUTOFF
}
#endif
...
...
@@ -144,23 +149,26 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
// Write results for atom1.
#ifdef SUPPORTS_64_BIT_ATOMICS
atom_add(&global_value[atom1], (long) (value*0x100000000));
unsigned int offset1 = atom1;
atom_add(&global_value[offset1], (long) (value*0x100000000));
#else
unsigned int offset = atom1 + get_group_id(0)*PADDED_NUM_ATOMS;
global_value[offset] += value;
unsigned int offset
1
= atom1 + get_group_id(0)*PADDED_NUM_ATOMS;
global_value[offset
1
] += value;
#endif
STORE_PARAM_DERIVS1
}
// Write results.
for (int tgx = 0; tgx < TILE_SIZE; tgx++) {
#ifdef SUPPORTS_64_BIT_ATOMICS
unsigned int offset = y*TILE_SIZE+tgx;
atom_add(&global_value[offset], (long) (local_value[tgx]*0x100000000));
unsigned int offset
2
= y*TILE_SIZE+tgx;
atom_add(&global_value[offset
2
], (long) (local_value[tgx]*0x100000000));
#else
unsigned int offset = y*TILE_SIZE+tgx + get_group_id(0)*PADDED_NUM_ATOMS;
global_value[offset] += local_value[tgx];
unsigned int offset
2
= y*TILE_SIZE+tgx + get_group_id(0)*PADDED_NUM_ATOMS;
global_value[offset
2
] += local_value[tgx];
#endif
STORE_PARAM_DERIVS2
}
}
}
...
...
@@ -260,17 +268,21 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
COMPUTE_VALUE
value
+=
tempValue1
;
local_value[j]
+=
tempValue2
;
ADD_TEMP_DERIVS1
ADD_TEMP_DERIVS2
}
}
//
Write
results
for
atom1.
#
ifdef
SUPPORTS_64_BIT_ATOMICS
atom_add
(
&global_value[atom1],
(
long
)
(
value*0x100000000
))
;
unsigned
int
offset1
=
atom1
;
atom_add
(
&global_value[offset1],
(
long
)
(
value*0x100000000
))
;
#
else
unsigned
int
offset
=
atom1
+
get_group_id
(
0
)
*PADDED_NUM_ATOMS
;
global_value[offset]
+=
value
;
unsigned
int
offset
1
=
atom1
+
get_group_id
(
0
)
*PADDED_NUM_ATOMS
;
global_value[offset
1
]
+=
value
;
#
endif
STORE_PARAM_DERIVS1
}
}
else
...
...
@@ -305,17 +317,21 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
COMPUTE_VALUE
value
+=
tempValue1
;
local_value[j]
+=
tempValue2
;
ADD_TEMP_DERIVS1
ADD_TEMP_DERIVS2
}
}
//
Write
results
for
atom1.
#
ifdef
SUPPORTS_64_BIT_ATOMICS
atom_add
(
&global_value[atom1],
(
long
)
(
value*0x100000000
))
;
unsigned
int
offset1
=
atom1
;
atom_add
(
&global_value[offset1],
(
long
)
(
value*0x100000000
))
;
#
else
unsigned
int
offset
=
atom1
+
get_group_id
(
0
)
*PADDED_NUM_ATOMS
;
global_value[offset]
+=
value
;
unsigned
int
offset
1
=
atom1
+
get_group_id
(
0
)
*PADDED_NUM_ATOMS
;
global_value[offset
1
]
+=
value
;
#
endif
STORE_PARAM_DERIVS1
}
}
...
...
@@ -329,11 +345,13 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
#
endif
if
(
atom2
<
PADDED_NUM_ATOMS
)
{
#
ifdef
SUPPORTS_64_BIT_ATOMICS
atom_add
(
&global_value[atom2],
(
long
)
(
local_value[tgx]*0x100000000
))
;
unsigned
int
offset2
=
atom2
;
atom_add
(
&global_value[offset2],
(
long
)
(
local_value[tgx]*0x100000000
))
;
#
else
unsigned
int
offset
=
atom2
+
get_group_id
(
0
)
*PADDED_NUM_ATOMS
;
global_value[offset]
+=
local_value[tgx]
;
unsigned
int
offset
2
=
atom2
+
get_group_id
(
0
)
*PADDED_NUM_ATOMS
;
global_value[offset
2
]
+=
local_value[tgx]
;
#
endif
STORE_PARAM_DERIVS2
}
}
}
...
...
platforms/opencl/src/kernels/customGBValuePerParticle.cl
View file @
1f7866ad
...
...
@@ -21,6 +21,7 @@ __kernel void computePerParticleValues(int bufferSize, int numBuffers, __global
for
(
int
i
=
index+bufferSize
; i < totalSize; i += bufferSize)
sum
+=
valueBuffers[i]
;
#
endif
REDUCE_PARAM0_DERIV
//
Now
calculate
other
values
...
...
platforms/opencl/src/kernels/customIntegratorPerDof.cl
View file @
1f7866ad
...
...
@@ -25,7 +25,8 @@ void storePos(__global real4* restrict posq, __global real4* restrict posqCorrec
__kernel
void
computePerDof
(
__global
real4*
restrict
posq,
__global
real4*
restrict
posqCorrection,
__global
mixed4*
restrict
posDelta,
__global
mixed4*
restrict
velm,
__global
const
real4*
restrict
force,
__global
const
mixed2*
restrict
dt,
__global
const
mixed*
restrict
globals,
__global
mixed*
restrict
sum,
__global
const
float4*
restrict
gaussianValues,
unsigned
int
gaussianBaseIndex,
__global
const
float4*
restrict
uniformValues,
const
real
energy
__global
mixed*
restrict
sum,
__global
const
float4*
restrict
gaussianValues,
unsigned
int
gaussianBaseIndex,
__global
const
float4*
restrict
uniformValues,
const
real
energy,
__global
mixed*
restrict
energyParamDerivs
PARAMETER_ARGUMENTS
)
{
mixed
stepSize
=
dt[0].y
;
int
index
=
get_global_id
(
0
)
;
...
...
platforms/opencl/src/kernels/customNonbonded.cl
View file @
1f7866ad
...
...
@@ -4,15 +4,18 @@ if (!isExcluded && r2 < CUTOFF_SQUARED) {
if
(
!isExcluded
)
{
#
endif
real
tempForce
=
0.0f
;
COMPUTE_FORCE
real
switchValue
=
1
,
switchDeriv
=
0
;
#
if
USE_SWITCH
if
(
r
>
SWITCH_CUTOFF
)
{
real
x
=
r-SWITCH_CUTOFF
;
real
switchValue
=
1+x*x*x*
(
SWITCH_C3+x*
(
SWITCH_C4+x*SWITCH_C5
))
;
real
switchDeriv
=
x*x*
(
3*SWITCH_C3+x*
(
4*SWITCH_C4+x*5*SWITCH_C5
))
;
tempForce
=
tempForce*switchValue
-
tempEnergy*switchDeriv
;
tempEnergy
*=
switchValue
;
switchValue
=
1+x*x*x*
(
SWITCH_C3+x*
(
SWITCH_C4+x*SWITCH_C5
))
;
switchDeriv
=
x*x*
(
3*SWITCH_C3+x*
(
4*SWITCH_C4+x*5*SWITCH_C5
))
;
}
#
endif
COMPUTE_FORCE
#
if
USE_SWITCH
tempForce
=
tempForce*switchValue
-
tempEnergy*switchDeriv
;
tempEnergy
*=
switchValue
;
#
endif
dEdR
+=
tempForce*invR
;
}
platforms/opencl/src/kernels/nonbonded.cl
View file @
1f7866ad
...
...
@@ -35,6 +35,7 @@ __kernel void computeNonbonded(
const
unsigned
int
tgx
=
get_local_id
(
0
)
&
(
TILE_SIZE-1
)
;
const
unsigned
int
tbx
=
get_local_id
(
0
)
-
tgx
;
mixed
energy
=
0
;
INIT_DERIVATIVES
__local
AtomData
localData[FORCE_WORK_GROUP_SIZE]
;
//
First
loop:
process
tiles
that
contain
exclusions.
...
...
@@ -85,6 +86,7 @@ __kernel void computeNonbonded(
bool
isExcluded
=
(
atom1
>=
NUM_ATOMS
|
| atom2 >= NUM_ATOMS || !(excl & 0x1));
#endif
real tempEnergy = 0;
const real interactionScale = 0.5f;
COMPUTE_INTERACTION
energy += 0.5f*tempEnergy;
#ifdef INCLUDE_FORCES
...
...
@@ -144,6 +146,7 @@ __kernel void computeNonbonded(
bool
isExcluded
=
(
atom1
>=
NUM_ATOMS
|
| atom2 >= NUM_ATOMS || !(excl & 0x1));
#endif
real tempEnergy = 0;
const real interactionScale = 1.0f;
COMPUTE_INTERACTION
energy += tempEnergy;
#ifdef INCLUDE_FORCES
...
...
@@ -320,6 +323,7 @@ __kernel void computeNonbonded(
bool isExcluded = (atom1 >= NUM_ATOMS || atom2 >= NUM_ATOMS);
#endif
real tempEnergy = 0;
const real interactionScale = 1.0f;
COMPUTE_INTERACTION
energy += tempEnergy;
#ifdef INCLUDE_FORCES
...
...
@@ -374,6 +378,7 @@ __kernel void computeNonbonded(
bool isExcluded = (atom1 >= NUM_ATOMS |
|
atom2
>=
NUM_ATOMS
)
;
#
endif
real
tempEnergy
=
0
;
const
real
interactionScale
=
1.0f
;
COMPUTE_INTERACTION
energy
+=
tempEnergy
;
#
ifdef
INCLUDE_FORCES
...
...
@@ -429,4 +434,5 @@ __kernel void computeNonbonded(
#
ifdef
INCLUDE_ENERGY
energyBuffer[get_global_id
(
0
)
]
+=
energy
;
#
endif
SAVE_DERIVATIVES
}
platforms/reference/include/ReferenceAngleBondIxn.h
View file @
1f7866ad
/* Portions copyright (c) 2006 Stanford University and Simbios.
/* Portions copyright (c) 2006
-2016
Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -94,7 +94,7 @@ class OPENMM_EXPORT ReferenceAngleBondIxn : public ReferenceBondIxn {
void
calculateBondIxn
(
int
*
atomIndices
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
*
parameters
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
;
RealOpenMM
*
totalEnergy
,
double
*
energyParamDerivs
)
;
};
...
...
platforms/reference/include/ReferenceBondIxn.h
View file @
1f7866ad
/* Portions copyright (c) 2006 Stanford University and Simbios.
/* Portions copyright (c) 2006
-2016
Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -67,7 +67,7 @@ class OPENMM_EXPORT ReferenceBondIxn {
virtual
void
calculateBondIxn
(
int
*
atomIndices
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
*
parameters
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
;
RealOpenMM
*
totalEnergy
,
double
*
energyParamDerivs
)
;
/**---------------------------------------------------------------------------------------
...
...
platforms/reference/include/ReferenceCMAPTorsionIxn.h
View file @
1f7866ad
/* Portions copyright (c) 2010 Stanford University and Simbios.
/* Portions copyright (c) 2010
-2016
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -97,7 +97,7 @@ public:
void
calculateBondIxn
(
int
*
atomIndices
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
*
parameters
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
;
RealOpenMM
*
totalEnergy
,
double
*
energyParamDerivs
)
;
// ---------------------------------------------------------------------------------------
...
...
platforms/reference/include/ReferenceCustomAngleIxn.h
View file @
1f7866ad
...
...
@@ -25,7 +25,7 @@
#define __ReferenceCustomAngleIxn_H__
#include "ReferenceBondIxn.h"
#include "
lepton
/CompiledExpression.h"
#include "
openmm/internal
/CompiledExpression
Set
.h"
namespace
OpenMM
{
...
...
@@ -34,10 +34,10 @@ class ReferenceCustomAngleIxn : public ReferenceBondIxn {
private:
Lepton
::
CompiledExpression
energyExpression
;
Lepton
::
CompiledExpression
forceExpression
;
std
::
vector
<
double
*>
energyParam
s
;
std
::
vector
<
double
*>
forceParams
;
double
*
energyTheta
;
double
*
forceTheta
;
std
::
vector
<
Lepton
::
CompiledExpression
>
energyParamDerivExpression
s
;
CompiledExpressionSet
expressionSet
;
std
::
vector
<
int
>
angleParamIndex
;
int
thetaIndex
;
int
numParameters
;
bool
usePeriodic
;
RealVec
boxVectors
[
3
];
...
...
@@ -51,7 +51,8 @@ class ReferenceCustomAngleIxn : public ReferenceBondIxn {
--------------------------------------------------------------------------------------- */
ReferenceCustomAngleIxn
(
const
Lepton
::
CompiledExpression
&
energyExpression
,
const
Lepton
::
CompiledExpression
&
forceExpression
,
const
std
::
vector
<
std
::
string
>&
parameterNames
,
std
::
map
<
std
::
string
,
double
>
globalParameters
);
const
std
::
vector
<
std
::
string
>&
parameterNames
,
std
::
map
<
std
::
string
,
double
>
globalParameters
,
const
std
::
vector
<
Lepton
::
CompiledExpression
>
energyParamDerivExpressions
);
/**---------------------------------------------------------------------------------------
...
...
@@ -85,7 +86,7 @@ class ReferenceCustomAngleIxn : public ReferenceBondIxn {
void
calculateBondIxn
(
int
*
atomIndices
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
*
parameters
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
;
RealOpenMM
*
totalEnergy
,
double
*
energyParamDerivs
)
;
};
...
...
platforms/reference/include/ReferenceCustomBondIxn.h
View file @
1f7866ad
...
...
@@ -26,7 +26,7 @@
#define __ReferenceCustomBondIxn_H__
#include "ReferenceBondIxn.h"
#include "
lepton
/CompiledExpression.h"
#include "
openmm/internal
/CompiledExpression
Set
.h"
namespace
OpenMM
{
...
...
@@ -35,10 +35,10 @@ class ReferenceCustomBondIxn : public ReferenceBondIxn {
private:
Lepton
::
CompiledExpression
energyExpression
;
Lepton
::
CompiledExpression
forceExpression
;
std
::
vector
<
double
*>
energyParam
s
;
std
::
vector
<
double
*>
forceParams
;
double
*
energyR
;
double
*
forceR
;
std
::
vector
<
Lepton
::
CompiledExpression
>
energyParamDerivExpression
s
;
CompiledExpressionSet
expressionSet
;
std
::
vector
<
int
>
bondParamIndex
;
int
rIndex
;
int
numParameters
;
bool
usePeriodic
;
RealVec
boxVectors
[
3
];
...
...
@@ -52,7 +52,8 @@ class ReferenceCustomBondIxn : public ReferenceBondIxn {
--------------------------------------------------------------------------------------- */
ReferenceCustomBondIxn
(
const
Lepton
::
CompiledExpression
&
energyExpression
,
const
Lepton
::
CompiledExpression
&
forceExpression
,
const
std
::
vector
<
std
::
string
>&
parameterNames
,
std
::
map
<
std
::
string
,
double
>
globalParameters
);
const
std
::
vector
<
std
::
string
>&
parameterNames
,
std
::
map
<
std
::
string
,
double
>
globalParameters
,
const
std
::
vector
<
Lepton
::
CompiledExpression
>
energyParamDerivExpressions
);
/**---------------------------------------------------------------------------------------
...
...
@@ -86,7 +87,7 @@ class ReferenceCustomBondIxn : public ReferenceBondIxn {
void
calculateBondIxn
(
int
*
atomIndices
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
*
parameters
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
;
RealOpenMM
*
totalEnergy
,
double
*
energyParamDerivs
)
;
};
...
...
platforms/reference/include/ReferenceCustomCentroidBondIxn.h
View file @
1f7866ad
...
...
@@ -26,7 +26,7 @@
#define __ReferenceCustomCentroidBondIxn_H__
#include "ReferenceBondIxn.h"
#include "
lepton/
Expression
Program
.h"
#include "
openmm/internal/Compiled
Expression
Set
.h"
#include "lepton/ParsedExpression.h"
#include <map>
#include <vector>
...
...
@@ -44,12 +44,15 @@ class ReferenceCustomCentroidBondIxn : public ReferenceBondIxn {
std
::
vector
<
std
::
vector
<
int
>
>
groupAtoms
;
std
::
vector
<
std
::
vector
<
double
>
>
normalizedWeights
;
std
::
vector
<
std
::
vector
<
int
>
>
bondGroups
;
Lepton
::
ExpressionProgram
energyExpression
;
std
::
vector
<
std
::
string
>
bondParamNames
;
CompiledExpressionSet
expressionSet
;
Lepton
::
CompiledExpression
energyExpression
;
std
::
vector
<
Lepton
::
CompiledExpression
>
energyParamDerivExpressions
;
std
::
vector
<
int
>
bondParamIndex
;
std
::
vector
<
PositionTermInfo
>
positionTerms
;
std
::
vector
<
DistanceTermInfo
>
distanceTerms
;
std
::
vector
<
AngleTermInfo
>
angleTerms
;
std
::
vector
<
DihedralTermInfo
>
dihedralTerms
;
int
numParameters
;
bool
usePeriodic
;
RealVec
boxVectors
[
3
];
...
...
@@ -60,15 +63,13 @@ class ReferenceCustomCentroidBondIxn : public ReferenceBondIxn {
@param bond the index of the bond
@param groupCenters group center coordinates
@param variables the values of variables that may appear in expressions
@param forces force array (forces added)
@param totalEnergy total energy
--------------------------------------------------------------------------------------- */
void
calculateOneIxn
(
int
bond
,
std
::
vector
<
OpenMM
::
RealVec
>&
groupCenters
,
std
::
map
<
std
::
string
,
double
>&
variables
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
;
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
,
double
*
energyParamDerivs
);
void
computeDelta
(
int
group1
,
int
group2
,
RealOpenMM
*
delta
,
std
::
vector
<
OpenMM
::
RealVec
>&
groupCenters
)
const
;
...
...
@@ -86,7 +87,8 @@ class ReferenceCustomCentroidBondIxn : public ReferenceBondIxn {
ReferenceCustomCentroidBondIxn
(
int
numGroupsPerBond
,
const
std
::
vector
<
std
::
vector
<
int
>
>&
groupAtoms
,
const
std
::
vector
<
std
::
vector
<
double
>
>&
normalizedWeights
,
const
std
::
vector
<
std
::
vector
<
int
>
>&
bondGroups
,
const
Lepton
::
ParsedExpression
&
energyExpression
,
const
std
::
vector
<
std
::
string
>&
bondParameterNames
,
const
std
::
map
<
std
::
string
,
std
::
vector
<
int
>
>&
distances
,
const
std
::
map
<
std
::
string
,
std
::
vector
<
int
>
>&
angles
,
const
std
::
map
<
std
::
string
,
std
::
vector
<
int
>
>&
dihedrals
);
const
std
::
map
<
std
::
string
,
std
::
vector
<
int
>
>&
angles
,
const
std
::
map
<
std
::
string
,
std
::
vector
<
int
>
>&
dihedrals
,
const
std
::
vector
<
Lepton
::
CompiledExpression
>
energyParamDerivExpressions
);
/**---------------------------------------------------------------------------------------
...
...
@@ -130,7 +132,7 @@ class ReferenceCustomCentroidBondIxn : public ReferenceBondIxn {
void
calculatePairIxn
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
**
bondParameters
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
;
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
,
double
*
energyParamDerivs
)
;
// ---------------------------------------------------------------------------------------
...
...
@@ -139,9 +141,9 @@ class ReferenceCustomCentroidBondIxn : public ReferenceBondIxn {
class
ReferenceCustomCentroidBondIxn
::
PositionTermInfo
{
public:
std
::
string
name
;
int
group
,
component
;
Lepton
::
Expression
Program
forceExpression
;
PositionTermInfo
(
const
std
::
string
&
name
,
int
group
,
int
component
,
const
Lepton
::
Expression
Program
&
forceExpression
)
:
int
group
,
component
,
index
;
Lepton
::
Compiled
Expression
forceExpression
;
PositionTermInfo
(
const
std
::
string
&
name
,
int
group
,
int
component
,
const
Lepton
::
Compiled
Expression
&
forceExpression
)
:
name
(
name
),
group
(
group
),
component
(
component
),
forceExpression
(
forceExpression
)
{
}
};
...
...
@@ -149,10 +151,10 @@ public:
class
ReferenceCustomCentroidBondIxn
::
DistanceTermInfo
{
public:
std
::
string
name
;
int
g1
,
g2
;
Lepton
::
Expression
Program
forceExpression
;
int
g1
,
g2
,
index
;
Lepton
::
Compiled
Expression
forceExpression
;
mutable
RealOpenMM
delta
[
ReferenceForce
::
LastDeltaRIndex
];
DistanceTermInfo
(
const
std
::
string
&
name
,
const
std
::
vector
<
int
>&
groups
,
const
Lepton
::
Expression
Program
&
forceExpression
)
:
DistanceTermInfo
(
const
std
::
string
&
name
,
const
std
::
vector
<
int
>&
groups
,
const
Lepton
::
Compiled
Expression
&
forceExpression
)
:
name
(
name
),
g1
(
groups
[
0
]),
g2
(
groups
[
1
]),
forceExpression
(
forceExpression
)
{
}
};
...
...
@@ -160,11 +162,11 @@ public:
class
ReferenceCustomCentroidBondIxn
::
AngleTermInfo
{
public:
std
::
string
name
;
int
g1
,
g2
,
g3
;
Lepton
::
Expression
Program
forceExpression
;
int
g1
,
g2
,
g3
,
index
;
Lepton
::
Compiled
Expression
forceExpression
;
mutable
RealOpenMM
delta1
[
ReferenceForce
::
LastDeltaRIndex
];
mutable
RealOpenMM
delta2
[
ReferenceForce
::
LastDeltaRIndex
];
AngleTermInfo
(
const
std
::
string
&
name
,
const
std
::
vector
<
int
>&
groups
,
const
Lepton
::
Expression
Program
&
forceExpression
)
:
AngleTermInfo
(
const
std
::
string
&
name
,
const
std
::
vector
<
int
>&
groups
,
const
Lepton
::
Compiled
Expression
&
forceExpression
)
:
name
(
name
),
g1
(
groups
[
0
]),
g2
(
groups
[
1
]),
g3
(
groups
[
2
]),
forceExpression
(
forceExpression
)
{
}
};
...
...
@@ -172,14 +174,14 @@ public:
class
ReferenceCustomCentroidBondIxn
::
DihedralTermInfo
{
public:
std
::
string
name
;
int
g1
,
g2
,
g3
,
g4
;
Lepton
::
Expression
Program
forceExpression
;
int
g1
,
g2
,
g3
,
g4
,
index
;
Lepton
::
Compiled
Expression
forceExpression
;
mutable
RealOpenMM
delta1
[
ReferenceForce
::
LastDeltaRIndex
];
mutable
RealOpenMM
delta2
[
ReferenceForce
::
LastDeltaRIndex
];
mutable
RealOpenMM
delta3
[
ReferenceForce
::
LastDeltaRIndex
];
mutable
RealOpenMM
cross1
[
3
];
mutable
RealOpenMM
cross2
[
3
];
DihedralTermInfo
(
const
std
::
string
&
name
,
const
std
::
vector
<
int
>&
groups
,
const
Lepton
::
Expression
Program
&
forceExpression
)
:
DihedralTermInfo
(
const
std
::
string
&
name
,
const
std
::
vector
<
int
>&
groups
,
const
Lepton
::
Compiled
Expression
&
forceExpression
)
:
name
(
name
),
g1
(
groups
[
0
]),
g2
(
groups
[
1
]),
g3
(
groups
[
2
]),
g4
(
groups
[
3
]),
forceExpression
(
forceExpression
)
{
}
};
...
...
platforms/reference/include/ReferenceCustomCompoundBondIxn.h
View file @
1f7866ad
...
...
@@ -26,7 +26,7 @@
#define __ReferenceCustomCompoundBondIxn_H__
#include "ReferenceBondIxn.h"
#include "
lepton/
Expression
Program
.h"
#include "
openmm/internal/Compiled
Expression
Set
.h"
#include "lepton/ParsedExpression.h"
#include <map>
#include <vector>
...
...
@@ -42,12 +42,15 @@ class ReferenceCustomCompoundBondIxn : public ReferenceBondIxn {
class
AngleTermInfo
;
class
DihedralTermInfo
;
std
::
vector
<
std
::
vector
<
int
>
>
bondAtoms
;
Lepton
::
ExpressionProgram
energyExpression
;
std
::
vector
<
std
::
string
>
bondParamNames
;
CompiledExpressionSet
expressionSet
;
Lepton
::
CompiledExpression
energyExpression
;
std
::
vector
<
Lepton
::
CompiledExpression
>
energyParamDerivExpressions
;
std
::
vector
<
int
>
bondParamIndex
;
std
::
vector
<
ParticleTermInfo
>
particleTerms
;
std
::
vector
<
DistanceTermInfo
>
distanceTerms
;
std
::
vector
<
AngleTermInfo
>
angleTerms
;
std
::
vector
<
DihedralTermInfo
>
dihedralTerms
;
int
numParameters
;
bool
usePeriodic
;
RealVec
boxVectors
[
3
];
...
...
@@ -58,15 +61,13 @@ class ReferenceCustomCompoundBondIxn : public ReferenceBondIxn {
@param bond the index of the bond
@param atomCoordinates atom coordinates
@param variables the values of variables that may appear in expressions
@param forces force array (forces added)
@param totalEnergy total energy
--------------------------------------------------------------------------------------- */
void
calculateOneIxn
(
int
bond
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
map
<
std
::
string
,
double
>&
variables
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
;
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
,
double
*
energyParamDerivs
);
void
computeDelta
(
int
atom1
,
int
atom2
,
RealOpenMM
*
delta
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
)
const
;
...
...
@@ -83,7 +84,8 @@ class ReferenceCustomCompoundBondIxn : public ReferenceBondIxn {
ReferenceCustomCompoundBondIxn
(
int
numParticlesPerBond
,
const
std
::
vector
<
std
::
vector
<
int
>
>&
bondAtoms
,
const
Lepton
::
ParsedExpression
&
energyExpression
,
const
std
::
vector
<
std
::
string
>&
bondParameterNames
,
const
std
::
map
<
std
::
string
,
std
::
vector
<
int
>
>&
distances
,
const
std
::
map
<
std
::
string
,
std
::
vector
<
int
>
>&
angles
,
const
std
::
map
<
std
::
string
,
std
::
vector
<
int
>
>&
dihedrals
);
const
std
::
map
<
std
::
string
,
std
::
vector
<
int
>
>&
angles
,
const
std
::
map
<
std
::
string
,
std
::
vector
<
int
>
>&
dihedrals
,
const
std
::
vector
<
Lepton
::
CompiledExpression
>
energyParamDerivExpressions
);
/**---------------------------------------------------------------------------------------
...
...
@@ -127,7 +129,7 @@ class ReferenceCustomCompoundBondIxn : public ReferenceBondIxn {
void
calculatePairIxn
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
**
bondParameters
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
;
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
,
double
*
energyParamDerivs
)
;
// ---------------------------------------------------------------------------------------
...
...
@@ -136,9 +138,9 @@ class ReferenceCustomCompoundBondIxn : public ReferenceBondIxn {
class
ReferenceCustomCompoundBondIxn
::
ParticleTermInfo
{
public:
std
::
string
name
;
int
atom
,
component
;
Lepton
::
Expression
Program
forceExpression
;
ParticleTermInfo
(
const
std
::
string
&
name
,
int
atom
,
int
component
,
const
Lepton
::
Expression
Program
&
forceExpression
)
:
int
atom
,
component
,
index
;
Lepton
::
Compiled
Expression
forceExpression
;
ParticleTermInfo
(
const
std
::
string
&
name
,
int
atom
,
int
component
,
const
Lepton
::
Compiled
Expression
&
forceExpression
)
:
name
(
name
),
atom
(
atom
),
component
(
component
),
forceExpression
(
forceExpression
)
{
}
};
...
...
@@ -146,10 +148,10 @@ public:
class
ReferenceCustomCompoundBondIxn
::
DistanceTermInfo
{
public:
std
::
string
name
;
int
p1
,
p2
;
Lepton
::
Expression
Program
forceExpression
;
int
p1
,
p2
,
index
;
Lepton
::
Compiled
Expression
forceExpression
;
mutable
RealOpenMM
delta
[
ReferenceForce
::
LastDeltaRIndex
];
DistanceTermInfo
(
const
std
::
string
&
name
,
const
std
::
vector
<
int
>&
atoms
,
const
Lepton
::
Expression
Program
&
forceExpression
)
:
DistanceTermInfo
(
const
std
::
string
&
name
,
const
std
::
vector
<
int
>&
atoms
,
const
Lepton
::
Compiled
Expression
&
forceExpression
)
:
name
(
name
),
p1
(
atoms
[
0
]),
p2
(
atoms
[
1
]),
forceExpression
(
forceExpression
)
{
}
};
...
...
@@ -157,11 +159,11 @@ public:
class
ReferenceCustomCompoundBondIxn
::
AngleTermInfo
{
public:
std
::
string
name
;
int
p1
,
p2
,
p3
;
Lepton
::
Expression
Program
forceExpression
;
int
p1
,
p2
,
p3
,
index
;
Lepton
::
Compiled
Expression
forceExpression
;
mutable
RealOpenMM
delta1
[
ReferenceForce
::
LastDeltaRIndex
];
mutable
RealOpenMM
delta2
[
ReferenceForce
::
LastDeltaRIndex
];
AngleTermInfo
(
const
std
::
string
&
name
,
const
std
::
vector
<
int
>&
atoms
,
const
Lepton
::
Expression
Program
&
forceExpression
)
:
AngleTermInfo
(
const
std
::
string
&
name
,
const
std
::
vector
<
int
>&
atoms
,
const
Lepton
::
Compiled
Expression
&
forceExpression
)
:
name
(
name
),
p1
(
atoms
[
0
]),
p2
(
atoms
[
1
]),
p3
(
atoms
[
2
]),
forceExpression
(
forceExpression
)
{
}
};
...
...
@@ -169,14 +171,14 @@ public:
class
ReferenceCustomCompoundBondIxn
::
DihedralTermInfo
{
public:
std
::
string
name
;
int
p1
,
p2
,
p3
,
p4
;
Lepton
::
Expression
Program
forceExpression
;
int
p1
,
p2
,
p3
,
p4
,
index
;
Lepton
::
Compiled
Expression
forceExpression
;
mutable
RealOpenMM
delta1
[
ReferenceForce
::
LastDeltaRIndex
];
mutable
RealOpenMM
delta2
[
ReferenceForce
::
LastDeltaRIndex
];
mutable
RealOpenMM
delta3
[
ReferenceForce
::
LastDeltaRIndex
];
mutable
RealOpenMM
cross1
[
3
];
mutable
RealOpenMM
cross2
[
3
];
DihedralTermInfo
(
const
std
::
string
&
name
,
const
std
::
vector
<
int
>&
atoms
,
const
Lepton
::
Expression
Program
&
forceExpression
)
:
DihedralTermInfo
(
const
std
::
string
&
name
,
const
std
::
vector
<
int
>&
atoms
,
const
Lepton
::
Compiled
Expression
&
forceExpression
)
:
name
(
name
),
p1
(
atoms
[
0
]),
p2
(
atoms
[
1
]),
p3
(
atoms
[
2
]),
p4
(
atoms
[
3
]),
forceExpression
(
forceExpression
)
{
}
};
...
...
platforms/reference/include/ReferenceCustomDynamics.h
View file @
1f7866ad
...
...
@@ -41,6 +41,7 @@ namespace OpenMM {
class
ReferenceCustomDynamics
:
public
ReferenceDynamics
{
private:
class
DerivFunction
;
const
OpenMM
::
CustomIntegrator
&
integrator
;
std
::
vector
<
RealOpenMM
>
inverseMasses
;
std
::
vector
<
OpenMM
::
RealVec
>
sumBuffer
,
oldPos
;
...
...
@@ -51,6 +52,7 @@ private:
std
::
vector
<
bool
>
invalidatesForces
,
needsForces
,
needsEnergy
,
computeBothForceAndEnergy
;
std
::
vector
<
int
>
forceGroupFlags
,
blockEnd
;
RealOpenMM
energy
;
std
::
map
<
std
::
string
,
double
>
energyParamDerivs
;
Lepton
::
CompiledExpression
kineticEnergyExpression
;
bool
kineticEnergyNeedsForce
;
CompiledExpressionSet
expressionSet
;
...
...
@@ -59,6 +61,8 @@ private:
void
initialize
(
OpenMM
::
ContextImpl
&
context
,
std
::
vector
<
RealOpenMM
>&
masses
,
std
::
map
<
std
::
string
,
RealOpenMM
>&
globals
);
Lepton
::
ExpressionTreeNode
replaceDerivFunctions
(
const
Lepton
::
ExpressionTreeNode
&
node
,
OpenMM
::
ContextImpl
&
context
);
void
computePerDof
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
results
,
const
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
const
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
const
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
const
std
::
vector
<
RealOpenMM
>&
masses
,
const
std
::
vector
<
std
::
vector
<
OpenMM
::
RealVec
>
>&
perDof
,
const
Lepton
::
CompiledExpression
&
expression
,
int
forceIndex
);
...
...
platforms/reference/include/ReferenceCustomGBIxn.h
View file @
1f7866ad
/* Portions copyright (c) 2009 Stanford University and Simbios.
/* Portions copyright (c) 2009
-2016
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -26,7 +26,7 @@
#define __ReferenceCustomGBIxn_H__
#include "ReferenceNeighborList.h"
#include "
lepton/
Expression
Program
.h"
#include "
openmm/internal/Compiled
Expression
Set
.h"
#include "openmm/CustomGBForce.h"
#include <map>
#include <set>
...
...
@@ -43,18 +43,24 @@ class ReferenceCustomGBIxn {
const
OpenMM
::
NeighborList
*
neighborList
;
OpenMM
::
RealVec
periodicBoxVectors
[
3
];
RealOpenMM
cutoffDistance
;
std
::
vector
<
Lepton
::
ExpressionProgram
>
valueExpressions
;
std
::
vector
<
std
::
vector
<
Lepton
::
ExpressionProgram
>
>
valueDerivExpressions
;
std
::
vector
<
std
::
vector
<
Lepton
::
ExpressionProgram
>
>
valueGradientExpressions
;
std
::
vector
<
std
::
string
>
valueNames
;
CompiledExpressionSet
expressionSet
;
std
::
vector
<
Lepton
::
CompiledExpression
>
valueExpressions
;
std
::
vector
<
std
::
vector
<
Lepton
::
CompiledExpression
>
>
valueDerivExpressions
;
std
::
vector
<
std
::
vector
<
Lepton
::
CompiledExpression
>
>
valueGradientExpressions
;
std
::
vector
<
std
::
vector
<
Lepton
::
CompiledExpression
>
>
valueParamDerivExpressions
;
std
::
vector
<
OpenMM
::
CustomGBForce
::
ComputationType
>
valueTypes
;
std
::
vector
<
Lepton
::
Expression
Program
>
energyExpressions
;
std
::
vector
<
std
::
vector
<
Lepton
::
Expression
Program
>
>
energyDerivExpressions
;
std
::
vector
<
std
::
vector
<
Lepton
::
Expression
Program
>
>
energyGradientExpressions
;
std
::
vector
<
std
::
string
>
paramName
s
;
std
::
vector
<
Lepton
::
Compiled
Expression
>
energyExpressions
;
std
::
vector
<
std
::
vector
<
Lepton
::
Compiled
Expression
>
>
energyDerivExpressions
;
std
::
vector
<
std
::
vector
<
Lepton
::
Compiled
Expression
>
>
energyGradientExpressions
;
std
::
vector
<
std
::
vector
<
Lepton
::
CompiledExpression
>
>
energyParamDerivExpression
s
;
std
::
vector
<
OpenMM
::
CustomGBForce
::
ComputationType
>
energyTypes
;
std
::
vector
<
std
::
string
>
particleParamNames
;
std
::
vector
<
std
::
string
>
particleValueNames
;
std
::
vector
<
int
>
paramIndex
;
std
::
vector
<
int
>
valueIndex
;
std
::
vector
<
int
>
particleParamIndex
;
std
::
vector
<
int
>
particleValueIndex
;
int
rIndex
,
xIndex
,
yIndex
,
zIndex
;
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>
values
,
dEdV
;
std
::
vector
<
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>
>
dValuedParam
;
/**---------------------------------------------------------------------------------------
...
...
@@ -63,14 +69,11 @@ class ReferenceCustomGBIxn {
@param index the index of the value to compute
@param numAtoms number of atoms
@param atomCoordinates atom coordinates
@param values the vector to store computed values into
@param globalParameters the values of global parameters
@param atomParameters atomParameters[atomIndex][paramterIndex]
--------------------------------------------------------------------------------------- */
void
calculateSingleParticleValue
(
int
index
,
int
numAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>&
values
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
RealOpenMM
**
atomParameters
)
const
;
void
calculateSingleParticleValue
(
int
index
,
int
numAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
**
atomParameters
);
/**---------------------------------------------------------------------------------------
...
...
@@ -80,17 +83,13 @@ class ReferenceCustomGBIxn {
@param numAtoms number of atoms
@param atomCoordinates atom coordinates
@param atomParameters atomParameters[atomIndex][paramterIndex]
@param values the vector to store computed values into
@param globalParameters the values of global parameters
@param exclusions exclusions[i] is the set of excluded indices for atom i
@param useExclusions specifies whether to use exclusions
--------------------------------------------------------------------------------------- */
void
calculateParticlePairValue
(
int
index
,
int
numAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
**
atomParameters
,
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>&
values
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
,
bool
useExclusions
)
const
;
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
,
bool
useExclusions
);
/**---------------------------------------------------------------------------------------
...
...
@@ -101,14 +100,10 @@ class ReferenceCustomGBIxn {
@param atom2 the index of the second atom in the pair
@param atomCoordinates atom coordinates
@param atomParameters atomParameters[atomIndex][paramterIndex]
@param globalParameters the values of global parameters
@param values the vector to store computed values into
--------------------------------------------------------------------------------------- */
void
calculateOnePairValue
(
int
index
,
int
atom1
,
int
atom2
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
**
atomParameters
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>&
values
)
const
;
void
calculateOnePairValue
(
int
index
,
int
atom1
,
int
atom2
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
**
atomParameters
);
/**---------------------------------------------------------------------------------------
...
...
@@ -117,18 +112,14 @@ class ReferenceCustomGBIxn {
@param index the index of the value to compute
@param numAtoms number of atoms
@param atomCoordinates atom coordinates
@param values the vector containing computed values
@param globalParameters the values of global parameters
@param atomParameters atomParameters[atomIndex][paramterIndex]
@param forces forces on atoms are added to this
@param totalEnergy the energy contribution is added to this
@param dEdV the derivative of energy with respect to computed values is stored in this
--------------------------------------------------------------------------------------- */
void
calculateSingleParticleEnergyTerm
(
int
index
,
int
numAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
const
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>&
values
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
RealOpenMM
**
atomParameters
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
,
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>&
dEdV
)
const
;
void
calculateSingleParticleEnergyTerm
(
int
index
,
int
numAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
**
atomParameters
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
,
double
*
energyParamDerivs
);
/**---------------------------------------------------------------------------------------
...
...
@@ -138,21 +129,16 @@ class ReferenceCustomGBIxn {
@param numAtoms number of atoms
@param atomCoordinates atom coordinates
@param atomParameters atomParameters[atomIndex][paramterIndex]
@param values the vector containing computed values
@param globalParameters the values of global parameters
@param exclusions exclusions[i] is the set of excluded indices for atom i
@param useExclusions specifies whether to use exclusions
@param forces forces on atoms are added to this
@param totalEnergy the energy contribution is added to this
@param dEdV the derivative of energy with respect to computed values is stored in this
--------------------------------------------------------------------------------------- */
void
calculateParticlePairEnergyTerm
(
int
index
,
int
numAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
**
atomParameters
,
const
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>&
values
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
,
bool
useExclusions
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
,
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>&
dEdV
)
const
;
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
,
double
*
energyParamDerivs
)
;
/**---------------------------------------------------------------------------------------
...
...
@@ -163,18 +149,13 @@ class ReferenceCustomGBIxn {
@param atom2 the index of the second atom in the pair
@param atomCoordinates atom coordinates
@param atomParameters atomParameters[atomIndex][paramterIndex]
@param globalParameters the values of global parameters
@param values the vector containing computed values
@param forces forces on atoms are added to this
@param totalEnergy the energy contribution is added to this
@param dEdV the derivative of energy with respect to computed values is stored in this
--------------------------------------------------------------------------------------- */
void
calculateOnePairEnergyTerm
(
int
index
,
int
atom1
,
int
atom2
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
**
atomParameters
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
const
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>&
values
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
,
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>&
dEdV
)
const
;
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
,
double
*
energyParamDerivs
);
/**---------------------------------------------------------------------------------------
...
...
@@ -183,19 +164,13 @@ class ReferenceCustomGBIxn {
@param numAtoms number of atoms
@param atomCoordinates atom coordinates
@param atomParameters atomParameters[atomIndex][paramterIndex]
@param values the vector containing computed values
@param globalParameters the values of global parameters
@param exclusions exclusions[i] is the set of excluded indices for atom i
@param forces forces on atoms are added to this
@param dEdV the derivative of energy with respect to computed values is stored in this
--------------------------------------------------------------------------------------- */
void
calculateChainRuleForces
(
int
numAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
**
atomParameters
,
const
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>&
values
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>&
dEdV
)
const
;
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
double
*
energyParamDerivs
);
/**---------------------------------------------------------------------------------------
...
...
@@ -205,19 +180,13 @@ class ReferenceCustomGBIxn {
@param atom2 the index of the second atom in the pair
@param atomCoordinates atom coordinates
@param atomParameters atomParameters[atomIndex][paramterIndex]
@param globalParameters the values of global parameters
@param values the vector containing computed values
@param forces forces on atoms are added to this
@param dEdV the derivative of energy with respect to computed values is stored in this
@param isExcluded specifies whether this is an excluded pair
--------------------------------------------------------------------------------------- */
void
calculateOnePairChainRule
(
int
atom1
,
int
atom2
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
**
atomParameters
,
const
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
const
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>&
values
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>&
dEdV
,
bool
isExcluded
)
const
;
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
bool
isExcluded
);
public:
...
...
@@ -227,14 +196,16 @@ class ReferenceCustomGBIxn {
--------------------------------------------------------------------------------------- */
ReferenceCustomGBIxn
(
const
std
::
vector
<
Lepton
::
ExpressionProgram
>&
valueExpressions
,
const
std
::
vector
<
std
::
vector
<
Lepton
::
ExpressionProgram
>
>
valueDerivExpressions
,
const
std
::
vector
<
std
::
vector
<
Lepton
::
ExpressionProgram
>
>
valueGradientExpressions
,
ReferenceCustomGBIxn
(
const
std
::
vector
<
Lepton
::
CompiledExpression
>&
valueExpressions
,
const
std
::
vector
<
std
::
vector
<
Lepton
::
CompiledExpression
>
>
valueDerivExpressions
,
const
std
::
vector
<
std
::
vector
<
Lepton
::
CompiledExpression
>
>
valueGradientExpressions
,
const
std
::
vector
<
std
::
vector
<
Lepton
::
CompiledExpression
>
>
valueParamDerivExpressions
,
const
std
::
vector
<
std
::
string
>&
valueNames
,
const
std
::
vector
<
OpenMM
::
CustomGBForce
::
ComputationType
>&
valueTypes
,
const
std
::
vector
<
Lepton
::
ExpressionProgram
>&
energyExpressions
,
const
std
::
vector
<
std
::
vector
<
Lepton
::
ExpressionProgram
>
>
energyDerivExpressions
,
const
std
::
vector
<
std
::
vector
<
Lepton
::
ExpressionProgram
>
>
energyGradientExpressions
,
const
std
::
vector
<
Lepton
::
CompiledExpression
>&
energyExpressions
,
const
std
::
vector
<
std
::
vector
<
Lepton
::
CompiledExpression
>
>
energyDerivExpressions
,
const
std
::
vector
<
std
::
vector
<
Lepton
::
CompiledExpression
>
>
energyGradientExpressions
,
const
std
::
vector
<
std
::
vector
<
Lepton
::
CompiledExpression
>
>
energyParamDerivExpressions
,
const
std
::
vector
<
OpenMM
::
CustomGBForce
::
ComputationType
>&
energyTypes
,
const
std
::
vector
<
std
::
string
>&
parameterNames
);
...
...
@@ -284,7 +255,7 @@ class ReferenceCustomGBIxn {
--------------------------------------------------------------------------------------- */
void
calculateIxn
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
**
atomParameters
,
const
std
::
vector
<
std
::
set
<
int
>
>&
exclusions
,
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
;
std
::
map
<
std
::
string
,
double
>&
globalParameters
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
,
double
*
energyParamDerivs
)
;
// ---------------------------------------------------------------------------------------
...
...
Prev
1
2
3
4
5
6
7
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