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
162d69a2
Commit
162d69a2
authored
Feb 20, 2015
by
peastman
Browse files
Merge pull request #827 from peastman/reference
Lots of cleanup to reference platform
parents
2379b982
c44c956d
Changes
150
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
351 additions
and
492 deletions
+351
-492
platforms/reference/src/SimTKReference/ReferenceAngleBondIxn.cpp
...ms/reference/src/SimTKReference/ReferenceAngleBondIxn.cpp
+23
-25
platforms/reference/src/SimTKReference/ReferenceBondForce.cpp
...forms/reference/src/SimTKReference/ReferenceBondForce.cpp
+8
-10
platforms/reference/src/SimTKReference/ReferenceBondIxn.cpp
platforms/reference/src/SimTKReference/ReferenceBondIxn.cpp
+50
-52
platforms/reference/src/SimTKReference/ReferenceBrownianDynamics.cpp
...eference/src/SimTKReference/ReferenceBrownianDynamics.cpp
+14
-29
platforms/reference/src/SimTKReference/ReferenceCCMAAlgorithm.cpp
...s/reference/src/SimTKReference/ReferenceCCMAAlgorithm.cpp
+1
-5
platforms/reference/src/SimTKReference/ReferenceCMAPTorsionIxn.cpp
.../reference/src/SimTKReference/ReferenceCMAPTorsionIxn.cpp
+1
-1
platforms/reference/src/SimTKReference/ReferenceCustomAngleIxn.cpp
.../reference/src/SimTKReference/ReferenceCustomAngleIxn.cpp
+6
-8
platforms/reference/src/SimTKReference/ReferenceCustomBondIxn.cpp
...s/reference/src/SimTKReference/ReferenceCustomBondIxn.cpp
+7
-9
platforms/reference/src/SimTKReference/ReferenceCustomCompoundBondIxn.cpp
...nce/src/SimTKReference/ReferenceCustomCompoundBondIxn.cpp
+3
-5
platforms/reference/src/SimTKReference/ReferenceCustomDynamics.cpp
.../reference/src/SimTKReference/ReferenceCustomDynamics.cpp
+1
-3
platforms/reference/src/SimTKReference/ReferenceCustomExternalIxn.cpp
...ference/src/SimTKReference/ReferenceCustomExternalIxn.cpp
+3
-5
platforms/reference/src/SimTKReference/ReferenceCustomGBIxn.cpp
...rms/reference/src/SimTKReference/ReferenceCustomGBIxn.cpp
+9
-11
platforms/reference/src/SimTKReference/ReferenceCustomHbondIxn.cpp
.../reference/src/SimTKReference/ReferenceCustomHbondIxn.cpp
+4
-6
platforms/reference/src/SimTKReference/ReferenceCustomManyParticleIxn.cpp
...nce/src/SimTKReference/ReferenceCustomManyParticleIxn.cpp
+1
-3
platforms/reference/src/SimTKReference/ReferenceCustomNonbondedIxn.cpp
...erence/src/SimTKReference/ReferenceCustomNonbondedIxn.cpp
+14
-16
platforms/reference/src/SimTKReference/ReferenceCustomTorsionIxn.cpp
...eference/src/SimTKReference/ReferenceCustomTorsionIxn.cpp
+9
-11
platforms/reference/src/SimTKReference/ReferenceDynamics.cpp
platforms/reference/src/SimTKReference/ReferenceDynamics.cpp
+13
-15
platforms/reference/src/SimTKReference/ReferenceForce.cpp
platforms/reference/src/SimTKReference/ReferenceForce.cpp
+13
-15
platforms/reference/src/SimTKReference/ReferenceGBVI.cpp
platforms/reference/src/SimTKReference/ReferenceGBVI.cpp
+165
-255
platforms/reference/src/SimTKReference/ReferenceHarmonicBondIxn.cpp
...reference/src/SimTKReference/ReferenceHarmonicBondIxn.cpp
+6
-8
No files found.
platforms/reference/src/SimTKReference/ReferenceAngleBondIxn.cpp
View file @
162d69a2
...
@@ -25,14 +25,12 @@
...
@@ -25,14 +25,12 @@
#include <string.h>
#include <string.h>
#include <sstream>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceAngleBondIxn.h"
#include "ReferenceAngleBondIxn.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
using
std
::
vector
;
using
std
::
vector
;
using
OpenMM
::
RealVec
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -40,7 +38,7 @@ using OpenMM::RealVec;
...
@@ -40,7 +38,7 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceAngleBondIxn
::
ReferenceAngleBondIxn
(
){
ReferenceAngleBondIxn
::
ReferenceAngleBondIxn
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -56,7 +54,7 @@ ReferenceAngleBondIxn::ReferenceAngleBondIxn( ){
...
@@ -56,7 +54,7 @@ ReferenceAngleBondIxn::ReferenceAngleBondIxn( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceAngleBondIxn
::~
ReferenceAngleBondIxn
(
){
ReferenceAngleBondIxn
::~
ReferenceAngleBondIxn
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -78,8 +76,8 @@ ReferenceAngleBondIxn::~ReferenceAngleBondIxn( ){
...
@@ -78,8 +76,8 @@ ReferenceAngleBondIxn::~ReferenceAngleBondIxn( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceAngleBondIxn
::
getPrefactorsGivenAngleCosine
(
RealOpenMM
cosine
,
RealOpenMM
*
angleParameters
,
void
ReferenceAngleBondIxn
::
getPrefactorsGivenAngleCosine
(
RealOpenMM
cosine
,
RealOpenMM
*
angleParameters
,
RealOpenMM
*
dEdR
,
RealOpenMM
*
energyTerm
)
const
{
RealOpenMM
*
dEdR
,
RealOpenMM
*
energyTerm
)
const
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -92,9 +90,9 @@ void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine( RealOpenMM cosine, Re
...
@@ -92,9 +90,9 @@ void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine( RealOpenMM cosine, Re
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
RealOpenMM
angle
;
RealOpenMM
angle
;
if
(
cosine
>=
one
){
if
(
cosine
>=
one
)
{
angle
=
zero
;
angle
=
zero
;
}
else
if
(
cosine
<=
-
one
){
}
else
if
(
cosine
<=
-
one
)
{
angle
=
PI_M
;
angle
=
PI_M
;
}
else
{
}
else
{
angle
=
ACOS
(
cosine
);
angle
=
ACOS
(
cosine
);
...
@@ -120,11 +118,11 @@ void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine( RealOpenMM cosine, Re
...
@@ -120,11 +118,11 @@ void ReferenceAngleBondIxn::getPrefactorsGivenAngleCosine( RealOpenMM cosine, Re
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceAngleBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceAngleBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
*
parameters
,
vector
<
RealVec
>&
forces
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
{
RealOpenMM
*
totalEnergy
)
const
{
// constants -- reduce Visual Studio warnings regarding conversions between float & double
// constants -- reduce Visual Studio warnings regarding conversions between float & double
...
@@ -147,31 +145,31 @@ void ReferenceAngleBondIxn::calculateBondIxn( int* atomIndices,
...
@@ -147,31 +145,31 @@ void ReferenceAngleBondIxn::calculateBondIxn( int* atomIndices,
int
atomAIndex
=
atomIndices
[
0
];
int
atomAIndex
=
atomIndices
[
0
];
int
atomBIndex
=
atomIndices
[
1
];
int
atomBIndex
=
atomIndices
[
1
];
int
atomCIndex
=
atomIndices
[
2
];
int
atomCIndex
=
atomIndices
[
2
];
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
[
0
]
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
[
0
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomCIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
[
1
]
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomCIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
[
1
]);
RealOpenMM
pVector
[
threeI
];
RealOpenMM
pVector
[
threeI
];
SimTKOpenMMUtilities
::
crossProductVector3
(
deltaR
[
0
],
deltaR
[
1
],
pVector
);
SimTKOpenMMUtilities
::
crossProductVector3
(
deltaR
[
0
],
deltaR
[
1
],
pVector
);
RealOpenMM
rp
=
DOT3
(
pVector
,
pVector
);
RealOpenMM
rp
=
DOT3
(
pVector
,
pVector
);
rp
=
SQRT
(
rp
);
rp
=
SQRT
(
rp
);
if
(
rp
<
1.0e-06
){
if
(
rp
<
1.0e-06
)
{
rp
=
(
RealOpenMM
)
1.0e-06
;
rp
=
(
RealOpenMM
)
1.0e-06
;
}
}
RealOpenMM
dot
=
DOT3
(
deltaR
[
0
],
deltaR
[
1
]
);
RealOpenMM
dot
=
DOT3
(
deltaR
[
0
],
deltaR
[
1
]);
RealOpenMM
cosine
=
dot
/
SQRT
(
(
deltaR
[
0
][
ReferenceForce
::
R2Index
]
*
deltaR
[
1
][
ReferenceForce
::
R2Index
])
);
RealOpenMM
cosine
=
dot
/
SQRT
((
deltaR
[
0
][
ReferenceForce
::
R2Index
]
*
deltaR
[
1
][
ReferenceForce
::
R2Index
]));
RealOpenMM
dEdR
;
RealOpenMM
dEdR
;
RealOpenMM
energy
;
RealOpenMM
energy
;
getPrefactorsGivenAngleCosine
(
cosine
,
parameters
,
&
dEdR
,
&
energy
);
getPrefactorsGivenAngleCosine
(
cosine
,
parameters
,
&
dEdR
,
&
energy
);
RealOpenMM
termA
=
dEdR
/
(
deltaR
[
0
][
ReferenceForce
::
R2Index
]
*
rp
);
RealOpenMM
termA
=
dEdR
/
(
deltaR
[
0
][
ReferenceForce
::
R2Index
]
*
rp
);
RealOpenMM
termC
=
-
dEdR
/
(
deltaR
[
1
][
ReferenceForce
::
R2Index
]
*
rp
);
RealOpenMM
termC
=
-
dEdR
/
(
deltaR
[
1
][
ReferenceForce
::
R2Index
]
*
rp
);
RealOpenMM
deltaCrossP
[
LastAtomIndex
][
threeI
];
RealOpenMM
deltaCrossP
[
LastAtomIndex
][
threeI
];
SimTKOpenMMUtilities
::
crossProductVector3
(
deltaR
[
0
],
pVector
,
deltaCrossP
[
0
]
);
SimTKOpenMMUtilities
::
crossProductVector3
(
deltaR
[
0
],
pVector
,
deltaCrossP
[
0
]);
SimTKOpenMMUtilities
::
crossProductVector3
(
deltaR
[
1
],
pVector
,
deltaCrossP
[
2
]
);
SimTKOpenMMUtilities
::
crossProductVector3
(
deltaR
[
1
],
pVector
,
deltaCrossP
[
2
]);
for
(
int
ii
=
0
;
ii
<
threeI
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
threeI
;
ii
++
)
{
deltaCrossP
[
0
][
ii
]
*=
termA
;
deltaCrossP
[
0
][
ii
]
*=
termA
;
deltaCrossP
[
2
][
ii
]
*=
termC
;
deltaCrossP
[
2
][
ii
]
*=
termC
;
deltaCrossP
[
1
][
ii
]
=
oneM
*
(
deltaCrossP
[
0
][
ii
]
+
deltaCrossP
[
2
][
ii
]);
deltaCrossP
[
1
][
ii
]
=
oneM
*
(
deltaCrossP
[
0
][
ii
]
+
deltaCrossP
[
2
][
ii
]);
...
@@ -179,8 +177,8 @@ void ReferenceAngleBondIxn::calculateBondIxn( int* atomIndices,
...
@@ -179,8 +177,8 @@ void ReferenceAngleBondIxn::calculateBondIxn( int* atomIndices,
// accumulate forces
// accumulate forces
for
(
int
jj
=
0
;
jj
<
LastAtomIndex
;
jj
++
){
for
(
int
jj
=
0
;
jj
<
LastAtomIndex
;
jj
++
)
{
for
(
int
ii
=
0
;
ii
<
threeI
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
threeI
;
ii
++
)
{
forces
[
atomIndices
[
jj
]][
ii
]
+=
deltaCrossP
[
jj
][
ii
];
forces
[
atomIndices
[
jj
]][
ii
]
+=
deltaCrossP
[
jj
][
ii
];
}
}
}
}
...
...
platforms/reference/src/SimTKReference/ReferenceBondForce.cpp
View file @
162d69a2
...
@@ -25,13 +25,11 @@
...
@@ -25,13 +25,11 @@
#include <string.h>
#include <string.h>
#include <sstream>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceBondForce.h"
#include "ReferenceBondForce.h"
using
std
::
vector
;
using
std
::
vector
;
using
OpenMM
::
RealVec
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -39,7 +37,7 @@ using OpenMM::RealVec;
...
@@ -39,7 +37,7 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceBondForce
::
ReferenceBondForce
(
){
ReferenceBondForce
::
ReferenceBondForce
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -55,7 +53,7 @@ ReferenceBondForce::ReferenceBondForce( ){
...
@@ -55,7 +53,7 @@ ReferenceBondForce::ReferenceBondForce( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceBondForce
::~
ReferenceBondForce
(
){
ReferenceBondForce
::~
ReferenceBondForce
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -80,12 +78,12 @@ ReferenceBondForce::~ReferenceBondForce( ){
...
@@ -80,12 +78,12 @@ ReferenceBondForce::~ReferenceBondForce( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceBondForce
::
calculateForce
(
int
numberOfBonds
,
int
**
atomIndices
,
void
ReferenceBondForce
::
calculateForce
(
int
numberOfBonds
,
int
**
atomIndices
,
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
**
parameters
,
RealOpenMM
**
parameters
,
vector
<
RealVec
>&
forces
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
,
RealOpenMM
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
){
ReferenceBondIxn
&
referenceBondIxn
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -94,12 +92,12 @@ void ReferenceBondForce::calculateForce( int numberOfBonds, int** atomIndices,
...
@@ -94,12 +92,12 @@ void ReferenceBondForce::calculateForce( int numberOfBonds, int** atomIndices,
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
for
(
int
ii
=
0
;
ii
<
numberOfBonds
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
numberOfBonds
;
ii
++
)
{
// calculate bond ixn
// calculate bond ixn
referenceBondIxn
.
calculateBondIxn
(
atomIndices
[
ii
],
atomCoordinates
,
parameters
[
ii
],
referenceBondIxn
.
calculateBondIxn
(
atomIndices
[
ii
],
atomCoordinates
,
parameters
[
ii
],
forces
,
totalEnergy
);
forces
,
totalEnergy
);
}
}
}
}
platforms/reference/src/SimTKReference/ReferenceBondIxn.cpp
View file @
162d69a2
...
@@ -25,14 +25,12 @@
...
@@ -25,14 +25,12 @@
#include <string.h>
#include <string.h>
#include <sstream>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
#include "ReferenceBondIxn.h"
#include "ReferenceBondIxn.h"
using
std
::
vector
;
using
std
::
vector
;
using
OpenMM
::
RealVec
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -40,7 +38,7 @@ using OpenMM::RealVec;
...
@@ -40,7 +38,7 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceBondIxn
::
ReferenceBondIxn
(
){
ReferenceBondIxn
::
ReferenceBondIxn
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -56,7 +54,7 @@ ReferenceBondIxn::ReferenceBondIxn( ){
...
@@ -56,7 +54,7 @@ ReferenceBondIxn::ReferenceBondIxn( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceBondIxn
::~
ReferenceBondIxn
(
){
ReferenceBondIxn
::~
ReferenceBondIxn
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -78,9 +76,9 @@ ReferenceBondIxn::~ReferenceBondIxn( ){
...
@@ -78,9 +76,9 @@ ReferenceBondIxn::~ReferenceBondIxn( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
vector
<
RealVec
>&
atomCoordinates
,
void
ReferenceBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
*
parameters
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
parameters
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
{
RealOpenMM
*
totalEnergy
)
const
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceBondIxn::calculateBondIxn";
// static const std::string methodName = "\nReferenceBondIxn::calculateBondIxn";
...
@@ -104,8 +102,8 @@ ReferenceBondIxn::~ReferenceBondIxn( ){
...
@@ -104,8 +102,8 @@ ReferenceBondIxn::~ReferenceBondIxn( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceBondIxn
::
getNormedDotProduct
(
RealOpenMM
*
vector1
,
RealOpenMM
*
vector2
,
RealOpenMM
ReferenceBondIxn
::
getNormedDotProduct
(
RealOpenMM
*
vector1
,
RealOpenMM
*
vector2
,
int
hasREntry
=
0
)
{
int
hasREntry
=
0
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -124,35 +122,35 @@ RealOpenMM ReferenceBondIxn::getNormedDotProduct( RealOpenMM* vector1, RealOpenM
...
@@ -124,35 +122,35 @@ RealOpenMM ReferenceBondIxn::getNormedDotProduct( RealOpenMM* vector1, RealOpenM
#if defined USE_DOUBLE_FOR_NORMED_DOT_PRODUCT
#if defined USE_DOUBLE_FOR_NORMED_DOT_PRODUCT
double
v1D
[
3
];
double
v1D
[
3
];
double
v2D
[
3
];
double
v2D
[
3
];
v1D
[
0
]
=
static_cast
<
double
>
(
vector1
[
0
]
);
v1D
[
0
]
=
static_cast
<
double
>
(
vector1
[
0
]);
v1D
[
1
]
=
static_cast
<
double
>
(
vector1
[
1
]
);
v1D
[
1
]
=
static_cast
<
double
>
(
vector1
[
1
]);
v1D
[
2
]
=
static_cast
<
double
>
(
vector1
[
2
]
);
v1D
[
2
]
=
static_cast
<
double
>
(
vector1
[
2
]);
v2D
[
0
]
=
static_cast
<
double
>
(
vector2
[
0
]
);
v2D
[
0
]
=
static_cast
<
double
>
(
vector2
[
0
]);
v2D
[
1
]
=
static_cast
<
double
>
(
vector2
[
1
]
);
v2D
[
1
]
=
static_cast
<
double
>
(
vector2
[
1
]);
v2D
[
2
]
=
static_cast
<
double
>
(
vector2
[
2
]
);
v2D
[
2
]
=
static_cast
<
double
>
(
vector2
[
2
]);
double
dotProductD
=
DOT3
(
v1D
,
v2D
);
double
dotProductD
=
DOT3
(
v1D
,
v2D
);
if
(
dotProductD
!=
0.0
){
if
(
dotProductD
!=
0.0
)
{
if
(
hasREntry
){
if
(
hasREntry
)
{
dotProductD
/=
(
static_cast
<
double
>
(
vector1
[
ReferenceForce
::
RIndex
])
*
static_cast
<
double
>
(
vector2
[
ReferenceForce
::
RIndex
])
);
dotProductD
/=
(
static_cast
<
double
>
(
vector1
[
ReferenceForce
::
RIndex
])
*
static_cast
<
double
>
(
vector2
[
ReferenceForce
::
RIndex
]));
}
else
{
}
else
{
double
norm1
=
DOT3
(
v1D
,
v1D
);
double
norm1
=
DOT3
(
v1D
,
v1D
);
double
norm2
=
DOT3
(
v2D
,
v2D
);
double
norm2
=
DOT3
(
v2D
,
v2D
);
dotProductD
/=
sqrt
(
norm1
*
norm2
);
dotProductD
/=
sqrt
(
norm1
*
norm2
);
}
}
}
}
RealOpenMM
dotProduct
=
static_cast
<
RealOpenMM
>
(
dotProductD
);
RealOpenMM
dotProduct
=
static_cast
<
RealOpenMM
>
(
dotProductD
);
#else
#else
RealOpenMM
dotProduct
=
DOT3
(
vector1
,
vector2
);
RealOpenMM
dotProduct
=
DOT3
(
vector1
,
vector2
);
if
(
dotProduct
!=
zero
){
if
(
dotProduct
!=
zero
)
{
if
(
hasREntry
){
if
(
hasREntry
)
{
dotProduct
/=
(
vector1
[
ReferenceForce
::
RIndex
]
*
vector2
[
ReferenceForce
::
RIndex
]
);
dotProduct
/=
(
vector1
[
ReferenceForce
::
RIndex
]
*
vector2
[
ReferenceForce
::
RIndex
]);
}
else
{
}
else
{
RealOpenMM
norm1
=
DOT3
(
vector1
,
vector1
);
RealOpenMM
norm1
=
DOT3
(
vector1
,
vector1
);
RealOpenMM
norm2
=
DOT3
(
vector2
,
vector2
);
RealOpenMM
norm2
=
DOT3
(
vector2
,
vector2
);
dotProduct
/=
SQRT
(
norm1
*
norm2
);
dotProduct
/=
SQRT
(
norm1
*
norm2
);
}
}
}
}
...
@@ -161,9 +159,9 @@ RealOpenMM ReferenceBondIxn::getNormedDotProduct( RealOpenMM* vector1, RealOpenM
...
@@ -161,9 +159,9 @@ RealOpenMM ReferenceBondIxn::getNormedDotProduct( RealOpenMM* vector1, RealOpenM
// clamp dot product to [-1,1]
// clamp dot product to [-1,1]
if
(
dotProduct
>
one
){
if
(
dotProduct
>
one
)
{
dotProduct
=
one
;
dotProduct
=
one
;
}
else
if
(
dotProduct
<
-
one
){
}
else
if
(
dotProduct
<
-
one
)
{
dotProduct
=
-
one
;
dotProduct
=
-
one
;
}
}
...
@@ -185,9 +183,9 @@ RealOpenMM ReferenceBondIxn::getNormedDotProduct( RealOpenMM* vector1, RealOpenM
...
@@ -185,9 +183,9 @@ RealOpenMM ReferenceBondIxn::getNormedDotProduct( RealOpenMM* vector1, RealOpenM
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceBondIxn
::
getAngleBetweenTwoVectors
(
RealOpenMM
*
vector1
,
RealOpenMM
*
vector2
,
RealOpenMM
ReferenceBondIxn
::
getAngleBetweenTwoVectors
(
RealOpenMM
*
vector1
,
RealOpenMM
*
vector2
,
RealOpenMM
*
outputDotProduct
=
NULL
,
RealOpenMM
*
outputDotProduct
=
NULL
,
int
hasREntry
=
0
)
{
int
hasREntry
=
0
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -200,7 +198,7 @@ RealOpenMM ReferenceBondIxn::getAngleBetweenTwoVectors( RealOpenMM* vector1, Rea
...
@@ -200,7 +198,7 @@ RealOpenMM ReferenceBondIxn::getAngleBetweenTwoVectors( RealOpenMM* vector1, Rea
// get dot product betweenn vectors and then angle
// get dot product betweenn vectors and then angle
RealOpenMM
dotProduct
=
getNormedDotProduct
(
vector1
,
vector2
,
hasREntry
);
RealOpenMM
dotProduct
=
getNormedDotProduct
(
vector1
,
vector2
,
hasREntry
);
RealOpenMM
angle
;
RealOpenMM
angle
;
if
(
dotProduct
>
(
RealOpenMM
)
0.99
||
dotProduct
<
(
RealOpenMM
)
-
0.99
)
{
if
(
dotProduct
>
(
RealOpenMM
)
0.99
||
dotProduct
<
(
RealOpenMM
)
-
0.99
)
{
...
@@ -216,7 +214,7 @@ RealOpenMM ReferenceBondIxn::getAngleBetweenTwoVectors( RealOpenMM* vector1, Rea
...
@@ -216,7 +214,7 @@ RealOpenMM ReferenceBondIxn::getAngleBetweenTwoVectors( RealOpenMM* vector1, Rea
angle
=
ACOS
(
dotProduct
);
angle
=
ACOS
(
dotProduct
);
}
}
if
(
outputDotProduct
){
if
(
outputDotProduct
)
{
*
outputDotProduct
=
dotProduct
;
*
outputDotProduct
=
dotProduct
;
}
}
...
@@ -242,14 +240,14 @@ RealOpenMM ReferenceBondIxn::getAngleBetweenTwoVectors( RealOpenMM* vector1, Rea
...
@@ -242,14 +240,14 @@ RealOpenMM ReferenceBondIxn::getAngleBetweenTwoVectors( RealOpenMM* vector1, Rea
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceBondIxn
::
getDihedralAngleBetweenThreeVectors
(
RealOpenMM
*
vector1
,
RealOpenMM
ReferenceBondIxn
::
getDihedralAngleBetweenThreeVectors
(
RealOpenMM
*
vector1
,
RealOpenMM
*
vector2
,
RealOpenMM
*
vector2
,
RealOpenMM
*
vector3
,
RealOpenMM
*
vector3
,
RealOpenMM
**
outputCrossProduct
=
NULL
,
RealOpenMM
**
outputCrossProduct
=
NULL
,
RealOpenMM
*
cosineOfAngle
=
NULL
,
RealOpenMM
*
cosineOfAngle
=
NULL
,
RealOpenMM
*
signVector
=
NULL
,
RealOpenMM
*
signVector
=
NULL
,
RealOpenMM
*
signOfAngle
=
NULL
,
RealOpenMM
*
signOfAngle
=
NULL
,
int
hasREntry
=
0
)
{
int
hasREntry
=
0
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -265,7 +263,7 @@ RealOpenMM ReferenceBondIxn::getDihedralAngleBetweenThreeVectors( RealOpenMM* v
...
@@ -265,7 +263,7 @@ RealOpenMM ReferenceBondIxn::getDihedralAngleBetweenThreeVectors( RealOpenMM* v
// get cross products between vectors and then angle between cross product vectors
// get cross products between vectors and then angle between cross product vectors
RealOpenMM
*
crossProduct
[
2
];
RealOpenMM
*
crossProduct
[
2
];
if
(
outputCrossProduct
){
if
(
outputCrossProduct
)
{
crossProduct
[
0
]
=
outputCrossProduct
[
0
];
crossProduct
[
0
]
=
outputCrossProduct
[
0
];
crossProduct
[
1
]
=
outputCrossProduct
[
1
];
crossProduct
[
1
]
=
outputCrossProduct
[
1
];
}
else
{
}
else
{
...
@@ -273,17 +271,17 @@ RealOpenMM ReferenceBondIxn::getDihedralAngleBetweenThreeVectors( RealOpenMM* v
...
@@ -273,17 +271,17 @@ RealOpenMM ReferenceBondIxn::getDihedralAngleBetweenThreeVectors( RealOpenMM* v
crossProduct
[
1
]
=
tempVectors
+
3
;
crossProduct
[
1
]
=
tempVectors
+
3
;
}
}
SimTKOpenMMUtilities
::
crossProductVector3
(
vector1
,
vector2
,
crossProduct
[
0
]
);
SimTKOpenMMUtilities
::
crossProductVector3
(
vector1
,
vector2
,
crossProduct
[
0
]);
SimTKOpenMMUtilities
::
crossProductVector3
(
vector2
,
vector3
,
crossProduct
[
1
]
);
SimTKOpenMMUtilities
::
crossProductVector3
(
vector2
,
vector3
,
crossProduct
[
1
]);
RealOpenMM
angle
=
getAngleBetweenTwoVectors
(
crossProduct
[
0
],
crossProduct
[
1
],
cosineOfAngle
,
0
);
RealOpenMM
angle
=
getAngleBetweenTwoVectors
(
crossProduct
[
0
],
crossProduct
[
1
],
cosineOfAngle
,
0
);
// take care of sign of angle
// take care of sign of angle
if
(
signVector
){
if
(
signVector
)
{
RealOpenMM
dotProduct
=
DOT3
(
signVector
,
crossProduct
[
1
]
);
RealOpenMM
dotProduct
=
DOT3
(
signVector
,
crossProduct
[
1
]);
RealOpenMM
sign
=
dotProduct
<
zero
?
-
one
:
one
;
RealOpenMM
sign
=
dotProduct
<
zero
?
-
one
:
one
;
if
(
signOfAngle
){
if
(
signOfAngle
)
{
*
signOfAngle
=
sign
;
*
signOfAngle
=
sign
;
}
}
angle
*=
sign
;
angle
*=
sign
;
...
...
platforms/reference/src/SimTKReference/ReferenceBrownianDynamics.cpp
View file @
162d69a2
...
@@ -25,16 +25,15 @@
...
@@ -25,16 +25,15 @@
#include <cstring>
#include <cstring>
#include <sstream>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceBrownianDynamics.h"
#include "ReferenceBrownianDynamics.h"
#include "ReferenceVirtualSites.h"
#include "ReferenceVirtualSites.h"
#include "openmm/OpenMMException.h"
#include <cstdio>
#include <cstdio>
using
std
::
vector
;
using
std
::
vector
;
using
OpenMM
::
RealVec
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -47,29 +46,15 @@ using OpenMM::RealVec;
...
@@ -47,29 +46,15 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceBrownianDynamics
::
ReferenceBrownianDynamics
(
int
numberOfAtoms
,
ReferenceBrownianDynamics
::
ReferenceBrownianDynamics
(
int
numberOfAtoms
,
RealOpenMM
deltaT
,
RealOpenMM
friction
,
RealOpenMM
deltaT
,
RealOpenMM
friction
,
RealOpenMM
temperature
)
:
RealOpenMM
temperature
)
:
ReferenceDynamics
(
numberOfAtoms
,
deltaT
,
temperature
),
friction
(
friction
)
{
ReferenceDynamics
(
numberOfAtoms
,
deltaT
,
temperature
),
friction
(
friction
)
{
// ---------------------------------------------------------------------------------------
static
const
char
*
methodName
=
"
\n
ReferenceBrownianDynamics::ReferenceBrownianDynamics"
;
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
// ---------------------------------------------------------------------------------------
if
(
friction
<=
zero
){
if
(
friction
<=
0
)
{
std
::
stringstream
message
;
std
::
stringstream
message
;
message
<<
methodName
;
message
<<
"illegal friction value: "
<<
friction
;
message
<<
" input frction value="
<<
friction
<<
" is invalid -- setting to 1."
;
throw
OpenMMException
(
message
.
str
());
SimTKOpenMMLog
::
printError
(
message
);
this
->
friction
=
one
;
}
}
xPrime
.
resize
(
numberOfAtoms
);
xPrime
.
resize
(
numberOfAtoms
);
inverseMasses
.
resize
(
numberOfAtoms
);
inverseMasses
.
resize
(
numberOfAtoms
);
...
@@ -81,7 +66,7 @@ ReferenceBrownianDynamics::ReferenceBrownianDynamics( int numberOfAtoms,
...
@@ -81,7 +66,7 @@ ReferenceBrownianDynamics::ReferenceBrownianDynamics( int numberOfAtoms,
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceBrownianDynamics
::~
ReferenceBrownianDynamics
(
){
ReferenceBrownianDynamics
::~
ReferenceBrownianDynamics
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -99,7 +84,7 @@ ReferenceBrownianDynamics::~ReferenceBrownianDynamics( ){
...
@@ -99,7 +84,7 @@ ReferenceBrownianDynamics::~ReferenceBrownianDynamics( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceBrownianDynamics
::
getFriction
(
void
)
const
{
RealOpenMM
ReferenceBrownianDynamics
::
getFriction
()
const
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -139,10 +124,10 @@ void ReferenceBrownianDynamics::update(const OpenMM::System& system, vector<Real
...
@@ -139,10 +124,10 @@ void ReferenceBrownianDynamics::update(const OpenMM::System& system, vector<Real
// first-time-through initialization
// first-time-through initialization
int
numberOfAtoms
=
system
.
getNumParticles
();
int
numberOfAtoms
=
system
.
getNumParticles
();
if
(
getTimeStep
()
==
0
){
if
(
getTimeStep
()
==
0
)
{
// invert masses
// invert masses
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
)
{
if
(
masses
[
ii
]
==
zero
)
if
(
masses
[
ii
]
==
zero
)
inverseMasses
[
ii
]
=
zero
;
inverseMasses
[
ii
]
=
zero
;
else
else
...
@@ -152,7 +137,7 @@ void ReferenceBrownianDynamics::update(const OpenMM::System& system, vector<Real
...
@@ -152,7 +137,7 @@ void ReferenceBrownianDynamics::update(const OpenMM::System& system, vector<Real
// Perform the integration.
// Perform the integration.
const
RealOpenMM
noiseAmplitude
=
static_cast
<
RealOpenMM
>
(
sqrt
(
2.0
*
BOLTZ
*
getTemperature
()
*
getDeltaT
()
/
getFriction
())
);
const
RealOpenMM
noiseAmplitude
=
static_cast
<
RealOpenMM
>
(
sqrt
(
2.0
*
BOLTZ
*
getTemperature
()
*
getDeltaT
()
/
getFriction
()));
const
RealOpenMM
forceScale
=
getDeltaT
()
/
getFriction
();
const
RealOpenMM
forceScale
=
getDeltaT
()
/
getFriction
();
for
(
int
i
=
0
;
i
<
numberOfAtoms
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numberOfAtoms
;
++
i
)
{
if
(
masses
[
i
]
!=
zero
)
if
(
masses
[
i
]
!=
zero
)
...
@@ -166,7 +151,7 @@ void ReferenceBrownianDynamics::update(const OpenMM::System& system, vector<Real
...
@@ -166,7 +151,7 @@ void ReferenceBrownianDynamics::update(const OpenMM::System& system, vector<Real
// Update the positions and velocities.
// Update the positions and velocities.
RealOpenMM
velocityScale
=
static_cast
<
RealOpenMM
>
(
1.0
/
getDeltaT
()
);
RealOpenMM
velocityScale
=
static_cast
<
RealOpenMM
>
(
1.0
/
getDeltaT
());
for
(
int
i
=
0
;
i
<
numberOfAtoms
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numberOfAtoms
;
++
i
)
{
if
(
masses
[
i
]
!=
zero
)
if
(
masses
[
i
]
!=
zero
)
for
(
int
j
=
0
;
j
<
3
;
++
j
)
{
for
(
int
j
=
0
;
j
<
3
;
++
j
)
{
...
...
platforms/reference/src/SimTKReference/ReferenceCCMAAlgorithm.cpp
View file @
162d69a2
...
@@ -25,9 +25,7 @@
...
@@ -25,9 +25,7 @@
#include <string.h>
#include <string.h>
#include <sstream>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMLog.h"
#include "ReferenceCCMAAlgorithm.h"
#include "ReferenceCCMAAlgorithm.h"
#include "ReferenceDynamics.h"
#include "ReferenceDynamics.h"
#include "quern.h"
#include "quern.h"
...
@@ -39,9 +37,7 @@ using std::map;
...
@@ -39,9 +37,7 @@ using std::map;
using
std
::
pair
;
using
std
::
pair
;
using
std
::
vector
;
using
std
::
vector
;
using
std
::
set
;
using
std
::
set
;
using
OpenMM
::
OpenMMException
;
using
namespace
OpenMM
;
using
OpenMM
::
Vec3
;
using
OpenMM
::
RealVec
;
ReferenceCCMAAlgorithm
::
ReferenceCCMAAlgorithm
(
int
numberOfAtoms
,
ReferenceCCMAAlgorithm
::
ReferenceCCMAAlgorithm
(
int
numberOfAtoms
,
int
numberOfConstraints
,
int
numberOfConstraints
,
...
...
platforms/reference/src/SimTKReference/ReferenceCMAPTorsionIxn.cpp
View file @
162d69a2
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#include "ReferenceForce.h"
#include "ReferenceForce.h"
using
std
::
vector
;
using
std
::
vector
;
using
OpenMM
::
RealVec
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
...
platforms/reference/src/SimTKReference/ReferenceCustomAngleIxn.cpp
View file @
162d69a2
...
@@ -24,8 +24,6 @@
...
@@ -24,8 +24,6 @@
#include <string.h>
#include <string.h>
#include <sstream>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceCustomAngleIxn.h"
#include "ReferenceCustomAngleIxn.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
...
@@ -62,7 +60,7 @@ ReferenceCustomAngleIxn::ReferenceCustomAngleIxn(const Lepton::CompiledExpressio
...
@@ -62,7 +60,7 @@ ReferenceCustomAngleIxn::ReferenceCustomAngleIxn(const Lepton::CompiledExpressio
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceCustomAngleIxn
::~
ReferenceCustomAngleIxn
(
){
ReferenceCustomAngleIxn
::~
ReferenceCustomAngleIxn
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -84,11 +82,11 @@ ReferenceCustomAngleIxn::~ReferenceCustomAngleIxn( ){
...
@@ -84,11 +82,11 @@ ReferenceCustomAngleIxn::~ReferenceCustomAngleIxn( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceCustomAngleIxn
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceCustomAngleIxn
::
calculateBondIxn
(
int
*
atomIndices
,
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
*
parameters
,
vector
<
RealVec
>&
forces
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
{
RealOpenMM
*
totalEnergy
)
const
{
static
const
std
::
string
methodName
=
"
\n
ReferenceCustomAngleIxn::calculateAngleIxn"
;
static
const
std
::
string
methodName
=
"
\n
ReferenceCustomAngleIxn::calculateAngleIxn"
;
...
...
platforms/reference/src/SimTKReference/ReferenceCustomBondIxn.cpp
View file @
162d69a2
...
@@ -25,8 +25,6 @@
...
@@ -25,8 +25,6 @@
#include <string.h>
#include <string.h>
#include <sstream>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceCustomBondIxn.h"
#include "ReferenceCustomBondIxn.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
...
@@ -62,7 +60,7 @@ ReferenceCustomBondIxn::ReferenceCustomBondIxn(const Lepton::CompiledExpression&
...
@@ -62,7 +60,7 @@ ReferenceCustomBondIxn::ReferenceCustomBondIxn(const Lepton::CompiledExpression&
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceCustomBondIxn
::~
ReferenceCustomBondIxn
(
){
ReferenceCustomBondIxn
::~
ReferenceCustomBondIxn
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -84,11 +82,11 @@ ReferenceCustomBondIxn::~ReferenceCustomBondIxn( ){
...
@@ -84,11 +82,11 @@ ReferenceCustomBondIxn::~ReferenceCustomBondIxn( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceCustomBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceCustomBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
*
parameters
,
vector
<
RealVec
>&
forces
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
{
RealOpenMM
*
totalEnergy
)
const
{
static
const
std
::
string
methodName
=
"
\n
ReferenceCustomBondIxn::calculateBondIxn"
;
static
const
std
::
string
methodName
=
"
\n
ReferenceCustomBondIxn::calculateBondIxn"
;
...
@@ -110,7 +108,7 @@ void ReferenceCustomBondIxn::calculateBondIxn( int* atomIndices,
...
@@ -110,7 +108,7 @@ void ReferenceCustomBondIxn::calculateBondIxn( int* atomIndices,
int
atomAIndex
=
atomIndices
[
0
];
int
atomAIndex
=
atomIndices
[
0
];
int
atomBIndex
=
atomIndices
[
1
];
int
atomBIndex
=
atomIndices
[
1
];
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
);
ReferenceForce
::
setVariable
(
energyR
,
deltaR
[
ReferenceForce
::
RIndex
]);
ReferenceForce
::
setVariable
(
energyR
,
deltaR
[
ReferenceForce
::
RIndex
]);
ReferenceForce
::
setVariable
(
forceR
,
deltaR
[
ReferenceForce
::
RIndex
]);
ReferenceForce
::
setVariable
(
forceR
,
deltaR
[
ReferenceForce
::
RIndex
]);
...
...
platforms/reference/src/SimTKReference/ReferenceCustomCompoundBondIxn.cpp
View file @
162d69a2
...
@@ -26,8 +26,6 @@
...
@@ -26,8 +26,6 @@
#include <sstream>
#include <sstream>
#include <utility>
#include <utility>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
#include "ReferenceCustomCompoundBondIxn.h"
#include "ReferenceCustomCompoundBondIxn.h"
...
@@ -37,7 +35,7 @@ using std::pair;
...
@@ -37,7 +35,7 @@ using std::pair;
using
std
::
string
;
using
std
::
string
;
using
std
::
stringstream
;
using
std
::
stringstream
;
using
std
::
vector
;
using
std
::
vector
;
using
OpenMM
::
RealVec
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -72,7 +70,7 @@ ReferenceCustomCompoundBondIxn::ReferenceCustomCompoundBondIxn(int numParticlesP
...
@@ -72,7 +70,7 @@ ReferenceCustomCompoundBondIxn::ReferenceCustomCompoundBondIxn(int numParticlesP
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceCustomCompoundBondIxn
::~
ReferenceCustomCompoundBondIxn
(
){
ReferenceCustomCompoundBondIxn
::~
ReferenceCustomCompoundBondIxn
()
{
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -93,7 +91,7 @@ void ReferenceCustomCompoundBondIxn::calculatePairIxn(vector<RealVec>& atomCoord
...
@@ -93,7 +91,7 @@ void ReferenceCustomCompoundBondIxn::calculatePairIxn(vector<RealVec>& atomCoord
map
<
string
,
double
>
variables
=
globalParameters
;
map
<
string
,
double
>
variables
=
globalParameters
;
int
numBonds
=
bondAtoms
.
size
();
int
numBonds
=
bondAtoms
.
size
();
for
(
int
bond
=
0
;
bond
<
numBonds
;
bond
++
){
for
(
int
bond
=
0
;
bond
<
numBonds
;
bond
++
)
{
for
(
int
j
=
0
;
j
<
(
int
)
bondParamNames
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
(
int
)
bondParamNames
.
size
();
j
++
)
variables
[
bondParamNames
[
j
]]
=
bondParameters
[
bond
][
j
];
variables
[
bondParamNames
[
j
]]
=
bondParameters
[
bond
][
j
];
calculateOneIxn
(
bond
,
atomCoordinates
,
variables
,
forces
,
totalEnergy
);
calculateOneIxn
(
bond
,
atomCoordinates
,
variables
,
forces
,
totalEnergy
);
...
...
platforms/reference/src/SimTKReference/ReferenceCustomDynamics.cpp
View file @
162d69a2
...
@@ -22,8 +22,6 @@
...
@@ -22,8 +22,6 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceVirtualSites.h"
#include "ReferenceVirtualSites.h"
#include "ReferenceCustomDynamics.h"
#include "ReferenceCustomDynamics.h"
...
@@ -97,7 +95,7 @@ ReferenceCustomDynamics::~ReferenceCustomDynamics() {
...
@@ -97,7 +95,7 @@ ReferenceCustomDynamics::~ReferenceCustomDynamics() {
void
ReferenceCustomDynamics
::
update
(
ContextImpl
&
context
,
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
void
ReferenceCustomDynamics
::
update
(
ContextImpl
&
context
,
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealVec
>&
velocities
,
vector
<
RealVec
>&
forces
,
vector
<
RealOpenMM
>&
masses
,
vector
<
RealVec
>&
velocities
,
vector
<
RealVec
>&
forces
,
vector
<
RealOpenMM
>&
masses
,
map
<
string
,
RealOpenMM
>&
globals
,
vector
<
vector
<
RealVec
>
>&
perDof
,
bool
&
forcesAreValid
,
RealOpenMM
tolerance
){
map
<
string
,
RealOpenMM
>&
globals
,
vector
<
vector
<
RealVec
>
>&
perDof
,
bool
&
forcesAreValid
,
RealOpenMM
tolerance
)
{
int
numSteps
=
stepType
.
size
();
int
numSteps
=
stepType
.
size
();
globals
.
insert
(
context
.
getParameters
().
begin
(),
context
.
getParameters
().
end
());
globals
.
insert
(
context
.
getParameters
().
begin
(),
context
.
getParameters
().
end
());
oldPos
=
atomCoordinates
;
oldPos
=
atomCoordinates
;
...
...
platforms/reference/src/SimTKReference/ReferenceCustomExternalIxn.cpp
View file @
162d69a2
...
@@ -25,8 +25,6 @@
...
@@ -25,8 +25,6 @@
#include <string.h>
#include <string.h>
#include <sstream>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceCustomExternalIxn.h"
#include "ReferenceCustomExternalIxn.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
...
@@ -79,7 +77,7 @@ ReferenceCustomExternalIxn::ReferenceCustomExternalIxn(const Lepton::CompiledExp
...
@@ -79,7 +77,7 @@ ReferenceCustomExternalIxn::ReferenceCustomExternalIxn(const Lepton::CompiledExp
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceCustomExternalIxn
::~
ReferenceCustomExternalIxn
(
){
ReferenceCustomExternalIxn
::~
ReferenceCustomExternalIxn
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -101,11 +99,11 @@ ReferenceCustomExternalIxn::~ReferenceCustomExternalIxn( ){
...
@@ -101,11 +99,11 @@ ReferenceCustomExternalIxn::~ReferenceCustomExternalIxn( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceCustomExternalIxn
::
calculateForce
(
int
atomIndex
,
void
ReferenceCustomExternalIxn
::
calculateForce
(
int
atomIndex
,
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
*
parameters
,
vector
<
RealVec
>&
forces
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
energy
)
const
{
RealOpenMM
*
energy
)
const
{
static
const
std
::
string
methodName
=
"
\n
ReferenceCustomExternalIxn::calculateBondIxn"
;
static
const
std
::
string
methodName
=
"
\n
ReferenceCustomExternalIxn::calculateBondIxn"
;
...
...
platforms/reference/src/SimTKReference/ReferenceCustomGBIxn.cpp
View file @
162d69a2
...
@@ -25,8 +25,6 @@
...
@@ -25,8 +25,6 @@
#include <string.h>
#include <string.h>
#include <sstream>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
#include "ReferenceCustomGBIxn.h"
#include "ReferenceCustomGBIxn.h"
...
@@ -36,7 +34,7 @@ using std::set;
...
@@ -36,7 +34,7 @@ using std::set;
using
std
::
string
;
using
std
::
string
;
using
std
::
stringstream
;
using
std
::
stringstream
;
using
std
::
vector
;
using
std
::
vector
;
using
OpenMM
::
RealVec
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -86,7 +84,7 @@ ReferenceCustomGBIxn::ReferenceCustomGBIxn(const vector<Lepton::ExpressionProgra
...
@@ -86,7 +84,7 @@ ReferenceCustomGBIxn::ReferenceCustomGBIxn(const vector<Lepton::ExpressionProgra
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceCustomGBIxn
::~
ReferenceCustomGBIxn
(
){
ReferenceCustomGBIxn
::~
ReferenceCustomGBIxn
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -105,7 +103,7 @@ ReferenceCustomGBIxn::~ReferenceCustomGBIxn( ){
...
@@ -105,7 +103,7 @@ ReferenceCustomGBIxn::~ReferenceCustomGBIxn( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceCustomGBIxn
::
setUseCutoff
(
RealOpenMM
distance
,
const
OpenMM
::
NeighborList
&
neighbors
)
{
void
ReferenceCustomGBIxn
::
setUseCutoff
(
RealOpenMM
distance
,
const
OpenMM
::
NeighborList
&
neighbors
)
{
cutoff
=
true
;
cutoff
=
true
;
cutoffDistance
=
distance
;
cutoffDistance
=
distance
;
...
@@ -203,8 +201,8 @@ void ReferenceCustomGBIxn::calculateParticlePairValue(int index, int numAtoms, v
...
@@ -203,8 +201,8 @@ void ReferenceCustomGBIxn::calculateParticlePairValue(int index, int numAtoms, v
else
{
else
{
// Perform an O(N^2) loop over all atom pairs.
// Perform an O(N^2) loop over all atom pairs.
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
){
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
)
{
for
(
int
j
=
i
+
1
;
j
<
numAtoms
;
j
++
){
for
(
int
j
=
i
+
1
;
j
<
numAtoms
;
j
++
)
{
if
(
useExclusions
&&
exclusions
[
i
].
find
(
j
)
!=
exclusions
[
i
].
end
())
if
(
useExclusions
&&
exclusions
[
i
].
find
(
j
)
!=
exclusions
[
i
].
end
())
continue
;
continue
;
calculateOnePairValue
(
index
,
i
,
j
,
atomCoordinates
,
atomParameters
,
globalParameters
,
values
);
calculateOnePairValue
(
index
,
i
,
j
,
atomCoordinates
,
atomParameters
,
globalParameters
,
values
);
...
@@ -275,8 +273,8 @@ void ReferenceCustomGBIxn::calculateParticlePairEnergyTerm(int index, int numAto
...
@@ -275,8 +273,8 @@ void ReferenceCustomGBIxn::calculateParticlePairEnergyTerm(int index, int numAto
else
{
else
{
// Perform an O(N^2) loop over all atom pairs.
// Perform an O(N^2) loop over all atom pairs.
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
){
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
)
{
for
(
int
j
=
i
+
1
;
j
<
numAtoms
;
j
++
){
for
(
int
j
=
i
+
1
;
j
<
numAtoms
;
j
++
)
{
if
(
useExclusions
&&
exclusions
[
i
].
find
(
j
)
!=
exclusions
[
i
].
end
())
if
(
useExclusions
&&
exclusions
[
i
].
find
(
j
)
!=
exclusions
[
i
].
end
())
continue
;
continue
;
calculateOnePairEnergyTerm
(
index
,
i
,
j
,
atomCoordinates
,
atomParameters
,
globalParameters
,
values
,
forces
,
totalEnergy
,
dEdV
);
calculateOnePairEnergyTerm
(
index
,
i
,
j
,
atomCoordinates
,
atomParameters
,
globalParameters
,
values
,
forces
,
totalEnergy
,
dEdV
);
...
@@ -344,8 +342,8 @@ void ReferenceCustomGBIxn::calculateChainRuleForces(int numAtoms, vector<RealVec
...
@@ -344,8 +342,8 @@ void ReferenceCustomGBIxn::calculateChainRuleForces(int numAtoms, vector<RealVec
else
{
else
{
// Perform an O(N^2) loop over all atom pairs.
// Perform an O(N^2) loop over all atom pairs.
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
){
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
)
{
for
(
int
j
=
i
+
1
;
j
<
numAtoms
;
j
++
){
for
(
int
j
=
i
+
1
;
j
<
numAtoms
;
j
++
)
{
bool
isExcluded
=
(
exclusions
[
i
].
find
(
j
)
!=
exclusions
[
i
].
end
());
bool
isExcluded
=
(
exclusions
[
i
].
find
(
j
)
!=
exclusions
[
i
].
end
());
calculateOnePairChainRule
(
i
,
j
,
atomCoordinates
,
atomParameters
,
globalParameters
,
values
,
forces
,
dEdV
,
isExcluded
);
calculateOnePairChainRule
(
i
,
j
,
atomCoordinates
,
atomParameters
,
globalParameters
,
values
,
forces
,
dEdV
,
isExcluded
);
calculateOnePairChainRule
(
j
,
i
,
atomCoordinates
,
atomParameters
,
globalParameters
,
values
,
forces
,
dEdV
,
isExcluded
);
calculateOnePairChainRule
(
j
,
i
,
atomCoordinates
,
atomParameters
,
globalParameters
,
values
,
forces
,
dEdV
,
isExcluded
);
...
...
platforms/reference/src/SimTKReference/ReferenceCustomHbondIxn.cpp
View file @
162d69a2
...
@@ -26,8 +26,6 @@
...
@@ -26,8 +26,6 @@
#include <sstream>
#include <sstream>
#include <utility>
#include <utility>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
#include "ReferenceCustomHbondIxn.h"
#include "ReferenceCustomHbondIxn.h"
...
@@ -38,7 +36,7 @@ using std::set;
...
@@ -38,7 +36,7 @@ using std::set;
using
std
::
string
;
using
std
::
string
;
using
std
::
stringstream
;
using
std
::
stringstream
;
using
std
::
vector
;
using
std
::
vector
;
using
OpenMM
::
RealVec
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -65,7 +63,7 @@ ReferenceCustomHbondIxn::ReferenceCustomHbondIxn(const vector<vector<int> >& don
...
@@ -65,7 +63,7 @@ ReferenceCustomHbondIxn::ReferenceCustomHbondIxn(const vector<vector<int> >& don
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceCustomHbondIxn
::~
ReferenceCustomHbondIxn
(
){
ReferenceCustomHbondIxn
::~
ReferenceCustomHbondIxn
()
{
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -129,7 +127,7 @@ void ReferenceCustomHbondIxn::calculatePairIxn(vector<RealVec>& atomCoordinates,
...
@@ -129,7 +127,7 @@ void ReferenceCustomHbondIxn::calculatePairIxn(vector<RealVec>& atomCoordinates,
int
numDonors
=
donorAtoms
.
size
();
int
numDonors
=
donorAtoms
.
size
();
int
numAcceptors
=
acceptorAtoms
.
size
();
int
numAcceptors
=
acceptorAtoms
.
size
();
for
(
int
donor
=
0
;
donor
<
numDonors
;
donor
++
){
for
(
int
donor
=
0
;
donor
<
numDonors
;
donor
++
)
{
// Initialize per-donor parameters.
// Initialize per-donor parameters.
for
(
int
j
=
0
;
j
<
(
int
)
donorParamNames
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
(
int
)
donorParamNames
.
size
();
j
++
)
...
@@ -137,7 +135,7 @@ void ReferenceCustomHbondIxn::calculatePairIxn(vector<RealVec>& atomCoordinates,
...
@@ -137,7 +135,7 @@ void ReferenceCustomHbondIxn::calculatePairIxn(vector<RealVec>& atomCoordinates,
// loop over atom pairs
// loop over atom pairs
for
(
int
acceptor
=
0
;
acceptor
<
numAcceptors
;
acceptor
++
){
for
(
int
acceptor
=
0
;
acceptor
<
numAcceptors
;
acceptor
++
)
{
if
(
exclusions
[
donor
].
find
(
acceptor
)
==
exclusions
[
donor
].
end
())
{
if
(
exclusions
[
donor
].
find
(
acceptor
)
==
exclusions
[
donor
].
end
())
{
for
(
int
j
=
0
;
j
<
(
int
)
acceptorParamNames
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
(
int
)
acceptorParamNames
.
size
();
j
++
)
variables
[
acceptorParamNames
[
j
]]
=
acceptorParameters
[
acceptor
][
j
];
variables
[
acceptorParamNames
[
j
]]
=
acceptorParameters
[
acceptor
][
j
];
...
...
platforms/reference/src/SimTKReference/ReferenceCustomManyParticleIxn.cpp
View file @
162d69a2
...
@@ -26,8 +26,6 @@
...
@@ -26,8 +26,6 @@
#include <sstream>
#include <sstream>
#include <utility>
#include <utility>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
#include "ReferenceCustomManyParticleIxn.h"
#include "ReferenceCustomManyParticleIxn.h"
...
@@ -104,7 +102,7 @@ ReferenceCustomManyParticleIxn::ReferenceCustomManyParticleIxn(const CustomManyP
...
@@ -104,7 +102,7 @@ ReferenceCustomManyParticleIxn::ReferenceCustomManyParticleIxn(const CustomManyP
CustomManyParticleForceImpl
::
buildFilterArrays
(
force
,
numTypes
,
particleTypes
,
orderIndex
,
particleOrder
);
CustomManyParticleForceImpl
::
buildFilterArrays
(
force
,
numTypes
,
particleTypes
,
orderIndex
,
particleOrder
);
}
}
ReferenceCustomManyParticleIxn
::~
ReferenceCustomManyParticleIxn
(
){
ReferenceCustomManyParticleIxn
::~
ReferenceCustomManyParticleIxn
()
{
}
}
void
ReferenceCustomManyParticleIxn
::
calculateIxn
(
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
**
particleParameters
,
void
ReferenceCustomManyParticleIxn
::
calculateIxn
(
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
**
particleParameters
,
...
...
platforms/reference/src/SimTKReference/ReferenceCustomNonbondedIxn.cpp
View file @
162d69a2
...
@@ -25,8 +25,6 @@
...
@@ -25,8 +25,6 @@
#include <string.h>
#include <string.h>
#include <sstream>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
#include "ReferenceCustomNonbondedIxn.h"
#include "ReferenceCustomNonbondedIxn.h"
...
@@ -37,7 +35,7 @@ using std::string;
...
@@ -37,7 +35,7 @@ using std::string;
using
std
::
stringstream
;
using
std
::
stringstream
;
using
std
::
set
;
using
std
::
set
;
using
std
::
vector
;
using
std
::
vector
;
using
OpenMM
::
RealVec
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -73,7 +71,7 @@ ReferenceCustomNonbondedIxn::ReferenceCustomNonbondedIxn(const Lepton::CompiledE
...
@@ -73,7 +71,7 @@ ReferenceCustomNonbondedIxn::ReferenceCustomNonbondedIxn(const Lepton::CompiledE
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceCustomNonbondedIxn
::~
ReferenceCustomNonbondedIxn
(
){
ReferenceCustomNonbondedIxn
::~
ReferenceCustomNonbondedIxn
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -92,7 +90,7 @@ ReferenceCustomNonbondedIxn::~ReferenceCustomNonbondedIxn( ){
...
@@ -92,7 +90,7 @@ ReferenceCustomNonbondedIxn::~ReferenceCustomNonbondedIxn( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceCustomNonbondedIxn
::
setUseCutoff
(
RealOpenMM
distance
,
const
OpenMM
::
NeighborList
&
neighbors
)
{
void
ReferenceCustomNonbondedIxn
::
setUseCutoff
(
RealOpenMM
distance
,
const
OpenMM
::
NeighborList
&
neighbors
)
{
cutoff
=
true
;
cutoff
=
true
;
cutoffDistance
=
distance
;
cutoffDistance
=
distance
;
...
@@ -120,7 +118,7 @@ void ReferenceCustomNonbondedIxn::setInteractionGroups(const vector<pair<set<int
...
@@ -120,7 +118,7 @@ void ReferenceCustomNonbondedIxn::setInteractionGroups(const vector<pair<set<int
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceCustomNonbondedIxn
::
setUseSwitchingFunction
(
RealOpenMM
distance
)
{
void
ReferenceCustomNonbondedIxn
::
setUseSwitchingFunction
(
RealOpenMM
distance
)
{
useSwitch
=
true
;
useSwitch
=
true
;
switchingDistance
=
distance
;
switchingDistance
=
distance
;
}
}
...
@@ -166,10 +164,10 @@ void ReferenceCustomNonbondedIxn::setUseSwitchingFunction( RealOpenMM distance )
...
@@ -166,10 +164,10 @@ void ReferenceCustomNonbondedIxn::setUseSwitchingFunction( RealOpenMM distance )
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceCustomNonbondedIxn
::
calculatePairIxn
(
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
void
ReferenceCustomNonbondedIxn
::
calculatePairIxn
(
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
**
atomParameters
,
vector
<
set
<
int
>
>&
exclusions
,
RealOpenMM
**
atomParameters
,
vector
<
set
<
int
>
>&
exclusions
,
RealOpenMM
*
fixedParameters
,
const
map
<
string
,
double
>&
globalParameters
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
fixedParameters
,
const
map
<
string
,
double
>&
globalParameters
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
energyByAtom
,
RealOpenMM
*
totalEnergy
)
{
RealOpenMM
*
energyByAtom
,
RealOpenMM
*
totalEnergy
)
{
for
(
map
<
string
,
double
>::
const_iterator
iter
=
globalParameters
.
begin
();
iter
!=
globalParameters
.
end
();
++
iter
)
{
for
(
map
<
string
,
double
>::
const_iterator
iter
=
globalParameters
.
begin
();
iter
!=
globalParameters
.
end
();
++
iter
)
{
ReferenceForce
::
setVariable
(
ReferenceForce
::
getVariablePointer
(
energyExpression
,
iter
->
first
),
iter
->
second
);
ReferenceForce
::
setVariable
(
ReferenceForce
::
getVariablePointer
(
energyExpression
,
iter
->
first
),
iter
->
second
);
...
@@ -245,8 +243,8 @@ void ReferenceCustomNonbondedIxn::calculatePairIxn( int numberOfAtoms, vector<Re
...
@@ -245,8 +243,8 @@ void ReferenceCustomNonbondedIxn::calculatePairIxn( int numberOfAtoms, vector<Re
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceCustomNonbondedIxn
::
calculateOneIxn
(
int
ii
,
int
jj
,
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealVec
>&
forces
,
void
ReferenceCustomNonbondedIxn
::
calculateOneIxn
(
int
ii
,
int
jj
,
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
energyByAtom
,
RealOpenMM
*
totalEnergy
)
{
RealOpenMM
*
energyByAtom
,
RealOpenMM
*
totalEnergy
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -268,9 +266,9 @@ void ReferenceCustomNonbondedIxn::calculateOneIxn( int ii, int jj, vector<RealVe
...
@@ -268,9 +266,9 @@ void ReferenceCustomNonbondedIxn::calculateOneIxn( int ii, int jj, vector<RealVe
RealOpenMM
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
RealOpenMM
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
if
(
periodic
)
if
(
periodic
)
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
jj
],
atomCoordinates
[
ii
],
periodicBoxVectors
,
deltaR
);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
jj
],
atomCoordinates
[
ii
],
periodicBoxVectors
,
deltaR
);
else
else
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
jj
],
atomCoordinates
[
ii
],
deltaR
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
jj
],
atomCoordinates
[
ii
],
deltaR
);
RealOpenMM
r
=
deltaR
[
ReferenceForce
::
RIndex
];
RealOpenMM
r
=
deltaR
[
ReferenceForce
::
RIndex
];
if
(
cutoff
&&
r
>=
cutoffDistance
)
if
(
cutoff
&&
r
>=
cutoffDistance
)
return
;
return
;
...
@@ -290,7 +288,7 @@ void ReferenceCustomNonbondedIxn::calculateOneIxn( int ii, int jj, vector<RealVe
...
@@ -290,7 +288,7 @@ void ReferenceCustomNonbondedIxn::calculateOneIxn( int ii, int jj, vector<RealVe
energy
*=
switchValue
;
energy
*=
switchValue
;
}
}
}
}
for
(
int
kk
=
0
;
kk
<
3
;
kk
++
){
for
(
int
kk
=
0
;
kk
<
3
;
kk
++
)
{
RealOpenMM
force
=
-
dEdR
*
deltaR
[
kk
];
RealOpenMM
force
=
-
dEdR
*
deltaR
[
kk
];
forces
[
ii
][
kk
]
+=
force
;
forces
[
ii
][
kk
]
+=
force
;
forces
[
jj
][
kk
]
-=
force
;
forces
[
jj
][
kk
]
-=
force
;
...
@@ -298,10 +296,10 @@ void ReferenceCustomNonbondedIxn::calculateOneIxn( int ii, int jj, vector<RealVe
...
@@ -298,10 +296,10 @@ void ReferenceCustomNonbondedIxn::calculateOneIxn( int ii, int jj, vector<RealVe
// accumulate energies
// accumulate energies
if
(
totalEnergy
||
energyByAtom
)
{
if
(
totalEnergy
||
energyByAtom
)
{
if
(
totalEnergy
)
if
(
totalEnergy
)
*
totalEnergy
+=
energy
;
*
totalEnergy
+=
energy
;
if
(
energyByAtom
){
if
(
energyByAtom
)
{
energyByAtom
[
ii
]
+=
energy
;
energyByAtom
[
ii
]
+=
energy
;
energyByAtom
[
jj
]
+=
energy
;
energyByAtom
[
jj
]
+=
energy
;
}
}
...
...
platforms/reference/src/SimTKReference/ReferenceCustomTorsionIxn.cpp
View file @
162d69a2
...
@@ -24,8 +24,6 @@
...
@@ -24,8 +24,6 @@
#include <string.h>
#include <string.h>
#include <sstream>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceCustomTorsionIxn.h"
#include "ReferenceCustomTorsionIxn.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
...
@@ -62,7 +60,7 @@ ReferenceCustomTorsionIxn::ReferenceCustomTorsionIxn(const Lepton::CompiledExpre
...
@@ -62,7 +60,7 @@ ReferenceCustomTorsionIxn::ReferenceCustomTorsionIxn(const Lepton::CompiledExpre
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceCustomTorsionIxn
::~
ReferenceCustomTorsionIxn
(
){
ReferenceCustomTorsionIxn
::~
ReferenceCustomTorsionIxn
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -84,11 +82,11 @@ ReferenceCustomTorsionIxn::~ReferenceCustomTorsionIxn( ){
...
@@ -84,11 +82,11 @@ ReferenceCustomTorsionIxn::~ReferenceCustomTorsionIxn( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceCustomTorsionIxn
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceCustomTorsionIxn
::
calculateBondIxn
(
int
*
atomIndices
,
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
*
parameters
,
vector
<
RealVec
>&
forces
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
{
RealOpenMM
*
totalEnergy
)
const
{
static
const
std
::
string
methodName
=
"
\n
ReferenceCustomTorsionIxn::calculateTorsionIxn"
;
static
const
std
::
string
methodName
=
"
\n
ReferenceCustomTorsionIxn::calculateTorsionIxn"
;
...
@@ -136,20 +134,20 @@ void ReferenceCustomTorsionIxn::calculateBondIxn( int* atomIndices,
...
@@ -136,20 +134,20 @@ void ReferenceCustomTorsionIxn::calculateBondIxn( int* atomIndices,
RealOpenMM
internalF
[
4
][
3
];
RealOpenMM
internalF
[
4
][
3
];
RealOpenMM
forceFactors
[
4
];
RealOpenMM
forceFactors
[
4
];
RealOpenMM
normCross1
=
DOT3
(
crossProduct
[
0
],
crossProduct
[
0
]
);
RealOpenMM
normCross1
=
DOT3
(
crossProduct
[
0
],
crossProduct
[
0
]);
RealOpenMM
normBC
=
deltaR
[
1
][
ReferenceForce
::
RIndex
];
RealOpenMM
normBC
=
deltaR
[
1
][
ReferenceForce
::
RIndex
];
forceFactors
[
0
]
=
(
-
dEdAngle
*
normBC
)
/
normCross1
;
forceFactors
[
0
]
=
(
-
dEdAngle
*
normBC
)
/
normCross1
;
RealOpenMM
normCross2
=
DOT3
(
crossProduct
[
1
],
crossProduct
[
1
]
);
RealOpenMM
normCross2
=
DOT3
(
crossProduct
[
1
],
crossProduct
[
1
]);
forceFactors
[
3
]
=
(
dEdAngle
*
normBC
)
/
normCross2
;
forceFactors
[
3
]
=
(
dEdAngle
*
normBC
)
/
normCross2
;
forceFactors
[
1
]
=
DOT3
(
deltaR
[
0
],
deltaR
[
1
]
);
forceFactors
[
1
]
=
DOT3
(
deltaR
[
0
],
deltaR
[
1
]);
forceFactors
[
1
]
/=
deltaR
[
1
][
ReferenceForce
::
R2Index
];
forceFactors
[
1
]
/=
deltaR
[
1
][
ReferenceForce
::
R2Index
];
forceFactors
[
2
]
=
DOT3
(
deltaR
[
2
],
deltaR
[
1
]
);
forceFactors
[
2
]
=
DOT3
(
deltaR
[
2
],
deltaR
[
1
]);
forceFactors
[
2
]
/=
deltaR
[
1
][
ReferenceForce
::
R2Index
];
forceFactors
[
2
]
/=
deltaR
[
1
][
ReferenceForce
::
R2Index
];
for
(
int
ii
=
0
;
ii
<
3
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
3
;
ii
++
)
{
internalF
[
0
][
ii
]
=
forceFactors
[
0
]
*
crossProduct
[
0
][
ii
];
internalF
[
0
][
ii
]
=
forceFactors
[
0
]
*
crossProduct
[
0
][
ii
];
internalF
[
3
][
ii
]
=
forceFactors
[
3
]
*
crossProduct
[
1
][
ii
];
internalF
[
3
][
ii
]
=
forceFactors
[
3
]
*
crossProduct
[
1
][
ii
];
...
@@ -162,7 +160,7 @@ void ReferenceCustomTorsionIxn::calculateBondIxn( int* atomIndices,
...
@@ -162,7 +160,7 @@ void ReferenceCustomTorsionIxn::calculateBondIxn( int* atomIndices,
// accumulate forces
// accumulate forces
for
(
int
ii
=
0
;
ii
<
3
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
3
;
ii
++
)
{
forces
[
atomAIndex
][
ii
]
+=
internalF
[
0
][
ii
];
forces
[
atomAIndex
][
ii
]
+=
internalF
[
0
][
ii
];
forces
[
atomBIndex
][
ii
]
-=
internalF
[
1
][
ii
];
forces
[
atomBIndex
][
ii
]
-=
internalF
[
1
][
ii
];
forces
[
atomCIndex
][
ii
]
-=
internalF
[
2
][
ii
];
forces
[
atomCIndex
][
ii
]
-=
internalF
[
2
][
ii
];
...
...
platforms/reference/src/SimTKReference/ReferenceDynamics.cpp
View file @
162d69a2
...
@@ -25,15 +25,13 @@
...
@@ -25,15 +25,13 @@
#include <cstring>
#include <cstring>
#include <sstream>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceDynamics.h"
#include "ReferenceDynamics.h"
#include <cstdio>
#include <cstdio>
using
std
::
vector
;
using
std
::
vector
;
using
OpenMM
::
RealVec
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -46,7 +44,7 @@ using OpenMM::RealVec;
...
@@ -46,7 +44,7 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceDynamics
::
ReferenceDynamics
(
int
numberOfAtoms
,
RealOpenMM
deltaT
,
RealOpenMM
temperature
)
:
ReferenceDynamics
::
ReferenceDynamics
(
int
numberOfAtoms
,
RealOpenMM
deltaT
,
RealOpenMM
temperature
)
:
_numberOfAtoms
(
numberOfAtoms
),
_deltaT
(
deltaT
),
_temperature
(
temperature
)
{
_numberOfAtoms
(
numberOfAtoms
),
_deltaT
(
deltaT
),
_temperature
(
temperature
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -69,7 +67,7 @@ ReferenceDynamics::ReferenceDynamics( int numberOfAtoms, RealOpenMM deltaT, Rea
...
@@ -69,7 +67,7 @@ ReferenceDynamics::ReferenceDynamics( int numberOfAtoms, RealOpenMM deltaT, Rea
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceDynamics
::~
ReferenceDynamics
(
){
ReferenceDynamics
::~
ReferenceDynamics
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -77,7 +75,7 @@ ReferenceDynamics::~ReferenceDynamics( ){
...
@@ -77,7 +75,7 @@ ReferenceDynamics::~ReferenceDynamics( ){
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
if
(
_ownReferenceConstraint
){
if
(
_ownReferenceConstraint
)
{
delete
_referenceConstraint
;
delete
_referenceConstraint
;
}
}
}
}
...
@@ -90,7 +88,7 @@ ReferenceDynamics::~ReferenceDynamics( ){
...
@@ -90,7 +88,7 @@ ReferenceDynamics::~ReferenceDynamics( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
getNumberOfAtoms
(
void
)
const
{
int
ReferenceDynamics
::
getNumberOfAtoms
()
const
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -109,7 +107,7 @@ int ReferenceDynamics::getNumberOfAtoms( void ) const {
...
@@ -109,7 +107,7 @@ int ReferenceDynamics::getNumberOfAtoms( void ) const {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
getTimeStep
(
void
)
const
{
int
ReferenceDynamics
::
getTimeStep
()
const
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -128,7 +126,7 @@ int ReferenceDynamics::getTimeStep( void ) const {
...
@@ -128,7 +126,7 @@ int ReferenceDynamics::getTimeStep( void ) const {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
incrementTimeStep
(
void
){
int
ReferenceDynamics
::
incrementTimeStep
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -147,7 +145,7 @@ int ReferenceDynamics::incrementTimeStep( void ){
...
@@ -147,7 +145,7 @@ int ReferenceDynamics::incrementTimeStep( void ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceDynamics
::
getDeltaT
(
void
)
const
{
RealOpenMM
ReferenceDynamics
::
getDeltaT
()
const
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -164,7 +162,7 @@ RealOpenMM ReferenceDynamics::getDeltaT( void ) const {
...
@@ -164,7 +162,7 @@ RealOpenMM ReferenceDynamics::getDeltaT( void ) const {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceDynamics
::
setDeltaT
(
RealOpenMM
deltaT
)
{
void
ReferenceDynamics
::
setDeltaT
(
RealOpenMM
deltaT
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -183,7 +181,7 @@ void ReferenceDynamics::setDeltaT( RealOpenMM deltaT ) {
...
@@ -183,7 +181,7 @@ void ReferenceDynamics::setDeltaT( RealOpenMM deltaT ) {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceDynamics
::
getTemperature
(
void
)
const
{
RealOpenMM
ReferenceDynamics
::
getTemperature
()
const
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -202,7 +200,7 @@ RealOpenMM ReferenceDynamics::getTemperature( void ) const {
...
@@ -202,7 +200,7 @@ RealOpenMM ReferenceDynamics::getTemperature( void ) const {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceConstraintAlgorithm
*
ReferenceDynamics
::
getReferenceConstraintAlgorithm
(
void
)
const
{
ReferenceConstraintAlgorithm
*
ReferenceDynamics
::
getReferenceConstraintAlgorithm
()
const
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -221,7 +219,7 @@ ReferenceConstraintAlgorithm* ReferenceDynamics::getReferenceConstraintAlgorithm
...
@@ -221,7 +219,7 @@ ReferenceConstraintAlgorithm* ReferenceDynamics::getReferenceConstraintAlgorithm
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceDynamics
::
setReferenceConstraintAlgorithm
(
ReferenceConstraintAlgorithm
*
referenceConstraint
){
void
ReferenceDynamics
::
setReferenceConstraintAlgorithm
(
ReferenceConstraintAlgorithm
*
referenceConstraint
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -231,7 +229,7 @@ void ReferenceDynamics::setReferenceConstraintAlgorithm( ReferenceConstraintAlgo
...
@@ -231,7 +229,7 @@ void ReferenceDynamics::setReferenceConstraintAlgorithm( ReferenceConstraintAlgo
// delete if own
// delete if own
if
(
_referenceConstraint
&&
_ownReferenceConstraint
){
if
(
_referenceConstraint
&&
_ownReferenceConstraint
)
{
delete
_referenceConstraint
;
delete
_referenceConstraint
;
}
}
...
...
platforms/reference/src/SimTKReference/ReferenceForce.cpp
View file @
162d69a2
...
@@ -25,14 +25,12 @@
...
@@ -25,14 +25,12 @@
#include <cstring>
#include <cstring>
#include <sstream>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
#include <cstdio>
#include <cstdio>
using
OpenMM
::
RealVec
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -40,7 +38,7 @@ using OpenMM::RealVec;
...
@@ -40,7 +38,7 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceForce
::
ReferenceForce
(
){
ReferenceForce
::
ReferenceForce
()
{
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -49,7 +47,7 @@ ReferenceForce::ReferenceForce( ){
...
@@ -49,7 +47,7 @@ ReferenceForce::ReferenceForce( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceForce
::~
ReferenceForce
(
){
ReferenceForce
::~
ReferenceForce
()
{
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -65,28 +63,28 @@ RealOpenMM ReferenceForce::periodicDifference(RealOpenMM val1, RealOpenMM val2,
...
@@ -65,28 +63,28 @@ RealOpenMM ReferenceForce::periodicDifference(RealOpenMM val1, RealOpenMM val2,
}
}
void
ReferenceForce
::
getDeltaR
(
const
RealVec
&
atomCoordinatesI
,
const
RealVec
&
atomCoordinatesJ
,
void
ReferenceForce
::
getDeltaR
(
const
RealVec
&
atomCoordinatesI
,
const
RealVec
&
atomCoordinatesJ
,
RealOpenMM
*
deltaR
){
RealOpenMM
*
deltaR
)
{
deltaR
[
XIndex
]
=
atomCoordinatesJ
[
0
]
-
atomCoordinatesI
[
0
];
deltaR
[
XIndex
]
=
atomCoordinatesJ
[
0
]
-
atomCoordinatesI
[
0
];
deltaR
[
YIndex
]
=
atomCoordinatesJ
[
1
]
-
atomCoordinatesI
[
1
];
deltaR
[
YIndex
]
=
atomCoordinatesJ
[
1
]
-
atomCoordinatesI
[
1
];
deltaR
[
ZIndex
]
=
atomCoordinatesJ
[
2
]
-
atomCoordinatesI
[
2
];
deltaR
[
ZIndex
]
=
atomCoordinatesJ
[
2
]
-
atomCoordinatesI
[
2
];
deltaR
[
R2Index
]
=
DOT3
(
deltaR
,
deltaR
);
deltaR
[
R2Index
]
=
DOT3
(
deltaR
,
deltaR
);
deltaR
[
RIndex
]
=
(
RealOpenMM
)
SQRT
(
deltaR
[
R2Index
]
);
deltaR
[
RIndex
]
=
(
RealOpenMM
)
SQRT
(
deltaR
[
R2Index
]);
}
}
void
ReferenceForce
::
getDeltaRPeriodic
(
const
RealVec
&
atomCoordinatesI
,
const
RealVec
&
atomCoordinatesJ
,
void
ReferenceForce
::
getDeltaRPeriodic
(
const
RealVec
&
atomCoordinatesI
,
const
RealVec
&
atomCoordinatesJ
,
const
RealOpenMM
*
boxSize
,
RealOpenMM
*
deltaR
){
const
RealOpenMM
*
boxSize
,
RealOpenMM
*
deltaR
)
{
deltaR
[
XIndex
]
=
periodicDifference
(
atomCoordinatesJ
[
0
],
atomCoordinatesI
[
0
],
boxSize
[
0
]);
deltaR
[
XIndex
]
=
periodicDifference
(
atomCoordinatesJ
[
0
],
atomCoordinatesI
[
0
],
boxSize
[
0
]);
deltaR
[
YIndex
]
=
periodicDifference
(
atomCoordinatesJ
[
1
],
atomCoordinatesI
[
1
],
boxSize
[
1
]);
deltaR
[
YIndex
]
=
periodicDifference
(
atomCoordinatesJ
[
1
],
atomCoordinatesI
[
1
],
boxSize
[
1
]);
deltaR
[
ZIndex
]
=
periodicDifference
(
atomCoordinatesJ
[
2
],
atomCoordinatesI
[
2
],
boxSize
[
2
]);
deltaR
[
ZIndex
]
=
periodicDifference
(
atomCoordinatesJ
[
2
],
atomCoordinatesI
[
2
],
boxSize
[
2
]);
deltaR
[
R2Index
]
=
DOT3
(
deltaR
,
deltaR
);
deltaR
[
R2Index
]
=
DOT3
(
deltaR
,
deltaR
);
deltaR
[
RIndex
]
=
(
RealOpenMM
)
SQRT
(
deltaR
[
R2Index
]
);
deltaR
[
RIndex
]
=
(
RealOpenMM
)
SQRT
(
deltaR
[
R2Index
]);
}
}
void
ReferenceForce
::
getDeltaRPeriodic
(
const
RealVec
&
atomCoordinatesI
,
const
RealVec
&
atomCoordinatesJ
,
void
ReferenceForce
::
getDeltaRPeriodic
(
const
RealVec
&
atomCoordinatesI
,
const
RealVec
&
atomCoordinatesJ
,
const
RealVec
*
boxVectors
,
RealOpenMM
*
deltaR
){
const
RealVec
*
boxVectors
,
RealOpenMM
*
deltaR
)
{
RealVec
diff
=
atomCoordinatesJ
-
atomCoordinatesI
;
RealVec
diff
=
atomCoordinatesJ
-
atomCoordinatesI
;
diff
-=
boxVectors
[
2
]
*
floor
(
diff
[
2
]
/
boxVectors
[
2
][
2
]
+
0.5
);
diff
-=
boxVectors
[
2
]
*
floor
(
diff
[
2
]
/
boxVectors
[
2
][
2
]
+
0.5
);
diff
-=
boxVectors
[
1
]
*
floor
(
diff
[
1
]
/
boxVectors
[
1
][
1
]
+
0.5
);
diff
-=
boxVectors
[
1
]
*
floor
(
diff
[
1
]
/
boxVectors
[
1
][
1
]
+
0.5
);
...
...
platforms/reference/src/
gbsa/Cpu
GBVI.cpp
→
platforms/reference/src/
SimTKReference/Reference
GBVI.cpp
View file @
162d69a2
...
@@ -26,32 +26,31 @@
...
@@ -26,32 +26,31 @@
#include <sstream>
#include <sstream>
#include <stdio.h>
#include <stdio.h>
#include "SimTKOpenMMCommon.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
#include "
Cpu
GBVI.h"
#include "
Reference
GBVI.h"
using
namespace
std
;
using
namespace
std
;
using
namespace
OpenMM
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Cpu
GBVI constructor
Reference
GBVI constructor
gbviParameters gbviParameters object
gbviParameters gbviParameters object
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
CpuGBVI
::
Cpu
GBVI
(
GBVIParameters
*
gbviParameters
)
:
_gbviParameters
(
gbviParameters
)
{
ReferenceGBVI
::
Reference
GBVI
(
GBVIParameters
*
gbviParameters
)
:
_gbviParameters
(
gbviParameters
)
{
_switchDeriviative
.
resize
(
gbviParameters
->
getNumberOfAtoms
()
);
_switchDeriviative
.
resize
(
gbviParameters
->
getNumberOfAtoms
());
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Cpu
GBVI destructor
Reference
GBVI destructor
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
CpuGBVI
::~
Cpu
GBVI
(
){
ReferenceGBVI
::~
Reference
GBVI
()
{
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -62,7 +61,7 @@ CpuGBVI::~CpuGBVI( ){
...
@@ -62,7 +61,7 @@ CpuGBVI::~CpuGBVI( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
GBVIParameters
*
Cpu
GBVI
::
getGBVIParameters
(
void
)
const
{
GBVIParameters
*
Reference
GBVI
::
getGBVIParameters
()
const
{
return
_gbviParameters
;
return
_gbviParameters
;
}
}
...
@@ -74,7 +73,7 @@ GBVIParameters* CpuGBVI::getGBVIParameters( void ) const {
...
@@ -74,7 +73,7 @@ GBVIParameters* CpuGBVI::getGBVIParameters( void ) const {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
Cpu
GBVI
::
setGBVIParameters
(
GBVIParameters
*
gbviParameters
){
void
Reference
GBVI
::
setGBVIParameters
(
GBVIParameters
*
gbviParameters
)
{
_gbviParameters
=
gbviParameters
;
_gbviParameters
=
gbviParameters
;
}
}
...
@@ -86,7 +85,7 @@ void CpuGBVI::setGBVIParameters( GBVIParameters* gbviParameters ){
...
@@ -86,7 +85,7 @@ void CpuGBVI::setGBVIParameters( GBVIParameters* gbviParameters ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
Vector
&
Cpu
GBVI
::
getSwitchDeriviative
(
void
){
vector
<
RealOpenMM
>&
Reference
GBVI
::
getSwitchDeriviative
()
{
return
_switchDeriviative
;
return
_switchDeriviative
;
}
}
...
@@ -102,17 +101,17 @@ RealOpenMMVector& CpuGBVI::getSwitchDeriviative( void ){
...
@@ -102,17 +101,17 @@ RealOpenMMVector& CpuGBVI::getSwitchDeriviative( void ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
Cpu
GBVI
::
quinticSpline
(
RealOpenMM
x
,
RealOpenMM
rl
,
RealOpenMM
ru
,
void
Reference
GBVI
::
quinticSpline
(
RealOpenMM
x
,
RealOpenMM
rl
,
RealOpenMM
ru
,
RealOpenMM
*
outValue
,
RealOpenMM
*
outDerivative
){
RealOpenMM
*
outValue
,
RealOpenMM
*
outDerivative
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
minusSix
=
static_cast
<
RealOpenMM
>
(
-
6.0
);
static
const
RealOpenMM
minusSix
=
static_cast
<
RealOpenMM
>
(
-
6.0
);
static
const
RealOpenMM
minusTen
=
static_cast
<
RealOpenMM
>
(
-
10.0
);
static
const
RealOpenMM
minusTen
=
static_cast
<
RealOpenMM
>
(
-
10.0
);
static
const
RealOpenMM
minusThirty
=
static_cast
<
RealOpenMM
>
(
-
30.0
);
static
const
RealOpenMM
minusThirty
=
static_cast
<
RealOpenMM
>
(
-
30.0
);
static
const
RealOpenMM
fifteen
=
static_cast
<
RealOpenMM
>
(
15.0
);
static
const
RealOpenMM
fifteen
=
static_cast
<
RealOpenMM
>
(
15.0
);
static
const
RealOpenMM
sixty
=
static_cast
<
RealOpenMM
>
(
60.0
);
static
const
RealOpenMM
sixty
=
static_cast
<
RealOpenMM
>
(
60.0
);
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -140,19 +139,19 @@ void CpuGBVI::quinticSpline( RealOpenMM x, RealOpenMM rl, RealOpenMM ru,
...
@@ -140,19 +139,19 @@ void CpuGBVI::quinticSpline( RealOpenMM x, RealOpenMM rl, RealOpenMM ru,
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
Cpu
GBVI
::
computeBornRadiiUsingQuinticSpline
(
RealOpenMM
atomicRadius3
,
RealOpenMM
bornSum
,
void
Reference
GBVI
::
computeBornRadiiUsingQuinticSpline
(
RealOpenMM
atomicRadius3
,
RealOpenMM
bornSum
,
GBVIParameters
*
gbviParameters
,
GBVIParameters
*
gbviParameters
,
RealOpenMM
*
bornRadius
,
RealOpenMM
*
switchDeriviative
){
RealOpenMM
*
bornRadius
,
RealOpenMM
*
switchDeriviative
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
static
const
RealOpenMM
zero
=
static_cast
<
RealOpenMM
>
(
0.0
);
static
const
RealOpenMM
zero
=
static_cast
<
RealOpenMM
>
(
0.0
);
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
minusOne
=
static_cast
<
RealOpenMM
>
(
-
1.0
);
static
const
RealOpenMM
minusOne
=
static_cast
<
RealOpenMM
>
(
-
1.0
);
static
const
RealOpenMM
minusThree
=
static_cast
<
RealOpenMM
>
(
-
3.0
);
static
const
RealOpenMM
minusThree
=
static_cast
<
RealOpenMM
>
(
-
3.0
);
static
const
RealOpenMM
oneEighth
=
static_cast
<
RealOpenMM
>
(
0.125
);
static
const
RealOpenMM
oneEighth
=
static_cast
<
RealOpenMM
>
(
0.125
);
static
const
RealOpenMM
minusOneThird
=
static_cast
<
RealOpenMM
>
(
(
-
1.0
/
3.0
)
);
static
const
RealOpenMM
minusOneThird
=
static_cast
<
RealOpenMM
>
((
-
1.0
/
3.0
));
static
const
RealOpenMM
three
=
static_cast
<
RealOpenMM
>
(
3.0
);
static
const
RealOpenMM
three
=
static_cast
<
RealOpenMM
>
(
3.0
);
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -176,10 +175,10 @@ void CpuGBVI::computeBornRadiiUsingQuinticSpline( RealOpenMM atomicRadius3, Real
...
@@ -176,10 +175,10 @@ void CpuGBVI::computeBornRadiiUsingQuinticSpline( RealOpenMM atomicRadius3, Real
RealOpenMM
splineL
=
gbviParameters
->
getQuinticLowerLimitFactor
()
*
atomicRadius3
;
RealOpenMM
splineL
=
gbviParameters
->
getQuinticLowerLimitFactor
()
*
atomicRadius3
;
RealOpenMM
sum
;
RealOpenMM
sum
;
if
(
bornSum
>
splineL
){
if
(
bornSum
>
splineL
)
{
if
(
bornSum
<
atomicRadius3
){
if
(
bornSum
<
atomicRadius3
)
{
RealOpenMM
splineValue
,
splineDerivative
;
RealOpenMM
splineValue
,
splineDerivative
;
quinticSpline
(
bornSum
,
splineL
,
atomicRadius3
,
&
splineValue
,
&
splineDerivative
);
quinticSpline
(
bornSum
,
splineL
,
atomicRadius3
,
&
splineValue
,
&
splineDerivative
);
sum
=
(
atomicRadius3
-
bornSum
)
*
splineValue
+
gbviParameters
->
getQuinticUpperBornRadiusLimit
();
sum
=
(
atomicRadius3
-
bornSum
)
*
splineValue
+
gbviParameters
->
getQuinticUpperBornRadiusLimit
();
*
switchDeriviative
=
splineValue
-
(
atomicRadius3
-
bornSum
)
*
splineDerivative
;
*
switchDeriviative
=
splineValue
-
(
atomicRadius3
-
bornSum
)
*
splineDerivative
;
}
else
{
}
else
{
...
@@ -190,7 +189,7 @@ void CpuGBVI::computeBornRadiiUsingQuinticSpline( RealOpenMM atomicRadius3, Real
...
@@ -190,7 +189,7 @@ void CpuGBVI::computeBornRadiiUsingQuinticSpline( RealOpenMM atomicRadius3, Real
sum
=
atomicRadius3
-
bornSum
;
sum
=
atomicRadius3
-
bornSum
;
*
switchDeriviative
=
one
;
*
switchDeriviative
=
one
;
}
}
*
bornRadius
=
POW
(
sum
,
minusOneThird
);
*
bornRadius
=
POW
(
sum
,
minusOneThird
);
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -203,66 +202,66 @@ void CpuGBVI::computeBornRadiiUsingQuinticSpline( RealOpenMM atomicRadius3, Real
...
@@ -203,66 +202,66 @@ void CpuGBVI::computeBornRadiiUsingQuinticSpline( RealOpenMM atomicRadius3, Real
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
Cpu
GBVI
::
computeBornRadii
(
const
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
Vector
&
bornRadii
){
void
Reference
GBVI
::
computeBornRadii
(
const
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealOpenMM
>
&
bornRadii
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
static
const
RealOpenMM
zero
=
static_cast
<
RealOpenMM
>
(
0.0
);
static
const
RealOpenMM
zero
=
static_cast
<
RealOpenMM
>
(
0.0
);
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
minusThree
=
static_cast
<
RealOpenMM
>
(
-
3.0
);
static
const
RealOpenMM
minusThree
=
static_cast
<
RealOpenMM
>
(
-
3.0
);
static
const
RealOpenMM
oneEighth
=
static_cast
<
RealOpenMM
>
(
0.125
);
static
const
RealOpenMM
oneEighth
=
static_cast
<
RealOpenMM
>
(
0.125
);
static
const
RealOpenMM
minusOneThird
=
static_cast
<
RealOpenMM
>
(
(
-
1.0
/
3.0
)
);
static
const
RealOpenMM
minusOneThird
=
static_cast
<
RealOpenMM
>
((
-
1.0
/
3.0
));
static
const
RealOpenMM
three
=
static_cast
<
RealOpenMM
>
(
3.0
);
static
const
RealOpenMM
three
=
static_cast
<
RealOpenMM
>
(
3.0
);
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
GBVIParameters
*
gbviParameters
=
getGBVIParameters
();
GBVIParameters
*
gbviParameters
=
getGBVIParameters
();
int
numberOfAtoms
=
gbviParameters
->
getNumberOfAtoms
();
int
numberOfAtoms
=
gbviParameters
->
getNumberOfAtoms
();
const
RealOpenMM
Vector
&
atomicRadii
=
gbviParameters
->
getAtomicRadii
();
const
vector
<
RealOpenMM
>
&
atomicRadii
=
gbviParameters
->
getAtomicRadii
();
const
RealOpenMM
Vector
&
scaledRadii
=
gbviParameters
->
getScaledRadii
();
const
vector
<
RealOpenMM
>
&
scaledRadii
=
gbviParameters
->
getScaledRadii
();
RealOpenMM
Vector
&
switchDeriviatives
=
getSwitchDeriviative
();
vector
<
RealOpenMM
>
&
switchDeriviatives
=
getSwitchDeriviative
();
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// calculate Born radii
// calculate Born radii
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
){
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
)
{
RealOpenMM
radiusI
=
atomicRadii
[
atomI
];
RealOpenMM
radiusI
=
atomicRadii
[
atomI
];
RealOpenMM
sum
=
zero
;
RealOpenMM
sum
=
zero
;
// sum over volumes
// sum over volumes
for
(
int
atomJ
=
0
;
atomJ
<
numberOfAtoms
;
atomJ
++
){
for
(
int
atomJ
=
0
;
atomJ
<
numberOfAtoms
;
atomJ
++
)
{
if
(
atomJ
!=
atomI
){
if
(
atomJ
!=
atomI
)
{
RealOpenMM
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
RealOpenMM
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
if
(
_gbviParameters
->
getPeriodic
())
if
(
_gbviParameters
->
getPeriodic
())
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
_gbviParameters
->
getPeriodicBox
(),
deltaR
);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
_gbviParameters
->
getPeriodicBox
(),
deltaR
);
else
else
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
deltaR
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
deltaR
);
RealOpenMM
r
=
deltaR
[
ReferenceForce
::
RIndex
];
RealOpenMM
r
=
deltaR
[
ReferenceForce
::
RIndex
];
if
(
_gbviParameters
->
getUseCutoff
()
&&
r
>
_gbviParameters
->
getCutoffDistance
())
if
(
_gbviParameters
->
getUseCutoff
()
&&
r
>
_gbviParameters
->
getCutoffDistance
())
continue
;
continue
;
sum
+=
Cpu
GBVI
::
getVolume
(
r
,
radiusI
,
scaledRadii
[
atomJ
]
);
sum
+=
Reference
GBVI
::
getVolume
(
r
,
radiusI
,
scaledRadii
[
atomJ
]);
}
}
}
}
RealOpenMM
atomicRadius3
=
POW
(
radiusI
,
minusThree
);
RealOpenMM
atomicRadius3
=
POW
(
radiusI
,
minusThree
);
if
(
_gbviParameters
->
getBornRadiusScalingMethod
()
!=
GBVIParameters
::
QuinticSpline
){
if
(
_gbviParameters
->
getBornRadiusScalingMethod
()
!=
GBVIParameters
::
QuinticSpline
)
{
sum
=
atomicRadius3
-
sum
;
sum
=
atomicRadius3
-
sum
;
bornRadii
[
atomI
]
=
POW
(
sum
,
minusOneThird
);
bornRadii
[
atomI
]
=
POW
(
sum
,
minusOneThird
);
switchDeriviatives
[
atomI
]
=
one
;
switchDeriviatives
[
atomI
]
=
one
;
}
else
{
}
else
{
RealOpenMM
bornRadius
,
switchDeriviative
;
RealOpenMM
bornRadius
,
switchDeriviative
;
computeBornRadiiUsingQuinticSpline
(
atomicRadius3
,
sum
,
gbviParameters
,
computeBornRadiiUsingQuinticSpline
(
atomicRadius3
,
sum
,
gbviParameters
,
&
bornRadius
,
&
switchDeriviative
);
&
bornRadius
,
&
switchDeriviative
);
bornRadii
[
atomI
]
=
bornRadius
;
bornRadii
[
atomI
]
=
bornRadius
;
switchDeriviatives
[
atomI
]
=
switchDeriviative
;
switchDeriviatives
[
atomI
]
=
switchDeriviative
;
}
}
...
@@ -281,25 +280,25 @@ void CpuGBVI::computeBornRadii( const vector<RealVec>& atomCoordinates, RealOpen
...
@@ -281,25 +280,25 @@ void CpuGBVI::computeBornRadii( const vector<RealVec>& atomCoordinates, RealOpen
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
Cpu
GBVI
::
getVolume
(
RealOpenMM
r
,
RealOpenMM
R
,
RealOpenMM
S
){
RealOpenMM
Reference
GBVI
::
getVolume
(
RealOpenMM
r
,
RealOpenMM
R
,
RealOpenMM
S
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
static
const
RealOpenMM
zero
=
static_cast
<
RealOpenMM
>
(
0.0
);
static
const
RealOpenMM
zero
=
static_cast
<
RealOpenMM
>
(
0.0
);
static
const
RealOpenMM
minusThree
=
static_cast
<
RealOpenMM
>
(
-
3.0
);
static
const
RealOpenMM
minusThree
=
static_cast
<
RealOpenMM
>
(
-
3.0
);
RealOpenMM
diff
=
(
S
-
R
);
RealOpenMM
diff
=
(
S
-
R
);
if
(
FABS
(
diff
)
<
r
){
if
(
FABS
(
diff
)
<
r
)
{
RealOpenMM
lowerBound
=
(
R
>
(
r
-
S
))
?
R
:
(
r
-
S
);
RealOpenMM
lowerBound
=
(
R
>
(
r
-
S
))
?
R
:
(
r
-
S
);
return
(
Cpu
GBVI
::
getL
(
r
,
(
r
+
S
),
S
)
-
return
(
Reference
GBVI
::
getL
(
r
,
(
r
+
S
),
S
)
-
Cpu
GBVI
::
getL
(
r
,
lowerBound
,
S
));
Reference
GBVI
::
getL
(
r
,
lowerBound
,
S
));
}
else
if
(
r
<=
diff
){
}
else
if
(
r
<=
diff
)
{
return
Cpu
GBVI
::
getL
(
r
,
(
r
+
S
),
S
)
-
return
Reference
GBVI
::
getL
(
r
,
(
r
+
S
),
S
)
-
Cpu
GBVI
::
getL
(
r
,
(
r
-
S
),
S
)
+
Reference
GBVI
::
getL
(
r
,
(
r
-
S
),
S
)
+
POW
(
R
,
minusThree
);
POW
(
R
,
minusThree
);
}
else
{
}
else
{
return
zero
;
return
zero
;
...
@@ -318,15 +317,15 @@ RealOpenMM CpuGBVI::getVolume( RealOpenMM r, RealOpenMM R, RealOpenMM S ){
...
@@ -318,15 +317,15 @@ RealOpenMM CpuGBVI::getVolume( RealOpenMM r, RealOpenMM R, RealOpenMM S ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
Cpu
GBVI
::
getL
(
RealOpenMM
r
,
RealOpenMM
x
,
RealOpenMM
S
){
RealOpenMM
Reference
GBVI
::
getL
(
RealOpenMM
r
,
RealOpenMM
x
,
RealOpenMM
S
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
threeHalves
=
static_cast
<
RealOpenMM
>
(
1.5
);
static
const
RealOpenMM
threeHalves
=
static_cast
<
RealOpenMM
>
(
1.5
);
static
const
RealOpenMM
third
=
static_cast
<
RealOpenMM
>
(
(
1.0
/
3.0
)
);
static
const
RealOpenMM
third
=
static_cast
<
RealOpenMM
>
((
1.0
/
3.0
));
static
const
RealOpenMM
fourth
=
static_cast
<
RealOpenMM
>
(
0.25
);
static
const
RealOpenMM
fourth
=
static_cast
<
RealOpenMM
>
(
0.25
);
static
const
RealOpenMM
eighth
=
static_cast
<
RealOpenMM
>
(
0.125
);
static
const
RealOpenMM
eighth
=
static_cast
<
RealOpenMM
>
(
0.125
);
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -338,7 +337,7 @@ RealOpenMM CpuGBVI::getL( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
...
@@ -338,7 +337,7 @@ RealOpenMM CpuGBVI::getL( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
RealOpenMM
diff2
=
(
r
+
S
)
*
(
r
-
S
);
RealOpenMM
diff2
=
(
r
+
S
)
*
(
r
-
S
);
return
(
threeHalves
*
xInv
)
*
(
(
xInv
*
fourth
*
rInv
)
-
(
xInv2
*
third
)
+
(
diff2
*
xInv3
*
eighth
*
rInv
)
);
return
(
threeHalves
*
xInv
)
*
((
xInv
*
fourth
*
rInv
)
-
(
xInv2
*
third
)
+
(
diff2
*
xInv3
*
eighth
*
rInv
));
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -353,16 +352,16 @@ RealOpenMM CpuGBVI::getL( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
...
@@ -353,16 +352,16 @@ RealOpenMM CpuGBVI::getL( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
Cpu
GBVI
::
dL_dr
(
RealOpenMM
r
,
RealOpenMM
x
,
RealOpenMM
S
){
RealOpenMM
Reference
GBVI
::
dL_dr
(
RealOpenMM
r
,
RealOpenMM
x
,
RealOpenMM
S
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
threeHalves
=
static_cast
<
RealOpenMM
>
(
1.5
);
static
const
RealOpenMM
threeHalves
=
static_cast
<
RealOpenMM
>
(
1.5
);
static
const
RealOpenMM
threeEights
=
static_cast
<
RealOpenMM
>
(
0.375
);
static
const
RealOpenMM
threeEights
=
static_cast
<
RealOpenMM
>
(
0.375
);
static
const
RealOpenMM
third
=
static_cast
<
RealOpenMM
>
(
(
1.0
/
3.0
)
);
static
const
RealOpenMM
third
=
static_cast
<
RealOpenMM
>
((
1.0
/
3.0
));
static
const
RealOpenMM
fourth
=
static_cast
<
RealOpenMM
>
(
0.25
);
static
const
RealOpenMM
fourth
=
static_cast
<
RealOpenMM
>
(
0.25
);
static
const
RealOpenMM
eighth
=
static_cast
<
RealOpenMM
>
(
0.125
);
static
const
RealOpenMM
eighth
=
static_cast
<
RealOpenMM
>
(
0.125
);
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -375,7 +374,7 @@ RealOpenMM CpuGBVI::dL_dr( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
...
@@ -375,7 +374,7 @@ RealOpenMM CpuGBVI::dL_dr( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
RealOpenMM
diff2
=
(
r
+
S
)
*
(
r
-
S
);
RealOpenMM
diff2
=
(
r
+
S
)
*
(
r
-
S
);
return
(
(
-
threeHalves
*
xInv2
*
rInv2
)
*
(
fourth
+
eighth
*
diff2
*
xInv2
)
+
threeEights
*
xInv3
*
xInv
);
return
((
-
threeHalves
*
xInv2
*
rInv2
)
*
(
fourth
+
eighth
*
diff2
*
xInv2
)
+
threeEights
*
xInv3
*
xInv
);
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -390,14 +389,14 @@ RealOpenMM CpuGBVI::dL_dr( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
...
@@ -390,14 +389,14 @@ RealOpenMM CpuGBVI::dL_dr( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
Cpu
GBVI
::
dL_dx
(
RealOpenMM
r
,
RealOpenMM
x
,
RealOpenMM
S
){
RealOpenMM
Reference
GBVI
::
dL_dx
(
RealOpenMM
r
,
RealOpenMM
x
,
RealOpenMM
S
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
half
=
static_cast
<
RealOpenMM
>
(
0.5
);
static
const
RealOpenMM
half
=
static_cast
<
RealOpenMM
>
(
0.5
);
static
const
RealOpenMM
threeHalvesM
=
static_cast
<
RealOpenMM
>
(
-
1.5
);
static
const
RealOpenMM
threeHalvesM
=
static_cast
<
RealOpenMM
>
(
-
1.5
);
static
const
RealOpenMM
third
=
static_cast
<
RealOpenMM
>
(
(
1.0
/
3.0
)
);
static
const
RealOpenMM
third
=
static_cast
<
RealOpenMM
>
(
(
1.0
/
3.0
));
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -409,7 +408,7 @@ RealOpenMM CpuGBVI::dL_dx( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
...
@@ -409,7 +408,7 @@ RealOpenMM CpuGBVI::dL_dx( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
RealOpenMM
diff
=
(
r
+
S
)
*
(
r
-
S
);
RealOpenMM
diff
=
(
r
+
S
)
*
(
r
-
S
);
return
(
threeHalvesM
*
xInv3
)
*
(
(
half
*
rInv
)
-
xInv
+
(
half
*
diff
*
xInv2
*
rInv
)
);
return
(
threeHalvesM
*
xInv3
)
*
((
half
*
rInv
)
-
xInv
+
(
half
*
diff
*
xInv2
*
rInv
));
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -422,19 +421,19 @@ RealOpenMM CpuGBVI::dL_dx( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
...
@@ -422,19 +421,19 @@ RealOpenMM CpuGBVI::dL_dx( RealOpenMM r, RealOpenMM x, RealOpenMM S ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
Cpu
GBVI
::
Sgb
(
RealOpenMM
t
){
RealOpenMM
Reference
GBVI
::
Sgb
(
RealOpenMM
t
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// static const char* methodName = "
Cpu
GBVI::Sgb";
// static const char* methodName = "
Reference
GBVI::Sgb";
static
const
RealOpenMM
zero
=
static_cast
<
RealOpenMM
>
(
0.0
);
static
const
RealOpenMM
zero
=
static_cast
<
RealOpenMM
>
(
0.0
);
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
fourth
=
static_cast
<
RealOpenMM
>
(
0.25
);
static
const
RealOpenMM
fourth
=
static_cast
<
RealOpenMM
>
(
0.25
);
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
return
(
(
t
!=
zero
)
?
one
/
SQRT
(
(
one
+
(
fourth
*
EXP
(
-
t
))
/
t
)
)
:
zero
);
return
((
t
!=
zero
)
?
one
/
SQRT
((
one
+
(
fourth
*
EXP
(
-
t
))
/
t
))
:
zero
);
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -448,31 +447,31 @@ RealOpenMM CpuGBVI::Sgb( RealOpenMM t ){
...
@@ -448,31 +447,31 @@ RealOpenMM CpuGBVI::Sgb( RealOpenMM t ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
Cpu
GBVI
::
computeBornEnergy
(
const
vector
<
RealVec
>&
atomCoordinates
,
const
RealOpenMM
Vector
&
partialCharges
){
RealOpenMM
Reference
GBVI
::
computeBornEnergy
(
const
vector
<
RealVec
>&
atomCoordinates
,
const
vector
<
RealOpenMM
>
&
partialCharges
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
static
const
RealOpenMM
zero
=
static_cast
<
RealOpenMM
>
(
0.0
);
static
const
RealOpenMM
zero
=
static_cast
<
RealOpenMM
>
(
0.0
);
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
two
=
static_cast
<
RealOpenMM
>
(
2.0
);
static
const
RealOpenMM
two
=
static_cast
<
RealOpenMM
>
(
2.0
);
static
const
RealOpenMM
three
=
static_cast
<
RealOpenMM
>
(
3.0
);
static
const
RealOpenMM
three
=
static_cast
<
RealOpenMM
>
(
3.0
);
static
const
RealOpenMM
four
=
static_cast
<
RealOpenMM
>
(
4.0
);
static
const
RealOpenMM
four
=
static_cast
<
RealOpenMM
>
(
4.0
);
static
const
RealOpenMM
half
=
static_cast
<
RealOpenMM
>
(
0.5
);
static
const
RealOpenMM
half
=
static_cast
<
RealOpenMM
>
(
0.5
);
static
const
RealOpenMM
fourth
=
static_cast
<
RealOpenMM
>
(
0.25
);
static
const
RealOpenMM
fourth
=
static_cast
<
RealOpenMM
>
(
0.25
);
static
const
RealOpenMM
eighth
=
static_cast
<
RealOpenMM
>
(
0.125
);
static
const
RealOpenMM
eighth
=
static_cast
<
RealOpenMM
>
(
0.125
);
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
const
GBVIParameters
*
gbviParameters
=
getGBVIParameters
();
const
GBVIParameters
*
gbviParameters
=
getGBVIParameters
();
const
RealOpenMM
preFactor
=
gbviParameters
->
getElectricConstant
();
const
RealOpenMM
preFactor
=
gbviParameters
->
getElectricConstant
();
const
int
numberOfAtoms
=
gbviParameters
->
getNumberOfAtoms
();
const
int
numberOfAtoms
=
gbviParameters
->
getNumberOfAtoms
();
const
RealOpenMM
Vector
&
atomicRadii
=
gbviParameters
->
getAtomicRadii
();
const
vector
<
RealOpenMM
>
&
atomicRadii
=
gbviParameters
->
getAtomicRadii
();
const
RealOpenMM
Vector
&
gammaParameters
=
gbviParameters
->
getGammaParameters
();
const
vector
<
RealOpenMM
>
&
gammaParameters
=
gbviParameters
->
getGammaParameters
();
// compute Born radii
// compute Born radii
RealOpenMM
Vector
bornRadii
(
numberOfAtoms
);
vector
<
RealOpenMM
>
bornRadii
(
numberOfAtoms
);
computeBornRadii
(
atomCoordinates
,
bornRadii
);
computeBornRadii
(
atomCoordinates
,
bornRadii
);
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -483,7 +482,7 @@ RealOpenMM CpuGBVI::computeBornEnergy( const vector<RealVec>& atomCoordinates, c
...
@@ -483,7 +482,7 @@ RealOpenMM CpuGBVI::computeBornEnergy( const vector<RealVec>& atomCoordinates, c
RealOpenMM
energy
=
zero
;
RealOpenMM
energy
=
zero
;
RealOpenMM
cavityEnergy
=
zero
;
RealOpenMM
cavityEnergy
=
zero
;
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
){
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
)
{
RealOpenMM
partialChargeI
=
partialCharges
[
atomI
];
RealOpenMM
partialChargeI
=
partialCharges
[
atomI
];
...
@@ -496,19 +495,19 @@ RealOpenMM CpuGBVI::computeBornEnergy( const vector<RealVec>& atomCoordinates, c
...
@@ -496,19 +495,19 @@ RealOpenMM CpuGBVI::computeBornEnergy( const vector<RealVec>& atomCoordinates, c
RealOpenMM
ratio
=
(
atomicRadii
[
atomI
]
/
bornRadii
[
atomI
]);
RealOpenMM
ratio
=
(
atomicRadii
[
atomI
]
/
bornRadii
[
atomI
]);
cavityEnergy
+=
gammaParameters
[
atomI
]
*
ratio
*
ratio
*
ratio
;
cavityEnergy
+=
gammaParameters
[
atomI
]
*
ratio
*
ratio
*
ratio
;
for
(
int
atomJ
=
atomI
+
1
;
atomJ
<
numberOfAtoms
;
atomJ
++
){
for
(
int
atomJ
=
atomI
+
1
;
atomJ
<
numberOfAtoms
;
atomJ
++
)
{
RealOpenMM
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
RealOpenMM
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
if
(
_gbviParameters
->
getPeriodic
())
if
(
_gbviParameters
->
getPeriodic
())
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
_gbviParameters
->
getPeriodicBox
(),
deltaR
);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
_gbviParameters
->
getPeriodicBox
(),
deltaR
);
else
else
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
deltaR
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
deltaR
);
if
(
_gbviParameters
->
getUseCutoff
()
&&
deltaR
[
ReferenceForce
::
RIndex
]
>
_gbviParameters
->
getCutoffDistance
())
if
(
_gbviParameters
->
getUseCutoff
()
&&
deltaR
[
ReferenceForce
::
RIndex
]
>
_gbviParameters
->
getCutoffDistance
())
continue
;
continue
;
RealOpenMM
r2
=
deltaR
[
ReferenceForce
::
R2Index
];
RealOpenMM
r2
=
deltaR
[
ReferenceForce
::
R2Index
];
RealOpenMM
t
=
fourth
*
r2
/
(
bornRadii
[
atomI
]
*
bornRadii
[
atomJ
]);
RealOpenMM
t
=
fourth
*
r2
/
(
bornRadii
[
atomI
]
*
bornRadii
[
atomJ
]);
atomIEnergy
+=
partialCharges
[
atomJ
]
*
Sgb
(
t
)
/
deltaR
[
ReferenceForce
::
RIndex
];
atomIEnergy
+=
partialCharges
[
atomJ
]
*
Sgb
(
t
)
/
deltaR
[
ReferenceForce
::
RIndex
];
}
}
energy
+=
two
*
partialChargeI
*
atomIEnergy
;
energy
+=
two
*
partialChargeI
*
atomIEnergy
;
...
@@ -532,27 +531,27 @@ RealOpenMM CpuGBVI::computeBornEnergy( const vector<RealVec>& atomCoordinates, c
...
@@ -532,27 +531,27 @@ RealOpenMM CpuGBVI::computeBornEnergy( const vector<RealVec>& atomCoordinates, c
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
Cpu
GBVI
::
computeBornForces
(
std
::
vector
<
RealVec
>&
atomCoordinates
,
const
RealOpenMM
Vector
&
partialCharges
,
void
Reference
GBVI
::
computeBornForces
(
std
::
vector
<
RealVec
>&
atomCoordinates
,
const
vector
<
RealOpenMM
>
&
partialCharges
,
std
::
vector
<
OpenMM
::
RealVec
>&
inputForces
){
std
::
vector
<
OpenMM
::
RealVec
>&
inputForces
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
static
const
RealOpenMM
zero
=
static_cast
<
RealOpenMM
>
(
0.0
);
static
const
RealOpenMM
zero
=
static_cast
<
RealOpenMM
>
(
0.0
);
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
one
=
static_cast
<
RealOpenMM
>
(
1.0
);
static
const
RealOpenMM
two
=
static_cast
<
RealOpenMM
>
(
2.0
);
static
const
RealOpenMM
two
=
static_cast
<
RealOpenMM
>
(
2.0
);
static
const
RealOpenMM
three
=
static_cast
<
RealOpenMM
>
(
3.0
);
static
const
RealOpenMM
three
=
static_cast
<
RealOpenMM
>
(
3.0
);
static
const
RealOpenMM
four
=
static_cast
<
RealOpenMM
>
(
4.0
);
static
const
RealOpenMM
four
=
static_cast
<
RealOpenMM
>
(
4.0
);
static
const
RealOpenMM
half
=
static_cast
<
RealOpenMM
>
(
0.5
);
static
const
RealOpenMM
half
=
static_cast
<
RealOpenMM
>
(
0.5
);
static
const
RealOpenMM
oneThird
=
static_cast
<
RealOpenMM
>
(
(
1.0
/
3.0
)
);
static
const
RealOpenMM
oneThird
=
static_cast
<
RealOpenMM
>
((
1.0
/
3.0
));
static
const
RealOpenMM
fourth
=
static_cast
<
RealOpenMM
>
(
0.25
);
static
const
RealOpenMM
fourth
=
static_cast
<
RealOpenMM
>
(
0.25
);
static
const
RealOpenMM
eighth
=
static_cast
<
RealOpenMM
>
(
0.125
);
static
const
RealOpenMM
eighth
=
static_cast
<
RealOpenMM
>
(
0.125
);
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
const
GBVIParameters
*
gbviParameters
=
getGBVIParameters
();
const
GBVIParameters
*
gbviParameters
=
getGBVIParameters
();
const
int
numberOfAtoms
=
gbviParameters
->
getNumberOfAtoms
();
const
int
numberOfAtoms
=
gbviParameters
->
getNumberOfAtoms
();
const
RealOpenMM
Vector
&
atomicRadii
=
gbviParameters
->
getAtomicRadii
();
const
vector
<
RealOpenMM
>
&
atomicRadii
=
gbviParameters
->
getAtomicRadii
();
const
RealOpenMM
Vector
&
gammaParameters
=
gbviParameters
->
getGammaParameters
();
const
vector
<
RealOpenMM
>
&
gammaParameters
=
gbviParameters
->
getGammaParameters
();
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -564,37 +563,37 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
...
@@ -564,37 +563,37 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
// compute Born radii
// compute Born radii
RealOpenMM
Vector
bornRadii
(
numberOfAtoms
);
vector
<
RealOpenMM
>
bornRadii
(
numberOfAtoms
);
computeBornRadii
(
atomCoordinates
,
bornRadii
);
computeBornRadii
(
atomCoordinates
,
bornRadii
);
// set energy/forces to zero
// set energy/forces to zero
std
::
vector
<
OpenMM
::
RealVec
>
forces
(
numberOfAtoms
);
std
::
vector
<
OpenMM
::
RealVec
>
forces
(
numberOfAtoms
);
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
)
{
forces
[
ii
][
0
]
=
zero
;
forces
[
ii
][
0
]
=
zero
;
forces
[
ii
][
1
]
=
zero
;
forces
[
ii
][
1
]
=
zero
;
forces
[
ii
][
2
]
=
zero
;
forces
[
ii
][
2
]
=
zero
;
}
}
RealOpenMM
Vector
bornForces
(
numberOfAtoms
,
0.0
);
vector
<
RealOpenMM
>
bornForces
(
numberOfAtoms
,
0.0
);
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// first main loop
// first main loop
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
){
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
)
{
// partial of polar term wrt Born radius
// partial of polar term wrt Born radius
// and (dGpol/dr)(dr/dx)
// and (dGpol/dr)(dr/dx)
RealOpenMM
partialChargeI
=
preFactor
*
partialCharges
[
atomI
];
RealOpenMM
partialChargeI
=
preFactor
*
partialCharges
[
atomI
];
for
(
int
atomJ
=
atomI
;
atomJ
<
numberOfAtoms
;
atomJ
++
){
for
(
int
atomJ
=
atomI
;
atomJ
<
numberOfAtoms
;
atomJ
++
)
{
RealOpenMM
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
RealOpenMM
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
if
(
_gbviParameters
->
getPeriodic
())
if
(
_gbviParameters
->
getPeriodic
())
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
_gbviParameters
->
getPeriodicBox
(),
deltaR
);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
_gbviParameters
->
getPeriodicBox
(),
deltaR
);
else
else
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
deltaR
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
deltaR
);
if
(
_gbviParameters
->
getUseCutoff
()
&&
deltaR
[
ReferenceForce
::
RIndex
]
>
_gbviParameters
->
getCutoffDistance
())
if
(
_gbviParameters
->
getUseCutoff
()
&&
deltaR
[
ReferenceForce
::
RIndex
]
>
_gbviParameters
->
getCutoffDistance
())
continue
;
continue
;
...
@@ -607,16 +606,16 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
...
@@ -607,16 +606,16 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
RealOpenMM
alpha2_ij
=
bornRadii
[
atomI
]
*
bornRadii
[
atomJ
];
RealOpenMM
alpha2_ij
=
bornRadii
[
atomI
]
*
bornRadii
[
atomJ
];
RealOpenMM
D_ij
=
r2
/
(
four
*
alpha2_ij
);
RealOpenMM
D_ij
=
r2
/
(
four
*
alpha2_ij
);
RealOpenMM
expTerm
=
EXP
(
-
D_ij
);
RealOpenMM
expTerm
=
EXP
(
-
D_ij
);
RealOpenMM
denominator2
=
r2
+
alpha2_ij
*
expTerm
;
RealOpenMM
denominator2
=
r2
+
alpha2_ij
*
expTerm
;
RealOpenMM
denominator
=
SQRT
(
denominator2
);
RealOpenMM
denominator
=
SQRT
(
denominator2
);
RealOpenMM
Gpol
=
(
partialChargeI
*
partialCharges
[
atomJ
])
/
denominator
;
RealOpenMM
Gpol
=
(
partialChargeI
*
partialCharges
[
atomJ
])
/
denominator
;
RealOpenMM
dGpol_dr
=
-
Gpol
*
(
one
-
fourth
*
expTerm
)
/
denominator2
;
RealOpenMM
dGpol_dr
=
-
Gpol
*
(
one
-
fourth
*
expTerm
)
/
denominator2
;
RealOpenMM
dGpol_dalpha2_ij
=
-
half
*
Gpol
*
expTerm
*
(
one
+
D_ij
)
/
denominator2
;
RealOpenMM
dGpol_dalpha2_ij
=
-
half
*
Gpol
*
expTerm
*
(
one
+
D_ij
)
/
denominator2
;
if
(
atomI
!=
atomJ
){
if
(
atomI
!=
atomJ
)
{
bornForces
[
atomJ
]
+=
dGpol_dalpha2_ij
*
bornRadii
[
atomI
];
bornForces
[
atomJ
]
+=
dGpol_dalpha2_ij
*
bornRadii
[
atomI
];
...
@@ -645,9 +644,9 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
...
@@ -645,9 +644,9 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
// dGpol/dBornRadius) = bornForces[]
// dGpol/dBornRadius) = bornForces[]
// dBornRadius/dr = (1/3)*(bR**4)*(dV/dr)
// dBornRadius/dr = (1/3)*(bR**4)*(dV/dr)
const
RealOpenMM
Vector
&
scaledRadii
=
gbviParameters
->
getScaledRadii
();
const
vector
<
RealOpenMM
>
&
scaledRadii
=
gbviParameters
->
getScaledRadii
();
const
RealOpenMM
Vector
&
switchDeriviative
=
getSwitchDeriviative
();
const
vector
<
RealOpenMM
>
&
switchDeriviative
=
getSwitchDeriviative
();
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
){
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
)
{
RealOpenMM
R
=
atomicRadii
[
atomI
];
RealOpenMM
R
=
atomicRadii
[
atomI
];
...
@@ -659,9 +658,9 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
...
@@ -659,9 +658,9 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
RealOpenMM
b2
=
bornRadii
[
atomI
]
*
bornRadii
[
atomI
];
RealOpenMM
b2
=
bornRadii
[
atomI
]
*
bornRadii
[
atomI
];
bornForces
[
atomI
]
*=
switchDeriviative
[
atomI
]
*
oneThird
*
b2
*
b2
;
bornForces
[
atomI
]
*=
switchDeriviative
[
atomI
]
*
oneThird
*
b2
*
b2
;
for
(
int
atomJ
=
0
;
atomJ
<
numberOfAtoms
;
atomJ
++
){
for
(
int
atomJ
=
0
;
atomJ
<
numberOfAtoms
;
atomJ
++
)
{
if
(
atomJ
!=
atomI
){
if
(
atomJ
!=
atomI
)
{
RealOpenMM
deltaX
=
atomCoordinates
[
atomJ
][
0
]
-
atomCoordinates
[
atomI
][
0
];
RealOpenMM
deltaX
=
atomCoordinates
[
atomJ
][
0
]
-
atomCoordinates
[
atomI
][
0
];
RealOpenMM
deltaY
=
atomCoordinates
[
atomJ
][
1
]
-
atomCoordinates
[
atomI
][
1
];
RealOpenMM
deltaY
=
atomCoordinates
[
atomJ
][
1
]
-
atomCoordinates
[
atomI
][
1
];
...
@@ -669,9 +668,9 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
...
@@ -669,9 +668,9 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
RealOpenMM
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
RealOpenMM
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
if
(
_gbviParameters
->
getPeriodic
())
if
(
_gbviParameters
->
getPeriodic
())
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
_gbviParameters
->
getPeriodicBox
(),
deltaR
);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
_gbviParameters
->
getPeriodicBox
(),
deltaR
);
else
else
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
deltaR
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
deltaR
);
if
(
_gbviParameters
->
getUseCutoff
()
&&
deltaR
[
ReferenceForce
::
RIndex
]
>
_gbviParameters
->
getCutoffDistance
())
if
(
_gbviParameters
->
getUseCutoff
()
&&
deltaR
[
ReferenceForce
::
RIndex
]
>
_gbviParameters
->
getCutoffDistance
())
continue
;
continue
;
...
@@ -680,7 +679,7 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
...
@@ -680,7 +679,7 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
deltaY
=
deltaR
[
ReferenceForce
::
YIndex
];
deltaY
=
deltaR
[
ReferenceForce
::
YIndex
];
deltaZ
=
deltaR
[
ReferenceForce
::
ZIndex
];
deltaZ
=
deltaR
[
ReferenceForce
::
ZIndex
];
RealOpenMM
r
=
SQRT
(
r2
);
RealOpenMM
r
=
SQRT
(
r2
);
RealOpenMM
S
=
scaledRadii
[
atomJ
];
RealOpenMM
S
=
scaledRadii
[
atomJ
];
RealOpenMM
diff
=
(
S
-
R
);
RealOpenMM
diff
=
(
S
-
R
);
...
@@ -689,16 +688,16 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
...
@@ -689,16 +688,16 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
// find dRb/dr, where Rb is the Born radius
// find dRb/dr, where Rb is the Born radius
if
(
FABS
(
diff
)
<
r
){
if
(
FABS
(
diff
)
<
r
)
{
de
=
Cpu
GBVI
::
dL_dr
(
r
,
r
+
S
,
S
)
+
Cpu
GBVI
::
dL_dx
(
r
,
r
+
S
,
S
);
de
=
Reference
GBVI
::
dL_dr
(
r
,
r
+
S
,
S
)
+
Reference
GBVI
::
dL_dx
(
r
,
r
+
S
,
S
);
if
(
R
>
(
r
-
S
)
){
if
(
R
>
(
r
-
S
))
{
de
-=
Cpu
GBVI
::
dL_dr
(
r
,
R
,
S
);
de
-=
Reference
GBVI
::
dL_dr
(
r
,
R
,
S
);
}
else
{
}
else
{
de
-=
(
Cpu
GBVI
::
dL_dr
(
r
,
(
r
-
S
),
S
)
+
Cpu
GBVI
::
dL_dx
(
r
,
(
r
-
S
),
S
)
);
de
-=
(
Reference
GBVI
::
dL_dr
(
r
,
(
r
-
S
),
S
)
+
Reference
GBVI
::
dL_dx
(
r
,
(
r
-
S
),
S
)
);
}
}
}
else
if
(
r
<
(
S
-
R
)
){
}
else
if
(
r
<
(
S
-
R
))
{
de
=
Cpu
GBVI
::
dL_dr
(
r
,
r
+
S
,
S
)
+
Cpu
GBVI
::
dL_dx
(
r
,
r
+
S
,
S
);
de
=
Reference
GBVI
::
dL_dr
(
r
,
r
+
S
,
S
)
+
Reference
GBVI
::
dL_dx
(
r
,
r
+
S
,
S
);
de
-=
(
Cpu
GBVI
::
dL_dr
(
r
,
r
-
S
,
S
)
+
Cpu
GBVI
::
dL_dx
(
r
,
r
-
S
,
S
)
);
de
-=
(
Reference
GBVI
::
dL_dr
(
r
,
r
-
S
,
S
)
+
Reference
GBVI
::
dL_dx
(
r
,
r
-
S
,
S
)
);
}
}
// de = (dG/dRb)(dRb/dr)
// de = (dG/dRb)(dRb/dr)
...
@@ -721,12 +720,10 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
...
@@ -721,12 +720,10 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
}
}
}
}
//printGbvi( atomCoordinates, partialCharges, bornRadii, bornForces, forces, "GBVI: Post loop2", stderr );
// convert from cal to Joule & apply prefactor tau = (1/diel_solute - 1/diel_solvent)
// convert from cal to Joule & apply prefactor tau = (1/diel_solute - 1/diel_solvent)
RealOpenMM
conversion
=
static_cast
<
RealOpenMM
>
(
gbviParameters
->
getTau
());
RealOpenMM
conversion
=
static_cast
<
RealOpenMM
>
(
gbviParameters
->
getTau
());
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
){
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
)
{
inputForces
[
atomI
][
0
]
+=
conversion
*
forces
[
atomI
][
0
];
inputForces
[
atomI
][
0
]
+=
conversion
*
forces
[
atomI
][
0
];
inputForces
[
atomI
][
1
]
+=
conversion
*
forces
[
atomI
][
1
];
inputForces
[
atomI
][
1
]
+=
conversion
*
forces
[
atomI
][
1
];
inputForces
[
atomI
][
2
]
+=
conversion
*
forces
[
atomI
][
2
];
inputForces
[
atomI
][
2
]
+=
conversion
*
forces
[
atomI
][
2
];
...
@@ -734,93 +731,6 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
...
@@ -734,93 +731,6 @@ void CpuGBVI::computeBornForces( std::vector<RealVec>& atomCoordinates, const Re
}
}
/**---------------------------------------------------------------------------------------
Print GB/VI parameters, radii, forces, ...
@param atomCoordinates atomic coordinates
@param partialCharges partial charges
@param bornRadii Born radii (may be empty)
@param bornForces Born forces (may be empty)
@param forces forces (may be empty)
@param idString id string (who is calling)
@param log log file
--------------------------------------------------------------------------------------- */
void
CpuGBVI
::
printGbvi
(
const
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
const
RealOpenMMVector
&
partialCharges
,
const
RealOpenMMVector
&
bornRadii
,
const
RealOpenMMVector
&
bornForces
,
const
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
const
std
::
string
&
idString
,
FILE
*
log
){
// ---------------------------------------------------------------------------------------
const
GBVIParameters
*
gbviParameters
=
getGBVIParameters
();
const
int
numberOfAtoms
=
gbviParameters
->
getNumberOfAtoms
();
const
RealOpenMMVector
&
atomicRadii
=
gbviParameters
->
getAtomicRadii
();
const
RealOpenMMVector
&
gammaParameters
=
gbviParameters
->
getGammaParameters
();
// ---------------------------------------------------------------------------------------
// constants
const
RealOpenMM
preFactor
=
2.0
*
gbviParameters
->
getElectricConstant
();
// ---------------------------------------------------------------------------------------
const
RealOpenMMVector
&
scaledRadii
=
gbviParameters
->
getScaledRadii
();
const
RealOpenMMVector
&
switchDeriviative
=
getSwitchDeriviative
();
RealOpenMM
tau
=
static_cast
<
RealOpenMM
>
(
gbviParameters
->
getTau
());
int
useComparisonFormat
=
1
;
(
void
)
fprintf
(
log
,
"Reference Gbvi %s atoms=%d
\n
"
,
idString
.
c_str
(),
numberOfAtoms
);
(
void
)
fprintf
(
log
,
" tau %15.7e
\n
"
,
tau
);
(
void
)
fprintf
(
log
,
" scaleMethod %d (QuinticEnum=%d)
\n
"
,
_gbviParameters
->
getBornRadiusScalingMethod
(),
GBVIParameters
::
QuinticSpline
);
(
void
)
fprintf
(
log
,
" preFactor %15.7e)
\n
"
,
preFactor
);
if
(
useComparisonFormat
){
(
void
)
fprintf
(
log
,
" br bF swd r scR tau*gamma q)
\n
"
);
for
(
unsigned
int
atomI
=
0
;
atomI
<
static_cast
<
unsigned
int
>
(
numberOfAtoms
);
atomI
++
){
(
void
)
fprintf
(
log
,
"%6d "
,
atomI
);
if
(
bornRadii
.
size
()
>
atomI
){
(
void
)
fprintf
(
log
,
"%15.7e "
,
bornRadii
[
atomI
]
);
}
if
(
bornForces
.
size
()
>
atomI
){
(
void
)
fprintf
(
log
,
"%15.7e "
,
tau
*
bornForces
[
atomI
]
);
}
(
void
)
fprintf
(
log
,
" %15.7e %15.7e %15.7e %15.7e %15.7e"
,
switchDeriviative
[
atomI
],
atomicRadii
[
atomI
],
scaledRadii
[
atomI
],
tau
*
gammaParameters
[
atomI
],
partialCharges
[
atomI
]
);
(
void
)
fprintf
(
log
,
"
\n
"
);
}
}
else
{
for
(
unsigned
int
atomI
=
0
;
atomI
<
static_cast
<
unsigned
int
>
(
numberOfAtoms
);
atomI
++
){
(
void
)
fprintf
(
log
,
"%6d r=%15.7e rSc=%15.7e swd=%15.7e tau*gam=%15.7e q=%15.7e"
,
atomI
,
atomicRadii
[
atomI
],
scaledRadii
[
atomI
],
switchDeriviative
[
atomI
],
tau
*
gammaParameters
[
atomI
],
partialCharges
[
atomI
]
);
if
(
bornRadii
.
size
()
>
atomI
){
(
void
)
fprintf
(
log
,
" bR=%15.7e"
,
bornRadii
[
atomI
]
);
}
if
(
bornForces
.
size
()
>
atomI
){
(
void
)
fprintf
(
log
,
" tau*bF=%15.7e"
,
tau
*
bornForces
[
atomI
]
);
}
(
void
)
fprintf
(
log
,
"
\n
"
);
}
}
return
;
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Use double precision
Use double precision
...
@@ -835,7 +745,7 @@ void CpuGBVI::printGbvi( const std::vector<OpenMM::RealVec>& atomCoordinates, co
...
@@ -835,7 +745,7 @@ void CpuGBVI::printGbvi( const std::vector<OpenMM::RealVec>& atomCoordinates, co
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
double
Cpu
GBVI
::
getVolumeD
(
double
r
,
double
R
,
double
S
){
double
Reference
GBVI
::
getVolumeD
(
double
r
,
double
R
,
double
S
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -843,18 +753,18 @@ double CpuGBVI::getVolumeD( double r, double R, double S ){
...
@@ -843,18 +753,18 @@ double CpuGBVI::getVolumeD( double r, double R, double S ){
static
const
double
minusThree
=
-
3.0
;
static
const
double
minusThree
=
-
3.0
;
double
diff
=
(
S
-
R
);
double
diff
=
(
S
-
R
);
if
(
fabs
(
diff
)
<
r
){
if
(
fabs
(
diff
)
<
r
)
{
double
lowerBound
=
(
R
>
(
r
-
S
))
?
R
:
(
r
-
S
);
double
lowerBound
=
(
R
>
(
r
-
S
))
?
R
:
(
r
-
S
);
return
(
Cpu
GBVI
::
getLD
(
r
,
(
r
+
S
),
S
)
-
return
(
Reference
GBVI
::
getLD
(
r
,
(
r
+
S
),
S
)
-
Cpu
GBVI
::
getLD
(
r
,
lowerBound
,
S
));
Reference
GBVI
::
getLD
(
r
,
lowerBound
,
S
));
}
else
if
(
r
<
diff
){
}
else
if
(
r
<
diff
)
{
return
Cpu
GBVI
::
getLD
(
r
,
(
r
+
S
),
S
)
-
return
Reference
GBVI
::
getLD
(
r
,
(
r
+
S
),
S
)
-
Cpu
GBVI
::
getLD
(
r
,
(
r
-
S
),
S
)
+
Reference
GBVI
::
getLD
(
r
,
(
r
-
S
),
S
)
+
pow
(
R
,
minusThree
);
pow
(
R
,
minusThree
);
}
else
{
}
else
{
return
zero
;
return
zero
;
...
@@ -875,7 +785,7 @@ double CpuGBVI::getVolumeD( double r, double R, double S ){
...
@@ -875,7 +785,7 @@ double CpuGBVI::getVolumeD( double r, double R, double S ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
double
Cpu
GBVI
::
getLD
(
double
r
,
double
x
,
double
S
){
double
Reference
GBVI
::
getLD
(
double
r
,
double
x
,
double
S
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -895,7 +805,7 @@ double CpuGBVI::getLD( double r, double x, double S ){
...
@@ -895,7 +805,7 @@ double CpuGBVI::getLD( double r, double x, double S ){
double
diff2
=
(
r
+
S
)
*
(
r
-
S
);
double
diff2
=
(
r
+
S
)
*
(
r
-
S
);
return
(
threeHalves
*
xInv
)
*
(
(
xInv
*
fourth
*
rInv
)
-
(
xInv2
*
third
)
+
(
diff2
*
xInv3
*
eighth
*
rInv
)
);
return
(
threeHalves
*
xInv
)
*
((
xInv
*
fourth
*
rInv
)
-
(
xInv2
*
third
)
+
(
diff2
*
xInv3
*
eighth
*
rInv
));
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -912,7 +822,7 @@ double CpuGBVI::getLD( double r, double x, double S ){
...
@@ -912,7 +822,7 @@ double CpuGBVI::getLD( double r, double x, double S ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
double
Cpu
GBVI
::
dL_drD
(
double
r
,
double
x
,
double
S
){
double
Reference
GBVI
::
dL_drD
(
double
r
,
double
x
,
double
S
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -934,7 +844,7 @@ double CpuGBVI::dL_drD( double r, double x, double S ){
...
@@ -934,7 +844,7 @@ double CpuGBVI::dL_drD( double r, double x, double S ){
double
diff2
=
(
r
+
S
)
*
(
r
-
S
);
double
diff2
=
(
r
+
S
)
*
(
r
-
S
);
return
(
(
-
threeHalves
*
xInv2
*
rInv2
)
*
(
fourth
+
eighth
*
diff2
*
xInv2
)
+
threeEights
*
xInv3
*
xInv
);
return
((
-
threeHalves
*
xInv2
*
rInv2
)
*
(
fourth
+
eighth
*
diff2
*
xInv2
)
+
threeEights
*
xInv3
*
xInv
);
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -951,7 +861,7 @@ double CpuGBVI::dL_drD( double r, double x, double S ){
...
@@ -951,7 +861,7 @@ double CpuGBVI::dL_drD( double r, double x, double S ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
double
Cpu
GBVI
::
dL_dxD
(
double
r
,
double
x
,
double
S
){
double
Reference
GBVI
::
dL_dxD
(
double
r
,
double
x
,
double
S
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -970,5 +880,5 @@ double CpuGBVI::dL_dxD( double r, double x, double S ){
...
@@ -970,5 +880,5 @@ double CpuGBVI::dL_dxD( double r, double x, double S ){
double
diff
=
(
r
+
S
)
*
(
r
-
S
);
double
diff
=
(
r
+
S
)
*
(
r
-
S
);
return
(
threeHalvesM
*
xInv3
)
*
(
(
half
*
rInv
)
-
xInv
+
(
half
*
diff
*
xInv2
*
rInv
)
);
return
(
threeHalvesM
*
xInv3
)
*
((
half
*
rInv
)
-
xInv
+
(
half
*
diff
*
xInv2
*
rInv
));
}
}
platforms/reference/src/SimTKReference/ReferenceHarmonicBondIxn.cpp
View file @
162d69a2
...
@@ -25,14 +25,12 @@
...
@@ -25,14 +25,12 @@
#include <string.h>
#include <string.h>
#include <sstream>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceHarmonicBondIxn.h"
#include "ReferenceHarmonicBondIxn.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
using
std
::
vector
;
using
std
::
vector
;
using
OpenMM
::
RealVec
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -40,7 +38,7 @@ using OpenMM::RealVec;
...
@@ -40,7 +38,7 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceHarmonicBondIxn
::
ReferenceHarmonicBondIxn
(
){
ReferenceHarmonicBondIxn
::
ReferenceHarmonicBondIxn
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -56,7 +54,7 @@ ReferenceHarmonicBondIxn::ReferenceHarmonicBondIxn( ){
...
@@ -56,7 +54,7 @@ ReferenceHarmonicBondIxn::ReferenceHarmonicBondIxn( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceHarmonicBondIxn
::~
ReferenceHarmonicBondIxn
(
){
ReferenceHarmonicBondIxn
::~
ReferenceHarmonicBondIxn
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -79,11 +77,11 @@ ReferenceHarmonicBondIxn::~ReferenceHarmonicBondIxn( ){
...
@@ -79,11 +77,11 @@ ReferenceHarmonicBondIxn::~ReferenceHarmonicBondIxn( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceHarmonicBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceHarmonicBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
*
parameters
,
vector
<
RealVec
>&
forces
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
{
RealOpenMM
*
totalEnergy
)
const
{
static
const
std
::
string
methodName
=
"
\n
ReferenceHarmonicBondIxn::calculateBondIxn"
;
static
const
std
::
string
methodName
=
"
\n
ReferenceHarmonicBondIxn::calculateBondIxn"
;
...
@@ -101,7 +99,7 @@ void ReferenceHarmonicBondIxn::calculateBondIxn( int* atomIndices,
...
@@ -101,7 +99,7 @@ void ReferenceHarmonicBondIxn::calculateBondIxn( int* atomIndices,
int
atomAIndex
=
atomIndices
[
0
];
int
atomAIndex
=
atomIndices
[
0
];
int
atomBIndex
=
atomIndices
[
1
];
int
atomBIndex
=
atomIndices
[
1
];
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
);
// deltaIdeal = r - r_0
// deltaIdeal = r - r_0
...
...
Prev
1
2
3
4
5
6
7
8
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