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
a783b996
Commit
a783b996
authored
Jan 13, 2017
by
peastman
Browse files
Eliminated RealOpenMM type
parent
9500f3af
Changes
148
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
2792 additions
and
2951 deletions
+2792
-2951
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceBondForce.h
...s/reference/src/SimTKReference/AmoebaReferenceBondForce.h
+14
-14
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceForce.cpp
...rms/reference/src/SimTKReference/AmoebaReferenceForce.cpp
+28
-27
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceForce.h
...forms/reference/src/SimTKReference/AmoebaReferenceForce.h
+15
-16
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceGeneralizedKirkwoodForce.cpp
...imTKReference/AmoebaReferenceGeneralizedKirkwoodForce.cpp
+48
-54
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceGeneralizedKirkwoodForce.h
.../SimTKReference/AmoebaReferenceGeneralizedKirkwoodForce.h
+27
-27
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceInPlaneAngleForce.cpp
...e/src/SimTKReference/AmoebaReferenceInPlaneAngleForce.cpp
+68
-83
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceInPlaneAngleForce.h
...nce/src/SimTKReference/AmoebaReferenceInPlaneAngleForce.h
+26
-26
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceMultipoleForce.cpp
...ence/src/SimTKReference/AmoebaReferenceMultipoleForce.cpp
+1700
-1701
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceMultipoleForce.h
...erence/src/SimTKReference/AmoebaReferenceMultipoleForce.h
+266
-266
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceOutOfPlaneBendForce.cpp
...src/SimTKReference/AmoebaReferenceOutOfPlaneBendForce.cpp
+57
-70
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceOutOfPlaneBendForce.h
...e/src/SimTKReference/AmoebaReferenceOutOfPlaneBendForce.h
+20
-21
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferencePiTorsionForce.cpp
...ence/src/SimTKReference/AmoebaReferencePiTorsionForce.cpp
+36
-45
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferencePiTorsionForce.h
...erence/src/SimTKReference/AmoebaReferencePiTorsionForce.h
+16
-16
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceStretchBendForce.cpp
...ce/src/SimTKReference/AmoebaReferenceStretchBendForce.cpp
+54
-62
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceStretchBendForce.h
...ence/src/SimTKReference/AmoebaReferenceStretchBendForce.h
+18
-18
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceTorsionTorsionForce.cpp
...src/SimTKReference/AmoebaReferenceTorsionTorsionForce.cpp
+110
-156
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceTorsionTorsionForce.h
...e/src/SimTKReference/AmoebaReferenceTorsionTorsionForce.h
+30
-30
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceVdwForce.cpp
.../reference/src/SimTKReference/AmoebaReferenceVdwForce.cpp
+79
-113
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceVdwForce.h
...ms/reference/src/SimTKReference/AmoebaReferenceVdwForce.h
+30
-31
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceWcaDispersionForce.cpp
.../src/SimTKReference/AmoebaReferenceWcaDispersionForce.cpp
+150
-175
No files found.
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceBondForce.h
View file @
a783b996
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceBondForce_H__
#ifndef __AmoebaReferenceBondForce_H__
#define __AmoebaReferenceBondForce_H__
#define __AmoebaReferenceBondForce_H__
#include "
Real
Vec.h"
#include "
openmm/
Vec
3
.h"
#include <vector>
#include <vector>
namespace
OpenMM
{
namespace
OpenMM
{
...
@@ -58,7 +58,7 @@ public:
...
@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
Real
Vec
*
vectors
);
void
setPeriodic
(
OpenMM
::
Vec
3
*
vectors
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -78,18 +78,18 @@ public:
...
@@ -78,18 +78,18 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
calculateForceAndEnergy
(
int
numBonds
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
posData
,
double
calculateForceAndEnergy
(
int
numBonds
,
std
::
vector
<
OpenMM
::
Vec
3
>&
posData
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
RealOpenMM
>&
bondLength
,
const
std
::
vector
<
double
>&
bondLength
,
const
std
::
vector
<
RealOpenMM
>&
bondK
,
const
std
::
vector
<
double
>&
bondK
,
RealOpenMM
bondCubic
,
RealOpenMM
bondQuartic
,
double
bondCubic
,
double
bondQuartic
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forceData
)
const
;
std
::
vector
<
OpenMM
::
Vec
3
>&
forceData
)
const
;
private:
private:
bool
usePeriodic
;
bool
usePeriodic
;
Real
Vec
boxVectors
[
3
];
Vec
3
boxVectors
[
3
];
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -107,10 +107,10 @@ private:
...
@@ -107,10 +107,10 @@ private:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
calculateBondIxn
(
const
OpenMM
::
Real
Vec
&
positionAtomA
,
const
OpenMM
::
Real
Vec
&
positionAtomB
,
double
calculateBondIxn
(
const
OpenMM
::
Vec
3
&
positionAtomA
,
const
OpenMM
::
Vec
3
&
positionAtomB
,
RealOpenMM
bondLength
,
RealOpenMM
bondK
,
double
bondLength
,
double
bondK
,
RealOpenMM
bondCubic
,
RealOpenMM
bondQuartic
,
double
bondCubic
,
double
bondQuartic
,
OpenMM
::
Real
Vec
*
forces
)
const
;
OpenMM
::
Vec
3
*
forces
)
const
;
};
};
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceForce.cpp
View file @
a783b996
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
*/
*/
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceForce.h"
#include <cmath>
#include <vector>
#include <vector>
using
namespace
OpenMM
;
using
namespace
OpenMM
;
...
@@ -37,8 +38,8 @@ using namespace OpenMM;
...
@@ -37,8 +38,8 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
AmoebaReferenceForce
::
loadDeltaR
(
const
Real
Vec
&
xVector
,
const
Real
Vec
&
yVector
,
void
AmoebaReferenceForce
::
loadDeltaR
(
const
Vec
3
&
xVector
,
const
Vec
3
&
yVector
,
std
::
vector
<
RealOpenMM
>&
deltaR
)
{
std
::
vector
<
double
>&
deltaR
)
{
deltaR
.
resize
(
0
);
deltaR
.
resize
(
0
);
deltaR
.
push_back
(
yVector
[
0
]
-
xVector
[
0
]);
deltaR
.
push_back
(
yVector
[
0
]
-
xVector
[
0
]);
deltaR
.
push_back
(
yVector
[
1
]
-
xVector
[
1
]);
deltaR
.
push_back
(
yVector
[
1
]
-
xVector
[
1
]);
...
@@ -56,9 +57,9 @@ void AmoebaReferenceForce::loadDeltaR(const RealVec& xVector, const RealVec& yVe
...
@@ -56,9 +57,9 @@ void AmoebaReferenceForce::loadDeltaR(const RealVec& xVector, const RealVec& yVe
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
const
Real
Vec
&
xVector
,
const
Real
Vec
&
yVector
,
void
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
const
Vec
3
&
xVector
,
const
Vec
3
&
yVector
,
std
::
vector
<
RealOpenMM
>&
deltaR
,
const
Real
Vec
*
boxVectors
)
{
std
::
vector
<
double
>&
deltaR
,
const
Vec
3
*
boxVectors
)
{
Real
Vec
diff
=
yVector
-
xVector
;
Vec
3
diff
=
yVector
-
xVector
;
diff
-=
boxVectors
[
2
]
*
floor
(
diff
[
2
]
/
boxVectors
[
2
][
2
]
+
0.5
);
diff
-=
boxVectors
[
2
]
*
floor
(
diff
[
2
]
/
boxVectors
[
2
][
2
]
+
0.5
);
diff
-=
boxVectors
[
1
]
*
floor
(
diff
[
1
]
/
boxVectors
[
1
][
1
]
+
0.5
);
diff
-=
boxVectors
[
1
]
*
floor
(
diff
[
1
]
/
boxVectors
[
1
][
1
]
+
0.5
);
diff
-=
boxVectors
[
0
]
*
floor
(
diff
[
0
]
/
boxVectors
[
0
][
0
]
+
0.5
);
diff
-=
boxVectors
[
0
]
*
floor
(
diff
[
0
]
/
boxVectors
[
0
][
0
]
+
0.5
);
...
@@ -78,7 +79,7 @@ void AmoebaReferenceForce::loadDeltaRPeriodic(const RealVec& xVector, const Real
...
@@ -78,7 +79,7 @@ void AmoebaReferenceForce::loadDeltaRPeriodic(const RealVec& xVector, const Real
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
AmoebaReferenceForce
::
getNormSquared3
(
const
std
::
vector
<
RealOpenMM
>&
inputVector
)
{
double
AmoebaReferenceForce
::
getNormSquared3
(
const
std
::
vector
<
double
>&
inputVector
)
{
// get 3 norm
// get 3 norm
return
(
inputVector
[
0
]
*
inputVector
[
0
]
+
inputVector
[
1
]
*
inputVector
[
1
]
+
inputVector
[
2
]
*
inputVector
[
2
]);
return
(
inputVector
[
0
]
*
inputVector
[
0
]
+
inputVector
[
1
]
*
inputVector
[
1
]
+
inputVector
[
2
]
*
inputVector
[
2
]);
...
@@ -94,7 +95,7 @@ RealOpenMM AmoebaReferenceForce::getNormSquared3(const std::vector<RealOpenMM>&
...
@@ -94,7 +95,7 @@ RealOpenMM AmoebaReferenceForce::getNormSquared3(const std::vector<RealOpenMM>&
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
AmoebaReferenceForce
::
getNormSquared3
(
const
RealOpenMM
*
inputVector
)
{
double
AmoebaReferenceForce
::
getNormSquared3
(
const
double
*
inputVector
)
{
// get 3 norm
// get 3 norm
return
(
inputVector
[
0
]
*
inputVector
[
0
]
+
inputVector
[
1
]
*
inputVector
[
1
]
+
inputVector
[
2
]
*
inputVector
[
2
]);
return
(
inputVector
[
0
]
*
inputVector
[
0
]
+
inputVector
[
1
]
*
inputVector
[
1
]
+
inputVector
[
2
]
*
inputVector
[
2
]);
...
@@ -110,25 +111,25 @@ RealOpenMM AmoebaReferenceForce::getNormSquared3(const RealOpenMM* inputVector)
...
@@ -110,25 +111,25 @@ RealOpenMM AmoebaReferenceForce::getNormSquared3(const RealOpenMM* inputVector)
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
AmoebaReferenceForce
::
getNorm3
(
const
std
::
vector
<
RealOpenMM
>&
inputVector
)
{
double
AmoebaReferenceForce
::
getNorm3
(
const
std
::
vector
<
double
>&
inputVector
)
{
// get 3 norm
// get 3 norm
return
SQRT
(
inputVector
[
0
]
*
inputVector
[
0
]
+
inputVector
[
1
]
*
inputVector
[
1
]
+
inputVector
[
2
]
*
inputVector
[
2
]);
return
sqrt
(
inputVector
[
0
]
*
inputVector
[
0
]
+
inputVector
[
1
]
*
inputVector
[
1
]
+
inputVector
[
2
]
*
inputVector
[
2
]);
}
}
RealOpenMM
AmoebaReferenceForce
::
getNorm3
(
const
RealOpenMM
*
inputVector
)
{
double
AmoebaReferenceForce
::
getNorm3
(
const
double
*
inputVector
)
{
// get 3 norm
// get 3 norm
return
SQRT
(
inputVector
[
0
]
*
inputVector
[
0
]
+
inputVector
[
1
]
*
inputVector
[
1
]
+
inputVector
[
2
]
*
inputVector
[
2
]);
return
sqrt
(
inputVector
[
0
]
*
inputVector
[
0
]
+
inputVector
[
1
]
*
inputVector
[
1
]
+
inputVector
[
2
]
*
inputVector
[
2
]);
}
}
RealOpenMM
AmoebaReferenceForce
::
normalizeVector3
(
RealOpenMM
*
inputVector
)
{
double
AmoebaReferenceForce
::
normalizeVector3
(
double
*
inputVector
)
{
RealOpenMM
norm
=
SQRT
(
inputVector
[
0
]
*
inputVector
[
0
]
+
inputVector
[
1
]
*
inputVector
[
1
]
+
inputVector
[
2
]
*
inputVector
[
2
]);
double
norm
=
sqrt
(
inputVector
[
0
]
*
inputVector
[
0
]
+
inputVector
[
1
]
*
inputVector
[
1
]
+
inputVector
[
2
]
*
inputVector
[
2
]);
if
(
norm
>
0.0
)
{
if
(
norm
>
0.0
)
{
RealOpenMM
normI
=
1.0
/
norm
;
double
normI
=
1.0
/
norm
;
inputVector
[
0
]
*=
normI
;
inputVector
[
0
]
*=
normI
;
inputVector
[
1
]
*=
normI
;
inputVector
[
1
]
*=
normI
;
inputVector
[
2
]
*=
normI
;
inputVector
[
2
]
*=
normI
;
}
}
return
norm
;
return
norm
;
...
@@ -145,7 +146,7 @@ RealOpenMM AmoebaReferenceForce::normalizeVector3(RealOpenMM* inputVector) {
...
@@ -145,7 +146,7 @@ RealOpenMM AmoebaReferenceForce::normalizeVector3(RealOpenMM* inputVector) {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
AmoebaReferenceForce
::
getDotProduct3
(
const
std
::
vector
<
RealOpenMM
>&
xVector
,
const
std
::
vector
<
RealOpenMM
>&
yVector
)
{
double
AmoebaReferenceForce
::
getDotProduct3
(
const
std
::
vector
<
double
>&
xVector
,
const
std
::
vector
<
double
>&
yVector
)
{
// get dot product
// get dot product
return
xVector
[
0
]
*
yVector
[
0
]
+
xVector
[
1
]
*
yVector
[
1
]
+
xVector
[
2
]
*
yVector
[
2
];
return
xVector
[
0
]
*
yVector
[
0
]
+
xVector
[
1
]
*
yVector
[
1
]
+
xVector
[
2
]
*
yVector
[
2
];
...
@@ -162,13 +163,13 @@ RealOpenMM AmoebaReferenceForce::getDotProduct3(const std::vector<RealOpenMM>& x
...
@@ -162,13 +163,13 @@ RealOpenMM AmoebaReferenceForce::getDotProduct3(const std::vector<RealOpenMM>& x
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
AmoebaReferenceForce
::
getDotProduct3
(
const
RealOpenMM
*
xVector
,
const
RealOpenMM
*
yVector
)
{
double
AmoebaReferenceForce
::
getDotProduct3
(
const
double
*
xVector
,
const
double
*
yVector
)
{
// get dot product
// get dot product
return
xVector
[
0
]
*
yVector
[
0
]
+
xVector
[
1
]
*
yVector
[
1
]
+
xVector
[
2
]
*
yVector
[
2
];
return
xVector
[
0
]
*
yVector
[
0
]
+
xVector
[
1
]
*
yVector
[
1
]
+
xVector
[
2
]
*
yVector
[
2
];
}
}
RealOpenMM
AmoebaReferenceForce
::
getDotProduct3
(
const
RealOpenMM
*
xVector
,
const
OpenMM
::
Vec3
&
yVector
)
{
double
AmoebaReferenceForce
::
getDotProduct3
(
const
double
*
xVector
,
const
OpenMM
::
Vec3
&
yVector
)
{
// get dot product
// get dot product
return
xVector
[
0
]
*
yVector
[
0
]
+
xVector
[
1
]
*
yVector
[
1
]
+
xVector
[
2
]
*
yVector
[
2
];
return
xVector
[
0
]
*
yVector
[
0
]
+
xVector
[
1
]
*
yVector
[
1
]
+
xVector
[
2
]
*
yVector
[
2
];
...
@@ -186,7 +187,7 @@ RealOpenMM AmoebaReferenceForce::getDotProduct3(const RealOpenMM* xVector, const
...
@@ -186,7 +187,7 @@ RealOpenMM AmoebaReferenceForce::getDotProduct3(const RealOpenMM* xVector, const
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
AmoebaReferenceForce
::
getDotProduct3
(
unsigned
int
vectorOffset
,
const
std
::
vector
<
RealOpenMM
>&
xVector
,
const
RealOpenMM
*
yVector
)
{
double
AmoebaReferenceForce
::
getDotProduct3
(
unsigned
int
vectorOffset
,
const
std
::
vector
<
double
>&
xVector
,
const
double
*
yVector
)
{
// get dot product
// get dot product
return
xVector
[
vectorOffset
+
0
]
*
yVector
[
0
]
+
xVector
[
vectorOffset
+
1
]
*
yVector
[
1
]
+
xVector
[
vectorOffset
+
2
]
*
yVector
[
2
];
return
xVector
[
vectorOffset
+
0
]
*
yVector
[
0
]
+
xVector
[
vectorOffset
+
1
]
*
yVector
[
1
]
+
xVector
[
vectorOffset
+
2
]
*
yVector
[
2
];
...
@@ -202,9 +203,9 @@ RealOpenMM AmoebaReferenceForce::getDotProduct3(unsigned int vectorOffset, const
...
@@ -202,9 +203,9 @@ RealOpenMM AmoebaReferenceForce::getDotProduct3(unsigned int vectorOffset, const
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
AmoebaReferenceForce
::
getCrossProduct
(
const
std
::
vector
<
RealOpenMM
>&
xVector
,
void
AmoebaReferenceForce
::
getCrossProduct
(
const
std
::
vector
<
double
>&
xVector
,
const
std
::
vector
<
RealOpenMM
>&
yVector
,
const
std
::
vector
<
double
>&
yVector
,
std
::
vector
<
RealOpenMM
>&
zVector
)
{
std
::
vector
<
double
>&
zVector
)
{
zVector
[
0
]
=
xVector
[
1
]
*
yVector
[
2
]
-
xVector
[
2
]
*
yVector
[
1
];
zVector
[
0
]
=
xVector
[
1
]
*
yVector
[
2
]
-
xVector
[
2
]
*
yVector
[
1
];
zVector
[
1
]
=
xVector
[
2
]
*
yVector
[
0
]
-
xVector
[
0
]
*
yVector
[
2
];
zVector
[
1
]
=
xVector
[
2
]
*
yVector
[
0
]
-
xVector
[
0
]
*
yVector
[
2
];
zVector
[
2
]
=
xVector
[
0
]
*
yVector
[
1
]
-
xVector
[
1
]
*
yVector
[
0
];
zVector
[
2
]
=
xVector
[
0
]
*
yVector
[
1
]
-
xVector
[
1
]
*
yVector
[
0
];
...
@@ -220,9 +221,9 @@ void AmoebaReferenceForce::getCrossProduct(const std::vector<RealOpenMM>& xVecto
...
@@ -220,9 +221,9 @@ void AmoebaReferenceForce::getCrossProduct(const std::vector<RealOpenMM>& xVecto
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
AmoebaReferenceForce
::
getCrossProduct
(
const
RealOpenMM
*
xVector
,
void
AmoebaReferenceForce
::
getCrossProduct
(
const
double
*
xVector
,
const
RealOpenMM
*
yVector
,
const
double
*
yVector
,
RealOpenMM
*
zVector
)
{
double
*
zVector
)
{
zVector
[
0
]
=
xVector
[
1
]
*
yVector
[
2
]
-
xVector
[
2
]
*
yVector
[
1
];
zVector
[
0
]
=
xVector
[
1
]
*
yVector
[
2
]
-
xVector
[
2
]
*
yVector
[
1
];
zVector
[
1
]
=
xVector
[
2
]
*
yVector
[
0
]
-
xVector
[
0
]
*
yVector
[
2
];
zVector
[
1
]
=
xVector
[
2
]
*
yVector
[
0
]
-
xVector
[
0
]
*
yVector
[
2
];
zVector
[
2
]
=
xVector
[
0
]
*
yVector
[
1
]
-
xVector
[
1
]
*
yVector
[
0
];
zVector
[
2
]
=
xVector
[
0
]
*
yVector
[
1
]
-
xVector
[
1
]
*
yVector
[
0
];
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceForce.h
View file @
a783b996
...
@@ -25,7 +25,6 @@
...
@@ -25,7 +25,6 @@
#ifndef __AmoebaReferenceForce_H__
#ifndef __AmoebaReferenceForce_H__
#define __AmoebaReferenceForce_H__
#define __AmoebaReferenceForce_H__
#include "RealVec.h"
#include "openmm/Vec3.h"
#include "openmm/Vec3.h"
#include <vector>
#include <vector>
...
@@ -62,8 +61,8 @@ public:
...
@@ -62,8 +61,8 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
static
void
loadDeltaR
(
const
OpenMM
::
Real
Vec
&
xVector
,
const
OpenMM
::
Real
Vec
&
yVector
,
static
void
loadDeltaR
(
const
OpenMM
::
Vec
3
&
xVector
,
const
OpenMM
::
Vec
3
&
yVector
,
std
::
vector
<
RealOpenMM
>&
deltaR
);
std
::
vector
<
double
>&
deltaR
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Load delta of two vectors, applying periodic boundary conditions
Load delta of two vectors, applying periodic boundary conditions
...
@@ -75,7 +74,7 @@ public:
...
@@ -75,7 +74,7 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
static
void
loadDeltaRPeriodic
(
const
Real
Vec
&
xVector
,
const
Real
Vec
&
yVector
,
std
::
vector
<
RealOpenMM
>&
deltaR
,
const
Real
Vec
*
boxVectors
);
static
void
loadDeltaRPeriodic
(
const
Vec
3
&
xVector
,
const
Vec
3
&
yVector
,
std
::
vector
<
double
>&
deltaR
,
const
Vec
3
*
boxVectors
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -87,8 +86,8 @@ public:
...
@@ -87,8 +86,8 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
static
RealOpenMM
getNormSquared3
(
const
std
::
vector
<
RealOpenMM
>&
inputVector
);
static
double
getNormSquared3
(
const
std
::
vector
<
double
>&
inputVector
);
static
RealOpenMM
getNormSquared3
(
const
RealOpenMM
*
inputVector
);
static
double
getNormSquared3
(
const
double
*
inputVector
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -100,8 +99,8 @@ public:
...
@@ -100,8 +99,8 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
static
RealOpenMM
getNorm3
(
const
std
::
vector
<
RealOpenMM
>&
inputVector
);
static
double
getNorm3
(
const
std
::
vector
<
double
>&
inputVector
);
static
RealOpenMM
getNorm3
(
const
RealOpenMM
*
inputVector
);
static
double
getNorm3
(
const
double
*
inputVector
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -113,7 +112,7 @@ public:
...
@@ -113,7 +112,7 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
static
RealOpenMM
normalizeVector3
(
RealOpenMM
*
inputVector
);
static
double
normalizeVector3
(
double
*
inputVector
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -126,10 +125,10 @@ public:
...
@@ -126,10 +125,10 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
static
RealOpenMM
getDotProduct3
(
const
std
::
vector
<
RealOpenMM
>&
xVector
,
const
std
::
vector
<
RealOpenMM
>&
yVector
);
static
double
getDotProduct3
(
const
std
::
vector
<
double
>&
xVector
,
const
std
::
vector
<
double
>&
yVector
);
static
RealOpenMM
getDotProduct3
(
const
RealOpenMM
*
xVector
,
const
RealOpenMM
*
yVector
);
static
double
getDotProduct3
(
const
double
*
xVector
,
const
double
*
yVector
);
static
RealOpenMM
getDotProduct3
(
const
RealOpenMM
*
xVector
,
const
OpenMM
::
Vec3
&
yVector
);
static
double
getDotProduct3
(
const
double
*
xVector
,
const
OpenMM
::
Vec3
&
yVector
);
static
RealOpenMM
getDotProduct3
(
unsigned
int
vectorOffset
,
const
std
::
vector
<
RealOpenMM
>&
xVector
,
const
RealOpenMM
*
yVector
);
static
double
getDotProduct3
(
unsigned
int
vectorOffset
,
const
std
::
vector
<
double
>&
xVector
,
const
double
*
yVector
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -141,10 +140,10 @@ public:
...
@@ -141,10 +140,10 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
static
void
getCrossProduct
(
const
std
::
vector
<
RealOpenMM
>&
xVector
,
const
std
::
vector
<
RealOpenMM
>&
yVector
,
static
void
getCrossProduct
(
const
std
::
vector
<
double
>&
xVector
,
const
std
::
vector
<
double
>&
yVector
,
std
::
vector
<
RealOpenMM
>&
zVector
);
std
::
vector
<
double
>&
zVector
);
static
void
getCrossProduct
(
const
RealOpenMM
*
xVector
,
const
RealOpenMM
*
yVector
,
RealOpenMM
*
zVector
);
static
void
getCrossProduct
(
const
double
*
xVector
,
const
double
*
yVector
,
double
*
zVector
);
};
};
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceGeneralizedKirkwoodForce.cpp
View file @
a783b996
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
*/
*/
#include "AmoebaReferenceGeneralizedKirkwoodForce.h"
#include "AmoebaReferenceGeneralizedKirkwoodForce.h"
#include <cmath>
using
std
::
vector
;
using
std
::
vector
;
using
namespace
OpenMM
;
using
namespace
OpenMM
;
...
@@ -61,120 +62,113 @@ int AmoebaReferenceGeneralizedKirkwoodForce::getDirectPolarization() const {
...
@@ -61,120 +62,113 @@ int AmoebaReferenceGeneralizedKirkwoodForce::getDirectPolarization() const {
return
_directPolarization
;
return
_directPolarization
;
}
}
void
AmoebaReferenceGeneralizedKirkwoodForce
::
setSoluteDielectric
(
RealOpenMM
soluteDielectric
)
{
void
AmoebaReferenceGeneralizedKirkwoodForce
::
setSoluteDielectric
(
double
soluteDielectric
)
{
_soluteDielectric
=
soluteDielectric
;
_soluteDielectric
=
soluteDielectric
;
}
}
RealOpenMM
AmoebaReferenceGeneralizedKirkwoodForce
::
getSoluteDielectric
()
const
{
double
AmoebaReferenceGeneralizedKirkwoodForce
::
getSoluteDielectric
()
const
{
return
_soluteDielectric
;
return
_soluteDielectric
;
}
}
void
AmoebaReferenceGeneralizedKirkwoodForce
::
setSolventDielectric
(
RealOpenMM
solventDielectric
)
{
void
AmoebaReferenceGeneralizedKirkwoodForce
::
setSolventDielectric
(
double
solventDielectric
)
{
_solventDielectric
=
solventDielectric
;
_solventDielectric
=
solventDielectric
;
}
}
RealOpenMM
AmoebaReferenceGeneralizedKirkwoodForce
::
getSolventDielectric
()
const
{
double
AmoebaReferenceGeneralizedKirkwoodForce
::
getSolventDielectric
()
const
{
return
_solventDielectric
;
return
_solventDielectric
;
}
}
void
AmoebaReferenceGeneralizedKirkwoodForce
::
setDielectricOffset
(
RealOpenMM
dielectricOffset
)
{
void
AmoebaReferenceGeneralizedKirkwoodForce
::
setDielectricOffset
(
double
dielectricOffset
)
{
_dielectricOffset
=
dielectricOffset
;
_dielectricOffset
=
dielectricOffset
;
}
}
RealOpenMM
AmoebaReferenceGeneralizedKirkwoodForce
::
getDielectricOffset
()
const
{
double
AmoebaReferenceGeneralizedKirkwoodForce
::
getDielectricOffset
()
const
{
return
_dielectricOffset
;
return
_dielectricOffset
;
}
}
void
AmoebaReferenceGeneralizedKirkwoodForce
::
setProbeRadius
(
RealOpenMM
probeRadius
)
{
void
AmoebaReferenceGeneralizedKirkwoodForce
::
setProbeRadius
(
double
probeRadius
)
{
_probeRadius
=
probeRadius
;
_probeRadius
=
probeRadius
;
}
}
RealOpenMM
AmoebaReferenceGeneralizedKirkwoodForce
::
getProbeRadius
()
const
{
double
AmoebaReferenceGeneralizedKirkwoodForce
::
getProbeRadius
()
const
{
return
_probeRadius
;
return
_probeRadius
;
}
}
void
AmoebaReferenceGeneralizedKirkwoodForce
::
setSurfaceAreaFactor
(
RealOpenMM
surfaceAreaFactor
)
{
void
AmoebaReferenceGeneralizedKirkwoodForce
::
setSurfaceAreaFactor
(
double
surfaceAreaFactor
)
{
_surfaceAreaFactor
=
surfaceAreaFactor
;
_surfaceAreaFactor
=
surfaceAreaFactor
;
}
}
RealOpenMM
AmoebaReferenceGeneralizedKirkwoodForce
::
getSurfaceAreaFactor
()
const
{
double
AmoebaReferenceGeneralizedKirkwoodForce
::
getSurfaceAreaFactor
()
const
{
return
_surfaceAreaFactor
;
return
_surfaceAreaFactor
;
}
}
void
AmoebaReferenceGeneralizedKirkwoodForce
::
setAtomicRadii
(
const
vector
<
RealOpenMM
>&
atomicRadii
)
{
void
AmoebaReferenceGeneralizedKirkwoodForce
::
setAtomicRadii
(
const
vector
<
double
>&
atomicRadii
)
{
_atomicRadii
.
resize
(
atomicRadii
.
size
());
_atomicRadii
.
resize
(
atomicRadii
.
size
());
copy
(
atomicRadii
.
begin
(),
atomicRadii
.
end
(),
_atomicRadii
.
begin
());
copy
(
atomicRadii
.
begin
(),
atomicRadii
.
end
(),
_atomicRadii
.
begin
());
}
}
void
AmoebaReferenceGeneralizedKirkwoodForce
::
getAtomicRadii
(
vector
<
RealOpenMM
>&
atomicRadii
)
const
{
void
AmoebaReferenceGeneralizedKirkwoodForce
::
getAtomicRadii
(
vector
<
double
>&
atomicRadii
)
const
{
atomicRadii
.
resize
(
_atomicRadii
.
size
());
atomicRadii
.
resize
(
_atomicRadii
.
size
());
copy
(
_atomicRadii
.
begin
(),
_atomicRadii
.
end
(),
atomicRadii
.
begin
());
copy
(
_atomicRadii
.
begin
(),
_atomicRadii
.
end
(),
atomicRadii
.
begin
());
}
}
void
AmoebaReferenceGeneralizedKirkwoodForce
::
setScaleFactors
(
const
vector
<
RealOpenMM
>&
scaleFactors
)
{
void
AmoebaReferenceGeneralizedKirkwoodForce
::
setScaleFactors
(
const
vector
<
double
>&
scaleFactors
)
{
_scaleFactors
.
resize
(
scaleFactors
.
size
());
_scaleFactors
.
resize
(
scaleFactors
.
size
());
copy
(
scaleFactors
.
begin
(),
scaleFactors
.
end
(),
_scaleFactors
.
begin
());
copy
(
scaleFactors
.
begin
(),
scaleFactors
.
end
(),
_scaleFactors
.
begin
());
}
}
void
AmoebaReferenceGeneralizedKirkwoodForce
::
getScaleFactors
(
vector
<
RealOpenMM
>&
scaleFactors
)
const
{
void
AmoebaReferenceGeneralizedKirkwoodForce
::
getScaleFactors
(
vector
<
double
>&
scaleFactors
)
const
{
scaleFactors
.
resize
(
_scaleFactors
.
size
());
scaleFactors
.
resize
(
_scaleFactors
.
size
());
copy
(
_scaleFactors
.
begin
(),
_scaleFactors
.
end
(),
scaleFactors
.
begin
());
copy
(
_scaleFactors
.
begin
(),
_scaleFactors
.
end
(),
scaleFactors
.
begin
());
}
}
void
AmoebaReferenceGeneralizedKirkwoodForce
::
setCharges
(
const
vector
<
RealOpenMM
>&
charges
)
{
void
AmoebaReferenceGeneralizedKirkwoodForce
::
setCharges
(
const
vector
<
double
>&
charges
)
{
_charges
.
resize
(
charges
.
size
());
_charges
.
resize
(
charges
.
size
());
copy
(
charges
.
begin
(),
charges
.
end
(),
_charges
.
begin
());
copy
(
charges
.
begin
(),
charges
.
end
(),
_charges
.
begin
());
}
}
void
AmoebaReferenceGeneralizedKirkwoodForce
::
getGrycukBornRadii
(
vector
<
RealOpenMM
>&
bornRadii
)
const
{
void
AmoebaReferenceGeneralizedKirkwoodForce
::
getGrycukBornRadii
(
vector
<
double
>&
bornRadii
)
const
{
bornRadii
.
resize
(
_bornRadii
.
size
());
bornRadii
.
resize
(
_bornRadii
.
size
());
copy
(
_bornRadii
.
begin
(),
_bornRadii
.
end
(),
bornRadii
.
begin
());
copy
(
_bornRadii
.
begin
(),
_bornRadii
.
end
(),
bornRadii
.
begin
());
}
}
void
AmoebaReferenceGeneralizedKirkwoodForce
::
calculateGrycukBornRadii
(
const
vector
<
Real
Vec
>&
particlePositions
)
{
void
AmoebaReferenceGeneralizedKirkwoodForce
::
calculateGrycukBornRadii
(
const
vector
<
Vec
3
>&
particlePositions
)
{
const
RealOpenMM
zero
=
0.0
;
const
double
bigRadius
=
1000.0
;
const
RealOpenMM
one
=
1.0
;
const
RealOpenMM
three
=
3.0
;
const
RealOpenMM
six
=
6.0
;
const
RealOpenMM
eight
=
8.0
;
const
RealOpenMM
sixteen
=
16.0
;
const
RealOpenMM
oneThird
=
1.0
/
3.0
;
const
RealOpenMM
bigRadius
=
1000.0
;
_bornRadii
.
resize
(
_numParticles
);
_bornRadii
.
resize
(
_numParticles
);
for
(
unsigned
int
ii
=
0
;
ii
<
_numParticles
;
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
_numParticles
;
ii
++
)
{
if
(
_atomicRadii
[
ii
]
<=
zero
)
{
if
(
_atomicRadii
[
ii
]
<=
0.0
)
{
_bornRadii
[
ii
]
=
bigRadius
;
_bornRadii
[
ii
]
=
bigRadius
;
continue
;
continue
;
}
}
RealOpenMM
bornSum
=
zero
;
double
bornSum
=
0.0
;
for
(
unsigned
int
jj
=
0
;
jj
<
_numParticles
;
jj
++
)
{
for
(
unsigned
int
jj
=
0
;
jj
<
_numParticles
;
jj
++
)
{
if
(
ii
==
jj
||
_atomicRadii
[
jj
]
<
zero
)
continue
;
if
(
ii
==
jj
||
_atomicRadii
[
jj
]
<
0.0
)
continue
;
RealOpenMM
xr
=
particlePositions
[
jj
][
0
]
-
particlePositions
[
ii
][
0
];
double
xr
=
particlePositions
[
jj
][
0
]
-
particlePositions
[
ii
][
0
];
RealOpenMM
yr
=
particlePositions
[
jj
][
1
]
-
particlePositions
[
ii
][
1
];
double
yr
=
particlePositions
[
jj
][
1
]
-
particlePositions
[
ii
][
1
];
RealOpenMM
zr
=
particlePositions
[
jj
][
2
]
-
particlePositions
[
ii
][
2
];
double
zr
=
particlePositions
[
jj
][
2
]
-
particlePositions
[
ii
][
2
];
RealOpenMM
r2
=
xr
*
xr
+
yr
*
yr
+
zr
*
zr
;
double
r2
=
xr
*
xr
+
yr
*
yr
+
zr
*
zr
;
RealOpenMM
r
=
SQRT
(
r2
);
double
r
=
sqrt
(
r2
);
RealOpenMM
sk
=
_atomicRadii
[
jj
]
*
_scaleFactors
[
jj
];
double
sk
=
_atomicRadii
[
jj
]
*
_scaleFactors
[
jj
];
RealOpenMM
sk2
=
sk
*
sk
;
double
sk2
=
sk
*
sk
;
if
((
_atomicRadii
[
ii
]
+
r
)
<
sk
)
{
if
((
_atomicRadii
[
ii
]
+
r
)
<
sk
)
{
RealOpenMM
lik
=
_atomicRadii
[
ii
];
double
lik
=
_atomicRadii
[
ii
];
RealOpenMM
uik
=
sk
-
r
;
double
uik
=
sk
-
r
;
RealOpenMM
lik3
=
lik
*
lik
*
lik
;
double
lik3
=
lik
*
lik
*
lik
;
RealOpenMM
uik3
=
uik
*
uik
*
uik
;
double
uik3
=
uik
*
uik
*
uik
;
bornSum
-=
(
one
/
uik3
-
one
/
lik3
);
bornSum
-=
(
1.0
/
uik3
-
1.0
/
lik3
);
}
}
RealOpenMM
uik
=
r
+
sk
;
double
uik
=
r
+
sk
;
RealOpenMM
lik
;
double
lik
;
if
((
_atomicRadii
[
ii
]
+
r
)
<
sk
)
{
if
((
_atomicRadii
[
ii
]
+
r
)
<
sk
)
{
lik
=
sk
-
r
;
lik
=
sk
-
r
;
}
else
if
(
r
<
(
_atomicRadii
[
ii
]
+
sk
))
{
}
else
if
(
r
<
(
_atomicRadii
[
ii
]
+
sk
))
{
...
@@ -183,22 +177,22 @@ void AmoebaReferenceGeneralizedKirkwoodForce::calculateGrycukBornRadii(const vec
...
@@ -183,22 +177,22 @@ void AmoebaReferenceGeneralizedKirkwoodForce::calculateGrycukBornRadii(const vec
lik
=
r
-
sk
;
lik
=
r
-
sk
;
}
}
RealOpenMM
l2
=
lik
*
lik
;
double
l2
=
lik
*
lik
;
RealOpenMM
l4
=
l2
*
l2
;
double
l4
=
l2
*
l2
;
RealOpenMM
lr
=
lik
*
r
;
double
lr
=
lik
*
r
;
RealOpenMM
l4r
=
l4
*
r
;
double
l4r
=
l4
*
r
;
RealOpenMM
u2
=
uik
*
uik
;
double
u2
=
uik
*
uik
;
RealOpenMM
u4
=
u2
*
u2
;
double
u4
=
u2
*
u2
;
RealOpenMM
ur
=
uik
*
r
;
double
ur
=
uik
*
r
;
RealOpenMM
u4r
=
u4
*
r
;
double
u4r
=
u4
*
r
;
RealOpenMM
term
=
(
three
*
(
r2
-
sk2
)
+
six
*
u2
-
eight
*
ur
)
/
u4r
-
(
three
*
(
r2
-
sk2
)
+
six
*
l2
-
eight
*
lr
)
/
l4r
;
double
term
=
(
3.0
*
(
r2
-
sk2
)
+
6.0
*
u2
-
8.0
*
ur
)
/
u4r
-
(
3.0
*
(
r2
-
sk2
)
+
6.0
*
l2
-
8.0
*
lr
)
/
l4r
;
bornSum
+=
term
/
sixteen
;
bornSum
+=
term
/
16.0
;
}
}
bornSum
=
one
/
(
_atomicRadii
[
ii
]
*
_atomicRadii
[
ii
]
*
_atomicRadii
[
ii
])
-
bornSum
;
bornSum
=
1.0
/
(
_atomicRadii
[
ii
]
*
_atomicRadii
[
ii
]
*
_atomicRadii
[
ii
])
-
bornSum
;
_bornRadii
[
ii
]
=
(
bornSum
<=
zero
)
?
bigRadius
:
POW
(
bornSum
,
-
oneThird
);
_bornRadii
[
ii
]
=
(
bornSum
<=
0.0
)
?
bigRadius
:
pow
(
bornSum
,
-
1.0
/
3.0
);
}
}
return
;
return
;
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceGeneralizedKirkwoodForce.h
View file @
a783b996
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceGeneralizedKirkwoodForce_H__
#ifndef __AmoebaReferenceGeneralizedKirkwoodForce_H__
#define __AmoebaReferenceGeneralizedKirkwoodForce_H__
#define __AmoebaReferenceGeneralizedKirkwoodForce_H__
#include "
Real
Vec.h"
#include "
openmm/
Vec
3
.h"
#include <vector>
#include <vector>
using
namespace
OpenMM
;
using
namespace
OpenMM
;
...
@@ -101,7 +101,7 @@ public:
...
@@ -101,7 +101,7 @@ public:
*
*
* @return soluteDielectric
* @return soluteDielectric
*/
*/
RealOpenMM
getSoluteDielectric
()
const
;
double
getSoluteDielectric
()
const
;
/**
/**
* Set solute dielectric
* Set solute dielectric
...
@@ -109,7 +109,7 @@ public:
...
@@ -109,7 +109,7 @@ public:
* @param soluteDielectric solute dielectric
* @param soluteDielectric solute dielectric
*
*
*/
*/
void
setSoluteDielectric
(
RealOpenMM
soluteDielectric
);
void
setSoluteDielectric
(
double
soluteDielectric
);
/**
/**
* Get solvent dielectric
* Get solvent dielectric
...
@@ -117,7 +117,7 @@ public:
...
@@ -117,7 +117,7 @@ public:
* @return solventDielectric
* @return solventDielectric
*
*
*/
*/
RealOpenMM
getSolventDielectric
()
const
;
double
getSolventDielectric
()
const
;
/**
/**
* Set solvent dielectric
* Set solvent dielectric
...
@@ -125,7 +125,7 @@ public:
...
@@ -125,7 +125,7 @@ public:
* @param solventDielectric solvent dielectric
* @param solventDielectric solvent dielectric
*
*
*/
*/
void
setSolventDielectric
(
RealOpenMM
solventDielectric
);
void
setSolventDielectric
(
double
solventDielectric
);
/**
/**
* Get dielectric offset
* Get dielectric offset
...
@@ -133,7 +133,7 @@ public:
...
@@ -133,7 +133,7 @@ public:
* @return dielectricOffset
* @return dielectricOffset
*
*
*/
*/
RealOpenMM
getDielectricOffset
()
const
;
double
getDielectricOffset
()
const
;
/**
/**
* Set dielectric offset
* Set dielectric offset
...
@@ -141,7 +141,7 @@ public:
...
@@ -141,7 +141,7 @@ public:
* @param dielectricOffset dielectric offset
* @param dielectricOffset dielectric offset
*
*
*/
*/
void
setDielectricOffset
(
RealOpenMM
dielectricOffset
);
void
setDielectricOffset
(
double
dielectricOffset
);
/**
/**
* Get probeRadius
* Get probeRadius
...
@@ -149,7 +149,7 @@ public:
...
@@ -149,7 +149,7 @@ public:
* @return probeRadius
* @return probeRadius
*
*
*/
*/
RealOpenMM
getProbeRadius
()
const
;
double
getProbeRadius
()
const
;
/**
/**
* Set probe radius
* Set probe radius
...
@@ -157,7 +157,7 @@ public:
...
@@ -157,7 +157,7 @@ public:
* @param probeRadius probe radiue
* @param probeRadius probe radiue
*
*
*/
*/
void
setProbeRadius
(
RealOpenMM
probeRadius
);
void
setProbeRadius
(
double
probeRadius
);
/**
/**
* Get surfaceAreaFactor
* Get surfaceAreaFactor
...
@@ -165,7 +165,7 @@ public:
...
@@ -165,7 +165,7 @@ public:
* @return surfaceAreaFactor
* @return surfaceAreaFactor
*
*
*/
*/
RealOpenMM
getSurfaceAreaFactor
()
const
;
double
getSurfaceAreaFactor
()
const
;
/**
/**
* Set surface area factor
* Set surface area factor
...
@@ -173,7 +173,7 @@ public:
...
@@ -173,7 +173,7 @@ public:
* @param surfaceAreaFactor surface area factor
* @param surfaceAreaFactor surface area factor
*
*
*/
*/
void
setSurfaceAreaFactor
(
RealOpenMM
surfaceAreaFactor
);
void
setSurfaceAreaFactor
(
double
surfaceAreaFactor
);
/**
/**
* Set atomic radii
* Set atomic radii
...
@@ -181,7 +181,7 @@ public:
...
@@ -181,7 +181,7 @@ public:
* @param atomicRadii input vector of atomic radii
* @param atomicRadii input vector of atomic radii
*
*
*/
*/
void
setAtomicRadii
(
const
vector
<
RealOpenMM
>&
atomicRadii
);
void
setAtomicRadii
(
const
vector
<
double
>&
atomicRadii
);
/**
/**
* Get atomic radii
* Get atomic radii
...
@@ -189,7 +189,7 @@ public:
...
@@ -189,7 +189,7 @@ public:
* @param atomicRadii output vector of atomic radii
* @param atomicRadii output vector of atomic radii
*
*
*/
*/
void
getAtomicRadii
(
vector
<
RealOpenMM
>&
atomicRadii
)
const
;
void
getAtomicRadii
(
vector
<
double
>&
atomicRadii
)
const
;
/**
/**
* Set scale factors
* Set scale factors
...
@@ -197,7 +197,7 @@ public:
...
@@ -197,7 +197,7 @@ public:
* @param scaleFactors input vector of scale factors
* @param scaleFactors input vector of scale factors
*
*
*/
*/
void
setScaleFactors
(
const
vector
<
RealOpenMM
>&
scaleFactors
);
void
setScaleFactors
(
const
vector
<
double
>&
scaleFactors
);
/**
/**
* Get scale factors
* Get scale factors
...
@@ -205,7 +205,7 @@ public:
...
@@ -205,7 +205,7 @@ public:
* @param scaleFactors output vector of scale factors
* @param scaleFactors output vector of scale factors
*
*
*/
*/
void
getScaleFactors
(
vector
<
RealOpenMM
>&
scaleFactors
)
const
;
void
getScaleFactors
(
vector
<
double
>&
scaleFactors
)
const
;
/**
/**
* Set charges
* Set charges
...
@@ -213,7 +213,7 @@ public:
...
@@ -213,7 +213,7 @@ public:
* @param charges input vector of charges
* @param charges input vector of charges
*
*
*/
*/
void
setCharges
(
const
vector
<
RealOpenMM
>&
charges
);
void
setCharges
(
const
vector
<
double
>&
charges
);
/**
/**
* Calculate Grycuk Born radii
* Calculate Grycuk Born radii
...
@@ -221,7 +221,7 @@ public:
...
@@ -221,7 +221,7 @@ public:
* @param particlePositions particle positions
* @param particlePositions particle positions
*
*
*/
*/
void
calculateGrycukBornRadii
(
const
vector
<
Real
Vec
>&
particlePositions
);
void
calculateGrycukBornRadii
(
const
vector
<
Vec
3
>&
particlePositions
);
/**
/**
* Get Grycik Born radii (must have called calculateGrycukBornRadii())
* Get Grycik Born radii (must have called calculateGrycukBornRadii())
...
@@ -229,7 +229,7 @@ public:
...
@@ -229,7 +229,7 @@ public:
* @param bornRadii vector of Born radii
* @param bornRadii vector of Born radii
*
*
*/
*/
void
getGrycukBornRadii
(
vector
<
RealOpenMM
>&
bornRadii
)
const
;
void
getGrycukBornRadii
(
vector
<
double
>&
bornRadii
)
const
;
private:
private:
...
@@ -237,17 +237,17 @@ private:
...
@@ -237,17 +237,17 @@ private:
int
_includeCavityTerm
;
int
_includeCavityTerm
;
int
_directPolarization
;
int
_directPolarization
;
RealOpenMM
_soluteDielectric
;
double
_soluteDielectric
;
RealOpenMM
_solventDielectric
;
double
_solventDielectric
;
RealOpenMM
_dielectricOffset
;
double
_dielectricOffset
;
RealOpenMM
_probeRadius
;
double
_probeRadius
;
RealOpenMM
_surfaceAreaFactor
;
double
_surfaceAreaFactor
;
std
::
vector
<
RealOpenMM
>
_atomicRadii
;
std
::
vector
<
double
>
_atomicRadii
;
std
::
vector
<
RealOpenMM
>
_scaleFactors
;
std
::
vector
<
double
>
_scaleFactors
;
std
::
vector
<
RealOpenMM
>
_charges
;
std
::
vector
<
double
>
_charges
;
std
::
vector
<
RealOpenMM
>
_bornRadii
;
std
::
vector
<
double
>
_bornRadii
;
};
};
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceInPlaneAngleForce.cpp
View file @
a783b996
...
@@ -25,11 +25,12 @@
...
@@ -25,11 +25,12 @@
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceInPlaneAngleForce.h"
#include "AmoebaReferenceInPlaneAngleForce.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
#include "SimTKOpenMMRealType.h"
using
std
::
vector
;
using
std
::
vector
;
using
namespace
OpenMM
;
using
namespace
OpenMM
;
void
AmoebaReferenceInPlaneAngleForce
::
setPeriodic
(
OpenMM
::
Real
Vec
*
vectors
)
{
void
AmoebaReferenceInPlaneAngleForce
::
setPeriodic
(
OpenMM
::
Vec
3
*
vectors
)
{
usePeriodic
=
true
;
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
1
]
=
vectors
[
1
];
...
@@ -54,49 +55,34 @@ void AmoebaReferenceInPlaneAngleForce::setPeriodic(OpenMM::RealVec* vectors) {
...
@@ -54,49 +55,34 @@ void AmoebaReferenceInPlaneAngleForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
AmoebaReferenceInPlaneAngleForce
::
getPrefactorsGivenAngleCosine
(
RealOpenMM
cosine
,
double
AmoebaReferenceInPlaneAngleForce
::
getPrefactorsGivenAngleCosine
(
double
cosine
,
RealOpenMM
idealAngle
,
RealOpenMM
angleK
,
double
idealAngle
,
double
angleK
,
RealOpenMM
angleCubic
,
RealOpenMM
angleQuartic
,
double
angleCubic
,
double
angleQuartic
,
RealOpenMM
anglePentic
,
RealOpenMM
angleSextic
,
double
anglePentic
,
double
angleSextic
,
RealOpenMM
*
dEdR
)
const
{
double
*
dEdR
)
const
{
double
angle
;
// ---------------------------------------------------------------------------------------
if
(
cosine
>=
1.0
)
{
angle
=
0.0
;
static
const
RealOpenMM
zero
=
0.0
;
}
else
if
(
cosine
<=
-
1.0
)
{
static
const
RealOpenMM
one
=
1.0
;
static
const
RealOpenMM
two
=
2.0
;
static
const
RealOpenMM
three
=
3.0
;
static
const
RealOpenMM
four
=
4.0
;
static
const
RealOpenMM
five
=
5.0
;
static
const
RealOpenMM
six
=
6.0
;
// static const std::string methodName = "AmoebaReferenceInPlaneAngleForce::getPrefactorsGivenAngleCosine";
// ---------------------------------------------------------------------------------------
RealOpenMM
angle
;
if
(
cosine
>=
one
)
{
angle
=
zero
;
}
else
if
(
cosine
<=
-
one
)
{
angle
=
RADIAN
*
PI_M
;
angle
=
RADIAN
*
PI_M
;
}
else
{
}
else
{
angle
=
RADIAN
*
ACOS
(
cosine
);
angle
=
RADIAN
*
ACOS
(
cosine
);
}
}
RealOpenMM
deltaIdeal
=
angle
-
idealAngle
;
double
deltaIdeal
=
angle
-
idealAngle
;
RealOpenMM
deltaIdeal2
=
deltaIdeal
*
deltaIdeal
;
double
deltaIdeal2
=
deltaIdeal
*
deltaIdeal
;
RealOpenMM
deltaIdeal3
=
deltaIdeal
*
deltaIdeal2
;
double
deltaIdeal3
=
deltaIdeal
*
deltaIdeal2
;
RealOpenMM
deltaIdeal4
=
deltaIdeal2
*
deltaIdeal2
;
double
deltaIdeal4
=
deltaIdeal2
*
deltaIdeal2
;
*
dEdR
=
(
two
+
three
*
angleCubic
*
deltaIdeal
+
*
dEdR
=
(
2.0
+
3.0
*
angleCubic
*
deltaIdeal
+
four
*
angleQuartic
*
deltaIdeal2
+
4.0
*
angleQuartic
*
deltaIdeal2
+
five
*
anglePentic
*
deltaIdeal3
+
5.0
*
anglePentic
*
deltaIdeal3
+
six
*
angleSextic
*
deltaIdeal4
);
6.0
*
angleSextic
*
deltaIdeal4
);
*
dEdR
*=
RADIAN
*
angleK
*
deltaIdeal
;
*
dEdR
*=
RADIAN
*
angleK
*
deltaIdeal
;
RealOpenMM
energy
=
1.0
f
+
angleCubic
*
deltaIdeal
+
angleQuartic
*
deltaIdeal2
+
double
energy
=
1.0
f
+
angleCubic
*
deltaIdeal
+
angleQuartic
*
deltaIdeal2
+
anglePentic
*
deltaIdeal3
+
angleSextic
*
deltaIdeal4
;
anglePentic
*
deltaIdeal3
+
angleSextic
*
deltaIdeal4
;
energy
*=
angleK
*
deltaIdeal2
;
energy
*=
angleK
*
deltaIdeal2
;
return
energy
;
return
energy
;
...
@@ -122,12 +108,12 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::getPrefactorsGivenAngleCosine(RealO
...
@@ -122,12 +108,12 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::getPrefactorsGivenAngleCosine(RealO
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
AmoebaReferenceInPlaneAngleForce
::
calculateAngleIxn
(
const
Real
Vec
&
positionAtomA
,
const
Real
Vec
&
positionAtomB
,
double
AmoebaReferenceInPlaneAngleForce
::
calculateAngleIxn
(
const
Vec
3
&
positionAtomA
,
const
Vec
3
&
positionAtomB
,
const
Real
Vec
&
positionAtomC
,
const
Real
Vec
&
positionAtomD
,
const
Vec
3
&
positionAtomC
,
const
Vec
3
&
positionAtomD
,
RealOpenMM
angle
,
RealOpenMM
angleK
,
double
angle
,
double
angleK
,
RealOpenMM
angleCubic
,
RealOpenMM
angleQuartic
,
double
angleCubic
,
double
angleQuartic
,
RealOpenMM
anglePentic
,
RealOpenMM
angleSextic
,
double
anglePentic
,
double
angleSextic
,
Real
Vec
*
forces
)
const
{
Vec
3
*
forces
)
const
{
// T = AD x CD
// T = AD x CD
// P = B + T*delta
// P = B + T*delta
// AP = A - P
// AP = A - P
...
@@ -136,7 +122,7 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
...
@@ -136,7 +122,7 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
enum
{
AD
,
BD
,
CD
,
T
,
AP
,
P
,
CP
,
M
,
APxM
,
CPxM
,
ADxBD
,
BDxCD
,
TxCD
,
ADxT
,
dBxAD
,
CDxdB
,
LastDeltaAtomIndex
};
enum
{
AD
,
BD
,
CD
,
T
,
AP
,
P
,
CP
,
M
,
APxM
,
CPxM
,
ADxBD
,
BDxCD
,
TxCD
,
ADxT
,
dBxAD
,
CDxdB
,
LastDeltaAtomIndex
};
Real
Vec
deltaR
[
LastDeltaAtomIndex
];
Vec
3
deltaR
[
LastDeltaAtomIndex
];
if
(
usePeriodic
)
{
if
(
usePeriodic
)
{
deltaR
[
AD
]
=
ReferenceForce
::
getDeltaRPeriodic
(
positionAtomD
,
positionAtomA
,
boxVectors
);
deltaR
[
AD
]
=
ReferenceForce
::
getDeltaRPeriodic
(
positionAtomD
,
positionAtomA
,
boxVectors
);
deltaR
[
BD
]
=
ReferenceForce
::
getDeltaRPeriodic
(
positionAtomD
,
positionAtomB
,
boxVectors
);
deltaR
[
BD
]
=
ReferenceForce
::
getDeltaRPeriodic
(
positionAtomD
,
positionAtomB
,
boxVectors
);
...
@@ -150,9 +136,8 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
...
@@ -150,9 +136,8 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
deltaR
[
T
]
=
deltaR
[
AD
].
cross
(
deltaR
[
CD
]);
deltaR
[
T
]
=
deltaR
[
AD
].
cross
(
deltaR
[
CD
]);
RealOpenMM
rT2
=
deltaR
[
T
].
dot
(
deltaR
[
T
]);
double
rT2
=
deltaR
[
T
].
dot
(
deltaR
[
T
]);
RealOpenMM
delta
=
deltaR
[
T
].
dot
(
deltaR
[
BD
])
/
rT2
;
double
delta
=
-
deltaR
[
T
].
dot
(
deltaR
[
BD
])
/
rT2
;
delta
*=
-
1
;
deltaR
[
P
]
=
positionAtomB
+
deltaR
[
T
]
*
delta
;
deltaR
[
P
]
=
positionAtomB
+
deltaR
[
T
]
*
delta
;
if
(
usePeriodic
)
{
if
(
usePeriodic
)
{
...
@@ -164,28 +149,28 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
...
@@ -164,28 +149,28 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
deltaR
[
CP
]
=
ReferenceForce
::
getDeltaR
(
deltaR
[
P
],
positionAtomC
);
deltaR
[
CP
]
=
ReferenceForce
::
getDeltaR
(
deltaR
[
P
],
positionAtomC
);
}
}
RealOpenMM
rAp2
=
deltaR
[
AP
].
dot
(
deltaR
[
AP
]);
double
rAp2
=
deltaR
[
AP
].
dot
(
deltaR
[
AP
]);
RealOpenMM
rCp2
=
deltaR
[
CP
].
dot
(
deltaR
[
CP
]);
double
rCp2
=
deltaR
[
CP
].
dot
(
deltaR
[
CP
]);
if
(
rAp2
<=
0
&&
rCp2
<=
0
)
{
if
(
rAp2
<=
0
&&
rCp2
<=
0
)
{
return
0
;
return
0
;
}
}
deltaR
[
M
]
=
deltaR
[
CP
].
cross
(
deltaR
[
AP
]);
deltaR
[
M
]
=
deltaR
[
CP
].
cross
(
deltaR
[
AP
]);
RealOpenMM
rm
=
SQRT
(
deltaR
[
M
].
dot
(
deltaR
[
M
]));
double
rm
=
sqrt
(
deltaR
[
M
].
dot
(
deltaR
[
M
]));
if
(
rm
<
1.0e-06
)
{
if
(
rm
<
1.0e-06
)
{
rm
=
1.0e-06
;
rm
=
1.0e-06
;
}
}
RealOpenMM
dot
=
deltaR
[
AP
].
dot
(
deltaR
[
CP
]);
double
dot
=
deltaR
[
AP
].
dot
(
deltaR
[
CP
]);
RealOpenMM
cosine
=
dot
/
SQRT
(
rAp2
*
rCp2
);
double
cosine
=
dot
/
SQRT
(
rAp2
*
rCp2
);
RealOpenMM
dEdR
;
double
dEdR
;
RealOpenMM
energy
=
getPrefactorsGivenAngleCosine
(
cosine
,
angle
,
angleK
,
angleCubic
,
angleQuartic
,
double
energy
=
getPrefactorsGivenAngleCosine
(
cosine
,
angle
,
angleK
,
angleCubic
,
angleQuartic
,
anglePentic
,
angleSextic
,
&
dEdR
);
anglePentic
,
angleSextic
,
&
dEdR
);
RealOpenMM
termA
=
-
dEdR
/
(
rAp2
*
rm
);
double
termA
=
-
dEdR
/
(
rAp2
*
rm
);
RealOpenMM
termC
=
dEdR
/
(
rCp2
*
rm
);
double
termC
=
dEdR
/
(
rCp2
*
rm
);
deltaR
[
APxM
]
=
deltaR
[
AP
].
cross
(
deltaR
[
M
]);
deltaR
[
APxM
]
=
deltaR
[
AP
].
cross
(
deltaR
[
M
]);
deltaR
[
CPxM
]
=
deltaR
[
CP
].
cross
(
deltaR
[
M
]);
deltaR
[
CPxM
]
=
deltaR
[
CP
].
cross
(
deltaR
[
M
]);
...
@@ -193,27 +178,27 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
...
@@ -193,27 +178,27 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
// forces will be gathered here
// forces will be gathered here
enum
{
dA
,
dB
,
dC
,
dD
,
LastDIndex
};
enum
{
dA
,
dB
,
dC
,
dD
,
LastDIndex
};
Real
Vec
forceTerm
[
LastDIndex
];
Vec
3
forceTerm
[
LastDIndex
];
forceTerm
[
dA
]
=
deltaR
[
APxM
]
*
termA
;
forceTerm
[
dA
]
=
deltaR
[
APxM
]
*
termA
;
forceTerm
[
dC
]
=
deltaR
[
CPxM
]
*
termC
;
forceTerm
[
dC
]
=
deltaR
[
CPxM
]
*
termC
;
forceTerm
[
dB
]
=
-
(
forceTerm
[
dA
]
+
forceTerm
[
dC
]);
forceTerm
[
dB
]
=
-
(
forceTerm
[
dA
]
+
forceTerm
[
dC
]);
RealOpenMM
pTrT2
=
forceTerm
[
dB
].
dot
(
deltaR
[
T
]);
double
pTrT2
=
forceTerm
[
dB
].
dot
(
deltaR
[
T
]);
pTrT2
/=
rT2
;
pTrT2
/=
rT2
;
deltaR
[
CDxdB
]
=
deltaR
[
CD
].
cross
(
forceTerm
[
dB
]);
deltaR
[
CDxdB
]
=
deltaR
[
CD
].
cross
(
forceTerm
[
dB
]);
deltaR
[
dBxAD
]
=
forceTerm
[
dB
].
cross
(
deltaR
[
AD
]);
deltaR
[
dBxAD
]
=
forceTerm
[
dB
].
cross
(
deltaR
[
AD
]);
if
(
FABS
(
pTrT2
)
>
1.0e-08
)
{
if
(
FABS
(
pTrT2
)
>
1.0e-08
)
{
RealOpenMM
delta2
=
delta
*
2
;
double
delta2
=
delta
*
2
;
deltaR
[
BDxCD
]
=
forceTerm
[
dB
].
cross
(
deltaR
[
CD
]);
deltaR
[
BDxCD
]
=
forceTerm
[
dB
].
cross
(
deltaR
[
CD
]);
deltaR
[
TxCD
]
=
forceTerm
[
T
].
cross
(
deltaR
[
CD
]);
deltaR
[
TxCD
]
=
forceTerm
[
T
].
cross
(
deltaR
[
CD
]);
deltaR
[
ADxBD
]
=
forceTerm
[
AD
].
cross
(
deltaR
[
BD
]);
deltaR
[
ADxBD
]
=
forceTerm
[
AD
].
cross
(
deltaR
[
BD
]);
deltaR
[
ADxT
]
=
forceTerm
[
AD
].
cross
(
deltaR
[
T
]);
deltaR
[
ADxT
]
=
forceTerm
[
AD
].
cross
(
deltaR
[
T
]);
Real
Vec
term
=
deltaR
[
BDxCD
]
+
deltaR
[
TxCD
]
*
delta2
;
Vec
3
term
=
deltaR
[
BDxCD
]
+
deltaR
[
TxCD
]
*
delta2
;
forceTerm
[
dA
]
+=
deltaR
[
CDxdB
]
*
delta
+
term
*
pTrT2
;
forceTerm
[
dA
]
+=
deltaR
[
CDxdB
]
*
delta
+
term
*
pTrT2
;
term
=
deltaR
[
ADxBD
]
+
deltaR
[
ADxT
]
*
delta2
;
term
=
deltaR
[
ADxBD
]
+
deltaR
[
ADxT
]
*
delta2
;
forceTerm
[
dC
]
+=
deltaR
[
dBxAD
]
*
delta
+
term
*
pTrT2
;
forceTerm
[
dC
]
+=
deltaR
[
dBxAD
]
*
delta
+
term
*
pTrT2
;
...
@@ -233,29 +218,29 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
...
@@ -233,29 +218,29 @@ RealOpenMM AmoebaReferenceInPlaneAngleForce::calculateAngleIxn(const RealVec& po
}
}
RealOpenMM
AmoebaReferenceInPlaneAngleForce
::
calculateForceAndEnergy
(
int
numAngles
,
vector
<
Real
Vec
>&
posData
,
double
AmoebaReferenceInPlaneAngleForce
::
calculateForceAndEnergy
(
int
numAngles
,
vector
<
Vec
3
>&
posData
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle4
,
const
std
::
vector
<
int
>&
particle4
,
const
std
::
vector
<
RealOpenMM
>&
angle
,
const
std
::
vector
<
double
>&
angle
,
const
std
::
vector
<
RealOpenMM
>&
kQuadratic
,
const
std
::
vector
<
double
>&
kQuadratic
,
RealOpenMM
angleCubic
,
double
angleCubic
,
RealOpenMM
angleQuartic
,
double
angleQuartic
,
RealOpenMM
anglePentic
,
double
anglePentic
,
RealOpenMM
angleSextic
,
double
angleSextic
,
vector
<
Real
Vec
>&
forceData
)
const
{
vector
<
Vec
3
>&
forceData
)
const
{
RealOpenMM
energy
=
0.0
;
double
energy
=
0.0
;
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
numAngles
);
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
numAngles
);
ii
++
)
{
int
particle1Index
=
particle1
[
ii
];
int
particle1Index
=
particle1
[
ii
];
int
particle2Index
=
particle2
[
ii
];
int
particle2Index
=
particle2
[
ii
];
int
particle3Index
=
particle3
[
ii
];
int
particle3Index
=
particle3
[
ii
];
int
particle4Index
=
particle4
[
ii
];
int
particle4Index
=
particle4
[
ii
];
RealOpenMM
idealAngle
=
angle
[
ii
];
double
idealAngle
=
angle
[
ii
];
RealOpenMM
angleK
=
kQuadratic
[
ii
];
double
angleK
=
kQuadratic
[
ii
];
Real
Vec
forces
[
4
];
Vec
3
forces
[
4
];
energy
+=
calculateAngleIxn
(
posData
[
particle1Index
],
posData
[
particle2Index
],
posData
[
particle3Index
],
posData
[
particle4Index
],
energy
+=
calculateAngleIxn
(
posData
[
particle1Index
],
posData
[
particle2Index
],
posData
[
particle3Index
],
posData
[
particle4Index
],
idealAngle
,
angleK
,
angleCubic
,
angleQuartic
,
anglePentic
,
angleSextic
,
forces
);
idealAngle
,
angleK
,
angleCubic
,
angleQuartic
,
anglePentic
,
angleSextic
,
forces
);
// accumulate forces
// accumulate forces
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceInPlaneAngleForce.h
View file @
a783b996
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceInPlaneAngleForce_H__
#ifndef __AmoebaReferenceInPlaneAngleForce_H__
#define __AmoebaReferenceInPlaneAngleForce_H__
#define __AmoebaReferenceInPlaneAngleForce_H__
#include "
Real
Vec.h"
#include "
openmm/
Vec
3
.h"
#include <vector>
#include <vector>
namespace
OpenMM
{
namespace
OpenMM
{
...
@@ -58,7 +58,7 @@ public:
...
@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
Real
Vec
*
vectors
);
void
setPeriodic
(
OpenMM
::
Vec
3
*
vectors
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -83,23 +83,23 @@ public:
...
@@ -83,23 +83,23 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
calculateForceAndEnergy
(
int
numAngles
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
posData
,
double
calculateForceAndEnergy
(
int
numAngles
,
std
::
vector
<
OpenMM
::
Vec
3
>&
posData
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle4
,
const
std
::
vector
<
int
>&
particle4
,
const
std
::
vector
<
RealOpenMM
>&
angle
,
const
std
::
vector
<
double
>&
angle
,
const
std
::
vector
<
RealOpenMM
>&
kQuadratic
,
const
std
::
vector
<
double
>&
kQuadratic
,
RealOpenMM
globalAngleCubic
,
double
globalAngleCubic
,
RealOpenMM
globalAngleQuartic
,
double
globalAngleQuartic
,
RealOpenMM
globalAnglePentic
,
double
globalAnglePentic
,
RealOpenMM
globalAngleSextic
,
double
globalAngleSextic
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forceData
)
const
;
std
::
vector
<
OpenMM
::
Vec
3
>&
forceData
)
const
;
private:
private:
bool
usePeriodic
;
bool
usePeriodic
;
Real
Vec
boxVectors
[
3
];
Vec
3
boxVectors
[
3
];
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -119,11 +119,11 @@ private:
...
@@ -119,11 +119,11 @@ private:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
getPrefactorsGivenAngleCosine
(
RealOpenMM
cosine
,
RealOpenMM
idealAngle
,
RealOpenMM
angleK
,
double
getPrefactorsGivenAngleCosine
(
double
cosine
,
double
idealAngle
,
double
angleK
,
RealOpenMM
angleCubic
,
RealOpenMM
angleQuartic
,
double
angleCubic
,
double
angleQuartic
,
RealOpenMM
anglePentic
,
RealOpenMM
angleSextic
,
double
anglePentic
,
double
angleSextic
,
RealOpenMM
*
dEdR
)
const
;
double
*
dEdR
)
const
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Calculate Amoeba angle ixn (force and energy)
Calculate Amoeba angle ixn (force and energy)
...
@@ -144,12 +144,12 @@ private:
...
@@ -144,12 +144,12 @@ private:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
calculateAngleIxn
(
const
OpenMM
::
Real
Vec
&
positionAtomA
,
const
OpenMM
::
Real
Vec
&
positionAtomB
,
double
calculateAngleIxn
(
const
OpenMM
::
Vec
3
&
positionAtomA
,
const
OpenMM
::
Vec
3
&
positionAtomB
,
const
OpenMM
::
Real
Vec
&
positionAtomC
,
const
OpenMM
::
Real
Vec
&
positionAtomD
,
const
OpenMM
::
Vec
3
&
positionAtomC
,
const
OpenMM
::
Vec
3
&
positionAtomD
,
RealOpenMM
angle
,
RealOpenMM
angleK
,
double
angle
,
double
angleK
,
RealOpenMM
angleCubic
,
RealOpenMM
angleQuartic
,
double
angleCubic
,
double
angleQuartic
,
RealOpenMM
anglePentic
,
RealOpenMM
angleSextic
,
double
anglePentic
,
double
angleSextic
,
OpenMM
::
Real
Vec
*
forces
)
const
;
OpenMM
::
Vec
3
*
forces
)
const
;
};
};
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceMultipoleForce.cpp
View file @
a783b996
This source diff could not be displayed because it is too large. You can
view the blob
instead.
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceMultipoleForce.h
View file @
a783b996
...
@@ -24,8 +24,8 @@
...
@@ -24,8 +24,8 @@
#ifndef __AmoebaReferenceMultipoleForce_H__
#ifndef __AmoebaReferenceMultipoleForce_H__
#define __AmoebaReferenceMultipoleForce_H__
#define __AmoebaReferenceMultipoleForce_H__
#include "RealVec.h"
#include "openmm/AmoebaMultipoleForce.h"
#include "openmm/AmoebaMultipoleForce.h"
#include "openmm/Vec3.h"
#include "AmoebaReferenceGeneralizedKirkwoodForce.h"
#include "AmoebaReferenceGeneralizedKirkwoodForce.h"
#include <map>
#include <map>
#include "fftpack.h"
#include "fftpack.h"
...
@@ -33,22 +33,22 @@
...
@@ -33,22 +33,22 @@
namespace
OpenMM
{
namespace
OpenMM
{
typedef
std
::
map
<
unsigned
int
,
RealOpenMM
>
MapIntRealOpenMM
;
typedef
std
::
map
<
unsigned
int
,
double
>
MapIntRealOpenMM
;
typedef
MapIntRealOpenMM
::
iterator
MapIntRealOpenMMI
;
typedef
MapIntRealOpenMM
::
iterator
MapIntRealOpenMMI
;
typedef
MapIntRealOpenMM
::
const_iterator
MapIntRealOpenMMCI
;
typedef
MapIntRealOpenMM
::
const_iterator
MapIntRealOpenMMCI
;
// A few useful constants for the spherical harmonic multipole code.
// A few useful constants for the spherical harmonic multipole code.
const
RealOpenMM
oneThird
=
1.0
/
3.0
;
const
double
oneThird
=
1.0
/
3.0
;
const
RealOpenMM
twoThirds
=
2.0
/
3.0
;
const
double
twoThirds
=
2.0
/
3.0
;
const
RealOpenMM
fourThirds
=
4.0
/
3.0
;
const
double
fourThirds
=
4.0
/
3.0
;
const
RealOpenMM
fourSqrtOneThird
=
4.0
/
sqrt
(
3.0
);
const
double
fourSqrtOneThird
=
4.0
/
sqrt
(
3.0
);
const
RealOpenMM
sqrtFourThirds
=
2.0
/
sqrt
(
3.0
);
const
double
sqrtFourThirds
=
2.0
/
sqrt
(
3.0
);
const
RealOpenMM
sqrtOneThird
=
1.0
/
sqrt
(
3.0
);
const
double
sqrtOneThird
=
1.0
/
sqrt
(
3.0
);
const
RealOpenMM
sqrtThree
=
sqrt
(
3.0
);
const
double
sqrtThree
=
sqrt
(
3.0
);
const
RealOpenMM
oneNinth
=
1.0
/
9.0
;
const
double
oneNinth
=
1.0
/
9.0
;
const
RealOpenMM
fourOverFortyFive
=
4.0
/
45.0
;
const
double
fourOverFortyFive
=
4.0
/
45.0
;
const
RealOpenMM
fourOverFifteen
=
4.0
/
15.0
;
const
double
fourOverFifteen
=
4.0
/
15.0
;
/**
/**
...
@@ -167,30 +167,30 @@ private:
...
@@ -167,30 +167,30 @@ private:
};
};
/**
/**
* 4-dimensional
RealOpenMM
vector
* 4-dimensional
double
vector
*/
*/
class
RealOpenMM
4
{
class
double
4
{
public:
public:
/**
/**
* Create a
RealOpenMM
4 whose elements are all 0.
* Create a
double
4 whose elements are all 0.
*/
*/
RealOpenMM
4
()
{
double
4
()
{
data
[
0
]
=
data
[
1
]
=
data
[
2
]
=
data
[
3
]
=
0.0
;
data
[
0
]
=
data
[
1
]
=
data
[
2
]
=
data
[
3
]
=
0.0
;
}
}
/**
/**
* Create a
RealOpenMM
4 with specified x, y, z, w components.
* Create a
double
4 with specified x, y, z, w components.
*/
*/
RealOpenMM4
(
RealOpenMM
x
,
RealOpenMM
y
,
RealOpenMM
z
,
RealOpenMM
w
)
{
double4
(
double
x
,
double
y
,
double
z
,
double
w
)
{
data
[
0
]
=
x
;
data
[
0
]
=
x
;
data
[
1
]
=
y
;
data
[
1
]
=
y
;
data
[
2
]
=
z
;
data
[
2
]
=
z
;
data
[
3
]
=
w
;
data
[
3
]
=
w
;
}
}
RealOpenMM
operator
[](
int
index
)
const
{
double
operator
[](
int
index
)
const
{
assert
(
index
>=
0
&&
index
<
4
);
assert
(
index
>=
0
&&
index
<
4
);
return
data
[
index
];
return
data
[
index
];
}
}
RealOpenMM
&
operator
[](
int
index
)
{
double
&
operator
[](
int
index
)
{
assert
(
index
>=
0
&&
index
<
4
);
assert
(
index
>=
0
&&
index
<
4
);
return
data
[
index
];
return
data
[
index
];
}
}
...
@@ -198,17 +198,17 @@ public:
...
@@ -198,17 +198,17 @@ public:
// Arithmetic operators
// Arithmetic operators
// unary plus
// unary plus
RealOpenMM
4
operator
+
()
const
{
double
4
operator
+
()
const
{
return
RealOpenMM
4
(
*
this
);
return
double
4
(
*
this
);
}
}
// plus
// plus
RealOpenMM
4
operator
+
(
const
RealOpenMM
4
&
rhs
)
const
{
double
4
operator
+
(
const
double
4
&
rhs
)
const
{
const
RealOpenMM
4
&
lhs
=
*
this
;
const
double
4
&
lhs
=
*
this
;
return
RealOpenMM
4
(
lhs
[
0
]
+
rhs
[
0
],
lhs
[
1
]
+
rhs
[
1
],
lhs
[
2
]
+
rhs
[
2
],
lhs
[
3
]
+
rhs
[
3
]);
return
double
4
(
lhs
[
0
]
+
rhs
[
0
],
lhs
[
1
]
+
rhs
[
1
],
lhs
[
2
]
+
rhs
[
2
],
lhs
[
3
]
+
rhs
[
3
]);
}
}
RealOpenMM
4
&
operator
+=
(
const
RealOpenMM
4
&
rhs
)
{
double
4
&
operator
+=
(
const
double
4
&
rhs
)
{
data
[
0
]
+=
rhs
[
0
];
data
[
0
]
+=
rhs
[
0
];
data
[
1
]
+=
rhs
[
1
];
data
[
1
]
+=
rhs
[
1
];
data
[
2
]
+=
rhs
[
2
];
data
[
2
]
+=
rhs
[
2
];
...
@@ -216,7 +216,7 @@ public:
...
@@ -216,7 +216,7 @@ public:
return
*
this
;
return
*
this
;
}
}
RealOpenMM
4
&
operator
-=
(
const
RealOpenMM
4
&
rhs
)
{
double
4
&
operator
-=
(
const
double
4
&
rhs
)
{
data
[
0
]
-=
rhs
[
0
];
data
[
0
]
-=
rhs
[
0
];
data
[
1
]
-=
rhs
[
1
];
data
[
1
]
-=
rhs
[
1
];
data
[
2
]
-=
rhs
[
2
];
data
[
2
]
-=
rhs
[
2
];
...
@@ -225,7 +225,7 @@ public:
...
@@ -225,7 +225,7 @@ public:
}
}
private:
private:
RealOpenMM
data
[
4
];
double
data
[
4
];
};
};
using
namespace
OpenMM
;
using
namespace
OpenMM
;
...
@@ -425,7 +425,7 @@ public:
...
@@ -425,7 +425,7 @@ public:
* @return epsilon
* @return epsilon
*
*
*/
*/
RealOpenMM
getMutualInducedDipoleEpsilon
()
const
;
double
getMutualInducedDipoleEpsilon
()
const
;
/**
/**
* Set the coefficients for the µ_0, µ_1, µ_2, µ_n terms in the extrapolation
* Set the coefficients for the µ_0, µ_1, µ_2, µ_n terms in the extrapolation
...
@@ -434,7 +434,7 @@ public:
...
@@ -434,7 +434,7 @@ public:
* @param optCoefficients a vector whose mth entry specifies the coefficient for µ_m
* @param optCoefficients a vector whose mth entry specifies the coefficient for µ_m
*
*
*/
*/
void
setExtrapolationCoefficients
(
const
std
::
vector
<
RealOpenMM
>
&
coefficients
);
void
setExtrapolationCoefficients
(
const
std
::
vector
<
double
>
&
coefficients
);
/**
/**
* Set the target epsilon for converging mutual induced dipoles.
* Set the target epsilon for converging mutual induced dipoles.
...
@@ -442,7 +442,7 @@ public:
...
@@ -442,7 +442,7 @@ public:
* @param targetEpsilon target epsilon for converging mutual induced dipoles
* @param targetEpsilon target epsilon for converging mutual induced dipoles
*
*
*/
*/
void
setMutualInducedDipoleTargetEpsilon
(
RealOpenMM
targetEpsilon
);
void
setMutualInducedDipoleTargetEpsilon
(
double
targetEpsilon
);
/**
/**
* Get the target epsilon for converging mutual induced dipoles.
* Get the target epsilon for converging mutual induced dipoles.
...
@@ -450,7 +450,7 @@ public:
...
@@ -450,7 +450,7 @@ public:
* @return target epsilon for converging mutual induced dipoles
* @return target epsilon for converging mutual induced dipoles
*
*
*/
*/
RealOpenMM
getMutualInducedDipoleTargetEpsilon
()
const
;
double
getMutualInducedDipoleTargetEpsilon
()
const
;
/**
/**
* Set the maximum number of iterations to be executed in converging mutual induced dipoles.
* Set the maximum number of iterations to be executed in converging mutual induced dipoles.
...
@@ -487,19 +487,19 @@ public:
...
@@ -487,19 +487,19 @@ public:
*
*
* @return energy
* @return energy
*/
*/
RealOpenMM
calculateForceAndEnergy
(
const
std
::
vector
<
OpenMM
::
Real
Vec
>&
particlePositions
,
double
calculateForceAndEnergy
(
const
std
::
vector
<
OpenMM
::
Vec
3
>&
particlePositions
,
const
std
::
vector
<
RealOpenMM
>&
charges
,
const
std
::
vector
<
double
>&
charges
,
const
std
::
vector
<
RealOpenMM
>&
dipoles
,
const
std
::
vector
<
double
>&
dipoles
,
const
std
::
vector
<
RealOpenMM
>&
quadrupoles
,
const
std
::
vector
<
double
>&
quadrupoles
,
const
std
::
vector
<
RealOpenMM
>&
tholes
,
const
std
::
vector
<
double
>&
tholes
,
const
std
::
vector
<
RealOpenMM
>&
dampingFactors
,
const
std
::
vector
<
double
>&
dampingFactors
,
const
std
::
vector
<
RealOpenMM
>&
polarity
,
const
std
::
vector
<
double
>&
polarity
,
const
std
::
vector
<
int
>&
axisTypes
,
const
std
::
vector
<
int
>&
axisTypes
,
const
std
::
vector
<
int
>&
multipoleAtomZs
,
const
std
::
vector
<
int
>&
multipoleAtomZs
,
const
std
::
vector
<
int
>&
multipoleAtomXs
,
const
std
::
vector
<
int
>&
multipoleAtomXs
,
const
std
::
vector
<
int
>&
multipoleAtomYs
,
const
std
::
vector
<
int
>&
multipoleAtomYs
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
int
>
>
>&
multipoleAtomCovalentInfo
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
int
>
>
>&
multipoleAtomCovalentInfo
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
);
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
);
/**
/**
* Calculate particle induced dipoles.
* Calculate particle induced dipoles.
...
@@ -519,19 +519,19 @@ public:
...
@@ -519,19 +519,19 @@ public:
* @param multipoleAtomCovalentInfo covalent info needed to set scaling factors
* @param multipoleAtomCovalentInfo covalent info needed to set scaling factors
* @param outputMultipoleMoments output multipole moments
* @param outputMultipoleMoments output multipole moments
*/
*/
void
calculateInducedDipoles
(
const
std
::
vector
<
OpenMM
::
Real
Vec
>&
particlePositions
,
void
calculateInducedDipoles
(
const
std
::
vector
<
OpenMM
::
Vec
3
>&
particlePositions
,
const
std
::
vector
<
RealOpenMM
>&
charges
,
const
std
::
vector
<
double
>&
charges
,
const
std
::
vector
<
RealOpenMM
>&
dipoles
,
const
std
::
vector
<
double
>&
dipoles
,
const
std
::
vector
<
RealOpenMM
>&
quadrupoles
,
const
std
::
vector
<
double
>&
quadrupoles
,
const
std
::
vector
<
RealOpenMM
>&
tholes
,
const
std
::
vector
<
double
>&
tholes
,
const
std
::
vector
<
RealOpenMM
>&
dampingFactors
,
const
std
::
vector
<
double
>&
dampingFactors
,
const
std
::
vector
<
RealOpenMM
>&
polarity
,
const
std
::
vector
<
double
>&
polarity
,
const
std
::
vector
<
int
>&
axisTypes
,
const
std
::
vector
<
int
>&
axisTypes
,
const
std
::
vector
<
int
>&
multipoleAtomZs
,
const
std
::
vector
<
int
>&
multipoleAtomZs
,
const
std
::
vector
<
int
>&
multipoleAtomXs
,
const
std
::
vector
<
int
>&
multipoleAtomXs
,
const
std
::
vector
<
int
>&
multipoleAtomYs
,
const
std
::
vector
<
int
>&
multipoleAtomYs
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
int
>
>
>&
multipoleAtomCovalentInfo
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
int
>
>
>&
multipoleAtomCovalentInfo
,
std
::
vector
<
Real
Vec
>&
outputInducedDipoles
);
std
::
vector
<
Vec
3
>&
outputInducedDipoles
);
/**
/**
* Calculate particle permanent dipoles rotated in the lab frame.
* Calculate particle permanent dipoles rotated in the lab frame.
...
@@ -552,19 +552,19 @@ public:
...
@@ -552,19 +552,19 @@ public:
* @param outputMultipoleMoments output multipole moments
* @param outputMultipoleMoments output multipole moments
*/
*/
void
calculateLabFramePermanentDipoles
(
const
std
::
vector
<
Real
Vec
>&
particlePositions
,
void
calculateLabFramePermanentDipoles
(
const
std
::
vector
<
Vec
3
>&
particlePositions
,
const
std
::
vector
<
RealOpenMM
>&
charges
,
const
std
::
vector
<
double
>&
charges
,
const
std
::
vector
<
RealOpenMM
>&
dipoles
,
const
std
::
vector
<
double
>&
dipoles
,
const
std
::
vector
<
RealOpenMM
>&
quadrupoles
,
const
std
::
vector
<
double
>&
quadrupoles
,
const
std
::
vector
<
RealOpenMM
>&
tholes
,
const
std
::
vector
<
double
>&
tholes
,
const
std
::
vector
<
RealOpenMM
>&
dampingFactors
,
const
std
::
vector
<
double
>&
dampingFactors
,
const
std
::
vector
<
RealOpenMM
>&
polarity
,
const
std
::
vector
<
double
>&
polarity
,
const
std
::
vector
<
int
>&
axisTypes
,
const
std
::
vector
<
int
>&
axisTypes
,
const
std
::
vector
<
int
>&
multipoleAtomZs
,
const
std
::
vector
<
int
>&
multipoleAtomZs
,
const
std
::
vector
<
int
>&
multipoleAtomXs
,
const
std
::
vector
<
int
>&
multipoleAtomXs
,
const
std
::
vector
<
int
>&
multipoleAtomYs
,
const
std
::
vector
<
int
>&
multipoleAtomYs
,
const
std
::
vector
<
vector
<
vector
<
int
>
>
>&
multipoleAtomCovalentInfo
,
const
std
::
vector
<
vector
<
vector
<
int
>
>
>&
multipoleAtomCovalentInfo
,
std
::
vector
<
Real
Vec
>&
outputRotatedPermanentDipoles
);
std
::
vector
<
Vec
3
>&
outputRotatedPermanentDipoles
);
/**
/**
* Calculate particle total dipoles.
* Calculate particle total dipoles.
...
@@ -586,19 +586,19 @@ public:
...
@@ -586,19 +586,19 @@ public:
*/
*/
void
calculateTotalDipoles
(
const
std
::
vector
<
Real
Vec
>&
particlePositions
,
void
calculateTotalDipoles
(
const
std
::
vector
<
Vec
3
>&
particlePositions
,
const
std
::
vector
<
RealOpenMM
>&
charges
,
const
std
::
vector
<
double
>&
charges
,
const
std
::
vector
<
RealOpenMM
>&
dipoles
,
const
std
::
vector
<
double
>&
dipoles
,
const
std
::
vector
<
RealOpenMM
>&
quadrupoles
,
const
std
::
vector
<
double
>&
quadrupoles
,
const
std
::
vector
<
RealOpenMM
>&
tholes
,
const
std
::
vector
<
double
>&
tholes
,
const
std
::
vector
<
RealOpenMM
>&
dampingFactors
,
const
std
::
vector
<
double
>&
dampingFactors
,
const
std
::
vector
<
RealOpenMM
>&
polarity
,
const
std
::
vector
<
double
>&
polarity
,
const
std
::
vector
<
int
>&
axisTypes
,
const
std
::
vector
<
int
>&
axisTypes
,
const
std
::
vector
<
int
>&
multipoleAtomZs
,
const
std
::
vector
<
int
>&
multipoleAtomZs
,
const
std
::
vector
<
int
>&
multipoleAtomXs
,
const
std
::
vector
<
int
>&
multipoleAtomXs
,
const
std
::
vector
<
int
>&
multipoleAtomYs
,
const
std
::
vector
<
int
>&
multipoleAtomYs
,
const
std
::
vector
<
vector
<
vector
<
int
>
>
>&
multipoleAtomCovalentInfo
,
const
std
::
vector
<
vector
<
vector
<
int
>
>
>&
multipoleAtomCovalentInfo
,
std
::
vector
<
Real
Vec
>&
outputRotatedPermanentDipoles
);
std
::
vector
<
Vec
3
>&
outputRotatedPermanentDipoles
);
...
@@ -620,20 +620,20 @@ public:
...
@@ -620,20 +620,20 @@ public:
* @param multipoleAtomCovalentInfo covalent info needed to set scaling factors
* @param multipoleAtomCovalentInfo covalent info needed to set scaling factors
* @param outputMultipoleMoments output multipole moments
* @param outputMultipoleMoments output multipole moments
*/
*/
void
calculateAmoebaSystemMultipoleMoments
(
const
std
::
vector
<
RealOpenMM
>&
masses
,
void
calculateAmoebaSystemMultipoleMoments
(
const
std
::
vector
<
double
>&
masses
,
const
std
::
vector
<
OpenMM
::
Real
Vec
>&
particlePositions
,
const
std
::
vector
<
OpenMM
::
Vec
3
>&
particlePositions
,
const
std
::
vector
<
RealOpenMM
>&
charges
,
const
std
::
vector
<
double
>&
charges
,
const
std
::
vector
<
RealOpenMM
>&
dipoles
,
const
std
::
vector
<
double
>&
dipoles
,
const
std
::
vector
<
RealOpenMM
>&
quadrupoles
,
const
std
::
vector
<
double
>&
quadrupoles
,
const
std
::
vector
<
RealOpenMM
>&
tholes
,
const
std
::
vector
<
double
>&
tholes
,
const
std
::
vector
<
RealOpenMM
>&
dampingFactors
,
const
std
::
vector
<
double
>&
dampingFactors
,
const
std
::
vector
<
RealOpenMM
>&
polarity
,
const
std
::
vector
<
double
>&
polarity
,
const
std
::
vector
<
int
>&
axisTypes
,
const
std
::
vector
<
int
>&
axisTypes
,
const
std
::
vector
<
int
>&
multipoleAtomZs
,
const
std
::
vector
<
int
>&
multipoleAtomZs
,
const
std
::
vector
<
int
>&
multipoleAtomXs
,
const
std
::
vector
<
int
>&
multipoleAtomXs
,
const
std
::
vector
<
int
>&
multipoleAtomYs
,
const
std
::
vector
<
int
>&
multipoleAtomYs
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
int
>
>
>&
multipoleAtomCovalentInfo
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
int
>
>
>&
multipoleAtomCovalentInfo
,
std
::
vector
<
RealOpenMM
>&
outputMultipoleMoments
);
std
::
vector
<
double
>&
outputMultipoleMoments
);
/**
/**
* Calculate electrostatic potential at a set of grid points.
* Calculate electrostatic potential at a set of grid points.
...
@@ -653,20 +653,20 @@ public:
...
@@ -653,20 +653,20 @@ public:
* @param input grid input grid points to compute potential
* @param input grid input grid points to compute potential
* @param outputPotential output electrostatic potential
* @param outputPotential output electrostatic potential
*/
*/
void
calculateElectrostaticPotential
(
const
std
::
vector
<
OpenMM
::
Real
Vec
>&
particlePositions
,
void
calculateElectrostaticPotential
(
const
std
::
vector
<
OpenMM
::
Vec
3
>&
particlePositions
,
const
std
::
vector
<
RealOpenMM
>&
charges
,
const
std
::
vector
<
double
>&
charges
,
const
std
::
vector
<
RealOpenMM
>&
dipoles
,
const
std
::
vector
<
double
>&
dipoles
,
const
std
::
vector
<
RealOpenMM
>&
quadrupoles
,
const
std
::
vector
<
double
>&
quadrupoles
,
const
std
::
vector
<
RealOpenMM
>&
tholes
,
const
std
::
vector
<
double
>&
tholes
,
const
std
::
vector
<
RealOpenMM
>&
dampingFactors
,
const
std
::
vector
<
double
>&
dampingFactors
,
const
std
::
vector
<
RealOpenMM
>&
polarity
,
const
std
::
vector
<
double
>&
polarity
,
const
std
::
vector
<
int
>&
axisTypes
,
const
std
::
vector
<
int
>&
axisTypes
,
const
std
::
vector
<
int
>&
multipoleAtomZs
,
const
std
::
vector
<
int
>&
multipoleAtomZs
,
const
std
::
vector
<
int
>&
multipoleAtomXs
,
const
std
::
vector
<
int
>&
multipoleAtomXs
,
const
std
::
vector
<
int
>&
multipoleAtomYs
,
const
std
::
vector
<
int
>&
multipoleAtomYs
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
int
>
>
>&
multipoleAtomCovalentInfo
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
int
>
>
>&
multipoleAtomCovalentInfo
,
const
std
::
vector
<
Real
Vec
>&
inputGrid
,
const
std
::
vector
<
Vec
3
>&
inputGrid
,
std
::
vector
<
RealOpenMM
>&
outputPotential
);
std
::
vector
<
double
>&
outputPotential
);
protected:
protected:
...
@@ -682,15 +682,15 @@ protected:
...
@@ -682,15 +682,15 @@ protected:
class
MultipoleParticleData
{
class
MultipoleParticleData
{
public:
public:
unsigned
int
particleIndex
;
unsigned
int
particleIndex
;
Real
Vec
position
;
Vec
3
position
;
RealOpenMM
charge
;
double
charge
;
Real
Vec
dipole
;
Vec
3
dipole
;
RealOpenMM
quadrupole
[
6
];
double
quadrupole
[
6
];
Real
Vec
sphericalDipole
;
Vec
3
sphericalDipole
;
RealOpenMM
sphericalQuadrupole
[
5
];
double
sphericalQuadrupole
[
5
];
RealOpenMM
thole
;
double
thole
;
RealOpenMM
dampingFactor
;
double
dampingFactor
;
RealOpenMM
polarity
;
double
polarity
;
};
};
/**
/**
...
@@ -698,22 +698,22 @@ protected:
...
@@ -698,22 +698,22 @@ protected:
*/
*/
class
TransformedMultipole
{
class
TransformedMultipole
{
public:
public:
RealOpenMM
charge
;
double
charge
;
Real
Vec
dipole
;
Vec
3
dipole
;
RealOpenMM
quadrupole
[
6
];
double
quadrupole
[
6
];
};
};
/*
/*
* Helper class used in calculating induced dipoles
* Helper class used in calculating induced dipoles
*/
*/
struct
UpdateInducedDipoleFieldStruct
{
struct
UpdateInducedDipoleFieldStruct
{
UpdateInducedDipoleFieldStruct
(
std
::
vector
<
OpenMM
::
Real
Vec
>&
inputFixed_E_Field
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
inputInducedDipoles
,
std
::
vector
<
std
::
vector
<
Real
Vec
>
>&
extrapolatedDipoles
,
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>&
extrapolatedDipoleFieldGradient
);
UpdateInducedDipoleFieldStruct
(
std
::
vector
<
OpenMM
::
Vec
3
>&
inputFixed_E_Field
,
std
::
vector
<
OpenMM
::
Vec
3
>&
inputInducedDipoles
,
std
::
vector
<
std
::
vector
<
Vec
3
>
>&
extrapolatedDipoles
,
std
::
vector
<
std
::
vector
<
double
>
>&
extrapolatedDipoleFieldGradient
);
std
::
vector
<
OpenMM
::
Real
Vec
>*
fixedMultipoleField
;
std
::
vector
<
OpenMM
::
Vec
3
>*
fixedMultipoleField
;
std
::
vector
<
OpenMM
::
Real
Vec
>*
inducedDipoles
;
std
::
vector
<
OpenMM
::
Vec
3
>*
inducedDipoles
;
std
::
vector
<
std
::
vector
<
Real
Vec
>
>*
extrapolatedDipoles
;
std
::
vector
<
std
::
vector
<
Vec
3
>
>*
extrapolatedDipoles
;
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>*
extrapolatedDipoleFieldGradient
;
std
::
vector
<
std
::
vector
<
double
>
>*
extrapolatedDipoleFieldGradient
;
std
::
vector
<
OpenMM
::
Real
Vec
>
inducedDipoleField
;
std
::
vector
<
OpenMM
::
Vec
3
>
inducedDipoleField
;
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>
inducedDipoleFieldGradient
;
std
::
vector
<
std
::
vector
<
double
>
>
inducedDipoleFieldGradient
;
};
};
unsigned
int
_numParticles
;
unsigned
int
_numParticles
;
...
@@ -721,37 +721,37 @@ protected:
...
@@ -721,37 +721,37 @@ protected:
NonbondedMethod
_nonbondedMethod
;
NonbondedMethod
_nonbondedMethod
;
PolarizationType
_polarizationType
;
PolarizationType
_polarizationType
;
RealOpenMM
_electric
;
double
_electric
;
RealOpenMM
_dielectric
;
double
_dielectric
;
enum
ScaleType
{
D_SCALE
,
P_SCALE
,
M_SCALE
,
U_SCALE
,
LAST_SCALE_TYPE_INDEX
};
enum
ScaleType
{
D_SCALE
,
P_SCALE
,
M_SCALE
,
U_SCALE
,
LAST_SCALE_TYPE_INDEX
};
std
::
vector
<
std
::
vector
<
MapIntRealOpenMM
>
>
_scaleMaps
;
std
::
vector
<
std
::
vector
<
MapIntRealOpenMM
>
>
_scaleMaps
;
std
::
vector
<
unsigned
int
>
_maxScaleIndex
;
std
::
vector
<
unsigned
int
>
_maxScaleIndex
;
RealOpenMM
_dScale
[
5
];
double
_dScale
[
5
];
RealOpenMM
_pScale
[
5
];
double
_pScale
[
5
];
RealOpenMM
_mScale
[
5
];
double
_mScale
[
5
];
RealOpenMM
_uScale
[
5
];
double
_uScale
[
5
];
std
::
vector
<
TransformedMultipole
>
_transformed
;
std
::
vector
<
TransformedMultipole
>
_transformed
;
std
::
vector
<
Real
Vec
>
_fixedMultipoleField
;
std
::
vector
<
Vec
3
>
_fixedMultipoleField
;
std
::
vector
<
Real
Vec
>
_fixedMultipoleFieldPolar
;
std
::
vector
<
Vec
3
>
_fixedMultipoleFieldPolar
;
std
::
vector
<
Real
Vec
>
_inducedDipole
;
std
::
vector
<
Vec
3
>
_inducedDipole
;
std
::
vector
<
Real
Vec
>
_inducedDipolePolar
;
std
::
vector
<
Vec
3
>
_inducedDipolePolar
;
std
::
vector
<
std
::
vector
<
Real
Vec
>
>
_ptDipoleP
;
std
::
vector
<
std
::
vector
<
Vec
3
>
>
_ptDipoleP
;
std
::
vector
<
std
::
vector
<
Real
Vec
>
>
_ptDipoleD
;
std
::
vector
<
std
::
vector
<
Vec
3
>
>
_ptDipoleD
;
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>
_ptDipoleFieldGradientP
;
std
::
vector
<
std
::
vector
<
double
>
>
_ptDipoleFieldGradientP
;
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>
_ptDipoleFieldGradientD
;
std
::
vector
<
std
::
vector
<
double
>
>
_ptDipoleFieldGradientD
;
int
_mutualInducedDipoleConverged
;
int
_mutualInducedDipoleConverged
;
int
_mutualInducedDipoleIterations
;
int
_mutualInducedDipoleIterations
;
int
_maximumMutualInducedDipoleIterations
;
int
_maximumMutualInducedDipoleIterations
;
int
_maxPTOrder
;
int
_maxPTOrder
;
std
::
vector
<
RealOpenMM
>
_extrapolationCoefficients
;
std
::
vector
<
double
>
_extrapolationCoefficients
;
std
::
vector
<
RealOpenMM
>
_extPartCoefficients
;
std
::
vector
<
double
>
_extPartCoefficients
;
RealOpenMM
_mutualInducedDipoleEpsilon
;
double
_mutualInducedDipoleEpsilon
;
RealOpenMM
_mutualInducedDipoleTargetEpsilon
;
double
_mutualInducedDipoleTargetEpsilon
;
RealOpenMM
_polarSOR
;
double
_polarSOR
;
RealOpenMM
_debye
;
double
_debye
;
/**
/**
* Helper constructor method to centralize initialization of objects.
* Helper constructor method to centralize initialization of objects.
...
@@ -772,13 +772,13 @@ protected:
...
@@ -772,13 +772,13 @@ protected:
* @param particleData output data struct
* @param particleData output data struct
*
*
*/
*/
void
loadParticleData
(
const
std
::
vector
<
OpenMM
::
Real
Vec
>&
particlePositions
,
void
loadParticleData
(
const
std
::
vector
<
OpenMM
::
Vec
3
>&
particlePositions
,
const
std
::
vector
<
RealOpenMM
>&
charges
,
const
std
::
vector
<
double
>&
charges
,
const
std
::
vector
<
RealOpenMM
>&
dipoles
,
const
std
::
vector
<
double
>&
dipoles
,
const
std
::
vector
<
RealOpenMM
>&
quadrupoles
,
const
std
::
vector
<
double
>&
quadrupoles
,
const
std
::
vector
<
RealOpenMM
>&
tholes
,
const
std
::
vector
<
double
>&
tholes
,
const
std
::
vector
<
RealOpenMM
>&
dampingFactors
,
const
std
::
vector
<
double
>&
dampingFactors
,
const
std
::
vector
<
RealOpenMM
>&
polarity
,
const
std
::
vector
<
double
>&
polarity
,
std
::
vector
<
MultipoleParticleData
>&
particleData
)
const
;
std
::
vector
<
MultipoleParticleData
>&
particleData
)
const
;
/**
/**
...
@@ -811,7 +811,7 @@ protected:
...
@@ -811,7 +811,7 @@ protected:
* @param epsilon
* @param epsilon
*
*
*/
*/
void
setMutualInducedDipoleEpsilon
(
RealOpenMM
epsilon
);
void
setMutualInducedDipoleEpsilon
(
double
epsilon
);
/**
/**
* Setup scale factors given covalent info.
* Setup scale factors given covalent info.
...
@@ -830,7 +830,7 @@ protected:
...
@@ -830,7 +830,7 @@ protected:
*
*
* @return scaleFactor
* @return scaleFactor
*/
*/
RealOpenMM
getMultipoleScaleFactor
(
unsigned
int
particleI
,
unsigned
int
particleJ
,
ScaleType
scaleType
)
const
;
double
getMultipoleScaleFactor
(
unsigned
int
particleI
,
unsigned
int
particleJ
,
ScaleType
scaleType
)
const
;
/**
/**
* Get scale factor for particleI & particleJ
* Get scale factor for particleI & particleJ
...
@@ -841,7 +841,7 @@ protected:
...
@@ -841,7 +841,7 @@ protected:
*
*
* @return array of scaleFactors
* @return array of scaleFactors
*/
*/
void
getMultipoleScaleFactors
(
unsigned
int
particleI
,
unsigned
int
particleJ
,
std
::
vector
<
RealOpenMM
>&
scaleFactors
)
const
;
void
getMultipoleScaleFactors
(
unsigned
int
particleI
,
unsigned
int
particleJ
,
std
::
vector
<
double
>&
scaleFactors
)
const
;
/**
/**
* Get p- and d-scale factors for particleI & particleJ ixn
* Get p- and d-scale factors for particleI & particleJ ixn
...
@@ -851,7 +851,7 @@ protected:
...
@@ -851,7 +851,7 @@ protected:
* @param dScale output d-scale factor
* @param dScale output d-scale factor
* @param pScale output p-scale factor
* @param pScale output p-scale factor
*/
*/
void
getDScaleAndPScale
(
unsigned
int
particleI
,
unsigned
int
particleJ
,
RealOpenMM
&
dScale
,
RealOpenMM
&
pScale
)
const
;
void
getDScaleAndPScale
(
unsigned
int
particleI
,
unsigned
int
particleJ
,
double
&
dScale
,
double
&
pScale
)
const
;
/**
/**
* Calculate damped powers of 1/r.
* Calculate damped powers of 1/r.
...
@@ -861,8 +861,8 @@ protected:
...
@@ -861,8 +861,8 @@ protected:
* @param dScale output d-scale factor
* @param dScale output d-scale factor
* @param pScale output p-scale factor
* @param pScale output p-scale factor
*/
*/
void
getAndScaleInverseRs
(
RealOpenMM
dampI
,
RealOpenMM
dampJ
,
RealOpenMM
tholeI
,
RealOpenMM
tholeJ
,
void
getAndScaleInverseRs
(
double
dampI
,
double
dampJ
,
double
tholeI
,
double
tholeJ
,
RealOpenMM
r
,
std
::
vector
<
RealOpenMM
>&
rrI
)
const
;
double
r
,
std
::
vector
<
double
>&
rrI
)
const
;
/**
/**
* Check if multipoles at chiral site should be inverted.
* Check if multipoles at chiral site should be inverted.
...
@@ -915,11 +915,11 @@ protected:
...
@@ -915,11 +915,11 @@ protected:
* @param r the bond length between atoms I and J
* @param r the bond length between atoms I and J
* @param rotationmatrix the output rotation matrix for a 3-vector
* @param rotationmatrix the output rotation matrix for a 3-vector
*/
*/
void
formQIRotationMatrix
(
const
Real
Vec
&
iPosition
,
void
formQIRotationMatrix
(
const
Vec
3
&
iPosition
,
const
Real
Vec
&
jPosition
,
const
Vec
3
&
jPosition
,
const
Real
Vec
&
deltaR
,
const
Vec
3
&
deltaR
,
RealOpenMM
r
,
double
r
,
RealOpenMM
(
&
rotationMatrix
)[
3
][
3
])
const
;
double
(
&
rotationMatrix
)[
3
][
3
])
const
;
/**
/**
...
@@ -928,7 +928,7 @@ protected:
...
@@ -928,7 +928,7 @@ protected:
* @param D1 The input spherical harmonic dipole rotation matrix
* @param D1 The input spherical harmonic dipole rotation matrix
* @param D2 The output spherical harmonic quadrupole rotation matrix
* @param D2 The output spherical harmonic quadrupole rotation matrix
*/
*/
void
buildSphericalQuadrupoleRotationMatrix
(
const
RealOpenMM
(
&
D1
)[
3
][
3
],
RealOpenMM
(
&
D2
)[
5
][
5
])
const
;
void
buildSphericalQuadrupoleRotationMatrix
(
const
double
(
&
D1
)[
3
][
3
],
double
(
&
D2
)[
5
][
5
])
const
;
/**
/**
* Constructs a rotation matrix for spherical harmonic quadrupoles, using the dipole rotation matrix.
* Constructs a rotation matrix for spherical harmonic quadrupoles, using the dipole rotation matrix.
...
@@ -937,7 +937,7 @@ protected:
...
@@ -937,7 +937,7 @@ protected:
* @param D1 The input spherical harmonic dipole rotation matrix
* @param D1 The input spherical harmonic dipole rotation matrix
* @param D2 The output spherical harmonic quadrupole rotation matrix
* @param D2 The output spherical harmonic quadrupole rotation matrix
*/
*/
void
buildPartialSphericalQuadrupoleRotationMatrix
(
const
RealOpenMM
(
&
D1
)[
3
][
3
],
RealOpenMM
(
&
D2
)[
3
][
5
])
const
;
void
buildPartialSphericalQuadrupoleRotationMatrix
(
const
double
(
&
D1
)[
3
][
3
],
double
(
&
D2
)[
3
][
5
])
const
;
/**
/**
* Apply rotation matrix to molecular dipole/quadrupoles to get corresponding lab frame values.
* Apply rotation matrix to molecular dipole/quadrupoles to get corresponding lab frame values.
...
@@ -969,7 +969,7 @@ protected:
...
@@ -969,7 +969,7 @@ protected:
* @param pScale p-scale value for i-j interaction
* @param pScale p-scale value for i-j interaction
*/
*/
virtual
void
calculateFixedMultipoleFieldPairIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
virtual
void
calculateFixedMultipoleFieldPairIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
RealOpenMM
dScale
,
RealOpenMM
pScale
);
double
dScale
,
double
pScale
);
/**
/**
* Initialize induced dipoles
* Initialize induced dipoles
...
@@ -991,9 +991,9 @@ protected:
...
@@ -991,9 +991,9 @@ protected:
* @param field vector of induced dipole fields
* @param field vector of induced dipole fields
*/
*/
void
calculateInducedDipolePairIxn
(
unsigned
int
particleI
,
unsigned
int
particleJ
,
void
calculateInducedDipolePairIxn
(
unsigned
int
particleI
,
unsigned
int
particleJ
,
RealOpenMM
rr3
,
RealOpenMM
rr5
,
const
Real
Vec
&
delta
,
double
rr3
,
double
rr5
,
const
Vec
3
&
delta
,
const
std
::
vector
<
Real
Vec
>&
inducedDipole
,
const
std
::
vector
<
Vec
3
>&
inducedDipole
,
std
::
vector
<
Real
Vec
>&
field
)
const
;
std
::
vector
<
Vec
3
>&
field
)
const
;
/**
/**
* Calculate fields due induced dipoles at each site.
* Calculate fields due induced dipoles at each site.
...
@@ -1044,7 +1044,7 @@ protected:
...
@@ -1044,7 +1044,7 @@ protected:
* @param prevErrors the vector of errors from previous iterations
* @param prevErrors the vector of errors from previous iterations
* @param coefficients the coefficients will be stored into this
* @param coefficients the coefficients will be stored into this
*/
*/
void
computeDIISCoefficients
(
const
std
::
vector
<
std
::
vector
<
Real
Vec
>
>&
prevErrors
,
std
::
vector
<
RealOpenMM
>&
coefficients
)
const
;
void
computeDIISCoefficients
(
const
std
::
vector
<
std
::
vector
<
Vec
3
>
>&
prevErrors
,
std
::
vector
<
double
>&
coefficients
)
const
;
/**
/**
* Update fields due to induced dipoles for each particle.
* Update fields due to induced dipoles for each particle.
...
@@ -1052,8 +1052,8 @@ protected:
...
@@ -1052,8 +1052,8 @@ protected:
* @param particleData vector of particle positions and parameters (charge, labFrame dipoles, quadrupoles, ...)
* @param particleData vector of particle positions and parameters (charge, labFrame dipoles, quadrupoles, ...)
* @param updateInducedDipoleFields vector of UpdateInducedDipoleFieldStruct containing input induced dipoles and output fields
* @param updateInducedDipoleFields vector of UpdateInducedDipoleFieldStruct containing input induced dipoles and output fields
*/
*/
RealOpenMM
updateInducedDipoleFields
(
const
std
::
vector
<
MultipoleParticleData
>&
particleData
,
double
updateInducedDipoleFields
(
const
std
::
vector
<
MultipoleParticleData
>&
particleData
,
std
::
vector
<
UpdateInducedDipoleFieldStruct
>&
calculateInducedDipoleField
);
std
::
vector
<
UpdateInducedDipoleFieldStruct
>&
calculateInducedDipoleField
);
/**
/**
* Update induced dipole for a particle given updated induced dipole field at the site.
* Update induced dipole for a particle given updated induced dipole field at the site.
...
@@ -1063,10 +1063,10 @@ protected:
...
@@ -1063,10 +1063,10 @@ protected:
* @param inducedDipoleField fields due induced dipoles at each site
* @param inducedDipoleField fields due induced dipoles at each site
* @param inducedDipoles output vector of updated induced dipoles
* @param inducedDipoles output vector of updated induced dipoles
*/
*/
RealOpenMM
updateInducedDipole
(
const
std
::
vector
<
MultipoleParticleData
>&
particleI
,
double
updateInducedDipole
(
const
std
::
vector
<
MultipoleParticleData
>&
particleI
,
const
std
::
vector
<
Real
Vec
>&
fixedMultipoleField
,
const
std
::
vector
<
Vec
3
>&
fixedMultipoleField
,
const
std
::
vector
<
Real
Vec
>&
inducedDipoleField
,
const
std
::
vector
<
Vec
3
>&
inducedDipoleField
,
std
::
vector
<
Real
Vec
>&
inducedDipoles
);
std
::
vector
<
Vec
3
>&
inducedDipoles
);
/**
/**
* Calculate induced dipoles.
* Calculate induced dipoles.
...
@@ -1097,13 +1097,13 @@ protected:
...
@@ -1097,13 +1097,13 @@ protected:
* @param particleData output vector of parameters (charge, labFrame dipoles, quadrupoles, ...) for particles
* @param particleData output vector of parameters (charge, labFrame dipoles, quadrupoles, ...) for particles
*
*
*/
*/
void
setup
(
const
std
::
vector
<
OpenMM
::
Real
Vec
>&
particlePositions
,
void
setup
(
const
std
::
vector
<
OpenMM
::
Vec
3
>&
particlePositions
,
const
std
::
vector
<
RealOpenMM
>&
charges
,
const
std
::
vector
<
double
>&
charges
,
const
std
::
vector
<
RealOpenMM
>&
dipoles
,
const
std
::
vector
<
double
>&
dipoles
,
const
std
::
vector
<
RealOpenMM
>&
quadrupoles
,
const
std
::
vector
<
double
>&
quadrupoles
,
const
std
::
vector
<
RealOpenMM
>&
tholes
,
const
std
::
vector
<
double
>&
tholes
,
const
std
::
vector
<
RealOpenMM
>&
dampingFactors
,
const
std
::
vector
<
double
>&
dampingFactors
,
const
std
::
vector
<
RealOpenMM
>&
polarity
,
const
std
::
vector
<
double
>&
polarity
,
const
std
::
vector
<
int
>&
axisTypes
,
const
std
::
vector
<
int
>&
axisTypes
,
const
std
::
vector
<
int
>&
multipoleAtomZs
,
const
std
::
vector
<
int
>&
multipoleAtomZs
,
const
std
::
vector
<
int
>&
multipoleAtomXs
,
const
std
::
vector
<
int
>&
multipoleAtomXs
,
...
@@ -1120,8 +1120,8 @@ protected:
...
@@ -1120,8 +1120,8 @@ protected:
* @param forces vector of particle forces to be updated
* @param forces vector of particle forces to be updated
* @param torque vector of particle torques to be updated
* @param torque vector of particle torques to be updated
*/
*/
RealOpenMM
calculateElectrostaticPairIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleK
,
double
calculateElectrostaticPairIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleK
,
const
std
::
vector
<
RealOpenMM
>&
scalingFactors
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
,
std
::
vector
<
Real
Vec
>&
torque
)
const
;
const
std
::
vector
<
double
>&
scalingFactors
,
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
,
std
::
vector
<
Vec
3
>&
torque
)
const
;
/**
/**
* Map particle torque to force.
* Map particle torque to force.
...
@@ -1138,7 +1138,7 @@ protected:
...
@@ -1138,7 +1138,7 @@ protected:
const
MultipoleParticleData
&
particleU
,
const
MultipoleParticleData
&
particleU
,
const
MultipoleParticleData
&
particleV
,
const
MultipoleParticleData
&
particleV
,
MultipoleParticleData
*
particleW
,
MultipoleParticleData
*
particleW
,
int
axisType
,
const
Vec3
&
torque
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
)
const
;
int
axisType
,
const
Vec3
&
torque
,
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
)
const
;
/**
/**
* Map torques to forces.
* Map torques to forces.
...
@@ -1156,8 +1156,8 @@ protected:
...
@@ -1156,8 +1156,8 @@ protected:
const
std
::
vector
<
int
>&
multipoleAtomYs
,
const
std
::
vector
<
int
>&
multipoleAtomYs
,
const
std
::
vector
<
int
>&
multipoleAtomZs
,
const
std
::
vector
<
int
>&
multipoleAtomZs
,
const
std
::
vector
<
int
>&
axisTypes
,
const
std
::
vector
<
int
>&
axisTypes
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
torques
,
std
::
vector
<
OpenMM
::
Vec
3
>&
torques
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
)
const
;
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
)
const
;
/**
/**
* Calculate electrostatic forces
* Calculate electrostatic forces
...
@@ -1168,44 +1168,44 @@ protected:
...
@@ -1168,44 +1168,44 @@ protected:
*
*
* @return energy
* @return energy
*/
*/
virtual
RealOpenMM
calculateElectrostatic
(
const
std
::
vector
<
MultipoleParticleData
>&
particleData
,
virtual
double
calculateElectrostatic
(
const
std
::
vector
<
MultipoleParticleData
>&
particleData
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
torques
,
std
::
vector
<
OpenMM
::
Vec
3
>&
torques
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
);
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
);
/**
/**
* Normalize a
Real
Vec
* Normalize a Vec
3
*
*
* @param vectorToNormalize vector to normalize
* @param vectorToNormalize vector to normalize
*
*
* @return norm of vector on input
* @return norm of vector on input
*
*
*/
*/
RealOpenMM
normalizeRealVec
(
Real
Vec
&
vectorToNormalize
)
const
;
double
normalizeVec3
(
Vec
3
&
vectorToNormalize
)
const
;
/**
/**
* Initialize vector of
RealOpenMM
(size=numParticles)
* Initialize vector of
double
(size=numParticles)
*
*
* @param vectorToInitialize vector to initialize
* @param vectorToInitialize vector to initialize
*
*
*/
*/
void
initializeRealOpenMMVector
(
vector
<
RealOpenMM
>&
vectorToInitialize
)
const
;
void
initializeRealOpenMMVector
(
vector
<
double
>&
vectorToInitialize
)
const
;
/**
/**
* Initialize vector of
Real
Vec (size=numParticles)
* Initialize vector of Vec
3
(size=numParticles)
*
*
* @param vectorToInitialize vector to initialize
* @param vectorToInitialize vector to initialize
*
*
*/
*/
void
initialize
Real
VecVector
(
vector
<
Real
Vec
>&
vectorToInitialize
)
const
;
void
initializeVec
3
Vector
(
vector
<
Vec
3
>&
vectorToInitialize
)
const
;
/**
/**
* Copy vector of
Real
Vec
* Copy vector of Vec
3
*
*
* @param inputVector vector to copy
* @param inputVector vector to copy
* @param outputVector output vector
* @param outputVector output vector
*
*
*/
*/
void
copy
Real
VecVector
(
const
std
::
vector
<
OpenMM
::
Real
Vec
>&
inputVector
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
outputVector
)
const
;
void
copyVec
3
Vector
(
const
std
::
vector
<
OpenMM
::
Vec
3
>&
inputVector
,
std
::
vector
<
OpenMM
::
Vec
3
>&
outputVector
)
const
;
/**
/**
* Calculate potential at grid point due to a particle
* Calculate potential at grid point due to a particle
...
@@ -1216,7 +1216,7 @@ protected:
...
@@ -1216,7 +1216,7 @@ protected:
* @return potential at grid point
* @return potential at grid point
*
*
*/
*/
RealOpenMM
calculateElectrostaticPotentialForParticleGridPoint
(
const
MultipoleParticleData
&
particleI
,
const
Real
Vec
&
gridPoint
)
const
;
double
calculateElectrostaticPotentialForParticleGridPoint
(
const
MultipoleParticleData
&
particleI
,
const
Vec
3
&
gridPoint
)
const
;
/**
/**
* Apply periodic boundary conditions to difference in positions
* Apply periodic boundary conditions to difference in positions
...
@@ -1224,7 +1224,7 @@ protected:
...
@@ -1224,7 +1224,7 @@ protected:
* @param deltaR difference in particle positions; modified on output after applying PBC
* @param deltaR difference in particle positions; modified on output after applying PBC
*
*
*/
*/
virtual
void
getPeriodicDelta
(
Real
Vec
&
deltaR
)
const
{};
virtual
void
getPeriodicDelta
(
Vec
3
&
deltaR
)
const
{};
};
};
class
AmoebaReferenceGeneralizedKirkwoodMultipoleForce
:
public
AmoebaReferenceMultipoleForce
{
class
AmoebaReferenceGeneralizedKirkwoodMultipoleForce
:
public
AmoebaReferenceMultipoleForce
{
...
@@ -1257,7 +1257,7 @@ public:
...
@@ -1257,7 +1257,7 @@ public:
* @return probe radius
* @return probe radius
*
*
*/
*/
RealOpenMM
getProbeRadius
()
const
;
double
getProbeRadius
()
const
;
/**
/**
* Get surface area factor.
* Get surface area factor.
...
@@ -1265,7 +1265,7 @@ public:
...
@@ -1265,7 +1265,7 @@ public:
* @return surface area factor
* @return surface area factor
*
*
*/
*/
RealOpenMM
getSurfaceAreaFactor
()
const
;
double
getSurfaceAreaFactor
()
const
;
/**
/**
* Get dielectric offset.
* Get dielectric offset.
...
@@ -1273,34 +1273,34 @@ public:
...
@@ -1273,34 +1273,34 @@ public:
* @return dielectric offset
* @return dielectric offset
*
*
*/
*/
RealOpenMM
getDielectricOffset
()
const
;
double
getDielectricOffset
()
const
;
private:
private:
AmoebaReferenceGeneralizedKirkwoodForce
*
_amoebaReferenceGeneralizedKirkwoodForce
;
AmoebaReferenceGeneralizedKirkwoodForce
*
_amoebaReferenceGeneralizedKirkwoodForce
;
RealOpenMM
_gkc
;
double
_gkc
;
RealOpenMM
_fc
;
double
_fc
;
RealOpenMM
_fd
;
double
_fd
;
RealOpenMM
_fq
;
double
_fq
;
std
::
vector
<
RealOpenMM
>
_atomicRadii
;
std
::
vector
<
double
>
_atomicRadii
;
std
::
vector
<
RealOpenMM
>
_scaledRadii
;
std
::
vector
<
double
>
_scaledRadii
;
std
::
vector
<
RealOpenMM
>
_bornRadii
;
std
::
vector
<
double
>
_bornRadii
;
std
::
vector
<
RealOpenMM
>
_bornForce
;
std
::
vector
<
double
>
_bornForce
;
std
::
vector
<
Real
Vec
>
_gkField
;
std
::
vector
<
Vec
3
>
_gkField
;
std
::
vector
<
Real
Vec
>
_inducedDipoleS
;
std
::
vector
<
Vec
3
>
_inducedDipoleS
;
std
::
vector
<
Real
Vec
>
_inducedDipolePolarS
;
std
::
vector
<
Vec
3
>
_inducedDipolePolarS
;
std
::
vector
<
std
::
vector
<
Real
Vec
>
>
_ptDipolePS
;
std
::
vector
<
std
::
vector
<
Vec
3
>
>
_ptDipolePS
;
std
::
vector
<
std
::
vector
<
Real
Vec
>
>
_ptDipoleDS
;
std
::
vector
<
std
::
vector
<
Vec
3
>
>
_ptDipoleDS
;
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>
_ptDipoleFieldGradientPS
;
std
::
vector
<
std
::
vector
<
double
>
>
_ptDipoleFieldGradientPS
;
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>
_ptDipoleFieldGradientDS
;
std
::
vector
<
std
::
vector
<
double
>
>
_ptDipoleFieldGradientDS
;
int
_includeCavityTerm
;
int
_includeCavityTerm
;
RealOpenMM
_probeRadius
;
double
_probeRadius
;
RealOpenMM
_surfaceAreaFactor
;
double
_surfaceAreaFactor
;
RealOpenMM
_dielectricOffset
;
double
_dielectricOffset
;
/**
/**
* Zero fixed multipole fields.
* Zero fixed multipole fields.
...
@@ -1318,7 +1318,7 @@ private:
...
@@ -1318,7 +1318,7 @@ private:
* @param pScale p-scale value for i-j interaction
* @param pScale p-scale value for i-j interaction
*/
*/
void
calculateFixedMultipoleFieldPairIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
void
calculateFixedMultipoleFieldPairIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
RealOpenMM
dScale
,
RealOpenMM
pScale
);
double
dScale
,
double
pScale
);
/**
/**
* Calculate induced dipoles.
* Calculate induced dipoles.
...
@@ -1346,9 +1346,9 @@ private:
...
@@ -1346,9 +1346,9 @@ private:
*
*
* @return energy
* @return energy
*/
*/
RealOpenMM
calculateElectrostatic
(
const
std
::
vector
<
MultipoleParticleData
>&
particleData
,
double
calculateElectrostatic
(
const
std
::
vector
<
MultipoleParticleData
>&
particleData
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
torques
,
std
::
vector
<
OpenMM
::
Vec
3
>&
torques
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
);
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
);
/**
/**
* Calculate GK field at particle I due induced dipole at particle J and vice versa
* Calculate GK field at particle I due induced dipole at particle J and vice versa
...
@@ -1360,7 +1360,7 @@ private:
...
@@ -1360,7 +1360,7 @@ private:
* @param fieldPolar vector of induced dipole polar fields
* @param fieldPolar vector of induced dipole polar fields
*/
*/
void
calculateInducedDipolePairGkIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
void
calculateInducedDipolePairGkIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
const
std
::
vector
<
Real
Vec
>&
field
,
std
::
vector
<
Real
Vec
>&
fieldPolar
)
const
;
const
std
::
vector
<
Vec
3
>&
field
,
std
::
vector
<
Vec
3
>&
fieldPolar
)
const
;
/**
/**
* Calculate Kirkwood interaction.
* Calculate Kirkwood interaction.
...
@@ -1373,10 +1373,10 @@ private:
...
@@ -1373,10 +1373,10 @@ private:
*
*
* @return energy
* @return energy
*/
*/
RealOpenMM
calculateKirkwoodPairIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
double
calculateKirkwoodPairIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
std
::
vector
<
Real
Vec
>&
forces
,
std
::
vector
<
Vec
3
>&
forces
,
std
::
vector
<
Real
Vec
>&
torques
,
std
::
vector
<
Vec
3
>&
torques
,
std
::
vector
<
RealOpenMM
>&
dBorn
)
const
;
std
::
vector
<
double
>&
dBorn
)
const
;
/**
/**
* Calculate Grycuk 'chain-rule' force.
* Calculate Grycuk 'chain-rule' force.
...
@@ -1388,7 +1388,7 @@ private:
...
@@ -1388,7 +1388,7 @@ private:
*
*
*/
*/
void
calculateGrycukChainRulePairIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
void
calculateGrycukChainRulePairIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
const
std
::
vector
<
RealOpenMM
>&
dBorn
,
std
::
vector
<
Real
Vec
>&
forces
)
const
;
const
std
::
vector
<
double
>&
dBorn
,
std
::
vector
<
Vec
3
>&
forces
)
const
;
/**
/**
* Calculate TINKER's ACE approximation to non-polar cavity term.
* Calculate TINKER's ACE approximation to non-polar cavity term.
...
@@ -1398,7 +1398,7 @@ private:
...
@@ -1398,7 +1398,7 @@ private:
* @return ACE energy
* @return ACE energy
*
*
*/
*/
RealOpenMM
calculateCavityTermEnergyAndForces
(
std
::
vector
<
RealOpenMM
>&
dBorn
)
const
;
double
calculateCavityTermEnergyAndForces
(
std
::
vector
<
double
>&
dBorn
)
const
;
/**
/**
* Correct vacuum to SCRF derivatives (TINKER's ediff1()).
* Correct vacuum to SCRF derivatives (TINKER's ediff1()).
...
@@ -1412,9 +1412,9 @@ private:
...
@@ -1412,9 +1412,9 @@ private:
*
*
* @return energy
* @return energy
*/
*/
RealOpenMM
calculateKirkwoodEDiffPairIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
double
calculateKirkwoodEDiffPairIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
RealOpenMM
pscale
,
RealOpenMM
dscale
,
double
pscale
,
double
dscale
,
std
::
vector
<
Real
Vec
>&
forces
,
std
::
vector
<
Real
Vec
>&
torques
)
const
;
std
::
vector
<
Vec
3
>&
forces
,
std
::
vector
<
Vec
3
>&
torques
)
const
;
};
};
...
@@ -1440,7 +1440,7 @@ public:
...
@@ -1440,7 +1440,7 @@ public:
* @return cutoff distance
* @return cutoff distance
*
*
*/
*/
RealOpenMM
getCutoffDistance
()
const
;
double
getCutoffDistance
()
const
;
/**
/**
* Set cutoff distance.
* Set cutoff distance.
...
@@ -1448,7 +1448,7 @@ public:
...
@@ -1448,7 +1448,7 @@ public:
* @return cutoff distance
* @return cutoff distance
*
*
*/
*/
void
setCutoffDistance
(
RealOpenMM
cutoffDistance
);
void
setCutoffDistance
(
double
cutoffDistance
);
/**
/**
* Get alpha used in Ewald summation.
* Get alpha used in Ewald summation.
...
@@ -1456,7 +1456,7 @@ public:
...
@@ -1456,7 +1456,7 @@ public:
* @return alpha
* @return alpha
*
*
*/
*/
RealOpenMM
getAlphaEwald
()
const
;
double
getAlphaEwald
()
const
;
/**
/**
* Set alpha used in Ewald summation.
* Set alpha used in Ewald summation.
...
@@ -1464,7 +1464,7 @@ public:
...
@@ -1464,7 +1464,7 @@ public:
* @return alpha
* @return alpha
*
*
*/
*/
void
setAlphaEwald
(
RealOpenMM
alphaEwald
);
void
setAlphaEwald
(
double
alphaEwald
);
/**
/**
* Get PME grid dimensions.
* Get PME grid dimensions.
...
@@ -1488,19 +1488,19 @@ public:
...
@@ -1488,19 +1488,19 @@ public:
*
*
* @param vectors the vectors defining the periodic box
* @param vectors the vectors defining the periodic box
*/
*/
void
setPeriodicBoxSize
(
OpenMM
::
Real
Vec
*
vectors
);
void
setPeriodicBoxSize
(
OpenMM
::
Vec
3
*
vectors
);
private:
private:
static
const
int
AMOEBA_PME_ORDER
;
static
const
int
AMOEBA_PME_ORDER
;
static
const
RealOpenMM
SQRT_PI
;
static
const
double
SQRT_PI
;
RealOpenMM
_alphaEwald
;
double
_alphaEwald
;
RealOpenMM
_cutoffDistance
;
double
_cutoffDistance
;
RealOpenMM
_cutoffDistanceSquared
;
double
_cutoffDistanceSquared
;
Real
Vec
_recipBoxVectors
[
3
];
Vec
3
_recipBoxVectors
[
3
];
Real
Vec
_periodicBoxVectors
[
3
];
Vec
3
_periodicBoxVectors
[
3
];
int
_totalGridSize
;
int
_totalGridSize
;
IntVec
_pmeGridDimensions
;
IntVec
_pmeGridDimensions
;
...
@@ -1510,15 +1510,15 @@ private:
...
@@ -1510,15 +1510,15 @@ private:
unsigned
int
_pmeGridSize
;
unsigned
int
_pmeGridSize
;
t_complex
*
_pmeGrid
;
t_complex
*
_pmeGrid
;
std
::
vector
<
RealOpenMM
>
_pmeBsplineModuli
[
3
];
std
::
vector
<
double
>
_pmeBsplineModuli
[
3
];
std
::
vector
<
RealOpenMM
4
>
_thetai
[
3
];
std
::
vector
<
double
4
>
_thetai
[
3
];
std
::
vector
<
IntVec
>
_iGrid
;
std
::
vector
<
IntVec
>
_iGrid
;
std
::
vector
<
RealOpenMM
>
_phi
;
std
::
vector
<
double
>
_phi
;
std
::
vector
<
RealOpenMM
>
_phid
;
std
::
vector
<
double
>
_phid
;
std
::
vector
<
RealOpenMM
>
_phip
;
std
::
vector
<
double
>
_phip
;
std
::
vector
<
RealOpenMM
>
_phidp
;
std
::
vector
<
double
>
_phidp
;
std
::
vector
<
RealOpenMM
4
>
_pmeBsplineTheta
;
std
::
vector
<
double
4
>
_pmeBsplineTheta
;
std
::
vector
<
RealOpenMM
4
>
_pmeBsplineDtheta
;
std
::
vector
<
double
4
>
_pmeBsplineDtheta
;
/**
/**
* Resize PME arrays.
* Resize PME arrays.
...
@@ -1537,7 +1537,7 @@ private:
...
@@ -1537,7 +1537,7 @@ private:
* @param delta input vector of difference in particle positions; on output adjusted for
* @param delta input vector of difference in particle positions; on output adjusted for
* periodic boundary conditions
* periodic boundary conditions
*/
*/
void
getPeriodicDelta
(
Real
Vec
&
deltaR
)
const
;
void
getPeriodicDelta
(
Vec
3
&
deltaR
)
const
;
/**
/**
* Calculate damped inverse distances.
* Calculate damped inverse distances.
...
@@ -1550,8 +1550,8 @@ private:
...
@@ -1550,8 +1550,8 @@ private:
* @param dampedPInverseDistances damped inverse distances (prr3,prr5,prr7 in udirect2a() in TINKER)
* @param dampedPInverseDistances damped inverse distances (prr3,prr5,prr7 in udirect2a() in TINKER)
*/
*/
void
getDampedInverseDistances
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
void
getDampedInverseDistances
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
RealOpenMM
dscale
,
RealOpenMM
pscale
,
RealOpenMM
r
,
double
dscale
,
double
pscale
,
double
r
,
Real
Vec
&
dampedDInverseDistances
,
Real
Vec
&
dampedPInverseDistances
)
const
;
Vec
3
&
dampedDInverseDistances
,
Vec
3
&
dampedPInverseDistances
)
const
;
/**
/**
* Initialize B-spline moduli.
* Initialize B-spline moduli.
...
@@ -1568,7 +1568,7 @@ private:
...
@@ -1568,7 +1568,7 @@ private:
* @param pScale p-scale value for i-j interaction
* @param pScale p-scale value for i-j interaction
*/
*/
void
calculateFixedMultipoleFieldPairIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
void
calculateFixedMultipoleFieldPairIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
RealOpenMM
dscale
,
RealOpenMM
pscale
);
double
dscale
,
double
pscale
);
/**
/**
* Calculate fixed multipole fields.
* Calculate fixed multipole fields.
...
@@ -1584,7 +1584,7 @@ private:
...
@@ -1584,7 +1584,7 @@ private:
* @param thetai output spline coefficients
* @param thetai output spline coefficients
* @param w offset from grid point
* @param w offset from grid point
*/
*/
void
computeBSplinePoint
(
std
::
vector
<
RealOpenMM
4
>&
thetai
,
RealOpenMM
w
);
void
computeBSplinePoint
(
std
::
vector
<
double
4
>&
thetai
,
double
w
);
/**
/**
* Compute bspline coefficients.
* Compute bspline coefficients.
...
@@ -1601,7 +1601,7 @@ private:
...
@@ -1601,7 +1601,7 @@ private:
/**
/**
* Transform potential from fractional coordinates to cartesian coordinates.
* Transform potential from fractional coordinates to cartesian coordinates.
*/
*/
void
transformPotentialToCartesianCoordinates
(
const
std
::
vector
<
RealOpenMM
>&
fphi
,
std
::
vector
<
RealOpenMM
>&
cphi
)
const
;
void
transformPotentialToCartesianCoordinates
(
const
std
::
vector
<
double
>&
fphi
,
std
::
vector
<
double
>&
cphi
)
const
;
/**
/**
* Spread fixed multipoles onto PME grid.
* Spread fixed multipoles onto PME grid.
...
@@ -1637,8 +1637,8 @@ private:
...
@@ -1637,8 +1637,8 @@ private:
*
*
* @return energy
* @return energy
*/
*/
RealOpenMM
computeReciprocalSpaceFixedMultipoleForceAndEnergy
(
const
std
::
vector
<
MultipoleParticleData
>&
particleData
,
double
computeReciprocalSpaceFixedMultipoleForceAndEnergy
(
const
std
::
vector
<
MultipoleParticleData
>&
particleData
,
std
::
vector
<
Real
Vec
>&
forces
,
std
::
vector
<
Real
Vec
>&
torques
)
const
;
std
::
vector
<
Vec
3
>&
forces
,
std
::
vector
<
Vec
3
>&
torques
)
const
;
/**
/**
* Set reciprocal space fixed multipole fields.
* Set reciprocal space fixed multipole fields.
...
@@ -1665,9 +1665,9 @@ private:
...
@@ -1665,9 +1665,9 @@ private:
* @param field vector of field at each particle due induced dipole of other particles
* @param field vector of field at each particle due induced dipole of other particles
*/
*/
void
calculateDirectInducedDipolePairIxn
(
unsigned
int
iIndex
,
unsigned
int
jIndex
,
void
calculateDirectInducedDipolePairIxn
(
unsigned
int
iIndex
,
unsigned
int
jIndex
,
RealOpenMM
preFactor1
,
RealOpenMM
preFactor2
,
const
Real
Vec
&
delta
,
double
preFactor1
,
double
preFactor2
,
const
Vec
3
&
delta
,
const
std
::
vector
<
Real
Vec
>&
inducedDipole
,
const
std
::
vector
<
Vec
3
>&
inducedDipole
,
std
::
vector
<
Real
Vec
>&
field
)
const
;
std
::
vector
<
Vec
3
>&
field
)
const
;
/**
/**
* Calculate direct space field at particleI due to induced dipole at particle J and vice versa for
* Calculate direct space field at particleI due to induced dipole at particle J and vice versa for
...
@@ -1694,8 +1694,8 @@ private:
...
@@ -1694,8 +1694,8 @@ private:
* @param inputInducedDipole induced dipole value
* @param inputInducedDipole induced dipole value
* @param inputInducedDipolePolar induced dipole polar value
* @param inputInducedDipolePolar induced dipole polar value
*/
*/
void
spreadInducedDipolesOnGrid
(
const
std
::
vector
<
Real
Vec
>&
inputInducedDipole
,
void
spreadInducedDipolesOnGrid
(
const
std
::
vector
<
Vec
3
>&
inputInducedDipole
,
const
std
::
vector
<
Real
Vec
>&
inputInducedDipolePolar
);
const
std
::
vector
<
Vec
3
>&
inputInducedDipolePolar
);
/**
/**
* Calculate induced dipole fields.
* Calculate induced dipole fields.
...
@@ -1713,14 +1713,14 @@ private:
...
@@ -1713,14 +1713,14 @@ private:
* @param fieldPolar reciprocal space output induced dipole polar field value at each site
* @param fieldPolar reciprocal space output induced dipole polar field value at each site
*
*
*/
*/
void
recordInducedDipoleField
(
vector
<
Real
Vec
>&
field
,
vector
<
Real
Vec
>&
fieldPolar
);
void
recordInducedDipoleField
(
vector
<
Vec
3
>&
field
,
vector
<
Vec
3
>&
fieldPolar
);
/**
/**
* Compute Pme self energy.
* Compute Pme self energy.
*
*
* @param particleData vector of parameters (charge, labFrame dipoles, quadrupoles, ...) for particles
* @param particleData vector of parameters (charge, labFrame dipoles, quadrupoles, ...) for particles
*/
*/
RealOpenMM
calculatePmeSelfEnergy
(
const
std
::
vector
<
MultipoleParticleData
>&
particleData
)
const
;
double
calculatePmeSelfEnergy
(
const
std
::
vector
<
MultipoleParticleData
>&
particleData
)
const
;
/**
/**
* Compute the self torques.
* Compute the self torques.
...
@@ -1728,7 +1728,7 @@ private:
...
@@ -1728,7 +1728,7 @@ private:
* @param particleData vector of parameters (charge, labFrame dipoles, quadrupoles, ...) for particles
* @param particleData vector of parameters (charge, labFrame dipoles, quadrupoles, ...) for particles
* @param torques vector of torques
* @param torques vector of torques
*/
*/
void
calculatePmeSelfTorque
(
const
std
::
vector
<
MultipoleParticleData
>&
particleData
,
std
::
vector
<
Real
Vec
>&
torques
)
const
;
void
calculatePmeSelfTorque
(
const
std
::
vector
<
MultipoleParticleData
>&
particleData
,
std
::
vector
<
Vec
3
>&
torques
)
const
;
/**
/**
* Calculate direct space electrostatic interaction between particles I and J.
* Calculate direct space electrostatic interaction between particles I and J.
...
@@ -1739,9 +1739,9 @@ private:
...
@@ -1739,9 +1739,9 @@ private:
* @param forces vector of particle forces to be updated
* @param forces vector of particle forces to be updated
* @param torques vector of particle torques to be updated
* @param torques vector of particle torques to be updated
*/
*/
RealOpenMM
calculatePmeDirectElectrostaticPairIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
double
calculatePmeDirectElectrostaticPairIxn
(
const
MultipoleParticleData
&
particleI
,
const
MultipoleParticleData
&
particleJ
,
const
std
::
vector
<
RealOpenMM
>&
scalingFactors
,
const
std
::
vector
<
double
>&
scalingFactors
,
std
::
vector
<
Real
Vec
>&
forces
,
std
::
vector
<
Real
Vec
>&
torques
)
const
;
std
::
vector
<
Vec
3
>&
forces
,
std
::
vector
<
Vec
3
>&
torques
)
const
;
/**
/**
* Calculate reciprocal space energy/force/torque for dipole interaction.
* Calculate reciprocal space energy/force/torque for dipole interaction.
...
@@ -1752,9 +1752,9 @@ private:
...
@@ -1752,9 +1752,9 @@ private:
* @param forces vector of particle forces to be updated
* @param forces vector of particle forces to be updated
* @param torques vector of particle torques to be updated
* @param torques vector of particle torques to be updated
*/
*/
RealOpenMM
computeReciprocalSpaceInducedDipoleForceAndEnergy
(
AmoebaReferenceMultipoleForce
::
PolarizationType
polarizationType
,
double
computeReciprocalSpaceInducedDipoleForceAndEnergy
(
AmoebaReferenceMultipoleForce
::
PolarizationType
polarizationType
,
const
std
::
vector
<
MultipoleParticleData
>&
particleData
,
const
std
::
vector
<
MultipoleParticleData
>&
particleData
,
std
::
vector
<
Real
Vec
>&
forces
,
std
::
vector
<
Real
Vec
>&
torques
)
const
;
std
::
vector
<
Vec
3
>&
forces
,
std
::
vector
<
Vec
3
>&
torques
)
const
;
/**
/**
* Calculate electrostatic forces.
* Calculate electrostatic forces.
...
@@ -1765,9 +1765,9 @@ private:
...
@@ -1765,9 +1765,9 @@ private:
*
*
* @return energy
* @return energy
*/
*/
RealOpenMM
calculateElectrostatic
(
const
std
::
vector
<
MultipoleParticleData
>&
particleData
,
double
calculateElectrostatic
(
const
std
::
vector
<
MultipoleParticleData
>&
particleData
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
torques
,
std
::
vector
<
OpenMM
::
Vec
3
>&
torques
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
);
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
);
};
};
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceOutOfPlaneBendForce.cpp
View file @
a783b996
...
@@ -24,11 +24,12 @@
...
@@ -24,11 +24,12 @@
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceOutOfPlaneBendForce.h"
#include "AmoebaReferenceOutOfPlaneBendForce.h"
#include "SimTKOpenMMRealType.h"
using
std
::
vector
;
using
std
::
vector
;
using
namespace
OpenMM
;
using
namespace
OpenMM
;
void
AmoebaReferenceOutOfPlaneBendForce
::
setPeriodic
(
OpenMM
::
Real
Vec
*
vectors
)
{
void
AmoebaReferenceOutOfPlaneBendForce
::
setPeriodic
(
OpenMM
::
Vec
3
*
vectors
)
{
usePeriodic
=
true
;
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
1
]
=
vectors
[
1
];
...
@@ -55,34 +56,20 @@ void AmoebaReferenceOutOfPlaneBendForce::setPeriodic(OpenMM::RealVec* vectors) {
...
@@ -55,34 +56,20 @@ void AmoebaReferenceOutOfPlaneBendForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
AmoebaReferenceOutOfPlaneBendForce
::
calculateOutOfPlaneBendIxn
(
const
RealVec
&
positionAtomA
,
const
RealVec
&
positionAtomB
,
double
AmoebaReferenceOutOfPlaneBendForce
::
calculateOutOfPlaneBendIxn
(
const
Vec3
&
positionAtomA
,
const
Vec3
&
positionAtomB
,
const
RealVec
&
positionAtomC
,
const
RealVec
&
positionAtomD
,
const
Vec3
&
positionAtomC
,
const
Vec3
&
positionAtomD
,
RealOpenMM
angleK
,
double
angleK
,
RealOpenMM
angleCubic
,
RealOpenMM
angleQuartic
,
double
angleCubic
,
double
angleQuartic
,
RealOpenMM
anglePentic
,
RealOpenMM
angleSextic
,
double
anglePentic
,
double
angleSextic
,
RealVec
*
forces
)
const
{
Vec3
*
forces
)
const
{
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn";
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
static
const
RealOpenMM
two
=
2.0
;
static
const
RealOpenMM
three
=
3.0
;
static
const
RealOpenMM
four
=
4.0
;
static
const
RealOpenMM
five
=
5.0
;
static
const
RealOpenMM
six
=
6.0
;
enum
{
A
,
B
,
C
,
D
,
LastAtomIndex
};
enum
{
A
,
B
,
C
,
D
,
LastAtomIndex
};
enum
{
AB
,
CB
,
DB
,
AD
,
CD
,
LastDeltaIndex
};
enum
{
AB
,
CB
,
DB
,
AD
,
CD
,
LastDeltaIndex
};
// ---------------------------------------------------------------------------------------
// get deltaR between various combinations of the 4 atoms
// get deltaR between various combinations of the 4 atoms
// and various intermediate terms
// and various intermediate terms
std
::
vector
<
RealOpenMM
>
deltaR
[
LastDeltaIndex
];
std
::
vector
<
double
>
deltaR
[
LastDeltaIndex
];
for
(
int
ii
=
0
;
ii
<
LastDeltaIndex
;
ii
++
)
{
for
(
int
ii
=
0
;
ii
<
LastDeltaIndex
;
ii
++
)
{
deltaR
[
ii
].
resize
(
3
);
deltaR
[
ii
].
resize
(
3
);
}
}
...
@@ -101,52 +88,52 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
...
@@ -101,52 +88,52 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomD
,
positionAtomC
,
deltaR
[
CD
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomD
,
positionAtomC
,
deltaR
[
CD
]);
}
}
RealOpenMM
rDB2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
DB
]);
double
rDB2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
DB
]);
RealOpenMM
rAD2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
AD
]);
double
rAD2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
AD
]);
RealOpenMM
rCD2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
CD
]);
double
rCD2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
CD
]);
std
::
vector
<
RealOpenMM
>
tempVector
(
3
);
std
::
vector
<
double
>
tempVector
(
3
);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
CB
],
deltaR
[
DB
],
tempVector
);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
CB
],
deltaR
[
DB
],
tempVector
);
RealOpenMM
eE
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
AB
],
tempVector
);
double
eE
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
AB
],
tempVector
);
RealOpenMM
dot
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
AD
],
deltaR
[
CD
]);
double
dot
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
AD
],
deltaR
[
CD
]);
RealOpenMM
cc
=
rAD2
*
rCD2
-
dot
*
dot
;
double
cc
=
rAD2
*
rCD2
-
dot
*
dot
;
if
(
rDB2
<=
zero
||
cc
==
zero
)
{
if
(
rDB2
<=
0.0
||
cc
==
0.0
)
{
return
zero
;
return
0.0
;
}
}
RealOpenMM
bkk2
=
rDB2
-
eE
*
eE
/
cc
;
double
bkk2
=
rDB2
-
eE
*
eE
/
cc
;
RealOpenMM
cosine
=
SQRT
(
bkk2
/
rDB2
);
double
cosine
=
sqrt
(
bkk2
/
rDB2
);
RealOpenMM
angle
;
double
angle
;
if
(
cosine
>=
one
)
{
if
(
cosine
>=
1.0
)
{
angle
=
zero
;
angle
=
0.0
;
}
else
if
(
cosine
<=
-
one
)
{
}
else
if
(
cosine
<=
-
1.0
)
{
angle
=
PI
_M
;
angle
=
M_
PI
;
}
else
{
}
else
{
angle
=
RADIAN
*
ACOS
(
cosine
);
angle
=
RADIAN
*
acos
(
cosine
);
}
}
// chain rule
// chain rule
RealOpenMM
dt
=
angle
;
double
dt
=
angle
;
RealOpenMM
dt2
=
dt
*
dt
;
double
dt2
=
dt
*
dt
;
RealOpenMM
dt3
=
dt2
*
dt
;
double
dt3
=
dt2
*
dt
;
RealOpenMM
dt4
=
dt2
*
dt2
;
double
dt4
=
dt2
*
dt2
;
RealOpenMM
dEdDt
=
two
+
three
*
angleCubic
*
dt
+
four
*
angleQuartic
*
dt2
+
double
dEdDt
=
2.0
+
3.0
*
angleCubic
*
dt
+
4.0
*
angleQuartic
*
dt2
+
five
*
anglePentic
*
dt3
+
six
*
angleSextic
*
dt4
;
5.0
*
anglePentic
*
dt3
+
6.0
*
angleSextic
*
dt4
;
dEdDt
*=
angleK
*
dt
*
RADIAN
;
dEdDt
*=
angleK
*
dt
*
RADIAN
;
RealOpenMM
dEdCos
=
dEdDt
/
SQRT
(
cc
*
bkk2
);
double
dEdCos
=
dEdDt
/
sqrt
(
cc
*
bkk2
);
if
(
eE
>
zero
)
{
if
(
eE
>
0.0
)
{
dEdCos
*=
-
one
;
dEdCos
*=
-
1.0
;
}
}
RealOpenMM
term
=
eE
/
cc
;
double
term
=
eE
/
cc
;
std
::
vector
<
RealOpenMM
>
dccd
[
LastAtomIndex
];
std
::
vector
<
double
>
dccd
[
LastAtomIndex
];
std
::
vector
<
RealOpenMM
>
deed
[
LastAtomIndex
];
std
::
vector
<
double
>
deed
[
LastAtomIndex
];
std
::
vector
<
RealOpenMM
>
subForce
[
LastAtomIndex
];
std
::
vector
<
double
>
subForce
[
LastAtomIndex
];
for
(
int
ii
=
0
;
ii
<
LastAtomIndex
;
ii
++
)
{
for
(
int
ii
=
0
;
ii
<
LastAtomIndex
;
ii
++
)
{
dccd
[
ii
].
resize
(
3
);
dccd
[
ii
].
resize
(
3
);
deed
[
ii
].
resize
(
3
);
deed
[
ii
].
resize
(
3
);
...
@@ -155,7 +142,7 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
...
@@ -155,7 +142,7 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
for
(
int
ii
=
0
;
ii
<
3
;
ii
++
)
{
for
(
int
ii
=
0
;
ii
<
3
;
ii
++
)
{
dccd
[
A
][
ii
]
=
(
deltaR
[
AD
][
ii
]
*
rCD2
-
deltaR
[
CD
][
ii
]
*
dot
)
*
term
;
dccd
[
A
][
ii
]
=
(
deltaR
[
AD
][
ii
]
*
rCD2
-
deltaR
[
CD
][
ii
]
*
dot
)
*
term
;
dccd
[
C
][
ii
]
=
(
deltaR
[
CD
][
ii
]
*
rAD2
-
deltaR
[
AD
][
ii
]
*
dot
)
*
term
;
dccd
[
C
][
ii
]
=
(
deltaR
[
CD
][
ii
]
*
rAD2
-
deltaR
[
AD
][
ii
]
*
dot
)
*
term
;
dccd
[
D
][
ii
]
=
-
one
*
(
dccd
[
A
][
ii
]
+
dccd
[
C
][
ii
]);
dccd
[
D
][
ii
]
=
-
1.0
*
(
dccd
[
A
][
ii
]
+
dccd
[
C
][
ii
]);
}
}
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
DB
],
deltaR
[
CB
],
deed
[
A
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
DB
],
deltaR
[
CB
],
deed
[
A
]);
...
@@ -189,7 +176,7 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
...
@@ -189,7 +176,7 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
if
(
jj
==
3
)
{
if
(
jj
==
3
)
{
for
(
int
ii
=
0
;
ii
<
3
;
ii
++
)
{
for
(
int
ii
=
0
;
ii
<
3
;
ii
++
)
{
subForce
[
1
][
ii
]
=
-
one
*
(
subForce
[
0
][
ii
]
+
subForce
[
2
][
ii
]
+
subForce
[
3
][
ii
]);
subForce
[
1
][
ii
]
=
-
1.0
*
(
subForce
[
0
][
ii
]
+
subForce
[
2
][
ii
]
+
subForce
[
3
][
ii
]);
}
}
}
}
}
}
...
@@ -206,31 +193,31 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
...
@@ -206,31 +193,31 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
// calculate energy if 'energy' is set
// calculate energy if 'energy' is set
RealOpenMM
energy
=
one
+
angleCubic
*
dt
+
angleQuartic
*
dt2
+
anglePentic
*
dt3
+
angleSextic
*
dt4
;
double
energy
=
1.0
+
angleCubic
*
dt
+
angleQuartic
*
dt2
+
anglePentic
*
dt3
+
angleSextic
*
dt4
;
energy
*=
angleK
*
dt2
;
energy
*=
angleK
*
dt2
;
return
energy
;
return
energy
;
}
}
RealOpenMM
AmoebaReferenceOutOfPlaneBendForce
::
calculateForceAndEnergy
(
int
numOutOfPlaneBends
,
vector
<
Real
Vec
>&
posData
,
double
AmoebaReferenceOutOfPlaneBendForce
::
calculateForceAndEnergy
(
int
numOutOfPlaneBends
,
vector
<
Vec
3
>&
posData
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle4
,
const
std
::
vector
<
int
>&
particle4
,
const
std
::
vector
<
RealOpenMM
>&
kQuadratic
,
const
std
::
vector
<
double
>&
kQuadratic
,
RealOpenMM
angleCubic
,
double
angleCubic
,
RealOpenMM
angleQuartic
,
double
angleQuartic
,
RealOpenMM
anglePentic
,
double
anglePentic
,
RealOpenMM
angleSextic
,
double
angleSextic
,
vector
<
Real
Vec
>&
forceData
)
const
{
vector
<
Vec
3
>&
forceData
)
const
{
RealOpenMM
energy
=
0.0
;
double
energy
=
0.0
;
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
numOutOfPlaneBends
);
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
numOutOfPlaneBends
);
ii
++
)
{
int
particle1Index
=
particle1
[
ii
];
int
particle1Index
=
particle1
[
ii
];
int
particle2Index
=
particle2
[
ii
];
int
particle2Index
=
particle2
[
ii
];
int
particle3Index
=
particle3
[
ii
];
int
particle3Index
=
particle3
[
ii
];
int
particle4Index
=
particle4
[
ii
];
int
particle4Index
=
particle4
[
ii
];
RealOpenMM
kAngle
=
kQuadratic
[
ii
];
double
kAngle
=
kQuadratic
[
ii
];
Real
Vec
forces
[
4
];
Vec
3
forces
[
4
];
energy
+=
calculateOutOfPlaneBendIxn
(
posData
[
particle1Index
],
posData
[
particle2Index
],
posData
[
particle3Index
],
posData
[
particle4Index
],
energy
+=
calculateOutOfPlaneBendIxn
(
posData
[
particle1Index
],
posData
[
particle2Index
],
posData
[
particle3Index
],
posData
[
particle4Index
],
kAngle
,
angleCubic
,
angleQuartic
,
anglePentic
,
angleSextic
,
forces
);
kAngle
,
angleCubic
,
angleQuartic
,
anglePentic
,
angleSextic
,
forces
);
for
(
int
jj
=
0
;
jj
<
3
;
jj
++
)
{
for
(
int
jj
=
0
;
jj
<
3
;
jj
++
)
{
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceOutOfPlaneBendForce.h
View file @
a783b996
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceOutOfPlaneBendForce_H__
#ifndef __AmoebaReferenceOutOfPlaneBendForce_H__
#define __AmoebaReferenceOutOfPlaneBendForce_H__
#define __AmoebaReferenceOutOfPlaneBendForce_H__
#include "
Real
Vec.h"
#include "
openmm/
Vec
3
.h"
#include <vector>
#include <vector>
namespace
OpenMM
{
namespace
OpenMM
{
...
@@ -58,7 +58,7 @@ public:
...
@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
Real
Vec
*
vectors
);
void
setPeriodic
(
OpenMM
::
Vec
3
*
vectors
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -82,22 +82,22 @@ public:
...
@@ -82,22 +82,22 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
calculateForceAndEnergy
(
int
numOutOfPlaneBends
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
posData
,
double
calculateForceAndEnergy
(
int
numOutOfPlaneBends
,
std
::
vector
<
OpenMM
::
Vec
3
>&
posData
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle4
,
const
std
::
vector
<
int
>&
particle4
,
const
std
::
vector
<
RealOpenMM
>&
kAngle
,
const
std
::
vector
<
double
>&
kAngle
,
RealOpenMM
angleCubic
,
double
angleCubic
,
RealOpenMM
angleQuartic
,
double
angleQuartic
,
RealOpenMM
anglePentic
,
double
anglePentic
,
RealOpenMM
angleSextic
,
double
angleSextic
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forceData
)
const
;
std
::
vector
<
OpenMM
::
Vec
3
>&
forceData
)
const
;
private:
private:
bool
usePeriodic
;
bool
usePeriodic
;
Real
Vec
boxVectors
[
3
];
Vec
3
boxVectors
[
3
];
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -118,13 +118,12 @@ private:
...
@@ -118,13 +118,12 @@ private:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
calculateOutOfPlaneBendIxn
(
const
OpenMM
::
RealVec
&
positionAtomA
,
const
OpenMM
::
RealVec
&
positionAtomB
,
double
calculateOutOfPlaneBendIxn
(
const
OpenMM
::
Vec3
&
positionAtomA
,
const
OpenMM
::
Vec3
&
positionAtomB
,
const
OpenMM
::
RealVec
&
positionAtomC
,
const
OpenMM
::
RealVec
&
positionAtomD
,
const
OpenMM
::
Vec3
&
positionAtomC
,
const
OpenMM
::
Vec3
&
positionAtomD
,
RealOpenMM
angleK
,
double
angleK
,
RealOpenMM
angleCubic
,
RealOpenMM
angleQuartic
,
double
angleCubic
,
double
angleQuartic
,
RealOpenMM
anglePentic
,
RealOpenMM
angleSextic
,
double
anglePentic
,
double
angleSextic
,
OpenMM
::
RealVec
*
forces
)
const
;
OpenMM
::
Vec3
*
forces
)
const
;
};
};
}
// namespace OpenMM
}
// namespace OpenMM
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferencePiTorsionForce.cpp
View file @
a783b996
...
@@ -23,12 +23,13 @@
...
@@ -23,12 +23,13 @@
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceForce.h"
#include "AmoebaReferencePiTorsionForce.h"
#include "AmoebaReferencePiTorsionForce.h"
#include <cmath>
#include <vector>
#include <vector>
using
std
::
vector
;
using
std
::
vector
;
using
namespace
OpenMM
;
using
namespace
OpenMM
;
void
AmoebaReferencePiTorsionForce
::
setPeriodic
(
OpenMM
::
Real
Vec
*
vectors
)
{
void
AmoebaReferencePiTorsionForce
::
setPeriodic
(
OpenMM
::
Vec
3
*
vectors
)
{
usePeriodic
=
true
;
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
1
]
=
vectors
[
1
];
...
@@ -52,24 +53,14 @@ void AmoebaReferencePiTorsionForce::setPeriodic(OpenMM::RealVec* vectors) {
...
@@ -52,24 +53,14 @@ void AmoebaReferencePiTorsionForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
AmoebaReferencePiTorsionForce
::
calculatePiTorsionIxn
(
const
RealVec
&
positionAtomA
,
const
RealVec
&
positionAtomB
,
double
AmoebaReferencePiTorsionForce
::
calculatePiTorsionIxn
(
const
Vec3
&
positionAtomA
,
const
Vec3
&
positionAtomB
,
const
RealVec
&
positionAtomC
,
const
RealVec
&
positionAtomD
,
const
Vec3
&
positionAtomC
,
const
Vec3
&
positionAtomD
,
const
RealVec
&
positionAtomE
,
const
RealVec
&
positionAtomF
,
const
Vec3
&
positionAtomE
,
const
Vec3
&
positionAtomF
,
RealOpenMM
piTorsionK
,
RealVec
*
forces
)
const
{
double
piTorsionK
,
Vec3
*
forces
)
const
{
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferencePiTorsionForce::calculatePiTorsionIxn";
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
static
const
RealOpenMM
two
=
2.0
;
// ---------------------------------------------------------------------------------------
enum
{
AD
,
BD
,
EC
,
FC
,
P
,
Q
,
CP
,
DC
,
QD
,
T
,
U
,
TU
,
DP
,
QC
,
dT
,
dU
,
dP
,
dQ
,
dC1
,
dC2
,
dD1
,
dD2
,
LastDeltaIndex
};
enum
{
AD
,
BD
,
EC
,
FC
,
P
,
Q
,
CP
,
DC
,
QD
,
T
,
U
,
TU
,
DP
,
QC
,
dT
,
dU
,
dP
,
dQ
,
dC1
,
dC2
,
dD1
,
dD2
,
LastDeltaIndex
};
std
::
vector
<
RealOpenMM
>
deltaR
[
LastDeltaIndex
];
std
::
vector
<
double
>
deltaR
[
LastDeltaIndex
];
for
(
unsigned
int
ii
=
0
;
ii
<
LastDeltaIndex
;
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
LastDeltaIndex
;
ii
++
)
{
deltaR
[
ii
].
resize
(
3
);
deltaR
[
ii
].
resize
(
3
);
}
}
...
@@ -87,7 +78,7 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p
...
@@ -87,7 +78,7 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p
}
}
enum
{
A
,
B
,
C
,
D
,
E
,
F
,
LastAtomIndex
};
enum
{
A
,
B
,
C
,
D
,
E
,
F
,
LastAtomIndex
};
std
::
vector
<
RealOpenMM
>
d
[
LastAtomIndex
];
std
::
vector
<
double
>
d
[
LastAtomIndex
];
for
(
unsigned
int
ii
=
0
;
ii
<
LastAtomIndex
;
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
LastAtomIndex
;
ii
++
)
{
d
[
ii
].
resize
(
3
);
d
[
ii
].
resize
(
3
);
}
}
...
@@ -106,36 +97,36 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p
...
@@ -106,36 +97,36 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
DC
],
deltaR
[
QD
],
deltaR
[
U
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
DC
],
deltaR
[
QD
],
deltaR
[
U
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
T
],
deltaR
[
U
],
deltaR
[
TU
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
T
],
deltaR
[
U
],
deltaR
[
TU
]);
RealOpenMM
rT2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
T
]);
double
rT2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
T
]);
RealOpenMM
rU2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
U
]);
double
rU2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
U
]);
RealOpenMM
rTrU
=
SQRT
(
rT2
*
rU2
);
double
rTrU
=
sqrt
(
rT2
*
rU2
);
if
(
rTrU
<=
zero
)
{
if
(
rTrU
<=
0.0
)
{
return
zero
;
return
0.0
;
}
}
RealOpenMM
rDC
=
AmoebaReferenceForce
::
getNorm3
(
deltaR
[
DC
]);
double
rDC
=
AmoebaReferenceForce
::
getNorm3
(
deltaR
[
DC
]);
RealOpenMM
cosine
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
T
],
deltaR
[
U
]);
double
cosine
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
T
],
deltaR
[
U
]);
cosine
/=
rTrU
;
cosine
/=
rTrU
;
RealOpenMM
sine
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
DC
],
deltaR
[
TU
]);
double
sine
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
DC
],
deltaR
[
TU
]);
sine
/=
(
rDC
*
rTrU
);
sine
/=
(
rDC
*
rTrU
);
RealOpenMM
cosine2
=
cosine
*
cosine
-
sine
*
sine
;
double
cosine2
=
cosine
*
cosine
-
sine
*
sine
;
RealOpenMM
sine2
=
two
*
cosine
*
sine
;
double
sine2
=
2.0
*
cosine
*
sine
;
RealOpenMM
phi2
=
one
-
cosine2
;
double
phi2
=
1.0
-
cosine2
;
RealOpenMM
dphi2
=
two
*
sine2
;
double
dphi2
=
2.0
*
sine2
;
RealOpenMM
dedphi
=
piTorsionK
*
dphi2
;
double
dedphi
=
piTorsionK
*
dphi2
;
for
(
unsigned
int
ii
=
0
;
ii
<
3
;
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
3
;
ii
++
)
{
deltaR
[
DP
][
ii
]
=
positionAtomD
[
ii
]
-
deltaR
[
P
][
ii
];
deltaR
[
DP
][
ii
]
=
positionAtomD
[
ii
]
-
deltaR
[
P
][
ii
];
deltaR
[
QC
][
ii
]
=
deltaR
[
Q
][
ii
]
-
positionAtomC
[
ii
];
deltaR
[
QC
][
ii
]
=
deltaR
[
Q
][
ii
]
-
positionAtomC
[
ii
];
}
}
RealOpenMM
factorT
=
dedphi
/
(
rDC
*
rT2
);
double
factorT
=
dedphi
/
(
rDC
*
rT2
);
RealOpenMM
factorU
=
-
dedphi
/
(
rDC
*
rU2
);
double
factorU
=
-
dedphi
/
(
rDC
*
rU2
);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
T
],
deltaR
[
DC
],
deltaR
[
dT
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
T
],
deltaR
[
DC
],
deltaR
[
dT
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
U
],
deltaR
[
DC
],
deltaR
[
dU
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
U
],
deltaR
[
DC
],
deltaR
[
dU
]);
...
@@ -200,16 +191,16 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p
...
@@ -200,16 +191,16 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p
}
}
RealOpenMM
AmoebaReferencePiTorsionForce
::
calculateForceAndEnergy
(
int
numPiTorsions
,
vector
<
Real
Vec
>&
posData
,
double
AmoebaReferencePiTorsionForce
::
calculateForceAndEnergy
(
int
numPiTorsions
,
vector
<
Vec
3
>&
posData
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle4
,
const
std
::
vector
<
int
>&
particle4
,
const
std
::
vector
<
int
>&
particle5
,
const
std
::
vector
<
int
>&
particle5
,
const
std
::
vector
<
int
>&
particle6
,
const
std
::
vector
<
int
>&
particle6
,
const
std
::
vector
<
RealOpenMM
>&
kTorsion
,
const
std
::
vector
<
double
>&
kTorsion
,
vector
<
Real
Vec
>&
forceData
)
const
{
vector
<
Vec
3
>&
forceData
)
const
{
RealOpenMM
energy
=
0.0
;
double
energy
=
0.0
;
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
numPiTorsions
);
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
numPiTorsions
);
ii
++
)
{
int
particle1Index
=
particle1
[
ii
];
int
particle1Index
=
particle1
[
ii
];
...
@@ -219,7 +210,7 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculateForceAndEnergy(int numPiTorsi
...
@@ -219,7 +210,7 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculateForceAndEnergy(int numPiTorsi
int
particle5Index
=
particle5
[
ii
];
int
particle5Index
=
particle5
[
ii
];
int
particle6Index
=
particle6
[
ii
];
int
particle6Index
=
particle6
[
ii
];
Real
Vec
forces
[
6
];
Vec
3
forces
[
6
];
energy
+=
calculatePiTorsionIxn
(
posData
[
particle1Index
],
posData
[
particle2Index
],
energy
+=
calculatePiTorsionIxn
(
posData
[
particle1Index
],
posData
[
particle2Index
],
posData
[
particle3Index
],
posData
[
particle4Index
],
posData
[
particle3Index
],
posData
[
particle4Index
],
posData
[
particle5Index
],
posData
[
particle6Index
],
posData
[
particle5Index
],
posData
[
particle6Index
],
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferencePiTorsionForce.h
View file @
a783b996
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#ifndef __AmoebaReferencePiTorsionForce_H__
#ifndef __AmoebaReferencePiTorsionForce_H__
#define __AmoebaReferencePiTorsionForce_H__
#define __AmoebaReferencePiTorsionForce_H__
#include "
Real
Vec.h"
#include "
openmm/
Vec
3
.h"
#include <vector>
#include <vector>
namespace
OpenMM
{
namespace
OpenMM
{
...
@@ -58,7 +58,7 @@ public:
...
@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
Real
Vec
*
vectors
);
void
setPeriodic
(
OpenMM
::
Vec
3
*
vectors
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -82,21 +82,21 @@ public:
...
@@ -82,21 +82,21 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
calculateForceAndEnergy
(
int
numPiTorsions
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
posData
,
double
calculateForceAndEnergy
(
int
numPiTorsions
,
std
::
vector
<
OpenMM
::
Vec
3
>&
posData
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle4
,
const
std
::
vector
<
int
>&
particle4
,
const
std
::
vector
<
int
>&
particle5
,
const
std
::
vector
<
int
>&
particle5
,
const
std
::
vector
<
int
>&
particle6
,
const
std
::
vector
<
int
>&
particle6
,
const
std
::
vector
<
RealOpenMM
>&
kTorsion
,
const
std
::
vector
<
double
>&
kTorsion
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forceData
)
const
;
std
::
vector
<
OpenMM
::
Vec
3
>&
forceData
)
const
;
private:
private:
bool
usePeriodic
;
bool
usePeriodic
;
Real
Vec
boxVectors
[
3
];
Vec
3
boxVectors
[
3
];
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -115,10 +115,10 @@ private:
...
@@ -115,10 +115,10 @@ private:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
calculatePiTorsionIxn
(
const
OpenMM
::
Real
Vec
&
positionAtomA
,
const
OpenMM
::
Real
Vec
&
positionAtomB
,
double
calculatePiTorsionIxn
(
const
OpenMM
::
Vec
3
&
positionAtomA
,
const
OpenMM
::
Vec
3
&
positionAtomB
,
const
OpenMM
::
Real
Vec
&
positionAtomC
,
const
OpenMM
::
Real
Vec
&
positionAtomD
,
const
OpenMM
::
Vec
3
&
positionAtomC
,
const
OpenMM
::
Vec
3
&
positionAtomD
,
const
OpenMM
::
Real
Vec
&
positionAtomE
,
const
OpenMM
::
Real
Vec
&
positionAtomF
,
const
OpenMM
::
Vec
3
&
positionAtomE
,
const
OpenMM
::
Vec
3
&
positionAtomF
,
RealOpenMM
kTorsion
,
OpenMM
::
Real
Vec
*
forces
)
const
;
double
kTorsion
,
OpenMM
::
Vec
3
*
forces
)
const
;
};
};
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceStretchBendForce.cpp
View file @
a783b996
...
@@ -24,12 +24,13 @@
...
@@ -24,12 +24,13 @@
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceStretchBendForce.h"
#include "AmoebaReferenceStretchBendForce.h"
#include "SimTKOpenMMRealType.h"
#include <vector>
#include <vector>
using
std
::
vector
;
using
std
::
vector
;
using
namespace
OpenMM
;
using
namespace
OpenMM
;
void
AmoebaReferenceStretchBendForce
::
setPeriodic
(
OpenMM
::
Real
Vec
*
vectors
)
{
void
AmoebaReferenceStretchBendForce
::
setPeriodic
(
OpenMM
::
Vec
3
*
vectors
)
{
usePeriodic
=
true
;
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
1
]
=
vectors
[
1
];
...
@@ -56,20 +57,11 @@ void AmoebaReferenceStretchBendForce::setPeriodic(OpenMM::RealVec* vectors) {
...
@@ -56,20 +57,11 @@ void AmoebaReferenceStretchBendForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
AmoebaReferenceStretchBendForce
::
calculateStretchBendIxn
(
const
RealVec
&
positionAtomA
,
const
RealVec
&
positionAtomB
,
double
AmoebaReferenceStretchBendForce
::
calculateStretchBendIxn
(
const
Vec3
&
positionAtomA
,
const
Vec3
&
positionAtomB
,
const
RealVec
&
positionAtomC
,
const
Vec3
&
positionAtomC
,
RealOpenMM
lengthAB
,
RealOpenMM
lengthCB
,
double
lengthAB
,
double
lengthCB
,
RealOpenMM
idealAngle
,
RealOpenMM
k1Parameter
,
double
idealAngle
,
double
k1Parameter
,
RealOpenMM
k2Parameter
,
RealVec
*
forces
)
const
{
double
k2Parameter
,
Vec3
*
forces
)
const
{
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceStretchBendForce::calculateStretchBendIxn";
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
// ---------------------------------------------------------------------------------------
enum
{
A
,
B
,
C
,
LastAtomIndex
};
enum
{
A
,
B
,
C
,
LastAtomIndex
};
enum
{
AB
,
CB
,
CBxAB
,
ABxP
,
CBxP
,
LastDeltaIndex
};
enum
{
AB
,
CB
,
CBxAB
,
ABxP
,
CBxP
,
LastDeltaIndex
};
...
@@ -79,7 +71,7 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
...
@@ -79,7 +71,7 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
// get deltaR between various combinations of the 3 atoms
// get deltaR between various combinations of the 3 atoms
// and various intermediate terms
// and various intermediate terms
std
::
vector
<
RealOpenMM
>
deltaR
[
LastDeltaIndex
];
std
::
vector
<
double
>
deltaR
[
LastDeltaIndex
];
for
(
unsigned
int
ii
=
0
;
ii
<
LastDeltaIndex
;
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
LastDeltaIndex
;
ii
++
)
{
deltaR
[
ii
].
resize
(
3
);
deltaR
[
ii
].
resize
(
3
);
}
}
...
@@ -91,30 +83,30 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
...
@@ -91,30 +83,30 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomB
,
positionAtomA
,
deltaR
[
AB
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomB
,
positionAtomA
,
deltaR
[
AB
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomB
,
positionAtomC
,
deltaR
[
CB
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomB
,
positionAtomC
,
deltaR
[
CB
]);
}
}
RealOpenMM
rAB2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
AB
]);
double
rAB2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
AB
]);
RealOpenMM
rAB
=
SQRT
(
rAB2
);
double
rAB
=
sqrt
(
rAB2
);
RealOpenMM
rCB2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
CB
]);
double
rCB2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
CB
]);
RealOpenMM
rCB
=
SQRT
(
rCB2
);
double
rCB
=
sqrt
(
rCB2
);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
CB
],
deltaR
[
AB
],
deltaR
[
CBxAB
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
CB
],
deltaR
[
AB
],
deltaR
[
CBxAB
]);
RealOpenMM
rP
=
AmoebaReferenceForce
::
getNorm3
(
deltaR
[
CBxAB
]);
double
rP
=
AmoebaReferenceForce
::
getNorm3
(
deltaR
[
CBxAB
]);
if
(
rP
<=
zero
)
{
if
(
rP
<=
0.0
)
{
return
zero
;
return
0.0
;
}
}
RealOpenMM
dot
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
CB
],
deltaR
[
AB
]);
double
dot
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
CB
],
deltaR
[
AB
]);
RealOpenMM
cosine
=
dot
/
(
rAB
*
rCB
);
double
cosine
=
dot
/
(
rAB
*
rCB
);
RealOpenMM
angle
;
double
angle
;
if
(
cosine
>=
one
)
{
if
(
cosine
>=
1.0
)
{
angle
=
zero
;
angle
=
0.0
;
}
else
if
(
cosine
<=
-
one
)
{
}
else
if
(
cosine
<=
-
1.0
)
{
angle
=
PI
_M
;
angle
=
M_
PI
;
}
else
{
}
else
{
angle
=
RADIAN
*
ACOS
(
cosine
);
angle
=
RADIAN
*
acos
(
cosine
);
}
}
RealOpenMM
termA
=
-
RADIAN
/
(
rAB2
*
rP
);
double
termA
=
-
RADIAN
/
(
rAB2
*
rP
);
RealOpenMM
termC
=
RADIAN
/
(
rCB2
*
rP
);
double
termC
=
RADIAN
/
(
rCB2
*
rP
);
// P = CBxAB
// P = CBxAB
...
@@ -125,11 +117,11 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
...
@@ -125,11 +117,11 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
deltaR
[
CBxP
][
ii
]
*=
termC
;
deltaR
[
CBxP
][
ii
]
*=
termC
;
}
}
RealOpenMM
dr1
=
rAB
-
lengthAB
;
double
dr1
=
rAB
-
lengthAB
;
RealOpenMM
dr2
=
rCB
-
lengthCB
;
double
dr2
=
rCB
-
lengthCB
;
RealOpenMM
drkk
=
dr1
*
k1Parameter
+
dr2
*
k2Parameter
;
double
drkk
=
dr1
*
k1Parameter
+
dr2
*
k2Parameter
;
termA
=
one
/
rAB
;
termA
=
1.0
/
rAB
;
termC
=
one
/
rCB
;
termC
=
1.0
/
rCB
;
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -138,11 +130,11 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
...
@@ -138,11 +130,11 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
// calculate forces for atoms a, b, c
// calculate forces for atoms a, b, c
// the force for b is then -(a + c)
// the force for b is then -(a + c)
std
::
vector
<
RealOpenMM
>
subForce
[
LastAtomIndex
];
std
::
vector
<
double
>
subForce
[
LastAtomIndex
];
for
(
int
ii
=
0
;
ii
<
LastAtomIndex
;
ii
++
)
{
for
(
int
ii
=
0
;
ii
<
LastAtomIndex
;
ii
++
)
{
subForce
[
ii
].
resize
(
3
);
subForce
[
ii
].
resize
(
3
);
}
}
RealOpenMM
dt
=
angle
-
idealAngle
*
RADIAN
;
double
dt
=
angle
-
idealAngle
*
RADIAN
;
for
(
int
jj
=
0
;
jj
<
3
;
jj
++
)
{
for
(
int
jj
=
0
;
jj
<
3
;
jj
++
)
{
subForce
[
A
][
jj
]
=
k1Parameter
*
dt
*
termA
*
deltaR
[
AB
][
jj
]
+
drkk
*
deltaR
[
ABxP
][
jj
];
subForce
[
A
][
jj
]
=
k1Parameter
*
dt
*
termA
*
deltaR
[
AB
][
jj
]
+
drkk
*
deltaR
[
ABxP
][
jj
];
subForce
[
C
][
jj
]
=
k2Parameter
*
dt
*
termC
*
deltaR
[
CB
][
jj
]
+
drkk
*
deltaR
[
CBxP
][
jj
];
subForce
[
C
][
jj
]
=
k2Parameter
*
dt
*
termC
*
deltaR
[
CB
][
jj
]
+
drkk
*
deltaR
[
CBxP
][
jj
];
...
@@ -162,29 +154,29 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
...
@@ -162,29 +154,29 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
return
dt
*
drkk
;
return
dt
*
drkk
;
}
}
RealOpenMM
AmoebaReferenceStretchBendForce
::
calculateForceAndEnergy
(
int
numStretchBends
,
vector
<
Real
Vec
>&
posData
,
double
AmoebaReferenceStretchBendForce
::
calculateForceAndEnergy
(
int
numStretchBends
,
vector
<
Vec
3
>&
posData
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
RealOpenMM
>&
lengthABParameters
,
const
std
::
vector
<
double
>&
lengthABParameters
,
const
std
::
vector
<
RealOpenMM
>&
lengthCBParameters
,
const
std
::
vector
<
double
>&
lengthCBParameters
,
const
std
::
vector
<
RealOpenMM
>&
angle
,
const
std
::
vector
<
double
>&
angle
,
const
std
::
vector
<
RealOpenMM
>&
k1Quadratic
,
const
std
::
vector
<
double
>&
k1Quadratic
,
const
std
::
vector
<
RealOpenMM
>&
k2Quadratic
,
const
std
::
vector
<
double
>&
k2Quadratic
,
vector
<
Real
Vec
>&
forceData
)
const
{
vector
<
Vec
3
>&
forceData
)
const
{
RealOpenMM
energy
=
0.0
;
double
energy
=
0.0
;
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
numStretchBends
);
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
numStretchBends
);
ii
++
)
{
int
particle1Index
=
particle1
[
ii
];
int
particle1Index
=
particle1
[
ii
];
int
particle2Index
=
particle2
[
ii
];
int
particle2Index
=
particle2
[
ii
];
int
particle3Index
=
particle3
[
ii
];
int
particle3Index
=
particle3
[
ii
];
RealOpenMM
abLength
=
lengthABParameters
[
ii
];
double
abLength
=
lengthABParameters
[
ii
];
RealOpenMM
cbLength
=
lengthCBParameters
[
ii
];
double
cbLength
=
lengthCBParameters
[
ii
];
RealOpenMM
idealAngle
=
angle
[
ii
];
double
idealAngle
=
angle
[
ii
];
RealOpenMM
angleK1
=
k1Quadratic
[
ii
];
double
angleK1
=
k1Quadratic
[
ii
];
RealOpenMM
angleK2
=
k2Quadratic
[
ii
];
double
angleK2
=
k2Quadratic
[
ii
];
Real
Vec
forces
[
3
];
Vec
3
forces
[
3
];
energy
+=
calculateStretchBendIxn
(
posData
[
particle1Index
],
posData
[
particle2Index
],
posData
[
particle3Index
],
energy
+=
calculateStretchBendIxn
(
posData
[
particle1Index
],
posData
[
particle2Index
],
posData
[
particle3Index
],
abLength
,
cbLength
,
idealAngle
,
angleK1
,
angleK2
,
forces
);
abLength
,
cbLength
,
idealAngle
,
angleK1
,
angleK2
,
forces
);
// accumulate forces
// accumulate forces
for
(
int
jj
=
0
;
jj
<
3
;
jj
++
)
{
for
(
int
jj
=
0
;
jj
<
3
;
jj
++
)
{
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceStretchBendForce.h
View file @
a783b996
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceStretchBendForce_H__
#ifndef __AmoebaReferenceStretchBendForce_H__
#define __AmoebaReferenceStretchBendForce_H__
#define __AmoebaReferenceStretchBendForce_H__
#include "
Real
Vec.h"
#include "
openmm/
Vec
3
.h"
#include <vector>
#include <vector>
namespace
OpenMM
{
namespace
OpenMM
{
...
@@ -58,7 +58,7 @@ public:
...
@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
Real
Vec
*
vectors
);
void
setPeriodic
(
OpenMM
::
Vec
3
*
vectors
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -80,22 +80,22 @@ public:
...
@@ -80,22 +80,22 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
calculateForceAndEnergy
(
int
numAngles
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
posData
,
double
calculateForceAndEnergy
(
int
numAngles
,
std
::
vector
<
OpenMM
::
Vec
3
>&
posData
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
RealOpenMM
>&
lengthABParameters
,
const
std
::
vector
<
double
>&
lengthABParameters
,
const
std
::
vector
<
RealOpenMM
>&
lengthCBParameters
,
const
std
::
vector
<
double
>&
lengthCBParameters
,
const
std
::
vector
<
RealOpenMM
>&
angle
,
const
std
::
vector
<
double
>&
angle
,
const
std
::
vector
<
RealOpenMM
>&
k1Quadratic
,
const
std
::
vector
<
double
>&
k1Quadratic
,
const
std
::
vector
<
RealOpenMM
>&
k2Quadratic
,
const
std
::
vector
<
double
>&
k2Quadratic
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forceData
)
const
;
std
::
vector
<
OpenMM
::
Vec
3
>&
forceData
)
const
;
private:
private:
bool
usePeriodic
;
bool
usePeriodic
;
Real
Vec
boxVectors
[
3
];
Vec
3
boxVectors
[
3
];
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -115,11 +115,11 @@ private:
...
@@ -115,11 +115,11 @@ private:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
calculateStretchBendIxn
(
const
OpenMM
::
Real
Vec
&
positionAtomA
,
const
OpenMM
::
Real
Vec
&
positionAtomB
,
double
calculateStretchBendIxn
(
const
OpenMM
::
Vec
3
&
positionAtomA
,
const
OpenMM
::
Vec
3
&
positionAtomB
,
const
OpenMM
::
Real
Vec
&
positionAtomC
,
const
OpenMM
::
Vec
3
&
positionAtomC
,
RealOpenMM
lengthAB
,
RealOpenMM
lengthCB
,
double
lengthAB
,
double
lengthCB
,
RealOpenMM
idealAngle
,
RealOpenMM
k1Parameter
,
double
idealAngle
,
double
k1Parameter
,
RealOpenMM
k2Parameter
,
OpenMM
::
Real
Vec
*
forces
)
const
;
double
k2Parameter
,
OpenMM
::
Vec
3
*
forces
)
const
;
};
};
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceTorsionTorsionForce.cpp
View file @
a783b996
...
@@ -23,11 +23,12 @@
...
@@ -23,11 +23,12 @@
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceTorsionTorsionForce.h"
#include "AmoebaReferenceTorsionTorsionForce.h"
#include "SimTKOpenMMRealType.h"
using
std
::
vector
;
using
std
::
vector
;
using
namespace
OpenMM
;
using
namespace
OpenMM
;
void
AmoebaReferenceTorsionTorsionForce
::
setPeriodic
(
OpenMM
::
Real
Vec
*
vectors
)
{
void
AmoebaReferenceTorsionTorsionForce
::
setPeriodic
(
OpenMM
::
Vec
3
*
vectors
)
{
usePeriodic
=
true
;
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
1
]
=
vectors
[
1
];
...
@@ -54,15 +55,9 @@ void AmoebaReferenceTorsionTorsionForce::setPeriodic(OpenMM::RealVec* vectors) {
...
@@ -54,15 +55,9 @@ void AmoebaReferenceTorsionTorsionForce::setPeriodic(OpenMM::RealVec* vectors) {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
AmoebaReferenceTorsionTorsionForce
::
loadGridValuesFromEnclosingRectangle
(
void
AmoebaReferenceTorsionTorsionForce
::
loadGridValuesFromEnclosingRectangle
(
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>
>&
grid
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
double
>
>
>&
grid
,
RealOpenMM
angle1
,
RealOpenMM
angle2
,
RealOpenMM
corners
[
2
][
2
],
double
angle1
,
double
angle2
,
double
corners
[
2
][
2
],
RealOpenMM
*
fValues
,
RealOpenMM
*
fValues1
,
RealOpenMM
*
fValues2
,
RealOpenMM
*
fValues12
)
const
{
double
*
fValues
,
double
*
fValues1
,
double
*
fValues2
,
double
*
fValues12
)
const
{
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "loadGridValuesFromEnclosingRectangle";
// ---------------------------------------------------------------------------------------
// get 2 opposing grid indices for rectangle
// get 2 opposing grid indices for rectangle
...
@@ -123,50 +118,37 @@ void AmoebaReferenceTorsionTorsionForce::loadGridValuesFromEnclosingRectangle(
...
@@ -123,50 +118,37 @@ void AmoebaReferenceTorsionTorsionForce::loadGridValuesFromEnclosingRectangle(
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
AmoebaReferenceTorsionTorsionForce
::
getBicubicCoefficientMatrix
(
const
RealOpenMM
*
y
,
void
AmoebaReferenceTorsionTorsionForce
::
getBicubicCoefficientMatrix
(
const
double
*
y
,
const
RealOpenMM
*
y1
,
const
RealOpenMM
*
y2
,
const
RealOpenMM
*
y12
,
const
RealOpenMM
d1
,
const
RealOpenMM
d2
,
const
double
*
y1
,
const
double
*
y2
,
const
double
*
y12
,
const
double
d1
,
const
double
d2
,
RealOpenMM
c
[
4
][
4
])
const
{
double
c
[
4
][
4
])
const
{
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix";
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
static
const
RealOpenMM
two
=
2.0
;
static
const
RealOpenMM
three
=
3.0
;
static
const
RealOpenMM
four
=
4.0
;
static
const
RealOpenMM
five
=
5.0
;
static
const
RealOpenMM
six
=
6.0
;
static
const
RealOpenMM
nine
=
9.0
;
// transpose of matrix in Tinker due to difference in C/Fotran row/column major
// transpose of matrix in Tinker due to difference in C/Fotran row/column major
// change indices when multiplying by weightMatrix
// change indices when multiplying by weightMatrix
static
const
RealOpenMM
weightMatrix
[
16
][
16
]
=
{
static
const
double
weightMatrix
[
16
][
16
]
=
{
{
one
,
zero
,
-
three
,
two
,
zero
,
zero
,
zero
,
zero
,
-
three
,
zero
,
nine
,
-
six
,
two
,
zero
,
-
six
,
four
},
{
1.0
,
0.0
,
-
3.0
,
2.0
,
0.0
,
0.0
,
0.0
,
0.0
,
-
3.0
,
0.0
,
9.0
,
-
6.0
,
2.0
,
0.0
,
-
6.0
,
4.0
},
{
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
three
,
zero
,
-
nine
,
six
,
-
two
,
zero
,
six
,
-
four
},
{
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
3.0
,
0.0
,
-
9.0
,
6.0
,
-
2.0
,
0.0
,
6.0
,
-
4.0
},
{
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
nine
,
-
six
,
zero
,
zero
,
-
six
,
four
},
{
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
9.0
,
-
6.0
,
0.0
,
0.0
,
-
6.0
,
4.0
},
{
zero
,
zero
,
three
,
-
two
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
-
nine
,
six
,
zero
,
zero
,
six
,
-
four
},
{
0.0
,
0.0
,
3.0
,
-
2.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
-
9.0
,
6.0
,
0.0
,
0.0
,
6.0
,
-
4.0
},
{
zero
,
zero
,
zero
,
zero
,
one
,
zero
,
-
three
,
two
,
-
two
,
zero
,
six
,
-
four
,
one
,
zero
,
-
three
,
two
},
{
0.0
,
0.0
,
0.0
,
0.0
,
1.0
,
0.0
,
-
3.0
,
2.0
,
-
2.0
,
0.0
,
6.0
,
-
4.0
,
1.0
,
0.0
,
-
3.0
,
2.0
},
{
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
-
one
,
zero
,
three
,
-
two
,
one
,
zero
,
-
three
,
two
},
{
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
-
1.0
,
0.0
,
3.0
,
-
2.0
,
1.0
,
0.0
,
-
3.0
,
2.0
},
{
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
-
three
,
two
,
zero
,
zero
,
three
,
-
two
},
{
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
-
3.0
,
2.0
,
0.0
,
0.0
,
3.0
,
-
2.0
},
{
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
three
,
-
two
,
zero
,
zero
,
-
six
,
four
,
zero
,
zero
,
three
,
-
two
},
{
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
3.0
,
-
2.0
,
0.0
,
0.0
,
-
6.0
,
4.0
,
0.0
,
0.0
,
3.0
,
-
2.0
},
{
zero
,
one
,
-
two
,
one
,
zero
,
zero
,
zero
,
zero
,
zero
,
-
three
,
six
,
-
three
,
zero
,
two
,
-
four
,
two
},
{
0.0
,
1.0
,
-
2.0
,
1.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
-
3.0
,
6.0
,
-
3.0
,
0.0
,
2.0
,
-
4.0
,
2.0
},
{
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
three
,
-
six
,
three
,
zero
,
-
two
,
four
,
-
two
},
{
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
3.0
,
-
6.0
,
3.0
,
0.0
,
-
2.0
,
4.0
,
-
2.0
},
{
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
-
three
,
three
,
zero
,
zero
,
two
,
-
two
},
{
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
-
3.0
,
3.0
,
0.0
,
0.0
,
2.0
,
-
2.0
},
{
zero
,
zero
,
-
one
,
one
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
three
,
-
three
,
zero
,
zero
,
-
two
,
two
},
{
0.0
,
0.0
,
-
1.0
,
1.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
3.0
,
-
3.0
,
0.0
,
0.0
,
-
2.0
,
2.0
},
{
zero
,
zero
,
zero
,
zero
,
zero
,
one
,
-
two
,
one
,
zero
,
-
two
,
four
,
-
two
,
zero
,
one
,
-
two
,
one
},
{
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
1.0
,
-
2.0
,
1.0
,
0.0
,
-
2.0
,
4.0
,
-
2.0
,
0.0
,
1.0
,
-
2.0
,
1.0
},
{
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
-
one
,
two
,
-
one
,
zero
,
one
,
-
two
,
one
},
{
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
-
1.0
,
2.0
,
-
1.0
,
0.0
,
1.0
,
-
2.0
,
1.0
},
{
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
one
,
-
one
,
zero
,
zero
,
-
one
,
one
},
{
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
1.0
,
-
1.0
,
0.0
,
0.0
,
-
1.0
,
1.0
},
{
zero
,
zero
,
zero
,
zero
,
zero
,
zero
,
-
one
,
one
,
zero
,
zero
,
two
,
-
two
,
zero
,
zero
,
-
one
,
one
}
};
{
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
-
1.0
,
1.0
,
0.0
,
0.0
,
2.0
,
-
2.0
,
0.0
,
0.0
,
-
1.0
,
1.0
}
};
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// pack y, y1, y2, y12 into single vector of dimension 16
// pack y, y1, y2, y12 into single vector of dimension 16
std
::
vector
<
RealOpenMM
>
x
(
16
);
std
::
vector
<
double
>
x
(
16
);
RealOpenMM
d1d2
=
d1
*
d2
;
double
d1d2
=
d1
*
d2
;
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
)
{
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
)
{
x
[
ii
]
=
y
[
ii
];
x
[
ii
]
=
y
[
ii
];
x
[
ii
+
4
]
=
y1
[
ii
]
*
d1
;
x
[
ii
+
4
]
=
y1
[
ii
]
*
d1
;
...
@@ -179,7 +161,7 @@ void AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix(const RealO
...
@@ -179,7 +161,7 @@ void AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix(const RealO
int
rowIndex
=
0
;
int
rowIndex
=
0
;
int
colIndex
=
0
;
int
colIndex
=
0
;
for
(
int
ii
=
0
;
ii
<
16
;
ii
++
)
{
for
(
int
ii
=
0
;
ii
<
16
;
ii
++
)
{
RealOpenMM
sum
=
weightMatrix
[
0
][
ii
]
*
x
[
0
];
double
sum
=
weightMatrix
[
0
][
ii
]
*
x
[
0
];
for
(
int
jj
=
1
;
jj
<
16
;
jj
++
)
{
for
(
int
jj
=
1
;
jj
<
16
;
jj
++
)
{
sum
+=
weightMatrix
[
jj
][
ii
]
*
x
[
jj
];
sum
+=
weightMatrix
[
jj
][
ii
]
*
x
[
jj
];
}
}
...
@@ -223,40 +205,30 @@ void AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix(const RealO
...
@@ -223,40 +205,30 @@ void AmoebaReferenceTorsionTorsionForce::getBicubicCoefficientMatrix(const RealO
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
AmoebaReferenceTorsionTorsionForce
::
getBicubicValues
(
void
AmoebaReferenceTorsionTorsionForce
::
getBicubicValues
(
const
RealOpenMM
*
y
,
const
RealOpenMM
*
y1
,
const
RealOpenMM
*
y2
,
const
RealOpenMM
*
y12
,
const
double
*
y
,
const
double
*
y1
,
const
double
*
y2
,
const
double
*
y12
,
const
RealOpenMM
x1Lower
,
const
RealOpenMM
x1Upper
,
const
double
x1Lower
,
const
double
x1Upper
,
const
RealOpenMM
x2Lower
,
const
RealOpenMM
x2Upper
,
const
double
x2Lower
,
const
double
x2Upper
,
const
RealOpenMM
gridValue1
,
const
RealOpenMM
gridValue2
,
const
double
gridValue1
,
const
double
gridValue2
,
RealOpenMM
*
functionValue
,
RealOpenMM
*
functionValue1
,
RealOpenMM
*
functionValue2
)
const
{
double
*
functionValue
,
double
*
functionValue1
,
double
*
functionValue2
)
const
{
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "getBicubicValues";
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
two
=
2.0
;
static
const
RealOpenMM
three
=
3.0
;
// ---------------------------------------------------------------------------------------
// get coefficent matrix
// get coefficent matrix
RealOpenMM
coefficientMatrix
[
4
][
4
];
double
coefficientMatrix
[
4
][
4
];
getBicubicCoefficientMatrix
(
y
,
y1
,
y2
,
y12
,
x1Upper
-
x1Lower
,
x2Upper
-
x2Lower
,
coefficientMatrix
);
getBicubicCoefficientMatrix
(
y
,
y1
,
y2
,
y12
,
x1Upper
-
x1Lower
,
x2Upper
-
x2Lower
,
coefficientMatrix
);
// apply coefficent matrix
// apply coefficent matrix
RealOpenMM
t
=
(
gridValue1
-
x1Lower
)
/
(
x1Upper
-
x1Lower
);
double
t
=
(
gridValue1
-
x1Lower
)
/
(
x1Upper
-
x1Lower
);
RealOpenMM
u
=
(
gridValue2
-
x2Lower
)
/
(
x2Upper
-
x2Lower
);
double
u
=
(
gridValue2
-
x2Lower
)
/
(
x2Upper
-
x2Lower
);
*
functionValue
=
zero
;
*
functionValue
=
0.0
;
*
functionValue1
=
zero
;
*
functionValue1
=
0.0
;
*
functionValue2
=
zero
;
*
functionValue2
=
0.0
;
for
(
int
ii
=
3
;
ii
>=
0
;
ii
--
)
{
for
(
int
ii
=
3
;
ii
>=
0
;
ii
--
)
{
*
functionValue
=
t
*
(
*
functionValue
)
+
(
(
coefficientMatrix
[
ii
][
3
]
*
u
+
coefficientMatrix
[
ii
][
2
])
*
u
+
coefficientMatrix
[
ii
][
1
])
*
u
+
coefficientMatrix
[
ii
][
0
];
*
functionValue
=
t
*
(
*
functionValue
)
+
(
(
coefficientMatrix
[
ii
][
3
]
*
u
+
coefficientMatrix
[
ii
][
2
])
*
u
+
coefficientMatrix
[
ii
][
1
])
*
u
+
coefficientMatrix
[
ii
][
0
];
*
functionValue1
=
u
*
(
*
functionValue1
)
+
(
three
*
coefficientMatrix
[
3
][
ii
]
*
t
+
two
*
coefficientMatrix
[
2
][
ii
])
*
t
+
coefficientMatrix
[
1
][
ii
];
*
functionValue1
=
u
*
(
*
functionValue1
)
+
(
3.0
*
coefficientMatrix
[
3
][
ii
]
*
t
+
2.0
*
coefficientMatrix
[
2
][
ii
])
*
t
+
coefficientMatrix
[
1
][
ii
];
*
functionValue2
=
t
*
(
*
functionValue2
)
+
(
three
*
coefficientMatrix
[
ii
][
3
]
*
u
+
two
*
coefficientMatrix
[
ii
][
2
])
*
u
+
coefficientMatrix
[
ii
][
1
];
*
functionValue2
=
t
*
(
*
functionValue2
)
+
(
3.0
*
coefficientMatrix
[
ii
][
3
]
*
u
+
2.0
*
coefficientMatrix
[
ii
][
2
])
*
u
+
coefficientMatrix
[
ii
][
1
];
}
}
*
functionValue1
/=
(
x1Upper
-
x1Lower
);
*
functionValue1
/=
(
x1Upper
-
x1Lower
);
...
@@ -280,22 +252,13 @@ void AmoebaReferenceTorsionTorsionForce::getBicubicValues(
...
@@ -280,22 +252,13 @@ void AmoebaReferenceTorsionTorsionForce::getBicubicValues(
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
AmoebaReferenceTorsionTorsionForce
::
checkTorsionSign
(
int
AmoebaReferenceTorsionTorsionForce
::
checkTorsionSign
(
const
RealVec
&
positionAtomA
,
const
RealVec
&
positionAtomB
,
const
Vec3
&
positionAtomA
,
const
Vec3
&
positionAtomB
,
const
RealVec
&
positionAtomC
,
const
RealVec
&
positionAtomD
)
const
{
const
Vec3
&
positionAtomC
,
const
Vec3
&
positionAtomD
)
const
{
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "AmoebaReferenceTorsionTorsionForce::checkTorsionSign";
static
const
RealOpenMM
zero
=
0.0
;
static
const
int
one
=
1
;
// ---------------------------------------------------------------------------------------
// compute parallelpiped volume at atomC and return sign based on sign of volume
// compute parallelpiped volume at atomC and return sign based on sign of volume
enum
{
CA
,
CB
,
CD
,
LastDeltaIndex
};
enum
{
CA
,
CB
,
CD
,
LastDeltaIndex
};
std
::
vector
<
RealOpenMM
>
deltaR
[
LastDeltaIndex
];
std
::
vector
<
double
>
deltaR
[
LastDeltaIndex
];
for
(
unsigned
int
ii
=
0
;
ii
<
LastDeltaIndex
;
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
LastDeltaIndex
;
ii
++
)
{
deltaR
[
ii
].
resize
(
3
);
deltaR
[
ii
].
resize
(
3
);
}
}
...
@@ -311,11 +274,11 @@ int AmoebaReferenceTorsionTorsionForce::checkTorsionSign(
...
@@ -311,11 +274,11 @@ int AmoebaReferenceTorsionTorsionForce::checkTorsionSign(
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomD
,
deltaR
[
CD
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomD
,
deltaR
[
CD
]);
}
}
RealOpenMM
volume
=
deltaR
[
CA
][
0
]
*
(
deltaR
[
CB
][
1
]
*
deltaR
[
CD
][
2
]
-
deltaR
[
CB
][
2
]
*
deltaR
[
CD
][
1
])
+
double
volume
=
deltaR
[
CA
][
0
]
*
(
deltaR
[
CB
][
1
]
*
deltaR
[
CD
][
2
]
-
deltaR
[
CB
][
2
]
*
deltaR
[
CD
][
1
])
+
deltaR
[
CB
][
0
]
*
(
deltaR
[
CD
][
1
]
*
deltaR
[
CA
][
2
]
-
deltaR
[
CD
][
2
]
*
deltaR
[
CA
][
1
])
+
deltaR
[
CB
][
0
]
*
(
deltaR
[
CD
][
1
]
*
deltaR
[
CA
][
2
]
-
deltaR
[
CD
][
2
]
*
deltaR
[
CA
][
1
])
+
deltaR
[
CD
][
0
]
*
(
deltaR
[
CA
][
1
]
*
deltaR
[
CB
][
2
]
-
deltaR
[
CA
][
2
]
*
deltaR
[
CB
][
1
]);
deltaR
[
CD
][
0
]
*
(
deltaR
[
CA
][
1
]
*
deltaR
[
CB
][
2
]
-
deltaR
[
CA
][
2
]
*
deltaR
[
CB
][
1
]);
return
(
volume
>=
zero
?
one
:
-
one
);
return
(
volume
>=
0.0
?
1.0
:
-
1.0
);
}
}
...
@@ -337,21 +300,12 @@ int AmoebaReferenceTorsionTorsionForce::checkTorsionSign(
...
@@ -337,21 +300,12 @@ int AmoebaReferenceTorsionTorsionForce::checkTorsionSign(
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
AmoebaReferenceTorsionTorsionForce
::
calculateTorsionTorsionIxn
(
const
RealVec
&
positionAtomA
,
const
RealVec
&
positionAtomB
,
double
AmoebaReferenceTorsionTorsionForce
::
calculateTorsionTorsionIxn
(
const
Vec3
&
positionAtomA
,
const
Vec3
&
positionAtomB
,
const
RealVec
&
positionAtomC
,
const
RealVec
&
positionAtomD
,
const
Vec3
&
positionAtomC
,
const
Vec3
&
positionAtomD
,
const
RealVec
&
positionAtomE
,
const
RealVec
*
positionChiralCheckAtom
,
const
Vec3
&
positionAtomE
,
const
Vec3
*
positionChiralCheckAtom
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>
>&
grid
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
double
>
>
>&
grid
,
RealVec
*
forces
)
const
{
Vec3
*
forces
)
const
{
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceTorsionTorsionForce::calculateForceAndEnergy";
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
// ---------------------------------------------------------------------------------------
enum
{
A
,
B
,
C
,
D
,
E
,
LastAtomIndex
};
enum
{
A
,
B
,
C
,
D
,
E
,
LastAtomIndex
};
// get deltaR between various combinations of the 4 atoms
// get deltaR between various combinations of the 4 atoms
...
@@ -359,7 +313,7 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
...
@@ -359,7 +313,7 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
enum
{
BA
,
CB
,
DC
,
ED
,
T
,
U
,
V
,
UxV
,
CA
,
DB
,
EC
,
dT
,
dU
,
dU2
,
dV2
,
LastDeltaIndex
};
enum
{
BA
,
CB
,
DC
,
ED
,
T
,
U
,
V
,
UxV
,
CA
,
DB
,
EC
,
dT
,
dU
,
dU2
,
dV2
,
LastDeltaIndex
};
std
::
vector
<
RealOpenMM
>
deltaR
[
LastDeltaIndex
];
std
::
vector
<
double
>
deltaR
[
LastDeltaIndex
];
for
(
unsigned
int
ii
=
0
;
ii
<
LastDeltaIndex
;
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
LastDeltaIndex
;
ii
++
)
{
deltaR
[
ii
].
resize
(
3
);
deltaR
[
ii
].
resize
(
3
);
}
}
...
@@ -383,7 +337,7 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
...
@@ -383,7 +337,7 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomE
,
deltaR
[
EC
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomE
,
deltaR
[
EC
]);
}
}
std
::
vector
<
RealOpenMM
>
d
[
LastAtomIndex
];
std
::
vector
<
double
>
d
[
LastAtomIndex
];
for
(
unsigned
int
ii
=
0
;
ii
<
LastAtomIndex
;
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
LastAtomIndex
;
ii
++
)
{
d
[
ii
].
resize
(
3
);
d
[
ii
].
resize
(
3
);
}
}
...
@@ -394,51 +348,51 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
...
@@ -394,51 +348,51 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
U
],
deltaR
[
V
],
deltaR
[
UxV
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
U
],
deltaR
[
V
],
deltaR
[
UxV
]);
RealOpenMM
rT2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
T
]);
double
rT2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
T
]);
RealOpenMM
rU2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
U
]);
double
rU2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
U
]);
RealOpenMM
rV2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
V
]);
double
rV2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
V
]);
RealOpenMM
rUrV
=
SQRT
(
rU2
*
rV2
);
double
rUrV
=
sqrt
(
rU2
*
rV2
);
RealOpenMM
rTrU
=
SQRT
(
rT2
*
rU2
);
double
rTrU
=
sqrt
(
rT2
*
rU2
);
if
(
rTrU
<=
zero
||
rUrV
<=
zero
)
{
if
(
rTrU
<=
0.0
||
rUrV
<=
0.0
)
{
return
zero
;
return
0.0
;
}
}
RealOpenMM
rCB
=
AmoebaReferenceForce
::
getNorm3
(
deltaR
[
CB
]);
double
rCB
=
AmoebaReferenceForce
::
getNorm3
(
deltaR
[
CB
]);
RealOpenMM
cosine1
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
T
],
deltaR
[
U
]);
double
cosine1
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
T
],
deltaR
[
U
]);
cosine1
/=
rTrU
;
cosine1
/=
rTrU
;
RealOpenMM
angle1
;
double
angle1
;
if
(
cosine1
<=
-
one
)
{
if
(
cosine1
<=
-
1.0
)
{
angle1
=
PI
_M
*
RADIAN
;
angle1
=
M_
PI
*
RADIAN
;
}
else
if
(
cosine1
>=
one
)
{
}
else
if
(
cosine1
>=
1.0
)
{
angle1
=
zero
;
angle1
=
0.0
;
}
else
{
}
else
{
angle1
=
RADIAN
*
ACOS
(
cosine1
);
angle1
=
RADIAN
*
acos
(
cosine1
);
}
}
RealOpenMM
sign
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
BA
],
deltaR
[
U
]);
double
sign
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
BA
],
deltaR
[
U
]);
if
(
sign
<
zero
)
{
if
(
sign
<
0.0
)
{
angle1
=
-
angle1
;
angle1
=
-
angle1
;
}
}
// value1 = angle1;
// value1 = angle1;
RealOpenMM
rDC
=
AmoebaReferenceForce
::
getNorm3
(
deltaR
[
DC
]);
double
rDC
=
AmoebaReferenceForce
::
getNorm3
(
deltaR
[
DC
]);
RealOpenMM
cosine2
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
U
],
deltaR
[
V
]);
double
cosine2
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
U
],
deltaR
[
V
]);
cosine2
/=
rUrV
;
cosine2
/=
rUrV
;
RealOpenMM
angle2
;
double
angle2
;
if
(
cosine2
<=
-
one
)
{
if
(
cosine2
<=
-
1.0
)
{
angle2
=
PI
_M
*
RADIAN
;
angle2
=
M_
PI
*
RADIAN
;
}
else
if
(
cosine1
>=
one
)
{
}
else
if
(
cosine1
>=
1.0
)
{
angle2
=
zero
;
angle2
=
0.0
;
}
else
{
}
else
{
angle2
=
RADIAN
*
ACOS
(
cosine2
);
angle2
=
RADIAN
*
acos
(
cosine2
);
}
}
sign
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
CB
],
deltaR
[
V
]);
sign
=
AmoebaReferenceForce
::
getDotProduct3
(
deltaR
[
CB
],
deltaR
[
V
]);
if
(
sign
<
zero
)
{
if
(
sign
<
0.0
)
{
angle2
=
-
angle2
;
angle2
=
-
angle2
;
}
}
...
@@ -447,18 +401,18 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
...
@@ -447,18 +401,18 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
if
(
positionChiralCheckAtom
)
{
if
(
positionChiralCheckAtom
)
{
sign
=
checkTorsionSign
(
*
positionChiralCheckAtom
,
positionAtomB
,
positionAtomC
,
positionAtomD
);
sign
=
checkTorsionSign
(
*
positionChiralCheckAtom
,
positionAtomB
,
positionAtomC
,
positionAtomD
);
if
(
sign
<
zero
)
{
if
(
sign
<
0.0
)
{
angle1
=
-
angle1
;
angle1
=
-
angle1
;
angle2
=
-
angle2
;
angle2
=
-
angle2
;
}
}
}
else
{
}
else
{
sign
=
one
;
sign
=
1.0
;
}
}
// bicubic interpolation
// bicubic interpolation
RealOpenMM
corners
[
2
][
2
];
double
corners
[
2
][
2
];
RealOpenMM
eValues
[
4
][
4
];
double
eValues
[
4
][
4
];
enum
{
E0
,
E1
,
E2
,
E12
,
LastEIndex
};
enum
{
E0
,
E1
,
E2
,
E12
,
LastEIndex
};
loadGridValuesFromEnclosingRectangle
(
grid
,
angle1
,
angle2
,
corners
,
eValues
[
E0
],
eValues
[
E1
],
eValues
[
E2
],
eValues
[
E12
]);
loadGridValuesFromEnclosingRectangle
(
grid
,
angle1
,
angle2
,
corners
,
eValues
[
E0
],
eValues
[
E1
],
eValues
[
E2
],
eValues
[
E12
]);
...
@@ -467,9 +421,9 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
...
@@ -467,9 +421,9 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
// get corners of grid encompassing point
// get corners of grid encompassing point
// get width/height of encompassing rectangle
// get width/height of encompassing rectangle
RealOpenMM
gridEnergy
;
double
gridEnergy
;
RealOpenMM
dEdAngle1
;
double
dEdAngle1
;
RealOpenMM
dEdAngle2
;
double
dEdAngle2
;
AmoebaReferenceTorsionTorsionForce
::
getBicubicValues
(
AmoebaReferenceTorsionTorsionForce
::
getBicubicValues
(
eValues
[
E0
],
eValues
[
E1
],
eValues
[
E2
],
eValues
[
E12
],
eValues
[
E0
],
eValues
[
E1
],
eValues
[
E2
],
eValues
[
E12
],
corners
[
0
][
0
],
corners
[
0
][
1
],
corners
[
1
][
0
],
corners
[
1
][
1
],
corners
[
0
][
0
],
corners
[
0
][
1
],
corners
[
1
][
0
],
corners
[
1
][
1
],
...
@@ -481,8 +435,8 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
...
@@ -481,8 +435,8 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
T
],
deltaR
[
CB
],
deltaR
[
dT
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
T
],
deltaR
[
CB
],
deltaR
[
dT
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
U
],
deltaR
[
CB
],
deltaR
[
dU
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
U
],
deltaR
[
CB
],
deltaR
[
dU
]);
RealOpenMM
factorT
=
dEdAngle1
/
(
rCB
*
rT2
);
double
factorT
=
dEdAngle1
/
(
rCB
*
rT2
);
RealOpenMM
factorU
=
-
dEdAngle1
/
(
rCB
*
rU2
);
double
factorU
=
-
dEdAngle1
/
(
rCB
*
rU2
);
deltaR
[
dT
][
0
]
*=
factorT
;
deltaR
[
dT
][
0
]
*=
factorT
;
deltaR
[
dT
][
1
]
*=
factorT
;
deltaR
[
dT
][
1
]
*=
factorT
;
...
@@ -495,7 +449,7 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
...
@@ -495,7 +449,7 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
dT
],
deltaR
[
CB
],
d
[
A
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
dT
],
deltaR
[
CB
],
d
[
A
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
dU
],
deltaR
[
CB
],
d
[
D
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
dU
],
deltaR
[
CB
],
d
[
D
]);
std
::
vector
<
RealOpenMM
>
tmp
[
3
];
std
::
vector
<
double
>
tmp
[
3
];
for
(
unsigned
int
ii
=
0
;
ii
<
3
;
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
3
;
ii
++
)
{
tmp
[
ii
].
resize
(
3
);
tmp
[
ii
].
resize
(
3
);
}
}
...
@@ -518,8 +472,8 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
...
@@ -518,8 +472,8 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
U
],
deltaR
[
DC
],
deltaR
[
dU2
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
U
],
deltaR
[
DC
],
deltaR
[
dU2
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
V
],
deltaR
[
DC
],
deltaR
[
dV2
]);
AmoebaReferenceForce
::
getCrossProduct
(
deltaR
[
V
],
deltaR
[
DC
],
deltaR
[
dV2
]);
RealOpenMM
factorU2
=
dEdAngle2
/
(
rDC
*
rU2
);
double
factorU2
=
dEdAngle2
/
(
rDC
*
rU2
);
RealOpenMM
factorV2
=
-
dEdAngle2
/
(
rDC
*
rV2
);
double
factorV2
=
-
dEdAngle2
/
(
rDC
*
rV2
);
deltaR
[
dU2
][
0
]
*=
factorU2
;
deltaR
[
dU2
][
0
]
*=
factorU2
;
deltaR
[
dU2
][
1
]
*=
factorU2
;
deltaR
[
dU2
][
1
]
*=
factorU2
;
...
@@ -574,17 +528,17 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
...
@@ -574,17 +528,17 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
return
gridEnergy
;
return
gridEnergy
;
}
}
RealOpenMM
AmoebaReferenceTorsionTorsionForce
::
calculateForceAndEnergy
(
int
numTorsionTorsions
,
vector
<
Real
Vec
>&
posData
,
double
AmoebaReferenceTorsionTorsionForce
::
calculateForceAndEnergy
(
int
numTorsionTorsions
,
vector
<
Vec
3
>&
posData
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle4
,
const
std
::
vector
<
int
>&
particle4
,
const
std
::
vector
<
int
>&
particle5
,
const
std
::
vector
<
int
>&
particle5
,
const
std
::
vector
<
int
>&
chiralCheckAtom
,
const
std
::
vector
<
int
>&
chiralCheckAtom
,
const
std
::
vector
<
int
>&
gridIndices
,
const
std
::
vector
<
int
>&
gridIndices
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>
>
>&
torsionTorsionGrids
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
std
::
vector
<
double
>
>
>
>&
torsionTorsionGrids
,
vector
<
Real
Vec
>&
forceData
)
const
{
vector
<
Vec
3
>&
forceData
)
const
{
RealOpenMM
energy
=
0.0
;
double
energy
=
0.0
;
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
numTorsionTorsions
);
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
numTorsionTorsions
);
ii
++
)
{
int
particle1Index
=
particle1
[
ii
];
int
particle1Index
=
particle1
[
ii
];
...
@@ -597,8 +551,8 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateForceAndEnergy(int numTo
...
@@ -597,8 +551,8 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateForceAndEnergy(int numTo
int
gridIndex
=
gridIndices
[
ii
];
int
gridIndex
=
gridIndices
[
ii
];
Real
Vec
forces
[
5
];
Vec
3
forces
[
5
];
Real
Vec
*
chiralCheckAtom
;
Vec
3
*
chiralCheckAtom
;
if
(
chiralCheckAtomIndex
>
-
1
)
{
if
(
chiralCheckAtomIndex
>
-
1
)
{
chiralCheckAtom
=
&
posData
[
chiralCheckAtomIndex
];
chiralCheckAtom
=
&
posData
[
chiralCheckAtomIndex
];
}
else
{
}
else
{
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceTorsionTorsionForce.h
View file @
a783b996
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#ifndef __AmoebaReferenceTorsionTorsionForce_H__
#ifndef __AmoebaReferenceTorsionTorsionForce_H__
#define __AmoebaReferenceTorsionTorsionForce_H__
#define __AmoebaReferenceTorsionTorsionForce_H__
#include "
Real
Vec.h"
#include "
openmm/
Vec
3
.h"
#include <vector>
#include <vector>
namespace
OpenMM
{
namespace
OpenMM
{
...
@@ -58,7 +58,7 @@ public:
...
@@ -58,7 +58,7 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
Real
Vec
*
vectors
);
void
setPeriodic
(
OpenMM
::
Vec
3
*
vectors
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -81,21 +81,21 @@ public:
...
@@ -81,21 +81,21 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
calculateForceAndEnergy
(
int
numTorsionTorsions
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
posData
,
double
calculateForceAndEnergy
(
int
numTorsionTorsions
,
std
::
vector
<
OpenMM
::
Vec
3
>&
posData
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle1
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle2
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle3
,
const
std
::
vector
<
int
>&
particle4
,
const
std
::
vector
<
int
>&
particle4
,
const
std
::
vector
<
int
>&
particle5
,
const
std
::
vector
<
int
>&
particle5
,
const
std
::
vector
<
int
>&
chiralCheckAtom
,
const
std
::
vector
<
int
>&
chiralCheckAtom
,
const
std
::
vector
<
int
>&
gridIndices
,
const
std
::
vector
<
int
>&
gridIndices
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>
>
>&
torsionTorsionGrids
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
std
::
vector
<
double
>
>
>
>&
torsionTorsionGrids
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forceData
)
const
;
std
::
vector
<
OpenMM
::
Vec
3
>&
forceData
)
const
;
private:
private:
bool
usePeriodic
;
bool
usePeriodic
;
Real
Vec
boxVectors
[
3
];
Vec
3
boxVectors
[
3
];
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -116,9 +116,9 @@ private:
...
@@ -116,9 +116,9 @@ private:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
loadGridValuesFromEnclosingRectangle
(
void
loadGridValuesFromEnclosingRectangle
(
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>
>&
grid
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
double
>
>
>&
grid
,
RealOpenMM
angle1
,
RealOpenMM
angle2
,
RealOpenMM
corners
[
2
][
2
],
double
angle1
,
double
angle2
,
double
corners
[
2
][
2
],
RealOpenMM
*
fValues
,
RealOpenMM
*
fValues1
,
RealOpenMM
*
fValues2
,
RealOpenMM
*
fValues12
)
const
;
double
*
fValues
,
double
*
fValues1
,
double
*
fValues2
,
double
*
fValues12
)
const
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -141,8 +141,8 @@ private:
...
@@ -141,8 +141,8 @@ private:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
getBicubicCoefficientMatrix
(
const
RealOpenMM
*
y
,
const
RealOpenMM
*
y1
,
const
RealOpenMM
*
y2
,
const
RealOpenMM
*
y12
,
void
getBicubicCoefficientMatrix
(
const
double
*
y
,
const
double
*
y1
,
const
double
*
y2
,
const
double
*
y12
,
const
RealOpenMM
d1
,
const
RealOpenMM
d2
,
RealOpenMM
c
[
4
][
4
])
const
;
const
double
d1
,
const
double
d2
,
double
c
[
4
][
4
])
const
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -176,11 +176,11 @@ private:
...
@@ -176,11 +176,11 @@ private:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
getBicubicValues
(
void
getBicubicValues
(
const
RealOpenMM
*
y
,
const
RealOpenMM
*
y1
,
const
RealOpenMM
*
y2
,
const
RealOpenMM
*
y12
,
const
double
*
y
,
const
double
*
y1
,
const
double
*
y2
,
const
double
*
y12
,
const
RealOpenMM
x1Lower
,
const
RealOpenMM
x1Upper
,
const
double
x1Lower
,
const
double
x1Upper
,
const
RealOpenMM
x2Lower
,
const
RealOpenMM
x2Upper
,
const
double
x2Lower
,
const
double
x2Upper
,
const
RealOpenMM
gridValue1
,
const
RealOpenMM
gridValue2
,
const
double
gridValue1
,
const
double
gridValue2
,
RealOpenMM
*
functionValue
,
RealOpenMM
*
functionValue1
,
RealOpenMM
*
functionValue2
)
const
;
double
*
functionValue
,
double
*
functionValue1
,
double
*
functionValue2
)
const
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -196,8 +196,8 @@ private:
...
@@ -196,8 +196,8 @@ private:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
checkTorsionSign
(
const
OpenMM
::
Real
Vec
&
positionAtomA
,
const
OpenMM
::
Real
Vec
&
positionAtomB
,
int
checkTorsionSign
(
const
OpenMM
::
Vec
3
&
positionAtomA
,
const
OpenMM
::
Vec
3
&
positionAtomB
,
const
OpenMM
::
Real
Vec
&
positionAtomC
,
const
OpenMM
::
Real
Vec
&
positionAtomD
)
const
;
const
OpenMM
::
Vec
3
&
positionAtomC
,
const
OpenMM
::
Vec
3
&
positionAtomD
)
const
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -217,11 +217,11 @@ private:
...
@@ -217,11 +217,11 @@ private:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
calculateTorsionTorsionIxn
(
const
OpenMM
::
Real
Vec
&
positionAtomA
,
const
OpenMM
::
Real
Vec
&
positionAtomB
,
double
calculateTorsionTorsionIxn
(
const
OpenMM
::
Vec
3
&
positionAtomA
,
const
OpenMM
::
Vec
3
&
positionAtomB
,
const
OpenMM
::
Real
Vec
&
positionAtomC
,
const
OpenMM
::
Real
Vec
&
positionAtomD
,
const
OpenMM
::
Vec
3
&
positionAtomC
,
const
OpenMM
::
Vec
3
&
positionAtomD
,
const
OpenMM
::
Real
Vec
&
positionAtomE
,
const
OpenMM
::
Real
Vec
*
chiralCheckAtom
,
const
OpenMM
::
Vec
3
&
positionAtomE
,
const
OpenMM
::
Vec
3
*
chiralCheckAtom
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>
>&
grid
,
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
double
>
>
>&
grid
,
OpenMM
::
Real
Vec
*
forces
)
const
;
OpenMM
::
Vec
3
*
forces
)
const
;
};
};
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceVdwForce.cpp
View file @
a783b996
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "ReferenceForce.h"
#include "ReferenceForce.h"
#include <algorithm>
#include <algorithm>
#include <cctype>
#include <cctype>
#include <cmath>
using
std
::
vector
;
using
std
::
vector
;
using
namespace
OpenMM
;
using
namespace
OpenMM
;
...
@@ -76,7 +77,7 @@ double AmoebaReferenceVdwForce::getCutoff() const {
...
@@ -76,7 +77,7 @@ double AmoebaReferenceVdwForce::getCutoff() const {
return
_cutoff
;
return
_cutoff
;
}
}
void
AmoebaReferenceVdwForce
::
setPeriodicBox
(
OpenMM
::
Real
Vec
*
vectors
)
{
void
AmoebaReferenceVdwForce
::
setPeriodicBox
(
OpenMM
::
Vec
3
*
vectors
)
{
_periodicBoxVectors
[
0
]
=
vectors
[
0
];
_periodicBoxVectors
[
0
]
=
vectors
[
0
];
_periodicBoxVectors
[
1
]
=
vectors
[
1
];
_periodicBoxVectors
[
1
]
=
vectors
[
1
];
_periodicBoxVectors
[
2
]
=
vectors
[
2
];
_periodicBoxVectors
[
2
]
=
vectors
[
2
];
...
@@ -102,22 +103,19 @@ std::string AmoebaReferenceVdwForce::getSigmaCombiningRule() const {
...
@@ -102,22 +103,19 @@ std::string AmoebaReferenceVdwForce::getSigmaCombiningRule() const {
return
_sigmaCombiningRule
;
return
_sigmaCombiningRule
;
}
}
RealOpenMM
AmoebaReferenceVdwForce
::
arithmeticSigmaCombiningRule
(
RealOpenMM
sigmaI
,
RealOpenMM
sigmaJ
)
const
{
double
AmoebaReferenceVdwForce
::
arithmeticSigmaCombiningRule
(
double
sigmaI
,
double
sigmaJ
)
const
{
return
(
sigmaI
+
sigmaJ
);
return
(
sigmaI
+
sigmaJ
);
}
}
RealOpenMM
AmoebaReferenceVdwForce
::
geometricSigmaCombiningRule
(
RealOpenMM
sigmaI
,
RealOpenMM
sigmaJ
)
const
{
double
AmoebaReferenceVdwForce
::
geometricSigmaCombiningRule
(
double
sigmaI
,
double
sigmaJ
)
const
{
return
2.0
*
SQRT
(
sigmaI
*
sigmaJ
);
return
2.0
*
sqrt
(
sigmaI
*
sigmaJ
);
}
}
RealOpenMM
AmoebaReferenceVdwForce
::
cubicMeanSigmaCombiningRule
(
RealOpenMM
sigmaI
,
RealOpenMM
sigmaJ
)
const
{
double
AmoebaReferenceVdwForce
::
cubicMeanSigmaCombiningRule
(
double
sigmaI
,
double
sigmaJ
)
const
{
double
sigmaI2
=
sigmaI
*
sigmaI
;
double
sigmaJ2
=
sigmaJ
*
sigmaJ
;
const
RealOpenMM
zero
=
0.0
;
return
sigmaI
!=
0.0
&&
sigmaJ
!=
0.0
?
2.0
*
(
sigmaI2
*
sigmaI
+
sigmaJ2
*
sigmaJ
)
/
(
sigmaI2
+
sigmaJ2
)
:
0.0
;
RealOpenMM
sigmaI2
=
sigmaI
*
sigmaI
;
RealOpenMM
sigmaJ2
=
sigmaJ
*
sigmaJ
;
return
sigmaI
!=
zero
&&
sigmaJ
!=
0.0
?
2.0
*
(
sigmaI2
*
sigmaI
+
sigmaJ2
*
sigmaJ
)
/
(
sigmaI2
+
sigmaJ2
)
:
zero
;
}
}
void
AmoebaReferenceVdwForce
::
setEpsilonCombiningRule
(
const
std
::
string
&
epsilonCombiningRule
)
{
void
AmoebaReferenceVdwForce
::
setEpsilonCombiningRule
(
const
std
::
string
&
epsilonCombiningRule
)
{
...
@@ -142,97 +140,83 @@ std::string AmoebaReferenceVdwForce::getEpsilonCombiningRule() const {
...
@@ -142,97 +140,83 @@ std::string AmoebaReferenceVdwForce::getEpsilonCombiningRule() const {
return
_epsilonCombiningRule
;
return
_epsilonCombiningRule
;
}
}
RealOpenMM
AmoebaReferenceVdwForce
::
arithmeticEpsilonCombiningRule
(
RealOpenMM
epsilonI
,
RealOpenMM
epsilonJ
)
const
{
double
AmoebaReferenceVdwForce
::
arithmeticEpsilonCombiningRule
(
double
epsilonI
,
double
epsilonJ
)
const
{
return
0.5
*
(
epsilonI
+
epsilonJ
);
return
0.5
*
(
epsilonI
+
epsilonJ
);
}
}
RealOpenMM
AmoebaReferenceVdwForce
::
geometricEpsilonCombiningRule
(
RealOpenMM
epsilonI
,
RealOpenMM
epsilonJ
)
const
{
double
AmoebaReferenceVdwForce
::
geometricEpsilonCombiningRule
(
double
epsilonI
,
double
epsilonJ
)
const
{
return
SQRT
(
epsilonI
*
epsilonJ
);
return
sqrt
(
epsilonI
*
epsilonJ
);
}
}
RealOpenMM
AmoebaReferenceVdwForce
::
harmonicEpsilonCombiningRule
(
RealOpenMM
epsilonI
,
RealOpenMM
epsilonJ
)
const
{
double
AmoebaReferenceVdwForce
::
harmonicEpsilonCombiningRule
(
double
epsilonI
,
double
epsilonJ
)
const
{
return
(
epsilonI
!=
0.0
&&
epsilonJ
!=
0.0
)
?
2.0
*
(
epsilonI
*
epsilonJ
)
/
(
epsilonI
+
epsilonJ
)
:
0.0
;
return
(
epsilonI
!=
0.0
&&
epsilonJ
!=
0.0
)
?
2.0
*
(
epsilonI
*
epsilonJ
)
/
(
epsilonI
+
epsilonJ
)
:
0.0
;
}
}
RealOpenMM
AmoebaReferenceVdwForce
::
hhgEpsilonCombiningRule
(
RealOpenMM
epsilonI
,
RealOpenMM
epsilonJ
)
const
{
double
AmoebaReferenceVdwForce
::
hhgEpsilonCombiningRule
(
double
epsilonI
,
double
epsilonJ
)
const
{
RealOpenMM
denominator
=
SQRT
(
epsilonI
)
+
SQRT
(
epsilonJ
);
double
denominator
=
sqrt
(
epsilonI
)
+
sqrt
(
epsilonJ
);
return
(
epsilonI
!=
0.0
&&
epsilonJ
!=
0.0
)
?
4.0
*
(
epsilonI
*
epsilonJ
)
/
(
denominator
*
denominator
)
:
0.0
;
return
(
epsilonI
!=
0.0
&&
epsilonJ
!=
0.0
)
?
4.0
*
(
epsilonI
*
epsilonJ
)
/
(
denominator
*
denominator
)
:
0.0
;
}
}
void
AmoebaReferenceVdwForce
::
addReducedForce
(
unsigned
int
particleI
,
unsigned
int
particleIV
,
void
AmoebaReferenceVdwForce
::
addReducedForce
(
unsigned
int
particleI
,
unsigned
int
particleIV
,
RealOpenMM
reduction
,
RealOpenMM
sign
,
double
reduction
,
double
sign
,
Vec3
&
force
,
vector
<
RealVec
>&
forces
)
const
{
Vec3
&
force
,
vector
<
Vec3
>&
forces
)
const
{
// ---------------------------------------------------------------------------------------
static
const
RealOpenMM
one
=
1.0
;
// ---------------------------------------------------------------------------------------
forces
[
particleI
][
0
]
+=
sign
*
force
[
0
]
*
reduction
;
forces
[
particleI
][
0
]
+=
sign
*
force
[
0
]
*
reduction
;
forces
[
particleI
][
1
]
+=
sign
*
force
[
1
]
*
reduction
;
forces
[
particleI
][
1
]
+=
sign
*
force
[
1
]
*
reduction
;
forces
[
particleI
][
2
]
+=
sign
*
force
[
2
]
*
reduction
;
forces
[
particleI
][
2
]
+=
sign
*
force
[
2
]
*
reduction
;
forces
[
particleIV
][
0
]
+=
sign
*
force
[
0
]
*
(
one
-
reduction
);
forces
[
particleIV
][
0
]
+=
sign
*
force
[
0
]
*
(
1.0
-
reduction
);
forces
[
particleIV
][
1
]
+=
sign
*
force
[
1
]
*
(
one
-
reduction
);
forces
[
particleIV
][
1
]
+=
sign
*
force
[
1
]
*
(
1.0
-
reduction
);
forces
[
particleIV
][
2
]
+=
sign
*
force
[
2
]
*
(
one
-
reduction
);
forces
[
particleIV
][
2
]
+=
sign
*
force
[
2
]
*
(
1.0
-
reduction
);
}
}
RealOpenMM
AmoebaReferenceVdwForce
::
calculatePairIxn
(
RealOpenMM
combinedSigma
,
RealOpenMM
combinedEpsilon
,
double
AmoebaReferenceVdwForce
::
calculatePairIxn
(
double
combinedSigma
,
double
combinedEpsilon
,
const
Vec3
&
particleIPosition
,
const
Vec3
&
particleIPosition
,
const
Vec3
&
particleJPosition
,
const
Vec3
&
particleJPosition
,
Vec3
&
force
)
const
{
Vec3
&
force
)
const
{
// ---------------------------------------------------------------------------------------
static
const
double
dhal
=
0.07
;
static
const
double
ghal
=
0.12
;
static
const
RealOpenMM
one
=
1.0
;
static
const
RealOpenMM
two
=
2.0
;
static
const
RealOpenMM
seven
=
7.0
;
static
const
RealOpenMM
dhal
=
0.07
;
static
const
RealOpenMM
ghal
=
0.12
;
// ---------------------------------------------------------------------------------------
// get deltaR, R2, and R between 2 atoms
// get deltaR, R2, and R between 2 atoms
RealOpenMM
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
double
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
if
(
_nonbondedMethod
==
CutoffPeriodic
)
if
(
_nonbondedMethod
==
CutoffPeriodic
)
ReferenceForce
::
getDeltaRPeriodic
(
particleJPosition
,
particleIPosition
,
_periodicBoxVectors
,
deltaR
);
ReferenceForce
::
getDeltaRPeriodic
(
particleJPosition
,
particleIPosition
,
_periodicBoxVectors
,
deltaR
);
else
else
ReferenceForce
::
getDeltaR
(
particleJPosition
,
particleIPosition
,
deltaR
);
ReferenceForce
::
getDeltaR
(
particleJPosition
,
particleIPosition
,
deltaR
);
RealOpenMM
r_ij_2
=
deltaR
[
ReferenceForce
::
R2Index
];
double
r_ij_2
=
deltaR
[
ReferenceForce
::
R2Index
];
RealOpenMM
r_ij
=
deltaR
[
ReferenceForce
::
RIndex
];
double
r_ij
=
deltaR
[
ReferenceForce
::
RIndex
];
RealOpenMM
sigma_7
=
combinedSigma
*
combinedSigma
*
combinedSigma
;
double
sigma_7
=
combinedSigma
*
combinedSigma
*
combinedSigma
;
sigma_7
=
sigma_7
*
sigma_7
*
combinedSigma
;
sigma_7
=
sigma_7
*
sigma_7
*
combinedSigma
;
RealOpenMM
r_ij_6
=
r_ij_2
*
r_ij_2
*
r_ij_2
;
double
r_ij_6
=
r_ij_2
*
r_ij_2
*
r_ij_2
;
RealOpenMM
r_ij_7
=
r_ij_6
*
r_ij
;
double
r_ij_7
=
r_ij_6
*
r_ij
;
RealOpenMM
rho
=
r_ij_7
+
ghal
*
sigma_7
;
double
rho
=
r_ij_7
+
ghal
*
sigma_7
;
RealOpenMM
tau
=
(
dhal
+
one
)
/
(
r_ij
+
dhal
*
combinedSigma
);
double
tau
=
(
dhal
+
1.0
)
/
(
r_ij
+
dhal
*
combinedSigma
);
RealOpenMM
tau_7
=
tau
*
tau
*
tau
;
double
tau_7
=
tau
*
tau
*
tau
;
tau_7
=
tau_7
*
tau_7
*
tau
;
tau_7
=
tau_7
*
tau_7
*
tau
;
RealOpenMM
dtau
=
tau
/
(
dhal
+
one
);
double
dtau
=
tau
/
(
dhal
+
1.0
);
RealOpenMM
ratio
=
(
sigma_7
/
rho
);
double
ratio
=
(
sigma_7
/
rho
);
RealOpenMM
gtau
=
combinedEpsilon
*
tau_7
*
r_ij_6
*
(
ghal
+
one
)
*
ratio
*
ratio
;
double
gtau
=
combinedEpsilon
*
tau_7
*
r_ij_6
*
(
ghal
+
1.0
)
*
ratio
*
ratio
;
RealOpenMM
energy
=
combinedEpsilon
*
tau_7
*
sigma_7
*
((
ghal
+
one
)
*
sigma_7
/
rho
-
two
);
double
energy
=
combinedEpsilon
*
tau_7
*
sigma_7
*
((
ghal
+
1.0
)
*
sigma_7
/
rho
-
2.0
);
RealOpenMM
dEdR
=
-
seven
*
(
dtau
*
energy
+
gtau
);
double
dEdR
=
-
7.0
*
(
dtau
*
energy
+
gtau
);
// tapering
// tapering
if
((
_nonbondedMethod
==
CutoffNonPeriodic
||
_nonbondedMethod
==
CutoffPeriodic
)
&&
r_ij
>
_taperCutoff
)
{
if
((
_nonbondedMethod
==
CutoffNonPeriodic
||
_nonbondedMethod
==
CutoffPeriodic
)
&&
r_ij
>
_taperCutoff
)
{
RealOpenMM
delta
=
r_ij
-
_taperCutoff
;
double
delta
=
r_ij
-
_taperCutoff
;
RealOpenMM
taper
=
1.0
+
delta
*
delta
*
delta
*
(
_taperCoefficients
[
C3
]
+
delta
*
(
_taperCoefficients
[
C4
]
+
delta
*
_taperCoefficients
[
C5
]));
double
taper
=
1.0
+
delta
*
delta
*
delta
*
(
_taperCoefficients
[
C3
]
+
delta
*
(
_taperCoefficients
[
C4
]
+
delta
*
_taperCoefficients
[
C5
]));
RealOpenMM
dtaper
=
delta
*
delta
*
(
3.0
*
_taperCoefficients
[
C3
]
+
delta
*
(
4.0
*
_taperCoefficients
[
C4
]
+
delta
*
5.0
*
_taperCoefficients
[
C5
]));
double
dtaper
=
delta
*
delta
*
(
3.0
*
_taperCoefficients
[
C3
]
+
delta
*
(
4.0
*
_taperCoefficients
[
C4
]
+
delta
*
5.0
*
_taperCoefficients
[
C5
]));
dEdR
=
energy
*
dtaper
+
dEdR
*
taper
;
dEdR
=
energy
*
dtaper
+
dEdR
*
taper
;
energy
*=
taper
;
energy
*=
taper
;
}
}
dEdR
/=
r_ij
;
dEdR
/=
r_ij
;
...
@@ -246,16 +230,14 @@ RealOpenMM AmoebaReferenceVdwForce::calculatePairIxn(RealOpenMM combinedSigma, R
...
@@ -246,16 +230,14 @@ RealOpenMM AmoebaReferenceVdwForce::calculatePairIxn(RealOpenMM combinedSigma, R
}
}
void
AmoebaReferenceVdwForce
::
setReducedPositions
(
int
numParticles
,
void
AmoebaReferenceVdwForce
::
setReducedPositions
(
int
numParticles
,
const
vector
<
Real
Vec
>&
particlePositions
,
const
vector
<
Vec
3
>&
particlePositions
,
const
std
::
vector
<
int
>&
indexIVs
,
const
std
::
vector
<
int
>&
indexIVs
,
const
std
::
vector
<
RealOpenMM
>&
reductions
,
const
std
::
vector
<
double
>&
reductions
,
std
::
vector
<
Vec3
>&
reducedPositions
)
const
{
std
::
vector
<
Vec3
>&
reducedPositions
)
const
{
static
const
RealOpenMM
zero
=
0.0
;
reducedPositions
.
resize
(
numParticles
);
reducedPositions
.
resize
(
numParticles
);
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
numParticles
);
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
numParticles
);
ii
++
)
{
if
(
reductions
[
ii
]
!=
zero
)
{
if
(
reductions
[
ii
]
!=
0.0
)
{
int
reductionIndex
=
indexIVs
[
ii
];
int
reductionIndex
=
indexIVs
[
ii
];
reducedPositions
[
ii
]
=
Vec3
(
reductions
[
ii
]
*
(
particlePositions
[
ii
][
0
]
-
particlePositions
[
reductionIndex
][
0
])
+
particlePositions
[
reductionIndex
][
0
],
reducedPositions
[
ii
]
=
Vec3
(
reductions
[
ii
]
*
(
particlePositions
[
ii
][
0
]
-
particlePositions
[
reductionIndex
][
0
])
+
particlePositions
[
reductionIndex
][
0
],
reductions
[
ii
]
*
(
particlePositions
[
ii
][
1
]
-
particlePositions
[
reductionIndex
][
1
])
+
particlePositions
[
reductionIndex
][
1
],
reductions
[
ii
]
*
(
particlePositions
[
ii
][
1
]
-
particlePositions
[
reductionIndex
][
1
])
+
particlePositions
[
reductionIndex
][
1
],
...
@@ -266,22 +248,14 @@ void AmoebaReferenceVdwForce::setReducedPositions(int numParticles,
...
@@ -266,22 +248,14 @@ void AmoebaReferenceVdwForce::setReducedPositions(int numParticles,
}
}
}
}
RealOpenMM
AmoebaReferenceVdwForce
::
calculateForceAndEnergy
(
int
numParticles
,
double
AmoebaReferenceVdwForce
::
calculateForceAndEnergy
(
int
numParticles
,
const
vector
<
RealVec
>&
particlePositions
,
const
vector
<
Vec3
>&
particlePositions
,
const
std
::
vector
<
int
>&
indexIVs
,
const
std
::
vector
<
int
>&
indexIVs
,
const
std
::
vector
<
RealOpenMM
>&
sigmas
,
const
std
::
vector
<
double
>&
sigmas
,
const
std
::
vector
<
RealOpenMM
>&
epsilons
,
const
std
::
vector
<
double
>&
epsilons
,
const
std
::
vector
<
RealOpenMM
>&
reductions
,
const
std
::
vector
<
double
>&
reductions
,
const
std
::
vector
<
std
::
set
<
int
>
>&
allExclusions
,
const
std
::
vector
<
std
::
set
<
int
>
>&
allExclusions
,
vector
<
RealVec
>&
forces
)
const
{
vector
<
Vec3
>&
forces
)
const
{
// ---------------------------------------------------------------------------------------
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
static
const
RealOpenMM
two
=
2.0
;
// ---------------------------------------------------------------------------------------
// set reduced coordinates
// set reduced coordinates
...
@@ -297,12 +271,12 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
...
@@ -297,12 +271,12 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
// based on reduction factor
// based on reduction factor
// (4) reset exclusion vector
// (4) reset exclusion vector
RealOpenMM
energy
=
zero
;
double
energy
=
0.0
;
std
::
vector
<
unsigned
int
>
exclusions
(
numParticles
,
0
);
std
::
vector
<
unsigned
int
>
exclusions
(
numParticles
,
0
);
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
numParticles
);
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
numParticles
);
ii
++
)
{
RealOpenMM
sigmaI
=
sigmas
[
ii
];
double
sigmaI
=
sigmas
[
ii
];
RealOpenMM
epsilonI
=
epsilons
[
ii
];
double
epsilonI
=
epsilons
[
ii
];
for
(
std
::
set
<
int
>::
const_iterator
jj
=
allExclusions
[
ii
].
begin
();
jj
!=
allExclusions
[
ii
].
end
();
jj
++
)
{
for
(
std
::
set
<
int
>::
const_iterator
jj
=
allExclusions
[
ii
].
begin
();
jj
!=
allExclusions
[
ii
].
end
();
jj
++
)
{
exclusions
[
*
jj
]
=
1
;
exclusions
[
*
jj
]
=
1
;
}
}
...
@@ -310,8 +284,8 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
...
@@ -310,8 +284,8 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
for
(
unsigned
int
jj
=
ii
+
1
;
jj
<
static_cast
<
unsigned
int
>
(
numParticles
);
jj
++
)
{
for
(
unsigned
int
jj
=
ii
+
1
;
jj
<
static_cast
<
unsigned
int
>
(
numParticles
);
jj
++
)
{
if
(
exclusions
[
jj
]
==
0
)
{
if
(
exclusions
[
jj
]
==
0
)
{
RealOpenMM
combinedSigma
=
(
this
->*
_combineSigmas
)(
sigmaI
,
sigmas
[
jj
]);
double
combinedSigma
=
(
this
->*
_combineSigmas
)(
sigmaI
,
sigmas
[
jj
]);
RealOpenMM
combinedEpsilon
=
(
this
->*
_combineEpsilons
)(
epsilonI
,
epsilons
[
jj
]);
double
combinedEpsilon
=
(
this
->*
_combineEpsilons
)(
epsilonI
,
epsilons
[
jj
]);
Vec3
force
;
Vec3
force
;
energy
+=
calculatePairIxn
(
combinedSigma
,
combinedEpsilon
,
energy
+=
calculatePairIxn
(
combinedSigma
,
combinedEpsilon
,
...
@@ -323,14 +297,14 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
...
@@ -323,14 +297,14 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
forces
[
ii
][
1
]
-=
force
[
1
];
forces
[
ii
][
1
]
-=
force
[
1
];
forces
[
ii
][
2
]
-=
force
[
2
];
forces
[
ii
][
2
]
-=
force
[
2
];
}
else
{
}
else
{
addReducedForce
(
ii
,
indexIVs
[
ii
],
reductions
[
ii
],
-
one
,
force
,
forces
);
addReducedForce
(
ii
,
indexIVs
[
ii
],
reductions
[
ii
],
-
1.0
,
force
,
forces
);
}
}
if
(
indexIVs
[
jj
]
==
jj
)
{
if
(
indexIVs
[
jj
]
==
jj
)
{
forces
[
jj
][
0
]
+=
force
[
0
];
forces
[
jj
][
0
]
+=
force
[
0
];
forces
[
jj
][
1
]
+=
force
[
1
];
forces
[
jj
][
1
]
+=
force
[
1
];
forces
[
jj
][
2
]
+=
force
[
2
];
forces
[
jj
][
2
]
+=
force
[
2
];
}
else
{
}
else
{
addReducedForce
(
jj
,
indexIVs
[
jj
],
reductions
[
jj
],
one
,
force
,
forces
);
addReducedForce
(
jj
,
indexIVs
[
jj
],
reductions
[
jj
],
1.0
,
force
,
forces
);
}
}
}
}
...
@@ -344,22 +318,14 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
...
@@ -344,22 +318,14 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
return
energy
;
return
energy
;
}
}
RealOpenMM
AmoebaReferenceVdwForce
::
calculateForceAndEnergy
(
int
numParticles
,
double
AmoebaReferenceVdwForce
::
calculateForceAndEnergy
(
int
numParticles
,
const
vector
<
RealVec
>&
particlePositions
,
const
vector
<
Vec3
>&
particlePositions
,
const
std
::
vector
<
int
>&
indexIVs
,
const
std
::
vector
<
int
>&
indexIVs
,
const
std
::
vector
<
RealOpenMM
>&
sigmas
,
const
std
::
vector
<
double
>&
sigmas
,
const
std
::
vector
<
RealOpenMM
>&
epsilons
,
const
std
::
vector
<
double
>&
epsilons
,
const
std
::
vector
<
RealOpenMM
>&
reductions
,
const
std
::
vector
<
double
>&
reductions
,
const
NeighborList
&
neighborList
,
const
NeighborList
&
neighborList
,
vector
<
RealVec
>&
forces
)
const
{
vector
<
Vec3
>&
forces
)
const
{
// ---------------------------------------------------------------------------------------
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
static
const
RealOpenMM
two
=
2.0
;
// ---------------------------------------------------------------------------------------
// set reduced coordinates
// set reduced coordinates
...
@@ -372,15 +338,15 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
...
@@ -372,15 +338,15 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
// then call addReducedForce() to apportion force to particle and its covalent partner
// then call addReducedForce() to apportion force to particle and its covalent partner
// based on reduction factor
// based on reduction factor
RealOpenMM
energy
=
zero
;
double
energy
=
0.0
;
for
(
unsigned
int
ii
=
0
;
ii
<
neighborList
.
size
();
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
neighborList
.
size
();
ii
++
)
{
OpenMM
::
AtomPair
pair
=
neighborList
[
ii
];
OpenMM
::
AtomPair
pair
=
neighborList
[
ii
];
int
siteI
=
pair
.
first
;
int
siteI
=
pair
.
first
;
int
siteJ
=
pair
.
second
;
int
siteJ
=
pair
.
second
;
RealOpenMM
combinedSigma
=
(
this
->*
_combineSigmas
)(
sigmas
[
siteI
],
sigmas
[
siteJ
]);
double
combinedSigma
=
(
this
->*
_combineSigmas
)(
sigmas
[
siteI
],
sigmas
[
siteJ
]);
RealOpenMM
combinedEpsilon
=
(
this
->*
_combineEpsilons
)(
epsilons
[
siteI
],
epsilons
[
siteJ
]);
double
combinedEpsilon
=
(
this
->*
_combineEpsilons
)(
epsilons
[
siteI
],
epsilons
[
siteJ
]);
Vec3
force
;
Vec3
force
;
energy
+=
calculatePairIxn
(
combinedSigma
,
combinedEpsilon
,
energy
+=
calculatePairIxn
(
combinedSigma
,
combinedEpsilon
,
...
@@ -391,14 +357,14 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
...
@@ -391,14 +357,14 @@ RealOpenMM AmoebaReferenceVdwForce::calculateForceAndEnergy(int numParticles,
forces
[
siteI
][
1
]
-=
force
[
1
];
forces
[
siteI
][
1
]
-=
force
[
1
];
forces
[
siteI
][
2
]
-=
force
[
2
];
forces
[
siteI
][
2
]
-=
force
[
2
];
}
else
{
}
else
{
addReducedForce
(
siteI
,
indexIVs
[
siteI
],
reductions
[
siteI
],
-
one
,
force
,
forces
);
addReducedForce
(
siteI
,
indexIVs
[
siteI
],
reductions
[
siteI
],
-
1.0
,
force
,
forces
);
}
}
if
(
indexIVs
[
siteJ
]
==
siteJ
)
{
if
(
indexIVs
[
siteJ
]
==
siteJ
)
{
forces
[
siteJ
][
0
]
+=
force
[
0
];
forces
[
siteJ
][
0
]
+=
force
[
0
];
forces
[
siteJ
][
1
]
+=
force
[
1
];
forces
[
siteJ
][
1
]
+=
force
[
1
];
forces
[
siteJ
][
2
]
+=
force
[
2
];
forces
[
siteJ
][
2
]
+=
force
[
2
];
}
else
{
}
else
{
addReducedForce
(
siteJ
,
indexIVs
[
siteJ
],
reductions
[
siteJ
],
one
,
force
,
forces
);
addReducedForce
(
siteJ
,
indexIVs
[
siteJ
],
reductions
[
siteJ
],
1.0
,
force
,
forces
);
}
}
}
}
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceVdwForce.h
View file @
a783b996
...
@@ -25,7 +25,6 @@
...
@@ -25,7 +25,6 @@
#ifndef __AmoebaReferenceVdwForce_H__
#ifndef __AmoebaReferenceVdwForce_H__
#define __AmoebaReferenceVdwForce_H__
#define __AmoebaReferenceVdwForce_H__
#include "RealVec.h"
#include "openmm/Vec3.h"
#include "openmm/Vec3.h"
#include "ReferenceNeighborList.h"
#include "ReferenceNeighborList.h"
#include <string>
#include <string>
...
@@ -34,7 +33,7 @@
...
@@ -34,7 +33,7 @@
namespace
OpenMM
{
namespace
OpenMM
{
class
AmoebaReferenceVdwForce
;
class
AmoebaReferenceVdwForce
;
typedef
RealOpenMM
(
AmoebaReferenceVdwForce
::*
CombiningFunction
)(
RealOpenMM
x
,
RealOpenMM
y
)
const
;
typedef
double
(
AmoebaReferenceVdwForce
::*
CombiningFunction
)(
double
x
,
double
y
)
const
;
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -178,7 +177,7 @@ public:
...
@@ -178,7 +177,7 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
setPeriodicBox
(
OpenMM
::
Real
Vec
*
vectors
);
void
setPeriodicBox
(
OpenMM
::
Vec
3
*
vectors
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -197,12 +196,12 @@ public:
...
@@ -197,12 +196,12 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
calculateForceAndEnergy
(
int
numParticles
,
const
std
::
vector
<
OpenMM
::
Real
Vec
>&
particlePositions
,
double
calculateForceAndEnergy
(
int
numParticles
,
const
std
::
vector
<
OpenMM
::
Vec
3
>&
particlePositions
,
const
std
::
vector
<
int
>&
indexIVs
,
const
std
::
vector
<
int
>&
indexIVs
,
const
std
::
vector
<
RealOpenMM
>&
sigmas
,
const
std
::
vector
<
RealOpenMM
>&
epsilons
,
const
std
::
vector
<
double
>&
sigmas
,
const
std
::
vector
<
double
>&
epsilons
,
const
std
::
vector
<
RealOpenMM
>&
reductions
,
const
std
::
vector
<
double
>&
reductions
,
const
std
::
vector
<
std
::
set
<
int
>
>&
vdwExclusions
,
const
std
::
vector
<
std
::
set
<
int
>
>&
vdwExclusions
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
)
const
;
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
)
const
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -221,12 +220,12 @@ public:
...
@@ -221,12 +220,12 @@ public:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
calculateForceAndEnergy
(
int
numParticles
,
const
std
::
vector
<
OpenMM
::
Real
Vec
>&
particlePositions
,
double
calculateForceAndEnergy
(
int
numParticles
,
const
std
::
vector
<
OpenMM
::
Vec
3
>&
particlePositions
,
const
std
::
vector
<
int
>&
indexIVs
,
const
std
::
vector
<
int
>&
indexIVs
,
const
std
::
vector
<
RealOpenMM
>&
sigmas
,
const
std
::
vector
<
RealOpenMM
>&
epsilons
,
const
std
::
vector
<
double
>&
sigmas
,
const
std
::
vector
<
double
>&
epsilons
,
const
std
::
vector
<
RealOpenMM
>&
reductions
,
const
std
::
vector
<
double
>&
reductions
,
const
NeighborList
&
neighborList
,
const
NeighborList
&
neighborList
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
)
const
;
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
)
const
;
private:
private:
...
@@ -242,18 +241,18 @@ private:
...
@@ -242,18 +241,18 @@ private:
double
_cutoff
;
double
_cutoff
;
double
_taperCutoffFactor
;
double
_taperCutoffFactor
;
double
_taperCutoff
;
double
_taperCutoff
;
RealOpenMM
_taperCoefficients
[
3
];
double
_taperCoefficients
[
3
];
Real
Vec
_periodicBoxVectors
[
3
];
Vec
3
_periodicBoxVectors
[
3
];
CombiningFunction
_combineSigmas
;
CombiningFunction
_combineSigmas
;
RealOpenMM
arithmeticSigmaCombiningRule
(
RealOpenMM
sigmaI
,
RealOpenMM
sigmaJ
)
const
;
double
arithmeticSigmaCombiningRule
(
double
sigmaI
,
double
sigmaJ
)
const
;
RealOpenMM
geometricSigmaCombiningRule
(
RealOpenMM
sigmaI
,
RealOpenMM
sigmaJ
)
const
;
double
geometricSigmaCombiningRule
(
double
sigmaI
,
double
sigmaJ
)
const
;
RealOpenMM
cubicMeanSigmaCombiningRule
(
RealOpenMM
sigmaI
,
RealOpenMM
sigmaJ
)
const
;
double
cubicMeanSigmaCombiningRule
(
double
sigmaI
,
double
sigmaJ
)
const
;
CombiningFunction
_combineEpsilons
;
CombiningFunction
_combineEpsilons
;
RealOpenMM
arithmeticEpsilonCombiningRule
(
RealOpenMM
epsilonI
,
RealOpenMM
epsilonJ
)
const
;
double
arithmeticEpsilonCombiningRule
(
double
epsilonI
,
double
epsilonJ
)
const
;
RealOpenMM
geometricEpsilonCombiningRule
(
RealOpenMM
epsilonI
,
RealOpenMM
epsilonJ
)
const
;
double
geometricEpsilonCombiningRule
(
double
epsilonI
,
double
epsilonJ
)
const
;
RealOpenMM
harmonicEpsilonCombiningRule
(
RealOpenMM
epsilonI
,
RealOpenMM
epsilonJ
)
const
;
double
harmonicEpsilonCombiningRule
(
double
epsilonI
,
double
epsilonJ
)
const
;
RealOpenMM
hhgEpsilonCombiningRule
(
RealOpenMM
epsilonI
,
RealOpenMM
epsilonJ
)
const
;
double
hhgEpsilonCombiningRule
(
double
epsilonI
,
double
epsilonJ
)
const
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -272,8 +271,8 @@ private:
...
@@ -272,8 +271,8 @@ private:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
setReducedPositions
(
int
numParticles
,
const
std
::
vector
<
Real
Vec
>&
particlePositions
,
void
setReducedPositions
(
int
numParticles
,
const
std
::
vector
<
Vec
3
>&
particlePositions
,
const
std
::
vector
<
int
>&
indexIVs
,
const
std
::
vector
<
RealOpenMM
>&
reductions
,
const
std
::
vector
<
int
>&
indexIVs
,
const
std
::
vector
<
double
>&
reductions
,
std
::
vector
<
Vec3
>&
reducedPositions
)
const
;
std
::
vector
<
Vec3
>&
reducedPositions
)
const
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -290,8 +289,8 @@ private:
...
@@ -290,8 +289,8 @@ private:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
addReducedForce
(
unsigned
int
particleI
,
unsigned
int
particleIV
,
void
addReducedForce
(
unsigned
int
particleI
,
unsigned
int
particleIV
,
RealOpenMM
reduction
,
RealOpenMM
sign
,
double
reduction
,
double
sign
,
Vec3
&
force
,
std
::
vector
<
OpenMM
::
Real
Vec
>&
forces
)
const
;
Vec3
&
force
,
std
::
vector
<
OpenMM
::
Vec
3
>&
forces
)
const
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -317,9 +316,9 @@ private:
...
@@ -317,9 +316,9 @@ private:
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
calculatePairIxn
(
RealOpenMM
combindedSigma
,
RealOpenMM
combindedEpsilon
,
double
calculatePairIxn
(
double
combindedSigma
,
double
combindedEpsilon
,
const
Vec3
&
particleIPosition
,
const
Vec3
&
particleJPosition
,
const
Vec3
&
particleIPosition
,
const
Vec3
&
particleJPosition
,
Vec3
&
force
)
const
;
Vec3
&
force
)
const
;
};
};
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceWcaDispersionForce.cpp
View file @
a783b996
...
@@ -24,221 +24,207 @@
...
@@ -24,221 +24,207 @@
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceForce.h"
#include "AmoebaReferenceWcaDispersionForce.h"
#include "AmoebaReferenceWcaDispersionForce.h"
#include <cmath>
using
std
::
vector
;
using
std
::
vector
;
using
namespace
OpenMM
;
using
namespace
OpenMM
;
AmoebaReferenceWcaDispersionForce
::
AmoebaReferenceWcaDispersionForce
(
RealOpenMM
epso
,
RealOpenMM
epsh
,
RealOpenMM
rmino
,
RealOpenMM
rminh
,
AmoebaReferenceWcaDispersionForce
::
AmoebaReferenceWcaDispersionForce
(
double
epso
,
double
epsh
,
double
rmino
,
double
rminh
,
RealOpenMM
awater
,
RealOpenMM
shctd
,
RealOpenMM
dispoff
,
RealOpenMM
slevy
)
:
double
awater
,
double
shctd
,
double
dispoff
,
double
slevy
)
:
_epso
(
epso
),
_epsh
(
epsh
),
_rmino
(
rmino
),
_rminh
(
rminh
),
_awater
(
awater
),
_shctd
(
shctd
),
_dispoff
(
dispoff
),
_slevy
(
slevy
)
{
_epso
(
epso
),
_epsh
(
epsh
),
_rmino
(
rmino
),
_rminh
(
rminh
),
_awater
(
awater
),
_shctd
(
shctd
),
_dispoff
(
dispoff
),
_slevy
(
slevy
)
{
}
}
RealOpenMM
AmoebaReferenceWcaDispersionForce
::
calculatePairIxn
(
RealOpenMM
radiusI
,
RealOpenMM
radiusK
,
double
AmoebaReferenceWcaDispersionForce
::
calculatePairIxn
(
double
radiusI
,
double
radiusK
,
const
Real
Vec
&
particleIPosition
,
const
Vec
3
&
particleIPosition
,
const
Real
Vec
&
particleJPosition
,
const
Vec
3
&
particleJPosition
,
const
RealOpenMM
*
const
intermediateValues
,
const
double
*
const
intermediateValues
,
Vec3
&
force
)
const
{
Vec3
&
force
)
const
{
// ---------------------------------------------------------------------------------------
static
const
double
PI
=
M_PI
;
static
const
RealOpenMM
zero
=
0.0
;
double
xr
=
particleIPosition
[
0
]
-
particleJPosition
[
0
];
static
const
RealOpenMM
one
=
1.0
;
double
yr
=
particleIPosition
[
1
]
-
particleJPosition
[
1
];
static
const
RealOpenMM
two
=
2.0
;
double
zr
=
particleIPosition
[
2
]
-
particleJPosition
[
2
];
static
const
RealOpenMM
three
=
3.0
;
static
const
RealOpenMM
four
=
4.0
;
static
const
RealOpenMM
five
=
5.0
;
static
const
RealOpenMM
six
=
6.0
;
static
const
RealOpenMM
seven
=
7.0
;
static
const
RealOpenMM
eight
=
8.0
;
static
const
RealOpenMM
ten
=
10.0
;
static
const
RealOpenMM
fortyEight
=
48.0
;
static
const
RealOpenMM
PI
=
3.1415926535897932384
;
// ---------------------------------------------------------------------------------------
double
r2
=
xr
*
xr
+
yr
*
yr
+
zr
*
zr
;
double
r
=
sqrt
(
r2
);
double
r3
=
r2
*
r
;
RealOpenMM
xr
=
particleIPosition
[
0
]
-
particleJPosition
[
0
];
double
sK
=
radiusK
*
_shctd
;
RealOpenMM
yr
=
particleIPosition
[
1
]
-
particleJPosition
[
1
];
double
sK2
=
sK
*
sK
;
RealOpenMM
zr
=
particleIPosition
[
2
]
-
particleJPosition
[
2
];
RealOpenMM
r2
=
xr
*
xr
+
yr
*
yr
+
zr
*
zr
;
double
rmixo
=
intermediateValues
[
RMIXO
];
RealOpenMM
r
=
SQRT
(
r2
);
double
rmixo7
=
intermediateValues
[
RMIXO7
];
RealOpenMM
r3
=
r2
*
r
;
RealOpenMM
sK
=
radiusK
*
_shctd
;
double
emixo
=
intermediateValues
[
EMIXO
];
RealOpenMM
sK2
=
sK
*
sK
;
RealOpenMM
rmix
o
=
intermediateValues
[
RMIX
O
];
double
rmix
h
=
intermediateValues
[
RMIX
H
];
RealOpenMM
rmix
o
7
=
intermediateValues
[
RMIX
O
7
];
double
rmix
h
7
=
intermediateValues
[
RMIX
H
7
];
RealOpenMM
emix
o
=
intermediateValues
[
EMIX
O
];
double
emix
h
=
intermediateValues
[
EMIX
H
];
RealOpenMM
rmixh
=
intermediateValues
[
RMIXH
];
double
ao
=
intermediateValues
[
AO
];
RealOpenMM
rmixh7
=
intermediateValues
[
RMIXH7
];
double
ah
=
intermediateValues
[
AH
];
RealOpenMM
emixh
=
intermediateValues
[
EMIXH
];
double
sum
=
0.0
;
double
de
=
0.0
;
RealOpenMM
ao
=
intermediateValues
[
AO
];
RealOpenMM
ah
=
intermediateValues
[
AH
];
RealOpenMM
sum
=
zero
;
RealOpenMM
de
=
zero
;
if
(
radiusI
<
(
r
+
sK
))
{
if
(
radiusI
<
(
r
+
sK
))
{
RealOpenMM
rmax
=
(
radiusI
>
(
r
-
sK
))
?
radiusI
:
(
r
-
sK
);
double
rmax
=
(
radiusI
>
(
r
-
sK
))
?
radiusI
:
(
r
-
sK
);
RealOpenMM
lik
=
rmax
;
double
lik
=
rmax
;
RealOpenMM
lik2
=
lik
*
lik
;
double
lik2
=
lik
*
lik
;
RealOpenMM
lik3
=
lik2
*
lik
;
double
lik3
=
lik2
*
lik
;
RealOpenMM
lik4
=
lik2
*
lik2
;
double
lik4
=
lik2
*
lik2
;
if
(
lik
<
rmixo
)
{
if
(
lik
<
rmixo
)
{
RealOpenMM
uik
=
(
r
+
sK
)
<
rmixo
?
(
r
+
sK
)
:
rmixo
;
double
uik
=
(
r
+
sK
)
<
rmixo
?
(
r
+
sK
)
:
rmixo
;
RealOpenMM
uik2
=
uik
*
uik
;
double
uik2
=
uik
*
uik
;
RealOpenMM
uik3
=
uik2
*
uik
;
double
uik3
=
uik2
*
uik
;
RealOpenMM
uik4
=
uik2
*
uik2
;
double
uik4
=
uik2
*
uik2
;
RealOpenMM
term
=
four
*
PI
/
(
fortyEight
*
r
)
*
(
three
*
(
lik4
-
uik4
)
-
eight
*
r
*
(
lik3
-
uik3
)
+
six
*
(
r2
-
sK2
)
*
(
lik2
-
uik2
));
double
term
=
4.0
*
PI
/
(
48.0
*
r
)
*
(
3.0
*
(
lik4
-
uik4
)
-
8.0
*
r
*
(
lik3
-
uik3
)
+
6.0
*
(
r2
-
sK2
)
*
(
lik2
-
uik2
));
RealOpenMM
dl
;
double
dl
;
if
(
radiusI
>
(
r
-
sK
))
{
if
(
radiusI
>
(
r
-
sK
))
{
dl
=
-
lik2
+
two
*
(
r2
+
sK2
);
dl
=
-
lik2
+
2.0
*
(
r2
+
sK2
);
dl
*=
lik2
;
dl
*=
lik2
;
}
else
{
}
else
{
dl
=
-
lik3
+
four
*
lik2
*
r
-
six
*
lik
*
r2
+
two
*
lik
*
sK2
+
four
*
r
*
(
r2
-
sK2
);
dl
=
-
lik3
+
4.0
*
lik2
*
r
-
6.0
*
lik
*
r2
+
2.0
*
lik
*
sK2
+
4.0
*
r
*
(
r2
-
sK2
);
dl
*=
lik
;
dl
*=
lik
;
}
}
RealOpenMM
du
;
double
du
;
if
((
r
+
sK
)
>
rmixo
)
{
if
((
r
+
sK
)
>
rmixo
)
{
du
=
-
uik2
+
two
*
(
r2
+
sK2
);
du
=
-
uik2
+
2.0
*
(
r2
+
sK2
);
du
*=
-
uik2
;
du
*=
-
uik2
;
}
else
{
}
else
{
du
=
-
uik3
+
four
*
uik2
*
r
-
six
*
uik
*
r2
+
two
*
uik
*
sK2
+
four
*
r
*
(
r2
-
sK2
);
du
=
-
uik3
+
4.0
*
uik2
*
r
-
6.0
*
uik
*
r2
+
2.0
*
uik
*
sK2
+
4.0
*
r
*
(
r2
-
sK2
);
du
*=
-
uik
;
du
*=
-
uik
;
}
}
de
=
-
emixo
*
PI
*
(
dl
+
du
)
/
(
four
*
r2
);
de
=
-
emixo
*
PI
*
(
dl
+
du
)
/
(
4.0
*
r2
);
sum
+=
-
emixo
*
term
;
sum
+=
-
emixo
*
term
;
}
}
if
(
lik
<
rmixh
)
{
if
(
lik
<
rmixh
)
{
RealOpenMM
uik
=
(
r
+
sK
)
<
rmixh
?
(
r
+
sK
)
:
rmixh
;
double
uik
=
(
r
+
sK
)
<
rmixh
?
(
r
+
sK
)
:
rmixh
;
RealOpenMM
uik2
=
uik
*
uik
;
double
uik2
=
uik
*
uik
;
RealOpenMM
uik3
=
uik2
*
uik
;
double
uik3
=
uik2
*
uik
;
RealOpenMM
uik4
=
uik2
*
uik2
;
double
uik4
=
uik2
*
uik2
;
RealOpenMM
term
=
four
*
PI
/
(
fortyEight
*
r
)
*
(
three
*
(
lik4
-
uik4
)
-
eight
*
r
*
(
lik3
-
uik3
)
+
six
*
(
r2
-
sK2
)
*
(
lik2
-
uik2
));
double
term
=
4.0
*
PI
/
(
48.0
*
r
)
*
(
3.0
*
(
lik4
-
uik4
)
-
8.0
*
r
*
(
lik3
-
uik3
)
+
6.0
*
(
r2
-
sK2
)
*
(
lik2
-
uik2
));
RealOpenMM
dl
;
double
dl
;
if
(
radiusI
>
(
r
-
sK
))
{
if
(
radiusI
>
(
r
-
sK
))
{
dl
=
-
lik2
+
two
*
(
r2
+
sK2
);
dl
=
-
lik2
+
2.0
*
(
r2
+
sK2
);
dl
*=
lik2
;
dl
*=
lik2
;
}
else
{
}
else
{
dl
=
-
lik3
+
four
*
lik2
*
r
-
six
*
lik
*
r2
+
two
*
lik
*
sK2
+
four
*
r
*
(
r2
-
sK2
);
dl
=
-
lik3
+
4.0
*
lik2
*
r
-
6.0
*
lik
*
r2
+
2.0
*
lik
*
sK2
+
4.0
*
r
*
(
r2
-
sK2
);
dl
*=
lik
;
dl
*=
lik
;
}
}
RealOpenMM
du
;
double
du
;
if
(
r
+
sK
>
rmixh
)
{
if
(
r
+
sK
>
rmixh
)
{
du
=
-
uik2
+
two
*
(
r2
+
sK2
);
du
=
-
uik2
+
2.0
*
(
r2
+
sK2
);
du
*=
-
uik2
;
du
*=
-
uik2
;
}
else
{
}
else
{
du
=
-
uik3
+
four
*
uik2
*
r
-
six
*
uik
*
r2
+
two
*
uik
*
sK2
+
four
*
r
*
(
r2
-
sK2
);
du
=
-
uik3
+
4.0
*
uik2
*
r
-
6.0
*
uik
*
r2
+
2.0
*
uik
*
sK2
+
4.0
*
r
*
(
r2
-
sK2
);
du
*=
-
uik
;
du
*=
-
uik
;
}
}
de
-=
two
*
emixh
*
PI
*
(
dl
+
du
)
/
(
four
*
r2
);
de
-=
2.0
*
emixh
*
PI
*
(
dl
+
du
)
/
(
4.0
*
r2
);
sum
-=
two
*
emixh
*
term
;
sum
-=
2.0
*
emixh
*
term
;
}
}
RealOpenMM
uik
=
r
+
sK
;
double
uik
=
r
+
sK
;
RealOpenMM
uik2
=
uik
*
uik
;
double
uik2
=
uik
*
uik
;
RealOpenMM
uik3
=
uik2
*
uik
;
double
uik3
=
uik2
*
uik
;
RealOpenMM
uik4
=
uik2
*
uik2
;
double
uik4
=
uik2
*
uik2
;
RealOpenMM
uik5
=
uik3
*
uik2
;
double
uik5
=
uik3
*
uik2
;
RealOpenMM
uik6
=
uik3
*
uik3
;
double
uik6
=
uik3
*
uik3
;
RealOpenMM
uik10
=
uik5
*
uik5
;
double
uik10
=
uik5
*
uik5
;
RealOpenMM
uik11
=
uik5
*
uik6
;
double
uik11
=
uik5
*
uik6
;
RealOpenMM
uik12
=
uik6
*
uik6
;
double
uik12
=
uik6
*
uik6
;
RealOpenMM
uik13
=
uik10
*
uik3
;
double
uik13
=
uik10
*
uik3
;
if
(
uik
>
rmixo
)
{
if
(
uik
>
rmixo
)
{
RealOpenMM
lik
=
rmax
>
rmixo
?
rmax
:
rmixo
;
double
lik
=
rmax
>
rmixo
?
rmax
:
rmixo
;
RealOpenMM
lik2
=
lik
*
lik
;
double
lik2
=
lik
*
lik
;
RealOpenMM
lik3
=
lik2
*
lik
;
double
lik3
=
lik2
*
lik
;
RealOpenMM
lik4
=
lik2
*
lik2
;
double
lik4
=
lik2
*
lik2
;
RealOpenMM
lik5
=
lik2
*
lik3
;
double
lik5
=
lik2
*
lik3
;
RealOpenMM
lik6
=
lik3
*
lik3
;
double
lik6
=
lik3
*
lik3
;
RealOpenMM
lik10
=
lik5
*
lik5
;
double
lik10
=
lik5
*
lik5
;
RealOpenMM
lik11
=
lik5
*
lik6
;
double
lik11
=
lik5
*
lik6
;
RealOpenMM
lik12
=
lik6
*
lik6
;
double
lik12
=
lik6
*
lik6
;
RealOpenMM
lik13
=
lik10
*
lik3
;
double
lik13
=
lik10
*
lik3
;
RealOpenMM
term
=
four
*
PI
/
(
120.0
*
r
*
lik5
*
uik5
)
*
(
15.0
*
uik
*
lik
*
r
*
(
uik4
-
lik4
)
-
ten
*
uik2
*
lik2
*
(
uik3
-
lik3
)
+
six
*
(
sK2
-
r2
)
*
(
uik5
-
lik5
));
double
term
=
4.0
*
PI
/
(
120.0
*
r
*
lik5
*
uik5
)
*
(
15.0
*
uik
*
lik
*
r
*
(
uik4
-
lik4
)
-
10.0
*
uik2
*
lik2
*
(
uik3
-
lik3
)
+
6.0
*
(
sK2
-
r2
)
*
(
uik5
-
lik5
));
RealOpenMM
dl
;
double
dl
;
if
(
radiusI
>
(
r
-
sK
)
||
rmax
<
rmixo
)
{
if
(
radiusI
>
(
r
-
sK
)
||
rmax
<
rmixo
)
{
dl
=
-
five
*
lik2
+
three
*
(
r2
+
sK2
);
dl
=
-
5.0
*
lik2
+
3.0
*
(
r2
+
sK2
);
dl
/=
-
lik5
;
dl
/=
-
lik5
;
}
else
{
}
else
{
dl
=
five
*
lik3
-
33.0
*
lik
*
r2
-
three
*
lik
*
sK2
+
15.0
*
(
lik2
*
r
+
r3
-
r
*
sK2
);
dl
=
5.0
*
lik3
-
33.0
*
lik
*
r2
-
3.0
*
lik
*
sK2
+
15.0
*
(
lik2
*
r
+
r3
-
r
*
sK2
);
dl
/=
lik6
;
dl
/=
lik6
;
}
}
RealOpenMM
du
=
five
*
uik3
-
33.0
*
uik
*
r2
-
three
*
uik
*
sK2
+
15.0
*
(
uik2
*
r
+
r3
-
r
*
sK2
);
double
du
=
5.0
*
uik3
-
33.0
*
uik
*
r2
-
3.0
*
uik
*
sK2
+
15.0
*
(
uik2
*
r
+
r3
-
r
*
sK2
);
du
/=
-
uik6
;
du
/=
-
uik6
;
RealOpenMM
idisp
=
-
two
*
ao
*
term
;
double
idisp
=
-
2.0
*
ao
*
term
;
de
-=
two
*
ao
*
PI
*
(
dl
+
du
)
/
(
15.0
*
r2
);
de
-=
2.0
*
ao
*
PI
*
(
dl
+
du
)
/
(
15.0
*
r2
);
term
=
four
*
PI
/
(
2640.0
*
r
*
lik12
*
uik12
)
*
(
120.0
*
uik
*
lik
*
r
*
(
uik11
-
lik11
)
-
66.0
*
uik2
*
lik2
*
(
uik10
-
lik10
)
+
55.0
*
(
sK2
-
r2
)
*
(
uik12
-
lik12
));
term
=
4.0
*
PI
/
(
2640.0
*
r
*
lik12
*
uik12
)
*
(
120.0
*
uik
*
lik
*
r
*
(
uik11
-
lik11
)
-
66.0
*
uik2
*
lik2
*
(
uik10
-
lik10
)
+
55.0
*
(
sK2
-
r2
)
*
(
uik12
-
lik12
));
if
(
radiusI
>
(
r
-
sK
)
||
rmax
<
rmixo
)
{
if
(
radiusI
>
(
r
-
sK
)
||
rmax
<
rmixo
)
{
dl
=
-
six
*
lik2
+
five
*
r2
+
five
*
sK2
;
dl
=
-
6.0
*
lik2
+
5.0
*
r2
+
5.0
*
sK2
;
dl
/=
-
lik12
;
dl
/=
-
lik12
;
}
else
{
}
else
{
dl
=
six
*
lik3
-
125.0
*
lik
*
r2
-
five
*
lik
*
sK2
+
60.0
*
(
lik2
*
r
+
r3
-
r
*
sK2
);
dl
=
6.0
*
lik3
-
125.0
*
lik
*
r2
-
5.0
*
lik
*
sK2
+
60.0
*
(
lik2
*
r
+
r3
-
r
*
sK2
);
dl
/=
lik13
;
dl
/=
lik13
;
}
}
du
=
six
*
uik3
-
125.0
*
uik
*
r2
-
five
*
uik
*
sK2
+
60.0
*
(
uik2
*
r
+
r3
-
r
*
sK2
);
du
=
6.0
*
uik3
-
125.0
*
uik
*
r2
-
5.0
*
uik
*
sK2
+
60.0
*
(
uik2
*
r
+
r3
-
r
*
sK2
);
du
/=
-
uik13
;
du
/=
-
uik13
;
de
+=
ao
*
rmixo7
*
PI
*
(
dl
+
du
)
/
(
60.0
*
r2
);
de
+=
ao
*
rmixo7
*
PI
*
(
dl
+
du
)
/
(
60.0
*
r2
);
sum
+=
ao
*
rmixo7
*
term
+
idisp
;
sum
+=
ao
*
rmixo7
*
term
+
idisp
;
}
}
if
(
uik
>
rmixh
)
{
if
(
uik
>
rmixh
)
{
lik
=
rmax
>
rmixh
?
rmax
:
rmixh
;
lik
=
rmax
>
rmixh
?
rmax
:
rmixh
;
lik2
=
lik
*
lik
;
lik2
=
lik
*
lik
;
lik3
=
lik2
*
lik
;
lik3
=
lik2
*
lik
;
lik4
=
lik2
*
lik2
;
lik4
=
lik2
*
lik2
;
RealOpenMM
lik5
=
lik2
*
lik3
;
double
lik5
=
lik2
*
lik3
;
RealOpenMM
lik6
=
lik3
*
lik3
;
double
lik6
=
lik3
*
lik3
;
RealOpenMM
lik10
=
lik5
*
lik5
;
double
lik10
=
lik5
*
lik5
;
RealOpenMM
lik11
=
lik5
*
lik6
;
double
lik11
=
lik5
*
lik6
;
RealOpenMM
lik12
=
lik6
*
lik6
;
double
lik12
=
lik6
*
lik6
;
RealOpenMM
lik13
=
lik3
*
lik10
;
double
lik13
=
lik3
*
lik10
;
RealOpenMM
term
=
four
*
PI
/
(
120.0
*
r
*
lik5
*
uik5
)
*
(
15.0
*
uik
*
lik
*
r
*
(
uik4
-
lik4
)
-
ten
*
uik2
*
lik2
*
(
uik3
-
lik3
)
+
six
*
(
sK2
-
r2
)
*
(
uik5
-
lik5
));
double
term
=
4.0
*
PI
/
(
120.0
*
r
*
lik5
*
uik5
)
*
(
15.0
*
uik
*
lik
*
r
*
(
uik4
-
lik4
)
-
10.0
*
uik2
*
lik2
*
(
uik3
-
lik3
)
+
6.0
*
(
sK2
-
r2
)
*
(
uik5
-
lik5
));
RealOpenMM
dl
;
double
dl
;
if
(
radiusI
>
(
r
-
sK
)
||
rmax
<
rmixh
)
{
if
(
radiusI
>
(
r
-
sK
)
||
rmax
<
rmixh
)
{
dl
=
-
five
*
lik2
+
three
*
(
r2
+
sK2
);
dl
=
-
5.0
*
lik2
+
3.0
*
(
r2
+
sK2
);
dl
/=
-
lik5
;
dl
/=
-
lik5
;
}
else
{
}
else
{
dl
=
five
*
lik3
-
33.0
*
lik
*
r2
-
three
*
lik
*
sK2
+
15.0
*
(
lik2
*
r
+
r3
-
r
*
sK2
);
dl
=
5.0
*
lik3
-
33.0
*
lik
*
r2
-
3.0
*
lik
*
sK2
+
15.0
*
(
lik2
*
r
+
r3
-
r
*
sK2
);
dl
/=
lik6
;
dl
/=
lik6
;
}
}
RealOpenMM
du
=
five
*
uik3
-
33.0
*
uik
*
r2
-
3.0
*
uik
*
sK2
+
15.0
*
(
uik2
*
r
+
r3
-
r
*
sK2
);
double
du
=
5.0
*
uik3
-
33.0
*
uik
*
r2
-
3.0
*
uik
*
sK2
+
15.0
*
(
uik2
*
r
+
r3
-
r
*
sK2
);
du
/=
-
uik6
;
du
/=
-
uik6
;
RealOpenMM
idisp
=
-
four
*
ah
*
term
;
double
idisp
=
-
4.0
*
ah
*
term
;
de
=
de
-
four
*
ah
*
PI
*
(
dl
+
du
)
/
(
15.0
*
r2
);
de
=
de
-
4.0
*
ah
*
PI
*
(
dl
+
du
)
/
(
15.0
*
r2
);
term
=
four
*
PI
/
(
2640.0
*
r
*
lik12
*
uik12
)
*
(
120.0
*
uik
*
lik
*
r
*
(
uik11
-
lik11
)
-
66.0
*
uik2
*
lik2
*
(
uik10
-
lik10
)
+
55.0
*
(
sK2
-
r2
)
*
(
uik12
-
lik12
));
term
=
4.0
*
PI
/
(
2640.0
*
r
*
lik12
*
uik12
)
*
(
120.0
*
uik
*
lik
*
r
*
(
uik11
-
lik11
)
-
66.0
*
uik2
*
lik2
*
(
uik10
-
lik10
)
+
55.0
*
(
sK2
-
r2
)
*
(
uik12
-
lik12
));
if
(
radiusI
>
(
r
-
sK
)
||
rmax
<
rmixh
)
{
if
(
radiusI
>
(
r
-
sK
)
||
rmax
<
rmixh
)
{
dl
=
-
six
*
lik2
+
five
*
r2
+
five
*
sK2
;
dl
=
-
6.0
*
lik2
+
5.0
*
r2
+
5.0
*
sK2
;
dl
=
-
dl
/
lik12
;
dl
=
-
dl
/
lik12
;
}
else
{;
}
else
{;
dl
=
six
*
lik3
-
125.0
*
lik
*
r2
-
five
*
lik
*
sK2
+
60.0
*
(
lik2
*
r
+
r3
-
r
*
sK2
);
dl
=
6.0
*
lik3
-
125.0
*
lik
*
r2
-
5.0
*
lik
*
sK2
+
60.0
*
(
lik2
*
r
+
r3
-
r
*
sK2
);
dl
=
dl
/
lik13
;
dl
=
dl
/
lik13
;
}
}
du
=
six
*
uik3
-
125.0
*
uik
*
r2
-
five
*
uik
*
sK2
+
60.0
*
(
uik2
*
r
+
r3
-
r
*
sK2
);
du
=
6.0
*
uik3
-
125.0
*
uik
*
r2
-
5.0
*
uik
*
sK2
+
60.0
*
(
uik2
*
r
+
r3
-
r
*
sK2
);
du
/=
-
uik13
;
du
/=
-
uik13
;
RealOpenMM
irep
=
two
*
ah
*
rmixh7
*
term
;
double
irep
=
2.0
*
ah
*
rmixh7
*
term
;
de
+=
ah
*
rmixh7
*
PI
*
(
dl
+
du
)
/
(
30.0
*
r2
);
de
+=
ah
*
rmixh7
*
PI
*
(
dl
+
du
)
/
(
30.0
*
r2
);
sum
+=
irep
+
idisp
;
sum
+=
irep
+
idisp
;
}
}
}
}
...
@@ -254,70 +240,59 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn(RealOpenMM radius
...
@@ -254,70 +240,59 @@ RealOpenMM AmoebaReferenceWcaDispersionForce::calculatePairIxn(RealOpenMM radius
}
}
RealOpenMM
AmoebaReferenceWcaDispersionForce
::
calculateForceAndEnergy
(
int
numParticles
,
double
AmoebaReferenceWcaDispersionForce
::
calculateForceAndEnergy
(
int
numParticles
,
const
vector
<
RealVec
>&
particlePositions
,
const
vector
<
Vec3
>&
particlePositions
,
const
std
::
vector
<
RealOpenMM
>&
radii
,
const
std
::
vector
<
double
>&
radii
,
const
std
::
vector
<
RealOpenMM
>&
epsilons
,
const
std
::
vector
<
double
>&
epsilons
,
RealOpenMM
totalMaximumDispersionEnergy
,
double
totalMaximumDispersionEnergy
,
vector
<
RealVec
>&
forces
)
const
{
vector
<
Vec3
>&
forces
)
const
{
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceWcaDispersionForce::calculateForceAndEnergy";
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
static
const
RealOpenMM
two
=
2.0
;
static
const
RealOpenMM
four
=
4.0
;
// ---------------------------------------------------------------------------------------
// loop over all ixns
// loop over all ixns
RealOpenMM
energy
=
zero
;
double
energy
=
0.0
;
RealOpenMM
rmino2
=
_rmino
*
_rmino
;
double
rmino2
=
_rmino
*
_rmino
;
RealOpenMM
rmino3
=
rmino2
*
_rmino
;
double
rmino3
=
rmino2
*
_rmino
;
RealOpenMM
rminh2
=
_rminh
*
_rminh
;
double
rminh2
=
_rminh
*
_rminh
;
RealOpenMM
rminh3
=
rminh2
*
_rminh
;
double
rminh3
=
rminh2
*
_rminh
;
RealOpenMM
intermediateValues
[
LastIntermediateValueIndex
];
double
intermediateValues
[
LastIntermediateValueIndex
];
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
numParticles
);
ii
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
numParticles
);
ii
++
)
{
RealOpenMM
epsi
=
epsilons
[
ii
];
double
epsi
=
epsilons
[
ii
];
RealOpenMM
rmini
=
radii
[
ii
];
double
rmini
=
radii
[
ii
];
RealOpenMM
denominator
=
SQRT
(
_epso
)
+
SQRT
(
epsi
);
double
denominator
=
sqrt
(
_epso
)
+
sqrt
(
epsi
);
RealOpenMM
emixo
=
four
*
_epso
*
epsi
/
(
denominator
*
denominator
);
double
emixo
=
4.0
*
_epso
*
epsi
/
(
denominator
*
denominator
);
intermediateValues
[
EMIXO
]
=
emixo
;
intermediateValues
[
EMIXO
]
=
emixo
;
RealOpenMM
rminI2
=
rmini
*
rmini
;
double
rminI2
=
rmini
*
rmini
;
RealOpenMM
rminI3
=
rminI2
*
rmini
;
double
rminI3
=
rminI2
*
rmini
;
RealOpenMM
rmixo
=
two
*
(
rmino3
+
rminI3
)
/
(
rmino2
+
rminI2
);
double
rmixo
=
2.0
*
(
rmino3
+
rminI3
)
/
(
rmino2
+
rminI2
);
intermediateValues
[
RMIXO
]
=
rmixo
;
intermediateValues
[
RMIXO
]
=
rmixo
;
RealOpenMM
rmixo7
=
rmixo
*
rmixo
*
rmixo
;
double
rmixo7
=
rmixo
*
rmixo
*
rmixo
;
rmixo7
=
rmixo7
*
rmixo7
*
rmixo
;
rmixo7
=
rmixo7
*
rmixo7
*
rmixo
;
intermediateValues
[
RMIXO7
]
=
rmixo7
;
intermediateValues
[
RMIXO7
]
=
rmixo7
;
intermediateValues
[
AO
]
=
emixo
*
rmixo7
;
intermediateValues
[
AO
]
=
emixo
*
rmixo7
;
denominator
=
SQRT
(
_epsh
)
+
SQRT
(
epsi
);
denominator
=
sqrt
(
_epsh
)
+
sqrt
(
epsi
);
RealOpenMM
emixh
=
four
*
_epsh
*
epsi
/
(
denominator
*
denominator
);
double
emixh
=
4.0
*
_epsh
*
epsi
/
(
denominator
*
denominator
);
intermediateValues
[
EMIXH
]
=
emixh
;
intermediateValues
[
EMIXH
]
=
emixh
;
RealOpenMM
rmixh
=
two
*
(
rminh3
+
rminI3
)
/
(
rminh2
+
rminI2
);
double
rmixh
=
2.0
*
(
rminh3
+
rminI3
)
/
(
rminh2
+
rminI2
);
intermediateValues
[
RMIXH
]
=
rmixh
;
intermediateValues
[
RMIXH
]
=
rmixh
;
RealOpenMM
rmixh7
=
rmixh
*
rmixh
*
rmixh
;
double
rmixh7
=
rmixh
*
rmixh
*
rmixh
;
rmixh7
=
rmixh7
*
rmixh7
*
rmixh
;
rmixh7
=
rmixh7
*
rmixh7
*
rmixh
;
intermediateValues
[
RMIXH7
]
=
rmixh7
;
intermediateValues
[
RMIXH7
]
=
rmixh7
;
intermediateValues
[
AH
]
=
emixh
*
rmixh7
;
intermediateValues
[
AH
]
=
emixh
*
rmixh7
;
for
(
unsigned
int
jj
=
0
;
jj
<
static_cast
<
unsigned
int
>
(
numParticles
);
jj
++
)
{
for
(
unsigned
int
jj
=
0
;
jj
<
static_cast
<
unsigned
int
>
(
numParticles
);
jj
++
)
{
...
...
Prev
1
…
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