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
469 additions
and
1008 deletions
+469
-1008
platforms/reference/src/SimTKReference/ReferenceLJCoulomb14.cpp
...rms/reference/src/SimTKReference/ReferenceLJCoulomb14.cpp
+9
-11
platforms/reference/src/SimTKReference/ReferenceLJCoulombIxn.cpp
...ms/reference/src/SimTKReference/ReferenceLJCoulombIxn.cpp
+54
-58
platforms/reference/src/SimTKReference/ReferenceLincsAlgorithm.cpp
.../reference/src/SimTKReference/ReferenceLincsAlgorithm.cpp
+12
-23
platforms/reference/src/SimTKReference/ReferenceMonteCarloBarostat.cpp
...erence/src/SimTKReference/ReferenceMonteCarloBarostat.cpp
+1
-1
platforms/reference/src/SimTKReference/ReferenceNeighborList.cpp
...ms/reference/src/SimTKReference/ReferenceNeighborList.cpp
+7
-7
platforms/reference/src/SimTKReference/ReferenceObc.cpp
platforms/reference/src/SimTKReference/ReferenceObc.cpp
+79
-165
platforms/reference/src/SimTKReference/ReferencePME.cpp
platforms/reference/src/SimTKReference/ReferencePME.cpp
+38
-36
platforms/reference/src/SimTKReference/ReferencePairIxn.cpp
platforms/reference/src/SimTKReference/ReferencePairIxn.cpp
+4
-4
platforms/reference/src/SimTKReference/ReferenceProperDihedralBond.cpp
...erence/src/SimTKReference/ReferenceProperDihedralBond.cpp
+19
-21
platforms/reference/src/SimTKReference/ReferenceRbDihedralBond.cpp
.../reference/src/SimTKReference/ReferenceRbDihedralBond.cpp
+21
-23
platforms/reference/src/SimTKReference/ReferenceStochasticDynamics.cpp
...erence/src/SimTKReference/ReferenceStochasticDynamics.cpp
+19
-37
platforms/reference/src/SimTKReference/ReferenceVariableStochasticDynamics.cpp
...rc/SimTKReference/ReferenceVariableStochasticDynamics.cpp
+20
-38
platforms/reference/src/SimTKReference/ReferenceVariableVerletDynamics.cpp
...ce/src/SimTKReference/ReferenceVariableVerletDynamics.cpp
+8
-10
platforms/reference/src/SimTKReference/ReferenceVerletDynamics.cpp
.../reference/src/SimTKReference/ReferenceVerletDynamics.cpp
+7
-10
platforms/reference/src/SimTKReference/SimTKOpenMMUtilities.cpp
...rms/reference/src/SimTKReference/SimTKOpenMMUtilities.cpp
+43
-42
platforms/reference/src/SimTKReference/fftpack.cpp
platforms/reference/src/SimTKReference/fftpack.cpp
+43
-43
platforms/reference/src/SimTKUtilities/SimTKOpenMMCommon.cpp
platforms/reference/src/SimTKUtilities/SimTKOpenMMCommon.cpp
+0
-38
platforms/reference/src/SimTKUtilities/SimTKOpenMMLog.cpp
platforms/reference/src/SimTKUtilities/SimTKOpenMMLog.cpp
+0
-304
platforms/reference/tests/TestReferenceCustomGBForce.cpp
platforms/reference/tests/TestReferenceCustomGBForce.cpp
+55
-83
platforms/reference/tests/TestReferenceGBVIForce.cpp
platforms/reference/tests/TestReferenceGBVIForce.cpp
+30
-54
No files found.
platforms/reference/src/SimTKReference/ReferenceLJCoulomb14.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 "ReferenceLJCoulomb14.h"
#include "ReferenceLJCoulomb14.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;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceLJCoulomb14
::
ReferenceLJCoulomb14
(
)
{
ReferenceLJCoulomb14
::
ReferenceLJCoulomb14
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -56,7 +54,7 @@ ReferenceLJCoulomb14::ReferenceLJCoulomb14( ) {
...
@@ -56,7 +54,7 @@ ReferenceLJCoulomb14::ReferenceLJCoulomb14( ) {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceLJCoulomb14
::~
ReferenceLJCoulomb14
(
){
ReferenceLJCoulomb14
::~
ReferenceLJCoulomb14
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -81,9 +79,9 @@ ReferenceLJCoulomb14::~ReferenceLJCoulomb14( ){
...
@@ -81,9 +79,9 @@ ReferenceLJCoulomb14::~ReferenceLJCoulomb14( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceLJCoulomb14
::
calculateBondIxn
(
int
*
atomIndices
,
vector
<
RealVec
>&
atomCoordinates
,
void
ReferenceLJCoulomb14
::
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
=
"
\n
ReferenceLJCoulomb14::calculateBondIxn"
;
static
const
std
::
string
methodName
=
"
\n
ReferenceLJCoulomb14::calculateBondIxn"
;
...
@@ -113,7 +111,7 @@ void ReferenceLJCoulomb14::calculateBondIxn( int* atomIndices, vector<RealVec>&
...
@@ -113,7 +111,7 @@ void ReferenceLJCoulomb14::calculateBondIxn( int* atomIndices, vector<RealVec>&
int
atomAIndex
=
atomIndices
[
0
];
int
atomAIndex
=
atomIndices
[
0
];
int
atomBIndex
=
atomIndices
[
1
];
int
atomBIndex
=
atomIndices
[
1
];
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
deltaR
[
0
]
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
deltaR
[
0
]);
RealOpenMM
r2
=
deltaR
[
0
][
ReferenceForce
::
R2Index
];
RealOpenMM
r2
=
deltaR
[
0
][
ReferenceForce
::
R2Index
];
RealOpenMM
inverseR
=
one
/
(
deltaR
[
0
][
ReferenceForce
::
RIndex
]);
RealOpenMM
inverseR
=
one
/
(
deltaR
[
0
][
ReferenceForce
::
RIndex
]);
...
@@ -121,13 +119,13 @@ void ReferenceLJCoulomb14::calculateBondIxn( int* atomIndices, vector<RealVec>&
...
@@ -121,13 +119,13 @@ void ReferenceLJCoulomb14::calculateBondIxn( int* atomIndices, vector<RealVec>&
sig2
*=
sig2
;
sig2
*=
sig2
;
RealOpenMM
sig6
=
sig2
*
sig2
*
sig2
;
RealOpenMM
sig6
=
sig2
*
sig2
*
sig2
;
RealOpenMM
dEdR
=
parameters
[
1
]
*
(
twelve
*
sig6
-
six
)
*
sig6
;
RealOpenMM
dEdR
=
parameters
[
1
]
*
(
twelve
*
sig6
-
six
)
*
sig6
;
dEdR
+=
(
RealOpenMM
)
(
ONE_4PI_EPS0
*
parameters
[
2
]
*
inverseR
);
dEdR
+=
(
RealOpenMM
)
(
ONE_4PI_EPS0
*
parameters
[
2
]
*
inverseR
);
dEdR
*=
inverseR
*
inverseR
;
dEdR
*=
inverseR
*
inverseR
;
// accumulate forces
// accumulate forces
for
(
int
ii
=
0
;
ii
<
3
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
3
;
ii
++
)
{
RealOpenMM
force
=
dEdR
*
deltaR
[
0
][
ii
];
RealOpenMM
force
=
dEdR
*
deltaR
[
0
][
ii
];
forces
[
atomAIndex
][
ii
]
+=
force
;
forces
[
atomAIndex
][
ii
]
+=
force
;
forces
[
atomBIndex
][
ii
]
-=
force
;
forces
[
atomBIndex
][
ii
]
-=
force
;
...
@@ -136,5 +134,5 @@ void ReferenceLJCoulomb14::calculateBondIxn( int* atomIndices, vector<RealVec>&
...
@@ -136,5 +134,5 @@ void ReferenceLJCoulomb14::calculateBondIxn( int* atomIndices, vector<RealVec>&
// accumulate energies
// accumulate energies
if
(
totalEnergy
!=
NULL
)
if
(
totalEnergy
!=
NULL
)
*
totalEnergy
+=
parameters
[
1
]
*
(
sig6
-
one
)
*
sig6
+
(
ONE_4PI_EPS0
*
parameters
[
2
]
*
inverseR
);
*
totalEnergy
+=
parameters
[
1
]
*
(
sig6
-
one
)
*
sig6
+
(
ONE_4PI_EPS0
*
parameters
[
2
]
*
inverseR
);
}
}
platforms/reference/src/SimTKReference/ReferenceLJCoulombIxn.cpp
View file @
162d69a2
...
@@ -27,12 +27,11 @@
...
@@ -27,12 +27,11 @@
#include <complex>
#include <complex>
#include <algorithm>
#include <algorithm>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceLJCoulombIxn.h"
#include "ReferenceLJCoulombIxn.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
#include "ReferencePME.h"
#include "ReferencePME.h"
#include "openmm/OpenMMException.h"
// In case we're using some primitive version of Visual Studio this will
// In case we're using some primitive version of Visual Studio this will
// make sure that erf() and erfc() are defined.
// make sure that erf() and erfc() are defined.
...
@@ -40,7 +39,7 @@
...
@@ -40,7 +39,7 @@
using
std
::
set
;
using
std
::
set
;
using
std
::
vector
;
using
std
::
vector
;
using
OpenMM
::
RealVec
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -48,7 +47,7 @@ using OpenMM::RealVec;
...
@@ -48,7 +47,7 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceLJCoulombIxn
::
ReferenceLJCoulombIxn
(
)
:
cutoff
(
false
),
useSwitch
(
false
),
periodic
(
false
),
ewald
(
false
),
pme
(
false
)
{
ReferenceLJCoulombIxn
::
ReferenceLJCoulombIxn
()
:
cutoff
(
false
),
useSwitch
(
false
),
periodic
(
false
),
ewald
(
false
),
pme
(
false
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -64,7 +63,7 @@ ReferenceLJCoulombIxn::ReferenceLJCoulombIxn( ) : cutoff(false), useSwitch(false
...
@@ -64,7 +63,7 @@ ReferenceLJCoulombIxn::ReferenceLJCoulombIxn( ) : cutoff(false), useSwitch(false
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceLJCoulombIxn
::~
ReferenceLJCoulombIxn
(
){
ReferenceLJCoulombIxn
::~
ReferenceLJCoulombIxn
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -84,7 +83,7 @@ ReferenceLJCoulombIxn::~ReferenceLJCoulombIxn( ){
...
@@ -84,7 +83,7 @@ ReferenceLJCoulombIxn::~ReferenceLJCoulombIxn( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceLJCoulombIxn
::
setUseCutoff
(
RealOpenMM
distance
,
const
OpenMM
::
NeighborList
&
neighbors
,
RealOpenMM
solventDielectric
)
{
void
ReferenceLJCoulombIxn
::
setUseCutoff
(
RealOpenMM
distance
,
const
OpenMM
::
NeighborList
&
neighbors
,
RealOpenMM
solventDielectric
)
{
cutoff
=
true
;
cutoff
=
true
;
cutoffDistance
=
distance
;
cutoffDistance
=
distance
;
...
@@ -101,7 +100,7 @@ ReferenceLJCoulombIxn::~ReferenceLJCoulombIxn( ){
...
@@ -101,7 +100,7 @@ ReferenceLJCoulombIxn::~ReferenceLJCoulombIxn( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceLJCoulombIxn
::
setUseSwitchingFunction
(
RealOpenMM
distance
)
{
void
ReferenceLJCoulombIxn
::
setUseSwitchingFunction
(
RealOpenMM
distance
)
{
useSwitch
=
true
;
useSwitch
=
true
;
switchingDistance
=
distance
;
switchingDistance
=
distance
;
}
}
...
@@ -210,16 +209,16 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
...
@@ -210,16 +209,16 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
// **************************************************************************************
// **************************************************************************************
if
(
includeReciprocal
)
{
if
(
includeReciprocal
)
{
for
(
int
atomID
=
0
;
atomID
<
numberOfAtoms
;
atomID
++
){
for
(
int
atomID
=
0
;
atomID
<
numberOfAtoms
;
atomID
++
)
{
RealOpenMM
selfEwaldEnergy
=
(
RealOpenMM
)
(
ONE_4PI_EPS0
*
atomParameters
[
atomID
][
QIndex
]
*
atomParameters
[
atomID
][
QIndex
]
*
alphaEwald
/
SQRT_PI
);
RealOpenMM
selfEwaldEnergy
=
(
RealOpenMM
)
(
ONE_4PI_EPS0
*
atomParameters
[
atomID
][
QIndex
]
*
atomParameters
[
atomID
][
QIndex
]
*
alphaEwald
/
SQRT_PI
);
totalSelfEwaldEnergy
-=
selfEwaldEnergy
;
totalSelfEwaldEnergy
-=
selfEwaldEnergy
;
if
(
energyByAtom
){
if
(
energyByAtom
)
{
energyByAtom
[
atomID
]
-=
selfEwaldEnergy
;
energyByAtom
[
atomID
]
-=
selfEwaldEnergy
;
}
}
}
}
}
}
if
(
totalEnergy
){
if
(
totalEnergy
)
{
*
totalEnergy
+=
totalSelfEwaldEnergy
;
*
totalEnergy
+=
totalSelfEwaldEnergy
;
}
}
...
@@ -238,11 +237,11 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
...
@@ -238,11 +237,11 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
charges
[
i
]
=
atomParameters
[
i
][
QIndex
];
charges
[
i
]
=
atomParameters
[
i
][
QIndex
];
pme_exec
(
pmedata
,
atomCoordinates
,
forces
,
charges
,
periodicBoxVectors
,
&
recipEnergy
);
pme_exec
(
pmedata
,
atomCoordinates
,
forces
,
charges
,
periodicBoxVectors
,
&
recipEnergy
);
if
(
totalEnergy
)
if
(
totalEnergy
)
*
totalEnergy
+=
recipEnergy
;
*
totalEnergy
+=
recipEnergy
;
if
(
energyByAtom
)
if
(
energyByAtom
)
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
energyByAtom
[
n
]
+=
recipEnergy
;
energyByAtom
[
n
]
+=
recipEnergy
;
pme_destroy
(
pmedata
);
pme_destroy
(
pmedata
);
...
@@ -264,22 +263,19 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
...
@@ -264,22 +263,19 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
vector
<
d_complex
>
tab_xy
(
numberOfAtoms
);
vector
<
d_complex
>
tab_xy
(
numberOfAtoms
);
vector
<
d_complex
>
tab_qxyz
(
numberOfAtoms
);
vector
<
d_complex
>
tab_qxyz
(
numberOfAtoms
);
if
(
kmax
<
1
)
{
if
(
kmax
<
1
)
std
::
stringstream
message
;
throw
OpenMMException
(
"kmax for Ewald summation < 1"
);
message
<<
" kmax < 1 , Aborting"
<<
std
::
endl
;
SimTKOpenMMLog
::
printError
(
message
);
}
for
(
int
i
=
0
;
(
i
<
numberOfAtoms
);
i
++
)
{
for
(
int
i
=
0
;
(
i
<
numberOfAtoms
);
i
++
)
{
for
(
int
m
=
0
;
(
m
<
3
);
m
++
)
for
(
int
m
=
0
;
(
m
<
3
);
m
++
)
EIR
(
0
,
i
,
m
)
=
d_complex
(
1
,
0
);
EIR
(
0
,
i
,
m
)
=
d_complex
(
1
,
0
);
for
(
int
m
=
0
;
(
m
<
3
);
m
++
)
for
(
int
m
=
0
;
(
m
<
3
);
m
++
)
EIR
(
1
,
i
,
m
)
=
d_complex
(
cos
(
atomCoordinates
[
i
][
m
]
*
recipBoxSize
[
m
]),
EIR
(
1
,
i
,
m
)
=
d_complex
(
cos
(
atomCoordinates
[
i
][
m
]
*
recipBoxSize
[
m
]),
sin
(
atomCoordinates
[
i
][
m
]
*
recipBoxSize
[
m
]));
sin
(
atomCoordinates
[
i
][
m
]
*
recipBoxSize
[
m
]));
for
(
int
j
=
2
;
(
j
<
kmax
);
j
++
)
for
(
int
j
=
2
;
(
j
<
kmax
);
j
++
)
for
(
int
m
=
0
;
(
m
<
3
);
m
++
)
for
(
int
m
=
0
;
(
m
<
3
);
m
++
)
EIR
(
j
,
i
,
m
)
=
EIR
(
j
-
1
,
i
,
m
)
*
EIR
(
1
,
i
,
m
);
EIR
(
j
,
i
,
m
)
=
EIR
(
j
-
1
,
i
,
m
)
*
EIR
(
1
,
i
,
m
);
}
}
...
@@ -288,40 +284,40 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
...
@@ -288,40 +284,40 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
int
lowry
=
0
;
int
lowry
=
0
;
int
lowrz
=
1
;
int
lowrz
=
1
;
for
(
int
rx
=
0
;
rx
<
numRx
;
rx
++
)
{
for
(
int
rx
=
0
;
rx
<
numRx
;
rx
++
)
{
RealOpenMM
kx
=
rx
*
recipBoxSize
[
0
];
RealOpenMM
kx
=
rx
*
recipBoxSize
[
0
];
for
(
int
ry
=
lowry
;
ry
<
numRy
;
ry
++
)
{
for
(
int
ry
=
lowry
;
ry
<
numRy
;
ry
++
)
{
RealOpenMM
ky
=
ry
*
recipBoxSize
[
1
];
RealOpenMM
ky
=
ry
*
recipBoxSize
[
1
];
if
(
ry
>=
0
)
{
if
(
ry
>=
0
)
{
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
tab_xy
[
n
]
=
EIR
(
rx
,
n
,
0
)
*
EIR
(
ry
,
n
,
1
);
tab_xy
[
n
]
=
EIR
(
rx
,
n
,
0
)
*
EIR
(
ry
,
n
,
1
);
}
}
else
{
else
{
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
tab_xy
[
n
]
=
EIR
(
rx
,
n
,
0
)
*
conj
(
EIR
(
-
ry
,
n
,
1
));
tab_xy
[
n
]
=
EIR
(
rx
,
n
,
0
)
*
conj
(
EIR
(
-
ry
,
n
,
1
));
}
}
for
(
int
rz
=
lowrz
;
rz
<
numRz
;
rz
++
)
{
for
(
int
rz
=
lowrz
;
rz
<
numRz
;
rz
++
)
{
if
(
rz
>=
0
)
{
if
(
rz
>=
0
)
{
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
tab_qxyz
[
n
]
=
atomParameters
[
n
][
QIndex
]
*
(
tab_xy
[
n
]
*
EIR
(
rz
,
n
,
2
));
tab_qxyz
[
n
]
=
atomParameters
[
n
][
QIndex
]
*
(
tab_xy
[
n
]
*
EIR
(
rz
,
n
,
2
));
}
}
else
{
else
{
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
tab_qxyz
[
n
]
=
atomParameters
[
n
][
QIndex
]
*
(
tab_xy
[
n
]
*
conj
(
EIR
(
-
rz
,
n
,
2
)));
tab_qxyz
[
n
]
=
atomParameters
[
n
][
QIndex
]
*
(
tab_xy
[
n
]
*
conj
(
EIR
(
-
rz
,
n
,
2
)));
}
}
RealOpenMM
cs
=
0.0
f
;
RealOpenMM
cs
=
0.0
f
;
RealOpenMM
ss
=
0.0
f
;
RealOpenMM
ss
=
0.0
f
;
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
{
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
{
cs
+=
tab_qxyz
[
n
].
real
();
cs
+=
tab_qxyz
[
n
].
real
();
ss
+=
tab_qxyz
[
n
].
imag
();
ss
+=
tab_qxyz
[
n
].
imag
();
}
}
...
@@ -330,21 +326,21 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
...
@@ -330,21 +326,21 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
RealOpenMM
k2
=
kx
*
kx
+
ky
*
ky
+
kz
*
kz
;
RealOpenMM
k2
=
kx
*
kx
+
ky
*
ky
+
kz
*
kz
;
RealOpenMM
ak
=
exp
(
k2
*
factorEwald
)
/
k2
;
RealOpenMM
ak
=
exp
(
k2
*
factorEwald
)
/
k2
;
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
{
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
{
RealOpenMM
force
=
ak
*
(
cs
*
tab_qxyz
[
n
].
imag
()
-
ss
*
tab_qxyz
[
n
].
real
());
RealOpenMM
force
=
ak
*
(
cs
*
tab_qxyz
[
n
].
imag
()
-
ss
*
tab_qxyz
[
n
].
real
());
forces
[
n
][
0
]
+=
2
*
recipCoeff
*
force
*
kx
;
forces
[
n
][
0
]
+=
2
*
recipCoeff
*
force
*
kx
;
forces
[
n
][
1
]
+=
2
*
recipCoeff
*
force
*
ky
;
forces
[
n
][
1
]
+=
2
*
recipCoeff
*
force
*
ky
;
forces
[
n
][
2
]
+=
2
*
recipCoeff
*
force
*
kz
;
forces
[
n
][
2
]
+=
2
*
recipCoeff
*
force
*
kz
;
}
}
recipEnergy
=
recipCoeff
*
ak
*
(
cs
*
cs
+
ss
*
ss
);
recipEnergy
=
recipCoeff
*
ak
*
(
cs
*
cs
+
ss
*
ss
);
totalRecipEnergy
+=
recipEnergy
;
totalRecipEnergy
+=
recipEnergy
;
if
(
totalEnergy
)
if
(
totalEnergy
)
*
totalEnergy
+=
recipEnergy
;
*
totalEnergy
+=
recipEnergy
;
if
(
energyByAtom
)
if
(
energyByAtom
)
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
for
(
int
n
=
0
;
n
<
numberOfAtoms
;
n
++
)
energyByAtom
[
n
]
+=
recipEnergy
;
energyByAtom
[
n
]
+=
recipEnergy
;
lowrz
=
1
-
numRz
;
lowrz
=
1
-
numRz
;
...
@@ -369,7 +365,7 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
...
@@ -369,7 +365,7 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
int
jj
=
pair
.
second
;
int
jj
=
pair
.
second
;
RealOpenMM
deltaR
[
2
][
ReferenceForce
::
LastDeltaRIndex
];
RealOpenMM
deltaR
[
2
][
ReferenceForce
::
LastDeltaRIndex
];
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
jj
],
atomCoordinates
[
ii
],
periodicBoxVectors
,
deltaR
[
0
]
);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
jj
],
atomCoordinates
[
ii
],
periodicBoxVectors
,
deltaR
[
0
]);
RealOpenMM
r
=
deltaR
[
0
][
ReferenceForce
::
RIndex
];
RealOpenMM
r
=
deltaR
[
0
][
ReferenceForce
::
RIndex
];
RealOpenMM
inverseR
=
one
/
(
deltaR
[
0
][
ReferenceForce
::
RIndex
]);
RealOpenMM
inverseR
=
one
/
(
deltaR
[
0
][
ReferenceForce
::
RIndex
]);
RealOpenMM
switchValue
=
1
,
switchDeriv
=
0
;
RealOpenMM
switchValue
=
1
,
switchDeriv
=
0
;
...
@@ -382,14 +378,14 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
...
@@ -382,14 +378,14 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
RealOpenMM
dEdR
=
(
RealOpenMM
)
(
ONE_4PI_EPS0
*
atomParameters
[
ii
][
QIndex
]
*
atomParameters
[
jj
][
QIndex
]
*
inverseR
*
inverseR
*
inverseR
);
RealOpenMM
dEdR
=
(
RealOpenMM
)
(
ONE_4PI_EPS0
*
atomParameters
[
ii
][
QIndex
]
*
atomParameters
[
jj
][
QIndex
]
*
inverseR
*
inverseR
*
inverseR
);
dEdR
=
(
RealOpenMM
)
(
dEdR
*
(
erfc
(
alphaR
)
+
2
*
alphaR
*
exp
(
-
alphaR
*
alphaR
)
/
SQRT_PI
));
dEdR
=
(
RealOpenMM
)
(
dEdR
*
(
erfc
(
alphaR
)
+
2
*
alphaR
*
exp
(
-
alphaR
*
alphaR
)
/
SQRT_PI
));
RealOpenMM
sig
=
atomParameters
[
ii
][
SigIndex
]
+
atomParameters
[
jj
][
SigIndex
];
RealOpenMM
sig
=
atomParameters
[
ii
][
SigIndex
]
+
atomParameters
[
jj
][
SigIndex
];
RealOpenMM
sig2
=
inverseR
*
sig
;
RealOpenMM
sig2
=
inverseR
*
sig
;
sig2
*=
sig2
;
sig2
*=
sig2
;
RealOpenMM
sig6
=
sig2
*
sig2
*
sig2
;
RealOpenMM
sig6
=
sig2
*
sig2
*
sig2
;
RealOpenMM
eps
=
atomParameters
[
ii
][
EpsIndex
]
*
atomParameters
[
jj
][
EpsIndex
];
RealOpenMM
eps
=
atomParameters
[
ii
][
EpsIndex
]
*
atomParameters
[
jj
][
EpsIndex
];
dEdR
+=
switchValue
*
eps
*
(
twelve
*
sig6
-
six
)
*
sig6
*
inverseR
*
inverseR
;
dEdR
+=
switchValue
*
eps
*
(
twelve
*
sig6
-
six
)
*
sig6
*
inverseR
*
inverseR
;
vdwEnergy
=
eps
*
(
sig6
-
one
)
*
sig6
;
vdwEnergy
=
eps
*
(
sig6
-
one
)
*
sig6
;
if
(
useSwitch
)
{
if
(
useSwitch
)
{
dEdR
-=
vdwEnergy
*
switchDeriv
*
inverseR
;
dEdR
-=
vdwEnergy
*
switchDeriv
*
inverseR
;
...
@@ -398,7 +394,7 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
...
@@ -398,7 +394,7 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
// accumulate forces
// accumulate forces
for
(
int
kk
=
0
;
kk
<
3
;
kk
++
){
for
(
int
kk
=
0
;
kk
<
3
;
kk
++
)
{
RealOpenMM
force
=
dEdR
*
deltaR
[
0
][
kk
];
RealOpenMM
force
=
dEdR
*
deltaR
[
0
][
kk
];
forces
[
ii
][
kk
]
+=
force
;
forces
[
ii
][
kk
]
+=
force
;
forces
[
jj
][
kk
]
-=
force
;
forces
[
jj
][
kk
]
-=
force
;
...
@@ -411,14 +407,14 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
...
@@ -411,14 +407,14 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
totalVdwEnergy
+=
vdwEnergy
;
totalVdwEnergy
+=
vdwEnergy
;
totalRealSpaceEwaldEnergy
+=
realSpaceEwaldEnergy
;
totalRealSpaceEwaldEnergy
+=
realSpaceEwaldEnergy
;
if
(
energyByAtom
){
if
(
energyByAtom
)
{
energyByAtom
[
ii
]
+=
realSpaceEwaldEnergy
+
vdwEnergy
;
energyByAtom
[
ii
]
+=
realSpaceEwaldEnergy
+
vdwEnergy
;
energyByAtom
[
jj
]
+=
realSpaceEwaldEnergy
+
vdwEnergy
;
energyByAtom
[
jj
]
+=
realSpaceEwaldEnergy
+
vdwEnergy
;
}
}
}
}
if
(
totalEnergy
)
if
(
totalEnergy
)
*
totalEnergy
+=
totalRealSpaceEwaldEnergy
+
totalVdwEnergy
;
*
totalEnergy
+=
totalRealSpaceEwaldEnergy
+
totalVdwEnergy
;
// Now subtract off the exclusions, since they were implicitly included in the reciprocal space sum.
// Now subtract off the exclusions, since they were implicitly included in the reciprocal space sum.
...
@@ -431,17 +427,17 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
...
@@ -431,17 +427,17 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
int
jj
=
*
iter
;
int
jj
=
*
iter
;
RealOpenMM
deltaR
[
2
][
ReferenceForce
::
LastDeltaRIndex
];
RealOpenMM
deltaR
[
2
][
ReferenceForce
::
LastDeltaRIndex
];
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
jj
],
atomCoordinates
[
ii
],
deltaR
[
0
]
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
jj
],
atomCoordinates
[
ii
],
deltaR
[
0
]);
RealOpenMM
r
=
deltaR
[
0
][
ReferenceForce
::
RIndex
];
RealOpenMM
r
=
deltaR
[
0
][
ReferenceForce
::
RIndex
];
RealOpenMM
inverseR
=
one
/
(
deltaR
[
0
][
ReferenceForce
::
RIndex
]);
RealOpenMM
inverseR
=
one
/
(
deltaR
[
0
][
ReferenceForce
::
RIndex
]);
RealOpenMM
alphaR
=
alphaEwald
*
r
;
RealOpenMM
alphaR
=
alphaEwald
*
r
;
if
(
erf
(
alphaR
)
>
1e-6
)
{
if
(
erf
(
alphaR
)
>
1e-6
)
{
RealOpenMM
dEdR
=
(
RealOpenMM
)
(
ONE_4PI_EPS0
*
atomParameters
[
ii
][
QIndex
]
*
atomParameters
[
jj
][
QIndex
]
*
inverseR
*
inverseR
*
inverseR
);
RealOpenMM
dEdR
=
(
RealOpenMM
)
(
ONE_4PI_EPS0
*
atomParameters
[
ii
][
QIndex
]
*
atomParameters
[
jj
][
QIndex
]
*
inverseR
*
inverseR
*
inverseR
);
dEdR
=
(
RealOpenMM
)
(
dEdR
*
(
erf
(
alphaR
)
-
2
*
alphaR
*
exp
(
-
alphaR
*
alphaR
)
/
SQRT_PI
));
dEdR
=
(
RealOpenMM
)
(
dEdR
*
(
erf
(
alphaR
)
-
2
*
alphaR
*
exp
(
-
alphaR
*
alphaR
)
/
SQRT_PI
));
// accumulate forces
// accumulate forces
for
(
int
kk
=
0
;
kk
<
3
;
kk
++
){
for
(
int
kk
=
0
;
kk
<
3
;
kk
++
)
{
RealOpenMM
force
=
dEdR
*
deltaR
[
0
][
kk
];
RealOpenMM
force
=
dEdR
*
deltaR
[
0
][
kk
];
forces
[
ii
][
kk
]
-=
force
;
forces
[
ii
][
kk
]
-=
force
;
forces
[
jj
][
kk
]
+=
force
;
forces
[
jj
][
kk
]
+=
force
;
...
@@ -452,7 +448,7 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
...
@@ -452,7 +448,7 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
realSpaceEwaldEnergy
=
(
RealOpenMM
)
(
ONE_4PI_EPS0
*
atomParameters
[
ii
][
QIndex
]
*
atomParameters
[
jj
][
QIndex
]
*
inverseR
*
erf
(
alphaR
));
realSpaceEwaldEnergy
=
(
RealOpenMM
)
(
ONE_4PI_EPS0
*
atomParameters
[
ii
][
QIndex
]
*
atomParameters
[
jj
][
QIndex
]
*
inverseR
*
erf
(
alphaR
));
totalExclusionEnergy
+=
realSpaceEwaldEnergy
;
totalExclusionEnergy
+=
realSpaceEwaldEnergy
;
if
(
energyByAtom
){
if
(
energyByAtom
)
{
energyByAtom
[
ii
]
-=
realSpaceEwaldEnergy
;
energyByAtom
[
ii
]
-=
realSpaceEwaldEnergy
;
energyByAtom
[
jj
]
-=
realSpaceEwaldEnergy
;
energyByAtom
[
jj
]
-=
realSpaceEwaldEnergy
;
}
}
...
@@ -460,7 +456,7 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
...
@@ -460,7 +456,7 @@ void ReferenceLJCoulombIxn::calculateEwaldIxn(int numberOfAtoms, vector<RealVec>
}
}
}
}
if
(
totalEnergy
)
if
(
totalEnergy
)
*
totalEnergy
-=
totalExclusionEnergy
;
*
totalEnergy
-=
totalExclusionEnergy
;
}
}
...
@@ -502,10 +498,10 @@ void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<RealVec>&
...
@@ -502,10 +498,10 @@ void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<RealVec>&
}
}
}
}
else
{
else
{
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
)
{
// loop over atom pairs
// loop over atom pairs
for
(
int
jj
=
ii
+
1
;
jj
<
numberOfAtoms
;
jj
++
)
for
(
int
jj
=
ii
+
1
;
jj
<
numberOfAtoms
;
jj
++
)
if
(
exclusions
[
jj
].
find
(
ii
)
==
exclusions
[
jj
].
end
())
if
(
exclusions
[
jj
].
find
(
ii
)
==
exclusions
[
jj
].
end
())
calculateOneIxn
(
ii
,
jj
,
atomCoordinates
,
atomParameters
,
forces
,
energyByAtom
,
totalEnergy
);
calculateOneIxn
(
ii
,
jj
,
atomCoordinates
,
atomParameters
,
forces
,
energyByAtom
,
totalEnergy
);
}
}
...
@@ -526,9 +522,9 @@ void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<RealVec>&
...
@@ -526,9 +522,9 @@ void ReferenceLJCoulombIxn::calculatePairIxn(int numberOfAtoms, vector<RealVec>&
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceLJCoulombIxn
::
calculateOneIxn
(
int
ii
,
int
jj
,
vector
<
RealVec
>&
atomCoordinates
,
void
ReferenceLJCoulombIxn
::
calculateOneIxn
(
int
ii
,
int
jj
,
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
**
atomParameters
,
vector
<
RealVec
>&
forces
,
RealOpenMM
**
atomParameters
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
energyByAtom
,
RealOpenMM
*
totalEnergy
)
const
{
RealOpenMM
*
energyByAtom
,
RealOpenMM
*
totalEnergy
)
const
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -555,9 +551,9 @@ void ReferenceLJCoulombIxn::calculateOneIxn( int ii, int jj, vector<RealVec>& at
...
@@ -555,9 +551,9 @@ void ReferenceLJCoulombIxn::calculateOneIxn( int ii, int jj, vector<RealVec>& at
// get deltaR, R2, and R between 2 atoms
// get deltaR, R2, and R between 2 atoms
if
(
periodic
)
if
(
periodic
)
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
jj
],
atomCoordinates
[
ii
],
periodicBoxVectors
,
deltaR
[
0
]
);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
jj
],
atomCoordinates
[
ii
],
periodicBoxVectors
,
deltaR
[
0
]);
else
else
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
jj
],
atomCoordinates
[
ii
],
deltaR
[
0
]
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
jj
],
atomCoordinates
[
ii
],
deltaR
[
0
]);
RealOpenMM
r2
=
deltaR
[
0
][
ReferenceForce
::
R2Index
];
RealOpenMM
r2
=
deltaR
[
0
][
ReferenceForce
::
R2Index
];
RealOpenMM
inverseR
=
one
/
(
deltaR
[
0
][
ReferenceForce
::
RIndex
]);
RealOpenMM
inverseR
=
one
/
(
deltaR
[
0
][
ReferenceForce
::
RIndex
]);
...
@@ -576,7 +572,7 @@ void ReferenceLJCoulombIxn::calculateOneIxn( int ii, int jj, vector<RealVec>& at
...
@@ -576,7 +572,7 @@ void ReferenceLJCoulombIxn::calculateOneIxn( int ii, int jj, vector<RealVec>& at
RealOpenMM
sig6
=
sig2
*
sig2
*
sig2
;
RealOpenMM
sig6
=
sig2
*
sig2
*
sig2
;
RealOpenMM
eps
=
atomParameters
[
ii
][
EpsIndex
]
*
atomParameters
[
jj
][
EpsIndex
];
RealOpenMM
eps
=
atomParameters
[
ii
][
EpsIndex
]
*
atomParameters
[
jj
][
EpsIndex
];
RealOpenMM
dEdR
=
switchValue
*
eps
*
(
twelve
*
sig6
-
six
)
*
sig6
;
RealOpenMM
dEdR
=
switchValue
*
eps
*
(
twelve
*
sig6
-
six
)
*
sig6
;
if
(
cutoff
)
if
(
cutoff
)
dEdR
+=
(
RealOpenMM
)
(
ONE_4PI_EPS0
*
atomParameters
[
ii
][
QIndex
]
*
atomParameters
[
jj
][
QIndex
]
*
(
inverseR
-
2.0
f
*
krf
*
r2
));
dEdR
+=
(
RealOpenMM
)
(
ONE_4PI_EPS0
*
atomParameters
[
ii
][
QIndex
]
*
atomParameters
[
jj
][
QIndex
]
*
(
inverseR
-
2.0
f
*
krf
*
r2
));
else
else
...
@@ -594,7 +590,7 @@ void ReferenceLJCoulombIxn::calculateOneIxn( int ii, int jj, vector<RealVec>& at
...
@@ -594,7 +590,7 @@ void ReferenceLJCoulombIxn::calculateOneIxn( int ii, int jj, vector<RealVec>& at
// accumulate forces
// accumulate forces
for
(
int
kk
=
0
;
kk
<
3
;
kk
++
){
for
(
int
kk
=
0
;
kk
<
3
;
kk
++
)
{
RealOpenMM
force
=
dEdR
*
deltaR
[
0
][
kk
];
RealOpenMM
force
=
dEdR
*
deltaR
[
0
][
kk
];
forces
[
ii
][
kk
]
+=
force
;
forces
[
ii
][
kk
]
+=
force
;
forces
[
jj
][
kk
]
-=
force
;
forces
[
jj
][
kk
]
-=
force
;
...
@@ -602,9 +598,9 @@ void ReferenceLJCoulombIxn::calculateOneIxn( int ii, int jj, vector<RealVec>& at
...
@@ -602,9 +598,9 @@ void ReferenceLJCoulombIxn::calculateOneIxn( int ii, int jj, vector<RealVec>& at
// accumulate energies
// accumulate energies
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/ReferenceLincsAlgorithm.cpp
View file @
162d69a2
...
@@ -24,15 +24,13 @@
...
@@ -24,15 +24,13 @@
#include <string.h>
#include <string.h>
#include <sstream>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMLog.h"
#include "ReferenceLincsAlgorithm.h"
#include "ReferenceLincsAlgorithm.h"
#include "ReferenceDynamics.h"
#include "ReferenceDynamics.h"
#include "openmm/OpenMMException.h"
#include "openmm/OpenMMException.h"
using
std
::
vector
;
using
std
::
vector
;
using
OpenMM
::
RealVec
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -44,9 +42,9 @@ using OpenMM::RealVec;
...
@@ -44,9 +42,9 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceLincsAlgorithm
::
ReferenceLincsAlgorithm
(
int
numberOfConstraints
,
ReferenceLincsAlgorithm
::
ReferenceLincsAlgorithm
(
int
numberOfConstraints
,
int
**
atomIndices
,
int
**
atomIndices
,
RealOpenMM
*
distance
){
RealOpenMM
*
distance
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -70,7 +68,7 @@ ReferenceLincsAlgorithm::ReferenceLincsAlgorithm( int numberOfConstraints,
...
@@ -70,7 +68,7 @@ ReferenceLincsAlgorithm::ReferenceLincsAlgorithm( int numberOfConstraints,
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceLincsAlgorithm
::
getNumberOfConstraints
(
void
)
const
{
int
ReferenceLincsAlgorithm
::
getNumberOfConstraints
()
const
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -89,7 +87,7 @@ int ReferenceLincsAlgorithm::getNumberOfConstraints( void ) const {
...
@@ -89,7 +87,7 @@ int ReferenceLincsAlgorithm::getNumberOfConstraints( void ) const {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceLincsAlgorithm
::
getNumTerms
(
void
)
const
{
int
ReferenceLincsAlgorithm
::
getNumTerms
()
const
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -106,7 +104,7 @@ int ReferenceLincsAlgorithm::getNumTerms( void ) const {
...
@@ -106,7 +104,7 @@ int ReferenceLincsAlgorithm::getNumTerms( void ) const {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceLincsAlgorithm
::
setNumTerms
(
int
terms
){
void
ReferenceLincsAlgorithm
::
setNumTerms
(
int
terms
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -214,14 +212,11 @@ void ReferenceLincsAlgorithm::updateAtomPositions(int numberOfAtoms, vector<Real
...
@@ -214,14 +212,11 @@ void ReferenceLincsAlgorithm::updateAtomPositions(int numberOfAtoms, vector<Real
@param atomCoordinatesP atom coordinates prime
@param atomCoordinatesP atom coordinates prime
@param inverseMasses 1/mass
@param inverseMasses 1/mass
@return SimTKOpenMMCommon::DefaultReturn if converge; else
return SimTKOpenMMCommon::ErrorReturn
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceLincsAlgorithm
::
apply
(
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
void
ReferenceLincsAlgorithm
::
apply
(
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealVec
>&
atomCoordinatesP
,
vector
<
RealVec
>&
atomCoordinatesP
,
vector
<
RealOpenMM
>&
inverseMasses
){
vector
<
RealOpenMM
>&
inverseMasses
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -234,9 +229,9 @@ int ReferenceLincsAlgorithm::apply( int numberOfAtoms, vector<RealVec>& atomCoor
...
@@ -234,9 +229,9 @@ int ReferenceLincsAlgorithm::apply( int numberOfAtoms, vector<RealVec>& atomCoor
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
if
(
_numberOfConstraints
==
0
)
if
(
_numberOfConstraints
==
0
)
return
SimTKOpenMMCommon
::
DefaultReturn
;
return
;
if
(
!
_hasInitialized
)
if
(
!
_hasInitialized
)
initialize
(
numberOfAtoms
,
inverseMasses
);
initialize
(
numberOfAtoms
,
inverseMasses
);
// Calculate the direction of each constraint, along with the initial RHS and solution vectors.
// Calculate the direction of each constraint, along with the initial RHS and solution vectors.
...
@@ -288,9 +283,6 @@ int ReferenceLincsAlgorithm::apply( int numberOfAtoms, vector<RealVec>& atomCoor
...
@@ -288,9 +283,6 @@ int ReferenceLincsAlgorithm::apply( int numberOfAtoms, vector<RealVec>& atomCoor
}
}
solveMatrix
();
solveMatrix
();
updateAtomPositions
(
numberOfAtoms
,
atomCoordinatesP
,
inverseMasses
);
updateAtomPositions
(
numberOfAtoms
,
atomCoordinatesP
,
inverseMasses
);
return
SimTKOpenMMCommon
::
DefaultReturn
;
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -302,12 +294,9 @@ int ReferenceLincsAlgorithm::apply( int numberOfAtoms, vector<RealVec>& atomCoor
...
@@ -302,12 +294,9 @@ int ReferenceLincsAlgorithm::apply( int numberOfAtoms, vector<RealVec>& atomCoor
@param velocities atom velocities
@param velocities atom velocities
@param inverseMasses 1/mass
@param inverseMasses 1/mass
@return SimTKOpenMMCommon::DefaultReturn if converge; else
return SimTKOpenMMCommon::ErrorReturn
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceLincsAlgorithm
::
applyToVelocities
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
void
ReferenceLincsAlgorithm
::
applyToVelocities
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
)
{
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
)
{
throw
OpenMM
::
OpenMMException
(
"applyToVelocities is not implemented"
);
throw
OpenMM
::
OpenMMException
(
"applyToVelocities is not implemented"
);
}
}
platforms/reference/src/SimTKReference/ReferenceMonteCarloBarostat.cpp
View file @
162d69a2
...
@@ -49,7 +49,7 @@ ReferenceMonteCarloBarostat::ReferenceMonteCarloBarostat(int numAtoms, const vec
...
@@ -49,7 +49,7 @@ ReferenceMonteCarloBarostat::ReferenceMonteCarloBarostat(int numAtoms, const vec
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceMonteCarloBarostat
::~
ReferenceMonteCarloBarostat
(
)
{
ReferenceMonteCarloBarostat
::~
ReferenceMonteCarloBarostat
()
{
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
...
platforms/reference/src/SimTKReference/ReferenceNeighborList.cpp
View file @
162d69a2
...
@@ -45,12 +45,12 @@ void OPENMM_EXPORT computeNeighborListNaive(
...
@@ -45,12 +45,12 @@ void OPENMM_EXPORT computeNeighborListNaive(
for
(
AtomIndex
atomJ
=
atomI
+
1
;
atomJ
<
(
AtomIndex
)
nAtoms
;
++
atomJ
)
for
(
AtomIndex
atomJ
=
atomI
+
1
;
atomJ
<
(
AtomIndex
)
nAtoms
;
++
atomJ
)
{
{
double
pairDistanceSquared
=
compPairDistanceSquared
(
atomLocations
[
atomI
],
atomLocations
[
atomJ
],
periodicBoxVectors
,
usePeriodic
);
double
pairDistanceSquared
=
compPairDistanceSquared
(
atomLocations
[
atomI
],
atomLocations
[
atomJ
],
periodicBoxVectors
,
usePeriodic
);
if
(
(
pairDistanceSquared
<=
maxDistanceSquared
)
&&
(
pairDistanceSquared
>=
minDistanceSquared
))
if
((
pairDistanceSquared
<=
maxDistanceSquared
)
&&
(
pairDistanceSquared
>=
minDistanceSquared
))
if
(
exclusions
[
atomI
].
find
(
atomJ
)
==
exclusions
[
atomI
].
end
())
if
(
exclusions
[
atomI
].
find
(
atomJ
)
==
exclusions
[
atomI
].
end
())
{
{
neighborList
.
push_back
(
AtomPair
(
atomI
,
atomJ
)
);
neighborList
.
push_back
(
AtomPair
(
atomI
,
atomJ
));
if
(
reportSymmetricPairs
)
if
(
reportSymmetricPairs
)
neighborList
.
push_back
(
AtomPair
(
atomI
,
atomJ
)
);
neighborList
.
push_back
(
AtomPair
(
atomI
,
atomJ
));
}
}
}
}
}
}
...
@@ -199,9 +199,9 @@ public:
...
@@ -199,9 +199,9 @@ public:
// Ignore exclusions.
// Ignore exclusions.
if
(
exclusions
[
atomI
].
find
(
atomJ
)
!=
exclusions
[
atomI
].
end
())
continue
;
if
(
exclusions
[
atomI
].
find
(
atomJ
)
!=
exclusions
[
atomI
].
end
())
continue
;
neighbors
.
push_back
(
AtomPair
(
atomI
,
atomJ
)
);
neighbors
.
push_back
(
AtomPair
(
atomI
,
atomJ
));
if
(
reportSymmetricPairs
)
if
(
reportSymmetricPairs
)
neighbors
.
push_back
(
AtomPair
(
atomJ
,
atomI
)
);
neighbors
.
push_back
(
AtomPair
(
atomJ
,
atomI
));
}
}
}
}
}
}
...
@@ -228,7 +228,7 @@ void OPENMM_EXPORT computeNeighborListVoxelHash(
...
@@ -228,7 +228,7 @@ void OPENMM_EXPORT computeNeighborListVoxelHash(
double
maxDistance
,
double
maxDistance
,
double
minDistance
,
double
minDistance
,
bool
reportSymmetricPairs
bool
reportSymmetricPairs
)
)
{
{
neighborList
.
clear
();
neighborList
.
clear
();
...
@@ -245,7 +245,7 @@ void OPENMM_EXPORT computeNeighborListVoxelHash(
...
@@ -245,7 +245,7 @@ void OPENMM_EXPORT computeNeighborListVoxelHash(
{
{
// 1) Find other atoms that are close to this one
// 1) Find other atoms that are close to this one
const
RealVec
&
location
=
atomLocations
[
atomJ
];
const
RealVec
&
location
=
atomLocations
[
atomJ
];
voxelHash
.
getNeighbors
(
voxelHash
.
getNeighbors
(
neighborList
,
neighborList
,
VoxelItem
(
&
location
,
atomJ
),
VoxelItem
(
&
location
,
atomJ
),
exclusions
,
exclusions
,
...
...
platforms/reference/src/
gbsa/Cpu
Obc.cpp
→
platforms/reference/src/
SimTKReference/Reference
Obc.cpp
View file @
162d69a2
...
@@ -28,32 +28,31 @@
...
@@ -28,32 +28,31 @@
#include <cmath>
#include <cmath>
#include <cstdio>
#include <cstdio>
#include "SimTKOpenMMCommon.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
#include "
Cpu
Obc.h"
#include "
Reference
Obc.h"
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Cpu
Obc constructor
Reference
Obc constructor
obcParameters obcParameters object
obcParameters obcParameters object
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
CpuObc
::
Cpu
Obc
(
ObcParameters
*
obcParameters
)
:
_obcParameters
(
obcParameters
),
_includeAceApproximation
(
1
)
{
ReferenceObc
::
Reference
Obc
(
ObcParameters
*
obcParameters
)
:
_obcParameters
(
obcParameters
),
_includeAceApproximation
(
1
)
{
_obcChain
.
resize
(
_obcParameters
->
getNumberOfAtoms
());
_obcChain
.
resize
(
_obcParameters
->
getNumberOfAtoms
());
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Cpu
Obc destructor
Reference
Obc destructor
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
CpuObc
::~
Cpu
Obc
(
){
ReferenceObc
::~
Reference
Obc
()
{
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -64,7 +63,7 @@ CpuObc::~CpuObc( ){
...
@@ -64,7 +63,7 @@ CpuObc::~CpuObc( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ObcParameters
*
Cpu
Obc
::
getObcParameters
(
void
)
const
{
ObcParameters
*
Reference
Obc
::
getObcParameters
()
const
{
return
_obcParameters
;
return
_obcParameters
;
}
}
...
@@ -76,7 +75,7 @@ ObcParameters* CpuObc::getObcParameters( void ) const {
...
@@ -76,7 +75,7 @@ ObcParameters* CpuObc::getObcParameters( void ) const {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
Cpu
Obc
::
setObcParameters
(
ObcParameters
*
obcParameters
){
void
Reference
Obc
::
setObcParameters
(
ObcParameters
*
obcParameters
)
{
_obcParameters
=
obcParameters
;
_obcParameters
=
obcParameters
;
}
}
...
@@ -88,7 +87,7 @@ void CpuObc::setObcParameters( ObcParameters* obcParameters ){
...
@@ -88,7 +87,7 @@ void CpuObc::setObcParameters( ObcParameters* obcParameters ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
Cpu
Obc
::
includeAceApproximation
(
void
)
const
{
int
Reference
Obc
::
includeAceApproximation
()
const
{
return
_includeAceApproximation
;
return
_includeAceApproximation
;
}
}
...
@@ -100,7 +99,7 @@ int CpuObc::includeAceApproximation( void ) const {
...
@@ -100,7 +99,7 @@ int CpuObc::includeAceApproximation( void ) const {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
Cpu
Obc
::
setIncludeAceApproximation
(
int
includeAceApproximation
){
void
Reference
Obc
::
setIncludeAceApproximation
(
int
includeAceApproximation
)
{
_includeAceApproximation
=
includeAceApproximation
;
_includeAceApproximation
=
includeAceApproximation
;
}
}
...
@@ -112,7 +111,7 @@ void CpuObc::setIncludeAceApproximation( int includeAceApproximation ){
...
@@ -112,7 +111,7 @@ void CpuObc::setIncludeAceApproximation( int includeAceApproximation ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
vector
<
RealOpenMM
>&
Cpu
Obc
::
getObcChain
(
void
){
vector
<
RealOpenMM
>&
Reference
Obc
::
getObcChain
()
{
return
_obcChain
;
return
_obcChain
;
}
}
...
@@ -128,25 +127,25 @@ vector<RealOpenMM>& CpuObc::getObcChain( void ){
...
@@ -128,25 +127,25 @@ vector<RealOpenMM>& CpuObc::getObcChain( void ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
Cpu
Obc
::
computeBornRadii
(
const
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealOpenMM
>&
bornRadii
){
void
Reference
Obc
::
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
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
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
);
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
ObcParameters
*
obcParameters
=
getObcParameters
();
ObcParameters
*
obcParameters
=
getObcParameters
();
int
numberOfAtoms
=
obcParameters
->
getNumberOfAtoms
();
int
numberOfAtoms
=
obcParameters
->
getNumberOfAtoms
();
const
RealOpenMM
Vector
&
atomicRadii
=
obcParameters
->
getAtomicRadii
();
const
vector
<
RealOpenMM
>
&
atomicRadii
=
obcParameters
->
getAtomicRadii
();
const
RealOpenMM
Vector
&
scaledRadiusFactor
=
obcParameters
->
getScaledRadiusFactors
();
const
vector
<
RealOpenMM
>
&
scaledRadiusFactor
=
obcParameters
->
getScaledRadiusFactors
();
RealOpenMM
Vector
&
obcChain
=
getObcChain
();
vector
<
RealOpenMM
>
&
obcChain
=
getObcChain
();
RealOpenMM
dielectricOffset
=
obcParameters
->
getDielectricOffset
();
RealOpenMM
dielectricOffset
=
obcParameters
->
getDielectricOffset
();
RealOpenMM
alphaObc
=
obcParameters
->
getAlphaObc
();
RealOpenMM
alphaObc
=
obcParameters
->
getAlphaObc
();
...
@@ -157,7 +156,7 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
...
@@ -157,7 +156,7 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
// 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
offsetRadiusI
=
radiusI
-
dielectricOffset
;
RealOpenMM
offsetRadiusI
=
radiusI
-
dielectricOffset
;
...
@@ -167,15 +166,15 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
...
@@ -167,15 +166,15 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
// HCT code
// HCT code
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
(
_obcParameters
->
getPeriodic
())
if
(
_obcParameters
->
getPeriodic
())
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
_obcParameters
->
getPeriodicBox
(),
deltaR
);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
_obcParameters
->
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
(
_obcParameters
->
getUseCutoff
()
&&
r
>
_obcParameters
->
getCutoffDistance
())
if
(
_obcParameters
->
getUseCutoff
()
&&
r
>
_obcParameters
->
getCutoffDistance
())
continue
;
continue
;
...
@@ -184,9 +183,9 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
...
@@ -184,9 +183,9 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
RealOpenMM
scaledRadiusJ
=
offsetRadiusJ
*
scaledRadiusFactor
[
atomJ
];
RealOpenMM
scaledRadiusJ
=
offsetRadiusJ
*
scaledRadiusFactor
[
atomJ
];
RealOpenMM
rScaledRadiusJ
=
r
+
scaledRadiusJ
;
RealOpenMM
rScaledRadiusJ
=
r
+
scaledRadiusJ
;
if
(
offsetRadiusI
<
rScaledRadiusJ
){
if
(
offsetRadiusI
<
rScaledRadiusJ
)
{
RealOpenMM
rInverse
=
one
/
r
;
RealOpenMM
rInverse
=
one
/
r
;
RealOpenMM
l_ij
=
offsetRadiusI
>
FABS
(
r
-
scaledRadiusJ
)
?
offsetRadiusI
:
FABS
(
r
-
scaledRadiusJ
);
RealOpenMM
l_ij
=
offsetRadiusI
>
FABS
(
r
-
scaledRadiusJ
)
?
offsetRadiusI
:
FABS
(
r
-
scaledRadiusJ
);
l_ij
=
one
/
l_ij
;
l_ij
=
one
/
l_ij
;
RealOpenMM
u_ij
=
one
/
rScaledRadiusJ
;
RealOpenMM
u_ij
=
one
/
rScaledRadiusJ
;
...
@@ -194,15 +193,15 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
...
@@ -194,15 +193,15 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
RealOpenMM
l_ij2
=
l_ij
*
l_ij
;
RealOpenMM
l_ij2
=
l_ij
*
l_ij
;
RealOpenMM
u_ij2
=
u_ij
*
u_ij
;
RealOpenMM
u_ij2
=
u_ij
*
u_ij
;
RealOpenMM
ratio
=
LN
(
(
u_ij
/
l_ij
)
);
RealOpenMM
ratio
=
LN
((
u_ij
/
l_ij
));
RealOpenMM
term
=
l_ij
-
u_ij
+
fourth
*
r
*
(
u_ij2
-
l_ij2
)
+
(
half
*
rInverse
*
ratio
)
+
(
fourth
*
scaledRadiusJ
*
scaledRadiusJ
*
rInverse
)
*
(
l_ij2
-
u_ij2
);
RealOpenMM
term
=
l_ij
-
u_ij
+
fourth
*
r
*
(
u_ij2
-
l_ij2
)
+
(
half
*
rInverse
*
ratio
)
+
(
fourth
*
scaledRadiusJ
*
scaledRadiusJ
*
rInverse
)
*
(
l_ij2
-
u_ij2
);
// this case (atom i completely inside atom j) is not considered in the original paper
// this case (atom i completely inside atom j) is not considered in the original paper
// Jay Ponder and the authors of Tinker recognized this and
// Jay Ponder and the authors of Tinker recognized this and
// worked out the details
// worked out the details
if
(
offsetRadiusI
<
(
scaledRadiusJ
-
r
)
){
if
(
offsetRadiusI
<
(
scaledRadiusJ
-
r
))
{
term
+=
two
*
(
radiusIInverse
-
l_ij
);
term
+=
two
*
(
radiusIInverse
-
l_ij
);
}
}
sum
+=
term
;
sum
+=
term
;
...
@@ -215,11 +214,11 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
...
@@ -215,11 +214,11 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
sum
*=
half
*
offsetRadiusI
;
sum
*=
half
*
offsetRadiusI
;
RealOpenMM
sum2
=
sum
*
sum
;
RealOpenMM
sum2
=
sum
*
sum
;
RealOpenMM
sum3
=
sum
*
sum2
;
RealOpenMM
sum3
=
sum
*
sum2
;
RealOpenMM
tanhSum
=
TANH
(
alphaObc
*
sum
-
betaObc
*
sum2
+
gammaObc
*
sum3
);
RealOpenMM
tanhSum
=
TANH
(
alphaObc
*
sum
-
betaObc
*
sum2
+
gammaObc
*
sum3
);
bornRadii
[
atomI
]
=
one
/
(
one
/
offsetRadiusI
-
tanhSum
/
radiusI
);
bornRadii
[
atomI
]
=
one
/
(
one
/
offsetRadiusI
-
tanhSum
/
radiusI
);
obcChain
[
atomI
]
=
offsetRadiusI
*
(
alphaObc
-
two
*
betaObc
*
sum
+
three
*
gammaObc
*
sum2
);
obcChain
[
atomI
]
=
offsetRadiusI
*
(
alphaObc
-
two
*
betaObc
*
sum
+
three
*
gammaObc
*
sum2
);
obcChain
[
atomI
]
=
(
one
-
tanhSum
*
tanhSum
)
*
obcChain
[
atomI
]
/
radiusI
;
obcChain
[
atomI
]
=
(
one
-
tanhSum
*
tanhSum
)
*
obcChain
[
atomI
]
/
radiusI
;
}
}
...
@@ -236,16 +235,16 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
...
@@ -236,16 +235,16 @@ void CpuObc::computeBornRadii( const vector<RealVec>& atomCoordinates, vector<Re
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
Cpu
Obc
::
computeAceNonPolarForce
(
const
ObcParameters
*
obcParameters
,
void
Reference
Obc
::
computeAceNonPolarForce
(
const
ObcParameters
*
obcParameters
,
const
RealOpenMM
Vector
&
bornRadii
,
const
vector
<
RealOpenMM
>
&
bornRadii
,
RealOpenMM
*
energy
,
RealOpenMM
*
energy
,
RealOpenMM
Vector
&
forces
)
const
{
vector
<
RealOpenMM
>
&
forces
)
const
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
static
const
RealOpenMM
zero
=
static_cast
<
RealOpenMM
>
(
0.0
);
static
const
RealOpenMM
zero
=
static_cast
<
RealOpenMM
>
(
0.0
);
static
const
RealOpenMM
minusSix
=
-
6.0
;
static
const
RealOpenMM
minusSix
=
-
6.0
;
static
const
RealOpenMM
six
=
static_cast
<
RealOpenMM
>
(
6.0
);
static
const
RealOpenMM
six
=
static_cast
<
RealOpenMM
>
(
6.0
);
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -254,7 +253,7 @@ void CpuObc::computeAceNonPolarForce( const ObcParameters* obcParameters,
...
@@ -254,7 +253,7 @@ void CpuObc::computeAceNonPolarForce( const ObcParameters* obcParameters,
const
RealOpenMM
probeRadius
=
obcParameters
->
getProbeRadius
();
const
RealOpenMM
probeRadius
=
obcParameters
->
getProbeRadius
();
const
RealOpenMM
surfaceAreaFactor
=
obcParameters
->
getPi4Asolv
();
const
RealOpenMM
surfaceAreaFactor
=
obcParameters
->
getPi4Asolv
();
const
RealOpenMM
Vector
&
atomicRadii
=
obcParameters
->
getAtomicRadii
();
const
vector
<
RealOpenMM
>
&
atomicRadii
=
obcParameters
->
getAtomicRadii
();
int
numberOfAtoms
=
obcParameters
->
getNumberOfAtoms
();
int
numberOfAtoms
=
obcParameters
->
getNumberOfAtoms
();
// the original ACE equation is based on Eq.2 of
// the original ACE equation is based on Eq.2 of
...
@@ -271,10 +270,10 @@ void CpuObc::computeAceNonPolarForce( const ObcParameters* obcParameters,
...
@@ -271,10 +270,10 @@ void CpuObc::computeAceNonPolarForce( const ObcParameters* obcParameters,
// observed values. He did not think it was important enough to write up, so there is
// observed values. He did not think it was important enough to write up, so there is
// no paper to cite.
// no paper to cite.
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
){
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
)
{
if
(
bornRadii
[
atomI
]
>
zero
){
if
(
bornRadii
[
atomI
]
>
zero
)
{
RealOpenMM
r
=
atomicRadii
[
atomI
]
+
probeRadius
;
RealOpenMM
r
=
atomicRadii
[
atomI
]
+
probeRadius
;
RealOpenMM
ratio6
=
POW
(
atomicRadii
[
atomI
]
/
bornRadii
[
atomI
],
six
);
RealOpenMM
ratio6
=
POW
(
atomicRadii
[
atomI
]
/
bornRadii
[
atomI
],
six
);
RealOpenMM
saTerm
=
surfaceAreaFactor
*
r
*
r
*
ratio6
;
RealOpenMM
saTerm
=
surfaceAreaFactor
*
r
*
r
*
ratio6
;
*
energy
+=
saTerm
;
*
energy
+=
saTerm
;
forces
[
atomI
]
+=
minusSix
*
saTerm
/
bornRadii
[
atomI
];
forces
[
atomI
]
+=
minusSix
*
saTerm
/
bornRadii
[
atomI
];
...
@@ -294,19 +293,19 @@ void CpuObc::computeAceNonPolarForce( const ObcParameters* obcParameters,
...
@@ -294,19 +293,19 @@ void CpuObc::computeAceNonPolarForce( const ObcParameters* obcParameters,
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
Cpu
Obc
::
computeBornEnergyForces
(
const
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
Reference
Obc
::
computeBornEnergyForces
(
const
vector
<
RealVec
>&
atomCoordinates
,
const
RealOpenMM
Vector
&
partialCharges
,
vector
<
RealVec
>&
inputForces
){
const
vector
<
RealOpenMM
>
&
partialCharges
,
vector
<
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
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
);
// constants
// constants
...
@@ -325,36 +324,36 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
...
@@ -325,36 +324,36 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
// 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
RealOpenMM
obcEnergy
=
zero
;
RealOpenMM
obcEnergy
=
zero
;
RealOpenMM
Vector
bornForces
(
numberOfAtoms
,
0.0
);
vector
<
RealOpenMM
>
bornForces
(
numberOfAtoms
,
0.0
);
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// compute the nonpolar solvation via ACE approximation
// compute the nonpolar solvation via ACE approximation
if
(
includeAceApproximation
()
){
if
(
includeAceApproximation
())
{
computeAceNonPolarForce
(
_obcParameters
,
bornRadii
,
&
obcEnergy
,
bornForces
);
computeAceNonPolarForce
(
_obcParameters
,
bornRadii
,
&
obcEnergy
,
bornForces
);
}
}
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// first main loop
// first main loop
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
){
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
)
{
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
(
_obcParameters
->
getPeriodic
())
if
(
_obcParameters
->
getPeriodic
())
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
_obcParameters
->
getPeriodicBox
(),
deltaR
);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
_obcParameters
->
getPeriodicBox
(),
deltaR
);
else
else
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
deltaR
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
deltaR
);
if
(
_obcParameters
->
getUseCutoff
()
&&
deltaR
[
ReferenceForce
::
RIndex
]
>
cutoffDistance
)
if
(
_obcParameters
->
getUseCutoff
()
&&
deltaR
[
ReferenceForce
::
RIndex
]
>
cutoffDistance
)
continue
;
continue
;
...
@@ -366,18 +365,18 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
...
@@ -366,18 +365,18 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
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
;
RealOpenMM
energy
=
Gpol
;
RealOpenMM
energy
=
Gpol
;
if
(
atomI
!=
atomJ
){
if
(
atomI
!=
atomJ
)
{
if
(
_obcParameters
->
getUseCutoff
())
if
(
_obcParameters
->
getUseCutoff
())
energy
-=
partialChargeI
*
partialCharges
[
atomJ
]
/
cutoffDistance
;
energy
-=
partialChargeI
*
partialCharges
[
atomJ
]
/
cutoffDistance
;
...
@@ -410,36 +409,36 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
...
@@ -410,36 +409,36 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
// second main loop
// second main loop
const
RealOpenMM
Vector
&
obcChain
=
getObcChain
();
const
vector
<
RealOpenMM
>
&
obcChain
=
getObcChain
();
const
RealOpenMM
Vector
&
atomicRadii
=
_obcParameters
->
getAtomicRadii
();
const
vector
<
RealOpenMM
>
&
atomicRadii
=
_obcParameters
->
getAtomicRadii
();
const
RealOpenMM
alphaObc
=
_obcParameters
->
getAlphaObc
();
const
RealOpenMM
alphaObc
=
_obcParameters
->
getAlphaObc
();
const
RealOpenMM
betaObc
=
_obcParameters
->
getBetaObc
();
const
RealOpenMM
betaObc
=
_obcParameters
->
getBetaObc
();
const
RealOpenMM
gammaObc
=
_obcParameters
->
getGammaObc
();
const
RealOpenMM
gammaObc
=
_obcParameters
->
getGammaObc
();
const
RealOpenMM
Vector
&
scaledRadiusFactor
=
_obcParameters
->
getScaledRadiusFactors
();
const
vector
<
RealOpenMM
>
&
scaledRadiusFactor
=
_obcParameters
->
getScaledRadiusFactors
();
// compute factor that depends only on the outer loop index
// compute factor that depends only on the outer loop index
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
){
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
)
{
bornForces
[
atomI
]
*=
bornRadii
[
atomI
]
*
bornRadii
[
atomI
]
*
obcChain
[
atomI
];
bornForces
[
atomI
]
*=
bornRadii
[
atomI
]
*
bornRadii
[
atomI
]
*
obcChain
[
atomI
];
}
}
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
){
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
)
{
// radius w/ dielectric offset applied
// radius w/ dielectric offset applied
RealOpenMM
radiusI
=
atomicRadii
[
atomI
];
RealOpenMM
radiusI
=
atomicRadii
[
atomI
];
RealOpenMM
offsetRadiusI
=
radiusI
-
dielectricOffset
;
RealOpenMM
offsetRadiusI
=
radiusI
-
dielectricOffset
;
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
(
_obcParameters
->
getPeriodic
())
if
(
_obcParameters
->
getPeriodic
())
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
_obcParameters
->
getPeriodicBox
(),
deltaR
);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
_obcParameters
->
getPeriodicBox
(),
deltaR
);
else
else
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
deltaR
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomI
],
atomCoordinates
[
atomJ
],
deltaR
);
if
(
_obcParameters
->
getUseCutoff
()
&&
deltaR
[
ReferenceForce
::
RIndex
]
>
cutoffDistance
)
if
(
_obcParameters
->
getUseCutoff
()
&&
deltaR
[
ReferenceForce
::
RIndex
]
>
cutoffDistance
)
continue
;
continue
;
...
@@ -459,9 +458,9 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
...
@@ -459,9 +458,9 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
// dL/dr & dU/dr are zero (this can be shown analytically)
// dL/dr & dU/dr are zero (this can be shown analytically)
// removed from calculation
// removed from calculation
if
(
offsetRadiusI
<
rScaledRadiusJ
){
if
(
offsetRadiusI
<
rScaledRadiusJ
)
{
RealOpenMM
l_ij
=
offsetRadiusI
>
FABS
(
r
-
scaledRadiusJ
)
?
offsetRadiusI
:
FABS
(
r
-
scaledRadiusJ
);
RealOpenMM
l_ij
=
offsetRadiusI
>
FABS
(
r
-
scaledRadiusJ
)
?
offsetRadiusI
:
FABS
(
r
-
scaledRadiusJ
);
l_ij
=
one
/
l_ij
;
l_ij
=
one
/
l_ij
;
RealOpenMM
u_ij
=
one
/
rScaledRadiusJ
;
RealOpenMM
u_ij
=
one
/
rScaledRadiusJ
;
...
@@ -473,7 +472,7 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
...
@@ -473,7 +472,7 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
RealOpenMM
rInverse
=
one
/
r
;
RealOpenMM
rInverse
=
one
/
r
;
RealOpenMM
r2Inverse
=
rInverse
*
rInverse
;
RealOpenMM
r2Inverse
=
rInverse
*
rInverse
;
RealOpenMM
t3
=
eighth
*
(
one
+
scaledRadiusJ2
*
r2Inverse
)
*
(
l_ij2
-
u_ij2
)
+
fourth
*
LN
(
u_ij
/
l_ij
)
*
r2Inverse
;
RealOpenMM
t3
=
eighth
*
(
one
+
scaledRadiusJ2
*
r2Inverse
)
*
(
l_ij2
-
u_ij2
)
+
fourth
*
LN
(
u_ij
/
l_ij
)
*
r2Inverse
;
RealOpenMM
de
=
bornForces
[
atomI
]
*
t3
*
rInverse
;
RealOpenMM
de
=
bornForces
[
atomI
]
*
t3
*
rInverse
;
...
@@ -495,90 +494,5 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
...
@@ -495,90 +494,5 @@ RealOpenMM CpuObc::computeBornEnergyForces( const vector<RealVec>& atomCoordinat
}
}
//printObc( atomCoordinates, partialCharges, bornRadii, bornForces, inputForces, "Obc Post loop2", stderr );
return
obcEnergy
;
return
obcEnergy
;
}
}
/**---------------------------------------------------------------------------------------
Print Obc 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
CpuObc
::
printObc
(
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
ObcParameters
*
obcParameters
=
getObcParameters
();
const
int
numberOfAtoms
=
obcParameters
->
getNumberOfAtoms
();
const
RealOpenMMVector
&
atomicRadii
=
obcParameters
->
getAtomicRadii
();
const
RealOpenMM
preFactor
=
2.0
*
obcParameters
->
getElectricConstant
();
const
RealOpenMMVector
&
obcChain
=
getObcChain
();
const
RealOpenMMVector
&
scaledRadiusFactor
=
obcParameters
->
getScaledRadiusFactors
();
const
RealOpenMM
alphaObc
=
obcParameters
->
getAlphaObc
();
const
RealOpenMM
betaObc
=
obcParameters
->
getBetaObc
();
const
RealOpenMM
gammaObc
=
obcParameters
->
getGammaObc
();
const
int
comparisonFormat
=
1
;
// ---------------------------------------------------------------------------------------
(
void
)
fprintf
(
log
,
"Reference Obc %s atoms=%d
\n
"
,
idString
.
c_str
(),
numberOfAtoms
);
if
(
comparisonFormat
){
(
void
)
fprintf
(
log
,
"Reference Obc %s atoms=%d Chain/Radii/Force
\n
"
,
idString
.
c_str
(),
numberOfAtoms
);
for
(
unsigned
int
atomI
=
0
;
atomI
<
static_cast
<
unsigned
int
>
(
numberOfAtoms
);
atomI
++
){
(
void
)
fprintf
(
log
,
"%6d "
,
atomI
);
if
(
obcChain
.
size
()
>
atomI
){
(
void
)
fprintf
(
log
,
" %15.7e"
,
obcChain
[
atomI
]
);
}
if
(
bornRadii
.
size
()
>
atomI
){
(
void
)
fprintf
(
log
,
" %15.7e"
,
bornRadii
[
atomI
]
);
}
if
(
bornForces
.
size
()
>
atomI
){
(
void
)
fprintf
(
log
,
" %15.7e"
,
bornForces
[
atomI
]
);
}
(
void
)
fprintf
(
log
,
" %15.7e %6.3f"
,
atomicRadii
[
atomI
],
partialCharges
[
atomI
]
);
(
void
)
fprintf
(
log
,
"
\n
"
);
}
}
else
{
(
void
)
fprintf
(
log
,
"Reference Obc %s atoms=%d
\n
"
,
idString
.
c_str
(),
numberOfAtoms
);
(
void
)
fprintf
(
log
,
" preFactor %15.7e
\n
"
,
preFactor
);
(
void
)
fprintf
(
log
,
" alpha %15.7e
\n
"
,
alphaObc
);
(
void
)
fprintf
(
log
,
" beta %15.7e
\n
"
,
betaObc
);
(
void
)
fprintf
(
log
,
" gamma %15.7e
\n
"
,
gammaObc
);
for
(
unsigned
int
atomI
=
0
;
atomI
<
static_cast
<
unsigned
int
>
(
numberOfAtoms
);
atomI
++
){
(
void
)
fprintf
(
log
,
"%6d r=%15.7e q=%6.3f"
,
atomI
,
atomicRadii
[
atomI
],
partialCharges
[
atomI
]
);
if
(
obcChain
.
size
()
>
atomI
){
(
void
)
fprintf
(
log
,
" bChn=%15.7e"
,
obcChain
[
atomI
]
);
}
if
(
bornRadii
.
size
()
>
atomI
){
(
void
)
fprintf
(
log
,
" bR=%15.7e"
,
bornRadii
[
atomI
]
);
}
if
(
bornForces
.
size
()
>
atomI
){
(
void
)
fprintf
(
log
,
" bF=%15.7e"
,
bornForces
[
atomI
]
);
}
(
void
)
fprintf
(
log
,
"
\n
"
);
}
}
return
;
}
platforms/reference/src/SimTKReference/ReferencePME.cpp
View file @
162d69a2
...
@@ -37,10 +37,10 @@
...
@@ -37,10 +37,10 @@
#include "fftpack.h"
#include "fftpack.h"
using
std
::
vector
;
using
std
::
vector
;
using
OpenMM
::
RealVec
;
typedef
int
ivec
[
3
];
typedef
int
ivec
[
3
];
namespace
OpenMM
{
struct
pme
struct
pme
{
{
...
@@ -77,7 +77,7 @@ struct pme
...
@@ -77,7 +77,7 @@ struct pme
* If particle i has coordinates { 0.543 , 6.235 , -0.73 }, we will get:
* If particle i has coordinates { 0.543 , 6.235 , -0.73 }, we will get:
*
*
* particleindex[i] = { 5 , 62 , 92 } (-0.73 + 10 = 9.27, we always apply PBC for grid calculations!)
* particleindex[i] = { 5 , 62 , 92 } (-0.73 + 10 = 9.27, we always apply PBC for grid calculations!)
* particlefraction[i] = { 0.43 , 0.35 , 0.7 } (
this is the fraction of the cell length where the atom is)
* particlefraction[i] = { 0.43 , 0.35 , 0.7 } (this is the fraction of the cell length where the atom is)
*
*
* (The reason for precaculating / storing these is that it gets a bit more complex for triclinic cells :-)
* (The reason for precaculating / storing these is that it gets a bit more complex for triclinic cells :-)
*
*
...
@@ -108,7 +108,7 @@ pme_calculate_bsplines_moduli(pme_t pme)
...
@@ -108,7 +108,7 @@ pme_calculate_bsplines_moduli(pme_t pme)
RealOpenMM
sc
,
ss
,
arg
;
RealOpenMM
sc
,
ss
,
arg
;
nmax
=
0
;
nmax
=
0
;
for
(
d
=
0
;
d
<
3
;
d
++
)
for
(
d
=
0
;
d
<
3
;
d
++
)
{
{
nmax
=
(
pme
->
ngrid
[
d
]
>
nmax
)
?
pme
->
ngrid
[
d
]
:
nmax
;
nmax
=
(
pme
->
ngrid
[
d
]
>
nmax
)
?
pme
->
ngrid
[
d
]
:
nmax
;
pme
->
bsplines_moduli
[
d
]
=
(
RealOpenMM
*
)
malloc
(
sizeof
(
RealOpenMM
)
*
pme
->
ngrid
[
d
]);
pme
->
bsplines_moduli
[
d
]
=
(
RealOpenMM
*
)
malloc
(
sizeof
(
RealOpenMM
)
*
pme
->
ngrid
[
d
]);
...
@@ -125,11 +125,11 @@ pme_calculate_bsplines_moduli(pme_t pme)
...
@@ -125,11 +125,11 @@ pme_calculate_bsplines_moduli(pme_t pme)
data
[
1
]
=
0
;
data
[
1
]
=
0
;
data
[
0
]
=
1
;
data
[
0
]
=
1
;
for
(
k
=
3
;
k
<
order
;
k
++
)
for
(
k
=
3
;
k
<
order
;
k
++
)
{
{
div
=
(
RealOpenMM
)
(
1.0
/
(
k
-
1.0
));
div
=
(
RealOpenMM
)
(
1.0
/
(
k
-
1.0
));
data
[
k
-
1
]
=
0
;
data
[
k
-
1
]
=
0
;
for
(
l
=
1
;
l
<
(
k
-
1
);
l
++
)
for
(
l
=
1
;
l
<
(
k
-
1
);
l
++
)
{
{
data
[
k
-
l
-
1
]
=
div
*
(
l
*
data
[
k
-
l
-
2
]
+
(
k
-
l
)
*
data
[
k
-
l
-
1
]);
data
[
k
-
l
-
1
]
=
div
*
(
l
*
data
[
k
-
l
-
2
]
+
(
k
-
l
)
*
data
[
k
-
l
-
1
]);
}
}
...
@@ -138,7 +138,7 @@ pme_calculate_bsplines_moduli(pme_t pme)
...
@@ -138,7 +138,7 @@ pme_calculate_bsplines_moduli(pme_t pme)
/* differentiate */
/* differentiate */
ddata
[
0
]
=-
data
[
0
];
ddata
[
0
]
=-
data
[
0
];
for
(
k
=
1
;
k
<
order
;
k
++
)
for
(
k
=
1
;
k
<
order
;
k
++
)
{
{
ddata
[
k
]
=
data
[
k
-
1
]
-
data
[
k
];
ddata
[
k
]
=
data
[
k
-
1
]
-
data
[
k
];
}
}
...
@@ -146,29 +146,29 @@ pme_calculate_bsplines_moduli(pme_t pme)
...
@@ -146,29 +146,29 @@ pme_calculate_bsplines_moduli(pme_t pme)
div
=
(
RealOpenMM
)
(
1.0
/
(
order
-
1
));
div
=
(
RealOpenMM
)
(
1.0
/
(
order
-
1
));
data
[
order
-
1
]
=
0
;
data
[
order
-
1
]
=
0
;
for
(
l
=
1
;
l
<
(
order
-
1
);
l
++
)
for
(
l
=
1
;
l
<
(
order
-
1
);
l
++
)
{
{
data
[
order
-
l
-
1
]
=
div
*
(
l
*
data
[
order
-
l
-
2
]
+
(
order
-
l
)
*
data
[
order
-
l
-
1
]);
data
[
order
-
l
-
1
]
=
div
*
(
l
*
data
[
order
-
l
-
2
]
+
(
order
-
l
)
*
data
[
order
-
l
-
1
]);
}
}
data
[
0
]
=
div
*
data
[
0
];
data
[
0
]
=
div
*
data
[
0
];
for
(
i
=
0
;
i
<
nmax
;
i
++
)
for
(
i
=
0
;
i
<
nmax
;
i
++
)
{
{
bsplines_data
[
i
]
=
0
;
bsplines_data
[
i
]
=
0
;
}
}
for
(
i
=
1
;
i
<=
order
;
i
++
)
for
(
i
=
1
;
i
<=
order
;
i
++
)
{
{
bsplines_data
[
i
]
=
data
[
i
-
1
];
bsplines_data
[
i
]
=
data
[
i
-
1
];
}
}
/* Evaluate the actual bspline moduli for X/Y/Z */
/* Evaluate the actual bspline moduli for X/Y/Z */
for
(
d
=
0
;
d
<
3
;
d
++
)
for
(
d
=
0
;
d
<
3
;
d
++
)
{
{
ndata
=
pme
->
ngrid
[
d
];
ndata
=
pme
->
ngrid
[
d
];
for
(
i
=
0
;
i
<
ndata
;
i
++
)
for
(
i
=
0
;
i
<
ndata
;
i
++
)
{
{
sc
=
ss
=
0
;
sc
=
ss
=
0
;
for
(
j
=
0
;
j
<
ndata
;
j
++
)
for
(
j
=
0
;
j
<
ndata
;
j
++
)
{
{
arg
=
(
RealOpenMM
)
((
2.0
*
M_PI
*
i
*
j
)
/
ndata
);
arg
=
(
RealOpenMM
)
((
2.0
*
M_PI
*
i
*
j
)
/
ndata
);
sc
+=
bsplines_data
[
j
]
*
cos
(
arg
);
sc
+=
bsplines_data
[
j
]
*
cos
(
arg
);
...
@@ -176,9 +176,9 @@ pme_calculate_bsplines_moduli(pme_t pme)
...
@@ -176,9 +176,9 @@ pme_calculate_bsplines_moduli(pme_t pme)
}
}
pme
->
bsplines_moduli
[
d
][
i
]
=
sc
*
sc
+
ss
*
ss
;
pme
->
bsplines_moduli
[
d
][
i
]
=
sc
*
sc
+
ss
*
ss
;
}
}
for
(
i
=
0
;
i
<
ndata
;
i
++
)
for
(
i
=
0
;
i
<
ndata
;
i
++
)
{
{
if
(
pme
->
bsplines_moduli
[
d
][
i
]
<
1.0e-7
)
if
(
pme
->
bsplines_moduli
[
d
][
i
]
<
1.0e-7
)
{
{
pme
->
bsplines_moduli
[
d
][
i
]
=
(
pme
->
bsplines_moduli
[
d
][
i
-
1
]
+
pme
->
bsplines_moduli
[
d
][
i
+
1
])
/
2
;
pme
->
bsplines_moduli
[
d
][
i
]
=
(
pme
->
bsplines_moduli
[
d
][
i
-
1
]
+
pme
->
bsplines_moduli
[
d
][
i
+
1
])
/
2
;
}
}
...
@@ -213,7 +213,7 @@ pme_update_grid_index_and_fraction(pme_t pme,
...
@@ -213,7 +213,7 @@ pme_update_grid_index_and_fraction(pme_t pme,
RealOpenMM
t
;
RealOpenMM
t
;
int
ti
;
int
ti
;
for
(
i
=
0
;
i
<
pme
->
natoms
;
i
++
)
for
(
i
=
0
;
i
<
pme
->
natoms
;
i
++
)
{
{
/* Index calculation (Look mom, no conditionals!):
/* Index calculation (Look mom, no conditionals!):
*
*
...
@@ -252,7 +252,7 @@ pme_update_grid_index_and_fraction(pme_t pme,
...
@@ -252,7 +252,7 @@ pme_update_grid_index_and_fraction(pme_t pme,
* (And, by adding 100.0 box lengths, we would lose a bit of numerical accuracy here!)
* (And, by adding 100.0 box lengths, we would lose a bit of numerical accuracy here!)
*/
*/
RealVec
coord
=
atomCoordinates
[
i
];
RealVec
coord
=
atomCoordinates
[
i
];
for
(
d
=
0
;
d
<
3
;
d
++
)
for
(
d
=
0
;
d
<
3
;
d
++
)
{
{
t
=
coord
[
0
]
*
recipBoxVectors
[
0
][
d
]
+
coord
[
1
]
*
recipBoxVectors
[
1
][
d
]
+
coord
[
2
]
*
recipBoxVectors
[
2
][
d
];
t
=
coord
[
0
]
*
recipBoxVectors
[
0
][
d
]
+
coord
[
1
]
*
recipBoxVectors
[
1
][
d
]
+
coord
[
2
]
*
recipBoxVectors
[
2
][
d
];
t
=
(
t
-
floor
(
t
))
*
pme
->
ngrid
[
d
];
t
=
(
t
-
floor
(
t
))
*
pme
->
ngrid
[
d
];
...
@@ -281,9 +281,9 @@ pme_update_bsplines(pme_t pme)
...
@@ -281,9 +281,9 @@ pme_update_bsplines(pme_t pme)
order
=
pme
->
order
;
order
=
pme
->
order
;
for
(
i
=
0
;
(
i
<
pme
->
natoms
);
i
++
)
for
(
i
=
0
;
(
i
<
pme
->
natoms
);
i
++
)
{
{
for
(
j
=
0
;
j
<
3
;
j
++
)
for
(
j
=
0
;
j
<
3
;
j
++
)
{
{
/* dr is relative offset from lower cell limit */
/* dr is relative offset from lower cell limit */
dr
=
pme
->
particlefraction
[
i
][
j
];
dr
=
pme
->
particlefraction
[
i
][
j
];
...
@@ -294,11 +294,11 @@ pme_update_bsplines(pme_t pme)
...
@@ -294,11 +294,11 @@ pme_update_bsplines(pme_t pme)
data
[
1
]
=
dr
;
data
[
1
]
=
dr
;
data
[
0
]
=
1
-
dr
;
data
[
0
]
=
1
-
dr
;
for
(
k
=
3
;
k
<
order
;
k
++
)
for
(
k
=
3
;
k
<
order
;
k
++
)
{
{
div
=
(
RealOpenMM
)
(
1.0
/
(
k
-
1.0
));
div
=
(
RealOpenMM
)
(
1.0
/
(
k
-
1.0
));
data
[
k
-
1
]
=
div
*
dr
*
data
[
k
-
2
];
data
[
k
-
1
]
=
div
*
dr
*
data
[
k
-
2
];
for
(
l
=
1
;
l
<
(
k
-
1
);
l
++
)
for
(
l
=
1
;
l
<
(
k
-
1
);
l
++
)
{
{
data
[
k
-
l
-
1
]
=
div
*
((
dr
+
l
)
*
data
[
k
-
l
-
2
]
+
(
k
-
l
-
dr
)
*
data
[
k
-
l
-
1
]);
data
[
k
-
l
-
1
]
=
div
*
((
dr
+
l
)
*
data
[
k
-
l
-
2
]
+
(
k
-
l
-
dr
)
*
data
[
k
-
l
-
1
]);
}
}
...
@@ -308,7 +308,7 @@ pme_update_bsplines(pme_t pme)
...
@@ -308,7 +308,7 @@ pme_update_bsplines(pme_t pme)
/* differentiate */
/* differentiate */
ddata
[
0
]
=
-
data
[
0
];
ddata
[
0
]
=
-
data
[
0
];
for
(
k
=
1
;
k
<
order
;
k
++
)
for
(
k
=
1
;
k
<
order
;
k
++
)
{
{
ddata
[
k
]
=
data
[
k
-
1
]
-
data
[
k
];
ddata
[
k
]
=
data
[
k
-
1
]
-
data
[
k
];
}
}
...
@@ -316,7 +316,7 @@ pme_update_bsplines(pme_t pme)
...
@@ -316,7 +316,7 @@ pme_update_bsplines(pme_t pme)
div
=
(
RealOpenMM
)
(
1.0
/
(
order
-
1
));
div
=
(
RealOpenMM
)
(
1.0
/
(
order
-
1
));
data
[
order
-
1
]
=
div
*
dr
*
data
[
order
-
2
];
data
[
order
-
1
]
=
div
*
dr
*
data
[
order
-
2
];
for
(
l
=
1
;
l
<
(
order
-
1
);
l
++
)
for
(
l
=
1
;
l
<
(
order
-
1
);
l
++
)
{
{
data
[
order
-
l
-
1
]
=
div
*
((
dr
+
l
)
*
data
[
order
-
l
-
2
]
+
(
order
-
l
-
dr
)
*
data
[
order
-
l
-
1
]);
data
[
order
-
l
-
1
]
=
div
*
((
dr
+
l
)
*
data
[
order
-
l
-
2
]
+
(
order
-
l
-
dr
)
*
data
[
order
-
l
-
1
]);
}
}
...
@@ -343,12 +343,12 @@ pme_grid_spread_charge(pme_t pme, const vector<RealOpenMM>& charges)
...
@@ -343,12 +343,12 @@ pme_grid_spread_charge(pme_t pme, const vector<RealOpenMM>& charges)
order
=
pme
->
order
;
order
=
pme
->
order
;
/* Reset the grid */
/* Reset the grid */
for
(
i
=
0
;
i
<
pme
->
ngrid
[
0
]
*
pme
->
ngrid
[
1
]
*
pme
->
ngrid
[
2
];
i
++
)
for
(
i
=
0
;
i
<
pme
->
ngrid
[
0
]
*
pme
->
ngrid
[
1
]
*
pme
->
ngrid
[
2
];
i
++
)
{
{
pme
->
grid
[
i
].
re
=
pme
->
grid
[
i
].
im
=
0
;
pme
->
grid
[
i
].
re
=
pme
->
grid
[
i
].
im
=
0
;
}
}
for
(
i
=
0
;
i
<
pme
->
natoms
;
i
++
)
for
(
i
=
0
;
i
<
pme
->
natoms
;
i
++
)
{
{
q
=
charges
[
i
];
q
=
charges
[
i
];
...
@@ -380,16 +380,16 @@ pme_grid_spread_charge(pme_t pme, const vector<RealOpenMM>& charges)
...
@@ -380,16 +380,16 @@ pme_grid_spread_charge(pme_t pme, const vector<RealOpenMM>& charges)
* 3) When we parallelize things, we only need to communicate in one direction instead of two!
* 3) When we parallelize things, we only need to communicate in one direction instead of two!
*/
*/
for
(
ix
=
0
;
ix
<
order
;
ix
++
)
for
(
ix
=
0
;
ix
<
order
;
ix
++
)
{
{
/* Calculate index, apply PBC so we spread to index 0/1/2 when a particle is close to the upper limit of the grid */
/* Calculate index, apply PBC so we spread to index 0/1/2 when a particle is close to the upper limit of the grid */
xindex
=
(
x0index
+
ix
)
%
pme
->
ngrid
[
0
];
xindex
=
(
x0index
+
ix
)
%
pme
->
ngrid
[
0
];
for
(
iy
=
0
;
iy
<
order
;
iy
++
)
for
(
iy
=
0
;
iy
<
order
;
iy
++
)
{
{
yindex
=
(
y0index
+
iy
)
%
pme
->
ngrid
[
1
];
yindex
=
(
y0index
+
iy
)
%
pme
->
ngrid
[
1
];
for
(
iz
=
0
;
iz
<
order
;
iz
++
)
for
(
iz
=
0
;
iz
<
order
;
iz
++
)
{
{
/* Can be optimized, but we keep it simple here */
/* Can be optimized, but we keep it simple here */
zindex
=
(
z0index
+
iz
)
%
pme
->
ngrid
[
2
];
zindex
=
(
z0index
+
iz
)
%
pme
->
ngrid
[
2
];
...
@@ -448,21 +448,21 @@ pme_reciprocal_convolution(pme_t pme,
...
@@ -448,21 +448,21 @@ pme_reciprocal_convolution(pme_t pme,
maxky
=
(
RealOpenMM
)
((
ny
+
1
)
/
2
);
maxky
=
(
RealOpenMM
)
((
ny
+
1
)
/
2
);
maxkz
=
(
RealOpenMM
)
((
nz
+
1
)
/
2
);
maxkz
=
(
RealOpenMM
)
((
nz
+
1
)
/
2
);
for
(
kx
=
0
;
kx
<
nx
;
kx
++
)
for
(
kx
=
0
;
kx
<
nx
;
kx
++
)
{
{
/* Calculate frequency. Grid indices in the upper half correspond to negative frequencies! */
/* Calculate frequency. Grid indices in the upper half correspond to negative frequencies! */
mx
=
(
RealOpenMM
)
((
kx
<
maxkx
)
?
kx
:
(
kx
-
nx
));
mx
=
(
RealOpenMM
)
((
kx
<
maxkx
)
?
kx
:
(
kx
-
nx
));
mhx
=
mx
*
recipBoxVectors
[
0
][
0
];
mhx
=
mx
*
recipBoxVectors
[
0
][
0
];
bx
=
boxfactor
*
pme
->
bsplines_moduli
[
0
][
kx
];
bx
=
boxfactor
*
pme
->
bsplines_moduli
[
0
][
kx
];
for
(
ky
=
0
;
ky
<
ny
;
ky
++
)
for
(
ky
=
0
;
ky
<
ny
;
ky
++
)
{
{
/* Calculate frequency. Grid indices in the upper half correspond to negative frequencies! */
/* Calculate frequency. Grid indices in the upper half correspond to negative frequencies! */
my
=
(
RealOpenMM
)
((
ky
<
maxky
)
?
ky
:
(
ky
-
ny
));
my
=
(
RealOpenMM
)
((
ky
<
maxky
)
?
ky
:
(
ky
-
ny
));
mhy
=
mx
*
recipBoxVectors
[
1
][
0
]
+
my
*
recipBoxVectors
[
1
][
1
];
mhy
=
mx
*
recipBoxVectors
[
1
][
0
]
+
my
*
recipBoxVectors
[
1
][
1
];
by
=
pme
->
bsplines_moduli
[
1
][
ky
];
by
=
pme
->
bsplines_moduli
[
1
][
ky
];
for
(
kz
=
0
;
kz
<
nz
;
kz
++
)
for
(
kz
=
0
;
kz
<
nz
;
kz
++
)
{
{
/* If the net charge of the system is 0.0, there will not be any DC (direct current, zero frequency) component. However,
/* If the net charge of the system is 0.0, there will not be any DC (direct current, zero frequency) component. However,
* we can still handle charged systems through a charge correction, in which case the DC
* we can still handle charged systems through a charge correction, in which case the DC
...
@@ -546,7 +546,7 @@ pme_grid_interpolate_force(pme_t pme,
...
@@ -546,7 +546,7 @@ pme_grid_interpolate_force(pme_t pme,
/* This is almost identical to the charge spreading routine! */
/* This is almost identical to the charge spreading routine! */
for
(
i
=
0
;
i
<
pme
->
natoms
;
i
++
)
for
(
i
=
0
;
i
<
pme
->
natoms
;
i
++
)
{
{
fx
=
fy
=
fz
=
0
;
fx
=
fy
=
fz
=
0
;
...
@@ -570,21 +570,21 @@ pme_grid_interpolate_force(pme_t pme,
...
@@ -570,21 +570,21 @@ pme_grid_interpolate_force(pme_t pme,
/* Since we will add order^3 (typically 4*4*4=64) terms to the force on each particle, we use temporary fx/fy/fz
/* Since we will add order^3 (typically 4*4*4=64) terms to the force on each particle, we use temporary fx/fy/fz
* variables, and only add it to memory forces[] at the end.
* variables, and only add it to memory forces[] at the end.
*/
*/
for
(
ix
=
0
;
ix
<
order
;
ix
++
)
for
(
ix
=
0
;
ix
<
order
;
ix
++
)
{
{
xindex
=
(
x0index
+
ix
)
%
pme
->
ngrid
[
0
];
xindex
=
(
x0index
+
ix
)
%
pme
->
ngrid
[
0
];
/* Get both the bspline factor and its derivative with respect to the x coordinate! */
/* Get both the bspline factor and its derivative with respect to the x coordinate! */
tx
=
thetax
[
ix
];
tx
=
thetax
[
ix
];
dtx
=
dthetax
[
ix
];
dtx
=
dthetax
[
ix
];
for
(
iy
=
0
;
iy
<
order
;
iy
++
)
for
(
iy
=
0
;
iy
<
order
;
iy
++
)
{
{
yindex
=
(
y0index
+
iy
)
%
pme
->
ngrid
[
1
];
yindex
=
(
y0index
+
iy
)
%
pme
->
ngrid
[
1
];
/* bspline + derivative wrt y */
/* bspline + derivative wrt y */
ty
=
thetay
[
iy
];
ty
=
thetay
[
iy
];
dty
=
dthetay
[
iy
];
dty
=
dthetay
[
iy
];
for
(
iz
=
0
;
iz
<
order
;
iz
++
)
for
(
iz
=
0
;
iz
<
order
;
iz
++
)
{
{
/* Can be optimized, but we keep it simple here */
/* Can be optimized, but we keep it simple here */
zindex
=
(
z0index
+
iz
)
%
pme
->
ngrid
[
2
];
zindex
=
(
z0index
+
iz
)
%
pme
->
ngrid
[
2
];
...
@@ -633,7 +633,7 @@ pme_init(pme_t * ppme,
...
@@ -633,7 +633,7 @@ pme_init(pme_t * ppme,
pme
->
ewaldcoeff
=
ewaldcoeff
;
pme
->
ewaldcoeff
=
ewaldcoeff
;
pme
->
natoms
=
natoms
;
pme
->
natoms
=
natoms
;
for
(
d
=
0
;
d
<
3
;
d
++
)
for
(
d
=
0
;
d
<
3
;
d
++
)
{
{
pme
->
ngrid
[
d
]
=
ngrid
[
d
];
pme
->
ngrid
[
d
]
=
ngrid
[
d
];
pme
->
bsplines_theta
[
d
]
=
(
RealOpenMM
*
)
malloc
(
sizeof
(
RealOpenMM
)
*
pme_order
*
natoms
);
pme
->
bsplines_theta
[
d
]
=
(
RealOpenMM
*
)
malloc
(
sizeof
(
RealOpenMM
)
*
pme_order
*
natoms
);
...
@@ -712,7 +712,7 @@ pme_destroy(pme_t pme)
...
@@ -712,7 +712,7 @@ pme_destroy(pme_t pme)
free
(
pme
->
grid
);
free
(
pme
->
grid
);
for
(
d
=
0
;
d
<
3
;
d
++
)
for
(
d
=
0
;
d
<
3
;
d
++
)
{
{
free
(
pme
->
bsplines_moduli
[
d
]);
free
(
pme
->
bsplines_moduli
[
d
]);
free
(
pme
->
bsplines_theta
[
d
]);
free
(
pme
->
bsplines_theta
[
d
]);
...
@@ -729,3 +729,5 @@ pme_destroy(pme_t pme)
...
@@ -729,3 +729,5 @@ pme_destroy(pme_t pme)
return
0
;
return
0
;
}
}
}
// namespace OpenMM
platforms/reference/src/SimTKReference/ReferencePairIxn.cpp
View file @
162d69a2
...
@@ -25,19 +25,19 @@
...
@@ -25,19 +25,19 @@
#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 "ReferencePairIxn.h"
#include "ReferencePairIxn.h"
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
ReferencePairIxn constructor
ReferencePairIxn constructor
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferencePairIxn
::
ReferencePairIxn
(
){
ReferencePairIxn
::
ReferencePairIxn
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -53,7 +53,7 @@ ReferencePairIxn::ReferencePairIxn( ){
...
@@ -53,7 +53,7 @@ ReferencePairIxn::ReferencePairIxn( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferencePairIxn
::~
ReferencePairIxn
(
){
ReferencePairIxn
::~
ReferencePairIxn
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
...
platforms/reference/src/SimTKReference/ReferenceProperDihedralBond.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 "ReferenceProperDihedralBond.h"
#include "ReferenceProperDihedralBond.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;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceProperDihedralBond
::
ReferenceProperDihedralBond
(
){
ReferenceProperDihedralBond
::
ReferenceProperDihedralBond
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -56,7 +54,7 @@ ReferenceProperDihedralBond::ReferenceProperDihedralBond( ){
...
@@ -56,7 +54,7 @@ ReferenceProperDihedralBond::ReferenceProperDihedralBond( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceProperDihedralBond
::~
ReferenceProperDihedralBond
(
){
ReferenceProperDihedralBond
::~
ReferenceProperDihedralBond
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -80,11 +78,11 @@ ReferenceProperDihedralBond::~ReferenceProperDihedralBond( ){
...
@@ -80,11 +78,11 @@ ReferenceProperDihedralBond::~ReferenceProperDihedralBond( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceProperDihedralBond
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceProperDihedralBond
::
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
ReferenceProperDihedralBond::calculateBondIxn"
;
static
const
std
::
string
methodName
=
"
\n
ReferenceProperDihedralBond::calculateBondIxn"
;
...
@@ -112,9 +110,9 @@ void ReferenceProperDihedralBond::calculateBondIxn( int* atomIndices,
...
@@ -112,9 +110,9 @@ void ReferenceProperDihedralBond::calculateBondIxn( int* atomIndices,
int
atomBIndex
=
atomIndices
[
1
];
int
atomBIndex
=
atomIndices
[
1
];
int
atomCIndex
=
atomIndices
[
2
];
int
atomCIndex
=
atomIndices
[
2
];
int
atomDIndex
=
atomIndices
[
3
];
int
atomDIndex
=
atomIndices
[
3
];
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
deltaR
[
0
]
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
deltaR
[
0
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
1
]
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
1
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
2
]
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
2
]);
RealOpenMM
dotDihedral
;
RealOpenMM
dotDihedral
;
RealOpenMM
signOfAngle
;
RealOpenMM
signOfAngle
;
...
@@ -128,35 +126,35 @@ void ReferenceProperDihedralBond::calculateBondIxn( int* atomIndices,
...
@@ -128,35 +126,35 @@ void ReferenceProperDihedralBond::calculateBondIxn( int* atomIndices,
// get dihedral angle
// get dihedral angle
RealOpenMM
dihedralAngle
=
getDihedralAngleBetweenThreeVectors
(
deltaR
[
0
],
deltaR
[
1
],
deltaR
[
2
],
RealOpenMM
dihedralAngle
=
getDihedralAngleBetweenThreeVectors
(
deltaR
[
0
],
deltaR
[
1
],
deltaR
[
2
],
crossProduct
,
&
dotDihedral
,
deltaR
[
0
],
crossProduct
,
&
dotDihedral
,
deltaR
[
0
],
&
signOfAngle
,
hasREntry
);
&
signOfAngle
,
hasREntry
);
// evaluate delta angle, dE/d(angle)
// evaluate delta angle, dE/d(angle)
RealOpenMM
deltaAngle
=
parameters
[
2
]
*
dihedralAngle
-
parameters
[
1
];
RealOpenMM
deltaAngle
=
parameters
[
2
]
*
dihedralAngle
-
parameters
[
1
];
RealOpenMM
sinDeltaAngle
=
SIN
(
deltaAngle
);
RealOpenMM
sinDeltaAngle
=
SIN
(
deltaAngle
);
RealOpenMM
dEdAngle
=
-
parameters
[
0
]
*
parameters
[
2
]
*
sinDeltaAngle
;
RealOpenMM
dEdAngle
=
-
parameters
[
0
]
*
parameters
[
2
]
*
sinDeltaAngle
;
RealOpenMM
energy
=
parameters
[
0
]
*
(
one
+
COS
(
deltaAngle
)
);
RealOpenMM
energy
=
parameters
[
0
]
*
(
one
+
COS
(
deltaAngle
)
);
// compute force
// compute force
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
];
...
@@ -169,7 +167,7 @@ void ReferenceProperDihedralBond::calculateBondIxn( int* atomIndices,
...
@@ -169,7 +167,7 @@ void ReferenceProperDihedralBond::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/ReferenceRbDihedralBond.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 "ReferenceRbDihedralBond.h"
#include "ReferenceRbDihedralBond.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;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceRbDihedralBond
::
ReferenceRbDihedralBond
(
){
ReferenceRbDihedralBond
::
ReferenceRbDihedralBond
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -56,7 +54,7 @@ ReferenceRbDihedralBond::ReferenceRbDihedralBond( ){
...
@@ -56,7 +54,7 @@ ReferenceRbDihedralBond::ReferenceRbDihedralBond( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceRbDihedralBond
::~
ReferenceRbDihedralBond
(
){
ReferenceRbDihedralBond
::~
ReferenceRbDihedralBond
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -78,11 +76,11 @@ ReferenceRbDihedralBond::~ReferenceRbDihedralBond( ){
...
@@ -78,11 +76,11 @@ ReferenceRbDihedralBond::~ReferenceRbDihedralBond( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceRbDihedralBond
::
calculateBondIxn
(
int
*
atomIndices
,
void
ReferenceRbDihedralBond
::
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
ReferenceRbDihedralBond::calculateBondIxn"
;
static
const
std
::
string
methodName
=
"
\n
ReferenceRbDihedralBond::calculateBondIxn"
;
...
@@ -114,9 +112,9 @@ void ReferenceRbDihedralBond::calculateBondIxn( int* atomIndices,
...
@@ -114,9 +112,9 @@ void ReferenceRbDihedralBond::calculateBondIxn( int* atomIndices,
int
atomBIndex
=
atomIndices
[
1
];
int
atomBIndex
=
atomIndices
[
1
];
int
atomCIndex
=
atomIndices
[
2
];
int
atomCIndex
=
atomIndices
[
2
];
int
atomDIndex
=
atomIndices
[
3
];
int
atomDIndex
=
atomIndices
[
3
];
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
deltaR
[
0
]
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
deltaR
[
0
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
1
]
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
1
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
2
]
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
2
]);
RealOpenMM
cosPhi
;
RealOpenMM
cosPhi
;
RealOpenMM
signOfAngle
;
RealOpenMM
signOfAngle
;
...
@@ -127,13 +125,13 @@ void ReferenceRbDihedralBond::calculateBondIxn( int* atomIndices,
...
@@ -127,13 +125,13 @@ void ReferenceRbDihedralBond::calculateBondIxn( int* atomIndices,
RealOpenMM
*
crossProduct
[
2
];
RealOpenMM
*
crossProduct
[
2
];
crossProduct
[
0
]
=
crossProductMemory
;
crossProduct
[
0
]
=
crossProductMemory
;
crossProduct
[
1
]
=
crossProductMemory
+
3
;
crossProduct
[
1
]
=
crossProductMemory
+
3
;
RealOpenMM
dihederalAngle
=
getDihedralAngleBetweenThreeVectors
(
deltaR
[
0
],
deltaR
[
1
],
deltaR
[
2
],
RealOpenMM
dihederalAngle
=
getDihedralAngleBetweenThreeVectors
(
deltaR
[
0
],
deltaR
[
1
],
deltaR
[
2
],
crossProduct
,
&
cosPhi
,
deltaR
[
0
],
crossProduct
,
&
cosPhi
,
deltaR
[
0
],
&
signOfAngle
,
hasREntry
);
&
signOfAngle
,
hasREntry
);
// Gromacs: use polymer convention
// Gromacs: use polymer convention
if
(
dihederalAngle
<
zero
){
if
(
dihederalAngle
<
zero
)
{
dihederalAngle
+=
PI_M
;
dihederalAngle
+=
PI_M
;
}
else
{
}
else
{
dihederalAngle
-=
PI_M
;
dihederalAngle
-=
PI_M
;
...
@@ -142,36 +140,36 @@ void ReferenceRbDihedralBond::calculateBondIxn( int* atomIndices,
...
@@ -142,36 +140,36 @@ void ReferenceRbDihedralBond::calculateBondIxn( int* atomIndices,
// Ryckaert-Bellemans:
// Ryckaert-Bellemans:
// V = sum over i: { C_i*cos(
psi
)**i }, where psi = phi - PI,
// V = sum over i: { C_i*cos(psi)**i }, where psi = phi - PI,
// C_i is ith RB coefficient
// C_i is ith RB coefficient
RealOpenMM
dEdAngle
=
zero
;
RealOpenMM
dEdAngle
=
zero
;
RealOpenMM
energy
=
parameters
[
0
];
RealOpenMM
energy
=
parameters
[
0
];
RealOpenMM
cosFactor
=
one
;
RealOpenMM
cosFactor
=
one
;
for
(
int
ii
=
1
;
ii
<
numberOfParameters
;
ii
++
){
for
(
int
ii
=
1
;
ii
<
numberOfParameters
;
ii
++
)
{
dEdAngle
-=
((
RealOpenMM
)
ii
)
*
parameters
[
ii
]
*
cosFactor
;
dEdAngle
-=
((
RealOpenMM
)
ii
)
*
parameters
[
ii
]
*
cosFactor
;
cosFactor
*=
cosPhi
;
cosFactor
*=
cosPhi
;
energy
+=
cosFactor
*
parameters
[
ii
];
energy
+=
cosFactor
*
parameters
[
ii
];
}
}
dEdAngle
*=
SIN
(
dihederalAngle
);
dEdAngle
*=
SIN
(
dihederalAngle
);
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
];
...
@@ -184,7 +182,7 @@ void ReferenceRbDihedralBond::calculateBondIxn( int* atomIndices,
...
@@ -184,7 +182,7 @@ void ReferenceRbDihedralBond::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/ReferenceStochasticDynamics.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 "ReferenceStochasticDynamics.h"
#include "ReferenceStochasticDynamics.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,31 +46,14 @@ using OpenMM::RealVec;
...
@@ -47,31 +46,14 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceStochasticDynamics
::
ReferenceStochasticDynamics
(
int
numberOfAtoms
,
ReferenceStochasticDynamics
::
ReferenceStochasticDynamics
(
int
numberOfAtoms
,
RealOpenMM
deltaT
,
RealOpenMM
tau
,
RealOpenMM
deltaT
,
RealOpenMM
tau
,
RealOpenMM
temperature
)
:
RealOpenMM
temperature
)
:
ReferenceDynamics
(
numberOfAtoms
,
deltaT
,
temperature
),
_tau
(
tau
)
{
ReferenceDynamics
(
numberOfAtoms
,
deltaT
,
temperature
),
_tau
(
tau
)
{
if
(
tau
<=
0
)
{
// ---------------------------------------------------------------------------------------
static
const
char
*
methodName
=
"
\n
ReferenceStochasticDynamics::ReferenceStochasticDynamics"
;
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
// ---------------------------------------------------------------------------------------
// ensure tau is not zero -- if it is print warning message
if
(
_tau
==
zero
){
std
::
stringstream
message
;
std
::
stringstream
message
;
message
<<
methodName
;
message
<<
"illegal tau value: "
<<
tau
;
message
<<
" input tau value="
<<
tau
<<
" is invalid -- setting to 1."
;
throw
OpenMMException
(
message
.
str
());
SimTKOpenMMLog
::
printError
(
message
);
_tau
=
one
;
}
}
xPrime
.
resize
(
numberOfAtoms
);
xPrime
.
resize
(
numberOfAtoms
);
inverseMasses
.
resize
(
numberOfAtoms
);
inverseMasses
.
resize
(
numberOfAtoms
);
...
@@ -83,7 +65,7 @@ ReferenceStochasticDynamics::ReferenceStochasticDynamics( int numberOfAtoms,
...
@@ -83,7 +65,7 @@ ReferenceStochasticDynamics::ReferenceStochasticDynamics( int numberOfAtoms,
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceStochasticDynamics
::~
ReferenceStochasticDynamics
(
){
ReferenceStochasticDynamics
::~
ReferenceStochasticDynamics
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -101,7 +83,7 @@ ReferenceStochasticDynamics::~ReferenceStochasticDynamics( ){
...
@@ -101,7 +83,7 @@ ReferenceStochasticDynamics::~ReferenceStochasticDynamics( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceStochasticDynamics
::
getTau
(
void
)
const
{
RealOpenMM
ReferenceStochasticDynamics
::
getTau
()
const
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -125,10 +107,10 @@ RealOpenMM ReferenceStochasticDynamics::getTau( void ) const {
...
@@ -125,10 +107,10 @@ RealOpenMM ReferenceStochasticDynamics::getTau( void ) const {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceStochasticDynamics
::
updatePart1
(
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
void
ReferenceStochasticDynamics
::
updatePart1
(
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealVec
>&
velocities
,
vector
<
RealVec
>&
velocities
,
vector
<
RealVec
>&
forces
,
vector
<
RealOpenMM
>&
inverseMasses
,
vector
<
RealVec
>&
forces
,
vector
<
RealOpenMM
>&
inverseMasses
,
vector
<
RealVec
>&
xPrime
){
vector
<
RealVec
>&
xPrime
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -166,10 +148,10 @@ void ReferenceStochasticDynamics::updatePart1( int numberOfAtoms, vector<RealVec
...
@@ -166,10 +148,10 @@ void ReferenceStochasticDynamics::updatePart1( int numberOfAtoms, vector<RealVec
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceStochasticDynamics
::
updatePart2
(
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
void
ReferenceStochasticDynamics
::
updatePart2
(
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealVec
>&
velocities
,
vector
<
RealVec
>&
velocities
,
vector
<
RealVec
>&
forces
,
vector
<
RealOpenMM
>&
inverseMasses
,
vector
<
RealVec
>&
forces
,
vector
<
RealOpenMM
>&
inverseMasses
,
vector
<
RealVec
>&
xPrime
){
vector
<
RealVec
>&
xPrime
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -214,10 +196,10 @@ void ReferenceStochasticDynamics::update(const OpenMM::System& system, vector<Re
...
@@ -214,10 +196,10 @@ void ReferenceStochasticDynamics::update(const OpenMM::System& system, vector<Re
// 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
...
@@ -227,11 +209,11 @@ void ReferenceStochasticDynamics::update(const OpenMM::System& system, vector<Re
...
@@ -227,11 +209,11 @@ void ReferenceStochasticDynamics::update(const OpenMM::System& system, vector<Re
// 1st update
// 1st update
updatePart1
(
numberOfAtoms
,
atomCoordinates
,
velocities
,
forces
,
inverseMasses
,
xPrime
);
updatePart1
(
numberOfAtoms
,
atomCoordinates
,
velocities
,
forces
,
inverseMasses
,
xPrime
);
// 2nd update
// 2nd update
updatePart2
(
numberOfAtoms
,
atomCoordinates
,
velocities
,
forces
,
inverseMasses
,
xPrime
);
updatePart2
(
numberOfAtoms
,
atomCoordinates
,
velocities
,
forces
,
inverseMasses
,
xPrime
);
ReferenceConstraintAlgorithm
*
referenceConstraintAlgorithm
=
getReferenceConstraintAlgorithm
();
ReferenceConstraintAlgorithm
*
referenceConstraintAlgorithm
=
getReferenceConstraintAlgorithm
();
if
(
referenceConstraintAlgorithm
)
if
(
referenceConstraintAlgorithm
)
...
...
platforms/reference/src/SimTKReference/ReferenceVariableStochasticDynamics.cpp
View file @
162d69a2
...
@@ -26,16 +26,15 @@
...
@@ -26,16 +26,15 @@
#include <sstream>
#include <sstream>
#include <algorithm>
#include <algorithm>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceVariableStochasticDynamics.h"
#include "ReferenceVariableStochasticDynamics.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
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -49,31 +48,14 @@ using OpenMM::RealVec;
...
@@ -49,31 +48,14 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceVariableStochasticDynamics
::
ReferenceVariableStochasticDynamics
(
int
numberOfAtoms
,
ReferenceVariableStochasticDynamics
::
ReferenceVariableStochasticDynamics
(
int
numberOfAtoms
,
RealOpenMM
tau
,
RealOpenMM
temperature
,
RealOpenMM
tau
,
RealOpenMM
temperature
,
RealOpenMM
accuracy
)
:
RealOpenMM
accuracy
)
:
ReferenceDynamics
(
numberOfAtoms
,
0.0
f
,
temperature
),
_tau
(
tau
),
_accuracy
(
accuracy
)
{
ReferenceDynamics
(
numberOfAtoms
,
0.0
f
,
temperature
),
_tau
(
tau
),
_accuracy
(
accuracy
)
{
if
(
tau
<=
0
)
{
// ---------------------------------------------------------------------------------------
static
const
char
*
methodName
=
"
\n
ReferenceVariableStochasticDynamics::ReferenceVariableStochasticDynamics"
;
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
// ---------------------------------------------------------------------------------------
// ensure tau is not zero -- if it is print warning message
if
(
_tau
==
zero
){
std
::
stringstream
message
;
std
::
stringstream
message
;
message
<<
methodName
;
message
<<
"illegal tau value: "
<<
tau
;
message
<<
" input tau value="
<<
tau
<<
" is invalid -- setting to 1."
;
throw
OpenMMException
(
message
.
str
());
SimTKOpenMMLog
::
printError
(
message
);
_tau
=
one
;
}
}
xPrime
.
resize
(
numberOfAtoms
);
xPrime
.
resize
(
numberOfAtoms
);
inverseMasses
.
resize
(
numberOfAtoms
);
inverseMasses
.
resize
(
numberOfAtoms
);
...
@@ -85,7 +67,7 @@ ReferenceVariableStochasticDynamics::ReferenceVariableStochasticDynamics( int nu
...
@@ -85,7 +67,7 @@ ReferenceVariableStochasticDynamics::ReferenceVariableStochasticDynamics( int nu
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceVariableStochasticDynamics
::~
ReferenceVariableStochasticDynamics
(
){
ReferenceVariableStochasticDynamics
::~
ReferenceVariableStochasticDynamics
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -103,7 +85,7 @@ ReferenceVariableStochasticDynamics::~ReferenceVariableStochasticDynamics( ){
...
@@ -103,7 +85,7 @@ ReferenceVariableStochasticDynamics::~ReferenceVariableStochasticDynamics( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceVariableStochasticDynamics
::
getAccuracy
(
void
)
const
{
RealOpenMM
ReferenceVariableStochasticDynamics
::
getAccuracy
()
const
{
return
_accuracy
;
return
_accuracy
;
}
}
...
@@ -113,7 +95,7 @@ RealOpenMM ReferenceVariableStochasticDynamics::getAccuracy( void ) const {
...
@@ -113,7 +95,7 @@ RealOpenMM ReferenceVariableStochasticDynamics::getAccuracy( void ) const {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceVariableStochasticDynamics
::
setAccuracy
(
RealOpenMM
accuracy
)
{
void
ReferenceVariableStochasticDynamics
::
setAccuracy
(
RealOpenMM
accuracy
)
{
_accuracy
=
accuracy
;
_accuracy
=
accuracy
;
}
}
...
@@ -125,7 +107,7 @@ void ReferenceVariableStochasticDynamics::setAccuracy( RealOpenMM accuracy ) {
...
@@ -125,7 +107,7 @@ void ReferenceVariableStochasticDynamics::setAccuracy( RealOpenMM accuracy ) {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceVariableStochasticDynamics
::
getTau
(
void
)
const
{
RealOpenMM
ReferenceVariableStochasticDynamics
::
getTau
()
const
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -151,10 +133,10 @@ RealOpenMM ReferenceVariableStochasticDynamics::getTau( void ) const {
...
@@ -151,10 +133,10 @@ RealOpenMM ReferenceVariableStochasticDynamics::getTau( void ) const {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceVariableStochasticDynamics
::
updatePart1
(
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
void
ReferenceVariableStochasticDynamics
::
updatePart1
(
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealVec
>&
velocities
,
vector
<
RealVec
>&
velocities
,
vector
<
RealVec
>&
forces
,
vector
<
RealOpenMM
>&
masses
,
vector
<
RealOpenMM
>&
inverseMasses
,
vector
<
RealVec
>&
forces
,
vector
<
RealOpenMM
>&
masses
,
vector
<
RealOpenMM
>&
inverseMasses
,
vector
<
RealVec
>&
xPrime
,
RealOpenMM
maxStepSize
){
vector
<
RealVec
>&
xPrime
,
RealOpenMM
maxStepSize
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -165,10 +147,10 @@ void ReferenceVariableStochasticDynamics::updatePart1( int numberOfAtoms, vector
...
@@ -165,10 +147,10 @@ void ReferenceVariableStochasticDynamics::updatePart1( int numberOfAtoms, vector
// first-time-through initialization
// first-time-through initialization
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
]
==
0
)
if
(
masses
[
ii
]
==
0
)
inverseMasses
[
ii
]
=
0
;
inverseMasses
[
ii
]
=
0
;
else
else
...
@@ -225,10 +207,10 @@ void ReferenceVariableStochasticDynamics::updatePart1( int numberOfAtoms, vector
...
@@ -225,10 +207,10 @@ void ReferenceVariableStochasticDynamics::updatePart1( int numberOfAtoms, vector
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceVariableStochasticDynamics
::
updatePart2
(
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
void
ReferenceVariableStochasticDynamics
::
updatePart2
(
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
vector
<
RealVec
>&
velocities
,
vector
<
RealVec
>&
velocities
,
vector
<
RealVec
>&
forces
,
vector
<
RealOpenMM
>&
inverseMasses
,
vector
<
RealVec
>&
forces
,
vector
<
RealOpenMM
>&
inverseMasses
,
vector
<
RealVec
>&
xPrime
){
vector
<
RealVec
>&
xPrime
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -272,11 +254,11 @@ void ReferenceVariableStochasticDynamics::update(const OpenMM::System& system, v
...
@@ -272,11 +254,11 @@ void ReferenceVariableStochasticDynamics::update(const OpenMM::System& system, v
// 1st update
// 1st update
int
numberOfAtoms
=
system
.
getNumParticles
();
int
numberOfAtoms
=
system
.
getNumParticles
();
updatePart1
(
numberOfAtoms
,
atomCoordinates
,
velocities
,
forces
,
masses
,
inverseMasses
,
xPrime
,
maxStepSize
);
updatePart1
(
numberOfAtoms
,
atomCoordinates
,
velocities
,
forces
,
masses
,
inverseMasses
,
xPrime
,
maxStepSize
);
// 2nd update
// 2nd update
updatePart2
(
numberOfAtoms
,
atomCoordinates
,
velocities
,
forces
,
inverseMasses
,
xPrime
);
updatePart2
(
numberOfAtoms
,
atomCoordinates
,
velocities
,
forces
,
inverseMasses
,
xPrime
);
ReferenceConstraintAlgorithm
*
referenceConstraintAlgorithm
=
getReferenceConstraintAlgorithm
();
ReferenceConstraintAlgorithm
*
referenceConstraintAlgorithm
=
getReferenceConstraintAlgorithm
();
if
(
referenceConstraintAlgorithm
)
if
(
referenceConstraintAlgorithm
)
...
@@ -284,7 +266,7 @@ void ReferenceVariableStochasticDynamics::update(const OpenMM::System& system, v
...
@@ -284,7 +266,7 @@ void ReferenceVariableStochasticDynamics::update(const OpenMM::System& system, v
// copy xPrime -> atomCoordinates
// copy xPrime -> atomCoordinates
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
)
{
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
)
{
if
(
masses
[
ii
]
!=
0.0
)
{
if
(
masses
[
ii
]
!=
0.0
)
{
atomCoordinates
[
ii
][
0
]
=
xPrime
[
ii
][
0
];
atomCoordinates
[
ii
][
0
]
=
xPrime
[
ii
][
0
];
atomCoordinates
[
ii
][
1
]
=
xPrime
[
ii
][
1
];
atomCoordinates
[
ii
][
1
]
=
xPrime
[
ii
][
1
];
...
...
platforms/reference/src/SimTKReference/ReferenceVariableVerletDynamics.cpp
View file @
162d69a2
...
@@ -26,14 +26,12 @@
...
@@ -26,14 +26,12 @@
#include <sstream>
#include <sstream>
#include <algorithm>
#include <algorithm>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceVariableVerletDynamics.h"
#include "ReferenceVariableVerletDynamics.h"
#include "ReferenceVirtualSites.h"
#include "ReferenceVirtualSites.h"
using
std
::
vector
;
using
std
::
vector
;
using
OpenMM
::
RealVec
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -45,8 +43,8 @@ using OpenMM::RealVec;
...
@@ -45,8 +43,8 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceVariableVerletDynamics
::
ReferenceVariableVerletDynamics
(
int
numberOfAtoms
,
RealOpenMM
accuracy
)
:
ReferenceVariableVerletDynamics
::
ReferenceVariableVerletDynamics
(
int
numberOfAtoms
,
RealOpenMM
accuracy
)
:
ReferenceDynamics
(
numberOfAtoms
,
0.0
f
,
0.0
f
),
_accuracy
(
accuracy
)
{
ReferenceDynamics
(
numberOfAtoms
,
0.0
f
,
0.0
f
),
_accuracy
(
accuracy
)
{
xPrime
.
resize
(
numberOfAtoms
);
xPrime
.
resize
(
numberOfAtoms
);
inverseMasses
.
resize
(
numberOfAtoms
);
inverseMasses
.
resize
(
numberOfAtoms
);
}
}
...
@@ -57,7 +55,7 @@ ReferenceVariableVerletDynamics::ReferenceVariableVerletDynamics( int numberOfAt
...
@@ -57,7 +55,7 @@ ReferenceVariableVerletDynamics::ReferenceVariableVerletDynamics( int numberOfAt
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceVariableVerletDynamics
::~
ReferenceVariableVerletDynamics
(
){
ReferenceVariableVerletDynamics
::~
ReferenceVariableVerletDynamics
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -75,7 +73,7 @@ ReferenceVariableVerletDynamics::~ReferenceVariableVerletDynamics( ){
...
@@ -75,7 +73,7 @@ ReferenceVariableVerletDynamics::~ReferenceVariableVerletDynamics( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceVariableVerletDynamics
::
getAccuracy
(
void
)
const
{
RealOpenMM
ReferenceVariableVerletDynamics
::
getAccuracy
()
const
{
return
_accuracy
;
return
_accuracy
;
}
}
...
@@ -85,7 +83,7 @@ RealOpenMM ReferenceVariableVerletDynamics::getAccuracy( void ) const {
...
@@ -85,7 +83,7 @@ RealOpenMM ReferenceVariableVerletDynamics::getAccuracy( void ) const {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceVariableVerletDynamics
::
setAccuracy
(
RealOpenMM
accuracy
)
{
void
ReferenceVariableVerletDynamics
::
setAccuracy
(
RealOpenMM
accuracy
)
{
_accuracy
=
accuracy
;
_accuracy
=
accuracy
;
}
}
...
@@ -119,10 +117,10 @@ void ReferenceVariableVerletDynamics::update(const OpenMM::System& system, vecto
...
@@ -119,10 +117,10 @@ void ReferenceVariableVerletDynamics::update(const OpenMM::System& system, vecto
// 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
...
...
platforms/reference/src/SimTKReference/ReferenceVerletDynamics.cpp
View file @
162d69a2
...
@@ -25,8 +25,6 @@
...
@@ -25,8 +25,6 @@
#include <cstring>
#include <cstring>
#include <sstream>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceVerletDynamics.h"
#include "ReferenceVerletDynamics.h"
#include "ReferenceVirtualSites.h"
#include "ReferenceVirtualSites.h"
...
@@ -34,7 +32,7 @@
...
@@ -34,7 +32,7 @@
#include <cstdio>
#include <cstdio>
using
std
::
vector
;
using
std
::
vector
;
using
OpenMM
::
RealVec
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -47,9 +45,8 @@ using OpenMM::RealVec;
...
@@ -47,9 +45,8 @@ using OpenMM::RealVec;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceVerletDynamics
::
ReferenceVerletDynamics
(
int
numberOfAtoms
,
ReferenceVerletDynamics
::
ReferenceVerletDynamics
(
int
numberOfAtoms
,
RealOpenMM
deltaT
)
:
RealOpenMM
deltaT
)
:
ReferenceDynamics
(
numberOfAtoms
,
deltaT
,
0.0
)
{
ReferenceDynamics
(
numberOfAtoms
,
deltaT
,
0.0
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -70,7 +67,7 @@ ReferenceVerletDynamics::ReferenceVerletDynamics( int numberOfAtoms,
...
@@ -70,7 +67,7 @@ ReferenceVerletDynamics::ReferenceVerletDynamics( int numberOfAtoms,
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
ReferenceVerletDynamics
::~
ReferenceVerletDynamics
(
){
ReferenceVerletDynamics
::~
ReferenceVerletDynamics
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -109,10 +106,10 @@ void ReferenceVerletDynamics::update(const OpenMM::System& system, vector<RealVe
...
@@ -109,10 +106,10 @@ void ReferenceVerletDynamics::update(const OpenMM::System& system, vector<RealVe
// 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
...
@@ -135,7 +132,7 @@ void ReferenceVerletDynamics::update(const OpenMM::System& system, vector<RealVe
...
@@ -135,7 +132,7 @@ void ReferenceVerletDynamics::update(const OpenMM::System& system, vector<RealVe
// 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/SimTK
Utilities
/SimTKOpenMMUtilities.cpp
→
platforms/reference/src/SimTK
Reference
/SimTKOpenMMUtilities.cpp
View file @
162d69a2
...
@@ -26,7 +26,6 @@
...
@@ -26,7 +26,6 @@
#include "openmm/internal/OSRngSeed.h"
#include "openmm/internal/OSRngSeed.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMLog.h"
#include "sfmt/SFMT.h"
#include "sfmt/SFMT.h"
// fabs(), ...
// fabs(), ...
...
@@ -36,6 +35,8 @@
...
@@ -36,6 +35,8 @@
#include <string.h>
#include <string.h>
#include <iostream>
#include <iostream>
using
namespace
OpenMM
;
uint32_t
SimTKOpenMMUtilities
::
_randomNumberSeed
=
0
;
uint32_t
SimTKOpenMMUtilities
::
_randomNumberSeed
=
0
;
bool
SimTKOpenMMUtilities
::
_randomInitialized
=
false
;
bool
SimTKOpenMMUtilities
::
_randomInitialized
=
false
;
bool
SimTKOpenMMUtilities
::
nextGaussianIsValid
=
false
;
bool
SimTKOpenMMUtilities
::
nextGaussianIsValid
=
false
;
...
@@ -58,9 +59,9 @@ OpenMM_SFMT::SFMT SimTKOpenMMUtilities::sfmt;
...
@@ -58,9 +59,9 @@ OpenMM_SFMT::SFMT SimTKOpenMMUtilities::sfmt;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
*
SimTKOpenMMUtilities
::
allocateOneDRealOpenMMArray
(
int
iSize
,
RealOpenMM
*
array1D
,
RealOpenMM
*
SimTKOpenMMUtilities
::
allocateOneDRealOpenMMArray
(
int
iSize
,
RealOpenMM
*
array1D
,
int
initialize
,
RealOpenMM
initialValue
,
int
initialize
,
RealOpenMM
initialValue
,
const
std
::
string
&
idString
){
const
std
::
string
&
idString
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -70,17 +71,17 @@ RealOpenMM* SimTKOpenMMUtilities::allocateOneDRealOpenMMArray( int iSize, RealOp
...
@@ -70,17 +71,17 @@ RealOpenMM* SimTKOpenMMUtilities::allocateOneDRealOpenMMArray( int iSize, RealOp
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
if
(
array1D
==
NULL
){
if
(
array1D
==
NULL
)
{
array1D
=
new
RealOpenMM
[
iSize
];
array1D
=
new
RealOpenMM
[
iSize
];
}
}
if
(
initialize
){
if
(
initialize
)
{
if
(
initialValue
==
zero
){
if
(
initialValue
==
zero
)
{
memset
(
array1D
,
0
,
iSize
*
sizeof
(
RealOpenMM
)
);
memset
(
array1D
,
0
,
iSize
*
sizeof
(
RealOpenMM
)
);
}
else
{
}
else
{
for
(
int
ii
=
0
;
ii
<
iSize
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
iSize
;
ii
++
)
{
array1D
[
ii
]
=
initialValue
;
array1D
[
ii
]
=
initialValue
;
}
}
}
}
...
@@ -106,9 +107,9 @@ RealOpenMM* SimTKOpenMMUtilities::allocateOneDRealOpenMMArray( int iSize, RealOp
...
@@ -106,9 +107,9 @@ RealOpenMM* SimTKOpenMMUtilities::allocateOneDRealOpenMMArray( int iSize, RealOp
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
**
SimTKOpenMMUtilities
::
allocateTwoDRealOpenMMArray
(
int
iSize
,
int
jSize
,
RealOpenMM
**
array2D
,
RealOpenMM
**
SimTKOpenMMUtilities
::
allocateTwoDRealOpenMMArray
(
int
iSize
,
int
jSize
,
RealOpenMM
**
array2D
,
int
initialize
,
RealOpenMM
initialValue
,
int
initialize
,
RealOpenMM
initialValue
,
const
std
::
string
&
idString
){
const
std
::
string
&
idString
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -116,22 +117,22 @@ RealOpenMM** SimTKOpenMMUtilities::allocateTwoDRealOpenMMArray( int iSize, int j
...
@@ -116,22 +117,22 @@ RealOpenMM** SimTKOpenMMUtilities::allocateTwoDRealOpenMMArray( int iSize, int j
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
if
(
array2D
==
NULL
){
if
(
array2D
==
NULL
)
{
array2D
=
new
RealOpenMM
*
[
iSize
];
array2D
=
new
RealOpenMM
*
[
iSize
];
std
::
string
blockString
=
idString
;
std
::
string
blockString
=
idString
;
blockString
.
append
(
"Block"
);
blockString
.
append
(
"Block"
);
RealOpenMM
*
block
=
new
RealOpenMM
[
jSize
*
iSize
];
RealOpenMM
*
block
=
new
RealOpenMM
[
jSize
*
iSize
];
for
(
int
ii
=
0
;
ii
<
iSize
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
iSize
;
ii
++
)
{
array2D
[
ii
]
=
block
;
array2D
[
ii
]
=
block
;
block
+=
jSize
;
block
+=
jSize
;
}
}
}
}
if
(
initialize
){
if
(
initialize
)
{
initialize2DRealOpenMMArray
(
iSize
,
jSize
,
array2D
,
initialValue
);
initialize2DRealOpenMMArray
(
iSize
,
jSize
,
array2D
,
initialValue
);
}
}
return
array2D
;
return
array2D
;
...
@@ -148,7 +149,7 @@ RealOpenMM** SimTKOpenMMUtilities::allocateTwoDRealOpenMMArray( int iSize, int j
...
@@ -148,7 +149,7 @@ RealOpenMM** SimTKOpenMMUtilities::allocateTwoDRealOpenMMArray( int iSize, int j
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
SimTKOpenMMUtilities
::
freeTwoDRealOpenMMArray
(
RealOpenMM
**
array2D
,
const
std
::
string
&
idString
){
void
SimTKOpenMMUtilities
::
freeTwoDRealOpenMMArray
(
RealOpenMM
**
array2D
,
const
std
::
string
&
idString
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -156,10 +157,10 @@ void SimTKOpenMMUtilities::freeTwoDRealOpenMMArray( RealOpenMM** array2D, const
...
@@ -156,10 +157,10 @@ void SimTKOpenMMUtilities::freeTwoDRealOpenMMArray( RealOpenMM** array2D, const
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
if
(
array2D
!=
NULL
){
if
(
array2D
!=
NULL
)
{
std
::
string
blockString
=
idString
;
std
::
string
blockString
=
idString
;
blockString
.
append
(
"Block"
);
blockString
.
append
(
"Block"
);
delete
[]
array2D
[
0
];
delete
[]
array2D
[
0
];
delete
[]
array2D
;
delete
[]
array2D
;
...
@@ -177,7 +178,7 @@ void SimTKOpenMMUtilities::freeTwoDRealOpenMMArray( RealOpenMM** array2D, const
...
@@ -177,7 +178,7 @@ void SimTKOpenMMUtilities::freeTwoDRealOpenMMArray( RealOpenMM** array2D, const
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
SimTKOpenMMUtilities
::
freeOneDRealOpenMMArray
(
RealOpenMM
*
array1D
,
const
std
::
string
&
idString
){
void
SimTKOpenMMUtilities
::
freeOneDRealOpenMMArray
(
RealOpenMM
*
array1D
,
const
std
::
string
&
idString
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -185,7 +186,7 @@ void SimTKOpenMMUtilities::freeOneDRealOpenMMArray( RealOpenMM* array1D, const s
...
@@ -185,7 +186,7 @@ void SimTKOpenMMUtilities::freeOneDRealOpenMMArray( RealOpenMM* array1D, const s
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
if
(
array1D
!=
NULL
){
if
(
array1D
!=
NULL
)
{
delete
[]
array1D
;
delete
[]
array1D
;
}
}
}
}
...
@@ -203,9 +204,9 @@ void SimTKOpenMMUtilities::freeOneDRealOpenMMArray( RealOpenMM* array1D, const s
...
@@ -203,9 +204,9 @@ void SimTKOpenMMUtilities::freeOneDRealOpenMMArray( RealOpenMM* array1D, const s
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
SimTKOpenMMUtilities
::
initialize2DRealOpenMMArray
(
int
iSize
,
int
jSize
,
void
SimTKOpenMMUtilities
::
initialize2DRealOpenMMArray
(
int
iSize
,
int
jSize
,
RealOpenMM
**
array2D
,
RealOpenMM
**
array2D
,
RealOpenMM
initialValue
){
RealOpenMM
initialValue
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -216,9 +217,9 @@ void SimTKOpenMMUtilities::initialize2DRealOpenMMArray( int iSize, int jSize,
...
@@ -216,9 +217,9 @@ void SimTKOpenMMUtilities::initialize2DRealOpenMMArray( int iSize, int jSize,
bool
useMemset
;
bool
useMemset
;
bool
useMemsetSingleBlock
;
bool
useMemsetSingleBlock
;
if
(
initialValue
==
0.0
f
){
if
(
initialValue
==
0.0
f
)
{
useMemset
=
true
;
useMemset
=
true
;
if
(
jSize
>
1
&&
(
array2D
[
0
]
+
jSize
)
==
array2D
[
1
]
){
if
(
jSize
>
1
&&
(
array2D
[
0
]
+
jSize
)
==
array2D
[
1
])
{
useMemsetSingleBlock
=
true
;
useMemsetSingleBlock
=
true
;
}
else
{
}
else
{
useMemsetSingleBlock
=
false
;
useMemsetSingleBlock
=
false
;
...
@@ -228,17 +229,17 @@ void SimTKOpenMMUtilities::initialize2DRealOpenMMArray( int iSize, int jSize,
...
@@ -228,17 +229,17 @@ void SimTKOpenMMUtilities::initialize2DRealOpenMMArray( int iSize, int jSize,
useMemset
=
false
;
useMemset
=
false
;
}
}
if
(
useMemset
){
if
(
useMemset
)
{
if
(
useMemsetSingleBlock
){
if
(
useMemsetSingleBlock
)
{
memset
(
array2D
[
0
],
0
,
iSize
*
jSize
*
sizeof
(
RealOpenMM
)
);
memset
(
array2D
[
0
],
0
,
iSize
*
jSize
*
sizeof
(
RealOpenMM
)
);
}
else
{
}
else
{
for
(
int
ii
=
0
;
ii
<
iSize
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
iSize
;
ii
++
)
{
memset
(
array2D
[
ii
],
0
,
jSize
*
sizeof
(
RealOpenMM
)
);
memset
(
array2D
[
ii
],
0
,
jSize
*
sizeof
(
RealOpenMM
)
);
}
}
}
}
}
else
{
}
else
{
for
(
int
ii
=
0
;
ii
<
iSize
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
iSize
;
ii
++
)
{
for
(
int
jj
=
0
;
jj
<
jSize
;
jj
++
){
for
(
int
jj
=
0
;
jj
<
jSize
;
jj
++
)
{
array2D
[
ii
][
jj
]
=
initialValue
;
array2D
[
ii
][
jj
]
=
initialValue
;
}
}
}
}
...
@@ -259,9 +260,9 @@ void SimTKOpenMMUtilities::initialize2DRealOpenMMArray( int iSize, int jSize,
...
@@ -259,9 +260,9 @@ void SimTKOpenMMUtilities::initialize2DRealOpenMMArray( int iSize, int jSize,
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
SimTKOpenMMUtilities
::
crossProductVector3
(
RealOpenMM
*
vectorX
,
void
SimTKOpenMMUtilities
::
crossProductVector3
(
RealOpenMM
*
vectorX
,
RealOpenMM
*
vectorY
,
RealOpenMM
*
vectorY
,
RealOpenMM
*
vectorZ
){
RealOpenMM
*
vectorZ
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -284,7 +285,7 @@ void SimTKOpenMMUtilities::crossProductVector3( RealOpenMM* vectorX,
...
@@ -284,7 +285,7 @@ void SimTKOpenMMUtilities::crossProductVector3( RealOpenMM* vectorX,
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
(
void
)
{
RealOpenMM
SimTKOpenMMUtilities
::
getNormallyDistributedRandomNumber
()
{
if
(
nextGaussianIsValid
)
{
if
(
nextGaussianIsValid
)
{
nextGaussianIsValid
=
false
;
nextGaussianIsValid
=
false
;
return
nextGaussian
;
return
nextGaussian
;
...
@@ -303,7 +304,7 @@ RealOpenMM SimTKOpenMMUtilities::getNormallyDistributedRandomNumber( void ) {
...
@@ -303,7 +304,7 @@ RealOpenMM SimTKOpenMMUtilities::getNormallyDistributedRandomNumber( void ) {
y
=
static_cast
<
RealOpenMM
>
(
2.0
*
genrand_real2
(
sfmt
)
-
1.0
);
y
=
static_cast
<
RealOpenMM
>
(
2.0
*
genrand_real2
(
sfmt
)
-
1.0
);
r2
=
x
*
x
+
y
*
y
;
r2
=
x
*
x
+
y
*
y
;
}
while
(
r2
>=
1.0
||
r2
==
0.0
);
}
while
(
r2
>=
1.0
||
r2
==
0.0
);
RealOpenMM
multiplier
=
static_cast
<
RealOpenMM
>
(
sqrt
((
-
2.0
*
log
(
r2
))
/
r2
)
);
RealOpenMM
multiplier
=
static_cast
<
RealOpenMM
>
(
sqrt
((
-
2.0
*
log
(
r2
))
/
r2
));
nextGaussian
=
y
*
multiplier
;
nextGaussian
=
y
*
multiplier
;
nextGaussianIsValid
=
true
;
nextGaussianIsValid
=
true
;
return
x
*
multiplier
;
return
x
*
multiplier
;
...
@@ -317,13 +318,13 @@ RealOpenMM SimTKOpenMMUtilities::getNormallyDistributedRandomNumber( void ) {
...
@@ -317,13 +318,13 @@ RealOpenMM SimTKOpenMMUtilities::getNormallyDistributedRandomNumber( void ) {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
SimTKOpenMMUtilities
::
getUniformlyDistributedRandomNumber
(
void
)
{
RealOpenMM
SimTKOpenMMUtilities
::
getUniformlyDistributedRandomNumber
()
{
if
(
!
_randomInitialized
)
{
if
(
!
_randomInitialized
)
{
init_gen_rand
(
_randomNumberSeed
,
sfmt
);
init_gen_rand
(
_randomNumberSeed
,
sfmt
);
_randomInitialized
=
true
;
_randomInitialized
=
true
;
nextGaussianIsValid
=
false
;
nextGaussianIsValid
=
false
;
}
}
RealOpenMM
value
=
static_cast
<
RealOpenMM
>
(
genrand_real2
(
sfmt
)
);
RealOpenMM
value
=
static_cast
<
RealOpenMM
>
(
genrand_real2
(
sfmt
));
return
value
;
return
value
;
}
}
...
@@ -335,7 +336,7 @@ RealOpenMM SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber( void ) {
...
@@ -335,7 +336,7 @@ RealOpenMM SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber( void ) {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
uint32_t
SimTKOpenMMUtilities
::
getRandomNumberSeed
(
void
)
{
uint32_t
SimTKOpenMMUtilities
::
getRandomNumberSeed
()
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -354,7 +355,7 @@ uint32_t SimTKOpenMMUtilities::getRandomNumberSeed( void ) {
...
@@ -354,7 +355,7 @@ uint32_t SimTKOpenMMUtilities::getRandomNumberSeed( void ) {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
SimTKOpenMMUtilities
::
setRandomNumberSeed
(
uint32_t
seed
)
{
void
SimTKOpenMMUtilities
::
setRandomNumberSeed
(
uint32_t
seed
)
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
...
platforms/reference/src/SimTKReference/fftpack.cpp
View file @
162d69a2
...
@@ -672,16 +672,16 @@ fftpack_transpose_2d(t_complex * in_data,
...
@@ -672,16 +672,16 @@ fftpack_transpose_2d(t_complex * in_data,
t_complex
*
src
;
t_complex
*
src
;
int
i
,
j
;
int
i
,
j
;
if
(
nx
<
2
||
ny
<
2
)
if
(
nx
<
2
||
ny
<
2
)
{
{
if
(
in_data
!=
out_data
)
if
(
in_data
!=
out_data
)
{
{
memcpy
(
out_data
,
in_data
,
sizeof
(
t_complex
)
*
nx
*
ny
);
memcpy
(
out_data
,
in_data
,
sizeof
(
t_complex
)
*
nx
*
ny
);
}
}
return
0
;
return
0
;
}
}
if
(
in_data
==
out_data
)
if
(
in_data
==
out_data
)
{
{
src
=
(
t_complex
*
)
malloc
(
sizeof
(
t_complex
)
*
nx
*
ny
);
src
=
(
t_complex
*
)
malloc
(
sizeof
(
t_complex
)
*
nx
*
ny
);
memcpy
(
src
,
in_data
,
sizeof
(
t_complex
)
*
nx
*
ny
);
memcpy
(
src
,
in_data
,
sizeof
(
t_complex
)
*
nx
*
ny
);
...
@@ -691,16 +691,16 @@ fftpack_transpose_2d(t_complex * in_data,
...
@@ -691,16 +691,16 @@ fftpack_transpose_2d(t_complex * in_data,
src
=
in_data
;
src
=
in_data
;
}
}
for
(
i
=
0
;
i
<
nx
;
i
++
)
for
(
i
=
0
;
i
<
nx
;
i
++
)
{
{
for
(
j
=
0
;
j
<
ny
;
j
++
)
for
(
j
=
0
;
j
<
ny
;
j
++
)
{
{
out_data
[
j
*
nx
+
i
].
re
=
src
[
i
*
ny
+
j
].
re
;
out_data
[
j
*
nx
+
i
].
re
=
src
[
i
*
ny
+
j
].
re
;
out_data
[
j
*
nx
+
i
].
im
=
src
[
i
*
ny
+
j
].
im
;
out_data
[
j
*
nx
+
i
].
im
=
src
[
i
*
ny
+
j
].
im
;
}
}
}
}
if
(
src
!=
in_data
)
if
(
src
!=
in_data
)
{
{
free
(
src
);
free
(
src
);
}
}
...
@@ -722,16 +722,16 @@ fftpack_transpose_2d_nelem(t_complex * in_data,
...
@@ -722,16 +722,16 @@ fftpack_transpose_2d_nelem(t_complex * in_data,
ncopy
=
nelem
*
sizeof
(
t_complex
);
ncopy
=
nelem
*
sizeof
(
t_complex
);
if
(
nx
<
2
||
ny
<
2
)
if
(
nx
<
2
||
ny
<
2
)
{
{
if
(
in_data
!=
out_data
)
if
(
in_data
!=
out_data
)
{
{
memcpy
(
out_data
,
in_data
,
nx
*
ny
*
ncopy
);
memcpy
(
out_data
,
in_data
,
nx
*
ny
*
ncopy
);
}
}
return
0
;
return
0
;
}
}
if
(
in_data
==
out_data
)
if
(
in_data
==
out_data
)
{
{
src
=
(
t_complex
*
)
malloc
(
nx
*
ny
*
ncopy
);
src
=
(
t_complex
*
)
malloc
(
nx
*
ny
*
ncopy
);
memcpy
(
src
,
in_data
,
nx
*
ny
*
ncopy
);
memcpy
(
src
,
in_data
,
nx
*
ny
*
ncopy
);
...
@@ -741,15 +741,15 @@ fftpack_transpose_2d_nelem(t_complex * in_data,
...
@@ -741,15 +741,15 @@ fftpack_transpose_2d_nelem(t_complex * in_data,
src
=
in_data
;
src
=
in_data
;
}
}
for
(
i
=
0
;
i
<
nx
;
i
++
)
for
(
i
=
0
;
i
<
nx
;
i
++
)
{
{
for
(
j
=
0
;
j
<
ny
;
j
++
)
for
(
j
=
0
;
j
<
ny
;
j
++
)
{
{
memcpy
(
out_data
+
(
j
*
nx
+
i
)
*
nelem
,
src
+
(
i
*
ny
+
j
)
*
nelem
,
ncopy
);
memcpy
(
out_data
+
(
j
*
nx
+
i
)
*
nelem
,
src
+
(
i
*
ny
+
j
)
*
nelem
,
ncopy
);
}
}
}
}
if
(
src
!=
in_data
)
if
(
src
!=
in_data
)
{
{
free
(
src
);
free
(
src
);
}
}
...
@@ -767,14 +767,14 @@ fftpack_init_1d(fftpack_t * pfft,
...
@@ -767,14 +767,14 @@ fftpack_init_1d(fftpack_t * pfft,
{
{
fftpack_t
fft
;
fftpack_t
fft
;
if
(
pfft
==
NULL
)
if
(
pfft
==
NULL
)
{
{
fprintf
(
stderr
,
"Fatal error - Invalid FFT opaque type pointer."
);
fprintf
(
stderr
,
"Fatal error - Invalid FFT opaque type pointer."
);
return
EINVAL
;
return
EINVAL
;
}
}
*
pfft
=
NULL
;
*
pfft
=
NULL
;
if
(
(
fft
=
(
struct
fftpack
*
)
malloc
(
sizeof
(
struct
fftpack
)))
==
NULL
)
if
(
(
fft
=
(
struct
fftpack
*
)
malloc
(
sizeof
(
struct
fftpack
)))
==
NULL
)
{
{
return
ENOMEM
;
return
ENOMEM
;
}
}
...
@@ -783,13 +783,13 @@ fftpack_init_1d(fftpack_t * pfft,
...
@@ -783,13 +783,13 @@ fftpack_init_1d(fftpack_t * pfft,
fft
->
n
=
nx
;
fft
->
n
=
nx
;
/* Need 4*n storage for 1D complex FFT */
/* Need 4*n storage for 1D complex FFT */
if
(
(
fft
->
work
=
(
RealOpenMM
*
)
malloc
(
sizeof
(
RealOpenMM
)
*
(
4
*
nx
)))
==
NULL
)
if
(
(
fft
->
work
=
(
RealOpenMM
*
)
malloc
(
sizeof
(
RealOpenMM
)
*
(
4
*
nx
)))
==
NULL
)
{
{
free
(
fft
);
free
(
fft
);
return
ENOMEM
;
return
ENOMEM
;
}
}
if
(
fft
->
n
>
1
)
if
(
fft
->
n
>
1
)
fftpack_cffti1
(
nx
,
fft
->
work
,
fft
->
ifac
);
fftpack_cffti1
(
nx
,
fft
->
work
,
fft
->
ifac
);
*
pfft
=
fft
;
*
pfft
=
fft
;
...
@@ -807,7 +807,7 @@ fftpack_init_2d(fftpack_t * pfft,
...
@@ -807,7 +807,7 @@ fftpack_init_2d(fftpack_t * pfft,
fftpack_t
fft
;
fftpack_t
fft
;
int
rc
;
int
rc
;
if
(
pfft
==
NULL
)
if
(
pfft
==
NULL
)
{
{
fprintf
(
stderr
,
"Fatal error - Invalid FFT opaque type pointer."
);
fprintf
(
stderr
,
"Fatal error - Invalid FFT opaque type pointer."
);
return
EINVAL
;
return
EINVAL
;
...
@@ -815,13 +815,13 @@ fftpack_init_2d(fftpack_t * pfft,
...
@@ -815,13 +815,13 @@ fftpack_init_2d(fftpack_t * pfft,
*
pfft
=
NULL
;
*
pfft
=
NULL
;
/* Create the X transform */
/* Create the X transform */
if
(
(
rc
=
fftpack_init_1d
(
&
fft
,
nx
))
!=
0
)
if
(
(
rc
=
fftpack_init_1d
(
&
fft
,
nx
))
!=
0
)
{
{
return
rc
;
return
rc
;
}
}
/* Create Y transform as a link from X */
/* Create Y transform as a link from X */
if
(
(
rc
=
fftpack_init_1d
(
&
(
fft
->
next
),
ny
))
!=
0
)
if
(
(
rc
=
fftpack_init_1d
(
&
(
fft
->
next
),
ny
))
!=
0
)
{
{
free
(
fft
);
free
(
fft
);
return
rc
;
return
rc
;
...
@@ -842,7 +842,7 @@ fftpack_init_3d(fftpack_t * pfft,
...
@@ -842,7 +842,7 @@ fftpack_init_3d(fftpack_t * pfft,
fftpack_t
fft
;
fftpack_t
fft
;
int
rc
;
int
rc
;
if
(
pfft
==
NULL
)
if
(
pfft
==
NULL
)
{
{
fprintf
(
stderr
,
"Fatal error - Invalid FFT opaque type pointer."
);
fprintf
(
stderr
,
"Fatal error - Invalid FFT opaque type pointer."
);
return
EINVAL
;
return
EINVAL
;
...
@@ -851,7 +851,7 @@ fftpack_init_3d(fftpack_t * pfft,
...
@@ -851,7 +851,7 @@ fftpack_init_3d(fftpack_t * pfft,
/* Create the X transform */
/* Create the X transform */
if
(
(
fft
=
(
struct
fftpack
*
)
malloc
(
sizeof
(
struct
fftpack
)))
==
NULL
)
if
(
(
fft
=
(
struct
fftpack
*
)
malloc
(
sizeof
(
struct
fftpack
)))
==
NULL
)
{
{
return
ENOMEM
;
return
ENOMEM
;
}
}
...
@@ -860,7 +860,7 @@ fftpack_init_3d(fftpack_t * pfft,
...
@@ -860,7 +860,7 @@ fftpack_init_3d(fftpack_t * pfft,
/* Need 4*nx storage for 1D complex FFT.
/* Need 4*nx storage for 1D complex FFT.
*/
*/
if
(
(
fft
->
work
=
(
RealOpenMM
*
)
malloc
(
sizeof
(
RealOpenMM
)
*
(
4
*
nx
)))
==
NULL
)
if
(
(
fft
->
work
=
(
RealOpenMM
*
)
malloc
(
sizeof
(
RealOpenMM
)
*
(
4
*
nx
)))
==
NULL
)
{
{
free
(
fft
);
free
(
fft
);
return
ENOMEM
;
return
ENOMEM
;
...
@@ -869,7 +869,7 @@ fftpack_init_3d(fftpack_t * pfft,
...
@@ -869,7 +869,7 @@ fftpack_init_3d(fftpack_t * pfft,
fftpack_cffti1
(
nx
,
fft
->
work
,
fft
->
ifac
);
fftpack_cffti1
(
nx
,
fft
->
work
,
fft
->
ifac
);
/* Create 2D Y/Z transforms as a link from X */
/* Create 2D Y/Z transforms as a link from X */
if
(
(
rc
=
fftpack_init_2d
(
&
(
fft
->
next
),
ny
,
nz
))
!=
0
)
if
(
(
rc
=
fftpack_init_2d
(
&
(
fft
->
next
),
ny
,
nz
))
!=
0
)
{
{
free
(
fft
);
free
(
fft
);
return
rc
;
return
rc
;
...
@@ -893,7 +893,7 @@ fftpack_exec_1d (fftpack_t fft,
...
@@ -893,7 +893,7 @@ fftpack_exec_1d (fftpack_t fft,
n
=
fft
->
n
;
n
=
fft
->
n
;
if
(
n
==
1
)
if
(
n
==
1
)
{
{
p1
=
(
RealOpenMM
*
)
in_data
;
p1
=
(
RealOpenMM
*
)
in_data
;
p2
=
(
RealOpenMM
*
)
out_data
;
p2
=
(
RealOpenMM
*
)
out_data
;
...
@@ -904,13 +904,13 @@ fftpack_exec_1d (fftpack_t fft,
...
@@ -904,13 +904,13 @@ fftpack_exec_1d (fftpack_t fft,
/* FFTPACK only does in-place transforms, so emulate out-of-place
/* FFTPACK only does in-place transforms, so emulate out-of-place
* by copying data to the output array first.
* by copying data to the output array first.
*/
*/
if
(
in_data
!=
out_data
)
if
(
in_data
!=
out_data
)
{
{
p1
=
(
RealOpenMM
*
)
in_data
;
p1
=
(
RealOpenMM
*
)
in_data
;
p2
=
(
RealOpenMM
*
)
out_data
;
p2
=
(
RealOpenMM
*
)
out_data
;
/* n complex = 2*n RealOpenMM elements */
/* n complex = 2*n RealOpenMM elements */
for
(
i
=
0
;
i
<
2
*
n
;
i
++
)
for
(
i
=
0
;
i
<
2
*
n
;
i
++
)
{
{
p2
[
i
]
=
p1
[
i
];
p2
[
i
]
=
p1
[
i
];
}
}
...
@@ -920,11 +920,11 @@ fftpack_exec_1d (fftpack_t fft,
...
@@ -920,11 +920,11 @@ fftpack_exec_1d (fftpack_t fft,
* Elements 2*n .. 4*n-1 are internal FFTPACK work space.
* Elements 2*n .. 4*n-1 are internal FFTPACK work space.
*/
*/
if
(
dir
==
FFTPACK_FORWARD
)
if
(
dir
==
FFTPACK_FORWARD
)
{
{
fftpack_cfftf1
(
n
,(
RealOpenMM
*
)
out_data
,
fft
->
work
+
2
*
n
,
fft
->
work
,
fft
->
ifac
,
-
1
);
fftpack_cfftf1
(
n
,(
RealOpenMM
*
)
out_data
,
fft
->
work
+
2
*
n
,
fft
->
work
,
fft
->
ifac
,
-
1
);
}
}
else
if
(
dir
==
FFTPACK_BACKWARD
)
else
if
(
dir
==
FFTPACK_BACKWARD
)
{
{
fftpack_cfftf1
(
n
,(
RealOpenMM
*
)
out_data
,
fft
->
work
+
2
*
n
,
fft
->
work
,
fft
->
ifac
,
1
);
fftpack_cfftf1
(
n
,(
RealOpenMM
*
)
out_data
,
fft
->
work
+
2
*
n
,
fft
->
work
,
fft
->
ifac
,
1
);
}
}
...
@@ -957,7 +957,7 @@ fftpack_exec_2d (fftpack_t fft,
...
@@ -957,7 +957,7 @@ fftpack_exec_2d (fftpack_t fft,
* by copying data to the output array first.
* by copying data to the output array first.
* For 2D there is likely enough data to benefit from memcpy().
* For 2D there is likely enough data to benefit from memcpy().
*/
*/
if
(
in_data
!=
out_data
)
if
(
in_data
!=
out_data
)
{
{
memcpy
(
out_data
,
in_data
,
sizeof
(
t_complex
)
*
nx
*
ny
);
memcpy
(
out_data
,
in_data
,
sizeof
(
t_complex
)
*
nx
*
ny
);
}
}
...
@@ -966,7 +966,7 @@ fftpack_exec_2d (fftpack_t fft,
...
@@ -966,7 +966,7 @@ fftpack_exec_2d (fftpack_t fft,
data
=
(
t_complex
*
)
out_data
;
data
=
(
t_complex
*
)
out_data
;
/* y transforms */
/* y transforms */
for
(
i
=
0
;
i
<
nx
;
i
++
)
for
(
i
=
0
;
i
<
nx
;
i
++
)
{
{
fftpack_exec_1d
(
fft
->
next
,
dir
,
data
+
i
*
ny
,
data
+
i
*
ny
);
fftpack_exec_1d
(
fft
->
next
,
dir
,
data
+
i
*
ny
,
data
+
i
*
ny
);
}
}
...
@@ -975,7 +975,7 @@ fftpack_exec_2d (fftpack_t fft,
...
@@ -975,7 +975,7 @@ fftpack_exec_2d (fftpack_t fft,
fftpack_transpose_2d
(
data
,
data
,
nx
,
ny
);
fftpack_transpose_2d
(
data
,
data
,
nx
,
ny
);
/* x transforms */
/* x transforms */
for
(
i
=
0
;
i
<
ny
;
i
++
)
for
(
i
=
0
;
i
<
ny
;
i
++
)
{
{
fftpack_exec_1d
(
fft
,
dir
,
data
+
i
*
nx
,
data
+
i
*
nx
);
fftpack_exec_1d
(
fft
,
dir
,
data
+
i
*
nx
,
data
+
i
*
nx
);
}
}
...
@@ -1007,7 +1007,7 @@ fftpack_exec_3d (fftpack_t fft,
...
@@ -1007,7 +1007,7 @@ fftpack_exec_3d (fftpack_t fft,
* by copying data to the output array first.
* by copying data to the output array first.
* For 3D there is likely enough data to benefit from memcpy().
* For 3D there is likely enough data to benefit from memcpy().
*/
*/
if
(
in_data
!=
out_data
)
if
(
in_data
!=
out_data
)
{
{
memcpy
(
out_data
,
in_data
,
sizeof
(
t_complex
)
*
nx
*
ny
*
nz
);
memcpy
(
out_data
,
in_data
,
sizeof
(
t_complex
)
*
nx
*
ny
*
nz
);
}
}
...
@@ -1016,23 +1016,23 @@ fftpack_exec_3d (fftpack_t fft,
...
@@ -1016,23 +1016,23 @@ fftpack_exec_3d (fftpack_t fft,
data
=
(
t_complex
*
)
out_data
;
data
=
(
t_complex
*
)
out_data
;
/* Perform z transforms */
/* Perform z transforms */
for
(
i
=
0
;
i
<
nx
*
ny
;
i
++
)
for
(
i
=
0
;
i
<
nx
*
ny
;
i
++
)
fftpack_exec_1d
(
fft
->
next
->
next
,
dir
,
data
+
i
*
nz
,
data
+
i
*
nz
);
fftpack_exec_1d
(
fft
->
next
->
next
,
dir
,
data
+
i
*
nz
,
data
+
i
*
nz
);
/* For each X slice, transpose the y & z dimensions inside the slice */
/* For each X slice, transpose the y & z dimensions inside the slice */
for
(
i
=
0
;
i
<
nx
;
i
++
)
for
(
i
=
0
;
i
<
nx
;
i
++
)
{
{
fftpack_transpose_2d
(
data
+
i
*
ny
*
nz
,
data
+
i
*
ny
*
nz
,
ny
,
nz
);
fftpack_transpose_2d
(
data
+
i
*
ny
*
nz
,
data
+
i
*
ny
*
nz
,
ny
,
nz
);
}
}
/* Array is now (nx,nz,ny) - perform y transforms */
/* Array is now (nx,nz,ny) - perform y transforms */
for
(
i
=
0
;
i
<
nx
*
nz
;
i
++
)
for
(
i
=
0
;
i
<
nx
*
nz
;
i
++
)
{
{
fftpack_exec_1d
(
fft
->
next
,
dir
,
data
+
i
*
ny
,
data
+
i
*
ny
);
fftpack_exec_1d
(
fft
->
next
,
dir
,
data
+
i
*
ny
,
data
+
i
*
ny
);
}
}
/* Transpose back to (nx,ny,nz) */
/* Transpose back to (nx,ny,nz) */
for
(
i
=
0
;
i
<
nx
;
i
++
)
for
(
i
=
0
;
i
<
nx
;
i
++
)
{
{
fftpack_transpose_2d
(
data
+
i
*
ny
*
nz
,
data
+
i
*
ny
*
nz
,
nz
,
ny
);
fftpack_transpose_2d
(
data
+
i
*
ny
*
nz
,
data
+
i
*
ny
*
nz
,
nz
,
ny
);
}
}
...
@@ -1041,26 +1041,26 @@ fftpack_exec_3d (fftpack_t fft,
...
@@ -1041,26 +1041,26 @@ fftpack_exec_3d (fftpack_t fft,
* (nx,ny,nz) to (ny,nx,nz).
* (nx,ny,nz) to (ny,nx,nz).
*/
*/
rc
=
fftpack_transpose_2d_nelem
(
data
,
data
,
nx
,
ny
,
nz
);
rc
=
fftpack_transpose_2d_nelem
(
data
,
data
,
nx
,
ny
,
nz
);
if
(
rc
!=
0
)
if
(
rc
!=
0
)
{
{
fprintf
(
stderr
,
"Fatal error - cannot transpose X & Y/Z in fftpack_exec_3d()."
);
fprintf
(
stderr
,
"Fatal error - cannot transpose X & Y/Z in fftpack_exec_3d()."
);
return
rc
;
return
rc
;
}
}
/* Then go from (ny,nx,nz) to (ny,nz,nx) */
/* Then go from (ny,nx,nz) to (ny,nz,nx) */
for
(
i
=
0
;
i
<
ny
;
i
++
)
for
(
i
=
0
;
i
<
ny
;
i
++
)
{
{
fftpack_transpose_2d
(
data
+
i
*
nx
*
nz
,
data
+
i
*
nx
*
nz
,
nx
,
nz
);
fftpack_transpose_2d
(
data
+
i
*
nx
*
nz
,
data
+
i
*
nx
*
nz
,
nx
,
nz
);
}
}
/* Perform x transforms */
/* Perform x transforms */
for
(
i
=
0
;
i
<
ny
*
nz
;
i
++
)
for
(
i
=
0
;
i
<
ny
*
nz
;
i
++
)
{
{
fftpack_exec_1d
(
fft
,
dir
,
data
+
i
*
nx
,
data
+
i
*
nx
);
fftpack_exec_1d
(
fft
,
dir
,
data
+
i
*
nx
,
data
+
i
*
nx
);
}
}
/* Transpose back from (ny,nz,nx) to (ny,nx,nz) */
/* Transpose back from (ny,nz,nx) to (ny,nx,nz) */
for
(
i
=
0
;
i
<
ny
;
i
++
)
for
(
i
=
0
;
i
<
ny
;
i
++
)
{
{
fftpack_transpose_2d
(
data
+
i
*
nz
*
nx
,
data
+
i
*
nz
*
nx
,
nz
,
nx
);
fftpack_transpose_2d
(
data
+
i
*
nz
*
nx
,
data
+
i
*
nz
*
nx
,
nz
,
nx
);
}
}
...
@@ -1068,7 +1068,7 @@ fftpack_exec_3d (fftpack_t fft,
...
@@ -1068,7 +1068,7 @@ fftpack_exec_3d (fftpack_t fft,
/* Transpose from (ny,nx,nz) to (nx,ny,nz).
/* Transpose from (ny,nx,nz) to (nx,ny,nz).
*/
*/
rc
=
fftpack_transpose_2d_nelem
(
data
,
data
,
ny
,
nx
,
nz
);
rc
=
fftpack_transpose_2d_nelem
(
data
,
data
,
ny
,
nx
,
nz
);
if
(
rc
!=
0
)
if
(
rc
!=
0
)
{
{
fprintf
(
stderr
,
"Fatal error - cannot transpose Y/Z & X in fftpack_exec_3d()."
);
fprintf
(
stderr
,
"Fatal error - cannot transpose Y/Z & X in fftpack_exec_3d()."
);
return
rc
;
return
rc
;
...
@@ -1082,10 +1082,10 @@ fftpack_exec_3d (fftpack_t fft,
...
@@ -1082,10 +1082,10 @@ fftpack_exec_3d (fftpack_t fft,
void
void
fftpack_destroy
(
fftpack_t
fft
)
fftpack_destroy
(
fftpack_t
fft
)
{
{
if
(
fft
!=
NULL
)
if
(
fft
!=
NULL
)
{
{
free
(
fft
->
work
);
free
(
fft
->
work
);
if
(
fft
->
next
!=
NULL
)
if
(
fft
->
next
!=
NULL
)
fftpack_destroy
(
fft
->
next
);
fftpack_destroy
(
fft
->
next
);
free
(
fft
);
free
(
fft
);
}
}
...
...
platforms/reference/src/SimTKUtilities/SimTKOpenMMCommon.cpp
deleted
100644 → 0
View file @
2379b982
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "SimTKOpenMMCommon.h"
// static settings
// initialization of static data members
const
std
::
string
SimTKOpenMMCommon
::
NotSet
=
std
::
string
(
"NotSet"
);
const
std
::
string
SimTKOpenMMCommon
::
Comment
=
std
::
string
(
"#"
);
const
std
::
string
SimTKOpenMMCommon
::
Tab
=
std
::
string
(
"
\t
"
);
const
int
SimTKOpenMMCommon
::
DefaultReturn
=
0
;
const
int
SimTKOpenMMCommon
::
ErrorReturn
=
-
1
;
const
RealOpenMM
SimTKOpenMMCommon
::
BigCutoffValue
=
1.0e+05
;
platforms/reference/src/SimTKUtilities/SimTKOpenMMLog.cpp
deleted
100644 → 0
View file @
2379b982
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "SimTKOpenMMLog.h"
#include <stdlib.h>
#include "openmm/OpenMMException.h"
// static settings
SimTKOpenMMLog
*
SimTKOpenMMLog
::
_simTKOpenMMLog
=
NULL
;
/**---------------------------------------------------------------------------------------
SimTKOpenMMLog constructor (Simbios)
@param logFile file reference for logging
--------------------------------------------------------------------------------------- */
SimTKOpenMMLog
::
SimTKOpenMMLog
(
FILE
*
logFile
)
:
_logFile
(
logFile
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMLog::SimTKOpenMMLog";
// ---------------------------------------------------------------------------------------
_logLevel
=
LogLowLevel
;
}
/**---------------------------------------------------------------------------------------
SimTKOpenMMLog destructor (Simbios)
--------------------------------------------------------------------------------------- */
SimTKOpenMMLog
::~
SimTKOpenMMLog
(
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMLog::~SimTKOpenMMLog";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Get LogFile
@return logFile
--------------------------------------------------------------------------------------- */
FILE
*
SimTKOpenMMLog
::
getLogFile
(
void
)
const
{
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMLog::getLogFile";
// ---------------------------------------------------------------------------------------
return
_logFile
;
}
/**---------------------------------------------------------------------------------------
Set LogFile
@param input logFile
--------------------------------------------------------------------------------------- */
void
SimTKOpenMMLog
::
setLogFile
(
FILE
*
logFile
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMLog::setLogFile";
// ---------------------------------------------------------------------------------------
_logFile
=
logFile
;
}
/**---------------------------------------------------------------------------------------
Set LogLevel
@param input logLevel
--------------------------------------------------------------------------------------- */
void
SimTKOpenMMLog
::
setLogLevel
(
SimTKOpenMMLog
::
LogLevels
logLevel
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMLog::setLogLevel";
// ---------------------------------------------------------------------------------------
_logLevel
=
logLevel
;
}
/**---------------------------------------------------------------------------------------
SimTKOpenMMLog log message to log (Simbios)
@param message message to log
--------------------------------------------------------------------------------------- */
void
SimTKOpenMMLog
::
logMessage
(
const
std
::
stringstream
&
message
)
const
{
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMLog::logMessage";
// ---------------------------------------------------------------------------------------
if
(
_logFile
){
// (void) fprintf( stderr, "%s", message.str().c_str() );
// (void) fflush( stderr );
(
void
)
fprintf
(
_logFile
,
"%s"
,
message
.
str
().
c_str
()
);
(
void
)
fflush
(
_logFile
);
}
}
/**---------------------------------------------------------------------------------------
Set global simTKOpenMMLog (Simbios)
@param logFile file to log to
@return new SimTKOpenMMLog
--------------------------------------------------------------------------------------- */
SimTKOpenMMLog
*
SimTKOpenMMLog
::
setSimTKOpenMMLog
(
FILE
*
logFile
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMLog::setSimTKOpenMMLog";
// ---------------------------------------------------------------------------------------
// allow for multiple logs
/*
if( _simTKOpenMMLog ){
delete _simTKOpenMMLog;
}
*/
_simTKOpenMMLog
=
new
SimTKOpenMMLog
(
logFile
);
return
_simTKOpenMMLog
;
}
/**---------------------------------------------------------------------------------------
Get global simTKOpenMMLog -- static method (Simbios)
@return static member
--------------------------------------------------------------------------------------- */
SimTKOpenMMLog
*
SimTKOpenMMLog
::
getSimTKOpenMMLog
(
void
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMLog::getSimTKOpenMMLog";
// ---------------------------------------------------------------------------------------
if
(
!
_simTKOpenMMLog
){
_simTKOpenMMLog
=
new
SimTKOpenMMLog
(
);
}
return
_simTKOpenMMLog
;
}
/**---------------------------------------------------------------------------------------
Get global simTKOpenMMLog (Simbios)
@return FILE reference
--------------------------------------------------------------------------------------- */
FILE
*
SimTKOpenMMLog
::
getSimTKOpenMMLogFile
(
void
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMLog::getSimTKOpenMMLogFile";
// ---------------------------------------------------------------------------------------
SimTKOpenMMLog
*
simTKOpenMMLog
=
getSimTKOpenMMLog
(
);
return
simTKOpenMMLog
->
getLogFile
();
}
/**---------------------------------------------------------------------------------------
Static method to print message (Simbios)
@param message message to log
--------------------------------------------------------------------------------------- */
void
SimTKOpenMMLog
::
printMessage
(
const
std
::
stringstream
&
message
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMLog::printMessage";
// ---------------------------------------------------------------------------------------
if
(
_simTKOpenMMLog
){
_simTKOpenMMLog
->
logMessage
(
message
);
}
else
{
(
void
)
fprintf
(
stderr
,
"%s"
,
message
.
str
().
c_str
()
);
(
void
)
fflush
(
stderr
);
}
}
/**---------------------------------------------------------------------------------------
Static method to print warning message (Simbios)
If global _simTKOpenMMLog is not set, then print to stderr
@param message message to log
--------------------------------------------------------------------------------------- */
void
SimTKOpenMMLog
::
printWarning
(
const
std
::
stringstream
&
message
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMLog::printWarning";
// ---------------------------------------------------------------------------------------
if
(
_simTKOpenMMLog
){
std
::
stringstream
messageWithHeader
;
messageWithHeader
<<
"Warning: "
<<
message
.
str
();
_simTKOpenMMLog
->
logMessage
(
messageWithHeader
);
}
else
{
(
void
)
fprintf
(
stderr
,
"Warning: %s"
,
message
.
str
().
c_str
()
);
}
}
/**---------------------------------------------------------------------------------------
Static method to print error message and exit program (Simbios)
If global _simTKOpenMMLog is not set, then print to stderr
@param message message to log
--------------------------------------------------------------------------------------- */
void
SimTKOpenMMLog
::
printError
(
const
std
::
stringstream
&
message
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMLog::printError";
// ---------------------------------------------------------------------------------------
std
::
stringstream
messageWithHeader
;
messageWithHeader
<<
"Error: "
<<
message
.
str
();
if
(
_simTKOpenMMLog
){
_simTKOpenMMLog
->
logMessage
(
messageWithHeader
);
}
else
{
(
void
)
fprintf
(
stderr
,
"%s"
,
messageWithHeader
.
str
().
c_str
()
);
(
void
)
fflush
(
stderr
);
}
throw
OpenMM
::
OpenMMException
(
messageWithHeader
.
str
());
}
platforms/reference/tests/TestReferenceCustomGBForce.cpp
View file @
162d69a2
...
@@ -473,7 +473,7 @@ void testExclusions() {
...
@@ -473,7 +473,7 @@ void testExclusions() {
// create custom GB/VI force
// create custom GB/VI force
static
CustomGBForce
*
createCustomGBVI
(
double
solventDielectric
,
double
soluteDielectric
)
{
static
CustomGBForce
*
createCustomGBVI
(
double
solventDielectric
,
double
soluteDielectric
)
{
CustomGBForce
*
customGbviForce
=
new
CustomGBForce
();
CustomGBForce
*
customGbviForce
=
new
CustomGBForce
();
...
@@ -524,7 +524,7 @@ static CustomGBForce* createCustomGBVI( double solventDielectric, double soluteD
...
@@ -524,7 +524,7 @@ static CustomGBForce* createCustomGBVI( double solventDielectric, double soluteD
// ethance GB/VI test case
// ethance GB/VI test case
static
void
buildEthane
(
GBVIForce
*
gbviForce
,
std
::
vector
<
Vec3
>&
positions
)
{
static
void
buildEthane
(
GBVIForce
*
gbviForce
,
std
::
vector
<
Vec3
>&
positions
)
{
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
...
@@ -535,7 +535,7 @@ static void buildEthane( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
...
@@ -535,7 +535,7 @@ static void buildEthane( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
int
AM1_BCC
=
1
;
int
AM1_BCC
=
1
;
H_charge
=
-
0.053
;
H_charge
=
-
0.053
;
C_charge
=
-
3.0
*
H_charge
;
C_charge
=
-
3.0
*
H_charge
;
if
(
AM1_BCC
){
if
(
AM1_BCC
)
{
C_radius
=
0.180
;
C_radius
=
0.180
;
C_gamma
=
-
0.2863
;
C_gamma
=
-
0.2863
;
H_radius
=
0.125
;
H_radius
=
0.125
;
...
@@ -548,43 +548,43 @@ static void buildEthane( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
...
@@ -548,43 +548,43 @@ static void buildEthane( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
H_gamma
=
0.1237
;
H_gamma
=
0.1237
;
}
}
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
){
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
gbviForce
->
addParticle
(
H_charge
,
H_radius
,
H_gamma
);
gbviForce
->
addParticle
(
H_charge
,
H_radius
,
H_gamma
);
}
}
gbviForce
->
setParticleParameters
(
1
,
C_charge
,
C_radius
,
C_gamma
);
gbviForce
->
setParticleParameters
(
1
,
C_charge
,
C_radius
,
C_gamma
);
gbviForce
->
setParticleParameters
(
4
,
C_charge
,
C_radius
,
C_gamma
);
gbviForce
->
setParticleParameters
(
4
,
C_charge
,
C_radius
,
C_gamma
);
gbviForce
->
addBond
(
0
,
1
,
C_HBondDistance
);
gbviForce
->
addBond
(
0
,
1
,
C_HBondDistance
);
gbviForce
->
addBond
(
2
,
1
,
C_HBondDistance
);
gbviForce
->
addBond
(
2
,
1
,
C_HBondDistance
);
gbviForce
->
addBond
(
3
,
1
,
C_HBondDistance
);
gbviForce
->
addBond
(
3
,
1
,
C_HBondDistance
);
gbviForce
->
addBond
(
1
,
4
,
C_CBondDistance
);
gbviForce
->
addBond
(
1
,
4
,
C_CBondDistance
);
gbviForce
->
addBond
(
5
,
4
,
C_HBondDistance
);
gbviForce
->
addBond
(
5
,
4
,
C_HBondDistance
);
gbviForce
->
addBond
(
6
,
4
,
C_HBondDistance
);
gbviForce
->
addBond
(
6
,
4
,
C_HBondDistance
);
gbviForce
->
addBond
(
7
,
4
,
C_HBondDistance
);
gbviForce
->
addBond
(
7
,
4
,
C_HBondDistance
);
std
::
vector
<
pair
<
int
,
int
>
>
bondExceptions
;
std
::
vector
<
pair
<
int
,
int
>
>
bondExceptions
;
std
::
vector
<
double
>
bondDistances
;
std
::
vector
<
double
>
bondDistances
;
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
0
,
1
));
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
0
,
1
));
bondDistances
.
push_back
(
C_HBondDistance
);
bondDistances
.
push_back
(
C_HBondDistance
);
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
2
,
1
));
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
2
,
1
));
bondDistances
.
push_back
(
C_HBondDistance
);
bondDistances
.
push_back
(
C_HBondDistance
);
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
3
,
1
));
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
3
,
1
));
bondDistances
.
push_back
(
C_HBondDistance
);
bondDistances
.
push_back
(
C_HBondDistance
);
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
1
,
4
));
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
1
,
4
));
bondDistances
.
push_back
(
C_CBondDistance
);
bondDistances
.
push_back
(
C_CBondDistance
);
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
5
,
4
));
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
5
,
4
));
bondDistances
.
push_back
(
C_HBondDistance
);
bondDistances
.
push_back
(
C_HBondDistance
);
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
6
,
4
));
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
6
,
4
));
bondDistances
.
push_back
(
C_HBondDistance
);
bondDistances
.
push_back
(
C_HBondDistance
);
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
7
,
4
));
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
7
,
4
));
bondDistances
.
push_back
(
C_HBondDistance
);
bondDistances
.
push_back
(
C_HBondDistance
);
positions
.
resize
(
numParticles
);
positions
.
resize
(
numParticles
);
positions
[
0
]
=
Vec3
(
0.5480
,
1.7661
,
0.0000
);
positions
[
0
]
=
Vec3
(
0.5480
,
1.7661
,
0.0000
);
...
@@ -600,7 +600,7 @@ static void buildEthane( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
...
@@ -600,7 +600,7 @@ static void buildEthane( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
// dimer GB/VI test case
// dimer GB/VI test case
static
void
buildDimer
(
GBVIForce
*
gbviForce
,
std
::
vector
<
Vec3
>&
positions
)
{
static
void
buildDimer
(
GBVIForce
*
gbviForce
,
std
::
vector
<
Vec3
>&
positions
)
{
const
int
numParticles
=
2
;
const
int
numParticles
=
2
;
...
@@ -614,7 +614,7 @@ static void buildDimer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
...
@@ -614,7 +614,7 @@ static void buildDimer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
H_charge
=
0.0
;
H_charge
=
0.0
;
C_charge
=
0.0
;
C_charge
=
0.0
;
if
(
AM1_BCC
){
if
(
AM1_BCC
)
{
C_radius
=
0.180
;
C_radius
=
0.180
;
C_gamma
=
-
0.2863
;
C_gamma
=
-
0.2863
;
H_radius
=
0.125
;
H_radius
=
0.125
;
...
@@ -627,17 +627,17 @@ static void buildDimer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
...
@@ -627,17 +627,17 @@ static void buildDimer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
H_gamma
=
0.1237
;
H_gamma
=
0.1237
;
}
}
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
){
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
gbviForce
->
addParticle
(
H_charge
,
H_radius
,
H_gamma
);
gbviForce
->
addParticle
(
H_charge
,
H_radius
,
H_gamma
);
}
}
gbviForce
->
setParticleParameters
(
1
,
C_charge
,
C_radius
,
C_gamma
);
gbviForce
->
setParticleParameters
(
1
,
C_charge
,
C_radius
,
C_gamma
);
gbviForce
->
addBond
(
0
,
1
,
C_HBondDistance
);
gbviForce
->
addBond
(
0
,
1
,
C_HBondDistance
);
std
::
vector
<
pair
<
int
,
int
>
>
bondExceptions
;
std
::
vector
<
pair
<
int
,
int
>
>
bondExceptions
;
std
::
vector
<
double
>
bondDistances
;
std
::
vector
<
double
>
bondDistances
;
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
0
,
1
));
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
0
,
1
));
bondDistances
.
push_back
(
C_HBondDistance
);
bondDistances
.
push_back
(
C_HBondDistance
);
positions
.
resize
(
numParticles
);
positions
.
resize
(
numParticles
);
positions
[
0
]
=
Vec3
(
0.0
,
0.0
,
0.0
);
positions
[
0
]
=
Vec3
(
0.0
,
0.0
,
0.0
);
...
@@ -646,7 +646,7 @@ static void buildDimer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
...
@@ -646,7 +646,7 @@ static void buildDimer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
// monomer GB/VI test case
// monomer GB/VI test case
static
void
buildMonomer
(
GBVIForce
*
gbviForce
,
std
::
vector
<
Vec3
>&
positions
)
{
static
void
buildMonomer
(
GBVIForce
*
gbviForce
,
std
::
vector
<
Vec3
>&
positions
)
{
const
int
numParticles
=
1
;
const
int
numParticles
=
1
;
...
@@ -656,8 +656,8 @@ static void buildMonomer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
...
@@ -656,8 +656,8 @@ static void buildMonomer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
H_radius
=
0.125
;
H_radius
=
0.125
;
H_gamma
=
0.2437
;
H_gamma
=
0.2437
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
){
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
gbviForce
->
addParticle
(
H_charge
,
H_radius
,
H_gamma
);
gbviForce
->
addParticle
(
H_charge
,
H_radius
,
H_gamma
);
}
}
positions
.
resize
(
numParticles
);
positions
.
resize
(
numParticles
);
positions
[
0
]
=
Vec3
(
0.0
,
0.0
,
0.0
);
positions
[
0
]
=
Vec3
(
0.0
,
0.0
,
0.0
);
...
@@ -666,7 +666,7 @@ static void buildMonomer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
...
@@ -666,7 +666,7 @@ static void buildMonomer( GBVIForce* gbviForce, std::vector<Vec3>& positions ) {
// taken from gbviForceImpl class
// taken from gbviForceImpl class
// computes the scaled radii based on covalent info and atomic radii
// computes the scaled radii based on covalent info and atomic radii
static
void
findScaledRadii
(
GBVIForce
&
gbviForce
,
std
::
vector
<
double
>
&
scaledRadii
)
{
static
void
findScaledRadii
(
GBVIForce
&
gbviForce
,
std
::
vector
<
double
>
&
scaledRadii
)
{
int
numberOfParticles
=
gbviForce
.
getNumParticles
();
int
numberOfParticles
=
gbviForce
.
getNumParticles
();
int
numberOfBonds
=
gbviForce
.
getNumBonds
();
int
numberOfBonds
=
gbviForce
.
getNumBonds
();
...
@@ -674,15 +674,11 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
...
@@ -674,15 +674,11 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
// load 1-2 atom pairs along w/ bond distance using HarmonicBondForce & constraints
// load 1-2 atom pairs along w/ bond distance using HarmonicBondForce & constraints
// numberOfBonds < 1, indicating they were not set by the user
// numberOfBonds < 1, indicating they were not set by the user
if
(
numberOfBonds
<
1
&&
numberOfParticles
>
1
){
(
void
)
fprintf
(
stderr
,
"Warning: no covalent bonds set for GB/VI force!
\n
"
);
}
std
::
vector
<
std
::
vector
<
int
>
>
bondIndices
;
std
::
vector
<
std
::
vector
<
int
>
>
bondIndices
;
bondIndices
.
resize
(
numberOfBonds
);
bondIndices
.
resize
(
numberOfBonds
);
std
::
vector
<
double
>
bondLengths
;
std
::
vector
<
double
>
bondLengths
;
bondLengths
.
resize
(
numberOfBonds
);
bondLengths
.
resize
(
numberOfBonds
);
scaledRadii
.
resize
(
numberOfParticles
);
scaledRadii
.
resize
(
numberOfParticles
);
for
(
int
i
=
0
;
i
<
numberOfParticles
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numberOfParticles
;
i
++
)
{
...
@@ -707,14 +703,14 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
...
@@ -707,14 +703,14 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
msg
<<
particle2
;
msg
<<
particle2
;
throw
OpenMMException
(
msg
.
str
());
throw
OpenMMException
(
msg
.
str
());
}
}
if
(
bondLength
<
0
)
{
if
(
bondLength
<
0
)
{
std
::
stringstream
msg
;
std
::
stringstream
msg
;
msg
<<
"GBVISoftcoreForce: negative bondlength: "
;
msg
<<
"GBVISoftcoreForce: negative bondlength: "
;
msg
<<
bondLength
;
msg
<<
bondLength
;
throw
OpenMMException
(
msg
.
str
());
throw
OpenMMException
(
msg
.
str
());
}
}
bondIndices
[
i
].
push_back
(
particle1
);
bondIndices
[
i
].
push_back
(
particle1
);
bondIndices
[
i
].
push_back
(
particle2
);
bondIndices
[
i
].
push_back
(
particle2
);
bondLengths
[
i
]
=
bondLength
;
bondLengths
[
i
]
=
bondLength
;
}
}
...
@@ -732,7 +728,7 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
...
@@ -732,7 +728,7 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
// compute scaled radii (Eq. 5 of Labute paper [JCC 29 p. 1693-1698 2008])
// compute scaled radii (Eq. 5 of Labute paper [JCC 29 p. 1693-1698 2008])
for
(
int
j
=
0
;
j
<
(
int
)
bonded12
.
size
();
++
j
){
for
(
int
j
=
0
;
j
<
(
int
)
bonded12
.
size
();
++
j
)
{
double
charge
;
double
charge
;
double
gamma
;
double
gamma
;
...
@@ -741,10 +737,7 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
...
@@ -741,10 +737,7 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
gbviForce
.
getParticleParameters
(
j
,
charge
,
radiusJ
,
gamma
);
gbviForce
.
getParticleParameters
(
j
,
charge
,
radiusJ
,
gamma
);
if
(
bonded12
[
j
].
size
()
==
0
){
if
(
bonded12
[
j
].
size
()
==
0
)
{
if
(
numberOfParticles
>
1
){
(
void
)
fprintf
(
stderr
,
"Warning GBVIForceImpl::findScaledRadii atom %d has no covalent bonds; using atomic radius=%.3f.
\n
"
,
j
,
radiusJ
);
}
scaledRadiusJ
=
radiusJ
;
scaledRadiusJ
=
radiusJ
;
// errors++;
// errors++;
}
}
...
@@ -755,7 +748,7 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
...
@@ -755,7 +748,7 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
// loop over bonded neighbors of atom j, applying Eq. 5 in Labute
// loop over bonded neighbors of atom j, applying Eq. 5 in Labute
scaledRadiusJ
=
0.0
;
scaledRadiusJ
=
0.0
;
for
(
int
i
=
0
;
i
<
(
int
)
bonded12
[
j
].
size
();
++
i
){
for
(
int
i
=
0
;
i
<
(
int
)
bonded12
[
j
].
size
();
++
i
)
{
int
index
=
bonded12
[
j
][
i
];
int
index
=
bonded12
[
j
][
i
];
int
bondedAtomIndex
=
(
j
==
bondIndices
[
index
][
0
])
?
bondIndices
[
index
][
1
]
:
bondIndices
[
index
][
0
];
int
bondedAtomIndex
=
(
j
==
bondIndices
[
index
][
0
])
?
bondIndices
[
index
][
1
]
:
bondIndices
[
index
][
0
];
...
@@ -772,54 +765,33 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
...
@@ -772,54 +765,33 @@ static void findScaledRadii( GBVIForce& gbviForce, std::vector<double> & scaledR
a_ji
*=
a_ji
;
a_ji
*=
a_ji
;
a_ji
=
(
rI2
-
a_ji
)
/
(
2.0
*
bondLengths
[
index
]);
a_ji
=
(
rI2
-
a_ji
)
/
(
2.0
*
bondLengths
[
index
]);
scaledRadiusJ
+=
a_ij
*
a_ij
*
(
3.0
*
radiusI
-
a_ij
)
+
a_ji
*
a_ji
*
(
3.0
*
radiusJ
-
a_ji
);
scaledRadiusJ
+=
a_ij
*
a_ij
*
(
3.0
*
radiusI
-
a_ij
)
+
a_ji
*
a_ji
*
(
3.0
*
radiusJ
-
a_ji
);
}
}
scaledRadiusJ
=
(
radiusJ
*
radiusJ
*
radiusJ
)
-
0.125
*
scaledRadiusJ
;
scaledRadiusJ
=
(
radiusJ
*
radiusJ
*
radiusJ
)
-
0.125
*
scaledRadiusJ
;
if
(
scaledRadiusJ
>
0.0
){
if
(
scaledRadiusJ
>
0.0
)
{
scaledRadiusJ
=
0.95
*
pow
(
scaledRadiusJ
,
(
1.0
/
3.0
)
);
scaledRadiusJ
=
0.95
*
pow
(
scaledRadiusJ
,
(
1.0
/
3.0
));
}
}
else
{
else
{
scaledRadiusJ
=
0.0
;
scaledRadiusJ
=
0.0
;
}
}
}
}
//(void) fprintf( stderr, "scaledRadii %d %12.4f\n", j, scaledRadiusJ );
scaledRadii
[
j
]
=
scaledRadiusJ
;
scaledRadii
[
j
]
=
scaledRadiusJ
;
}
}
// abort if errors
// abort if errors
if
(
errors
){
if
(
errors
)
{
throw
OpenMMException
(
"GBVIForceImpl::findScaledRadii errors -- aborting"
);
throw
OpenMMException
(
"GBVIForceImpl::findScaledRadii errors -- aborting"
);
}
}
#if GBVIDebug
(
void
)
fprintf
(
stderr
,
" R q gamma scaled radii no. bnds
\n
"
);
double
totalQ
=
0.0
;
for
(
int
i
=
0
;
i
<
(
int
)
scaledRadii
.
size
();
i
++
){
double
charge
;
double
gamma
;
double
radiusI
;
gbviForce
.
getParticleParameters
(
i
,
charge
,
radiusI
,
gamma
);
totalQ
+=
charge
;
(
void
)
fprintf
(
stderr
,
"%4d %14.5e %14.5e %14.5e %14.5e %d
\n
"
,
i
,
radiusI
,
charge
,
gamma
,
scaledRadii
[
i
],
(
int
)
bonded12
[
i
].
size
()
);
}
(
void
)
fprintf
(
stderr
,
"Total charge=%e
\n
"
,
totalQ
);
(
void
)
fflush
(
stderr
);
#endif
#undef GBVIDebug
}
}
// load parameters from gbviForce to customGbviForce
// load parameters from gbviForce to customGbviForce
// findScaledRadii() is called to calculate the scaled radii (S)
// findScaledRadii() is called to calculate the scaled radii (S)
// S is derived quantity in GBVIForce, not a parameter is the case here
// S is derived quantity in GBVIForce, not a parameter is the case here
static
void
loadGbviParameters
(
GBVIForce
*
gbviForce
,
CustomGBForce
*
customGbviForce
)
{
static
void
loadGbviParameters
(
GBVIForce
*
gbviForce
,
CustomGBForce
*
customGbviForce
)
{
int
numParticles
=
gbviForce
->
getNumParticles
();
int
numParticles
=
gbviForce
->
getNumParticles
();
...
@@ -827,11 +799,11 @@ static void loadGbviParameters( GBVIForce* gbviForce, CustomGBForce* customGbviF
...
@@ -827,11 +799,11 @@ static void loadGbviParameters( GBVIForce* gbviForce, CustomGBForce* customGbviF
vector
<
double
>
params
(
4
);
vector
<
double
>
params
(
4
);
std
::
vector
<
double
>
scaledRadii
;
std
::
vector
<
double
>
scaledRadii
;
findScaledRadii
(
*
gbviForce
,
scaledRadii
);
findScaledRadii
(
*
gbviForce
,
scaledRadii
);
for
(
int
ii
=
0
;
ii
<
numParticles
;
ii
++
)
{
for
(
int
ii
=
0
;
ii
<
numParticles
;
ii
++
)
{
double
charge
,
radius
,
gamma
;
double
charge
,
radius
,
gamma
;
gbviForce
->
getParticleParameters
(
ii
,
charge
,
radius
,
gamma
);
gbviForce
->
getParticleParameters
(
ii
,
charge
,
radius
,
gamma
);
params
[
0
]
=
charge
;
params
[
0
]
=
charge
;
params
[
1
]
=
radius
;
params
[
1
]
=
radius
;
params
[
2
]
=
scaledRadii
[
ii
];
params
[
2
]
=
scaledRadii
[
ii
];
...
@@ -852,14 +824,14 @@ void testGBVI(GBVIForce::NonbondedMethod gbviMethod, CustomGBForce::NonbondedMet
...
@@ -852,14 +824,14 @@ void testGBVI(GBVIForce::NonbondedMethod gbviMethod, CustomGBForce::NonbondedMet
// select molecule
// select molecule
if
(
molecule
==
"Monomer"
){
if
(
molecule
==
"Monomer"
)
{
buildMonomer
(
gbvi
,
positions
);
buildMonomer
(
gbvi
,
positions
);
}
}
else
if
(
molecule
==
"Dimer"
){
else
if
(
molecule
==
"Dimer"
)
{
buildDimer
(
gbvi
,
positions
);
buildDimer
(
gbvi
,
positions
);
}
}
else
{
else
{
buildEthane
(
gbvi
,
positions
);
buildEthane
(
gbvi
,
positions
);
}
}
int
numParticles
=
gbvi
->
getNumParticles
();
int
numParticles
=
gbvi
->
getNumParticles
();
...
@@ -875,12 +847,12 @@ void testGBVI(GBVIForce::NonbondedMethod gbviMethod, CustomGBForce::NonbondedMet
...
@@ -875,12 +847,12 @@ void testGBVI(GBVIForce::NonbondedMethod gbviMethod, CustomGBForce::NonbondedMet
// create customGbviForce GBVI force
// create customGbviForce GBVI force
CustomGBForce
*
customGbviForce
=
createCustomGBVI
(
gbvi
->
getSolventDielectric
(),
gbvi
->
getSoluteDielectric
()
);
CustomGBForce
*
customGbviForce
=
createCustomGBVI
(
gbvi
->
getSolventDielectric
(),
gbvi
->
getSoluteDielectric
());
customGbviForce
->
setCutoffDistance
(
2.0
);
customGbviForce
->
setCutoffDistance
(
2.0
);
// load parameters from gbvi to customGbviForce
// load parameters from gbvi to customGbviForce
loadGbviParameters
(
gbvi
,
customGbviForce
);
loadGbviParameters
(
gbvi
,
customGbviForce
);
OpenMM_SFMT
::
SFMT
sfmt
;
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
init_gen_rand
(
0
,
sfmt
);
...
...
platforms/reference/tests/TestReferenceGBVIForce.cpp
View file @
162d69a2
...
@@ -53,7 +53,6 @@ using namespace std;
...
@@ -53,7 +53,6 @@ using namespace std;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testSingleParticle
()
{
void
testSingleParticle
()
{
const
int
log
=
0
;
ReferencePlatform
platform
;
ReferencePlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
...
@@ -80,24 +79,19 @@ void testSingleParticle() {
...
@@ -80,24 +79,19 @@ void testSingleParticle() {
double
tau
=
(
1.0
/
forceField
->
getSoluteDielectric
()
-
1.0
/
forceField
->
getSolventDielectric
());
double
tau
=
(
1.0
/
forceField
->
getSoluteDielectric
()
-
1.0
/
forceField
->
getSolventDielectric
());
double
bornEnergy
=
(
-
charge
*
charge
/
(
8
*
PI_M
*
eps0
))
*
tau
/
bornRadius
;
double
bornEnergy
=
(
-
charge
*
charge
/
(
8
*
PI_M
*
eps0
))
*
tau
/
bornRadius
;
double
nonpolarEnergy
=
-
gamma
*
tau
*
std
::
pow
(
radius
/
bornRadius
,
3.0
);
double
nonpolarEnergy
=
-
gamma
*
tau
*
std
::
pow
(
radius
/
bornRadius
,
3.0
);
double
expectedE
=
(
bornEnergy
+
nonpolarEnergy
);
double
expectedE
=
(
bornEnergy
+
nonpolarEnergy
);
double
obtainedE
=
state
.
getPotentialEnergy
();
double
obtainedE
=
state
.
getPotentialEnergy
();
double
diff
=
fabs
(
(
obtainedE
-
expectedE
)
/
expectedE
);
double
diff
=
fabs
((
obtainedE
-
expectedE
)
/
expectedE
);
if
(
log
){
(
void
)
fprintf
(
stderr
,
"testSingleParticle expected=%14.6e obtained=%14.6e diff=%14.6e breakdown:[%14.6e %14.6e]
\n
"
,
expectedE
,
obtainedE
,
diff
,
bornEnergy
,
nonpolarEnergy
);
}
ASSERT_EQUAL_TOL
((
bornEnergy
+
nonpolarEnergy
),
state
.
getPotentialEnergy
(),
0.01
);
ASSERT_EQUAL_TOL
((
bornEnergy
+
nonpolarEnergy
),
state
.
getPotentialEnergy
(),
0.01
);
}
}
void
testEnergyEthane
(
int
applyBornRadiiScaling
)
{
void
testEnergyEthane
(
int
applyBornRadiiScaling
)
{
ReferencePlatform
platform
;
ReferencePlatform
platform
;
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
int
log
=
0
;
System
system
;
System
system
;
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
...
@@ -123,7 +117,7 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
...
@@ -123,7 +117,7 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
int
AM1_BCC
=
1
;
int
AM1_BCC
=
1
;
H_charge
=
-
0.053
;
H_charge
=
-
0.053
;
C_charge
=
-
3.0
*
H_charge
;
C_charge
=
-
3.0
*
H_charge
;
if
(
AM1_BCC
){
if
(
AM1_BCC
)
{
C_radius
=
0.180
;
C_radius
=
0.180
;
C_gamma
=
-
0.2863
;
C_gamma
=
-
0.2863
;
H_radius
=
0.125
;
H_radius
=
0.125
;
...
@@ -139,59 +133,56 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
...
@@ -139,59 +133,56 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
NoCutoff
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
NoCutoff
);
if
(
log
){
(
void
)
fprintf
(
stderr
,
"Applying GB/VI
\n
"
);
}
GBVIForce
*
forceField
=
new
GBVIForce
();
GBVIForce
*
forceField
=
new
GBVIForce
();
if
(
applyBornRadiiScaling
){
if
(
applyBornRadiiScaling
)
{
forceField
->
setBornRadiusScalingMethod
(
GBVIForce
::
QuinticSpline
);
forceField
->
setBornRadiusScalingMethod
(
GBVIForce
::
QuinticSpline
);
}
}
else
{
else
{
forceField
->
setBornRadiusScalingMethod
(
GBVIForce
::
NoScaling
);
forceField
->
setBornRadiusScalingMethod
(
GBVIForce
::
NoScaling
);
}
}
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
){
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
forceField
->
addParticle
(
H_charge
,
H_radius
,
H_gamma
);
forceField
->
addParticle
(
H_charge
,
H_radius
,
H_gamma
);
nonbonded
->
addParticle
(
H_charge
,
H_radius
,
0.0
);
nonbonded
->
addParticle
(
H_charge
,
H_radius
,
0.0
);
}
}
forceField
->
setParticleParameters
(
1
,
C_charge
,
C_radius
,
C_gamma
);
forceField
->
setParticleParameters
(
1
,
C_charge
,
C_radius
,
C_gamma
);
forceField
->
setParticleParameters
(
4
,
C_charge
,
C_radius
,
C_gamma
);
forceField
->
setParticleParameters
(
4
,
C_charge
,
C_radius
,
C_gamma
);
nonbonded
->
setParticleParameters
(
1
,
C_charge
,
C_radius
,
0.0
);
nonbonded
->
setParticleParameters
(
1
,
C_charge
,
C_radius
,
0.0
);
nonbonded
->
setParticleParameters
(
4
,
C_charge
,
C_radius
,
0.0
);
nonbonded
->
setParticleParameters
(
4
,
C_charge
,
C_radius
,
0.0
);
forceField
->
addBond
(
0
,
1
,
C_HBondDistance
);
forceField
->
addBond
(
0
,
1
,
C_HBondDistance
);
forceField
->
addBond
(
2
,
1
,
C_HBondDistance
);
forceField
->
addBond
(
2
,
1
,
C_HBondDistance
);
forceField
->
addBond
(
3
,
1
,
C_HBondDistance
);
forceField
->
addBond
(
3
,
1
,
C_HBondDistance
);
forceField
->
addBond
(
1
,
4
,
C_CBondDistance
);
forceField
->
addBond
(
1
,
4
,
C_CBondDistance
);
forceField
->
addBond
(
5
,
4
,
C_HBondDistance
);
forceField
->
addBond
(
5
,
4
,
C_HBondDistance
);
forceField
->
addBond
(
6
,
4
,
C_HBondDistance
);
forceField
->
addBond
(
6
,
4
,
C_HBondDistance
);
forceField
->
addBond
(
7
,
4
,
C_HBondDistance
);
forceField
->
addBond
(
7
,
4
,
C_HBondDistance
);
std
::
vector
<
pair
<
int
,
int
>
>
bondExceptions
;
std
::
vector
<
pair
<
int
,
int
>
>
bondExceptions
;
std
::
vector
<
double
>
bondDistances
;
std
::
vector
<
double
>
bondDistances
;
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
0
,
1
));
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
0
,
1
));
bondDistances
.
push_back
(
C_HBondDistance
);
bondDistances
.
push_back
(
C_HBondDistance
);
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
2
,
1
));
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
2
,
1
));
bondDistances
.
push_back
(
C_HBondDistance
);
bondDistances
.
push_back
(
C_HBondDistance
);
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
3
,
1
));
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
3
,
1
));
bondDistances
.
push_back
(
C_HBondDistance
);
bondDistances
.
push_back
(
C_HBondDistance
);
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
1
,
4
));
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
1
,
4
));
bondDistances
.
push_back
(
C_CBondDistance
);
bondDistances
.
push_back
(
C_CBondDistance
);
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
5
,
4
));
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
5
,
4
));
bondDistances
.
push_back
(
C_HBondDistance
);
bondDistances
.
push_back
(
C_HBondDistance
);
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
6
,
4
));
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
6
,
4
));
bondDistances
.
push_back
(
C_HBondDistance
);
bondDistances
.
push_back
(
C_HBondDistance
);
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
7
,
4
));
bondExceptions
.
push_back
(
pair
<
int
,
int
>
(
7
,
4
));
bondDistances
.
push_back
(
C_HBondDistance
);
bondDistances
.
push_back
(
C_HBondDistance
);
nonbonded
->
createExceptionsFromBonds
(
bondExceptions
,
0.0
,
0.0
);
nonbonded
->
createExceptionsFromBonds
(
bondExceptions
,
0.0
,
0.0
);
...
@@ -212,9 +203,6 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
...
@@ -212,9 +203,6 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
if
(
log
){
(
void
)
fprintf
(
stderr
,
"Energy %.4e
\n
"
,
state
.
getPotentialEnergy
()
);
}
// Take a small step in the direction of the energy gradient.
// Take a small step in the direction of the energy gradient.
...
@@ -222,18 +210,12 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
...
@@ -222,18 +210,12 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
double
forceSum
[
3
]
=
{
0.0
,
0.0
,
0.0
};
double
forceSum
[
3
]
=
{
0.0
,
0.0
,
0.0
};
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
Vec3
f
=
state
.
getForces
()[
i
];
Vec3
f
=
state
.
getForces
()[
i
];
if
(
log
){
(
void
)
fprintf
(
stderr
,
"F %d [%14.6e %14.6e %14.6e]
\n
"
,
i
,
f
[
0
],
f
[
1
],
f
[
2
]
);
}
norm
+=
f
[
0
]
*
f
[
0
]
+
f
[
1
]
*
f
[
1
]
+
f
[
2
]
*
f
[
2
];
norm
+=
f
[
0
]
*
f
[
0
]
+
f
[
1
]
*
f
[
1
]
+
f
[
2
]
*
f
[
2
];
forceSum
[
0
]
+=
f
[
0
];
forceSum
[
0
]
+=
f
[
0
];
forceSum
[
1
]
+=
f
[
1
];
forceSum
[
1
]
+=
f
[
1
];
forceSum
[
2
]
+=
f
[
2
];
forceSum
[
2
]
+=
f
[
2
];
}
}
norm
=
std
::
sqrt
(
norm
);
norm
=
std
::
sqrt
(
norm
);
if
(
log
){
(
void
)
fprintf
(
stderr
,
"Fsum [%14.6e %14.6e %14.6e] norm=%14.6e
\n
"
,
forceSum
[
0
],
forceSum
[
1
],
forceSum
[
2
],
norm
);
}
const
double
delta
=
1e-4
;
const
double
delta
=
1e-4
;
double
step
=
delta
/
norm
;
double
step
=
delta
/
norm
;
...
@@ -246,12 +228,6 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
...
@@ -246,12 +228,6 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
State
state2
=
context
.
getState
(
State
::
Energy
);
State
state2
=
context
.
getState
(
State
::
Energy
);
if
(
log
){
double
deltaE
=
fabs
(
state
.
getPotentialEnergy
()
-
state2
.
getPotentialEnergy
()
)
/
delta
;
double
diff
=
(
deltaE
-
norm
)
/
norm
;
(
void
)
fprintf
(
stderr
,
"Energies %.8e %.8e deltaE=%14.7e %14.7e diff=%14.7e
\n
"
,
state
.
getPotentialEnergy
(),
state2
.
getPotentialEnergy
(),
deltaE
,
norm
,
diff
);
}
// See whether the potential energy changed by the expected amount.
// See whether the potential energy changed by the expected amount.
ASSERT_EQUAL_TOL
(
norm
,
(
state2
.
getPotentialEnergy
()
-
state
.
getPotentialEnergy
())
/
delta
,
0.01
)
ASSERT_EQUAL_TOL
(
norm
,
(
state2
.
getPotentialEnergy
()
-
state
.
getPotentialEnergy
())
/
delta
,
0.01
)
...
@@ -260,8 +236,8 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
...
@@ -260,8 +236,8 @@ void testEnergyEthane( int applyBornRadiiScaling ) {
int
main
()
{
int
main
()
{
try
{
try
{
testSingleParticle
();
testSingleParticle
();
testEnergyEthane
(
0
);
testEnergyEthane
(
0
);
testEnergyEthane
(
1
);
testEnergyEthane
(
1
);
}
}
catch
(
const
exception
&
e
)
{
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
...
...
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