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
7ed51ce4
Commit
7ed51ce4
authored
Dec 17, 2008
by
Mark Friedrichs
Browse files
Bonded forces ok
parent
08c2e027
Changes
24
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
221 additions
and
137 deletions
+221
-137
platforms/brook/src/BrookBonded.cpp
platforms/brook/src/BrookBonded.cpp
+56
-29
platforms/brook/src/BrookBonded.h
platforms/brook/src/BrookBonded.h
+3
-3
platforms/brook/src/BrookCalcGBSAOBCForceKernel.cpp
platforms/brook/src/BrookCalcGBSAOBCForceKernel.cpp
+5
-10
platforms/brook/src/BrookCalcGBSAOBCForceKernel.h
platforms/brook/src/BrookCalcGBSAOBCForceKernel.h
+9
-4
platforms/brook/src/BrookCalcHarmonicAngleForceKernel.cpp
platforms/brook/src/BrookCalcHarmonicAngleForceKernel.cpp
+2
-1
platforms/brook/src/BrookCalcHarmonicBondForceKernel.cpp
platforms/brook/src/BrookCalcHarmonicBondForceKernel.cpp
+3
-1
platforms/brook/src/BrookCalcKineticEnergyKernel.cpp
platforms/brook/src/BrookCalcKineticEnergyKernel.cpp
+2
-1
platforms/brook/src/BrookCalcNonbondedForceKernel.cpp
platforms/brook/src/BrookCalcNonbondedForceKernel.cpp
+7
-12
platforms/brook/src/BrookCalcNonbondedForceKernel.h
platforms/brook/src/BrookCalcNonbondedForceKernel.h
+0
-4
platforms/brook/src/BrookCalcPeriodicTorsionForceKernel.cpp
platforms/brook/src/BrookCalcPeriodicTorsionForceKernel.cpp
+4
-3
platforms/brook/src/BrookCalcPeriodicTorsionForceKernel.h
platforms/brook/src/BrookCalcPeriodicTorsionForceKernel.h
+1
-1
platforms/brook/src/BrookCalcRBTorsionForceKernel.cpp
platforms/brook/src/BrookCalcRBTorsionForceKernel.cpp
+4
-3
platforms/brook/src/BrookCalcRBTorsionForceKernel.h
platforms/brook/src/BrookCalcRBTorsionForceKernel.h
+1
-1
platforms/brook/src/BrookCommon.cpp
platforms/brook/src/BrookCommon.cpp
+9
-9
platforms/brook/src/BrookCommon.h
platforms/brook/src/BrookCommon.h
+20
-20
platforms/brook/src/BrookIntegrateBrownianStepKernel.cpp
platforms/brook/src/BrookIntegrateBrownianStepKernel.cpp
+1
-1
platforms/brook/src/BrookIntegrateLangevinStepKernel.cpp
platforms/brook/src/BrookIntegrateLangevinStepKernel.cpp
+1
-1
platforms/brook/src/BrookPlatform.cpp
platforms/brook/src/BrookPlatform.cpp
+3
-1
platforms/brook/src/BrookRandomNumberGenerator.cpp
platforms/brook/src/BrookRandomNumberGenerator.cpp
+2
-2
platforms/brook/src/OpenMMBrookInterface.cpp
platforms/brook/src/OpenMMBrookInterface.cpp
+88
-30
No files found.
platforms/brook/src/BrookBonded.cpp
View file @
7ed51ce4
...
...
@@ -521,8 +521,8 @@ int BrookBonded::matchTorsion( int i, int j, int k, int l, int nbondeds, int *pa
* in the fourth component and match the middle two components
*
* The last bit will not be needed as long as gromacs generates
* all
dihedral
s. But I think there are force fields that don't
* use all
dihedral
s.
* all
torsion
s. But I think there are force fields that don't
* use all
torsion
s.
*
* @return ErrorReturnValue if error; else particle index
*
...
...
@@ -711,7 +711,7 @@ int BrookBonded::matchPair( int i, int j, int nbondeds, int *particles ){
*
*/
int
BrookBonded
::
addRB
Dihedral
s
(
int
*
nbondeds
,
int
*
particles
,
float
*
params
[],
int
BrookBonded
::
addRB
Torsion
s
(
int
*
nbondeds
,
int
*
particles
,
float
*
params
[],
const
vector
<
vector
<
int
>
>&
rbTorsionIndices
,
const
vector
<
vector
<
double
>
>&
rbTorsionParameters
){
...
...
@@ -779,13 +779,13 @@ int BrookBonded::addRBDihedrals( int *nbondeds, int *particles, float *params[],
*
*/
int
BrookBonded
::
addP
Dihedral
s
(
int
*
nbondeds
,
int
*
particles
,
BrookOpenMMFloat
*
params
[],
int
BrookBonded
::
addP
Torsion
s
(
int
*
nbondeds
,
int
*
particles
,
BrookOpenMMFloat
*
params
[],
const
vector
<
vector
<
int
>
>&
periodicTorsionIndices
,
const
vector
<
vector
<
double
>
>&
periodicTorsionParameters
){
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"BrookBonded::addP
Dihedrals
"
;
static
const
std
::
string
methodName
=
"BrookBonded::addP
Torsion
"
;
static
const
int
debug
=
0
;
// ---------------------------------------------------------------------------------------
...
...
@@ -815,9 +815,12 @@ int BrookBonded::addPDihedrals( int *nbondeds, int *particles, BrookOpenMMFloat*
ATOMS
(
ibonded
,
3
)
=
l
;
(
*
nbondeds
)
++
;
}
PARAMS
(
ibonded
,
1
,
1
)
=
(
BrookOpenMMFloat
)
pTParameters
[
0
];
// note: parameters 0 & 2 switched
PARAMS
(
ibonded
,
1
,
1
)
=
(
BrookOpenMMFloat
)
pTParameters
[
2
];
PARAMS
(
ibonded
,
1
,
2
)
=
(
BrookOpenMMFloat
)
pTParameters
[
1
];
PARAMS
(
ibonded
,
1
,
3
)
=
(
BrookOpenMMFloat
)
pTParameters
[
2
];
PARAMS
(
ibonded
,
1
,
3
)
=
(
BrookOpenMMFloat
)
pTParameters
[
0
];
if
(
debug
&&
getLog
()
){
(
void
)
fprintf
(
getLog
(),
" %d [%d %d %d %d] %.3e %.3e %.3e
\n
"
,
ibonded
,
i
,
j
,
k
,
l
,
...
...
@@ -910,7 +913,7 @@ int BrookBonded::addBonds( int *nbondeds, int *particles, float *params[], const
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"BrookBonded::addBonds"
;
static
const
int
debug
=
1
;
static
const
int
debug
=
0
;
// ---------------------------------------------------------------------------------------
...
...
@@ -1269,10 +1272,18 @@ int BrookBonded::setup( int numberOfParticles,
int
nbondeds
=
0
;
addRBDihedrals
(
&
nbondeds
,
particles
,
params
,
rbTorsionBrookBondParameters
->
getParticleIndices
(),
rbTorsionBrookBondParameters
->
getBondParameters
()
);
addPDihedrals
(
&
nbondeds
,
particles
,
params
,
periodicTorsionBrookBondParameters
->
getParticleIndices
(),
periodicTorsionBrookBondParameters
->
getBondParameters
()
);
if
(
rbTorsionBrookBondParameters
){
addRBTorsions
(
&
nbondeds
,
particles
,
params
,
rbTorsionBrookBondParameters
->
getParticleIndices
(),
rbTorsionBrookBondParameters
->
getBondParameters
()
);
}
if
(
periodicTorsionBrookBondParameters
){
addPTorsions
(
&
nbondeds
,
particles
,
params
,
periodicTorsionBrookBondParameters
->
getParticleIndices
(),
periodicTorsionBrookBondParameters
->
getBondParameters
()
);
}
if
(
harmonicAngleBrookBondParameters
){
addAngles
(
&
nbondeds
,
particles
,
params
,
harmonicAngleBrookBondParameters
->
getParticleIndices
(),
harmonicAngleBrookBondParameters
->
getBondParameters
()
);
}
if
(
harmonicBondBrookBondParameters
){
addBonds
(
&
nbondeds
,
particles
,
params
,
harmonicBondBrookBondParameters
->
getParticleIndices
(),
harmonicBondBrookBondParameters
->
getBondParameters
()
);
}
// ---------------------------------------------------------------------------------------
...
...
@@ -1287,13 +1298,15 @@ int BrookBonded::setup( int numberOfParticles,
//(void) fprintf( getLog(), "%s Post addBonds particles=%d number of bonds=%d maxBonds=%d\n", methodName.c_str(), numberOfParticles, nbondeds, maxBonds );
if
(
nonBonded14ForceParameters
){
addPairs
(
&
nbondeds
,
particles
,
params
,
charges
,
nonBonded14ForceParameters
->
getParticleIndices
(),
nonBonded14ForceParameters
->
getBondParameters
(),
lj14Scale
,
coulombScale
);
}
// check that number of bonds not too large for memory allocated
if
(
nbondeds
>=
maxBonds
){
std
::
stringstream
message
;
message
<<
methodName
<<
" number of bonds="
<<
nbondeds
<<
" is greater than maxBonds="
<<
maxBonds
;
message
<<
methodName
<<
" number of bonds="
<<
nbondeds
<<
" is greater than maxBonds="
<<
maxBonds
<<
" numberOfParticles="
<<
numberOfParticles
;
throw
OpenMMException
(
message
.
str
()
);
}
else
if
(
PrintOn
&&
getLog
()
){
(
void
)
fprintf
(
getLog
(),
"%s particles=%d number of bonds=%d maxBonds=%d
\n
"
,
methodName
.
c_str
(),
numberOfParticles
,
nbondeds
,
maxBonds
);
...
...
@@ -1515,7 +1528,7 @@ std::string BrookBonded::getContentsString( int level ) const {
* forces are to be picked up from and stores the position
* in the appropriate index.
*
* Input: number of
dihedral
s, the particle indices, and a flag indicating
* Input: number of
torsion
s, the particle indices, and a flag indicating
* whether we're doing i(0), j(1), k(2) or l(3)
* Output: an array of counts per particle
* arrays of inversemaps
...
...
@@ -1595,12 +1608,12 @@ if( particle > particleRange[1] ){
//Check to make sure we're inside the limits
if
(
counts
[
particle
]
>
nmaps
*
4
){
if
(
PrintOn
&&
getLog
()
){
(
void
)
fprintf
(
getLog
(),
"%s Particle %d has too many proper
dihedrals
(%d, max %d)
\n
"
,
(
void
)
fprintf
(
getLog
(),
"%s Particle %d has too many proper
torsions
(%d, max %d)
\n
"
,
methodName
.
c_str
(),
particle
,
counts
[
particle
],
nmaps
*
4
);
(
void
)
fflush
(
getLog
()
);
}
std
::
stringstream
message
;
message
<<
methodName
<<
" Particle "
<<
particle
<<
" has too many proper
dihedral
s; valid range:("
<<
counts
[
particle
]
<<
", "
<<
nmaps
*
4
<<
")"
;
message
<<
methodName
<<
" Particle "
<<
particle
<<
" has too many proper
torsion
s; valid range:("
<<
counts
[
particle
]
<<
", "
<<
nmaps
*
4
<<
")"
;
throw
OpenMMException
(
message
.
str
()
);
}
...
...
@@ -1869,8 +1882,9 @@ void BrookBonded::computeForces( BrookStreamImpl& positionStream, BrookStreamImp
brookStreamInternalF->printToFile( getLog() );
*/
(
void
)
fprintf
(
getLog
(),
"
\n
Inverse map streams
-- K_Stream cnt=%d
\n
"
,
getInverseMapStreamCount
(
K_Stream
)
);
(
void
)
fprintf
(
getLog
(),
"
\n
Inverse map streams
\n
"
);
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
){
(
void
)
fprintf
(
getLog
(),
"
\n
Inverse map streams -- StreamIndex=%d cnt=%d
\n
"
,
ii
,
getInverseMapStreamCount
(
ii
)
);
for
(
int
jj
=
0
;
jj
<
countPrintInvMap
[
ii
];
jj
++
){
(
void
)
fprintf
(
getLog
(),
"
\n
Inverse map streams index=%d %d
\n
"
,
ii
,
jj
);
inverseStreamMaps
[
ii
][
jj
]
->
printToFile
(
getLog
()
);
...
...
@@ -1928,11 +1942,20 @@ void BrookBonded::computeForces( BrookStreamImpl& positionStream, BrookStreamImp
bondedForceStreams
[
K_Stream
]
->
getBrookStream
(),
forceStream
.
getBrookStream
(),
forceStream
.
getBrookStream
()
);
}
else
if
(
getInverseMapStreamCount
(
I_Stream
)
==
1
&&
getInverseMapStreamCount
(
K_Stream
)
==
1
){
kinvmap_gather1_1
(
width
,
inverseStreamMaps
[
I_Stream
][
0
]
->
getBrookStream
(),
bondedForceStreams
[
I_Stream
]
->
getBrookStream
(),
inverseStreamMaps
[
K_Stream
][
0
]
->
getBrookStream
(),
bondedForceStreams
[
K_Stream
]
->
getBrookStream
(),
forceStream
.
getBrookStream
(),
forceStream
.
getBrookStream
()
);
}
else
{
// case not handled -- throw an exception
if
(
getLog
()
&&
ErrorMessages
++
<
MaxErrorMessages
){
if
(
getLog
()
&&
ErrorMessages
++
<
MaxErrorMessages
&&
getInverseMapStreamCount
(
I_Stream
)
>
0
&&
getInverseMapStreamCount
(
K_Stream
)
>
0
){
(
void
)
fprintf
(
getLog
(),
"%s case: I-map=%d K-map=%d -- not handled.
\n
"
,
methodName
.
c_str
(),
getInverseMapStreamCount
(
I_Stream
),
getInverseMapStreamCount
(
K_Stream
)
);
...
...
@@ -1988,13 +2011,16 @@ void BrookBonded::computeForces( BrookStreamImpl& positionStream, BrookStreamImp
// case not handled -- throw an exception
if
(
getLog
()
&&
ErrorMessages
++
<
MaxErrorMessages
){
if
(
getLog
()
&&
ErrorMessages
++
<
MaxErrorMessages
&&
getInverseMapStreamCount
(
J_Stream
)
>
0
&&
getInverseMapStreamCount
(
L_Stream
)
>
0
){
(
void
)
fprintf
(
getLog
(),
"%s case: J-map=%d L-map=%d -- not handled.
\n
"
,
methodName
.
c_str
(),
getInverseMapStreamCount
(
J_Stream
),
getInverseMapStreamCount
(
L_Stream
)
);
(
void
)
fflush
(
getLog
()
);
}
// this is for testing purposes a-- may need to be cleaned
// or add new gather functions
kinvmap_gather5_2
(
width
,
inverseStreamMaps
[
J_Stream
][
0
]
->
getBrookStream
(),
inverseStreamMaps
[
J_Stream
][
1
]
->
getBrookStream
(),
...
...
@@ -2006,6 +2032,7 @@ void BrookBonded::computeForces( BrookStreamImpl& positionStream, BrookStreamImp
inverseStreamMaps
[
L_Stream
][
1
]
->
getBrookStream
(),
bondedForceStreams
[
L_Stream
]
->
getBrookStream
(),
forceStream
.
getBrookStream
(),
forceStream
.
getBrookStream
()
);
/*
std::stringstream message;
message << methodName << "J-maps=" << getInverseMapStreamCount( J_Stream ) << " and " <<
...
...
platforms/brook/src/BrookBonded.h
View file @
7ed51ce4
...
...
@@ -347,7 +347,7 @@ class BrookBonded : public BrookCommon {
*
*/
int
addRB
Dihedral
s
(
int
*
nbondeds
,
int
*
particles
,
BrookOpenMMFloat
*
params
[],
const
std
::
vector
<
std
::
vector
<
int
>
>&
rbTorsionIndices
,
int
addRB
Torsion
s
(
int
*
nbondeds
,
int
*
particles
,
BrookOpenMMFloat
*
params
[],
const
std
::
vector
<
std
::
vector
<
int
>
>&
rbTorsionIndices
,
const
std
::
vector
<
std
::
vector
<
double
>
>&
rbTorsionParameters
);
/**
...
...
@@ -363,7 +363,7 @@ class BrookBonded : public BrookCommon {
*
*/
int
addP
Dihedral
s
(
int
*
nbondeds
,
int
*
particles
,
BrookOpenMMFloat
*
params
[],
const
std
::
vector
<
std
::
vector
<
int
>
>&
periodicTorsionIndices
,
int
addP
Torsion
s
(
int
*
nbondeds
,
int
*
particles
,
BrookOpenMMFloat
*
params
[],
const
std
::
vector
<
std
::
vector
<
int
>
>&
periodicTorsionIndices
,
const
std
::
vector
<
std
::
vector
<
double
>
>&
periodicTorsionParameters
);
/**
...
...
@@ -456,7 +456,7 @@ class BrookBonded : public BrookCommon {
* forces are to be picked up from and stores the position
* in the appropriate index.
*
* Input: number of
dihedral
s, the particle indices, and a flag indicating
* Input: number of
torsion
s, the particle indices, and a flag indicating
* whether we're doing i(0), j(1), k(2) or l(3)
* Output: an array of counts per particle
* arrays of inversemaps
...
...
platforms/brook/src/BrookCalcGBSAOBCForceKernel.cpp
View file @
7ed51ce4
...
...
@@ -64,7 +64,6 @@ BrookCalcGBSAOBCForceKernel::BrookCalcGBSAOBCForceKernel( std::string name, cons
// ---------------------------------------------------------------------------------------
_numberOfParticles
=
0
;
_brookGbsa
=
NULL
;
_log
=
NULL
;
const
BrookPlatform
brookPlatform
=
dynamic_cast
<
const
BrookPlatform
&>
(
platform
);
...
...
@@ -72,6 +71,7 @@ BrookCalcGBSAOBCForceKernel::BrookCalcGBSAOBCForceKernel( std::string name, cons
setLog
(
brookPlatform
.
getLog
()
);
}
_openMMBrookInterface
.
setNumberOfParticles
(
system
.
getNumParticles
()
);
}
/**
...
...
@@ -88,7 +88,6 @@ BrookCalcGBSAOBCForceKernel::~BrookCalcGBSAOBCForceKernel( ){
// ---------------------------------------------------------------------------------------
delete
_brookGbsa
;
}
/**
...
...
@@ -136,11 +135,7 @@ void BrookCalcGBSAOBCForceKernel::initialize( const System& system, const GBSAOB
// ---------------------------------------------------------------------------------------
if
(
_brookGbsa
){
delete
_brookGbsa
;
}
_brookGbsa
=
new
BrookGbsa
();
_brookGbsa
->
setLog
(
log
);
BrookGbsa
&
brookGbsa
=
_openMMBrookInterface
.
getBrookGbsa
();
// get parameters from force object
// and initialize brookGbsa
...
...
@@ -159,13 +154,13 @@ void BrookCalcGBSAOBCForceKernel::initialize( const System& system, const GBSAOB
parameters
[
1
]
=
radius
;
parameters
[
2
]
=
scalingFactor
;
}
_
brookGbsa
->
setup
(
particleParameters
,
force
.
getSolventDielectric
(),
force
.
getSoluteDielectric
(),
getPlatform
()
);
brookGbsa
.
setup
(
particleParameters
,
force
.
getSolventDielectric
(),
force
.
getSoluteDielectric
(),
getPlatform
()
);
_openMMBrookInterface
.
setTriggerForceKernel
(
this
);
_openMMBrookInterface
.
setTriggerEnergyKernel
(
this
);
if
(
log
){
std
::
string
contents
=
_
brookGbsa
->
getContentsString
(
);
std
::
string
contents
=
brookGbsa
.
getContentsString
(
);
(
void
)
fprintf
(
log
,
"%s brookGbsa::contents
\n
%s"
,
methodName
.
c_str
(),
contents
.
c_str
()
);
(
void
)
fflush
(
log
);
}
...
...
@@ -213,7 +208,7 @@ double BrookCalcGBSAOBCForceKernel::executeEnergy( OpenMMContextImpl& context ){
// ---------------------------------------------------------------------------------------
if
(
_openMMBrookInterface
.
getTriggerEnergyKernel
()
==
this
){
return
(
double
)
_openMMBrookInterface
.
computeEnergy
(
context
);
return
(
double
)
_openMMBrookInterface
.
computeEnergy
(
context
,
_system
);
}
else
{
return
0.0
;
}
...
...
platforms/brook/src/BrookCalcGBSAOBCForceKernel.h
View file @
7ed51ce4
...
...
@@ -122,6 +122,15 @@ class BrookCalcGBSAOBCForceKernel : public CalcGBSAOBCForceKernel {
FILE
*
getLog
(
void
)
const
;
/**
* Get Brook GBSA reference
*
* @return Brook GBSA reference
*
*/
BrookGbsa
&
getBrookGbsa
(
void
)
const
;
private:
// log file reference
...
...
@@ -132,10 +141,6 @@ class BrookCalcGBSAOBCForceKernel : public CalcGBSAOBCForceKernel {
int
_numberOfParticles
;
// Brook Gbsa
BrookGbsa
*
_brookGbsa
;
// interface
OpenMMBrookInterface
&
_openMMBrookInterface
;
...
...
platforms/brook/src/BrookCalcHarmonicAngleForceKernel.cpp
View file @
7ed51ce4
...
...
@@ -66,6 +66,7 @@ BrookCalcHarmonicAngleForceKernel::BrookCalcHarmonicAngleForceKernel( std::strin
if
(
brookPlatform
.
getLog
()
!=
NULL
){
setLog
(
brookPlatform
.
getLog
()
);
}
_openMMBrookInterface
.
setNumberOfParticles
(
system
.
getNumParticles
()
);
}
...
...
@@ -214,7 +215,7 @@ double BrookCalcHarmonicAngleForceKernel::executeEnergy( OpenMMContextImpl& cont
// ---------------------------------------------------------------------------------------
if
(
_openMMBrookInterface
.
getTriggerEnergyKernel
()
==
this
){
return
(
double
)
_openMMBrookInterface
.
computeEnergy
(
context
);
return
(
double
)
_openMMBrookInterface
.
computeEnergy
(
context
,
_system
);
}
else
{
return
0.0
;
}
...
...
platforms/brook/src/BrookCalcHarmonicBondForceKernel.cpp
View file @
7ed51ce4
...
...
@@ -67,6 +67,8 @@ BrookCalcHarmonicBondForceKernel::BrookCalcHarmonicBondForceKernel( std::string
setLog
(
brookPlatform
.
getLog
()
);
}
_openMMBrookInterface
.
setNumberOfParticles
(
system
.
getNumParticles
()
);
}
/**
...
...
@@ -215,7 +217,7 @@ double BrookCalcHarmonicBondForceKernel::executeEnergy( OpenMMContextImpl& conte
// ---------------------------------------------------------------------------------------
if
(
_openMMBrookInterface
.
getTriggerEnergyKernel
()
==
this
){
return
(
double
)
_openMMBrookInterface
.
computeEnergy
(
context
);
return
(
double
)
_openMMBrookInterface
.
computeEnergy
(
context
,
_system
);
}
else
{
return
0.0
;
}
...
...
platforms/brook/src/BrookCalcKineticEnergyKernel.cpp
View file @
7ed51ce4
...
...
@@ -56,7 +56,8 @@ BrookCalcKineticEnergyKernel::BrookCalcKineticEnergyKernel( std::string name, co
// ---------------------------------------------------------------------------------------
_numberOfParticles
=
0
;
_openMMBrookInterface
.
setNumberOfParticles
(
system
.
getNumParticles
()
);
_numberOfParticles
=
system
.
getNumParticles
();
_masses
=
NULL
;
}
...
...
platforms/brook/src/BrookCalcNonbondedForceKernel.cpp
View file @
7ed51ce4
...
...
@@ -61,8 +61,9 @@ BrookCalcNonbondedForceKernel::BrookCalcNonbondedForceKernel( std::string name,
// ---------------------------------------------------------------------------------------
_numberOfParticles
=
0
;
_brookNonBonded
=
NULL
;
_numberOfParticles
=
system
.
getNumParticles
();
_openMMBrookInterface
.
setNumberOfParticles
(
system
.
getNumParticles
()
);
_brookBondParameters
=
NULL
;
_log
=
NULL
;
...
...
@@ -94,7 +95,6 @@ BrookCalcNonbondedForceKernel::~BrookCalcNonbondedForceKernel( ){
// ---------------------------------------------------------------------------------------
//delete _brookBondParameters;
delete
_brookNonBonded
;
// deleted w/ kernel delete? If activated, program crashes
...
...
@@ -168,11 +168,7 @@ void BrookCalcNonbondedForceKernel::initialize( const System& system, const Nonb
// nonbonded
if
(
_brookNonBonded
){
delete
_brookNonBonded
;
}
_brookNonBonded
=
new
BrookNonBonded
();
_brookNonBonded
->
setLog
(
log
);
BrookNonBonded
&
brookNonBonded
=
_openMMBrookInterface
.
getBrookNonBonded
();
// charge & LJ parameters
...
...
@@ -187,15 +183,14 @@ void BrookCalcNonbondedForceKernel::initialize( const System& system, const Nonb
particleParamArray
[
2
]
=
charge
;
}
_
brookNonBonded
->
setup
(
_numberOfParticles
,
nonbondedParameters
,
exclusions
,
getPlatform
()
);
brookNonBonded
.
setup
(
_numberOfParticles
,
nonbondedParameters
,
exclusions
,
getPlatform
()
);
_openMMBrookInterface
.
setTriggerForceKernel
(
this
);
_openMMBrookInterface
.
setTriggerEnergyKernel
(
this
);
// echo contents
if
(
log
){
std
::
string
contents
=
_
brookNonBonded
->
getContentsString
(
);
std
::
string
contents
=
brookNonBonded
.
getContentsString
(
);
(
void
)
fprintf
(
log
,
"%s brookNonBonded::contents
\n
%s"
,
methodName
.
c_str
(),
contents
.
c_str
()
);
(
void
)
fflush
(
log
);
}
...
...
@@ -303,7 +298,7 @@ double BrookCalcNonbondedForceKernel::executeEnergy( OpenMMContextImpl& context
// ---------------------------------------------------------------------------------------
if
(
_openMMBrookInterface
.
getTriggerEnergyKernel
()
==
this
){
return
(
double
)
_openMMBrookInterface
.
computeEnergy
(
context
);
return
(
double
)
_openMMBrookInterface
.
computeEnergy
(
context
,
_system
);
}
else
{
return
0.0
;
}
...
...
platforms/brook/src/BrookCalcNonbondedForceKernel.h
View file @
7ed51ce4
...
...
@@ -169,10 +169,6 @@ class BrookCalcNonbondedForceKernel : public CalcNonbondedForceKernel {
int
_numberOfParticles
;
// Brook nonbonded
BrookNonBonded
*
_brookNonBonded
;
OpenMMBrookInterface
&
_openMMBrookInterface
;
System
&
_system
;
...
...
platforms/brook/src/BrookCalcPeriodicTorsionForceKernel.cpp
View file @
7ed51ce4
...
...
@@ -36,7 +36,7 @@
using
namespace
OpenMM
;
using
namespace
std
;
const
std
::
string
BrookCalcPeriodicTorsionForceKernel
::
BondName
=
"Proper
Dihedral
"
;
const
std
::
string
BrookCalcPeriodicTorsionForceKernel
::
BondName
=
"Proper
Torsion
"
;
/**
* BrookCalcPeriodicTorsionForceKernel constructor
...
...
@@ -61,6 +61,7 @@ BrookCalcPeriodicTorsionForceKernel::BrookCalcPeriodicTorsionForceKernel( std::s
_brookBondParameters
=
NULL
;
_log
=
NULL
;
_openMMBrookInterface
.
setNumberOfParticles
(
system
.
getNumParticles
()
);
const
BrookPlatform
brookPlatform
=
dynamic_cast
<
const
BrookPlatform
&>
(
platform
);
if
(
brookPlatform
.
getLog
()
!=
NULL
){
...
...
@@ -115,7 +116,7 @@ int BrookCalcPeriodicTorsionForceKernel::setLog( FILE* log ){
* Initialize the kernel, setting up the values of all the force field parameters.
*
* @param system System reference
* @param force Proper
Dihedral
Force reference
* @param force Proper
Torsion
Force reference
*
*/
...
...
@@ -216,7 +217,7 @@ double BrookCalcPeriodicTorsionForceKernel::executeEnergy( OpenMMContextImpl& co
// ---------------------------------------------------------------------------------------
if
(
_openMMBrookInterface
.
getTriggerEnergyKernel
()
==
this
){
return
(
double
)
_openMMBrookInterface
.
computeEnergy
(
context
);
return
(
double
)
_openMMBrookInterface
.
computeEnergy
(
context
,
_system
);
}
else
{
return
0.0
;
}
...
...
platforms/brook/src/BrookCalcPeriodicTorsionForceKernel.h
View file @
7ed51ce4
...
...
@@ -63,7 +63,7 @@ class BrookCalcPeriodicTorsionForceKernel : public CalcPeriodicTorsionForceKerne
* Initialize the kernel, setting up the values to calculate harmonic bond force & energy
*
* @param system System reference
* @param force Proper
Dihedral
Force reference
* @param force Proper
Torsion
Force reference
*
*/
...
...
platforms/brook/src/BrookCalcRBTorsionForceKernel.cpp
View file @
7ed51ce4
...
...
@@ -36,7 +36,7 @@
using
namespace
OpenMM
;
using
namespace
std
;
const
std
::
string
BrookCalcRBTorsionForceKernel
::
BondName
=
"Rb
Dihedral
"
;
const
std
::
string
BrookCalcRBTorsionForceKernel
::
BondName
=
"Rb
Torsion
"
;
/**
* BrookCalcRBTorsionForceKernel constructor
...
...
@@ -61,6 +61,7 @@ BrookCalcRBTorsionForceKernel::BrookCalcRBTorsionForceKernel( std::string name,
_brookBondParameters
=
NULL
;
_log
=
NULL
;
_openMMBrookInterface
.
setNumberOfParticles
(
system
.
getNumParticles
()
);
const
BrookPlatform
brookPlatform
=
dynamic_cast
<
const
BrookPlatform
&>
(
platform
);
if
(
brookPlatform
.
getLog
()
!=
NULL
){
...
...
@@ -115,7 +116,7 @@ int BrookCalcRBTorsionForceKernel::setLog( FILE* log ){
* Initialize the kernel, setting up the values of all the force field parameters.
*
* @param system System reference
* @param force Rb
Dihedral
Force reference
* @param force Rb
Torsion
Force reference
*
*/
...
...
@@ -219,7 +220,7 @@ double BrookCalcRBTorsionForceKernel::executeEnergy( OpenMMContextImpl& context
// ---------------------------------------------------------------------------------------
if
(
_openMMBrookInterface
.
getTriggerEnergyKernel
()
==
this
){
return
(
double
)
_openMMBrookInterface
.
computeEnergy
(
context
);
return
(
double
)
_openMMBrookInterface
.
computeEnergy
(
context
,
_system
);
}
else
{
return
0.0
;
}
...
...
platforms/brook/src/BrookCalcRBTorsionForceKernel.h
View file @
7ed51ce4
...
...
@@ -63,7 +63,7 @@ class BrookCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel {
* Initialize the kernel, setting up the values to calculate harmonic bond force & energy
*
* @param system System reference
* @param force Rb
Dihedral
Force reference
* @param force Rb
Torsion
Force reference
*
*/
...
...
platforms/brook/src/BrookCommon.cpp
View file @
7ed51ce4
...
...
@@ -120,7 +120,7 @@ BrookCommon::BrookCommon( ){
_particleStreamSize
=
-
1
;
_log
=
NULL
;
_
verbosity
=
0
;
_
isActive
=
0
;
}
...
...
@@ -347,27 +347,27 @@ int BrookCommon::setLog( FILE* log ){
}
/**
* Get
verbosity
* Get
flag signalling whether active
*
* @return
verbosity
* @return
flag signalling whether active
*
*/
int
BrookCommon
::
getVerbosity
(
void
)
const
{
return
_
verbosity
;
int
BrookCommon
::
isActive
(
void
)
const
{
return
_
isActive
;
}
/**
* Set
verbosity
* Set
flag signalling whether active
*
* @param
verbosity
* @param
flag signalling whether active
*
* @return DefaultReturnValue
*
*/
int
BrookCommon
::
set
Verbosity
(
int
verbosity
){
_
verbosity
=
verbosity
;
int
BrookCommon
::
set
IsActive
(
int
isActive
){
_
isActive
=
isActive
;
return
BrookCommon
::
DefaultReturnValue
;
}
...
...
platforms/brook/src/BrookCommon.h
View file @
7ed51ce4
...
...
@@ -201,6 +201,24 @@ class BrookCommon {
int
getParticleStreamSize
(
void
)
const
;
/**
* Get flag signalling whether active
*
* @return flag signalling whether active
*/
int
isActive
(
void
)
const
;
/**
* Set flag signalling whether active
*
* @param isActive flag signalling whether active
*
* @return DefaultReturnValue
*/
int
setIsActive
(
int
isActive
);
/**
* Set log file reference
*
...
...
@@ -232,24 +250,6 @@ class BrookCommon {
FILE
*
getLog
(
void
)
const
;
/**
* Get verbose flag
*
* @return verbosity flag
*
*/
int
getVerbosity
(
void
)
const
;
/**
* Set verbosity flag
*
* @param verbosity flag
*
*/
int
setVerbosity
(
int
verbosity
);
/*
* Given number of stream elements and width, returns the appropriate
* height of the stream
...
...
@@ -332,9 +332,9 @@ class BrookCommon {
FILE
*
_log
;
//
verbosity
//
active flag
int
_
verbosity
;
int
_
isActive
;
/**
* Set number of particles
...
...
platforms/brook/src/BrookIntegrateBrownianStepKernel.cpp
View file @
7ed51ce4
...
...
@@ -106,7 +106,7 @@ void BrookIntegrateBrownianStepKernel::initialize( const vector<double>& masses,
_brookRandomNumberGenerator
=
new
BrookRandomNumberGenerator
(
);
_brookRandomNumberGenerator
->
setup
(
(
int
)
masses
.
size
(),
getPlatform
()
);
_brookRandomNumberGenerator
->
setVerbosity
(
1
);
//
_brookRandomNumberGenerator->setVerbosity( 1 );
}
/**
...
...
platforms/brook/src/BrookIntegrateLangevinStepKernel.cpp
View file @
7ed51ce4
...
...
@@ -141,7 +141,7 @@ void BrookIntegrateLangevinStepKernel::initialize( const System& system, const L
_brookRandomNumberGenerator
=
new
BrookRandomNumberGenerator
(
);
_brookRandomNumberGenerator
->
setup
(
(
int
)
masses
.
size
(),
getPlatform
()
);
_brookRandomNumberGenerator
->
setVerbosity
(
1
);
//
_brookRandomNumberGenerator->setVerbosity( 1 );
}
...
...
platforms/brook/src/BrookPlatform.cpp
View file @
7ed51ce4
...
...
@@ -456,7 +456,9 @@ void BrookPlatform::contextCreated( OpenMMContextImpl& context ) const {
// ---------------------------------------------------------------------------------------
context
.
setPlatformData
(
new
OpenMMBrookInterface
(
getParticleStreamWidth
()
)
);
OpenMMBrookInterface
*
openMMBrookInterface
=
new
OpenMMBrookInterface
(
getParticleStreamWidth
()
);
openMMBrookInterface
->
setLog
(
stderr
);
context
.
setPlatformData
(
openMMBrookInterface
);
}
/**
...
...
platforms/brook/src/BrookRandomNumberGenerator.cpp
View file @
7ed51ce4
...
...
@@ -375,7 +375,7 @@ int BrookRandomNumberGenerator::_loadRandomNumberStreamsKiss( void ){
state
[
2
]
=
rand
();
state
[
3
]
=
rand
();
if
(
getVerbosity
()
&&
getLog
()
){
if
(
getLog
()
){
(
void
)
fprintf
(
getLog
(),
"LoadGVStreamsKiss: reset state seeds stateInitialized=%d reseed=%d
\n
"
,
stateInitialized
,
reseed
);
(
void
)
fflush
(
getLog
()
);
...
...
@@ -395,7 +395,7 @@ state[3] = 27587;
float
*
loadBuffer
=
_getLoadBuffer
();
if
(
getVerbosity
()
&&
getLog
()
){
if
(
getLog
()
){
static
float
count
=
0.0
f
;
float
block
=
(
float
)
(
3
*
getRandomNumberStreamSize
()
);
count
+=
1.0
f
;
...
...
platforms/brook/src/OpenMMBrookInterface.cpp
View file @
7ed51ce4
...
...
@@ -34,6 +34,12 @@
#include "OpenMMException.h"
#include <sstream>
// used for energy calculartion
#include "LangevinIntegrator.h"
#include "ReferencePlatform.h"
#include "internal/OpenMMContextImpl.h"
#include "BrookStreamImpl.h"
#include "OpenMMBrookInterface.h"
#include "gpu/kcommon.h"
...
...
@@ -56,10 +62,6 @@ OpenMMBrookInterface::OpenMMBrookInterface( int streamWidth ) : _particleStreamW
_numberOfParticles
=
0
;
_brookBonded
=
NULL
;
_brookNonBonded
=
NULL
;
_brookGbsa
=
NULL
;
_triggerForceKernel
=
NULL
;
_triggerEnergyKernel
=
NULL
;
...
...
@@ -99,9 +101,6 @@ OpenMMBrookInterface::~OpenMMBrookInterface( ){
// ---------------------------------------------------------------------------------------
delete
_brookBonded
;
delete
_brookNonBonded
;
delete
_brookGbsa
;
for
(
int
ii
=
0
;
ii
<
LastBondForce
;
ii
++
){
delete
_bondParameters
[
ii
];
}
...
...
@@ -128,6 +127,18 @@ int OpenMMBrookInterface::getNumberOfParticles( void ) const {
return
_numberOfParticles
;
}
/**
* Set number of particles
*
* @param numberOfParticles number of particles
*
*/
int
OpenMMBrookInterface
::
setNumberOfParticles
(
int
numberOfParticles
){
_numberOfParticles
=
numberOfParticles
;
return
BrookCommon
::
DefaultReturnValue
;
}
/**
* Get particle stream width
*
...
...
@@ -198,6 +209,9 @@ FILE* OpenMMBrookInterface::getLog( void ) const {
int
OpenMMBrookInterface
::
setLog
(
FILE
*
log
){
_log
=
log
;
_brookBonded
.
setLog
(
log
);
_brookNonBonded
.
setLog
(
log
);
_brookGbsa
.
setLog
(
log
);
return
BrookCommon
::
DefaultReturnValue
;
}
...
...
@@ -225,7 +239,20 @@ BrookBondParameters* OpenMMBrookInterface::_getBondParameters( BondParameterIndi
*/
int
OpenMMBrookInterface
::
_setBondParameters
(
BondParameterIndices
index
,
BrookBondParameters
*
brookBondParameters
){
if
(
brookBondParameters
&&
brookBondParameters
->
getNumberOfBonds
()
>
0
){
_brookBonded
.
setIsActive
(
1
);
}
_bondParameters
[
index
]
=
brookBondParameters
;
if
(
!
brookBondParameters
||
brookBondParameters
->
getNumberOfBonds
()
<
1
){
int
isActive
=
0
;
for
(
int
ii
=
0
;
ii
<
LastBondForce
&&
!
isActive
;
ii
++
){
isActive
=
(
_bondParameters
[
ii
]
!=
NULL
&&
brookBondParameters
->
getNumberOfBonds
()
>
0
)
?
1
:
0
;
}
_brookBonded
.
setIsActive
(
isActive
);
}
return
BrookCommon
::
DefaultReturnValue
;
}
...
...
@@ -473,6 +500,28 @@ void* OpenMMBrookInterface::getTriggerEnergyKernel( void ) const {
return
_triggerEnergyKernel
;
}
/**
* Get Brook non bonded
*
* @return BrookNonBonded reference
*
*/
BrookNonBonded
&
OpenMMBrookInterface
::
getBrookNonBonded
(
void
){
return
_brookNonBonded
;
}
/**
* Get Brook GBSA
*
* @return BrookGbsa reference
*
*/
BrookGbsa
&
OpenMMBrookInterface
::
getBrookGbsa
(
void
){
return
_brookGbsa
;
}
/**
* Zero forces
*
...
...
@@ -517,8 +566,6 @@ void OpenMMBrookInterface::computeForces( OpenMMContextImpl& context ){
// static const int debug = 1;
(
void
)
fprintf
(
stderr
,
"%s "
,
methodName
.
c_str
()
);
(
void
)
fflush
(
stderr
);
// ---------------------------------------------------------------------------------------
// nonbonded forces
...
...
@@ -526,27 +573,27 @@ void OpenMMBrookInterface::computeForces( OpenMMContextImpl& context ){
BrookStreamImpl
*
positions
=
getParticlePositions
();
BrookStreamImpl
*
forces
=
getParticleForces
();
if
(
_brookNonBonded
){
_brookNonBonded
->
computeForces
(
*
positions
,
*
forces
);
if
(
_brookNonBonded
.
isActive
()
){
_brookNonBonded
.
computeForces
(
*
positions
,
*
forces
);
}
// ---------------------------------------------------------------------------------------
// bonded forces
if
(
_brookBonded
){
if
(
_brookBonded
.
isActive
()
){
(
void
)
fprintf
(
stderr
,
"%s Bonded"
,
methodName
.
c_str
()
);
(
void
)
fflush
(
stderr
);
//
(void) fprintf( stderr, "%s Bonded
\n
", methodName.c_str() ); (void) fflush( stderr );
// perform setup first time through
if
(
_brookBonded
->
isSetupCompleted
()
==
0
){
_brookBonded
->
setup
(
getNumberOfParticles
(),
getHarmonicBondForceParameters
(),
getHarmonicAngleForceParameters
(),
if
(
_brookBonded
.
isSetupCompleted
()
==
0
){
_brookBonded
.
setup
(
getNumberOfParticles
(),
getHarmonicBondForceParameters
(),
getHarmonicAngleForceParameters
(),
getPeriodicTorsionForceParameters
(),
getRBTorsionForceParameters
(),
getNonBonded14ForceParameters
(),
getLj14Scale
(),
getCoulomb14Scale
(),
getParticleStreamWidth
(),
getParticleStreamSize
()
);
}
_brookBonded
->
computeForces
(
*
positions
,
*
forces
);
_brookBonded
.
computeForces
(
*
positions
,
*
forces
);
// diagnostics
...
...
@@ -569,8 +616,8 @@ void OpenMMBrookInterface::computeForces( OpenMMContextImpl& context ){
// GBSA OBC forces
if
(
_brookGbsa
){
_brookGbsa
->
computeForces
(
*
positions
,
*
forces
);
if
(
_brookGbsa
.
isActive
()
){
_brookGbsa
.
computeForces
(
*
positions
,
*
forces
);
}
// ---------------------------------------------------------------------------------------
...
...
@@ -580,25 +627,36 @@ void OpenMMBrookInterface::computeForces( OpenMMContextImpl& context ){
* Compute energy
*
* @param context context
* @param system system reference
*
*/
double
OpenMMBrookInterface
::
computeEnergy
(
OpenMMContextImpl
&
context
){
double
OpenMMBrookInterface
::
computeEnergy
(
OpenMMContextImpl
&
context
,
System
&
system
){
// ---------------------------------------------------------------------------------------
/*
static const std::string methodName = "OpenMMBrookInterface::computeEnergy";
static const int PrintOn = 0;
static const int MaxErrorMessages = 2;
static int ErrorMessages = 0;
*/
// static const int debug = 1;
//static const std::string methodName = "OpenMMBrookInterface::computeEnergy";
// ---------------------------------------------------------------------------------------
return
0.0
;
// We don't currently have GPU kernels to calculate energy, so instead we have the reference
// platform do it. This is VERY slow.
LangevinIntegrator
integrator
(
0.0
,
1.0
,
0.0
);
ReferencePlatform
platform
;
OpenMMContext
refContext
(
system
,
integrator
,
platform
);
const
Stream
&
positions
=
context
.
getPositions
();
double
*
posData
=
new
double
[
positions
.
getSize
()
*
3
];
positions
.
saveToArray
(
posData
);
vector
<
Vec3
>
pos
(
positions
.
getSize
());
for
(
int
ii
=
0
;
ii
<
pos
.
size
();
ii
++
){
pos
[
ii
]
=
Vec3
(
posData
[
3
*
ii
],
posData
[
3
*
ii
+
1
],
posData
[
3
*
ii
+
2
]);
}
delete
[]
posData
;
refContext
.
setPositions
(
pos
);
return
refContext
.
getState
(
State
::
Energy
).
getPotentialEnergy
();
// ---------------------------------------------------------------------------------------
}
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment