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
309008f7
Commit
309008f7
authored
Dec 12, 2008
by
Mark Friedrichs
Browse files
Mods
parent
cdee990d
Changes
62
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
875 additions
and
1219 deletions
+875
-1219
platforms/brook/src/BrookCalcRBTorsionForceKernel.cpp
platforms/brook/src/BrookCalcRBTorsionForceKernel.cpp
+5
-5
platforms/brook/src/BrookCalcRBTorsionForceKernel.h
platforms/brook/src/BrookCalcRBTorsionForceKernel.h
+3
-3
platforms/brook/src/BrookCalcStandardMMForceFieldKernel.cpp
platforms/brook/src/BrookCalcStandardMMForceFieldKernel.cpp
+0
-793
platforms/brook/src/BrookCommon.cpp
platforms/brook/src/BrookCommon.cpp
+70
-70
platforms/brook/src/BrookCommon.h
platforms/brook/src/BrookCommon.h
+43
-43
platforms/brook/src/BrookFloatStreamInternal.cpp
platforms/brook/src/BrookFloatStreamInternal.cpp
+64
-0
platforms/brook/src/BrookFloatStreamInternal.h
platforms/brook/src/BrookFloatStreamInternal.h
+13
-0
platforms/brook/src/BrookGbsa.cpp
platforms/brook/src/BrookGbsa.cpp
+399
-123
platforms/brook/src/BrookGbsa.h
platforms/brook/src/BrookGbsa.h
+53
-46
platforms/brook/src/BrookIntStreamInternal.cpp
platforms/brook/src/BrookIntStreamInternal.cpp
+48
-0
platforms/brook/src/BrookIntStreamInternal.h
platforms/brook/src/BrookIntStreamInternal.h
+13
-0
platforms/brook/src/BrookIntegrateBrownianStepKernel.cpp
platforms/brook/src/BrookIntegrateBrownianStepKernel.cpp
+6
-6
platforms/brook/src/BrookIntegrateBrownianStepKernel.h
platforms/brook/src/BrookIntegrateBrownianStepKernel.h
+3
-3
platforms/brook/src/BrookIntegrateLangevinStepKernel.cpp
platforms/brook/src/BrookIntegrateLangevinStepKernel.cpp
+6
-6
platforms/brook/src/BrookIntegrateLangevinStepKernel.h
platforms/brook/src/BrookIntegrateLangevinStepKernel.h
+3
-3
platforms/brook/src/BrookIntegrateVerletStepKernel.cpp
platforms/brook/src/BrookIntegrateVerletStepKernel.cpp
+6
-6
platforms/brook/src/BrookIntegrateVerletStepKernel.h
platforms/brook/src/BrookIntegrateVerletStepKernel.h
+6
-6
platforms/brook/src/BrookKernelFactory.cpp
platforms/brook/src/BrookKernelFactory.cpp
+39
-11
platforms/brook/src/BrookLangevinDynamics.cpp
platforms/brook/src/BrookLangevinDynamics.cpp
+72
-72
platforms/brook/src/BrookLangevinDynamics.h
platforms/brook/src/BrookLangevinDynamics.h
+23
-23
No files found.
platforms/brook/src/BrookCalcRBTorsionForceKernel.cpp
View file @
309008f7
...
...
@@ -49,7 +49,7 @@ const std::string BrookCalcRBTorsionForceKernel::BondName = "RbDihedral";
*/
BrookCalcRBTorsionForceKernel
::
BrookCalcRBTorsionForceKernel
(
std
::
string
name
,
const
Platform
&
platform
,
OpenMMBrookInterface
&
openMMBrookInterface
,
System
&
system
)
:
OpenMMBrookInterface
&
openMMBrookInterface
,
System
&
system
)
:
CalcRBTorsionForceKernel
(
name
,
platform
),
_openMMBrookInterface
(
openMMBrookInterface
),
_system
(
system
){
// ---------------------------------------------------------------------------------------
...
...
@@ -131,21 +131,21 @@ void BrookCalcRBTorsionForceKernel::initialize( const System& system, const RBTo
// ---------------------------------------------------------------------------------------
// create _brookBondParameters object containing
atom
indices/parameters
// create _brookBondParameters object containing
particle
indices/parameters
int
numberOfBonds
=
force
.
getNumTorsions
();
if
(
_brookBondParameters
){
delete
_brookBondParameters
;
}
_brookBondParameters
=
new
BrookBondParameters
(
BondName
,
NumberOf
Atom
sInBond
,
NumberOfParametersInBond
,
numberOfBonds
,
getLog
()
);
_brookBondParameters
=
new
BrookBondParameters
(
BondName
,
NumberOf
Particle
sInBond
,
NumberOfParametersInBond
,
numberOfBonds
,
getLog
()
);
for
(
int
ii
=
0
;
ii
<
numberOfBonds
;
ii
++
){
int
particle1
,
particle2
,
particle3
,
particle4
;
double
c0
,
c1
,
c2
,
c3
,
c4
,
c5
;
int
particles
[
NumberOf
Atom
sInBond
];
int
particles
[
NumberOf
Particle
sInBond
];
double
parameters
[
NumberOfParametersInBond
];
force
.
getTorsionParameters
(
ii
,
particle1
,
particle2
,
particle3
,
particle4
,
c0
,
c1
,
c2
,
c3
,
c4
,
c5
);
...
...
@@ -178,7 +178,7 @@ void BrookCalcRBTorsionForceKernel::initialize( const System& system, const RBTo
}
/**
* Compute forces given
atom
coordinates
* Compute forces given
particle
coordinates
*
* @param context OpenMMContextImpl context
*
...
...
platforms/brook/src/BrookCalcRBTorsionForceKernel.h
View file @
309008f7
...
...
@@ -72,7 +72,7 @@ class BrookCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel {
/**
* Execute the kernel to calculate the forces.
*
* @param positions
atom
coordiantes
* @param positions
particle
coordiantes
* @param forces output forces
*
*/
...
...
@@ -133,7 +133,7 @@ class BrookCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel {
/**
* Get indices/parameters
*
* @return BrookBondParameters containing
atom
indices/parameters
* @return BrookBondParameters containing
particle
indices/parameters
*
*/
...
...
@@ -141,7 +141,7 @@ class BrookCalcRBTorsionForceKernel : public CalcRBTorsionForceKernel {
private:
static
const
int
NumberOf
Atom
sInBond
=
4
;
static
const
int
NumberOf
Particle
sInBond
=
4
;
static
const
int
NumberOfParametersInBond
=
6
;
// bond name
...
...
platforms/brook/src/BrookCalcStandardMMForceFieldKernel.cpp
deleted
100644 → 0
View file @
cdee990d
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Authors: Peter Eastman, Mark Friedrichs *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include <cmath>
#include <limits>
#include "OpenMMException.h"
#include <sstream>
#include "BrookStreamImpl.h"
#include "BrookCalcNonbondedForceKernel.h"
#include "gpu/kforce.h"
#include "gpu/kinvmap_gather.h"
#include "NonbondedForce.h"
using
namespace
OpenMM
;
using
namespace
std
;
/**
* BrookCalcNonbondedForceKernel constructor
*
* @param name kernel name
* @param platform platform
*
*/
BrookCalcNonbondedForceKernel
::
BrookCalcNonbondedForceKernel
(
std
::
string
name
,
const
Platform
&
platform
)
:
CalcNonbondedForceKernel
(
name
,
platform
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCalcNonbondedForceKernel::BrookCalcNonbondedForceKernel";
// ---------------------------------------------------------------------------------------
_numberOfAtoms
=
0
;
_brookBonded
=
NULL
;
_brookNonBonded
=
NULL
;
_refForceField
=
NULL
;
_log
=
NULL
;
_refForceField
=
NULL
;
_refSystem
=
NULL
;
_refOpenMMContext
=
NULL
;
_referencePlatform
=
NULL
;
_refVerletIntegrator
=
NULL
;
const
BrookPlatform
brookPlatform
=
dynamic_cast
<
const
BrookPlatform
&>
(
platform
);
if
(
brookPlatform
.
getLog
()
!=
NULL
){
setLog
(
brookPlatform
.
getLog
()
);
}
}
/**
* BrookCalcNonbondedForceKernel destructor
*
*/
BrookCalcNonbondedForceKernel
::~
BrookCalcNonbondedForceKernel
(
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCalcNonbondedForceKernel::BrookCalcNonbondedForceKernel";
// ---------------------------------------------------------------------------------------
delete
_brookBonded
;
delete
_brookNonBonded
;
// deleted w/ kernel delete? If activated, program crashes
//delete _refForceField;
/*
delete _refSystem;
delete _refOpenMMContext;
delete _referencePlatform;
delete _refVerletIntegrator;
*/
}
/**
* Get log file reference
*
* @return log file reference
*
*/
FILE
*
BrookCalcNonbondedForceKernel
::
getLog
(
void
)
const
{
return
_log
;
}
/**
* Set log file reference
*
* @param log file reference
*
* @return DefaultReturnValue
*
*/
int
BrookCalcNonbondedForceKernel
::
setLog
(
FILE
*
log
){
_log
=
log
;
return
BrookCommon
::
DefaultReturnValue
;
}
/**
* Initialize the kernel, setting up the values of all the force field parameters.
*
* @param bondIndices the two atoms connected by each bond term
* @param bondParameters the force parameters (length, k) for each bond term
* @param angleIndices the three atoms connected by each angle term
* @param angleParameters the force parameters (angle, k) for each angle term
* @param periodicTorsionIndices the four atoms connected by each periodic torsion term
* @param periodicTorsionParameters the force parameters (k, phase, periodicity) for each periodic torsion term
* @param rbTorsionIndices the four atoms connected by each Ryckaert-Bellemans torsion term
* @param rbTorsionParameters the coefficients (in order of increasing powers) for each Ryckaert-Bellemans torsion term
* @param bonded14Indices each element contains the indices of two atoms whose nonbonded interactions should be reduced since
* they form a bonded 1-4 pair
* @param lj14Scale the factor by which van der Waals interactions should be reduced for bonded 1-4 pairs
* @param coulomb14Scale the factor by which Coulomb interactions should be reduced for bonded 1-4 pairs
* @param exclusions the i'th element lists the indices of all atoms with which the i'th atom should not interact through
* nonbonded forces. Bonded 1-4 pairs are also included in this list, since they should be omitted from
* the standard nonbonded calculation.
* @param nonbondedParameters the nonbonded force parameters (charge, sigma, epsilon) for each atom
* @param nonbondedMethod the method to use for handling long range nonbonded interactions
* @param nonbondedCutoff the cutoff distance for nonbonded interactions (if nonbondedMethod involves a cutoff)
* @param periodicBoxSize the size of the periodic box (if nonbondedMethod involves a periodic boundary conditions)
*/
void
BrookCalcNonbondedForceKernel
::
initialize
(
const
vector
<
vector
<
int
>
>&
bondIndices
,
const
vector
<
vector
<
double
>
>&
bondParameters
,
const
vector
<
vector
<
int
>
>&
angleIndices
,
const
vector
<
vector
<
double
>
>&
angleParameters
,
const
vector
<
vector
<
int
>
>&
periodicTorsionIndices
,
const
vector
<
vector
<
double
>
>&
periodicTorsionParameters
,
const
vector
<
vector
<
int
>
>&
rbTorsionIndices
,
const
vector
<
vector
<
double
>
>&
rbTorsionParameters
,
const
vector
<
vector
<
int
>
>&
bonded14Indices
,
double
lj14Scale
,
double
coulomb14Scale
,
const
vector
<
set
<
int
>
>&
exclusions
,
const
vector
<
vector
<
double
>
>&
nonbondedParameters
,
NonbondedMethod
nonbondedMethod
,
double
nonbondedCutoff
,
double
periodicBoxSize
[
3
]
){
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"BrookCalcNonbondedForceKernel::initialize"
;
// ---------------------------------------------------------------------------------------
FILE
*
log
=
getLog
();
_numberOfAtoms
=
nonbondedParameters
.
size
();
// ---------------------------------------------------------------------------------------
// bonded
if
(
_brookBonded
){
delete
_brookBonded
;
}
_brookBonded
=
new
BrookBonded
();
_brookBonded
->
setLog
(
log
);
_brookBonded
->
setup
(
_numberOfAtoms
,
bondIndices
,
bondParameters
,
angleIndices
,
angleParameters
,
periodicTorsionIndices
,
periodicTorsionParameters
,
rbTorsionIndices
,
rbTorsionParameters
,
bonded14Indices
,
nonbondedParameters
,
lj14Scale
,
coulomb14Scale
,
getPlatform
()
);
// echo contents
if
(
log
){
std
::
string
contents
=
_brookBonded
->
getContentsString
(
);
(
void
)
fprintf
(
log
,
"%s brookBonded::contents
\n
%s"
,
methodName
.
c_str
(),
contents
.
c_str
()
);
(
void
)
fflush
(
log
);
}
// ---------------------------------------------------------------------------------------
// nonbonded
if
(
_brookNonBonded
){
delete
_brookNonBonded
;
}
_brookNonBonded
=
new
BrookNonBonded
();
_brookNonBonded
->
setLog
(
log
);
_brookNonBonded
->
setup
(
_numberOfAtoms
,
nonbondedParameters
,
exclusions
,
getPlatform
()
);
// echo contents
if
(
log
){
std
::
string
contents
=
_brookNonBonded
->
getContentsString
(
);
(
void
)
fprintf
(
log
,
"%s brookNonBonded::contents
\n
%s"
,
methodName
.
c_str
(),
contents
.
c_str
()
);
(
void
)
fflush
(
log
);
}
// ---------------------------------------------------------------------------------------
// used for calculating energy
/*
_referenceCalcNonbondedForceKernel = new ReferenceCalcNonbondedForceKernel( getName(), getPlatform() );
_referenceCalcNonbondedForceKernel->initialize( bondIndices, bondParameters,
angleIndices, angleParameters,
periodicTorsionIndices, periodicTorsionParameters,
rbTorsionIndices, rbTorsionParameters,
bonded14Indices, lj14Scale, coulomb14Scale,
exclusions, nonbondedParameters,
nonbondedMethod, nonbondedCutoff, periodicBoxSize );
*/
_refForceField
=
new
NonbondedForce
(
_numberOfAtoms
,
bondIndices
.
size
(),
angleIndices
.
size
(),
periodicTorsionIndices
.
size
(),
rbTorsionIndices
.
size
()
);
// bonds
vector
<
vector
<
int
>
>::
const_iterator
bondI_it
=
bondIndices
.
begin
();
vector
<
vector
<
double
>
>::
const_iterator
bondP_it
=
bondParameters
.
begin
();
for
(
unsigned
int
ii
=
0
;
ii
<
bondIndices
.
size
();
ii
++
,
bondI_it
++
,
bondP_it
++
){
const
vector
<
int
>
bondInd
=
*
bondI_it
;
const
vector
<
double
>
bondPrm
=
*
bondP_it
;
_refForceField
->
setBondParameters
(
ii
,
bondInd
[
0
],
bondInd
[
1
],
bondPrm
[
0
],
bondPrm
[
1
]
);
}
// angles
vector
<
vector
<
int
>
>::
const_iterator
angleI_it
=
angleIndices
.
begin
();
vector
<
vector
<
double
>
>::
const_iterator
angleP_it
=
angleParameters
.
begin
();
for
(
unsigned
int
ii
=
0
;
ii
<
angleIndices
.
size
();
ii
++
,
angleI_it
++
,
angleP_it
++
){
const
vector
<
int
>
angleInd
=
*
angleI_it
;
const
vector
<
double
>
anglePrm
=
*
angleP_it
;
_refForceField
->
setAngleParameters
(
ii
,
angleInd
[
0
],
angleInd
[
1
],
angleInd
[
2
],
anglePrm
[
0
],
anglePrm
[
1
]
);
}
// periodicTorsions
vector
<
vector
<
int
>
>::
const_iterator
periodicTorsionI_it
=
periodicTorsionIndices
.
begin
();
vector
<
vector
<
double
>
>::
const_iterator
periodicTorsionP_it
=
periodicTorsionParameters
.
begin
();
for
(
unsigned
int
ii
=
0
;
ii
<
periodicTorsionIndices
.
size
();
ii
++
,
periodicTorsionI_it
++
,
periodicTorsionP_it
++
){
const
vector
<
int
>
periodicTorsionInd
=
*
periodicTorsionI_it
;
const
vector
<
double
>
periodicTorsionPrm
=
*
periodicTorsionP_it
;
_refForceField
->
setPeriodicTorsionParameters
(
ii
,
periodicTorsionInd
[
0
],
periodicTorsionInd
[
1
],
periodicTorsionInd
[
2
],
periodicTorsionInd
[
3
],
(
int
)
(
periodicTorsionPrm
[
2
]
+
0.001
),
periodicTorsionPrm
[
1
],
periodicTorsionPrm
[
0
]
);
/*
printf( "PeriodicTor: [%d %d %d %d] [%.5e %.5e %.5e]\n", periodicTorsionInd[0], periodicTorsionInd[1], periodicTorsionInd[2], periodicTorsionInd[3],
periodicTorsionPrm[2], periodicTorsionPrm[1], periodicTorsionPrm[0] ); fflush( stdout );
*/
}
// rbTorsions
vector
<
vector
<
int
>
>::
const_iterator
rbTorsionI_it
=
rbTorsionIndices
.
begin
();
vector
<
vector
<
double
>
>::
const_iterator
rbTorsionP_it
=
rbTorsionParameters
.
begin
();
for
(
unsigned
int
ii
=
0
;
ii
<
rbTorsionIndices
.
size
();
ii
++
,
rbTorsionI_it
++
,
rbTorsionP_it
++
){
const
vector
<
int
>
rbTorsionInd
=
*
rbTorsionI_it
;
const
vector
<
double
>
rbTorsionPrm
=
*
rbTorsionP_it
;
_refForceField
->
setRBTorsionParameters
(
ii
,
rbTorsionInd
[
0
],
rbTorsionInd
[
1
],
rbTorsionInd
[
2
],
rbTorsionInd
[
3
],
rbTorsionPrm
[
0
],
rbTorsionPrm
[
1
],
rbTorsionPrm
[
2
],
rbTorsionPrm
[
3
],
rbTorsionPrm
[
4
],
rbTorsionPrm
[
5
]
);
/*
printf( "RbTor: [%d %d %d %d] [%.5e %.5e %.5e %.5e %.5e %.5e]\n", rbTorsionInd[0], rbTorsionInd[1], rbTorsionInd[2], rbTorsionInd[3],
rbTorsionPrm[0], rbTorsionPrm[1], rbTorsionPrm[2], rbTorsionPrm[3], rbTorsionPrm[4], rbTorsionPrm[5] ); fflush( stdout );
*/
}
// nonbonded
for
(
unsigned
int
ii
=
0
;
ii
<
nonbondedParameters
.
size
();
ii
++
){
vector
<
double
>
nonbondedParameterVector
=
nonbondedParameters
[
ii
];
double
c6
=
nonbondedParameterVector
[
1
];
double
c12
=
nonbondedParameterVector
[
2
];
double
charge
=
nonbondedParameterVector
[
0
];
// int index, double charge, double radius, double depth
_refForceField
->
setAtomParameters
(
ii
,
charge
,
c6
,
c12
);
}
// ---------------------------------------------------------------------------------------
return
;
}
/**
* Execute the kernel to calculate the bonded & nonbonded forces
*
* @param positions stream of type Double3 containing the position (x, y, z) of each atom
* @param forces stream of type Double3 containing the force (x, y, z) on each atom. On entry, this contains the forces that
* have been calculated so far. The kernel should add its own forces to the values already in the stream.
*/
void
BrookCalcNonbondedForceKernel
::
executeForces
(
const
Stream
&
positions
,
Stream
&
forces
){
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"BrookCalcNonbondedForceKernel::executeForces"
;
static
const
int
I_Stream
=
0
;
static
const
int
J_Stream
=
1
;
static
const
int
K_Stream
=
2
;
static
const
int
L_Stream
=
3
;
static
const
int
PrintOn
=
0
;
static
const
int
MaxErrorMessages
=
2
;
static
int
ErrorMessages
=
0
;
static
const
float4
dummyParameters
(
0.0
,
0.0
,
0.0
,
0.0
);
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
const
BrookStreamImpl
&
positionStreamC
=
dynamic_cast
<
const
BrookStreamImpl
&>
(
positions
.
getImpl
());
BrookStreamImpl
&
positionStream
=
const_cast
<
BrookStreamImpl
&>
(
positionStreamC
);
BrookStreamImpl
&
forceStream
=
dynamic_cast
<
BrookStreamImpl
&>
(
forces
.
getImpl
());
// nonbonded forces
// added charge stream to knbforce_CDLJ4
// libs generated from ~/src/gmxgpu-nsqOpenMM
BrookFloatStreamInternal
**
nonbondedForceStreams
=
_brookNonBonded
->
getForceStreams
();
float
epsfac
=
138.935485
f
;
knbforce_CDLJ4
(
(
float
)
_brookNonBonded
->
getNumberOfAtoms
(),
(
float
)
_brookNonBonded
->
getAtomSizeCeiling
(),
(
float
)
_brookNonBonded
->
getDuplicationFactor
(),
(
float
)
_brookNonBonded
->
getAtomStreamHeight
(
),
(
float
)
_brookNonBonded
->
getAtomStreamWidth
(
),
(
float
)
_brookNonBonded
->
getJStreamWidth
(
),
(
float
)
_brookNonBonded
->
getPartialForceStreamWidth
(
),
epsfac
,
dummyParameters
,
positionStream
.
getBrookStream
(),
_brookNonBonded
->
getChargeStream
()
->
getBrookStream
(),
_brookNonBonded
->
getOuterVdwStream
()
->
getBrookStream
(),
_brookNonBonded
->
getInnerSigmaStream
()
->
getBrookStream
(),
_brookNonBonded
->
getInnerEpsilonStream
()
->
getBrookStream
(),
_brookNonBonded
->
getExclusionStream
()
->
getBrookStream
(),
nonbondedForceStreams
[
0
]
->
getBrookStream
(),
nonbondedForceStreams
[
1
]
->
getBrookStream
(),
nonbondedForceStreams
[
2
]
->
getBrookStream
(),
nonbondedForceStreams
[
3
]
->
getBrookStream
()
);
/*
float zerof = 0.0f;
nonbondedForceStreams[0]->fillWithValue( &zerof );
nonbondedForceStreams[1]->fillWithValue( &zerof );
nonbondedForceStreams[2]->fillWithValue( &zerof );
nonbondedForceStreams[3]->fillWithValue( &zerof );
*/
// diagnostics
if
(
1
&&
PrintOn
){
(
void
)
fprintf
(
getLog
(),
"
\n
Post knbforce_CDLJ4: atoms=%6d ceiling=%3d dupFac=%3d"
,
_brookNonBonded
->
getNumberOfAtoms
(),
_brookNonBonded
->
getAtomSizeCeiling
(),
_brookNonBonded
->
getDuplicationFactor
()
);
(
void
)
fprintf
(
getLog
(),
"
\n
hght=%6d width=%3d jWid=%3d"
,
_brookNonBonded
->
getAtomStreamHeight
(
),
_brookNonBonded
->
getAtomStreamWidth
(
),
_brookNonBonded
->
getJStreamWidth
(
)
);
(
void
)
fprintf
(
getLog
(),
"
\n
pFrc=%6d eps=%12.5e
\n
"
,
_brookNonBonded
->
getPartialForceStreamWidth
(
),
epsfac
);
(
void
)
fprintf
(
getLog
(),
"
\n
OuterVdwStreamd
\n
"
);
_brookNonBonded
->
getOuterVdwStream
()
->
printToFile
(
getLog
()
);
(
void
)
fprintf
(
getLog
(),
"
\n
InnerSigmaStream
\n
"
);
_brookNonBonded
->
getInnerSigmaStream
()
->
printToFile
(
getLog
()
);
(
void
)
fprintf
(
getLog
(),
"
\n
InnerEpsilonStream
\n
"
);
_brookNonBonded
->
getInnerEpsilonStream
()
->
printToFile
(
getLog
()
);
(
void
)
fprintf
(
getLog
(),
"
\n
ExclusionStream
\n
"
);
_brookNonBonded
->
getExclusionStream
()
->
printToFile
(
getLog
()
);
(
void
)
fprintf
(
getLog
(),
"
\n
ChargeStream
\n
"
);
_brookNonBonded
->
getChargeStream
()
->
printToFile
(
getLog
()
);
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
){
(
void
)
fprintf
(
getLog
(),
"
\n
Force stream %d
\n
"
,
ii
);
nonbondedForceStreams
[
ii
]
->
printToFile
(
getLog
()
);
}
}
// ---------------------------------------------------------------------------------------
// gather forces
kMergeFloat3_4_nobranch
(
(
float
)
_brookNonBonded
->
getDuplicationFactor
(),
(
float
)
_brookNonBonded
->
getAtomStreamWidth
(),
(
float
)
_brookNonBonded
->
getPartialForceStreamWidth
(),
(
float
)
_brookNonBonded
->
getNumberOfAtoms
(),
(
float
)
_brookNonBonded
->
getAtomSizeCeiling
(),
(
float
)
_brookNonBonded
->
getOuterLoopUnroll
(),
nonbondedForceStreams
[
0
]
->
getBrookStream
(),
nonbondedForceStreams
[
1
]
->
getBrookStream
(),
nonbondedForceStreams
[
2
]
->
getBrookStream
(),
nonbondedForceStreams
[
3
]
->
getBrookStream
(),
forceStream
.
getBrookStream
()
);
// diagnostics
if
(
0
&&
PrintOn
){
(
void
)
fprintf
(
getLog
(),
"
\n
NB forces"
);
BrookStreamInternal
*
brookStreamInternalF
=
forceStream
.
getBrookStreamImpl
();
brookStreamInternalF
->
printToFile
(
getLog
()
);
}
// ---------------------------------------------------------------------------------------
// bonded
epsfac
=
(
float
)
(
_brookBonded
->
getLJ_14Scale
()
*
_brookBonded
->
getCoulombFactor
());
float
width
=
(
float
)
(
_brookBonded
->
getInverseMapStreamWidth
());
// bonded forces
BrookFloatStreamInternal
**
bondedParameters
=
_brookBonded
->
getBondedParameterStreams
();
BrookFloatStreamInternal
**
bondedForceStreams
=
_brookBonded
->
getBondedForceStreams
();
BrookFloatStreamInternal
**
inverseStreamMaps
[
4
];
inverseStreamMaps
[
0
]
=
_brookBonded
->
getInverseStreamMapsStreams
(
0
);
inverseStreamMaps
[
1
]
=
_brookBonded
->
getInverseStreamMapsStreams
(
1
);
inverseStreamMaps
[
2
]
=
_brookBonded
->
getInverseStreamMapsStreams
(
2
);
inverseStreamMaps
[
3
]
=
_brookBonded
->
getInverseStreamMapsStreams
(
3
);
kbonded_CDLJ
(
epsfac
,
(
float
)
bondedForceStreams
[
0
]
->
getStreamWidth
(),
dummyParameters
,
positionStream
.
getBrookStream
(),
_brookBonded
->
getChargeStream
()
->
getBrookStream
(),
_brookBonded
->
getAtomIndicesStream
()
->
getBrookStream
(),
bondedParameters
[
0
]
->
getBrookStream
(),
bondedParameters
[
1
]
->
getBrookStream
(),
bondedParameters
[
2
]
->
getBrookStream
(),
bondedParameters
[
3
]
->
getBrookStream
(),
bondedParameters
[
4
]
->
getBrookStream
(),
bondedForceStreams
[
0
]
->
getBrookStream
(),
bondedForceStreams
[
1
]
->
getBrookStream
(),
bondedForceStreams
[
2
]
->
getBrookStream
(),
bondedForceStreams
[
3
]
->
getBrookStream
()
);
// diagnostics
if
(
1
&&
PrintOn
){
int
countPrintInvMap
[
4
]
=
{
3
,
5
,
2
,
4
};
(
void
)
fprintf
(
getLog
(),
"
\n
Post kbonded_CDLJ: epsFac=%.6f %.6f %.6f"
,
epsfac
,
_brookBonded
->
getLJ_14Scale
(),
_brookBonded
->
getCoulombFactor
());
(
void
)
fprintf
(
getLog
(),
"
\n
Atom indices stream
\n
"
);
_brookBonded
->
getAtomIndicesStream
()
->
printToFile
(
getLog
()
);
(
void
)
fprintf
(
getLog
(),
"
\n
Charge stream
\n
"
);
_brookBonded
->
getChargeStream
()
->
printToFile
(
getLog
()
);
for
(
int
ii
=
0
;
ii
<
5
;
ii
++
){
(
void
)
fprintf
(
getLog
(),
"
\n
Param stream %d
\n
"
,
ii
);
bondedParameters
[
ii
]
->
printToFile
(
getLog
()
);
}
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
){
(
void
)
fprintf
(
getLog
(),
"
\n
Force stream %d
\n
"
,
ii
);
bondedForceStreams
[
ii
]
->
printToFile
(
getLog
()
);
}
/*
(void) fprintf( getLog(), "\nNB1 forces" );
BrookStreamInternal* brookStreamInternalF = forceStream.getBrookStreamImpl();
brookStreamInternalF->printToFile( getLog() );
*/
(
void
)
fprintf
(
getLog
(),
"
\n
Inverse map streams -- K_Stream cnt=%d
\n
"
,
_brookBonded
->
getInverseMapStreamCount
(
K_Stream
)
);
for
(
int
ii
=
0
;
ii
<
4
;
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
()
);
}
}
}
// gather forces
if
(
_brookBonded
->
getInverseMapStreamCount
(
I_Stream
)
==
3
&&
_brookBonded
->
getInverseMapStreamCount
(
K_Stream
)
==
3
){
kinvmap_gather3_3
(
width
,
inverseStreamMaps
[
I_Stream
][
0
]
->
getBrookStream
(),
inverseStreamMaps
[
I_Stream
][
1
]
->
getBrookStream
(),
inverseStreamMaps
[
I_Stream
][
2
]
->
getBrookStream
(),
bondedForceStreams
[
I_Stream
]
->
getBrookStream
(),
inverseStreamMaps
[
K_Stream
][
0
]
->
getBrookStream
(),
inverseStreamMaps
[
K_Stream
][
1
]
->
getBrookStream
(),
inverseStreamMaps
[
K_Stream
][
2
]
->
getBrookStream
(),
bondedForceStreams
[
K_Stream
]
->
getBrookStream
(),
forceStream
.
getBrookStream
(),
forceStream
.
getBrookStream
()
);
}
else
if
(
_brookBonded
->
getInverseMapStreamCount
(
I_Stream
)
==
3
&&
_brookBonded
->
getInverseMapStreamCount
(
K_Stream
)
==
4
){
kinvmap_gather3_4
(
width
,
inverseStreamMaps
[
I_Stream
][
0
]
->
getBrookStream
(),
inverseStreamMaps
[
I_Stream
][
1
]
->
getBrookStream
(),
inverseStreamMaps
[
I_Stream
][
2
]
->
getBrookStream
(),
bondedForceStreams
[
I_Stream
]
->
getBrookStream
(),
inverseStreamMaps
[
K_Stream
][
0
]
->
getBrookStream
(),
inverseStreamMaps
[
K_Stream
][
1
]
->
getBrookStream
(),
inverseStreamMaps
[
K_Stream
][
2
]
->
getBrookStream
(),
inverseStreamMaps
[
K_Stream
][
3
]
->
getBrookStream
(),
bondedForceStreams
[
K_Stream
]
->
getBrookStream
(),
forceStream
.
getBrookStream
(),
forceStream
.
getBrookStream
()
);
}
else
if
(
_brookBonded
->
getInverseMapStreamCount
(
I_Stream
)
==
3
&&
_brookBonded
->
getInverseMapStreamCount
(
K_Stream
)
==
5
){
kinvmap_gather3_5
(
width
,
inverseStreamMaps
[
I_Stream
][
0
]
->
getBrookStream
(),
inverseStreamMaps
[
I_Stream
][
1
]
->
getBrookStream
(),
inverseStreamMaps
[
I_Stream
][
2
]
->
getBrookStream
(),
bondedForceStreams
[
I_Stream
]
->
getBrookStream
(),
inverseStreamMaps
[
K_Stream
][
0
]
->
getBrookStream
(),
inverseStreamMaps
[
K_Stream
][
1
]
->
getBrookStream
(),
inverseStreamMaps
[
K_Stream
][
2
]
->
getBrookStream
(),
inverseStreamMaps
[
K_Stream
][
3
]
->
getBrookStream
(),
inverseStreamMaps
[
K_Stream
][
4
]
->
getBrookStream
(),
bondedForceStreams
[
K_Stream
]
->
getBrookStream
(),
forceStream
.
getBrookStream
(),
forceStream
.
getBrookStream
()
);
}
else
{
// case not handled -- throw an exception
if
(
_brookBonded
->
getLog
()
&&
ErrorMessages
++
<
MaxErrorMessages
){
(
void
)
fprintf
(
_brookBonded
->
getLog
(),
"%s case: I-map=%d K-map=%d -- not handled.
\n
"
,
methodName
.
c_str
(),
_brookBonded
->
getInverseMapStreamCount
(
I_Stream
),
_brookBonded
->
getInverseMapStreamCount
(
K_Stream
)
);
(
void
)
fflush
(
_brookBonded
->
getLog
()
);
}
kinvmap_gather3_3
(
width
,
inverseStreamMaps
[
I_Stream
][
0
]
->
getBrookStream
(),
inverseStreamMaps
[
I_Stream
][
1
]
->
getBrookStream
(),
inverseStreamMaps
[
I_Stream
][
2
]
->
getBrookStream
(),
bondedForceStreams
[
I_Stream
]
->
getBrookStream
(),
inverseStreamMaps
[
K_Stream
][
0
]
->
getBrookStream
(),
inverseStreamMaps
[
K_Stream
][
1
]
->
getBrookStream
(),
inverseStreamMaps
[
K_Stream
][
2
]
->
getBrookStream
(),
bondedForceStreams
[
K_Stream
]
->
getBrookStream
(),
forceStream
.
getBrookStream
(),
forceStream
.
getBrookStream
()
);
/*
std::stringstream message;
message << methodName << "I-maps=" << _brookBonded->getInverseMapStreamCount( I_Stream ) << " and " <<
"K-maps=" << _brookBonded->getInverseMapStreamCount( K_Stream ) << " not handled.";
throw OpenMMException( message.str() );
*/
}
// diagnostics
if
(
0
&&
PrintOn
){
(
void
)
fprintf
(
getLog
(),
"
\n
Post 3_4/3_5 && NB forces"
);
BrookStreamInternal
*
brookStreamInternalF
=
forceStream
.
getBrookStreamImpl
();
brookStreamInternalF
->
printToFile
(
getLog
()
);
}
if
(
_brookBonded
->
getInverseMapStreamCount
(
J_Stream
)
==
5
&&
_brookBonded
->
getInverseMapStreamCount
(
L_Stream
)
==
2
){
kinvmap_gather5_2
(
width
,
inverseStreamMaps
[
J_Stream
][
0
]
->
getBrookStream
(),
inverseStreamMaps
[
J_Stream
][
1
]
->
getBrookStream
(),
inverseStreamMaps
[
J_Stream
][
2
]
->
getBrookStream
(),
inverseStreamMaps
[
J_Stream
][
3
]
->
getBrookStream
(),
inverseStreamMaps
[
J_Stream
][
4
]
->
getBrookStream
(),
bondedForceStreams
[
J_Stream
]
->
getBrookStream
(),
inverseStreamMaps
[
L_Stream
][
0
]
->
getBrookStream
(),
inverseStreamMaps
[
L_Stream
][
1
]
->
getBrookStream
(),
bondedForceStreams
[
L_Stream
]
->
getBrookStream
(),
forceStream
.
getBrookStream
(),
forceStream
.
getBrookStream
()
);
}
else
{
// case not handled -- throw an exception
if
(
_brookBonded
->
getLog
()
&&
ErrorMessages
++
<
MaxErrorMessages
){
(
void
)
fprintf
(
_brookBonded
->
getLog
(),
"%s case: J-map=%d L-map=%d -- not handled.
\n
"
,
methodName
.
c_str
(),
_brookBonded
->
getInverseMapStreamCount
(
J_Stream
),
_brookBonded
->
getInverseMapStreamCount
(
L_Stream
)
);
(
void
)
fflush
(
_brookBonded
->
getLog
()
);
}
kinvmap_gather5_2
(
width
,
inverseStreamMaps
[
J_Stream
][
0
]
->
getBrookStream
(),
inverseStreamMaps
[
J_Stream
][
1
]
->
getBrookStream
(),
inverseStreamMaps
[
J_Stream
][
2
]
->
getBrookStream
(),
inverseStreamMaps
[
J_Stream
][
3
]
->
getBrookStream
(),
inverseStreamMaps
[
J_Stream
][
4
]
->
getBrookStream
(),
bondedForceStreams
[
J_Stream
]
->
getBrookStream
(),
inverseStreamMaps
[
L_Stream
][
0
]
->
getBrookStream
(),
inverseStreamMaps
[
L_Stream
][
1
]
->
getBrookStream
(),
bondedForceStreams
[
L_Stream
]
->
getBrookStream
(),
forceStream
.
getBrookStream
(),
forceStream
.
getBrookStream
()
);
/*
std::stringstream message;
message << methodName << "J-maps=" << _brookBonded->getInverseMapStreamCount( J_Stream ) << " and " <<
"L-maps=" << _brookBonded->getInverseMapStreamCount( L_Stream ) << " not handled.";
throw OpenMMException( message.str() );
*/
}
// diagnostics
if
(
1
&&
PrintOn
){
(
void
)
fprintf
(
getLog
(),
"
\n
Final NB & bonded forces"
);
BrookStreamInternal
*
brookStreamInternalF
=
forceStream
.
getBrookStreamImpl
();
brookStreamInternalF
->
printToFile
(
getLog
()
);
/*
void* dataV = brookStreamInternalF->getData(1);
float* data = (float*) dataV;
(void) fprintf( getLog(), "\nFinal NB & bonded forces RAW\n" );
for( int ii = 0; ii < _brookNonBonded->getNumberOfAtoms()*3; ii += 3 ){
(void) fprintf( getLog(), "%d [%.6e %.6e %.6e]\n", ii, data[ii], data[ii+1], data[ii+2] );
}
*/
}
// ---------------------------------------------------------------------------------------
}
/**
* Execute the kernel to calculate the energy.
*
* @param positions atom positions
*
* @return potential energy due to the NonbondedForce
* Currently always return 0.0 since energies not calculated on gpu
*
*/
double
BrookCalcNonbondedForceKernel
::
executeEnergy
(
const
Stream
&
atomPositions
){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookCalcNonbondedForceKernel::executeEnergy";
// ---------------------------------------------------------------------------------------
const
BrookStreamImpl
&
positionStreamC
=
dynamic_cast
<
const
BrookStreamImpl
&>
(
atomPositions
.
getImpl
());
BrookStreamImpl
&
positionStream
=
const_cast
<
BrookStreamImpl
&>
(
positionStreamC
);
BrookOpenMMFloat
*
positionsF
=
(
BrookOpenMMFloat
*
)
positionStream
.
getData
();
OpenMMContext
*
context
=
getReferenceOpenMMContext
(
atomPositions
.
getSize
()
);
vector
<
Vec3
>
positions
(
positionStream
.
getSize
()
);
int
index
=
0
;
for
(
int
ii
=
0
;
ii
<
positionStream
.
getSize
();
ii
++
,
index
+=
3
){
positions
[
ii
]
=
Vec3
(
positionsF
[
index
],
positionsF
[
index
+
1
],
positionsF
[
index
+
2
]
);
}
context
->
setPositions
(
positions
);
State
state
=
context
->
getState
(
State
::
Energy
);
double
energy
=
state
.
getPotentialEnergy
();
// (void) fprintf( stdout, "BrookCalcNonbondedForceKernel::executeEnergy E=%.5e\n", energy ); fflush( stdout );
return
energy
;
}
/**
* Get reference Context
*
* @param numberOfAtoms number of atoms
*
* @return OpenMMContext
*
*/
OpenMMContext
*
BrookCalcNonbondedForceKernel
::
getReferenceOpenMMContext
(
int
numberOfAtoms
){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookCalcNonbondedForceKernel::getReferenceOpenMMContext";
// ---------------------------------------------------------------------------------------
if
(
_refOpenMMContext
==
NULL
){
_referencePlatform
=
new
ReferencePlatform
();
_refSystem
=
new
System
(
numberOfAtoms
,
0
);
_refVerletIntegrator
=
new
VerletIntegrator
(
0.01
);
_refSystem
->
addForce
(
_refForceField
);
_refOpenMMContext
=
new
OpenMMContext
(
*
_refSystem
,
*
_refVerletIntegrator
,
*
_referencePlatform
);
}
return
_refOpenMMContext
;
}
/**
* Execute the kernel to calculate the energy.
*
* @param positions atom positions
*
* @return potential energy due to the NonbondedForce
* Currently always return 0.0 since energies not calculated on gpu
*
*/
double
BrookCalcNonbondedForceKernel
::
executeEnergyOld
(
const
Stream
&
atomPositions
){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookCalcNonbondedForceKernel::executeEnergy";
// ---------------------------------------------------------------------------------------
const
BrookStreamImpl
&
positionStreamC
=
dynamic_cast
<
const
BrookStreamImpl
&>
(
atomPositions
.
getImpl
());
BrookStreamImpl
&
positionStream
=
const_cast
<
BrookStreamImpl
&>
(
positionStreamC
);
BrookOpenMMFloat
*
positionsF
=
(
BrookOpenMMFloat
*
)
positionStream
.
getData
();
ReferencePlatform
refPlatform
;
System
system
(
atomPositions
.
getSize
(),
0
);
VerletIntegrator
integrator
(
0.01
);
system
.
addForce
(
_refForceField
);
OpenMMContext
context
(
system
,
integrator
,
refPlatform
);
vector
<
Vec3
>
positions
(
positionStream
.
getSize
()
);
int
index
=
0
;
for
(
int
ii
=
0
;
ii
<
positionStream
.
getSize
();
ii
++
,
index
+=
3
){
positions
[
ii
]
=
Vec3
(
positionsF
[
index
],
positionsF
[
index
+
1
],
positionsF
[
index
+
2
]
);
}
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Energy
);
double
energy
=
state
.
getPotentialEnergy
();
//delete forceField;
// (void) fprintf( stdout, "BrookCalcNonbondedForceKernel::executeEnergy E=%.5e\n", energy ); fflush( stdout );
return
energy
;
}
platforms/brook/src/BrookCommon.cpp
View file @
309008f7
...
...
@@ -44,7 +44,7 @@ using namespace std;
// bonded streams
const
std
::
string
BrookCommon
::
Bonded
Atom
IndicesStream
=
"Bonded
Atom
IndicesStream"
;
const
std
::
string
BrookCommon
::
Bonded
Particle
IndicesStream
=
"Bonded
Particle
IndicesStream"
;
const
std
::
string
BrookCommon
::
BondedParametersStream
=
"BondedParametersStream"
;
const
std
::
string
BrookCommon
::
UnrolledForceStream
=
"UnrolledForceStream"
;
const
std
::
string
BrookCommon
::
BondedChargeStream
=
"BondedChargeStream"
;
...
...
@@ -61,9 +61,9 @@ const std::string BrookCommon::PartialForceStream
// OBC Gbsa streams
const
std
::
string
BrookCommon
::
Obc
Atomic
RadiiStream
=
"Obc
Atomic
RadiiStream"
;
const
std
::
string
BrookCommon
::
ObcScaled
Atomic
RadiiStream
=
"ObcScaled
Atomic
RadiiStream"
;
const
std
::
string
BrookCommon
::
Obc
Atomic
RadiiWithDielectricOffsetStream
=
"Obc
Atomic
RadiiWithDielectricOffsetStream"
;
const
std
::
string
BrookCommon
::
Obc
Particle
RadiiStream
=
"Obc
Particle
RadiiStream"
;
const
std
::
string
BrookCommon
::
ObcScaled
Particle
RadiiStream
=
"ObcScaled
Particle
RadiiStream"
;
const
std
::
string
BrookCommon
::
Obc
Particle
RadiiWithDielectricOffsetStream
=
"Obc
Particle
RadiiWithDielectricOffsetStream"
;
const
std
::
string
BrookCommon
::
ObcBornRadiiStream
=
"ObcBornRadiiStream"
;
const
std
::
string
BrookCommon
::
ObcBornRadii2Stream
=
"ObcBornRadii2Stream"
;
const
std
::
string
BrookCommon
::
ObcIntermediateForceStream
=
"ObcIntermediateForceStream"
;
...
...
@@ -81,8 +81,8 @@ const std::string BrookCommon::InverseMassStream
// Shake streams
const
std
::
string
BrookCommon
::
Shake
Atom
IndicesStream
=
"Shake
Atom
IndicesStream"
;
const
std
::
string
BrookCommon
::
Shake
Atom
ParameterStream
=
"Shake
Atom
ParameterStream"
;
const
std
::
string
BrookCommon
::
Shake
Particle
IndicesStream
=
"Shake
Particle
IndicesStream"
;
const
std
::
string
BrookCommon
::
Shake
Particle
ParameterStream
=
"Shake
Particle
ParameterStream"
;
const
std
::
string
BrookCommon
::
ShakeXCons0Stream
=
"ShakeXCons0Stream"
;
const
std
::
string
BrookCommon
::
ShakeXCons1Stream
=
"ShakeXCons1Stream"
;
const
std
::
string
BrookCommon
::
ShakeXCons2Stream
=
"ShakeXCons2Stream"
;
...
...
@@ -112,15 +112,15 @@ BrookCommon::BrookCommon( ){
// ---------------------------------------------------------------------------------------
_numberOf
Atom
s
=
0
;
_
atom
SizeModified
=
0
;
_numberOf
Particle
s
=
0
;
_
particle
SizeModified
=
0
;
_
atom
StreamWidth
=
-
1
;
_
atom
StreamHeight
=
-
1
;
_
atom
StreamSize
=
-
1
;
_
particle
StreamWidth
=
-
1
;
_
particle
StreamHeight
=
-
1
;
_
particle
StreamSize
=
-
1
;
_log
=
NULL
;
_verbosity
=
0
;
_log
=
NULL
;
_verbosity
=
0
;
}
...
...
@@ -141,182 +141,182 @@ BrookCommon::~BrookCommon( ){
}
/**
* Get number of
atom
s
* Get number of
particle
s
*
* @return number of
atom
s
* @return number of
particle
s
*
*/
int
BrookCommon
::
getNumberOf
Atom
s
(
void
)
const
{
return
_numberOf
Atom
s
;
int
BrookCommon
::
getNumberOf
Particle
s
(
void
)
const
{
return
_numberOf
Particle
s
;
}
/**
* Get number of
atom
s
* Get number of
particle
s
*
* @param numberOf
Atom
s number of
atom
s
* @return number of
atom
s
* @param numberOf
Particle
s number of
particle
s
* @return number of
particle
s
*
*/
int
BrookCommon
::
setNumberOf
Atom
s
(
int
numberOf
Atom
s
){
if
(
numberOf
Atom
s
!=
_numberOf
Atom
s
){
_
atom
SizeModified
=
numberOf
Atom
s
;
int
BrookCommon
::
setNumberOf
Particle
s
(
int
numberOf
Particle
s
){
if
(
numberOf
Particle
s
!=
_numberOf
Particle
s
){
_
particle
SizeModified
=
numberOf
Particle
s
;
}
_numberOf
Atom
s
=
numberOf
Atom
s
;
return
_numberOf
Atom
s
;
_numberOf
Particle
s
=
numberOf
Particle
s
;
return
_numberOf
Particle
s
;
}
/**
* Get
atom
stream width
* Get
particle
stream width
*
* @param platform platform
*
* @return
atom
stream width
* @return
particle
stream width
*
*/
int
BrookCommon
::
get
Atom
StreamWidth
(
const
Platform
&
platform
){
int
BrookCommon
::
get
Particle
StreamWidth
(
const
Platform
&
platform
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::get
Atom
StreamWidth";
// static const std::string methodName = "BrookCommon::get
Particle
StreamWidth";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
// get
atom
stream width
// get
particle
stream width
if
(
_
atom
StreamWidth
<
0
){
_get
Atom
StreamDimensions
(
platform
);
if
(
_
particle
StreamWidth
<
0
){
_get
Particle
StreamDimensions
(
platform
);
}
return
_
atom
StreamWidth
;
return
_
particle
StreamWidth
;
}
/**
* Get
atom
stream width
* Get
particle
stream width
*
* @return
atom
stream width
* @return
particle
stream width
*
*/
int
BrookCommon
::
get
Atom
StreamWidth
(
void
)
const
{
int
BrookCommon
::
get
Particle
StreamWidth
(
void
)
const
{
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::get
Atom
StreamWidth";
// static const std::string methodName = "BrookCommon::get
Particle
StreamWidth";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
return
_
atom
StreamWidth
;
return
_
particle
StreamWidth
;
}
/**
* Get
atom
stream height
* Get
particle
stream height
*
* @param platform platform
*
* @return
atom
stream height
* @return
particle
stream height
*
*/
int
BrookCommon
::
get
Atom
StreamHeight
(
const
Platform
&
platform
){
int
BrookCommon
::
get
Particle
StreamHeight
(
const
Platform
&
platform
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::get
Atom
StreamHeight";
// static const std::string methodName = "BrookCommon::get
Particle
StreamHeight";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
// get
atom
stream height
// get
particle
stream height
if
(
_
atom
StreamHeight
<
0
){
_get
Atom
StreamDimensions
(
platform
);
if
(
_
particle
StreamHeight
<
0
){
_get
Particle
StreamDimensions
(
platform
);
}
return
_
atom
StreamHeight
;
return
_
particle
StreamHeight
;
}
/**
* Get
atom
stream height
* Get
particle
stream height
*
* @return
atom
stream height
* @return
particle
stream height
*
*/
int
BrookCommon
::
get
Atom
StreamHeight
(
void
)
const
{
int
BrookCommon
::
get
Particle
StreamHeight
(
void
)
const
{
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::get
Atom
StreamHeight";
// static const std::string methodName = "BrookCommon::get
Particle
StreamHeight";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
return
_
atom
StreamHeight
;
return
_
particle
StreamHeight
;
}
/**
* Get
atom
stream size
* Get
particle
stream size
*
* @param platform platform
*
* @return
atom
stream size
* @return
particle
stream size
*
*/
int
BrookCommon
::
get
Atom
StreamSize
(
const
Platform
&
platform
){
int
BrookCommon
::
get
Particle
StreamSize
(
const
Platform
&
platform
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::get
Atom
StreamSize";
// static const std::string methodName = "BrookCommon::get
Particle
StreamSize";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
// get
atom
stream size
// get
particle
stream size
if
(
_
atom
StreamSize
<
0
){
_get
Atom
StreamDimensions
(
platform
);
if
(
_
particle
StreamSize
<
0
){
_get
Particle
StreamDimensions
(
platform
);
}
return
_
atom
StreamSize
;
return
_
particle
StreamSize
;
}
/**
* Get
atom
stream size
* Get
particle
stream size
*
* @return
atom
stream size
* @return
particle
stream size
*
*/
int
BrookCommon
::
get
Atom
StreamSize
(
void
)
const
{
return
_
atom
StreamSize
;
int
BrookCommon
::
get
Particle
StreamSize
(
void
)
const
{
return
_
particle
StreamSize
;
}
/**
* Get
atom
stream dimensions
* Get
particle
stream dimensions
*
* @param platform platform
*
*/
void
BrookCommon
::
_get
Atom
StreamDimensions
(
const
Platform
&
platform
){
void
BrookCommon
::
_get
Particle
StreamDimensions
(
const
Platform
&
platform
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::_get
Atom
StreamDimensions";
// static const std::string methodName = "BrookCommon::_get
Particle
StreamDimensions";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
// get
atom
stream size
// get
particle
stream size
const
BrookPlatform
brookPlatform
=
dynamic_cast
<
const
BrookPlatform
&>
(
platform
);
const
BrookStreamFactory
&
brookStreamFactory
=
dynamic_cast
<
const
BrookStreamFactory
&>
(
platform
.
getDefaultStreamFactory
()
);
_
atom
StreamWidth
=
brookStreamFactory
.
getDefault
Atom
StreamWidth
();
_
atom
StreamSize
=
brookPlatform
.
getStreamSize
(
getNumberOf
Atoms
(),
_atom
StreamWidth
,
NULL
);
_
atom
StreamHeight
=
(
int
)
(
((
float
)
_
atom
StreamSize
)
/
(
(
float
)
_
atom
StreamWidth
)
+
0.001
);
_
particle
StreamWidth
=
brookStreamFactory
.
getDefault
Particle
StreamWidth
();
_
particle
StreamSize
=
brookPlatform
.
getStreamSize
(
getNumberOf
Particles
(),
_particle
StreamWidth
,
NULL
);
_
particle
StreamHeight
=
(
int
)
(
((
float
)
_
particle
StreamSize
)
/
(
(
float
)
_
particle
StreamWidth
)
+
0.001
);
return
;
}
...
...
platforms/brook/src/BrookCommon.h
View file @
309008f7
...
...
@@ -59,7 +59,7 @@ class BrookCommon {
// bonded stream names
static
const
std
::
string
Bonded
Atom
IndicesStream
;
static
const
std
::
string
Bonded
Particle
IndicesStream
;
static
const
std
::
string
BondedParametersStream
;
static
const
std
::
string
UnrolledForceStream
;
static
const
std
::
string
BondedChargeStream
;
...
...
@@ -76,9 +76,9 @@ class BrookCommon {
// OBC Gbsa streams
static
const
std
::
string
Obc
Atomic
RadiiStream
;
static
const
std
::
string
ObcScaled
Atomic
RadiiStream
;
static
const
std
::
string
Obc
Atomic
RadiiWithDielectricOffsetStream
;
static
const
std
::
string
Obc
Particle
RadiiStream
;
static
const
std
::
string
ObcScaled
Particle
RadiiStream
;
static
const
std
::
string
Obc
Particle
RadiiWithDielectricOffsetStream
;
static
const
std
::
string
ObcBornRadiiStream
;
static
const
std
::
string
ObcBornRadii2Stream
;
static
const
std
::
string
ObcIntermediateForceStream
;
...
...
@@ -96,8 +96,8 @@ class BrookCommon {
// Shake streams
static
const
std
::
string
Shake
Atom
IndicesStream
;
static
const
std
::
string
Shake
Atom
ParameterStream
;
static
const
std
::
string
Shake
Particle
IndicesStream
;
static
const
std
::
string
Shake
Particle
ParameterStream
;
static
const
std
::
string
ShakeXCons0Stream
;
static
const
std
::
string
ShakeXCons1Stream
;
static
const
std
::
string
ShakeXCons2Stream
;
...
...
@@ -130,76 +130,76 @@ class BrookCommon {
~
BrookCommon
();
/**
* Return number of
atom
s
* Return number of
particle
s
*
* @return number of
atom
s
* @return number of
particle
s
*
*/
int
getNumberOf
Atom
s
(
void
)
const
;
int
getNumberOf
Particle
s
(
void
)
const
;
/**
* Get
atom
ceiling parameter
* Get
particle
ceiling parameter
*
* @return
atom
ceiling parameter
* @return
particle
ceiling parameter
*
*/
int
get
Atom
SizeCeiling
(
void
)
const
;
int
get
Particle
SizeCeiling
(
void
)
const
;
/**
* Get
atom
stream width
* Get
particle
stream width
*
* @param platform platform reference
*
* @return
atom
stream width
* @return
particle
stream width
*/
int
get
Atom
StreamWidth
(
const
Platform
&
platform
);
int
get
Particle
StreamWidth
(
const
Platform
&
platform
);
/**
* Get
atom
stream width
* Get
particle
stream width
*
* @return
atom
stream width
* @return
particle
stream width
*/
int
get
Atom
StreamWidth
(
void
)
const
;
int
get
Particle
StreamWidth
(
void
)
const
;
/**
* Get
atom
stream height
* Get
particle
stream height
*
* @param platform platform reference
*
* @return
atom
stream height
* @return
particle
stream height
*/
int
get
Atom
StreamHeight
(
const
Platform
&
platform
);
int
get
Particle
StreamHeight
(
const
Platform
&
platform
);
/**
* Get
atom
stream height
* Get
particle
stream height
*
* @return
atom
stream height
* @return
particle
stream height
*/
int
get
Atom
StreamHeight
(
void
)
const
;
int
get
Particle
StreamHeight
(
void
)
const
;
/**
* Get
atom
stream size
* Get
particle
stream size
*
* @param platform platform reference
*
* @return
atom
stream size
* @return
particle
stream size
*/
int
get
Atom
StreamSize
(
const
Platform
&
platform
);
int
get
Particle
StreamSize
(
const
Platform
&
platform
);
/**
* Get
atom
stream size
* Get
particle
stream size
*
* @return
atom
stream size
* @return
particle
stream size
*/
int
get
Atom
StreamSize
(
void
)
const
;
int
get
Particle
StreamSize
(
void
)
const
;
/**
* Set log file reference
...
...
@@ -314,19 +314,19 @@ class BrookCommon {
protected:
// number of
atom
s
// number of
particle
s
int
_numberOf
Atom
s
;
int
_numberOf
Particle
s
;
//
atom
stream dimensions
//
particle
stream dimensions
int
_
atom
StreamWidth
;
int
_
atom
StreamHeight
;
int
_
atom
StreamSize
;
int
_
particle
StreamWidth
;
int
_
particle
StreamHeight
;
int
_
particle
StreamSize
;
//
atom
size mod
//
particle
size mod
int
_
atom
SizeModified
;
int
_
particle
SizeModified
;
// log file reference
...
...
@@ -337,22 +337,22 @@ class BrookCommon {
int
_verbosity
;
/**
* Set number of
atom
s
* Set number of
particle
s
*
* @param numberOf
Atom
s number of
atom
s
* @param numberOf
Particle
s number of
particle
s
*
*/
int
setNumberOf
Atom
s
(
int
numberOf
Atom
s
);
int
setNumberOf
Particle
s
(
int
numberOf
Particle
s
);
/**
* Get
atom
stream dimensions
* Get
particle
stream dimensions
*
* @param platform platform
*
*/
void
_get
Atom
StreamDimensions
(
const
Platform
&
platform
);
void
_get
Particle
StreamDimensions
(
const
Platform
&
platform
);
/*
* Get line
...
...
platforms/brook/src/BrookFloatStreamInternal.cpp
View file @
309008f7
...
...
@@ -46,6 +46,8 @@ using namespace OpenMM;
* @param inputStreamWidth stream width
* @param inputDefaultDangleValue default dangle value
*
* @throw exception if stream type not recognized or stream width < 1
*
*/
BrookFloatStreamInternal
::
BrookFloatStreamInternal
(
const
std
::
string
&
name
,
int
size
,
int
streamWidth
,
BrookStreamInternal
::
DataType
type
,
...
...
@@ -278,6 +280,18 @@ void BrookFloatStreamInternal::loadFromArray( const void* array, BrookStreamInte
_aStream
.
read
(
_data
);
}
/**
* Save data to input array
*
* @param array a pointer to the start of the array. The array is assumed to have the same length as this stream,
* and to contain elements of the correct _data type for this stream. If the stream has a compound _data type, all
* the values should be packed into a single array: all the values for the first element, followed by all the values
* for the next element, etc.
*
* @throw exception if baseType not float, double, or integer
*
*/
void
BrookFloatStreamInternal
::
saveToArray
(
void
*
array
){
// ---------------------------------------------------------------------------------------
...
...
@@ -571,3 +585,53 @@ void* BrookFloatStreamInternal::getDataArray( void ){
return
new
float
[
totalSize
];
}
/**
* BrookFloatStreamInternal constructor
*
* @param stopIndex index to stop sum
* @param sum array of size=getWidth()
*
* @return DefaultReturnValue
*
* @throw exception if stopIndex is too large
*/
int
BrookFloatStreamInternal
::
sumByDimension
(
int
stopIndex
,
double
*
sum
){
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"BrookFloatStreamInternal::sumByDimension"
;
// ---------------------------------------------------------------------------------------
if
(
stopIndex
>
getSize
()
){
std
::
stringstream
message
;
message
<<
methodName
<<
" stream="
<<
getName
()
<<
" input topIndex"
<<
stopIndex
<<
" is too large: stream size="
<<
getSize
();
throw
OpenMMException
(
message
.
str
()
);
}
// get _data from GPU
_aStream
.
write
(
_data
);
int
width
=
getWidth
();
int
widthM1
=
getWidth
()
-
1
;
stopIndex
*=
width
;
for
(
int
ii
=
0
;
ii
<
width
;
ii
++
){
sum
[
ii
]
=
0.0
;
}
int
index
=
0
;
for
(
int
ii
=
0
;
ii
<
stopIndex
;
ii
++
){
sum
[
index
]
+=
(
double
)
_data
[
ii
];
if
(
index
==
widthM1
){
index
=
0
;
}
else
{
index
++
;
}
}
return
DefaultReturnValue
;
}
platforms/brook/src/BrookFloatStreamInternal.h
View file @
309008f7
...
...
@@ -159,6 +159,19 @@ class BrookFloatStreamInternal : public BrookStreamInternal {
const
std
::
string
getContentsString
(
int
level
=
0
)
const
;
/**
* Sum over stream dimensions
*
* @param stopIndex index to stop sum
* @param sum array of size=getWidth()
*
* @return DefaultReturnValue
*
* @throw exception if stopIndex is too large
*/
int
sumByDimension
(
int
stopIndex
,
double
*
sum
);
private:
BrookOpenMMFloat
_defaultDangleValue
;
...
...
platforms/brook/src/BrookGbsa.cpp
View file @
309008f7
...
...
@@ -34,6 +34,8 @@
#include "BrookPlatform.h"
#include "OpenMMException.h"
#include "BrookStreamImpl.h"
#include "gpu/kgbsa.h"
#include "gpu/kforce.h"
using
namespace
OpenMM
;
using
namespace
std
;
...
...
@@ -51,7 +53,7 @@ BrookGbsa::BrookGbsa( ){
// ---------------------------------------------------------------------------------------
_
atom
SizeCeiling
=
-
1
;
_
particle
SizeCeiling
=
-
1
;
_outerUnroll
=
4
;
_innerUnroll
=
4
;
...
...
@@ -59,9 +61,9 @@ BrookGbsa::BrookGbsa( ){
_partialForceStreamHeight
=
-
1
;
_partialForceStreamSize
=
-
1
;
_gbsa
Atom
StreamWidth
=
-
1
;
_gbsa
Atom
StreamHeight
=
-
1
;
_gbsa
Atom
StreamSize
=
-
1
;
_gbsa
Particle
StreamWidth
=
-
1
;
_gbsa
Particle
StreamHeight
=
-
1
;
_gbsa
Particle
StreamSize
=
-
1
;
_duplicationFactor
=
4
;
...
...
@@ -200,37 +202,37 @@ float BrookGbsa::getDielectricOffset( void ) const {
int
BrookGbsa
::
setOuterLoopUnroll
(
int
outerUnroll
){
if
(
outerUnroll
!=
_outerUnroll
){
_
atom
SizeCeiling
=
-
1
;
_
particle
SizeCeiling
=
-
1
;
}
_outerUnroll
=
_outerUnroll
;
return
_outerUnroll
;
}
/**
* Get
atom
ceiling parameter
* Get
particle
ceiling parameter
*
* @return
atom
ceiling parameter
* @return
particle
ceiling parameter
*
*/
int
BrookGbsa
::
get
Atom
SizeCeiling
(
void
)
const
{
int
BrookGbsa
::
get
Particle
SizeCeiling
(
void
)
const
{
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookGbsa::get
Atom
SizeCeiling";
//static const std::string methodName = "BrookGbsa::get
Particle
SizeCeiling";
// ---------------------------------------------------------------------------------------
if
(
_
atom
SizeCeiling
<
0
){
if
(
_
particle
SizeCeiling
<
0
){
BrookGbsa
*
localThis
=
const_cast
<
BrookGbsa
*
const
>
(
this
);
localThis
->
_
atom
SizeCeiling
=
localThis
->
getNumberOf
Atom
s
()
%
localThis
->
getOuterLoopUnroll
();
if
(
localThis
->
_
atom
SizeCeiling
){
localThis
->
_
atom
SizeCeiling
=
localThis
->
getOuterLoopUnroll
()
-
localThis
->
_
atom
SizeCeiling
;
localThis
->
_
particle
SizeCeiling
=
localThis
->
getNumberOf
Particle
s
()
%
localThis
->
getOuterLoopUnroll
();
if
(
localThis
->
_
particle
SizeCeiling
){
localThis
->
_
particle
SizeCeiling
=
localThis
->
getOuterLoopUnroll
()
-
localThis
->
_
particle
SizeCeiling
;
}
localThis
->
_
atom
SizeCeiling
+=
localThis
->
getNumberOf
Atom
s
();
localThis
->
_
particle
SizeCeiling
+=
localThis
->
getNumberOf
Particle
s
();
}
return
_
atom
SizeCeiling
;
return
_
particle
SizeCeiling
;
}
/**
...
...
@@ -293,68 +295,68 @@ int BrookGbsa::getPartialForceStreamSize( void ) const {
}
/**
* Get
Atom
stream size
* Get
Particle
stream size
*
* @return
Atom
stream size
* @return
Particle
stream size
*
*/
int
BrookGbsa
::
getGbsa
Atom
StreamSize
(
void
)
const
{
return
_gbsa
Atom
StreamSize
;
int
BrookGbsa
::
getGbsa
Particle
StreamSize
(
void
)
const
{
return
_gbsa
Particle
StreamSize
;
}
/**
* Get
atom
stream width
* Get
particle
stream width
*
* @return
atom
stream width
* @return
particle
stream width
*
*/
int
BrookGbsa
::
getGbsa
Atom
StreamWidth
(
void
)
const
{
return
_gbsa
Atom
StreamWidth
;
int
BrookGbsa
::
getGbsa
Particle
StreamWidth
(
void
)
const
{
return
_gbsa
Particle
StreamWidth
;
}
/**
* Get
atom
stream height
* Get
particle
stream height
*
* @return
atom
stream height
* @return
particle
stream height
*/
int
BrookGbsa
::
getGbsa
Atom
StreamHeight
(
void
)
const
{
return
_gbsa
Atom
StreamHeight
;
int
BrookGbsa
::
getGbsa
Particle
StreamHeight
(
void
)
const
{
return
_gbsa
Particle
StreamHeight
;
}
/**
* Get Obc
atomic
radii stream
* Get Obc
particle
radii stream
*
* @return Obc
atomic
radii stream
* @return Obc
particle
radii stream
*
*/
BrookFloatStreamInternal
*
BrookGbsa
::
getObc
Atomic
Radii
(
void
)
const
{
return
_gbsaStreams
[
Obc
Atomic
RadiiStream
];
BrookFloatStreamInternal
*
BrookGbsa
::
getObc
Particle
Radii
(
void
)
const
{
return
_gbsaStreams
[
Obc
Particle
RadiiStream
];
}
/**
* Get Obc scaled
atomic
radii stream
* Get Obc scaled
particle
radii stream
*
* @return Obc scaled
atomic
radii stream
* @return Obc scaled
particle
radii stream
*
*/
BrookFloatStreamInternal
*
BrookGbsa
::
getObcScaled
Atomic
Radii
(
void
)
const
{
return
_gbsaStreams
[
ObcScaled
Atomic
RadiiStream
];
BrookFloatStreamInternal
*
BrookGbsa
::
getObcScaled
Particle
Radii
(
void
)
const
{
return
_gbsaStreams
[
ObcScaled
Particle
RadiiStream
];
}
/**
* Get Obc
atomic
radii w/ dielectric offset
* Get Obc
particle
radii w/ dielectric offset
*
* @return Obc
atomic
radii w/ dielectric offset
* @return Obc
particle
radii w/ dielectric offset
*
*/
BrookFloatStreamInternal
*
BrookGbsa
::
getObc
Atomic
RadiiWithDielectricOffset
(
void
)
const
{
return
_gbsaStreams
[
Obc
Atomic
RadiiWithDielectricOffsetStream
];
BrookFloatStreamInternal
*
BrookGbsa
::
getObc
Particle
RadiiWithDielectricOffset
(
void
)
const
{
return
_gbsaStreams
[
Obc
Particle
RadiiWithDielectricOffsetStream
];
}
/**
...
...
@@ -457,15 +459,15 @@ int BrookGbsa::calculateBornRadii( const Stream& positions ){
// load coordinates into RealOpenMM 2d array
int
numberOf
Atoms
=
getNumberOf
Atom
s
();
int
numberOf
Particles
=
getNumberOf
Particle
s
();
RealOpenMM
**
atom
Coordinates
=
new
RealOpenMM
*
[
numberOf
Atom
s
];
RealOpenMM
*
atom
CoordinatesBlk
=
new
RealOpenMM
[
3
*
numberOf
Atom
s
];
RealOpenMM
**
particle
Coordinates
=
new
RealOpenMM
*
[
numberOf
Particle
s
];
RealOpenMM
*
particle
CoordinatesBlk
=
new
RealOpenMM
[
3
*
numberOf
Particle
s
];
// Born radii array size needs to match stream size since it will
// be written down to board
int
streamSize
=
getGbsa
Atom
StreamSize
();
int
streamSize
=
getGbsa
Particle
StreamSize
();
RealOpenMM
*
bornRadii
=
new
RealOpenMM
[
streamSize
];
memset
(
bornRadii
,
0
,
sizeof
(
RealOpenMM
)
*
streamSize
);
...
...
@@ -473,30 +475,30 @@ int BrookGbsa::calculateBornRadii( const Stream& positions ){
memset
(
obcChain
,
0
,
sizeof
(
RealOpenMM
)
*
streamSize
);
int
index
=
0
;
RealOpenMM
*
atom
CoordinatesBlkPtr
=
atom
CoordinatesBlk
;
for
(
int
ii
=
0
;
ii
<
numberOf
Atom
s
;
ii
++
){
RealOpenMM
*
particle
CoordinatesBlkPtr
=
particle
CoordinatesBlk
;
for
(
int
ii
=
0
;
ii
<
numberOf
Particle
s
;
ii
++
){
atom
Coordinates
[
ii
]
=
atom
CoordinatesBlkPtr
;
atom
CoordinatesBlkPtr
+=
3
;
particle
Coordinates
[
ii
]
=
particle
CoordinatesBlkPtr
;
particle
CoordinatesBlkPtr
+=
3
;
atom
Coordinates
[
ii
][
0
]
=
coordinates
[
index
++
];
atom
Coordinates
[
ii
][
1
]
=
coordinates
[
index
++
];
atom
Coordinates
[
ii
][
2
]
=
coordinates
[
index
++
];
particle
Coordinates
[
ii
][
0
]
=
coordinates
[
index
++
];
particle
Coordinates
[
ii
][
1
]
=
coordinates
[
index
++
];
particle
Coordinates
[
ii
][
2
]
=
coordinates
[
index
++
];
}
// calculate Born radii
_cpuObc
->
computeBornRadii
(
atom
Coordinates
,
bornRadii
,
obcChain
);
_cpuObc
->
computeBornRadii
(
particle
Coordinates
,
bornRadii
,
obcChain
);
// diagnostics
if
(
PrintOn
&&
getLog
()
){
(
void
)
fprintf
(
getLog
(),
"
\n
%s: atms=%d
\n
"
,
methodName
.
c_str
(),
numberOf
Atom
s
);
for
(
int
ii
=
0
;
ii
<
numberOf
Atom
s
;
ii
++
){
(
void
)
fprintf
(
getLog
(),
"
\n
%s: atms=%d
\n
"
,
methodName
.
c_str
(),
numberOf
Particle
s
);
for
(
int
ii
=
0
;
ii
<
numberOf
Particle
s
;
ii
++
){
(
void
)
fprintf
(
getLog
(),
"%d coord=[%.5e %.5e %.5e] bR=%.5e obcChain=%.6e
\n
"
,
ii
,
atom
Coordinates
[
ii
][
0
],
atom
Coordinates
[
ii
][
1
],
atom
Coordinates
[
ii
][
2
],
bornRadii
[
ii
],
obcChain
[
ii
]
);
particle
Coordinates
[
ii
][
0
],
particle
Coordinates
[
ii
][
1
],
particle
Coordinates
[
ii
][
2
],
bornRadii
[
ii
],
obcChain
[
ii
]
);
}
}
...
...
@@ -508,8 +510,8 @@ int BrookGbsa::calculateBornRadii( const Stream& positions ){
// free memory
delete
[]
atom
CoordinatesBlk
;
delete
[]
atom
Coordinates
;
delete
[]
particle
CoordinatesBlk
;
delete
[]
particle
Coordinates
;
delete
[]
bornRadii
;
delete
[]
obcChain
;
...
...
@@ -519,14 +521,14 @@ int BrookGbsa::calculateBornRadii( const Stream& positions ){
/**
* Initialize stream dimensions
*
* @param numberOf
Atoms
number of
atom
s
* @param numberOf
Particles
number of
particle
s
* @param platform platform
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
*/
int
BrookGbsa
::
initializeStreamSizes
(
int
numberOf
Atom
s
,
const
Platform
&
platform
){
int
BrookGbsa
::
initializeStreamSizes
(
int
numberOf
Particle
s
,
const
Platform
&
platform
){
// ---------------------------------------------------------------------------------------
...
...
@@ -534,9 +536,9 @@ int BrookGbsa::initializeStreamSizes( int numberOfAtoms, const Platform& platfor
// ---------------------------------------------------------------------------------------
_gbsa
Atom
StreamSize
=
get
Atom
StreamSize
(
platform
);
_gbsa
Atom
StreamWidth
=
get
Atom
StreamWidth
(
platform
);
_gbsa
Atom
StreamHeight
=
get
Atom
StreamHeight
(
platform
);
_gbsa
Particle
StreamSize
=
get
Particle
StreamSize
(
platform
);
_gbsa
Particle
StreamWidth
=
get
Particle
StreamWidth
(
platform
);
_gbsa
Particle
StreamHeight
=
get
Particle
StreamHeight
(
platform
);
int
innerUnroll
=
getInnerLoopUnroll
();
if
(
innerUnroll
<
1
){
...
...
@@ -553,7 +555,7 @@ int BrookGbsa::initializeStreamSizes( int numberOfAtoms, const Platform& platfor
return
ErrorReturnValue
;
}
_partialForceStreamSize
=
_gbsa
Atom
StreamSize
*
getDuplicationFactor
()
/
innerUnroll
;
_partialForceStreamSize
=
_gbsa
Particle
StreamSize
*
getDuplicationFactor
()
/
innerUnroll
;
_partialForceStreamHeight
=
_partialForceStreamSize
/
_partialForceStreamWidth
;
_partialForceStreamHeight
+=
(
(
_partialForceStreamSize
%
_partialForceStreamWidth
)
?
1
:
0
);
_partialForceStreamSize
=
_partialForceStreamHeight
*
_partialForceStreamWidth
;
...
...
@@ -579,49 +581,49 @@ int BrookGbsa::initializeStreams( const Platform& platform ){
// ---------------------------------------------------------------------------------------
int
gbsa
Atom
StreamSize
=
getGbsa
Atom
StreamSize
();
int
gbsa
Atom
StreamWidth
=
getGbsa
Atom
StreamWidth
();
int
gbsa
Particle
StreamSize
=
getGbsa
Particle
StreamSize
();
int
gbsa
Particle
StreamWidth
=
getGbsa
Particle
StreamWidth
();
//
atomic
radii & charge
//
particle
radii & charge
_gbsaStreams
[
Obc
Atomic
RadiiStream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
Obc
Atomic
RadiiStream
,
gbsa
Atom
StreamSize
,
gbsa
Atom
StreamWidth
,
_gbsaStreams
[
Obc
Particle
RadiiStream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
Obc
Particle
RadiiStream
,
gbsa
Particle
StreamSize
,
gbsa
Particle
StreamWidth
,
BrookStreamInternal
::
Float2
,
dangleValue
);
// scaled
atomic
radii
// scaled
particle
radii
_gbsaStreams
[
ObcScaled
Atomic
RadiiStream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
ObcScaled
Atomic
RadiiStream
,
gbsa
Atom
StreamSize
,
gbsa
Atom
StreamWidth
,
_gbsaStreams
[
ObcScaled
Particle
RadiiStream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
ObcScaled
Particle
RadiiStream
,
gbsa
Particle
StreamSize
,
gbsa
Particle
StreamWidth
,
BrookStreamInternal
::
Float2
,
dangleValue
);
//
atomic
radii w/ DielectricOffset
//
particle
radii w/ DielectricOffset
_gbsaStreams
[
Obc
Atomic
RadiiWithDielectricOffsetStream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
Obc
Atomic
RadiiWithDielectricOffsetStream
,
gbsa
Atom
StreamSize
,
gbsa
Atom
StreamWidth
,
_gbsaStreams
[
Obc
Particle
RadiiWithDielectricOffsetStream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
Obc
Particle
RadiiWithDielectricOffsetStream
,
gbsa
Particle
StreamSize
,
gbsa
Particle
StreamWidth
,
BrookStreamInternal
::
Float
,
dangleValue
);
// Born radii
_gbsaStreams
[
ObcBornRadiiStream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
ObcBornRadiiStream
,
gbsa
Atom
StreamSize
,
gbsa
Atom
StreamWidth
,
gbsa
Particle
StreamSize
,
gbsa
Particle
StreamWidth
,
BrookStreamInternal
::
Float
,
dangleValue
);
// Born2 radii
_gbsaStreams
[
ObcBornRadii2Stream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
ObcBornRadii2Stream
,
gbsa
Atom
StreamSize
,
gbsa
Atom
StreamWidth
,
gbsa
Particle
StreamSize
,
gbsa
Particle
StreamWidth
,
BrookStreamInternal
::
Float
,
dangleValue
);
// IntermediateForce
_gbsaStreams
[
ObcIntermediateForceStream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
ObcIntermediateForceStream
,
gbsa
Atom
StreamSize
,
gbsa
Atom
StreamWidth
,
gbsa
Particle
StreamSize
,
gbsa
Particle
StreamWidth
,
BrookStreamInternal
::
Float4
,
dangleValue
);
// Obc chain
_gbsaStreams
[
ObcChainStream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
ObcChainStream
,
gbsa
Atom
StreamSize
,
gbsa
Atom
StreamWidth
,
gbsa
Particle
StreamSize
,
gbsa
Particle
StreamWidth
,
BrookStreamInternal
::
Float
,
dangleValue
);
// partial force streams
...
...
@@ -640,9 +642,9 @@ int BrookGbsa::initializeStreams( const Platform& platform ){
/*
* Setup of Gbsa parameters
*
* @param
atom
Parameters vector of OBC parameters [
atom
I][0=charge]
*
[atom
I][1=radius]
*
[atom
I][2=scaling factor]
* @param
particle
Parameters vector of OBC parameters [
particle
I][0=charge]
*
[particle
I][1=radius]
*
[particle
I][2=scaling factor]
* @param solventDielectric solvent dielectric
* @param soluteDielectric solute dielectric
* @param platform Brook platform
...
...
@@ -651,44 +653,44 @@ int BrookGbsa::initializeStreams( const Platform& platform ){
*
* */
int
BrookGbsa
::
setup
(
const
std
::
vector
<
std
::
vector
<
double
>
>&
vectorOf
Atom
Parameters
,
int
BrookGbsa
::
setup
(
const
std
::
vector
<
std
::
vector
<
double
>
>&
vectorOf
Particle
Parameters
,
double
solventDielectric
,
double
soluteDielectric
,
const
Platform
&
platform
){
// ---------------------------------------------------------------------------------------
static
const
int
atom
ParametersSize
=
3
;
static
const
int
particle
ParametersSize
=
3
;
static
const
int
maxErrors
=
20
;
static
const
std
::
string
methodName
=
"BrookGbsa::setup"
;
// ---------------------------------------------------------------------------------------
int
numberOf
Atom
s
=
(
int
)
vectorOf
Atom
Parameters
.
size
();
setNumberOf
Atom
s
(
numberOf
Atom
s
);
int
numberOf
Particle
s
=
(
int
)
vectorOf
Particle
Parameters
.
size
();
setNumberOf
Particle
s
(
numberOf
Particle
s
);
_solventDielectric
=
solventDielectric
;
_soluteDielectric
=
soluteDielectric
;
// initialize stream sizes and then Brook streams
initializeStreamSizes
(
numberOf
Atom
s
,
platform
);
initializeStreamSizes
(
numberOf
Particle
s
,
platform
);
initializeStreams
(
platform
);
int
atom
StreamSize
=
getGbsa
Atom
StreamSize
();
BrookOpenMMFloat
*
radiiAndCharge
=
new
BrookOpenMMFloat
[
atom
StreamSize
*
2
];
BrookOpenMMFloat
*
scaledRadiiAndOffset
=
new
BrookOpenMMFloat
[
atom
StreamSize
*
2
];
memset
(
radiiAndCharge
,
0
,
atom
StreamSize
*
2
*
sizeof
(
BrookOpenMMFloat
)
);
memset
(
scaledRadiiAndOffset
,
0
,
atom
StreamSize
*
2
*
sizeof
(
BrookOpenMMFloat
)
);
int
particle
StreamSize
=
getGbsa
Particle
StreamSize
();
BrookOpenMMFloat
*
radiiAndCharge
=
new
BrookOpenMMFloat
[
particle
StreamSize
*
2
];
BrookOpenMMFloat
*
scaledRadiiAndOffset
=
new
BrookOpenMMFloat
[
particle
StreamSize
*
2
];
memset
(
radiiAndCharge
,
0
,
particle
StreamSize
*
2
*
sizeof
(
BrookOpenMMFloat
)
);
memset
(
scaledRadiiAndOffset
,
0
,
particle
StreamSize
*
2
*
sizeof
(
BrookOpenMMFloat
)
);
_charges
=
new
RealOpenMM
[
atom
StreamSize
];
_charges
=
new
RealOpenMM
[
particle
StreamSize
];
// used by CpuObc to calculate initial Born radii
vector
<
RealOpenMM
>
atomic
Radii
(
numberOf
Atom
s
);
vector
<
RealOpenMM
>
scaleFactors
(
numberOf
Atom
s
);
vector
<
RealOpenMM
>
particle
Radii
(
numberOf
Particle
s
);
vector
<
RealOpenMM
>
scaleFactors
(
numberOf
Particle
s
);
float
dielectricOffset
=
getDielectricOffset
();
// loop over
atom
parameters
// loop over
particle
parameters
// track any errors and then throw exception
// check parameter vector is right size
// set parameter entries or board and arrays used by CpuObc
...
...
@@ -700,22 +702,22 @@ int BrookGbsa::setup( const std::vector<std::vector<double> >& vectorOfAtomParam
typedef
std
::
vector
<
std
::
vector
<
double
>
>
VectorOfDoubleVectors
;
typedef
VectorOfDoubleVectors
::
const_iterator
VectorOfDoubleVectorsCI
;
for
(
VectorOfDoubleVectorsCI
ii
=
vectorOf
Atom
Parameters
.
begin
();
ii
!=
vectorOf
Atom
Parameters
.
end
();
ii
++
){
for
(
VectorOfDoubleVectorsCI
ii
=
vectorOf
Particle
Parameters
.
begin
();
ii
!=
vectorOf
Particle
Parameters
.
end
();
ii
++
){
std
::
vector
<
double
>
atom
Parameters
=
*
ii
;
std
::
vector
<
double
>
particle
Parameters
=
*
ii
;
if
(
atom
Parameters
.
size
()
!=
atom
ParametersSize
&&
errors
<
maxErrors
){
message
<<
methodName
<<
" parameter size="
<<
atom
Parameters
.
size
()
<<
" for parameter vector index="
<<
vectorIndex
<<
" is less than expected.
\n
"
;
if
(
particle
Parameters
.
size
()
!=
particle
ParametersSize
&&
errors
<
maxErrors
){
message
<<
methodName
<<
" parameter size="
<<
particle
Parameters
.
size
()
<<
" for parameter vector index="
<<
vectorIndex
<<
" is less than expected.
\n
"
;
errors
++
;
}
else
{
double
charge
=
atom
Parameters
[
0
];
double
radius
=
atom
Parameters
[
1
];
double
scalingFactor
=
atom
Parameters
[
2
];
double
charge
=
particle
Parameters
[
0
];
double
radius
=
particle
Parameters
[
1
];
double
scalingFactor
=
particle
Parameters
[
2
];
int
streamIndex
=
2
*
vectorIndex
;
atomic
Radii
[
vectorIndex
]
=
static_cast
<
RealOpenMM
>
(
radius
);
particle
Radii
[
vectorIndex
]
=
static_cast
<
RealOpenMM
>
(
radius
);
scaleFactors
[
vectorIndex
]
=
static_cast
<
RealOpenMM
>
(
scalingFactor
);
_charges
[
vectorIndex
]
=
static_cast
<
RealOpenMM
>
(
charge
);
...
...
@@ -741,16 +743,16 @@ int BrookGbsa::setup( const std::vector<std::vector<double> >& vectorOfAtomParam
// load streams
_gbsaStreams
[
Obc
Atomic
RadiiStream
]
->
loadFromArray
(
radiiAndCharge
);
_gbsaStreams
[
ObcScaled
Atomic
RadiiStream
]
->
loadFromArray
(
scaledRadiiAndOffset
);
_gbsaStreams
[
Obc
Particle
RadiiStream
]
->
loadFromArray
(
radiiAndCharge
);
_gbsaStreams
[
ObcScaled
Particle
RadiiStream
]
->
loadFromArray
(
scaledRadiiAndOffset
);
delete
[]
radiiAndCharge
;
delete
[]
scaledRadiiAndOffset
;
// setup for Born radii calculation
ObcParameters
*
obcParameters
=
new
ObcParameters
(
numberOf
Atom
s
,
ObcParameters
::
ObcTypeII
);
obcParameters
->
setAtomicRadii
(
atomic
Radii
);
ObcParameters
*
obcParameters
=
new
ObcParameters
(
numberOf
Particle
s
,
ObcParameters
::
ObcTypeII
);
obcParameters
->
setAtomicRadii
(
particle
Radii
);
obcParameters
->
setScaledRadiusFactors
(
scaleFactors
);
obcParameters
->
setSolventDielectric
(
static_cast
<
RealOpenMM
>
(
solventDielectric
)
);
...
...
@@ -765,14 +767,14 @@ int BrookGbsa::setup( const std::vector<std::vector<double> >& vectorOfAtomParam
/*
* Setup of stream dimensions for partial force streams
*
* @param
atom
StreamSize
atom
stream size
* @param
atom
StreamWidth
atom
stream width
* @param
particle
StreamSize
particle
stream size
* @param
particle
StreamWidth
particle
stream width
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
* */
int
BrookGbsa
::
initializePartialForceStreamSize
(
int
atom
StreamSize
,
int
atom
StreamWidth
){
int
BrookGbsa
::
initializePartialForceStreamSize
(
int
particle
StreamSize
,
int
particle
StreamWidth
){
// ---------------------------------------------------------------------------------------
...
...
@@ -796,7 +798,7 @@ int BrookGbsa::initializePartialForceStreamSize( int atomStreamSize, int atomStr
return
ErrorReturnValue
;
}
_partialForceStreamSize
=
atom
StreamSize
*
getDuplicationFactor
()
/
innerUnroll
;
_partialForceStreamSize
=
particle
StreamSize
*
getDuplicationFactor
()
/
innerUnroll
;
_partialForceStreamHeight
=
_partialForceStreamSize
/
_partialForceStreamWidth
;
_partialForceStreamHeight
+=
(
(
_partialForceStreamSize
%
_partialForceStreamWidth
)
?
1
:
0
);
...
...
@@ -837,8 +839,8 @@ std::string BrookGbsa::getContentsString( int level ) const {
#define LOCAL_SPRINTF(a,b,c) sprintf( (a), (b), (c) );
#endif
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
getNumberOf
Atom
s
()
);
message
<<
_getLine
(
tab
,
"Number of
atom
s:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
getNumberOf
Particle
s
()
);
message
<<
_getLine
(
tab
,
"Number of
particle
s:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
getNumberOfForceStreams
()
);
message
<<
_getLine
(
tab
,
"Number of force streams:"
,
value
);
...
...
@@ -852,17 +854,17 @@ std::string BrookGbsa::getContentsString( int level ) const {
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
getOuterLoopUnroll
()
)
message
<<
_getLine
(
tab
,
"Outer loop unroll:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
get
Atom
SizeCeiling
()
);
message
<<
_getLine
(
tab
,
"
Atom
ceiling:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
get
Particle
SizeCeiling
()
);
message
<<
_getLine
(
tab
,
"
Particle
ceiling:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
get
Atom
StreamWidth
()
);
message
<<
_getLine
(
tab
,
"
Atom
stream width:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
get
Particle
StreamWidth
()
);
message
<<
_getLine
(
tab
,
"
Particle
stream width:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
get
Atom
StreamHeight
()
);
message
<<
_getLine
(
tab
,
"
Atom
stream height:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
get
Particle
StreamHeight
()
);
message
<<
_getLine
(
tab
,
"
Particle
stream height:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
get
Atom
StreamSize
()
);
message
<<
_getLine
(
tab
,
"
Atom
stream size:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
get
Particle
StreamSize
()
);
message
<<
_getLine
(
tab
,
"
Particle
stream size:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
getPartialForceStreamWidth
()
);
message
<<
_getLine
(
tab
,
"Partial force stream width:"
,
value
);
...
...
@@ -905,7 +907,7 @@ std::string BrookGbsa::getContentsString( int level ) const {
/*
* Calculate OBC energy
*
* @param
atom
Positions
atom
positions
* @param
particle
Positions
particle
positions
* @return energy
*
...
...
@@ -913,7 +915,7 @@ std::string BrookGbsa::getContentsString( int level ) const {
*
* */
double
BrookGbsa
::
getEnergy
(
const
Stream
&
atom
Positions
){
double
BrookGbsa
::
getEnergy
(
const
Stream
&
particle
Positions
){
// ---------------------------------------------------------------------------------------
...
...
@@ -937,7 +939,7 @@ double BrookGbsa::getEnergy( const Stream& atomPositions ){
return
ErrorReturnValue
;
}
const
BrookStreamImpl
&
positionStreamC
=
dynamic_cast
<
const
BrookStreamImpl
&>
(
atom
Positions
.
getImpl
());
const
BrookStreamImpl
&
positionStreamC
=
dynamic_cast
<
const
BrookStreamImpl
&>
(
particle
Positions
.
getImpl
());
BrookStreamImpl
&
positionStream
=
const_cast
<
BrookStreamImpl
&>
(
positionStreamC
);
BrookOpenMMFloat
*
positionsF
=
(
BrookOpenMMFloat
*
)
positionStream
.
getData
();
...
...
@@ -951,3 +953,277 @@ double BrookGbsa::getEnergy( const Stream& atomPositions ){
return
_cpuObc
->
getEnergy
();
}
/**
* Compute forces
*
*/
void
BrookGbsa
::
computeForces
(
BrookStreamImpl
&
positionStream
,
BrookStreamImpl
&
forceStream
){
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"BrookGbsa::executeForces"
;
static
const
int
PrintOn
=
0
;
float
mergeNonObcForces
=
1.0
f
;
float
kcalMolTokJNM
=
-
0.4184
f
;
// ---------------------------------------------------------------------------------------
float
includeAceTerm
=
(
float
)
(
includeAce
());
BrookFloatStreamInternal
**
gbsaForceStreams
=
getForceStreams
();
// calculate Born radii
(
void
)
fprintf
(
getLog
(),
"
\n
Post kCalculateBornRadii: obcParticleRadiiWithDielectricOffset & obcScaledParticleRadii not set correctly!!!!!
\n
"
);
kCalculateBornRadii
(
(
float
)
getNumberOfParticles
(),
(
float
)
getParticleSizeCeiling
(),
(
float
)
getDuplicationFactor
(),
(
float
)
getParticleStreamWidth
(
),
(
float
)
getPartialForceStreamWidth
(
),
positionStream
.
getBrookStream
(),
getObcParticleRadii
()
->
getBrookStream
(),
getObcScaledParticleRadii
()
->
getBrookStream
(),
// NOTE: obcParticleRadiiWithDielectricOffset & obcScaledParticleRadii may be wrong!! or br files need editing
// gpuObc->getBrookStreamWrapperAtIndex( GpuObc::obcParticleRadiiWithDielectricOffset )->getStream(),
// gpuObc->getBrookStreamWrapperAtIndex( GpuObc::obcScaledParticleRadii )->getStream(),
gbsaForceStreams
[
0
]
->
getBrookStream
()
);
kPostCalculateBornRadii_nobranch
(
(
float
)
getDuplicationFactor
(),
(
float
)
getParticleStreamWidth
(
),
(
float
)
getPartialForceStreamWidth
(
),
(
float
)
getNumberOfParticles
(),
(
float
)
getParticleSizeCeiling
(),
(
float
)
getInnerLoopUnroll
(),
kcalMolTokJNM
,
(
float
)
mergeNonObcForces
,
gbsaForceStreams
[
0
]
->
getBrookStream
(),
getObcParticleRadii
()
->
getBrookStream
(),
getObcBornRadii
()
->
getBrookStream
(),
getObcChain
()
->
getBrookStream
()
);
// ---------------------------------------------------------------------------------------
// seecond major loop
kObcLoop1
(
(
float
)
getNumberOfParticles
(),
(
float
)
getParticleSizeCeiling
(),
(
float
)
getDuplicationFactor
(),
(
float
)
getParticleStreamWidth
(
),
(
float
)
getPartialForceStreamWidth
(
),
getSoluteDielectric
(),
getSolventDielectric
(),
includeAceTerm
,
positionStream
.
getBrookStream
(),
getObcBornRadii
()
->
getBrookStream
(),
getObcParticleRadii
()
->
getBrookStream
(),
gbsaForceStreams
[
0
]
->
getBrookStream
(),
gbsaForceStreams
[
1
]
->
getBrookStream
(),
gbsaForceStreams
[
2
]
->
getBrookStream
(),
gbsaForceStreams
[
3
]
->
getBrookStream
()
);
// ---------------------------------------------------------------------------------------
// diagnostics
if
(
1
&&
PrintOn
&&
getLog
()
){
(
void
)
fprintf
(
getLog
(),
"
\n
Post kObcLoop1: atms=%d ceil=%d dup=%d particleStrW=%3d prtlF=%3d diel=%.3f %.3f ACE=%.1f
\n
"
,
getNumberOfParticles
(),
getParticleSizeCeiling
(),
getDuplicationFactor
(),
getParticleStreamWidth
(
),
getPartialForceStreamWidth
(
),
getSoluteDielectric
(),
getSolventDielectric
(),
includeAceTerm
);
BrookStreamInternal
*
brookStreamInternalPos
=
positionStream
.
getBrookStreamImpl
();
(
void
)
fprintf
(
getLog
(),
"
\n
PositionStream
\n
"
);
brookStreamInternalPos
->
printToFile
(
getLog
()
);
(
void
)
fprintf
(
getLog
(),
"
\n
BornR
\n
"
);
getObcBornRadii
()
->
printToFile
(
getLog
()
);
(
void
)
fprintf
(
getLog
(),
"
\n
ParticleR
\n
"
);
getObcParticleRadii
()
->
printToFile
(
getLog
()
);
(
void
)
fprintf
(
getLog
(),
"
\n
ForceStreams output
\n
"
);
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
){
gbsaForceStreams
[
ii
]
->
printToFile
(
getLog
()
);
}
}
// ---------------------------------------------------------------------------------------
// gather for first loop
kPostObcLoop1_nobranch
(
(
float
)
getDuplicationFactor
(),
(
float
)
getParticleStreamWidth
(
),
(
float
)
getPartialForceStreamWidth
(
),
(
float
)
getNumberOfParticles
(),
(
float
)
getParticleSizeCeiling
(),
(
float
)
getInnerLoopUnroll
(),
gbsaForceStreams
[
0
]
->
getBrookStream
(),
gbsaForceStreams
[
1
]
->
getBrookStream
(),
gbsaForceStreams
[
2
]
->
getBrookStream
(),
gbsaForceStreams
[
3
]
->
getBrookStream
(),
getObcChain
()
->
getBrookStream
(),
getObcBornRadii
()
->
getBrookStream
(),
getObcIntermediateForce
()
->
getBrookStream
(),
getObcBornRadii2
()
->
getBrookStream
()
);
// ---------------------------------------------------------------------------------------
// diagnostics
if
(
PrintOn
&&
getLog
()){
(
void
)
fprintf
(
getLog
(),
"
\n
Post kPostObcLoop1_nobranch: dup=%d aStrW=%d pStrW=%d no.atms=%3d ceil=%3d Unroll=%1d
\n
"
,
getDuplicationFactor
(),
getParticleStreamWidth
(
),
getPartialForceStreamWidth
(
),
getNumberOfParticles
(),
getParticleSizeCeiling
(),
getInnerLoopUnroll
()
);
(
void
)
fprintf
(
getLog
(),
"
\n
ForceStreams
\n
"
);
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
){
gbsaForceStreams
[
ii
]
->
printToFile
(
getLog
()
);
}
(
void
)
fprintf
(
getLog
(),
"
\n
ObcChain
\n
"
);
getObcChain
()
->
printToFile
(
getLog
()
);
(
void
)
fprintf
(
getLog
(),
"
\n
BornR
\n
"
);
getObcBornRadii
()
->
printToFile
(
getLog
()
);
// output
(
void
)
fprintf
(
getLog
(),
"
\n
ObcIntermediateForce output
\n
"
);
getObcIntermediateForce
()
->
printToFile
(
getLog
()
);
// output
(
void
)
fprintf
(
getLog
(),
"
\n
ObcBornRadii2 output
\n
"
);
getObcBornRadii2
()
->
printToFile
(
getLog
()
);
}
// ---------------------------------------------------------------------------------------
// second major loop
(
void
)
fprintf
(
getLog
(),
"
\n
kObcLoop2 messed up see /home/friedrim/src/openmmWork/trunk/OpenMM/platforms/brook/src/gpu/kObcBaseD2.br
\n
"
);
kObcLoop2
(
(
float
)
getNumberOfParticles
(),
(
float
)
getParticleSizeCeiling
(),
(
float
)
getDuplicationFactor
(),
(
float
)
getParticleStreamWidth
(
),
(
float
)
getPartialForceStreamWidth
(
),
positionStream
.
getBrookStream
(),
getObcScaledParticleRadii
()
->
getBrookStream
(),
getObcBornRadii2
()
->
getBrookStream
(),
getObcBornRadii2
()
->
getBrookStream
(),
gbsaForceStreams
[
0
]
->
getBrookStream
(),
gbsaForceStreams
[
1
]
->
getBrookStream
(),
gbsaForceStreams
[
2
]
->
getBrookStream
(),
gbsaForceStreams
[
3
]
->
getBrookStream
()
);
// ---------------------------------------------------------------------------------------
// diagnostics
if
(
PrintOn
&&
getLog
()
){
(
void
)
fprintf
(
getLog
(),
"
\n
Post kObcLoop2: no.atms=%5d ceil=%3d dup=%3d strW=%3d pStrW=%3d
\n
"
,
getNumberOfParticles
(),
getParticleSizeCeiling
(),
getDuplicationFactor
(),
getParticleStreamWidth
(
),
getPartialForceStreamWidth
(
)
);
BrookStreamInternal
*
brookStreamInternalPos
=
positionStream
.
getBrookStreamImpl
();
(
void
)
fprintf
(
getLog
(),
"
\n
PositionStream
\n
"
);
brookStreamInternalPos
->
printToFile
(
getLog
()
);
(
void
)
fprintf
(
getLog
(),
"
\n
ObcScaledParticleRadii
\n
"
);
getObcScaledParticleRadii
()
->
printToFile
(
getLog
()
);
(
void
)
fprintf
(
getLog
(),
"
\n
getObcBornRadii2
\n
"
);
getObcBornRadii2
()
->
printToFile
(
getLog
()
);
(
void
)
fprintf
(
getLog
(),
"
\n
ForceStreams
\n
"
);
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
){
gbsaForceStreams
[
ii
]
->
printToFile
(
getLog
()
);
}
}
// ---------------------------------------------------------------------------------------
// gather for second loop
kPostObcLoop2_nobranch
(
(
float
)
getDuplicationFactor
(),
(
float
)
getParticleStreamWidth
(
),
(
float
)
getPartialForceStreamWidth
(
),
(
float
)
getNumberOfParticles
(),
(
float
)
getParticleSizeCeiling
(),
(
float
)
getInnerLoopUnroll
(),
kcalMolTokJNM
,
mergeNonObcForces
,
getObcIntermediateForce
()
->
getBrookStream
(),
forceStream
.
getBrookStream
(),
gbsaForceStreams
[
0
]
->
getBrookStream
(),
gbsaForceStreams
[
1
]
->
getBrookStream
(),
gbsaForceStreams
[
2
]
->
getBrookStream
(),
gbsaForceStreams
[
3
]
->
getBrookStream
(),
getObcParticleRadii
()
->
getBrookStream
(),
getObcBornRadii
()
->
getBrookStream
(),
getObcChain
()
->
getBrookStream
(),
forceStream
.
getBrookStream
()
);
// ---------------------------------------------------------------------------------------
// diagnostics
if
(
PrintOn
&&
getLog
()
){
(
void
)
fprintf
(
getLog
(),
"
\n
Post kPostObcLoop2_nobranch: atms=%d ceil=%d dup=%d particleStrW=%3d prtlF=%3d diel=%.3f %.3f ACE=%.1f
\n
"
,
getNumberOfParticles
(),
getParticleSizeCeiling
(),
getDuplicationFactor
(),
getParticleStreamWidth
(
),
getPartialForceStreamWidth
(
),
getSoluteDielectric
(),
getSolventDielectric
(),
includeAceTerm
);
(
void
)
fprintf
(
getLog
(),
"
\n
PartialForceStreams
\n
"
);
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
){
gbsaForceStreams
[
ii
]
->
printToFile
(
getLog
()
);
}
BrookStreamInternal
*
brookStreamInternalF
=
forceStream
.
getBrookStreamImpl
();
(
void
)
fprintf
(
getLog
(),
"
\n
ForceStream
\n
"
);
brookStreamInternalF
->
printToFile
(
getLog
()
);
(
void
)
fprintf
(
getLog
(),
"
\n
Chain
\n
"
);
getObcChain
()
->
printToFile
(
getLog
()
);
(
void
)
fprintf
(
getLog
(),
"
\n
BornR
\n
"
);
getObcBornRadii
()
->
printToFile
(
getLog
()
);
}
// ---------------------------------------------------------------------------------------
}
platforms/brook/src/BrookGbsa.h
View file @
309008f7
...
...
@@ -35,7 +35,7 @@
#include <vector>
#include <set>
#include "Brook
Float
StreamI
nterna
l.h"
#include "BrookStreamI
mp
l.h"
#include "BrookPlatform.h"
#include "BrookCommon.h"
#include "../../../platforms/reference/src/gbsa/CpuObc.h"
...
...
@@ -85,13 +85,13 @@ class BrookGbsa : public BrookCommon {
int
getDuplicationFactor
(
void
)
const
;
/**
* Get
atom
ceiling parameter
* Get
particle
ceiling parameter
*
* @return
atom
ceiling parameter
* @return
particle
ceiling parameter
*
*/
int
get
Atom
SizeCeiling
(
void
)
const
;
int
get
Particle
SizeCeiling
(
void
)
const
;
/**
* Get outer loop unroll
...
...
@@ -154,28 +154,28 @@ class BrookGbsa : public BrookCommon {
int
getPartialForceStreamSize
(
void
)
const
;
/**
* Get Gbsa
atom
stream width
* Get Gbsa
particle
stream width
*
* @return
atom
stream width
* @return
particle
stream width
*/
int
getGbsa
Atom
StreamWidth
(
void
)
const
;
int
getGbsa
Particle
StreamWidth
(
void
)
const
;
/**
* Get Gbsa
atom
stream height
* Get Gbsa
particle
stream height
*
* @return
atom
stream height
* @return
particle
stream height
*/
int
getGbsa
Atom
StreamHeight
(
void
)
const
;
int
getGbsa
Particle
StreamHeight
(
void
)
const
;
/**
* Get Gbsa
atom
stream size
* Get Gbsa
particle
stream size
*
* @return
atom
stream size
* @return
particle
stream size
*/
int
getGbsa
Atom
StreamSize
(
void
)
const
;
int
getGbsa
Particle
StreamSize
(
void
)
const
;
/**
* Get solute dielectric
...
...
@@ -202,31 +202,31 @@ class BrookGbsa : public BrookCommon {
float
getDielectricOffset
(
void
)
const
;
/**
* Get
atomic
radii
* Get
particle
radii
*
* @return
atomic
radii stream
* @return
particle
radii stream
*
*/
BrookFloatStreamInternal
*
getObc
Atomic
Radii
(
void
)
const
;
BrookFloatStreamInternal
*
getObc
Particle
Radii
(
void
)
const
;
/**
* Get scaled
atomic
radii
* Get scaled
particle
radii
*
* @return scaled
atomic
radii stream
* @return scaled
particle
radii stream
*
*/
BrookFloatStreamInternal
*
getObcScaled
Atomic
Radii
(
void
)
const
;
BrookFloatStreamInternal
*
getObcScaled
Particle
Radii
(
void
)
const
;
/**
* Get
atomic
radii w/ dielectric offset
* Get
particle
radii w/ dielectric offset
*
* @return
atomic
radii w/ dielectric offset stream
* @return
particle
radii w/ dielectric offset stream
*
*/
BrookFloatStreamInternal
*
getObc
Atomic
RadiiWithDielectricOffset
(
void
)
const
;
BrookFloatStreamInternal
*
getObc
Particle
RadiiWithDielectricOffset
(
void
)
const
;
/**
* Get Born radii stream
...
...
@@ -312,9 +312,9 @@ class BrookGbsa : public BrookCommon {
/*
* Setup of Gbsa parameters
*
* @param
atom
Parameters vector of OBC parameters [
atom
I][0=charge]
* [
atom
I][1=radius]
* [
atom
I][2=scaling factor]
* @param
particle
Parameters vector of OBC parameters [
particle
I][0=charge]
* [
particle
I][1=radius]
* [
particle
I][2=scaling factor]
* @param solventDielectric solvent dielectric
* @param soluteDielectric solute dielectric
* @param platform Brook platform
...
...
@@ -323,7 +323,7 @@ class BrookGbsa : public BrookCommon {
*
* */
int
setup
(
const
std
::
vector
<
std
::
vector
<
double
>
>&
atom
Parameters
,
int
setup
(
const
std
::
vector
<
std
::
vector
<
double
>
>&
particle
Parameters
,
double
solventDielectric
,
double
soluteDielectric
,
const
Platform
&
platform
);
/*
...
...
@@ -340,7 +340,7 @@ class BrookGbsa : public BrookCommon {
/*
* Calculate energy
*
* @param
atom
Positions
atom
positions
* @param
particle
Positions
particle
positions
* @return energy
*
...
...
@@ -348,7 +348,14 @@ class BrookGbsa : public BrookCommon {
*
* */
double
getEnergy
(
const
Stream
&
atomPositions
);
double
getEnergy
(
const
Stream
&
particlePositions
);
/**
* Compute forces
*
*/
void
computeForces
(
BrookStreamImpl
&
positionStream
,
BrookStreamImpl
&
forceStream
);
private:
...
...
@@ -359,9 +366,9 @@ class BrookGbsa : public BrookCommon {
// streams indices
enum
{
Obc
Atomic
RadiiStream
,
ObcScaled
Atomic
RadiiStream
,
Obc
Atomic
RadiiWithDielectricOffsetStream
,
Obc
Particle
RadiiStream
,
ObcScaled
Particle
RadiiStream
,
Obc
Particle
RadiiWithDielectricOffsetStream
,
ObcBornRadiiStream
,
ObcBornRadii2Stream
,
ObcIntermediateForceStream
,
...
...
@@ -369,9 +376,9 @@ class BrookGbsa : public BrookCommon {
LastStreamIndex
};
//
atom
ceiling
//
particle
ceiling
int
_
atom
SizeCeiling
;
int
_
particle
SizeCeiling
;
// unroll in i/j dimensions
...
...
@@ -392,11 +399,11 @@ class BrookGbsa : public BrookCommon {
int
_partialForceStreamHeight
;
int
_partialForceStreamSize
;
//
Atom
stream dimensions
//
Particle
stream dimensions
int
_gbsa
Atom
StreamWidth
;
int
_gbsa
Atom
StreamHeight
;
int
_gbsa
Atom
StreamSize
;
int
_gbsa
Particle
StreamWidth
;
int
_gbsa
Particle
StreamHeight
;
int
_gbsa
Particle
StreamSize
;
// dielectrics
...
...
@@ -414,7 +421,7 @@ class BrookGbsa : public BrookCommon {
int
_bornRadiiInitialized
;
//
atom
charges
//
particle
charges
RealOpenMM
*
_charges
;
...
...
@@ -425,26 +432,26 @@ class BrookGbsa : public BrookCommon {
/*
* Setup of stream dimensions
*
* @param
atom
StreamSize
atom
stream size
* @param
atom
StreamWidth
atom
stream width
* @param
particle
StreamSize
particle
stream size
* @param
particle
StreamWidth
particle
stream width
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
* */
int
initializeStreamSizes
(
int
atom
StreamSize
,
int
atom
StreamWidth
);
int
initializeStreamSizes
(
int
particle
StreamSize
,
int
particle
StreamWidth
);
/**
* Initialize stream dimensions
*
* @param numberOf
Atoms
number of
atom
s
* @param numberOf
Particles
number of
particle
s
* @param platform platform
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
*/
int
initializeStreamSizes
(
int
numberOf
Atom
s
,
const
Platform
&
platform
);
int
initializeStreamSizes
(
int
numberOf
Particle
s
,
const
Platform
&
platform
);
/**
* Initialize stream dimensions and streams
...
...
@@ -460,14 +467,14 @@ class BrookGbsa : public BrookCommon {
/*
* Setup of stream dimensions for partial force streams
*
* @param
atom
StreamSize
atom
stream size
* @param
atom
StreamWidth
atom
stream width
* @param
particle
StreamSize
particle
stream size
* @param
particle
StreamWidth
particle
stream width
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
* */
int
initializePartialForceStreamSize
(
int
atom
StreamSize
,
int
atom
StreamWidth
);
int
initializePartialForceStreamSize
(
int
particle
StreamSize
,
int
particle
StreamWidth
);
};
...
...
platforms/brook/src/BrookIntStreamInternal.cpp
View file @
309008f7
...
...
@@ -338,4 +338,52 @@ const std::string BrookIntStreamInternal::getContentsString( int level ) const {
return
message
.
str
();
}
/**
* BrookFloatStreamInternal constructor
*
* @param stopIndex index to stop sum
* @param sum array of size=getWidth()
*
* @return DefaultReturnValue
*
* @throw exception if stopIndex is too large
*/
int
BrookIntStreamInternal
::
sumByDimension
(
int
stopIndex
,
double
*
sum
){
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"BrookIntStreamInternal::sumByDimension"
;
// ---------------------------------------------------------------------------------------
if
(
stopIndex
>
getSize
()
){
std
::
stringstream
message
;
message
<<
methodName
<<
" stream="
<<
getName
()
<<
" input topIndex"
<<
stopIndex
<<
" is too large: stream size="
<<
getSize
();
throw
OpenMMException
(
message
.
str
()
);
}
// get _data from GPU
_aStream
.
write
(
_data
);
int
width
=
getWidth
();
int
widthM1
=
getWidth
()
-
1
;
stopIndex
*=
width
;
for
(
int
ii
=
0
;
ii
<
width
;
ii
++
){
sum
[
ii
]
=
0.0
;
}
int
index
=
0
;
for
(
int
ii
=
0
;
ii
<
stopIndex
;
ii
++
){
sum
[
index
]
+=
(
double
)
_data
[
ii
];
if
(
index
==
widthM1
){
index
=
0
;
}
else
{
index
++
;
}
}
return
DefaultReturnValue
;
}
platforms/brook/src/BrookIntStreamInternal.h
View file @
309008f7
...
...
@@ -154,6 +154,19 @@ public:
const
std
::
string
getContentsString
(
int
level
=
0
)
const
;
/**
* BrookFloatStreamInternal constructor
*
* @param stopIndex index to stop sum
* @param sum array of size=getWidth()
*
* @return DefaultReturnValue
*
* @throw exception if stopIndex is too large
*/
int
sumByDimension
(
int
stopIndex
,
double
*
sum
);
private:
int
_dangleValue
;
...
...
platforms/brook/src/BrookIntegrateBrownianStepKernel.cpp
View file @
309008f7
...
...
@@ -80,9 +80,9 @@ BrookIntegrateBrownianStepKernel::~BrookIntegrateBrownianStepKernel( ){
/**
* Initialize the kernel, setting up all parameters related to integrator.
*
* @param masses the mass of each
atom
* @param constraintIndices each element contains the indices of two
atom
s whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained
atom
s
* @param masses the mass of each
particle
* @param constraintIndices each element contains the indices of two
particle
s whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained
particle
s
*
*/
...
...
@@ -112,9 +112,9 @@ void BrookIntegrateBrownianStepKernel::initialize( const vector<double>& masses,
/**
* Execute kernel
*
* @param positions
atom
coordinates
* @param velocities
atom
velocities
* @param forces
atom
forces
* @param positions
particle
coordinates
* @param velocities
particle
velocities
* @param forces
particle
forces
* @param temperature heat bath temperature
* @param friction friction coefficient coupling the system to the heat bath
* @param stepSize integration step size
...
...
platforms/brook/src/BrookIntegrateBrownianStepKernel.h
View file @
309008f7
...
...
@@ -72,9 +72,9 @@ class BrookIntegrateBrownianStepKernel : public IntegrateBrownianStepKernel {
/**
* Initialize the kernel, setting up all parameters related to integrator.
*
* @param masses
atom
masses
* @param constraintIndices each element contains the indices of two
atom
s whose distance should be constrained
* @param constraintLengths required distance between each pair of constrained
atom
s
* @param masses
particle
masses
* @param constraintIndices each element contains the indices of two
particle
s whose distance should be constrained
* @param constraintLengths required distance between each pair of constrained
particle
s
*/
void
initialize
(
const
std
::
vector
<
double
>&
masses
,
const
std
::
vector
<
std
::
vector
<
int
>
>&
constraintIndices
,
...
...
platforms/brook/src/BrookIntegrateLangevinStepKernel.cpp
View file @
309008f7
...
...
@@ -80,9 +80,9 @@ BrookIntegrateLangevinStepKernel::~BrookIntegrateLangevinStepKernel( ){
/**
* Initialize the kernel, setting up all parameters related to integrator.
*
* @param masses the mass of each
atom
* @param constraintIndices each element contains the indices of two
atom
s whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained
atom
s
* @param masses the mass of each
particle
* @param constraintIndices each element contains the indices of two
particle
s whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained
particle
s
*
*/
...
...
@@ -112,9 +112,9 @@ void BrookIntegrateLangevinStepKernel::initialize( const vector<double>& masses,
/**
* Execute kernel
*
* @param positions
atom
coordinates
* @param velocities
atom
velocities
* @param forces
atom
forces
* @param positions
particle
coordinates
* @param velocities
particle
velocities
* @param forces
particle
forces
* @param temperature heat bath temperature
* @param friction friction coefficient coupling the system to the heat bath
* @param stepSize integration step size
...
...
platforms/brook/src/BrookIntegrateLangevinStepKernel.h
View file @
309008f7
...
...
@@ -72,9 +72,9 @@ class BrookIntegrateLangevinStepKernel : public IntegrateLangevinStepKernel {
/**
* Initialize the kernel, setting up all parameters related to integrator.
*
* @param masses
atom
masses
* @param constraintIndices each element contains the indices of two
atom
s whose distance should be constrained
* @param constraintLengths required distance between each pair of constrained
atom
s
* @param masses
particle
masses
* @param constraintIndices each element contains the indices of two
particle
s whose distance should be constrained
* @param constraintLengths required distance between each pair of constrained
particle
s
*/
void
initialize
(
const
std
::
vector
<
double
>&
masses
,
const
std
::
vector
<
std
::
vector
<
int
>
>&
constraintIndices
,
...
...
platforms/brook/src/BrookIntegrateVerletStepKernel.cpp
View file @
309008f7
...
...
@@ -77,9 +77,9 @@ BrookIntegrateVerletStepKernel::~BrookIntegrateVerletStepKernel( ){
/**
* Initialize the kernel, setting up all parameters related to integrator.
*
* @param masses the mass of each
atom
* @param constraintIndices each element contains the indices of two
atom
s whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained
atom
s
* @param masses the mass of each
particle
* @param constraintIndices each element contains the indices of two
particle
s whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained
particle
s
*
*/
...
...
@@ -104,9 +104,9 @@ void BrookIntegrateVerletStepKernel::initialize( const vector<double>& masses,
/**
* Execute kernel
*
* @param positions
atom
coordinates
* @param velocities
atom
velocities
* @param forces
atom
forces
* @param positions
particle
coordinates
* @param velocities
particle
velocities
* @param forces
particle
forces
* @param stepSize integration step size
*
*/
...
...
platforms/brook/src/BrookIntegrateVerletStepKernel.h
View file @
309008f7
...
...
@@ -66,9 +66,9 @@ class BrookIntegrateVerletStepKernel : public IntegrateVerletStepKernel {
/**
* Initialize the kernel, setting up all parameters related to integrator.
*
* @param masses the mass of each
atom
* @param constraintIndices each element contains the indices of two
atom
s whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained
atom
s
* @param masses the mass of each
particle
* @param constraintIndices each element contains the indices of two
particle
s whose distance should be constrained
* @param constraintLengths the required distance between each pair of constrained
particle
s
*
*/
void
initialize
(
const
std
::
vector
<
double
>&
masses
,
const
std
::
vector
<
std
::
vector
<
int
>
>&
constraintIndices
,
...
...
@@ -76,9 +76,9 @@ class BrookIntegrateVerletStepKernel : public IntegrateVerletStepKernel {
/**
* Execute kernel
*
* @param positions
atom
coordinates
* @param velocities
atom
velocities
* @param forces
atom
forces
* @param positions
particle
coordinates
* @param velocities
particle
velocities
* @param forces
particle
forces
* @param stepSize integration step size
*
*/
...
...
platforms/brook/src/BrookKernelFactory.cpp
View file @
309008f7
...
...
@@ -30,13 +30,15 @@
* -------------------------------------------------------------------------- */
#include "BrookKernelFactory.h"
#include "BrookCalcHarmonicAngleForceKernel.h"
#include "BrookCalcNonbondedForceKernel.h"
#include "BrookIntegrateLangevinStepKernel.h"
#include "BrookIntegrateVerletStepKernel.h"
#include "BrookIntegrateBrownianStepKernel.h"
#include "BrookCalcKineticEnergyKernel.h"
#include "BrookCalcGBSAOBCForceKernel.h"
//
#include "BrookCalcGBSAOBCForceKernel.h"
#include "BrookRemoveCMMotionKernel.h"
#include "internal/OpenMMContextImpl.h"
using
namespace
OpenMM
;
...
...
@@ -48,52 +50,78 @@ KernelImpl* BrookKernelFactory::createKernelImpl( std::string name, const Platfo
// ---------------------------------------------------------------------------------------
// StandardMM
OpenMMBrookInterface
&
openMMBrookInterface
=
*
static_cast
<
OpenMMBrookInterface
*>
(
context
.
getPlatformData
());
if
(
name
==
CalcNonbondedForceKernel
::
Name
()
){
// harmonic bonds
return
new
BrookCalcNonbondedForceKernel
(
name
,
platform
);
if
(
name
==
CalcHarmonicBondForceKernel
::
Name
()
){
// return new BrookCalcHarmonicBondForceKernel( name, platform, openMMBrookInterface, context.getSystem() );
// angle bonds
}
else
if
(
name
==
CalcHarmonicAngleForceKernel
::
Name
()
){
return
new
BrookCalcHarmonicAngleForceKernel
(
name
,
platform
,
openMMBrookInterface
,
context
.
getSystem
()
);
// periodic torsion bonds
}
else
if
(
name
==
CalcPeriodicTorsionForceKernel
::
Name
()
){
// return new BrookCalcPeriodicTorsionForceKernel( name, platform, openMMBrookInterface, context.getSystem() );
// RB torsion bonds
}
else
if
(
name
==
CalcRBTorsionForceKernel
::
Name
()
){
// return new BrookCalcRBTorsionForceKernel( name, platform, openMMBrookInterface, context.getSystem() );
// nonbonded
}
else
if
(
name
==
CalcNonbondedForceKernel
::
Name
()
){
// return new BrookCalcNonbondedForceKernel( name, platform, openMMBrookInterface, context.getSystem() );
// GBSA OBC
}
else
if
(
name
==
CalcGBSAOBCForceKernel
::
Name
()
){
return
new
BrookCalcGBSAOBCForceKernel
(
name
,
platform
);
//
return new BrookCalcGBSAOBCForce
Field
Kernel(
name, platform
, openMMBrookInterface, context.getSystem()
);
// Verlet integrator
}
else
if
(
name
==
IntegrateVerletStepKernel
::
Name
()
){
return
new
BrookIntegrateVerletStepKernel
(
name
,
platform
);
//
return new BrookIntegrateVerletStepKernel( name, platform
, openMMBrookInterface
);
// Brownian integrator
}
else
if
(
name
==
IntegrateBrownianStepKernel
::
Name
()
){
return
new
BrookIntegrateBrownianStepKernel
(
name
,
platform
);
//
return new BrookIntegrateBrownianStepKernel( name, platform
, openMMBrookInterface
);
// Andersen thermostat
}
else
if
(
name
==
ApplyAndersenThermostatKernel
::
Name
()
){
// return new BrookIntegrateAndersenThermostatKernel( name, platform );
// return new BrookIntegrateAndersenThermostatKernel( name, platform
, openMMBrookInterface
);
// Langevin integrator
}
else
if
(
name
==
IntegrateLangevinStepKernel
::
Name
()
){
return
new
BrookIntegrateLangevinStepKernel
(
name
,
platform
);
//
return new BrookIntegrateLangevinStepKernel( name, platform
, openMMBrookInterface
);
// Remove com
}
else
if
(
name
==
RemoveCMMotionKernel
::
Name
()
){
return
new
BrookRemoveCMMotionKernel
(
name
,
platform
);
//
return new BrookRemoveCMMotionKernel( name, platform
, openMMBrookInterface
);
// KE calculator
}
else
if
(
name
==
CalcKineticEnergyKernel
::
Name
()
){
return
new
BrookCalcKineticEnergyKernel
(
name
,
platform
);
//
return new BrookCalcKineticEnergyKernel( name, platform
, openMMBrookInterface
);
}
(
void
)
fprintf
(
stderr
,
"createKernelImpl: name=<%s> not found."
,
methodName
.
c_str
(),
name
.
c_str
()
);
...
...
platforms/brook/src/BrookLangevinDynamics.cpp
View file @
309008f7
...
...
@@ -63,13 +63,13 @@ BrookLangevinDynamics::BrookLangevinDynamics( ){
// ---------------------------------------------------------------------------------------
_numberOf
Atom
s
=
-
1
;
_numberOf
Particle
s
=
-
1
;
// mark stream dimension variables as unset
_sd
Atom
StreamWidth
=
-
1
;
_sd
Atom
StreamHeight
=
-
1
;
_sd
Atom
StreamSize
=
-
1
;
_sd
Particle
StreamWidth
=
-
1
;
_sd
Particle
StreamHeight
=
-
1
;
_sd
Particle
StreamSize
=
-
1
;
for
(
int
ii
=
0
;
ii
<
LastStreamIndex
;
ii
++
){
_sdStreams
[
ii
]
=
NULL
;
...
...
@@ -352,9 +352,9 @@ int BrookLangevinDynamics::updateParameters( double temperature, double friction
/**
* Update
*
* @param positions
atom
positions
* @param velocities
atom
velocities
* @param forces
atom
forces
* @param positions
particle
positions
* @param velocities
particle
velocities
* @param forces
particle
forces
* @param brookShakeAlgorithm BrookShakeAlgorithm reference
* @param brookRandomNumberGenerator BrookRandomNumberGenerator reference
*
...
...
@@ -414,7 +414,7 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// first integration step
kupdate_sd1_fix1
(
(
float
)
getLangevinDynamics
Atom
StreamWidth
(),
(
float
)
getLangevinDynamics
Particle
StreamWidth
(),
(
float
)
brookRandomNumberGenerator
.
getRandomNumberStreamWidth
(),
(
float
)
brookRandomNumberGenerator
.
getRvStreamOffset
(),
derivedParameters
[
EM
],
...
...
@@ -436,9 +436,9 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// diagnostics
if
(
PrintOn
){
(
void
)
fprintf
(
getLog
(),
"
\n
Post kupdate_sd1_fix1:
atom
StrW=%3d rngStrW=%3d rngOff=%5d "
(
void
)
fprintf
(
getLog
(),
"
\n
Post kupdate_sd1_fix1:
particle
StrW=%3d rngStrW=%3d rngOff=%5d "
"EM=%12.5e Sd1pc[]=[%12.5e %12.5e %12.5e]"
,
getLangevinDynamics
Atom
StreamWidth
(),
getLangevinDynamics
Particle
StreamWidth
(),
brookRandomNumberGenerator
.
getRandomNumberStreamWidth
(),
brookRandomNumberGenerator
.
getRvStreamOffset
(),
derivedParameters
[
EM
],
derivedParameters
[
Sd1pc1
],
derivedParameters
[
Sd1pc2
],
derivedParameters
[
Sd1pc3
]
);
...
...
@@ -481,20 +481,20 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// advance random number cursor
brookRandomNumberGenerator
.
advanceGVCursor
(
2
*
getNumberOf
Atom
s
()
);
brookRandomNumberGenerator
.
advanceGVCursor
(
2
*
getNumberOf
Particle
s
()
);
// first Shake step
if
(
brookShakeAlgorithm
.
getNumberOfConstraints
()
>
0
){
kshakeh_fix1
(
10.0
f
,
(
float
)
getLangevinDynamics
Atom
StreamWidth
(),
(
float
)
getLangevinDynamics
Particle
StreamWidth
(),
brookShakeAlgorithm
.
getInverseHydrogenMass
(),
omega
,
brookShakeAlgorithm
.
getShake
Atom
IndicesStream
()
->
getBrookStream
(),
brookShakeAlgorithm
.
getShake
Particle
IndicesStream
()
->
getBrookStream
(),
positionStream
.
getBrookStream
(),
getXPrimeStream
()
->
getBrookStream
(),
brookShakeAlgorithm
.
getShake
Atom
ParameterStream
()
->
getBrookStream
(),
brookShakeAlgorithm
.
getShake
Particle
ParameterStream
()
->
getBrookStream
(),
brookShakeAlgorithm
.
getShakeXCons0Stream
()
->
getBrookStream
(),
brookShakeAlgorithm
.
getShakeXCons1Stream
()
->
getBrookStream
(),
brookShakeAlgorithm
.
getShakeXCons2Stream
()
->
getBrookStream
(),
...
...
@@ -503,7 +503,7 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// first Shake gather
kshakeh_update1_fix1
(
(
float
)
getLangevinDynamics
Atom
StreamWidth
(),
(
float
)
getLangevinDynamics
Particle
StreamWidth
(),
derivedParameters
[
Sd2pc1
],
brookShakeAlgorithm
.
getShakeInverseMapStream
()
->
getBrookStream
(),
positionStream
.
getBrookStream
(),
...
...
@@ -519,7 +519,7 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// second integration step
kupdate_sd2_fix1
(
(
float
)
getLangevinDynamics
Atom
StreamWidth
(),
(
float
)
getLangevinDynamics
Particle
StreamWidth
(),
(
float
)
brookRandomNumberGenerator
.
getRandomNumberStreamWidth
(),
(
float
)
brookRandomNumberGenerator
.
getRvStreamOffset
(),
derivedParameters
[
Sd2pc1
],
...
...
@@ -538,9 +538,9 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// diagnostics
if
(
PrintOn
){
(
void
)
fprintf
(
getLog
(),
"
\n
Post kupdate_sd2_fix1:
atom
StrW=%3d rngStrW=%3d rngOff=%5d "
(
void
)
fprintf
(
getLog
(),
"
\n
Post kupdate_sd2_fix1:
particle
StrW=%3d rngStrW=%3d rngOff=%5d "
"Sd2pc[]=[%12.5e %12.5e]"
,
getLangevinDynamics
Atom
StreamWidth
(),
getLangevinDynamics
Particle
StreamWidth
(),
brookRandomNumberGenerator
.
getRandomNumberStreamWidth
(),
brookRandomNumberGenerator
.
getRvStreamOffset
(),
derivedParameters
[
Sd2pc1
],
derivedParameters
[
Sd2pc2
]
);
...
...
@@ -574,20 +574,20 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// advance random number cursor
brookRandomNumberGenerator
.
advanceGVCursor
(
2
*
getNumberOf
Atom
s
()
);
brookRandomNumberGenerator
.
advanceGVCursor
(
2
*
getNumberOf
Particle
s
()
);
// second Shake step
if
(
brookShakeAlgorithm
.
getNumberOfConstraints
()
>
0
){
kshakeh_fix1
(
10.0
f
,
(
float
)
getLangevinDynamics
Atom
StreamWidth
(),
(
float
)
getLangevinDynamics
Particle
StreamWidth
(),
brookShakeAlgorithm
.
getInverseHydrogenMass
(),
omega
,
brookShakeAlgorithm
.
getShake
Atom
IndicesStream
()
->
getBrookStream
(),
brookShakeAlgorithm
.
getShake
Particle
IndicesStream
()
->
getBrookStream
(),
positionStream
.
getBrookStream
(),
getXPrimeStream
()
->
getBrookStream
(),
brookShakeAlgorithm
.
getShake
Atom
ParameterStream
()
->
getBrookStream
(),
brookShakeAlgorithm
.
getShake
Particle
ParameterStream
()
->
getBrookStream
(),
brookShakeAlgorithm
.
getShakeXCons0Stream
()
->
getBrookStream
(),
brookShakeAlgorithm
.
getShakeXCons1Stream
()
->
getBrookStream
(),
brookShakeAlgorithm
.
getShakeXCons2Stream
()
->
getBrookStream
(),
...
...
@@ -596,7 +596,7 @@ int BrookLangevinDynamics::update( Stream& positions, Stream& velocities,
// second Shake gather
kshakeh_update2_fix1
(
(
float
)
getLangevinDynamics
Atom
StreamWidth
(),
(
float
)
getLangevinDynamics
Particle
StreamWidth
(),
brookShakeAlgorithm
.
getShakeInverseMapStream
()
->
getBrookStream
(),
positionStream
.
getBrookStream
(),
getXPrimeStream
()
->
getBrookStream
(),
...
...
@@ -635,35 +635,35 @@ const BrookOpenMMFloat* BrookLangevinDynamics::getDerivedParameters( void ) cons
}
/**
* Get
Atom
stream size
* Get
Particle
stream size
*
* @return
Atom
stream size
* @return
Particle
stream size
*
*/
int
BrookLangevinDynamics
::
getLangevinDynamics
Atom
StreamSize
(
void
)
const
{
return
_sd
Atom
StreamSize
;
int
BrookLangevinDynamics
::
getLangevinDynamics
Particle
StreamSize
(
void
)
const
{
return
_sd
Particle
StreamSize
;
}
/**
* Get
atom
stream width
* Get
particle
stream width
*
* @return
atom
stream width
* @return
particle
stream width
*
*/
int
BrookLangevinDynamics
::
getLangevinDynamics
Atom
StreamWidth
(
void
)
const
{
return
_sd
Atom
StreamWidth
;
int
BrookLangevinDynamics
::
getLangevinDynamics
Particle
StreamWidth
(
void
)
const
{
return
_sd
Particle
StreamWidth
;
}
/**
* Get
atom
stream height
* Get
particle
stream height
*
* @return
atom
stream height
* @return
particle
stream height
*/
int
BrookLangevinDynamics
::
getLangevinDynamics
Atom
StreamHeight
(
void
)
const
{
return
_sd
Atom
StreamHeight
;
int
BrookLangevinDynamics
::
getLangevinDynamics
Particle
StreamHeight
(
void
)
const
{
return
_sd
Particle
StreamHeight
;
}
/**
...
...
@@ -746,14 +746,14 @@ BrookFloatStreamInternal* BrookLangevinDynamics::getInverseMassStream( void ) co
/**
* Initialize stream dimensions
*
* @param numberOf
Atoms
number of
atom
s
* @param numberOf
Particles
number of
particle
s
* @param platform platform
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
*/
int
BrookLangevinDynamics
::
_initializeStreamSizes
(
int
numberOf
Atom
s
,
const
Platform
&
platform
){
int
BrookLangevinDynamics
::
_initializeStreamSizes
(
int
numberOf
Particle
s
,
const
Platform
&
platform
){
// ---------------------------------------------------------------------------------------
...
...
@@ -761,9 +761,9 @@ int BrookLangevinDynamics::_initializeStreamSizes( int numberOfAtoms, const Plat
// ---------------------------------------------------------------------------------------
_sd
Atom
StreamSize
=
get
Atom
StreamSize
(
platform
);
_sd
Atom
StreamWidth
=
get
Atom
StreamWidth
(
platform
);
_sd
Atom
StreamHeight
=
get
Atom
StreamHeight
(
platform
);
_sd
Particle
StreamSize
=
get
Particle
StreamSize
(
platform
);
_sd
Particle
StreamWidth
=
get
Particle
StreamWidth
(
platform
);
_sd
Particle
StreamHeight
=
get
Particle
StreamHeight
(
platform
);
return
DefaultReturnValue
;
}
...
...
@@ -771,7 +771,7 @@ int BrookLangevinDynamics::_initializeStreamSizes( int numberOfAtoms, const Plat
/**
* Initialize stream dimensions
*
* @param numberOf
Atoms
number of
atom
s
* @param numberOf
Particles
number of
particle
s
* @param platform platform
*
* @return ErrorReturnValue if error, else DefaultReturnValue
...
...
@@ -886,35 +886,35 @@ int BrookLangevinDynamics::_initializeStreams( const Platform& platform ){
// ---------------------------------------------------------------------------------------
int
sd
Atom
StreamSize
=
getLangevinDynamics
Atom
StreamSize
();
int
sd
Atom
StreamWidth
=
getLangevinDynamics
Atom
StreamWidth
();
int
sd
Particle
StreamSize
=
getLangevinDynamics
Particle
StreamSize
();
int
sd
Particle
StreamWidth
=
getLangevinDynamics
Particle
StreamWidth
();
_sdStreams
[
SDPC1Stream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
SDPC1Stream
,
sd
Atom
StreamSize
,
sd
Atom
StreamWidth
,
sd
Particle
StreamSize
,
sd
Particle
StreamWidth
,
BrookStreamInternal
::
Float2
,
dangleValue
);
_sdStreams
[
SDPC2Stream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
SDPC2Stream
,
sd
Atom
StreamSize
,
sd
Atom
StreamWidth
,
sd
Particle
StreamSize
,
sd
Particle
StreamWidth
,
BrookStreamInternal
::
Float2
,
dangleValue
);
_sdStreams
[
SD2XStream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
SD2XStream
,
sd
Atom
StreamSize
,
sd
Atom
StreamWidth
,
sd
Particle
StreamSize
,
sd
Particle
StreamWidth
,
BrookStreamInternal
::
Float3
,
dangleValue
);
_sdStreams
[
SD1VStream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
SD1VStream
,
sd
Atom
StreamSize
,
sd
Atom
StreamWidth
,
sd
Particle
StreamSize
,
sd
Particle
StreamWidth
,
BrookStreamInternal
::
Float3
,
dangleValue
);
_sdStreams
[
VPrimeStream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
VPrimeStream
,
sd
Atom
StreamSize
,
sd
Atom
StreamWidth
,
sd
Particle
StreamSize
,
sd
Particle
StreamWidth
,
BrookStreamInternal
::
Float3
,
dangleValue
);
_sdStreams
[
XPrimeStream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
XPrimeStream
,
sd
Atom
StreamSize
,
sd
Atom
StreamWidth
,
sd
Particle
StreamSize
,
sd
Particle
StreamWidth
,
BrookStreamInternal
::
Float3
,
dangleValue
);
_sdStreams
[
InverseMassStream
]
=
new
BrookFloatStreamInternal
(
BrookCommon
::
InverseMassStream
,
sd
Atom
StreamSize
,
sd
Atom
StreamWidth
,
sd
Particle
StreamSize
,
sd
Particle
StreamWidth
,
BrookStreamInternal
::
Float
,
dangleValue
);
return
DefaultReturnValue
;
...
...
@@ -935,20 +935,20 @@ int BrookLangevinDynamics::_updateSdStreams( void ){
// ---------------------------------------------------------------------------------------
int
sd
Atom
StreamSize
=
getLangevinDynamics
Atom
StreamSize
();
int
sd
Particle
StreamSize
=
getLangevinDynamics
Particle
StreamSize
();
BrookOpenMMFloat
*
sdpc
[
2
];
for
(
int
ii
=
0
;
ii
<
2
;
ii
++
){
sdpc
[
ii
]
=
new
BrookOpenMMFloat
[
2
*
sd
Atom
StreamSize
];
memset
(
sdpc
[
ii
],
0
,
2
*
sd
Atom
StreamSize
*
sizeof
(
BrookOpenMMFloat
)
);
sdpc
[
ii
]
=
new
BrookOpenMMFloat
[
2
*
sd
Particle
StreamSize
];
memset
(
sdpc
[
ii
],
0
,
2
*
sd
Particle
StreamSize
*
sizeof
(
BrookOpenMMFloat
)
);
}
BrookOpenMMFloat
*
inverseMass
=
new
BrookOpenMMFloat
[
sd
Atom
StreamSize
];
memset
(
inverseMass
,
0
,
sd
Atom
StreamSize
*
sizeof
(
BrookOpenMMFloat
)
);
BrookOpenMMFloat
*
inverseMass
=
new
BrookOpenMMFloat
[
sd
Particle
StreamSize
];
memset
(
inverseMass
,
0
,
sd
Particle
StreamSize
*
sizeof
(
BrookOpenMMFloat
)
);
const
BrookOpenMMFloat
*
derivedParameters
=
getDerivedParameters
(
);
int
numberOf
Atom
s
=
getNumberOf
Atom
s
();
int
numberOf
Particle
s
=
getNumberOf
Particle
s
();
int
index
=
0
;
for
(
int
ii
=
0
;
ii
<
numberOf
Atom
s
;
ii
++
,
index
+=
2
){
for
(
int
ii
=
0
;
ii
<
numberOf
Particle
s
;
ii
++
,
index
+=
2
){
sdpc
[
0
][
index
]
=
_inverseSqrtMasses
[
ii
]
*
(
static_cast
<
BrookOpenMMFloat
>
(
derivedParameters
[
Yv
])
);
sdpc
[
0
][
index
+
1
]
=
_inverseSqrtMasses
[
ii
]
*
(
static_cast
<
BrookOpenMMFloat
>
(
derivedParameters
[
V
])
);
...
...
@@ -971,13 +971,13 @@ int BrookLangevinDynamics::_updateSdStreams( void ){
// initialize SD2X
BrookOpenMMFloat
*
sd2x
=
new
BrookOpenMMFloat
[
3
*
sd
Atom
StreamSize
];
BrookOpenMMFloat
*
sd2x
=
new
BrookOpenMMFloat
[
3
*
sd
Particle
StreamSize
];
//SimTKOpenMMUtilities::setRandomNumberSeed( (uint32_t) getRandomNumberSeed() );
memset
(
sd2x
,
0
,
3
*
sd
Atom
StreamSize
*
sizeof
(
BrookOpenMMFloat
)
);
memset
(
sd2x
,
0
,
3
*
sd
Particle
StreamSize
*
sizeof
(
BrookOpenMMFloat
)
);
index
=
0
;
for
(
int
ii
=
0
;
ii
<
numberOf
Atom
s
;
ii
++
,
index
+=
3
){
for
(
int
ii
=
0
;
ii
<
numberOf
Particle
s
;
ii
++
,
index
+=
3
){
sd2x
[
index
]
=
_inverseSqrtMasses
[
ii
]
*
derivedParameters
[
X
]
*
(
static_cast
<
BrookOpenMMFloat
>
(
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
())
);
sd2x
[
index
+
1
]
=
_inverseSqrtMasses
[
ii
]
*
derivedParameters
[
X
]
*
(
static_cast
<
BrookOpenMMFloat
>
(
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
())
);
sd2x
[
index
+
2
]
=
_inverseSqrtMasses
[
ii
]
*
derivedParameters
[
X
]
*
(
static_cast
<
BrookOpenMMFloat
>
(
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
())
);
...
...
@@ -994,7 +994,7 @@ int BrookLangevinDynamics::_updateSdStreams( void ){
/**
* Set masses
*
* @param masses
atomic
masses
* @param masses
particle
masses
*
*/
...
...
@@ -1046,12 +1046,12 @@ int BrookLangevinDynamics::setup( const std::vector<double>& masses, const Platf
const
BrookPlatform
brookPlatform
=
dynamic_cast
<
const
BrookPlatform
&>
(
platform
);
setLog
(
brookPlatform
.
getLog
()
);
int
numberOf
Atom
s
=
(
int
)
masses
.
size
();
setNumberOf
Atom
s
(
numberOf
Atom
s
);
int
numberOf
Particle
s
=
(
int
)
masses
.
size
();
setNumberOf
Particle
s
(
numberOf
Particle
s
);
// set stream sizes and then create streams
_initializeStreamSizes
(
numberOf
Atom
s
,
platform
);
_initializeStreamSizes
(
numberOf
Particle
s
,
platform
);
_initializeStreams
(
platform
);
_setInverseSqrtMasses
(
masses
);
...
...
@@ -1090,17 +1090,17 @@ std::string BrookLangevinDynamics::getContentsString( int level ) const {
#define LOCAL_SPRINTF(a,b,c) sprintf( (a), (b), (c) );
#endif
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
getNumberOf
Atom
s
()
);
message
<<
_getLine
(
tab
,
"Number of
atom
s:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
getNumberOf
Particle
s
()
);
message
<<
_getLine
(
tab
,
"Number of
particle
s:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
get
Atom
StreamWidth
()
);
message
<<
_getLine
(
tab
,
"
Atom
stream width:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
get
Particle
StreamWidth
()
);
message
<<
_getLine
(
tab
,
"
Particle
stream width:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
get
Atom
StreamHeight
()
);
message
<<
_getLine
(
tab
,
"
Atom
stream height:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
get
Particle
StreamHeight
()
);
message
<<
_getLine
(
tab
,
"
Particle
stream height:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
get
Atom
StreamSize
()
);
message
<<
_getLine
(
tab
,
"
Atom
stream size:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%d"
,
get
Particle
StreamSize
()
);
message
<<
_getLine
(
tab
,
"
Particle
stream size:"
,
value
);
(
void
)
LOCAL_SPRINTF
(
value
,
"%.5f"
,
getTau
()
);
message
<<
_getLine
(
tab
,
"Tau:"
,
value
);
...
...
platforms/brook/src/BrookLangevinDynamics.h
View file @
309008f7
...
...
@@ -110,28 +110,28 @@ class BrookLangevinDynamics : public BrookCommon {
const
BrookOpenMMFloat
*
getDerivedParameters
(
void
)
const
;
/**
* Get LangevinDynamics
atom
stream width
* Get LangevinDynamics
particle
stream width
*
* @return
atom
stream width
* @return
particle
stream width
*/
int
getLangevinDynamics
Atom
StreamWidth
(
void
)
const
;
int
getLangevinDynamics
Particle
StreamWidth
(
void
)
const
;
/**
* Get LangevinDynamics
atom
stream height
* Get LangevinDynamics
particle
stream height
*
* @return
atom
stream height
* @return
particle
stream height
*/
int
getLangevinDynamics
Atom
StreamHeight
(
void
)
const
;
int
getLangevinDynamics
Particle
StreamHeight
(
void
)
const
;
/**
* Get LangevinDynamics
atom
stream size
* Get LangevinDynamics
particle
stream size
*
* @return
atom
stream size
* @return
particle
stream size
*/
int
getLangevinDynamics
Atom
StreamSize
(
void
)
const
;
int
getLangevinDynamics
Particle
StreamSize
(
void
)
const
;
/**
* Update parameters
...
...
@@ -149,9 +149,9 @@ class BrookLangevinDynamics : public BrookCommon {
/**
* Update
*
* @param positions
atom
positions
* @param velocities
atom
velocities
* @param forces
atom
forces
* @param positions
particle
positions
* @param velocities
particle
velocities
* @param forces
particle
forces
* @param brookShakeAlgorithm BrookShakeAlgorithm reference
* @param brookRandomNumberGenerator BrookRandomNumberGenerator reference
*
...
...
@@ -174,7 +174,7 @@ class BrookLangevinDynamics : public BrookCommon {
/*
* Setup of LangevinDynamics parameters
*
* @param masses
atom
masses
* @param masses
particle
masses
* @param platform Brook platform
*
* @return ErrorReturnValue value if error, else DefaultReturnValue
...
...
@@ -285,11 +285,11 @@ class BrookLangevinDynamics : public BrookCommon {
BrookOpenMMFloat
_temperature
;
BrookOpenMMFloat
_stepSize
;
//
Atom
stream dimensions
//
Particle
stream dimensions
int
_sd
Atom
StreamWidth
;
int
_sd
Atom
StreamHeight
;
int
_sd
Atom
StreamSize
;
int
_sd
Particle
StreamWidth
;
int
_sd
Particle
StreamHeight
;
int
_sd
Particle
StreamSize
;
/**
* Get derived parameter string
...
...
@@ -374,26 +374,26 @@ class BrookLangevinDynamics : public BrookCommon {
/*
* Setup of stream dimensions
*
* @param
atom
StreamSize
atom
stream size
* @param
atom
StreamWidth
atom
stream width
* @param
particle
StreamSize
particle
stream size
* @param
particle
StreamWidth
particle
stream width
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
* */
int
_initializeStreamSizes
(
int
atom
StreamSize
,
int
atom
StreamWidth
);
int
_initializeStreamSizes
(
int
particle
StreamSize
,
int
particle
StreamWidth
);
/**
* Initialize stream dimensions
*
* @param numberOf
Atom
s number of
atom
s
* @param numberOf
Particle
s number of
particle
s
* @param platform platform
*
* @return ErrorReturnValue if error, else DefaultReturnValue
*
*/
int
_initializeStreamSizes
(
int
numberOf
Atom
s
,
const
Platform
&
platform
);
int
_initializeStreamSizes
(
int
numberOf
Particle
s
,
const
Platform
&
platform
);
/**
* Initialize stream dimensions and streams
...
...
@@ -409,7 +409,7 @@ class BrookLangevinDynamics : public BrookCommon {
/**
* Set masses
*
* @param masses
atomic
masses
* @param masses
particle
masses
*
*/
...
...
Prev
1
2
3
4
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment