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
74efa95f
Commit
74efa95f
authored
Jul 22, 2016
by
peastman
Browse files
OpenCL implementation of parameter derivatives for CustomGBForce
parent
df07fbe9
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
251 additions
and
58 deletions
+251
-58
platforms/opencl/include/OpenCLKernels.h
platforms/opencl/include/OpenCLKernels.h
+3
-1
platforms/opencl/src/OpenCLBondedUtilities.cpp
platforms/opencl/src/OpenCLBondedUtilities.cpp
+2
-2
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+201
-39
platforms/opencl/src/OpenCLNonbondedUtilities.cpp
platforms/opencl/src/OpenCLNonbondedUtilities.cpp
+2
-2
platforms/opencl/src/kernels/customGBEnergyN2.cl
platforms/opencl/src/kernels/customGBEnergyN2.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
+28
-10
platforms/opencl/src/kernels/customGBValuePerParticle.cl
platforms/opencl/src/kernels/customGBValuePerParticle.cl
+1
-0
tests/TestCustomBondForce.h
tests/TestCustomBondForce.h
+1
-1
tests/TestCustomGBForce.h
tests/TestCustomGBForce.h
+2
-2
tests/TestCustomNonbondedForce.h
tests/TestCustomNonbondedForce.h
+1
-1
No files found.
platforms/opencl/include/OpenCLKernels.h
View file @
74efa95f
...
@@ -808,13 +808,15 @@ public:
...
@@ -808,13 +808,15 @@ public:
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomGBForce
&
force
);
void
copyParametersToContext
(
ContextImpl
&
context
,
const
CustomGBForce
&
force
);
private:
private:
double
cutoff
;
double
cutoff
;
bool
hasInitializedKernels
,
needParameterGradient
;
bool
hasInitializedKernels
,
needParameterGradient
,
needEnergyParamDerivs
;
int
maxTiles
,
numComputedValues
;
int
maxTiles
,
numComputedValues
;
OpenCLContext
&
cl
;
OpenCLContext
&
cl
;
OpenCLParameterSet
*
params
;
OpenCLParameterSet
*
params
;
OpenCLParameterSet
*
computedValues
;
OpenCLParameterSet
*
computedValues
;
OpenCLParameterSet
*
energyDerivs
;
OpenCLParameterSet
*
energyDerivs
;
OpenCLParameterSet
*
energyDerivChain
;
OpenCLParameterSet
*
energyDerivChain
;
std
::
vector
<
OpenCLParameterSet
*>
dValuedParam
;
std
::
vector
<
OpenCLArray
*>
dValue0dParam
;
OpenCLArray
*
longEnergyDerivs
;
OpenCLArray
*
longEnergyDerivs
;
OpenCLArray
*
globals
;
OpenCLArray
*
globals
;
OpenCLArray
*
valueBuffers
;
OpenCLArray
*
valueBuffers
;
...
...
platforms/opencl/src/OpenCLBondedUtilities.cpp
View file @
74efa95f
...
@@ -204,7 +204,7 @@ void OpenCLBondedUtilities::initialize(const System& system) {
...
@@ -204,7 +204,7 @@ void OpenCLBondedUtilities::initialize(const System& system) {
for
(
int
i
=
0
;
i
<
(
int
)
arguments
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
arguments
.
size
();
i
++
)
s
<<
", __global "
<<
argTypes
[
i
]
<<
"* customArg"
<<
(
i
+
1
);
s
<<
", __global "
<<
argTypes
[
i
]
<<
"* customArg"
<<
(
i
+
1
);
if
(
energyParameterDerivatives
.
size
()
>
0
)
if
(
energyParameterDerivatives
.
size
()
>
0
)
s
<<
", __global mixed* energyParamDerivs"
;
s
<<
", __global mixed*
restrict
energyParamDerivs"
;
s
<<
") {
\n
"
;
s
<<
") {
\n
"
;
s
<<
"mixed energy = 0;
\n
"
;
s
<<
"mixed energy = 0;
\n
"
;
for
(
int
i
=
0
;
i
<
energyParameterDerivatives
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
energyParameterDerivatives
.
size
();
i
++
)
...
@@ -219,7 +219,7 @@ void OpenCLBondedUtilities::initialize(const System& system) {
...
@@ -219,7 +219,7 @@ void OpenCLBondedUtilities::initialize(const System& system) {
for
(
int
i
=
0
;
i
<
energyParameterDerivatives
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
energyParameterDerivatives
.
size
();
i
++
)
for
(
int
index
=
0
;
index
<
numDerivs
;
index
++
)
for
(
int
index
=
0
;
index
<
numDerivs
;
index
++
)
if
(
allParamDerivNames
[
index
]
==
energyParameterDerivatives
[
i
])
if
(
allParamDerivNames
[
index
]
==
energyParameterDerivatives
[
i
])
s
<<
"energyParamDerivs[get_global_id(0)*"
<<
numDerivs
<<
"+"
<<
i
<<
"] += energyParamDeriv"
<<
i
<<
";
\n
"
;
s
<<
"energyParamDerivs[get_global_id(0)*"
<<
numDerivs
<<
"+"
<<
i
ndex
<<
"] += energyParamDeriv"
<<
i
<<
";
\n
"
;
s
<<
"}
\n
"
;
s
<<
"}
\n
"
;
map
<
string
,
string
>
defines
;
map
<
string
,
string
>
defines
;
defines
[
"PADDED_NUM_ATOMS"
]
=
context
.
intToString
(
context
.
getPaddedNumAtoms
());
defines
[
"PADDED_NUM_ATOMS"
]
=
context
.
intToString
(
context
.
getPaddedNumAtoms
());
...
...
platforms/opencl/src/OpenCLKernels.cpp
View file @
74efa95f
This diff is collapsed.
Click to expand it.
platforms/opencl/src/OpenCLNonbondedUtilities.cpp
View file @
74efa95f
...
@@ -605,7 +605,7 @@ cl::Kernel OpenCLNonbondedUtilities::createInteractionKernel(const string& sourc
...
@@ -605,7 +605,7 @@ cl::Kernel OpenCLNonbondedUtilities::createInteractionKernel(const string& sourc
}
}
}
}
if
(
energyParameterDerivatives
.
size
()
>
0
)
if
(
energyParameterDerivatives
.
size
()
>
0
)
args
<<
", __global mixed* energyParamDerivs"
;
args
<<
", __global mixed*
restrict
energyParamDerivs"
;
replacements
[
"PARAMETER_ARGUMENTS"
]
=
args
.
str
();
replacements
[
"PARAMETER_ARGUMENTS"
]
=
args
.
str
();
stringstream
loadLocal1
;
stringstream
loadLocal1
;
for
(
int
i
=
0
;
i
<
(
int
)
params
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
params
.
size
();
i
++
)
{
...
@@ -666,7 +666,7 @@ cl::Kernel OpenCLNonbondedUtilities::createInteractionKernel(const string& sourc
...
@@ -666,7 +666,7 @@ cl::Kernel OpenCLNonbondedUtilities::createInteractionKernel(const string& sourc
for
(
int
i
=
0
;
i
<
energyParameterDerivatives
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
energyParameterDerivatives
.
size
();
i
++
)
for
(
int
index
=
0
;
index
<
numDerivs
;
index
++
)
for
(
int
index
=
0
;
index
<
numDerivs
;
index
++
)
if
(
allParamDerivNames
[
index
]
==
energyParameterDerivatives
[
i
])
if
(
allParamDerivNames
[
index
]
==
energyParameterDerivatives
[
i
])
saveDerivs
<<
"energyParamDerivs[get_global_id(0)*"
<<
numDerivs
<<
"+"
<<
i
<<
"] += energyParamDeriv"
<<
i
<<
";
\n
"
;
saveDerivs
<<
"energyParamDerivs[get_global_id(0)*"
<<
numDerivs
<<
"+"
<<
i
ndex
<<
"] += energyParamDeriv"
<<
i
<<
";
\n
"
;
replacements
[
"SAVE_DERIVATIVES"
]
=
saveDerivs
.
str
();
replacements
[
"SAVE_DERIVATIVES"
]
=
saveDerivs
.
str
();
map
<
string
,
string
>
defines
;
map
<
string
,
string
>
defines
;
if
(
useCutoff
)
if
(
useCutoff
)
...
...
platforms/opencl/src/kernels/customGBEnergyN2.cl
View file @
74efa95f
...
@@ -32,6 +32,7 @@ __kernel void computeN2Energy(
...
@@ -32,6 +32,7 @@ __kernel void computeN2Energy(
const
unsigned
int
tgx
=
get_local_id
(
0
)
&
(
TILE_SIZE-1
)
;
const
unsigned
int
tgx
=
get_local_id
(
0
)
&
(
TILE_SIZE-1
)
;
const
unsigned
int
tbx
=
get_local_id
(
0
)
-
tgx
;
const
unsigned
int
tbx
=
get_local_id
(
0
)
-
tgx
;
mixed
energy
=
0
;
mixed
energy
=
0
;
INIT_PARAM_DERIVS
//
First
loop:
process
tiles
that
contain
exclusions.
//
First
loop:
process
tiles
that
contain
exclusions.
...
@@ -73,6 +74,7 @@ __kernel void computeN2Energy(
...
@@ -73,6 +74,7 @@ __kernel void computeN2Energy(
atom2
=
y*TILE_SIZE+j
;
atom2
=
y*TILE_SIZE+j
;
real
dEdR
=
0
;
real
dEdR
=
0
;
real
tempEnergy
=
0
;
real
tempEnergy
=
0
;
const
real
interactionScale
=
0.5f
;
#
ifdef
USE_EXCLUSIONS
#
ifdef
USE_EXCLUSIONS
bool
isExcluded
=
!
(
excl
&
0x1
)
;
bool
isExcluded
=
!
(
excl
&
0x1
)
;
#
endif
#
endif
...
@@ -123,6 +125,7 @@ __kernel void computeN2Energy(
...
@@ -123,6 +125,7 @@ __kernel void computeN2Energy(
atom2 = y*TILE_SIZE+tj;
atom2 = y*TILE_SIZE+tj;
real dEdR = 0;
real dEdR = 0;
real tempEnergy = 0;
real tempEnergy = 0;
const real interactionScale = 1.0f;
#ifdef USE_EXCLUSIONS
#ifdef USE_EXCLUSIONS
bool isExcluded = !(excl & 0x1);
bool isExcluded = !(excl & 0x1);
#endif
#endif
...
@@ -281,6 +284,7 @@ __kernel void computeN2Energy(
...
@@ -281,6 +284,7 @@ __kernel void computeN2Energy(
atom2
=
atomIndices[tbx+tj]
;
atom2
=
atomIndices[tbx+tj]
;
real
dEdR
=
0
;
real
dEdR
=
0
;
real
tempEnergy
=
0
;
real
tempEnergy
=
0
;
const
real
interactionScale
=
1.0f
;
if
(
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
if
(
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
COMPUTE_INTERACTION
COMPUTE_INTERACTION
dEdR
/=
-r
;
dEdR
/=
-r
;
...
@@ -319,6 +323,7 @@ __kernel void computeN2Energy(
...
@@ -319,6 +323,7 @@ __kernel void computeN2Energy(
atom2
=
atomIndices[tbx+tj]
;
atom2
=
atomIndices[tbx+tj]
;
real
dEdR
=
0
;
real
dEdR
=
0
;
real
tempEnergy
=
0
;
real
tempEnergy
=
0
;
const
real
interactionScale
=
1.0f
;
if
(
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
if
(
atom1
<
NUM_ATOMS
&&
atom2
<
NUM_ATOMS
)
{
COMPUTE_INTERACTION
COMPUTE_INTERACTION
dEdR
/=
-r
;
dEdR
/=
-r
;
...
@@ -373,4 +378,5 @@ __kernel void computeN2Energy(
...
@@ -373,4 +378,5 @@ __kernel void computeN2Energy(
pos++
;
pos++
;
}
}
energyBuffer[get_global_id
(
0
)
]
+=
energy
;
energyBuffer[get_global_id
(
0
)
]
+=
energy
;
SAVE_PARAM_DERIVS
}
}
platforms/opencl/src/kernels/customGBEnergyPerParticle.cl
View file @
74efa95f
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
__kernel
void
computePerParticleEnergy
(
int
bufferSize,
int
numBuffers,
__global
real4*
restrict
forceBuffers,
__global
mixed*
restrict
energyBuffer,
__global
const
real4*
restrict
posq
__kernel
void
computePerParticleEnergy
(
int
bufferSize,
int
numBuffers,
__global
real4*
restrict
forceBuffers,
__global
mixed*
restrict
energyBuffer,
__global
const
real4*
restrict
posq
PARAMETER_ARGUMENTS
)
{
PARAMETER_ARGUMENTS
)
{
mixed
energy
=
0
;
mixed
energy
=
0
;
INIT_PARAM_DERIVS
unsigned
int
index
=
get_global_id
(
0
)
;
unsigned
int
index
=
get_global_id
(
0
)
;
while
(
index
<
NUM_ATOMS
)
{
while
(
index
<
NUM_ATOMS
)
{
//
Reduce
the
derivatives
//
Reduce
the
derivatives
...
@@ -27,4 +28,5 @@ __kernel void computePerParticleEnergy(int bufferSize, int numBuffers, __global
...
@@ -27,4 +28,5 @@ __kernel void computePerParticleEnergy(int bufferSize, int numBuffers, __global
index
+=
get_global_size
(
0
)
;
index
+=
get_global_size
(
0
)
;
}
}
energyBuffer[get_global_id
(
0
)
]
+=
energy
;
energyBuffer[get_global_id
(
0
)
]
+=
energy
;
SAVE_PARAM_DERIVS
}
}
platforms/opencl/src/kernels/customGBGradientChainRule.cl
View file @
74efa95f
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
__kernel
void
computeGradientChainRuleTerms
(
__global
real4*
restrict
forceBuffers,
__global
const
real4*
restrict
posq
__kernel
void
computeGradientChainRuleTerms
(
__global
real4*
restrict
forceBuffers,
__global
const
real4*
restrict
posq
PARAMETER_ARGUMENTS
)
{
PARAMETER_ARGUMENTS
)
{
INIT_PARAM_DERIVS
unsigned
int
index
=
get_global_id
(
0
)
;
unsigned
int
index
=
get_global_id
(
0
)
;
while
(
index
<
NUM_ATOMS
)
{
while
(
index
<
NUM_ATOMS
)
{
real4
pos
=
posq[index]
;
real4
pos
=
posq[index]
;
...
@@ -12,4 +13,5 @@ __kernel void computeGradientChainRuleTerms(__global real4* restrict forceBuffer
...
@@ -12,4 +13,5 @@ __kernel void computeGradientChainRuleTerms(__global real4* restrict forceBuffer
forceBuffers[index]
=
force
;
forceBuffers[index]
=
force
;
index
+=
get_global_size
(
0
)
;
index
+=
get_global_size
(
0
)
;
}
}
SAVE_PARAM_DERIVS
}
}
platforms/opencl/src/kernels/customGBValueN2.cl
View file @
74efa95f
...
@@ -74,6 +74,7 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
...
@@ -74,6 +74,7 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
COMPUTE_VALUE
COMPUTE_VALUE
}
}
value += tempValue1;
value += tempValue1;
ADD_TEMP_DERIVS1
#ifdef USE_CUTOFF
#ifdef USE_CUTOFF
}
}
#endif
#endif
...
@@ -123,6 +124,8 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
...
@@ -123,6 +124,8 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
}
}
value += tempValue1;
value += tempValue1;
local_value[tbx+tj] += tempValue2;
local_value[tbx+tj] += tempValue2;
ADD_TEMP_DERIVS1
ADD_TEMP_DERIVS2
#ifdef USE_CUTOFF
#ifdef USE_CUTOFF
}
}
#endif
#endif
...
@@ -137,18 +140,23 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
...
@@ -137,18 +140,23 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
// Write results.
// Write results.
#ifdef SUPPORTS_64_BIT_ATOMICS
#ifdef SUPPORTS_64_BIT_ATOMICS
unsigned int offset = x*TILE_SIZE + tgx;
unsigned int offset1 = x*TILE_SIZE + tgx;
atom_add(&global_value[offset], (long) (value*0x100000000));
atom_add(&global_value[offset1], (long) (value*0x100000000));
STORE_PARAM_DERIVS1
if (x != y) {
if (x != y) {
offset = y*TILE_SIZE + tgx;
unsigned int offset2 = y*TILE_SIZE + tgx;
atom_add(&global_value[offset], (long) (local_value[get_local_id(0)]*0x100000000));
atom_add(&global_value[offset2], (long) (local_value[get_local_id(0)]*0x100000000));
STORE_PARAM_DERIVS2
}
}
#else
#else
unsigned int offset1 = x*TILE_SIZE + tgx + warp*PADDED_NUM_ATOMS;
unsigned int offset1 = x*TILE_SIZE + tgx + warp*PADDED_NUM_ATOMS;
unsigned int offset2 = y*TILE_SIZE + tgx + warp*PADDED_NUM_ATOMS;
unsigned int offset2 = y*TILE_SIZE + tgx + warp*PADDED_NUM_ATOMS;
global_value[offset1] += value;
global_value[offset1] += value;
if (x != y)
STORE_PARAM_DERIVS1
if (x != y) {
global_value[offset2] += local_value[get_local_id(0)];
global_value[offset2] += local_value[get_local_id(0)];
STORE_PARAM_DERIVS2
}
#endif
#endif
}
}
...
@@ -292,6 +300,8 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
...
@@ -292,6 +300,8 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
}
}
value
+=
tempValue1
;
value
+=
tempValue1
;
local_value[tbx+tj]
+=
tempValue2
;
local_value[tbx+tj]
+=
tempValue2
;
ADD_TEMP_DERIVS1
ADD_TEMP_DERIVS2
#
ifdef
USE_CUTOFF
#
ifdef
USE_CUTOFF
}
}
#
endif
#
endif
...
@@ -308,15 +318,23 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
...
@@ -308,15 +318,23 @@ __kernel void computeN2Value(__global const real4* restrict posq, __local real4*
unsigned
int
atom2
=
y*TILE_SIZE
+
tgx
;
unsigned
int
atom2
=
y*TILE_SIZE
+
tgx
;
#
endif
#
endif
#
ifdef
SUPPORTS_64_BIT_ATOMICS
#
ifdef
SUPPORTS_64_BIT_ATOMICS
atom_add
(
&global_value[atom1],
(
long
)
(
value*0x100000000
))
;
unsigned
in
offset1
=
atom1
;
if
(
atom2
<
PADDED_NUM_ATOMS
)
atom_add
(
&global_value[offset1],
(
long
)
(
value*0x100000000
))
;
atom_add
(
&global_value[atom2],
(
long
)
(
local_value[get_local_id
(
0
)
]*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
#
else
unsigned
int
offset1
=
atom1
+
warp*PADDED_NUM_ATOMS
;
unsigned
int
offset1
=
atom1
+
warp*PADDED_NUM_ATOMS
;
unsigned
int
offset2
=
atom2
+
warp*PADDED_NUM_ATOMS
;
global_value[offset1]
+=
value
;
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
)
]
;
global_value[offset2]
+=
local_value[get_local_id
(
0
)
]
;
STORE_PARAM_DERIVS2
}
#
endif
#
endif
}
}
pos++
;
pos++
;
...
...
platforms/opencl/src/kernels/customGBValuePerParticle.cl
View file @
74efa95f
...
@@ -21,6 +21,7 @@ __kernel void computePerParticleValues(int bufferSize, int numBuffers, __global
...
@@ -21,6 +21,7 @@ __kernel void computePerParticleValues(int bufferSize, int numBuffers, __global
for
(
int
i
=
index+bufferSize
; i < totalSize; i += bufferSize)
for
(
int
i
=
index+bufferSize
; i < totalSize; i += bufferSize)
sum
+=
valueBuffers[i]
;
sum
+=
valueBuffers[i]
;
#
endif
#
endif
REDUCE_PARAM0_DERIV
//
Now
calculate
other
values
//
Now
calculate
other
values
...
...
tests/TestCustomBondForce.h
View file @
74efa95f
...
@@ -187,8 +187,8 @@ void testEnergyParameterDerivatives() {
...
@@ -187,8 +187,8 @@ void testEnergyParameterDerivatives() {
CustomBondForce
*
bonds
=
new
CustomBondForce
(
"k*(r-r0)^2"
);
CustomBondForce
*
bonds
=
new
CustomBondForce
(
"k*(r-r0)^2"
);
bonds
->
addGlobalParameter
(
"r0"
,
0.0
);
bonds
->
addGlobalParameter
(
"r0"
,
0.0
);
bonds
->
addGlobalParameter
(
"k"
,
0.0
);
bonds
->
addGlobalParameter
(
"k"
,
0.0
);
bonds
->
addEnergyParameterDerivative
(
"r0"
);
bonds
->
addEnergyParameterDerivative
(
"k"
);
bonds
->
addEnergyParameterDerivative
(
"k"
);
bonds
->
addEnergyParameterDerivative
(
"r0"
);
vector
<
double
>
parameters
;
vector
<
double
>
parameters
;
bonds
->
addBond
(
0
,
1
,
parameters
);
bonds
->
addBond
(
0
,
1
,
parameters
);
bonds
->
addBond
(
1
,
2
,
parameters
);
bonds
->
addBond
(
1
,
2
,
parameters
);
...
...
tests/TestCustomGBForce.h
View file @
74efa95f
...
@@ -505,10 +505,10 @@ void testEnergyParameterDerivatives() {
...
@@ -505,10 +505,10 @@ void testEnergyParameterDerivatives() {
force
->
addComputedValue
(
"b"
,
"a+B"
,
CustomGBForce
::
SingleParticle
);
force
->
addComputedValue
(
"b"
,
"a+B"
,
CustomGBForce
::
SingleParticle
);
force
->
addEnergyTerm
(
"C*(a1+b1+a2+b2+r)^0.8"
,
CustomGBForce
::
ParticlePair
);
force
->
addEnergyTerm
(
"C*(a1+b1+a2+b2+r)^0.8"
,
CustomGBForce
::
ParticlePair
);
force
->
addEnergyTerm
(
"(D-B)*b"
,
CustomGBForce
::
SingleParticle
);
force
->
addEnergyTerm
(
"(D-B)*b"
,
CustomGBForce
::
SingleParticle
);
for
(
int
i
=
0
;
i
<
numParameters
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numParameters
;
i
++
)
force
->
addGlobalParameter
(
paramNames
[
i
],
paramValues
[
i
]);
force
->
addGlobalParameter
(
paramNames
[
i
],
paramValues
[
i
]);
for
(
int
i
=
numParameters
-
1
;
i
>=
0
;
i
--
)
force
->
addEnergyParameterDerivative
(
paramNames
[
i
]);
force
->
addEnergyParameterDerivative
(
paramNames
[
i
]);
}
force
->
setNonbondedMethod
(
CustomGBForce
::
CutoffPeriodic
);
force
->
setNonbondedMethod
(
CustomGBForce
::
CutoffPeriodic
);
force
->
setCutoffDistance
(
1.0
);
force
->
setCutoffDistance
(
1.0
);
vector
<
Vec3
>
positions
;
vector
<
Vec3
>
positions
;
...
...
tests/TestCustomNonbondedForce.h
View file @
74efa95f
...
@@ -1050,8 +1050,8 @@ void testEnergyParameterDerivatives() {
...
@@ -1050,8 +1050,8 @@ void testEnergyParameterDerivatives() {
CustomNonbondedForce
*
nonbonded
=
new
CustomNonbondedForce
(
"k*(r-r0)^2"
);
CustomNonbondedForce
*
nonbonded
=
new
CustomNonbondedForce
(
"k*(r-r0)^2"
);
nonbonded
->
addGlobalParameter
(
"r0"
,
0.0
);
nonbonded
->
addGlobalParameter
(
"r0"
,
0.0
);
nonbonded
->
addGlobalParameter
(
"k"
,
0.0
);
nonbonded
->
addGlobalParameter
(
"k"
,
0.0
);
nonbonded
->
addEnergyParameterDerivative
(
"r0"
);
nonbonded
->
addEnergyParameterDerivative
(
"k"
);
nonbonded
->
addEnergyParameterDerivative
(
"k"
);
nonbonded
->
addEnergyParameterDerivative
(
"r0"
);
vector
<
double
>
parameters
;
vector
<
double
>
parameters
;
nonbonded
->
addParticle
(
parameters
);
nonbonded
->
addParticle
(
parameters
);
nonbonded
->
addParticle
(
parameters
);
nonbonded
->
addParticle
(
parameters
);
...
...
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