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
0843c5f3
Commit
0843c5f3
authored
Jan 03, 2011
by
Peter Eastman
Browse files
First stage of a refactoring to clean up the reference platform
parent
bacc1eff
Changes
86
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
280 additions
and
522 deletions
+280
-522
platforms/reference/src/SimTKReference/ReferenceVariableStochasticDynamics.h
.../src/SimTKReference/ReferenceVariableStochasticDynamics.h
+10
-11
platforms/reference/src/SimTKReference/ReferenceVariableVerletDynamics.cpp
...ce/src/SimTKReference/ReferenceVariableVerletDynamics.cpp
+8
-11
platforms/reference/src/SimTKReference/ReferenceVariableVerletDynamics.h
...ence/src/SimTKReference/ReferenceVariableVerletDynamics.h
+4
-4
platforms/reference/src/SimTKReference/ReferenceVerletDynamics.cpp
.../reference/src/SimTKReference/ReferenceVerletDynamics.cpp
+8
-11
platforms/reference/src/SimTKReference/ReferenceVerletDynamics.h
...ms/reference/src/SimTKReference/ReferenceVerletDynamics.h
+4
-4
platforms/reference/src/SimTKUtilities/RealVec.h
platforms/reference/src/SimTKUtilities/RealVec.h
+162
-0
platforms/reference/src/SimTKUtilities/SimTKOpenMMCommon.h
platforms/reference/src/SimTKUtilities/SimTKOpenMMCommon.h
+1
-1
platforms/reference/src/SimTKUtilities/SimTKOpenMMUtilities.h
...forms/reference/src/SimTKUtilities/SimTKOpenMMUtilities.h
+1
-1
platforms/reference/src/gbsa/CpuGBVI.cpp
platforms/reference/src/gbsa/CpuGBVI.cpp
+11
-125
platforms/reference/src/gbsa/CpuGBVI.h
platforms/reference/src/gbsa/CpuGBVI.h
+12
-48
platforms/reference/src/gbsa/CpuImplicitSolvent.cpp
platforms/reference/src/gbsa/CpuImplicitSolvent.cpp
+8
-163
platforms/reference/src/gbsa/CpuImplicitSolvent.h
platforms/reference/src/gbsa/CpuImplicitSolvent.h
+6
-23
platforms/reference/src/gbsa/CpuObc.cpp
platforms/reference/src/gbsa/CpuObc.cpp
+6
-3
platforms/reference/src/gbsa/CpuObc.h
platforms/reference/src/gbsa/CpuObc.h
+3
-3
platforms/reference/src/gbsa/cpuObcInterface.cpp
platforms/reference/src/gbsa/cpuObcInterface.cpp
+5
-2
platforms/reference/src/gbsa/cpuObcInterface.h
platforms/reference/src/gbsa/cpuObcInterface.h
+4
-3
platforms/reference/tests/TestReferenceNeighborList.cpp
platforms/reference/tests/TestReferenceNeighborList.cpp
+7
-20
plugins/freeEnergy/platforms/reference/src/ReferenceFreeEnergyKernels.cpp
...gy/platforms/reference/src/ReferenceFreeEnergyKernels.cpp
+13
-32
plugins/freeEnergy/platforms/reference/src/SimTKReference/ReferenceFreeEnergyLJCoulomb14Softcore.cpp
...SimTKReference/ReferenceFreeEnergyLJCoulomb14Softcore.cpp
+5
-55
plugins/freeEnergy/platforms/reference/src/SimTKReference/ReferenceFreeEnergyLJCoulomb14Softcore.h
...c/SimTKReference/ReferenceFreeEnergyLJCoulomb14Softcore.h
+2
-2
No files found.
platforms/reference/src/SimTKReference/ReferenceVariableStochasticDynamics.h
View file @
0843c5f3
...
@@ -33,9 +33,8 @@ class ReferenceVariableStochasticDynamics : public ReferenceDynamics {
...
@@ -33,9 +33,8 @@ class ReferenceVariableStochasticDynamics : public ReferenceDynamics {
private:
private:
enum
TwoDArrayIndicies
{
xPrime2D
,
Max2DArrays
};
std
::
vector
<
OpenMM
::
RealVec
>
xPrime
;
enum
OneDArrayIndicies
{
InverseMasses
,
Max1DArrays
};
std
::
vector
<
RealOpenMM
>
inverseMasses
;
RealOpenMM
_tau
,
_accuracy
;
RealOpenMM
_tau
,
_accuracy
;
public:
public:
...
@@ -104,8 +103,8 @@ class ReferenceVariableStochasticDynamics : public ReferenceDynamics {
...
@@ -104,8 +103,8 @@ class ReferenceVariableStochasticDynamics : public ReferenceDynamics {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
update
(
int
numberOfAtoms
,
RealOpenMM
**
atomCoordinates
,
int
update
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
**
velocities
,
RealOpenMM
**
forces
,
RealOpenMM
*
masses
,
RealOpenMM
maxStepSize
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
maxStepSize
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -124,9 +123,9 @@ class ReferenceVariableStochasticDynamics : public ReferenceDynamics {
...
@@ -124,9 +123,9 @@ class ReferenceVariableStochasticDynamics : public ReferenceDynamics {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
updatePart1
(
int
numberOfAtoms
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
velocities
,
int
updatePart1
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
RealOpenMM
**
forces
,
RealOpenMM
*
masses
,
RealOpenMM
*
inverseMasses
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
**
xPrime
,
RealOpenMM
maxStepSize
);
std
::
vector
<
OpenMM
::
RealVec
>&
xPrime
,
RealOpenMM
maxStepSize
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -142,9 +141,9 @@ class ReferenceVariableStochasticDynamics : public ReferenceDynamics {
...
@@ -142,9 +141,9 @@ class ReferenceVariableStochasticDynamics : public ReferenceDynamics {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
updatePart2
(
int
numberOfAtoms
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
velocities
,
int
updatePart2
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
RealOpenMM
**
forces
,
RealOpenMM
*
inverseMasses
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
inverseMasses
,
RealOpenMM
**
xPrime
);
std
::
vector
<
OpenMM
::
RealVec
>&
xPrime
);
};
};
...
...
platforms/reference/src/SimTKReference/ReferenceVariableVerletDynamics.cpp
View file @
0843c5f3
...
@@ -30,6 +30,9 @@
...
@@ -30,6 +30,9 @@
#include "../SimTKUtilities/SimTKOpenMMUtilities.h"
#include "../SimTKUtilities/SimTKOpenMMUtilities.h"
#include "ReferenceVariableVerletDynamics.h"
#include "ReferenceVariableVerletDynamics.h"
using
std
::
vector
;
using
OpenMM
::
RealVec
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
ReferenceVariableVerletDynamics constructor
ReferenceVariableVerletDynamics constructor
...
@@ -52,9 +55,8 @@ ReferenceVariableVerletDynamics::ReferenceVariableVerletDynamics( int numberOfAt
...
@@ -52,9 +55,8 @@ ReferenceVariableVerletDynamics::ReferenceVariableVerletDynamics( int numberOfAt
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
allocate2DArrays
(
numberOfAtoms
,
3
,
Max2DArrays
);
xPrime
.
resize
(
numberOfAtoms
);
allocate1DArrays
(
numberOfAtoms
,
Max1DArrays
);
inverseMasses
.
resize
(
numberOfAtoms
);
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -111,9 +113,9 @@ void ReferenceVariableVerletDynamics::setAccuracy( RealOpenMM accuracy ) {
...
@@ -111,9 +113,9 @@ void ReferenceVariableVerletDynamics::setAccuracy( RealOpenMM accuracy ) {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceVariableVerletDynamics
::
update
(
int
numberOfAtoms
,
RealOpenMM
**
atomCoordinates
,
int
ReferenceVariableVerletDynamics
::
update
(
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
**
velocities
,
vector
<
RealVec
>&
velocities
,
RealOpenMM
**
forces
,
RealOpenMM
*
masses
,
RealOpenMM
maxStepSize
){
vector
<
RealVec
>&
forces
,
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
maxStepSize
){
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -124,11 +126,6 @@ int ReferenceVariableVerletDynamics::update( int numberOfAtoms, RealOpenMM** ato
...
@@ -124,11 +126,6 @@ int ReferenceVariableVerletDynamics::update( int numberOfAtoms, RealOpenMM** ato
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// get work arrays
RealOpenMM
**
xPrime
=
get2DArrayAtIndex
(
xPrime2D
);
RealOpenMM
*
inverseMasses
=
get1DArrayAtIndex
(
InverseMasses
);
// first-time-through initialization
// first-time-through initialization
if
(
getTimeStep
()
==
0
){
if
(
getTimeStep
()
==
0
){
...
...
platforms/reference/src/SimTKReference/ReferenceVariableVerletDynamics.h
View file @
0843c5f3
...
@@ -33,8 +33,8 @@ class ReferenceVariableVerletDynamics : public ReferenceDynamics {
...
@@ -33,8 +33,8 @@ class ReferenceVariableVerletDynamics : public ReferenceDynamics {
private:
private:
enum
TwoDArrayIndicies
{
xPrime2D
,
Max2DArrays
}
;
std
::
vector
<
OpenMM
::
RealVec
>
xPrime
;
enum
OneDArrayIndicies
{
InverseMasses
,
Max1DArrays
}
;
std
::
vector
<
RealOpenMM
>
inverseMasses
;
RealOpenMM
_accuracy
;
RealOpenMM
_accuracy
;
public:
public:
...
@@ -91,8 +91,8 @@ class ReferenceVariableVerletDynamics : public ReferenceDynamics {
...
@@ -91,8 +91,8 @@ class ReferenceVariableVerletDynamics : public ReferenceDynamics {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
update
(
int
numberOfAtoms
,
RealOpenMM
**
atomCoordinates
,
int
update
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
**
velocities
,
RealOpenMM
**
forces
,
RealOpenMM
*
masses
,
RealOpenMM
maxStepSize
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
,
RealOpenMM
maxStepSize
);
};
};
...
...
platforms/reference/src/SimTKReference/ReferenceVerletDynamics.cpp
View file @
0843c5f3
...
@@ -32,6 +32,9 @@
...
@@ -32,6 +32,9 @@
#include <cstdio>
#include <cstdio>
using
std
::
vector
;
using
OpenMM
::
RealVec
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
ReferenceVerletDynamics constructor
ReferenceVerletDynamics constructor
...
@@ -56,9 +59,8 @@ ReferenceVerletDynamics::ReferenceVerletDynamics( int numberOfAtoms,
...
@@ -56,9 +59,8 @@ ReferenceVerletDynamics::ReferenceVerletDynamics( int numberOfAtoms,
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
allocate2DArrays
(
numberOfAtoms
,
3
,
Max2DArrays
);
xPrime
.
resize
(
numberOfAtoms
);
allocate1DArrays
(
numberOfAtoms
,
Max1DArrays
);
inverseMasses
.
resize
(
numberOfAtoms
);
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -92,9 +94,9 @@ ReferenceVerletDynamics::~ReferenceVerletDynamics( ){
...
@@ -92,9 +94,9 @@ ReferenceVerletDynamics::~ReferenceVerletDynamics( ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
ReferenceVerletDynamics
::
update
(
int
numberOfAtoms
,
RealOpenMM
**
atomCoordinates
,
int
ReferenceVerletDynamics
::
update
(
int
numberOfAtoms
,
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
**
velocities
,
vector
<
RealVec
>&
velocities
,
RealOpenMM
**
forces
,
RealOpenMM
*
masses
){
vector
<
RealVec
>&
forces
,
vector
<
RealOpenMM
>&
masses
){
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -105,11 +107,6 @@ int ReferenceVerletDynamics::update( int numberOfAtoms, RealOpenMM** atomCoordin
...
@@ -105,11 +107,6 @@ int ReferenceVerletDynamics::update( int numberOfAtoms, RealOpenMM** atomCoordin
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// get work arrays
RealOpenMM
**
xPrime
=
get2DArrayAtIndex
(
xPrime2D
);
RealOpenMM
*
inverseMasses
=
get1DArrayAtIndex
(
InverseMasses
);
// first-time-through initialization
// first-time-through initialization
if
(
getTimeStep
()
==
0
){
if
(
getTimeStep
()
==
0
){
...
...
platforms/reference/src/SimTKReference/ReferenceVerletDynamics.h
View file @
0843c5f3
...
@@ -33,8 +33,8 @@ class ReferenceVerletDynamics : public ReferenceDynamics {
...
@@ -33,8 +33,8 @@ class ReferenceVerletDynamics : public ReferenceDynamics {
private:
private:
enum
TwoDArrayIndicies
{
xPrime2D
,
Max2DArrays
}
;
std
::
vector
<
OpenMM
::
RealVec
>
xPrime
;
enum
OneDArrayIndicies
{
InverseMasses
,
Max1DArrays
}
;
std
::
vector
<
RealOpenMM
>
inverseMasses
;
public:
public:
...
@@ -73,8 +73,8 @@ class ReferenceVerletDynamics : public ReferenceDynamics {
...
@@ -73,8 +73,8 @@ class ReferenceVerletDynamics : public ReferenceDynamics {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
update
(
int
numberOfAtoms
,
RealOpenMM
**
atomCoordinates
,
int
update
(
int
numberOfAtoms
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
**
velocities
,
RealOpenMM
**
forces
,
RealOpenMM
*
masses
);
std
::
vector
<
OpenMM
::
RealVec
>&
velocities
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
std
::
vector
<
RealOpenMM
>&
masses
);
};
};
...
...
platforms/reference/src/SimTKUtilities/RealVec.h
0 → 100644
View file @
0843c5f3
#ifndef OPENMM_REALVEC_H_
#define OPENMM_REALVEC_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2010 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "SimTKOpenMMRealType.h"
#include "openmm/Vec3.h"
#include <cassert>
#include <iosfwd>
namespace
OpenMM
{
/**
* This is identical to Vec3, except that the components are of type RealOpenMM, so
* it can be compiled in either single or double precision. Automatic conversion
* between this class and Vec3 is supported.
*/
class
RealVec
{
public:
/**
* Create a RealVec whose elements are all 0.
*/
RealVec
()
{
data
[
0
]
=
data
[
1
]
=
data
[
2
]
=
0.0
;
}
/**
* Create a RealVec with specified x, y, and z components.
*/
RealVec
(
RealOpenMM
x
,
RealOpenMM
y
,
RealOpenMM
z
)
{
data
[
0
]
=
x
;
data
[
1
]
=
y
;
data
[
2
]
=
z
;
}
/**
* Create a RealVec from a Vec3.
*/
RealVec
(
Vec3
v
)
{
data
[
0
]
=
v
[
0
];
data
[
1
]
=
v
[
1
];
data
[
2
]
=
v
[
2
];
}
/**
* Create a Vec3 from a RealVec.
*/
operator
Vec3
()
{
return
Vec3
(
data
[
0
],
data
[
1
],
data
[
2
]);
}
RealOpenMM
operator
[](
int
index
)
const
{
assert
(
index
>=
0
&&
index
<
3
);
return
data
[
index
];
}
RealOpenMM
&
operator
[](
int
index
)
{
assert
(
index
>=
0
&&
index
<
3
);
return
data
[
index
];
}
// Arithmetic operators
// unary plus
RealVec
operator
+
()
const
{
return
RealVec
(
*
this
);
}
// plus
RealVec
operator
+
(
const
RealVec
&
rhs
)
const
{
const
RealVec
&
lhs
=
*
this
;
return
RealVec
(
lhs
[
0
]
+
rhs
[
0
],
lhs
[
1
]
+
rhs
[
1
],
lhs
[
2
]
+
rhs
[
2
]);
}
RealVec
&
operator
+=
(
const
RealVec
&
rhs
)
{
data
[
0
]
+=
rhs
[
0
];
data
[
1
]
+=
rhs
[
1
];
data
[
2
]
+=
rhs
[
2
];
return
*
this
;
}
// unary minus
RealVec
operator
-
()
const
{
const
RealVec
&
lhs
=
*
this
;
return
RealVec
(
-
lhs
[
0
],
-
lhs
[
1
],
-
lhs
[
2
]);
}
// minus
RealVec
operator
-
(
const
RealVec
&
rhs
)
const
{
const
RealVec
&
lhs
=
*
this
;
return
RealVec
(
lhs
[
0
]
-
rhs
[
0
],
lhs
[
1
]
-
rhs
[
1
],
lhs
[
2
]
-
rhs
[
2
]);
}
RealVec
&
operator
-=
(
const
RealVec
&
rhs
)
{
data
[
0
]
-=
rhs
[
0
];
data
[
1
]
-=
rhs
[
1
];
data
[
2
]
-=
rhs
[
2
];
return
*
this
;
}
// scalar product
RealVec
operator
*
(
RealOpenMM
rhs
)
const
{
const
RealVec
&
lhs
=
*
this
;
return
RealVec
(
lhs
[
0
]
*
rhs
,
lhs
[
1
]
*
rhs
,
lhs
[
2
]
*
rhs
);
}
RealVec
&
operator
*=
(
RealOpenMM
rhs
)
{
data
[
0
]
*=
rhs
;
data
[
1
]
*=
rhs
;
data
[
2
]
*=
rhs
;
return
*
this
;
}
// dot product
RealOpenMM
dot
(
const
RealVec
&
rhs
)
const
{
const
RealVec
&
lhs
=
*
this
;
return
lhs
[
0
]
*
rhs
[
0
]
+
lhs
[
1
]
*
rhs
[
1
]
+
lhs
[
2
]
*
rhs
[
2
];
}
// cross product
RealVec
cross
(
const
RealVec
&
rhs
)
const
{
return
RealVec
(
data
[
1
]
*
rhs
[
2
]
-
data
[
2
]
*
rhs
[
1
],
data
[
2
]
*
rhs
[
0
]
-
data
[
0
]
*
rhs
[
2
],
data
[
0
]
*
rhs
[
1
]
-
data
[
1
]
*
rhs
[
0
]);
}
private:
RealOpenMM
data
[
3
];
};
template
<
class
CHAR
,
class
TRAITS
>
std
::
basic_ostream
<
CHAR
,
TRAITS
>&
operator
<<
(
std
::
basic_ostream
<
CHAR
,
TRAITS
>&
o
,
const
RealVec
&
v
)
{
o
<<
'['
<<
v
[
0
]
<<
", "
<<
v
[
1
]
<<
", "
<<
v
[
2
]
<<
']'
;
return
o
;
}
}
// namespace OpenMM
#endif
/*OPENMM_REALVEC_H_*/
platforms/reference/src/SimTKUtilities/SimTKOpenMMCommon.h
View file @
0843c5f3
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
#include "
SimTKOpenMMRealType
.h"
#include "
RealVec
.h"
#include "SimTKOpenMMWindowLinux.h"
#include "SimTKOpenMMWindowLinux.h"
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
...
platforms/reference/src/SimTKUtilities/SimTKOpenMMUtilities.h
View file @
0843c5f3
platforms/reference/src/gbsa/CpuGBVI.cpp
View file @
0843c5f3
...
@@ -32,6 +32,9 @@
...
@@ -32,6 +32,9 @@
#include "../SimTKReference/ReferenceForce.h"
#include "../SimTKReference/ReferenceForce.h"
#include <math.h>
#include <math.h>
using
namespace
std
;
using
namespace
OpenMM
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
CpuGBVI constructor
CpuGBVI constructor
...
@@ -146,7 +149,7 @@ int CpuGBVI::setGBVIParameters( GBVIParameters* gbviParameters ){
...
@@ -146,7 +149,7 @@ int CpuGBVI::setGBVIParameters( GBVIParameters* gbviParameters ){
#define GBVIDebug 0
#define GBVIDebug 0
int
CpuGBVI
::
computeBornRadii
(
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
bornRadii
,
RealOpenMM
*
chain
){
int
CpuGBVI
::
computeBornRadii
(
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
*
bornRadii
,
RealOpenMM
*
chain
){
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -435,7 +438,7 @@ RealOpenMM CpuGBVI::Sgb( RealOpenMM t ){
...
@@ -435,7 +438,7 @@ RealOpenMM CpuGBVI::Sgb( RealOpenMM t ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
CpuGBVI
::
computeBornEnergy
(
const
RealOpenMM
*
bornRadii
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
CpuGBVI
::
computeBornEnergy
(
const
RealOpenMM
*
bornRadii
,
vector
<
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialCharges
){
const
RealOpenMM
*
partialCharges
){
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -554,8 +557,8 @@ partialCharges[atomJ]*Sgb( t )/deltaR[ReferenceForce::RIndex];
...
@@ -554,8 +557,8 @@ partialCharges[atomJ]*Sgb( t )/deltaR[ReferenceForce::RIndex];
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
CpuGBVI
::
computeBornForces
(
const
RealOpenMM
*
bornRadii
,
RealOpenMM
**
atomCoordinates
,
int
CpuGBVI
::
computeBornForces
(
const
RealOpenMM
*
bornRadii
,
vector
<
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
inputForces
){
const
RealOpenMM
*
partialCharges
,
std
::
vector
<
OpenMM
::
RealVec
>&
inputForces
){
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -919,8 +922,8 @@ std::string CpuGBVI::getStateString( const char* title ) const {
...
@@ -919,8 +922,8 @@ std::string CpuGBVI::getStateString( const char* title ) const {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
CpuGBVI
::
writeBornEnergyForces
(
RealOpenMM
**
atomCoordinates
,
int
CpuGBVI
::
writeBornEnergyForces
(
vector
<
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
forces
,
const
RealOpenMM
*
partialCharges
,
vector
<
RealVec
>&
forces
,
const
std
::
string
&
resultsFileName
)
const
{
const
std
::
string
&
resultsFileName
)
const
{
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -1000,123 +1003,6 @@ int CpuGBVI::writeBornEnergyForces( RealOpenMM** atomCoordinates,
...
@@ -1000,123 +1003,6 @@ int CpuGBVI::writeBornEnergyForces( RealOpenMM** atomCoordinates,
}
}
/**---------------------------------------------------------------------------------------
Write results from first loop
@param numberOfAtoms number of atoms
@param forces forces
@param bornForce Born force prefactor
@param outputFileName output file name
@return SimTKOpenMMCommon::DefaultReturn unless
file cannot be opened
in which case return SimTKOpenMMCommon::ErrorReturn
--------------------------------------------------------------------------------------- */
int
CpuGBVI
::
writeForceLoop1
(
int
numberOfAtoms
,
RealOpenMM
**
forces
,
const
RealOpenMM
*
bornForce
,
const
std
::
string
&
outputFileName
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuGBVI::writeForceLoop1";
// ---------------------------------------------------------------------------------------
int
chunkSize
;
if
(
bornForce
){
chunkSize
=
3
;
}
else
{
chunkSize
=
4
;
}
StringVector
lineVector
;
std
::
stringstream
header
;
lineVector
.
push_back
(
"# bornF F"
);
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
){
std
::
stringstream
line
;
line
<<
(
atomI
+
1
)
<<
" "
;
SimTKOpenMMUtilities
::
formatRealStringStream
(
line
,
forces
[
atomI
],
chunkSize
);
if
(
bornForce
){
line
<<
" "
<<
bornForce
[
atomI
];
}
lineVector
.
push_back
(
line
.
str
()
);
}
return
SimTKOpenMMUtilities
::
writeFile
(
lineVector
,
outputFileName
);
}
/**---------------------------------------------------------------------------------------
Write results
@param numberOfAtoms number of atoms
@param chunkSizes vector of chunk sizes for realRealOpenMMVector
@param realRealOpenMMVector vector of RealOpenMM**
@param realVector vector of RealOpenMM*
@param outputFileName output file name
@return SimTKOpenMMCommon::DefaultReturn unless
file cannot be opened
in which case return SimTKOpenMMCommon::ErrorReturn
--------------------------------------------------------------------------------------- */
int
CpuGBVI
::
writeForceLoop
(
int
numberOfAtoms
,
const
IntVector
&
chunkSizes
,
const
RealOpenMMPtrPtrVector
&
realRealOpenMMVector
,
const
RealOpenMMPtrVector
&
realVector
,
const
std
::
string
&
outputFileName
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nCpuGBVI::writeForceLoop";
static
const
int
maxChunks
=
10
;
int
chunks
[
maxChunks
];
// ---------------------------------------------------------------------------------------
for
(
int
ii
=
0
;
ii
<
(
int
)
chunkSizes
.
size
();
ii
++
){
chunks
[
ii
]
=
chunkSizes
[
ii
];
}
for
(
int
ii
=
(
int
)
chunkSizes
.
size
();
ii
<
maxChunks
;
ii
++
){
chunks
[
ii
]
=
3
;
}
StringVector
lineVector
;
std
::
stringstream
header
;
// lineVector.push_back( "# " );
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
){
std
::
stringstream
line
;
char
buffer
[
128
];
(
void
)
sprintf
(
buffer
,
"%4d "
,
atomI
);
line
<<
buffer
;
int
index
=
0
;
for
(
RealOpenMMPtrPtrVectorCI
ii
=
realRealOpenMMVector
.
begin
();
ii
!=
realRealOpenMMVector
.
end
();
ii
++
){
RealOpenMM
**
forces
=
*
ii
;
(
void
)
sprintf
(
buffer
,
"%11.5f %11.5f %11.5f "
,
forces
[
atomI
][
0
],
forces
[
atomI
][
1
],
forces
[
atomI
][
2
]
);
line
<<
buffer
;
// SimTKOpenMMUtilities::formatRealStringStream( line, forces[atomI], chunks[index++] );
// line << " ";
}
for
(
RealOpenMMPtrVectorCI
ii
=
realVector
.
begin
();
ii
!=
realVector
.
end
();
ii
++
){
RealOpenMM
*
array
=
*
ii
;
(
void
)
sprintf
(
buffer
,
"%11.5f "
,
array
[
atomI
]
);
line
<<
buffer
;
}
lineVector
.
push_back
(
line
.
str
()
);
}
return
SimTKOpenMMUtilities
::
writeFile
(
lineVector
,
outputFileName
);
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Get Obc Born energy and forces -- used debugging
Get Obc Born energy and forces -- used debugging
...
@@ -1133,8 +1019,8 @@ int CpuGBVI::writeForceLoop( int numberOfAtoms, const IntVector& chunkSizes,
...
@@ -1133,8 +1019,8 @@ int CpuGBVI::writeForceLoop( int numberOfAtoms, const IntVector& chunkSizes,
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
CpuGBVI
::
computeBornEnergyForces
(
RealOpenMM
*
bornRadii
,
RealOpenMM
**
atomCoordinates
,
int
CpuGBVI
::
computeBornEnergyForces
(
RealOpenMM
*
bornRadii
,
vector
<
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
forces
){
const
RealOpenMM
*
partialCharges
,
vector
<
RealVec
>&
forces
){
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
...
platforms/reference/src/gbsa/CpuGBVI.h
View file @
0843c5f3
...
@@ -25,8 +25,10 @@
...
@@ -25,8 +25,10 @@
#ifndef __CpuGBVI_H__
#ifndef __CpuGBVI_H__
#define __CpuGBVI_H__
#define __CpuGBVI_H__
#include "../SimTKUtilities/RealVec.h"
#include "GBVIParameters.h"
#include "GBVIParameters.h"
#include "CpuImplicitSolvent.h"
#include "CpuImplicitSolvent.h"
#include <vector>
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -99,7 +101,7 @@ class CpuGBVI : public CpuImplicitSolvent {
...
@@ -99,7 +101,7 @@ class CpuGBVI : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
computeBornRadii
(
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
bornRadii
,
int
computeBornRadii
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
*
bornRadii
,
RealOpenMM
*
gbviChain
=
NULL
);
RealOpenMM
*
gbviChain
=
NULL
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -115,11 +117,11 @@ class CpuGBVI : public CpuImplicitSolvent {
...
@@ -115,11 +117,11 @@ class CpuGBVI : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
computeBornEnergyForces
(
RealOpenMM
*
bornRadii
,
RealOpenMM
**
atomCoordinates
,
int
computeBornEnergyForces
(
RealOpenMM
*
bornRadii
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
forces
);
const
RealOpenMM
*
partialCharges
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
);
int
computeBornEnergyForcesPrint
(
RealOpenMM
*
bornRadii
,
RealOpenMM
**
atomCoordinates
,
int
computeBornEnergyForcesPrint
(
RealOpenMM
*
bornRadii
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
forces
);
const
RealOpenMM
*
partialCharges
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -146,48 +148,10 @@ class CpuGBVI : public CpuImplicitSolvent {
...
@@ -146,48 +148,10 @@ class CpuGBVI : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
writeBornEnergyForces
(
RealOpenMM
**
atomCoordinates
,
int
writeBornEnergyForces
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
forces
,
const
RealOpenMM
*
partialCharges
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
const
std
::
string
&
resultsFileName
)
const
;
const
std
::
string
&
resultsFileName
)
const
;
/**---------------------------------------------------------------------------------------
Write results from first loop
@param atomCoordinates atomic coordinates
@param RealOpenMM forces forces
@param outputFileName output file name
@return SimTKOpenMMCommon::DefaultReturn unless
file cannot be opened
in which case return SimTKOpenMMCommon::ErrorReturn
--------------------------------------------------------------------------------------- */
static
int
writeForceLoop1
(
int
numberOfAtoms
,
RealOpenMM
**
forces
,
const
RealOpenMM
*
bornForce
,
const
std
::
string
&
outputFileName
);
/**---------------------------------------------------------------------------------------
Write results
@param numberOfAtoms number of atoms
@param chunkSizes vector of chunk sizes for realRealOpenMMVector
@param realRealOpenMMVector vector of RealOpenMM**
@param realVector vector of RealOpenMM*
@param outputFileName output file name
@return SimTKOpenMMCommon::DefaultReturn unless
file cannot be opened
in which case return SimTKOpenMMCommon::ErrorReturn
--------------------------------------------------------------------------------------- */
static
int
writeForceLoop
(
int
numberOfAtoms
,
const
IntVector
&
chunkSizes
,
const
RealOpenMMPtrPtrVector
&
realRealOpenMMVector
,
const
RealOpenMMPtrVector
&
realVector
,
const
std
::
string
&
outputFileName
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Get volume Eq. 4 of Labute paper [JCC 29 p. 1693-1698 2008])
Get volume Eq. 4 of Labute paper [JCC 29 p. 1693-1698 2008])
...
@@ -268,7 +232,7 @@ class CpuGBVI : public CpuImplicitSolvent {
...
@@ -268,7 +232,7 @@ class CpuGBVI : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
RealOpenMM
computeBornEnergy
(
const
RealOpenMM
*
bornRadii
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
computeBornEnergy
(
const
RealOpenMM
*
bornRadii
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialCharges
);
const
RealOpenMM
*
partialCharges
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -284,8 +248,8 @@ class CpuGBVI : public CpuImplicitSolvent {
...
@@ -284,8 +248,8 @@ class CpuGBVI : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
computeBornForces
(
const
RealOpenMM
*
bornRadii
,
RealOpenMM
**
atomCoordinates
,
int
computeBornForces
(
const
RealOpenMM
*
bornRadii
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
inputForces
);
const
RealOpenMM
*
partialCharges
,
std
::
vector
<
OpenMM
::
RealVec
>&
inputForces
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
...
platforms/reference/src/gbsa/CpuImplicitSolvent.cpp
View file @
0843c5f3
...
@@ -29,6 +29,9 @@
...
@@ -29,6 +29,9 @@
#include <cstdio>
#include <cstdio>
using
namespace
OpenMM
;
using
namespace
std
;
//#define UseGromacsMalloc 1
//#define UseGromacsMalloc 1
// Replacement new/delete w/ Gromac's smalloc() and sfree()
// Replacement new/delete w/ Gromac's smalloc() and sfree()
...
@@ -581,7 +584,7 @@ RealOpenMM* CpuImplicitSolvent::getBornRadiiTemp( void ){
...
@@ -581,7 +584,7 @@ RealOpenMM* CpuImplicitSolvent::getBornRadiiTemp( void ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
CpuImplicitSolvent
::
computeBornRadii
(
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
bornRadii
,
int
CpuImplicitSolvent
::
computeBornRadii
(
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
*
bornRadii
,
RealOpenMM
*
obcChain
){
RealOpenMM
*
obcChain
){
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -613,13 +616,12 @@ int CpuImplicitSolvent::computeBornRadii( RealOpenMM** atomCoordinates, RealOpen
...
@@ -613,13 +616,12 @@ int CpuImplicitSolvent::computeBornRadii( RealOpenMM** atomCoordinates, RealOpen
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
CpuImplicitSolvent
::
computeImplicitSolventForces
(
RealOpenMM
**
atomCoordinates
,
int
CpuImplicitSolvent
::
computeImplicitSolventForces
(
vector
<
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
forces
,
int
updateBornRadii
){
vector
<
RealVec
>&
forces
,
int
updateBornRadii
){
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
int
printSampleOutput
=
0
;
static
const
char
*
methodName
=
"
\n
CpuImplicitSolvent::computeImplicitSolventForces"
;
static
const
char
*
methodName
=
"
\n
CpuImplicitSolvent::computeImplicitSolventForces"
;
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -647,82 +649,13 @@ int CpuImplicitSolvent::computeImplicitSolventForces( RealOpenMM** atomCoordinat
...
@@ -647,82 +649,13 @@ int CpuImplicitSolvent::computeImplicitSolventForces( RealOpenMM** atomCoordinat
RealOpenMM
*
bornRadii
=
getBornRadii
();
RealOpenMM
*
bornRadii
=
getBornRadii
();
if
(
updateBornRadii
||
bornRadii
[
0
]
<
(
RealOpenMM
)
0.0001
||
callId
==
1
){
if
(
updateBornRadii
||
bornRadii
[
0
]
<
(
RealOpenMM
)
0.0001
||
callId
==
1
){
computeBornRadii
(
atomCoordinates
,
bornRadii
);
computeBornRadii
(
atomCoordinates
,
bornRadii
);
// diagnostics
if
(
printSampleOutput
){
RealOpenMM
*
atomicRadii
=
implicitSolventParameters
->
getAtomicRadii
();
std
::
stringstream
message
;
message
.
precision
(
6
);
message
.
width
(
12
);
message
<<
methodName
;
int
numberOfAtoms
=
implicitSolventParameters
->
getNumberOfAtoms
();
message
<<
" initialize Born radii for "
<<
numberOfAtoms
<<
" atoms on call="
<<
callId
;
for
(
int
ii
=
0
;
ii
<
printSampleOutput
&&
ii
<
numberOfAtoms
;
ii
++
){
message
<<
"
\n
"
<<
ii
<<
" rad="
<<
atomicRadii
[
ii
]
<<
" q="
<<
partialCharges
[
ii
]
<<
" bR="
<<
bornRadii
[
ii
]
<<
" X["
;
SimTKOpenMMUtilities
::
formatRealStringStream
(
message
,
atomCoordinates
[
ii
]
);
message
<<
"]"
;
}
message
<<
"
\n
"
;
int
startIndex
=
implicitSolventParameters
->
getNumberOfAtoms
()
-
printSampleOutput
>
0
?
implicitSolventParameters
->
getNumberOfAtoms
()
-
printSampleOutput
:
numberOfAtoms
;
for
(
int
ii
=
startIndex
;
ii
<
numberOfAtoms
;
ii
++
){
message
<<
"
\n
"
<<
ii
<<
" "
<<
atomicRadii
[
ii
]
<<
" "
<<
bornRadii
[
ii
]
<<
" X["
;
SimTKOpenMMUtilities
::
formatRealStringStream
(
message
,
atomCoordinates
[
ii
]
);
message
<<
"]"
;
}
SimTKOpenMMLog
::
printMessage
(
message
);
}
}
}
// compute forces
// compute forces
computeBornEnergyForces
(
getBornRadii
(),
atomCoordinates
,
partialCharges
,
forces
);
computeBornEnergyForces
(
getBornRadii
(),
atomCoordinates
,
partialCharges
,
forces
);
// diagnostics
if
(
printSampleOutput
&&
callId
==
1
){
static
int
internalId
=
0
;
int
processId
=
internalId
++
+
callId
;
std
::
stringstream
message
;
message
.
precision
(
6
);
message
.
width
(
12
);
int
numberOfAtoms
=
implicitSolventParameters
->
getNumberOfAtoms
();
message
<<
methodName
;
message
<<
" call="
<<
callId
<<
" E="
<<
getEnergy
()
<<
" "
<<
numberOfAtoms
<<
" atoms."
;
for
(
int
ii
=
0
;
ii
<
printSampleOutput
&&
ii
<
numberOfAtoms
;
ii
++
){
message
<<
"
\n
"
<<
ii
<<
" [ "
;
SimTKOpenMMUtilities
::
formatRealStringStream
(
message
,
forces
[
ii
]
);
message
<<
"] bRad="
<<
bornRadii
[
ii
];
}
message
<<
"
\n
"
;
int
startIndex
=
implicitSolventParameters
->
getNumberOfAtoms
()
-
printSampleOutput
>
0
?
implicitSolventParameters
->
getNumberOfAtoms
()
-
printSampleOutput
:
numberOfAtoms
;
for
(
int
ii
=
startIndex
;
ii
<
numberOfAtoms
;
ii
++
){
message
<<
"
\n
"
<<
ii
<<
" [ "
;
SimTKOpenMMUtilities
::
formatRealStringStream
(
message
,
forces
[
ii
]
);
message
<<
"] bRad="
<<
bornRadii
[
ii
];
}
SimTKOpenMMLog
::
printMessage
(
message
);
// write Born forces
std
::
stringstream
resultsFileName
;
resultsFileName
<<
getBaseFileName
()
<<
"."
<<
processId
<<
".gbsa0"
;
writeBornEnergyForces
(
atomCoordinates
,
partialCharges
,
forces
,
resultsFileName
.
str
()
);
}
return
SimTKOpenMMCommon
::
DefaultReturn
;
return
SimTKOpenMMCommon
::
DefaultReturn
;
}
}
...
@@ -742,9 +675,9 @@ int CpuImplicitSolvent::computeImplicitSolventForces( RealOpenMM** atomCoordinat
...
@@ -742,9 +675,9 @@ int CpuImplicitSolvent::computeImplicitSolventForces( RealOpenMM** atomCoordinat
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
CpuImplicitSolvent
::
computeBornEnergyForces
(
RealOpenMM
*
bornRadii
,
int
CpuImplicitSolvent
::
computeBornEnergyForces
(
RealOpenMM
*
bornRadii
,
RealOpenMM
**
atomCoordinates
,
vector
<
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
forces
){
vector
<
RealVec
>&
forces
){
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -824,94 +757,6 @@ int CpuImplicitSolvent::computeAceNonPolarForce( const ImplicitSolventParameters
...
@@ -824,94 +757,6 @@ int CpuImplicitSolvent::computeAceNonPolarForce( const ImplicitSolventParameters
}
}
/**---------------------------------------------------------------------------------------
Write Born energy and forces (Simbios)
@param atomCoordinates atomic coordinates
@param forces forces
@param resultsFileName output file name
@return SimTKOpenMMCommon::DefaultReturn unless
file cannot be opened
in which case return SimTKOpenMMCommon::ErrorReturn
--------------------------------------------------------------------------------------- */
int
CpuImplicitSolvent
::
writeBornEnergyForces
(
RealOpenMM
**
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
forces
,
const
std
::
string
&
resultsFileName
)
const
{
// ---------------------------------------------------------------------------------------
static
const
char
*
methodName
=
"
\n
CpuImplicitSolvent::writeBornEnergyForces"
;
// ---------------------------------------------------------------------------------------
ImplicitSolventParameters
*
implicitSolventParameters
=
getImplicitSolventParameters
();
int
numberOfAtoms
=
implicitSolventParameters
->
getNumberOfAtoms
();
const
RealOpenMM
*
atomicRadii
=
implicitSolventParameters
->
getAtomicRadii
();
const
RealOpenMM
*
bornRadii
=
getBornRadiiConst
();
// ---------------------------------------------------------------------------------------
// open file -- return if unsuccessful
FILE
*
implicitSolventResultsFile
=
NULL
;
#ifdef _MSC_VER
fopen_s
(
&
implicitSolventResultsFile
,
resultsFileName
.
c_str
(),
"w"
);
#else
implicitSolventResultsFile
=
fopen
(
resultsFileName
.
c_str
(),
"w"
);
#endif
// diganostics
std
::
stringstream
message
;
message
<<
methodName
;
if
(
implicitSolventResultsFile
!=
NULL
){
std
::
stringstream
message
;
message
<<
methodName
;
message
<<
" Opened file=<"
<<
resultsFileName
<<
">."
;
SimTKOpenMMLog
::
printMessage
(
message
);
}
else
{
std
::
stringstream
message
;
message
<<
methodName
;
message
<<
" could not open file=<"
<<
resultsFileName
<<
"> -- abort output."
;
SimTKOpenMMLog
::
printMessage
(
message
);
return
SimTKOpenMMCommon
::
ErrorReturn
;
}
// header
(
void
)
fprintf
(
implicitSolventResultsFile
,
"# %d atoms format: coords bornRadii q atomicRadii forces
\n
"
,
numberOfAtoms
);
RealOpenMM
forceConversion
=
1.0
;
RealOpenMM
lengthConversion
=
1.0
;
// output
if
(
forces
!=
NULL
&&
atomCoordinates
!=
NULL
&&
partialCharges
!=
NULL
&&
atomicRadii
!=
NULL
){
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
){
(
void
)
fprintf
(
implicitSolventResultsFile
,
"%.7e %.7e %.7e %.7e %.5f %.5f %.7e %.7e %.7e
\n
"
,
lengthConversion
*
atomCoordinates
[
ii
][
0
],
lengthConversion
*
atomCoordinates
[
ii
][
1
],
lengthConversion
*
atomCoordinates
[
ii
][
2
],
(
bornRadii
!=
NULL
?
lengthConversion
*
bornRadii
[
ii
]
:
0.0
),
partialCharges
[
ii
],
lengthConversion
*
atomicRadii
[
ii
],
forceConversion
*
forces
[
ii
][
0
],
forceConversion
*
forces
[
ii
][
1
],
forceConversion
*
forces
[
ii
][
2
]
);
}
}
(
void
)
fclose
(
implicitSolventResultsFile
);
return
SimTKOpenMMCommon
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Get BaseFileName
Get BaseFileName
...
...
platforms/reference/src/gbsa/CpuImplicitSolvent.h
View file @
0843c5f3
...
@@ -356,9 +356,9 @@ class OPENMM_EXPORT CpuImplicitSolvent {
...
@@ -356,9 +356,9 @@ class OPENMM_EXPORT CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
computeImplicitSolventForces
(
RealOpenMM
**
atomCoordinates
,
int
computeImplicitSolventForces
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
forces
,
int
updateBornRadii
=
0
);
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
int
updateBornRadii
=
0
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -372,7 +372,7 @@ class OPENMM_EXPORT CpuImplicitSolvent {
...
@@ -372,7 +372,7 @@ class OPENMM_EXPORT CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
virtual
int
computeBornRadii
(
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
bornRadii
,
virtual
int
computeBornRadii
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
*
bornRadii
,
RealOpenMM
*
obcChain
=
NULL
);
RealOpenMM
*
obcChain
=
NULL
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -388,8 +388,8 @@ class OPENMM_EXPORT CpuImplicitSolvent {
...
@@ -388,8 +388,8 @@ class OPENMM_EXPORT CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
virtual
int
computeBornEnergyForces
(
RealOpenMM
*
bornRadii
,
RealOpenMM
**
atomCoordinates
,
virtual
int
computeBornEnergyForces
(
RealOpenMM
*
bornRadii
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
forces
);
const
RealOpenMM
*
partialCharges
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -408,23 +408,6 @@ class OPENMM_EXPORT CpuImplicitSolvent {
...
@@ -408,23 +408,6 @@ class OPENMM_EXPORT CpuImplicitSolvent {
const
RealOpenMM
*
bornRadii
,
RealOpenMM
*
energy
,
const
RealOpenMM
*
bornRadii
,
RealOpenMM
*
energy
,
RealOpenMM
*
forces
)
const
;
RealOpenMM
*
forces
)
const
;
/**---------------------------------------------------------------------------------------
Write Born energy and forces (Simbios)
@param atomCoordinates atomic coordinates
@param partialCharges partial atom charges
@param forces force array
@param resultsFileName output file name
@return SimTKOpenMMCommon::DefaultReturn if file opened; else return SimTKOpenMMCommon::ErrorReturn
--------------------------------------------------------------------------------------- */
virtual
int
writeBornEnergyForces
(
RealOpenMM
**
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
forces
,
const
std
::
string
&
resultsFileName
)
const
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Get string w/ state
Get string w/ state
...
@@ -537,7 +520,7 @@ class OPENMM_EXPORT CpuImplicitSolvent {
...
@@ -537,7 +520,7 @@ class OPENMM_EXPORT CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
/*
/*
static int writeXyzFile( int numberOfAtoms, const
RealOpenMM**
atomCoordinates,
static int writeXyzFile( int numberOfAtoms, const
std::vector<OpenMM::RealVec>&
atomCoordinates,
const char** atomNames,
const char** atomNames,
const std::string& header, const std::string& xyzFileName,
const std::string& header, const std::string& xyzFileName,
const implicitSolventBonds** bondsArray ); */
const implicitSolventBonds** bondsArray ); */
...
...
platforms/reference/src/gbsa/CpuObc.cpp
View file @
0843c5f3
...
@@ -33,6 +33,9 @@
...
@@ -33,6 +33,9 @@
#include <cmath>
#include <cmath>
#include <cstdio>
#include <cstdio>
using
namespace
OpenMM
;
using
namespace
std
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
CpuObc constructor
CpuObc constructor
...
@@ -216,7 +219,7 @@ RealOpenMM* CpuObc::getObcChainTemp( void ){
...
@@ -216,7 +219,7 @@ RealOpenMM* CpuObc::getObcChainTemp( void ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
CpuObc
::
computeBornRadii
(
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
bornRadii
,
RealOpenMM
*
obcChain
){
int
CpuObc
::
computeBornRadii
(
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
*
bornRadii
,
RealOpenMM
*
obcChain
){
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -358,8 +361,8 @@ if( logFile ){
...
@@ -358,8 +361,8 @@ if( logFile ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
CpuObc
::
computeBornEnergyForces
(
RealOpenMM
*
bornRadii
,
RealOpenMM
**
atomCoordinates
,
int
CpuObc
::
computeBornEnergyForces
(
RealOpenMM
*
bornRadii
,
vector
<
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
inputForces
){
const
RealOpenMM
*
partialCharges
,
vector
<
RealVec
>&
inputForces
){
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
...
platforms/reference/src/gbsa/CpuObc.h
View file @
0843c5f3
...
@@ -128,7 +128,7 @@ class CpuObc : public CpuImplicitSolvent {
...
@@ -128,7 +128,7 @@ class CpuObc : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
computeBornRadii
(
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
bornRadii
,
int
computeBornRadii
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
*
bornRadii
,
RealOpenMM
*
obcChain
=
NULL
);
RealOpenMM
*
obcChain
=
NULL
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -144,8 +144,8 @@ class CpuObc : public CpuImplicitSolvent {
...
@@ -144,8 +144,8 @@ class CpuObc : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
computeBornEnergyForces
(
RealOpenMM
*
bornRadii
,
RealOpenMM
**
atomCoordinates
,
int
computeBornEnergyForces
(
RealOpenMM
*
bornRadii
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
forces
);
const
RealOpenMM
*
partialCharges
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
...
platforms/reference/src/gbsa/cpuObcInterface.cpp
View file @
0843c5f3
...
@@ -29,6 +29,9 @@
...
@@ -29,6 +29,9 @@
#include "ObcParameters.h"
#include "ObcParameters.h"
#include "CpuObc.h"
#include "CpuObc.h"
using
namespace
OpenMM
;
using
namespace
std
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Setup for Obc calculations from Gromacs
Setup for Obc calculations from Gromacs
...
@@ -149,9 +152,9 @@ cpuSetObcParameters( int numberOfAtoms, RealOpenMM* atomicRadii, RealOpenMM* obc
...
@@ -149,9 +152,9 @@ cpuSetObcParameters( int numberOfAtoms, RealOpenMM* atomicRadii, RealOpenMM* obc
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
extern
"C"
int
extern
"C"
int
cpuCalculateImplicitSolventForces
(
RealOpenMM
**
atomCoordinates
,
cpuCalculateImplicitSolventForces
(
vector
<
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
forces
,
RealOpenMM
*
energy
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
energy
,
int
updateBornRadii
){
int
updateBornRadii
){
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
...
platforms/reference/src/gbsa/cpuObcInterface.h
View file @
0843c5f3
...
@@ -31,8 +31,9 @@
...
@@ -31,8 +31,9 @@
#define externC extern
#define externC extern
#endif
#endif
#include "../SimTKUtilities/
SimTKOpenMMRealType
.h"
#include "../SimTKUtilities/
RealVec
.h"
#include <stdio.h>
#include <stdio.h>
#include <vector>
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
@@ -107,9 +108,9 @@ int cpuSetObcParameters( int numberOfAtoms, RealOpenMM* atomicRadii, RealOpenMM*
...
@@ -107,9 +108,9 @@ int cpuSetObcParameters( int numberOfAtoms, RealOpenMM* atomicRadii, RealOpenMM*
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
externC
int
cpuCalculateImplicitSolventForces
(
RealOpenMM
**
atomCoordinates
,
externC
int
cpuCalculateImplicitSolventForces
(
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
const
RealOpenMM
*
partialChargesIn
,
const
RealOpenMM
*
partialChargesIn
,
RealOpenMM
**
forces
,
RealOpenMM
*
energy
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
energy
,
int
updateBornRadii
);
int
updateBornRadii
);
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
...
platforms/reference/tests/TestReferenceNeighborList.cpp
View file @
0843c5f3
...
@@ -34,22 +34,16 @@
...
@@ -34,22 +34,16 @@
#include "sfmt/SFMT.h"
#include "sfmt/SFMT.h"
#include <cassert>
#include <cassert>
#include <iostream>
#include <iostream>
#include <vector>
using
namespace
std
;
using
namespace
std
;
using
namespace
OpenMM
;
using
namespace
OpenMM
;
void
testNeighborList
()
void
testNeighborList
()
{
{
RealOpenMM
*
particleList
[
2
];
vector
<
RealVec
>
particleList
(
2
);
particleList
[
0
]
=
new
RealOpenMM
[
3
];
particleList
[
0
]
=
RealVec
(
13.6
,
0
,
0
);
particleList
[
1
]
=
new
RealOpenMM
[
3
];
particleList
[
1
]
=
RealVec
(
0
,
0
,
0
);
// particleList[2] = new RealOpenMM[3];
particleList
[
0
][
0
]
=
13.6
f
;
particleList
[
0
][
1
]
=
0
;
particleList
[
0
][
2
]
=
0
;
particleList
[
1
][
0
]
=
0
;
particleList
[
1
][
1
]
=
0
;
particleList
[
1
][
2
]
=
0
;
vector
<
set
<
int
>
>
exclusions
(
2
);
vector
<
set
<
int
>
>
exclusions
(
2
);
NeighborList
neighborList
;
NeighborList
neighborList
;
...
@@ -65,10 +59,6 @@ void testNeighborList()
...
@@ -65,10 +59,6 @@ void testNeighborList()
computeNeighborListVoxelHash
(
neighborList
,
2
,
particleList
,
exclusions
,
NULL
,
13.5
,
0.01
);
computeNeighborListVoxelHash
(
neighborList
,
2
,
particleList
,
exclusions
,
NULL
,
13.5
,
0.01
);
assert
(
neighborList
.
size
()
==
0
);
assert
(
neighborList
.
size
()
==
0
);
delete
[]
particleList
[
0
];
delete
[]
particleList
[
1
];
// delete[] particleList[2];
}
}
double
periodicDifference
(
double
val1
,
double
val2
,
double
period
)
{
double
periodicDifference
(
double
val1
,
double
val2
,
double
period
)
{
...
@@ -77,14 +67,14 @@ double periodicDifference(double val1, double val2, double period) {
...
@@ -77,14 +67,14 @@ double periodicDifference(double val1, double val2, double period) {
return
diff
-
base
;
return
diff
-
base
;
}
}
double
distance2
(
Real
OpenMM
*
pos1
,
Real
OpenMM
*
pos2
,
const
RealOpenMM
*
periodicBoxSize
)
{
double
distance2
(
Real
Vec
&
pos1
,
Real
Vec
&
pos2
,
const
RealOpenMM
*
periodicBoxSize
)
{
double
dx
=
periodicDifference
(
pos1
[
0
],
pos2
[
0
],
periodicBoxSize
[
0
]);
double
dx
=
periodicDifference
(
pos1
[
0
],
pos2
[
0
],
periodicBoxSize
[
0
]);
double
dy
=
periodicDifference
(
pos1
[
1
],
pos2
[
1
],
periodicBoxSize
[
1
]);
double
dy
=
periodicDifference
(
pos1
[
1
],
pos2
[
1
],
periodicBoxSize
[
1
]);
double
dz
=
periodicDifference
(
pos1
[
2
],
pos2
[
2
],
periodicBoxSize
[
2
]);
double
dz
=
periodicDifference
(
pos1
[
2
],
pos2
[
2
],
periodicBoxSize
[
2
]);
return
dx
*
dx
+
dy
*
dy
+
dz
*
dz
;
return
dx
*
dx
+
dy
*
dy
+
dz
*
dz
;
}
}
void
verifyNeighborList
(
NeighborList
&
list
,
int
numParticles
,
RealOpenMM
**
positions
,
const
RealOpenMM
*
periodicBoxSize
,
double
cutoff
)
{
void
verifyNeighborList
(
NeighborList
&
list
,
int
numParticles
,
vector
<
RealVec
>&
positions
,
const
RealOpenMM
*
periodicBoxSize
,
double
cutoff
)
{
for
(
int
i
=
0
;
i
<
(
int
)
list
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
list
.
size
();
i
++
)
{
int
particle1
=
list
[
i
].
first
;
int
particle1
=
list
[
i
].
first
;
int
particle2
=
list
[
i
].
second
;
int
particle2
=
list
[
i
].
second
;
...
@@ -102,12 +92,11 @@ void testPeriodic() {
...
@@ -102,12 +92,11 @@ void testPeriodic() {
const
int
numParticles
=
100
;
const
int
numParticles
=
100
;
const
double
cutoff
=
3.0
;
const
double
cutoff
=
3.0
;
const
RealOpenMM
periodicBoxSize
[
3
]
=
{
20.0
,
15.0
,
22.0
};
const
RealOpenMM
periodicBoxSize
[
3
]
=
{
20.0
,
15.0
,
22.0
};
RealOpenMM
*
particleList
[
numParticles
]
;
vector
<
RealVec
>
particleList
(
numParticles
)
;
OpenMM_SFMT
::
SFMT
sfmt
;
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
init_gen_rand
(
0
,
sfmt
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
particleList
[
i
]
=
new
RealOpenMM
[
3
];
particleList
[
i
][
0
]
=
(
RealOpenMM
)
(
genrand_real2
(
sfmt
)
*
periodicBoxSize
[
0
]
*
3
);
particleList
[
i
][
0
]
=
(
RealOpenMM
)
(
genrand_real2
(
sfmt
)
*
periodicBoxSize
[
0
]
*
3
);
particleList
[
i
][
1
]
=
(
RealOpenMM
)
(
genrand_real2
(
sfmt
)
*
periodicBoxSize
[
1
]
*
3
);
particleList
[
i
][
1
]
=
(
RealOpenMM
)
(
genrand_real2
(
sfmt
)
*
periodicBoxSize
[
1
]
*
3
);
particleList
[
i
][
2
]
=
(
RealOpenMM
)
(
genrand_real2
(
sfmt
)
*
periodicBoxSize
[
2
]
*
3
);
particleList
[
i
][
2
]
=
(
RealOpenMM
)
(
genrand_real2
(
sfmt
)
*
periodicBoxSize
[
2
]
*
3
);
...
@@ -118,8 +107,6 @@ void testPeriodic() {
...
@@ -118,8 +107,6 @@ void testPeriodic() {
verifyNeighborList
(
neighborList
,
numParticles
,
particleList
,
periodicBoxSize
,
cutoff
);
verifyNeighborList
(
neighborList
,
numParticles
,
particleList
,
periodicBoxSize
,
cutoff
);
computeNeighborListVoxelHash
(
neighborList
,
numParticles
,
particleList
,
exclusions
,
periodicBoxSize
,
cutoff
);
computeNeighborListVoxelHash
(
neighborList
,
numParticles
,
particleList
,
exclusions
,
periodicBoxSize
,
cutoff
);
verifyNeighborList
(
neighborList
,
numParticles
,
particleList
,
periodicBoxSize
,
cutoff
);
verifyNeighborList
(
neighborList
,
numParticles
,
particleList
,
periodicBoxSize
,
cutoff
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
delete
[]
particleList
[
i
];
}
}
int
main
()
int
main
()
...
...
plugins/freeEnergy/platforms/reference/src/ReferenceFreeEnergyKernels.cpp
View file @
0843c5f3
...
@@ -41,6 +41,7 @@
...
@@ -41,6 +41,7 @@
#include <cmath>
#include <cmath>
#include <limits>
#include <limits>
using
namespace
std
;
using
namespace
OpenMM
;
using
namespace
OpenMM
;
static
int
**
allocateIntArray
(
int
length
,
int
width
)
{
static
int
**
allocateIntArray
(
int
length
,
int
width
)
{
...
@@ -57,26 +58,6 @@ static RealOpenMM** allocateRealArray(int length, int width) {
...
@@ -57,26 +58,6 @@ static RealOpenMM** allocateRealArray(int length, int width) {
return
array
;
return
array
;
}
}
static
int
**
copyToArray
(
const
std
::
vector
<
std
::
vector
<
int
>
>
vec
)
{
if
(
vec
.
size
()
==
0
)
return
new
int
*
[
0
];
int
**
array
=
allocateIntArray
(
vec
.
size
(),
vec
[
0
].
size
());
for
(
size_t
i
=
0
;
i
<
vec
.
size
();
++
i
)
for
(
size_t
j
=
0
;
j
<
vec
[
i
].
size
();
++
j
)
array
[
i
][
j
]
=
vec
[
i
][
j
];
return
array
;
}
static
RealOpenMM
**
copyToArray
(
const
std
::
vector
<
std
::
vector
<
double
>
>
vec
)
{
if
(
vec
.
size
()
==
0
)
return
new
RealOpenMM
*
[
0
];
RealOpenMM
**
array
=
allocateRealArray
(
vec
.
size
(),
vec
[
0
].
size
());
for
(
size_t
i
=
0
;
i
<
vec
.
size
();
++
i
)
for
(
size_t
j
=
0
;
j
<
vec
[
i
].
size
();
++
j
)
array
[
i
][
j
]
=
static_cast
<
RealOpenMM
>
(
vec
[
i
][
j
]);
return
array
;
}
static
void
disposeIntArray
(
int
**
array
,
int
size
)
{
static
void
disposeIntArray
(
int
**
array
,
int
size
)
{
if
(
array
)
{
if
(
array
)
{
for
(
int
i
=
0
;
i
<
size
;
++
i
)
for
(
int
i
=
0
;
i
<
size
;
++
i
)
...
@@ -93,19 +74,19 @@ static void disposeRealArray(RealOpenMM** array, int size) {
...
@@ -93,19 +74,19 @@ static void disposeRealArray(RealOpenMM** array, int size) {
}
}
}
}
static
RealOpenMM
**
extractPositions
(
ContextImpl
&
context
)
{
static
vector
<
RealVec
>&
extractPositions
(
ContextImpl
&
context
)
{
ReferencePlatform
::
PlatformData
*
data
=
reinterpret_cast
<
ReferencePlatform
::
PlatformData
*>
(
context
.
getPlatformData
());
ReferencePlatform
::
PlatformData
*
data
=
reinterpret_cast
<
ReferencePlatform
::
PlatformData
*>
(
context
.
getPlatformData
());
return
(
RealOpenMM
*
*
)
data
->
positions
;
return
*
((
vector
<
RealVec
>
*
)
data
->
positions
)
;
}
}
static
RealOpenMM
**
extractVelocities
(
ContextImpl
&
context
)
{
static
vector
<
RealVec
>&
extractVelocities
(
ContextImpl
&
context
)
{
ReferencePlatform
::
PlatformData
*
data
=
reinterpret_cast
<
ReferencePlatform
::
PlatformData
*>
(
context
.
getPlatformData
());
ReferencePlatform
::
PlatformData
*
data
=
reinterpret_cast
<
ReferencePlatform
::
PlatformData
*>
(
context
.
getPlatformData
());
return
(
RealOpenMM
*
*
)
data
->
velocities
;
return
*
((
vector
<
RealVec
>
*
)
data
->
velocities
)
;
}
}
static
RealOpenMM
**
extractForces
(
ContextImpl
&
context
)
{
static
vector
<
RealVec
>&
extractForces
(
ContextImpl
&
context
)
{
ReferencePlatform
::
PlatformData
*
data
=
reinterpret_cast
<
ReferencePlatform
::
PlatformData
*>
(
context
.
getPlatformData
());
ReferencePlatform
::
PlatformData
*
data
=
reinterpret_cast
<
ReferencePlatform
::
PlatformData
*>
(
context
.
getPlatformData
());
return
(
RealOpenMM
*
*
)
data
->
forces
;
return
*
((
vector
<
RealVec
>
*
)
data
->
forces
)
;
}
}
ReferenceFreeEnergyCalcNonbondedSoftcoreForceKernel
::~
ReferenceFreeEnergyCalcNonbondedSoftcoreForceKernel
()
{
ReferenceFreeEnergyCalcNonbondedSoftcoreForceKernel
::~
ReferenceFreeEnergyCalcNonbondedSoftcoreForceKernel
()
{
...
@@ -228,8 +209,8 @@ void ReferenceFreeEnergyCalcNonbondedSoftcoreForceKernel::initialize(const Syste
...
@@ -228,8 +209,8 @@ void ReferenceFreeEnergyCalcNonbondedSoftcoreForceKernel::initialize(const Syste
double
ReferenceFreeEnergyCalcNonbondedSoftcoreForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
ReferenceFreeEnergyCalcNonbondedSoftcoreForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
RealOpenMM
**
posData
=
extractPositions
(
context
);
vector
<
RealVec
>&
posData
=
extractPositions
(
context
);
RealOpenMM
**
forceData
=
extractForces
(
context
);
vector
<
RealVec
>&
forceData
=
extractForces
(
context
);
RealOpenMM
energy
=
0
;
RealOpenMM
energy
=
0
;
ReferenceFreeEnergyLJCoulombSoftcoreIxn
clj
;
ReferenceFreeEnergyLJCoulombSoftcoreIxn
clj
;
...
@@ -325,8 +306,8 @@ void ReferenceFreeEnergyCalcGBSAOBCSoftcoreForceKernel::initialize(const System&
...
@@ -325,8 +306,8 @@ void ReferenceFreeEnergyCalcGBSAOBCSoftcoreForceKernel::initialize(const System&
}
}
double
ReferenceFreeEnergyCalcGBSAOBCSoftcoreForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
ReferenceFreeEnergyCalcGBSAOBCSoftcoreForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
RealOpenMM
**
posData
=
extractPositions
(
context
);
vector
<
RealVec
>&
posData
=
extractPositions
(
context
);
RealOpenMM
**
forceData
=
extractForces
(
context
);
vector
<
RealVec
>&
forceData
=
extractForces
(
context
);
obc
->
computeImplicitSolventForces
(
posData
,
&
charges
[
0
],
forceData
,
1
);
obc
->
computeImplicitSolventForces
(
posData
,
&
charges
[
0
],
forceData
,
1
);
return
obc
->
getEnergy
();
return
obc
->
getEnergy
();
}
}
...
@@ -391,12 +372,12 @@ void ReferenceFreeEnergyCalcGBVISoftcoreForceKernel::initialize(const System& sy
...
@@ -391,12 +372,12 @@ void ReferenceFreeEnergyCalcGBVISoftcoreForceKernel::initialize(const System& sy
}
}
double
ReferenceFreeEnergyCalcGBVISoftcoreForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
ReferenceFreeEnergyCalcGBVISoftcoreForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
RealOpenMM
**
posData
=
extractPositions
(
context
);
vector
<
RealVec
>&
posData
=
extractPositions
(
context
);
RealOpenMM
*
bornRadii
=
new
RealOpenMM
[
context
.
getSystem
().
getNumParticles
()];
RealOpenMM
*
bornRadii
=
new
RealOpenMM
[
context
.
getSystem
().
getNumParticles
()];
gbviSoftcore
->
computeBornRadii
(
posData
,
bornRadii
,
NULL
);
gbviSoftcore
->
computeBornRadii
(
posData
,
bornRadii
,
NULL
);
if
(
includeForces
)
{
if
(
includeForces
)
{
RealOpenMM
**
forceData
=
extractForces
(
context
);
vector
<
RealVec
>&
forceData
=
extractForces
(
context
);
gbviSoftcore
->
computeBornForces
(
bornRadii
,
posData
,
&
charges
[
0
],
forceData
);
gbviSoftcore
->
computeBornForces
(
bornRadii
,
posData
,
&
charges
[
0
],
forceData
);
}
}
RealOpenMM
energy
=
0.0
;
RealOpenMM
energy
=
0.0
;
...
...
plugins/freeEnergy/platforms/reference/src/SimTKReference/ReferenceFreeEnergyLJCoulomb14Softcore.cpp
View file @
0843c5f3
...
@@ -31,6 +31,9 @@
...
@@ -31,6 +31,9 @@
#include "ReferenceFreeEnergyLJCoulomb14Softcore.h"
#include "ReferenceFreeEnergyLJCoulomb14Softcore.h"
#include "ReferenceForce.h"
#include "ReferenceForce.h"
using
std
::
vector
;
using
OpenMM
::
RealVec
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
ReferenceFreeEnergyLJCoulomb14Softcore constructor
ReferenceFreeEnergyLJCoulomb14Softcore constructor
...
@@ -144,8 +147,8 @@ int ReferenceFreeEnergyLJCoulomb14Softcore::getDerivedParameters( RealOpenMM c6,
...
@@ -144,8 +147,8 @@ int ReferenceFreeEnergyLJCoulomb14Softcore::getDerivedParameters( RealOpenMM c6,
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
ReferenceFreeEnergyLJCoulomb14Softcore
::
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
void
ReferenceFreeEnergyLJCoulomb14Softcore
::
calculateBondIxn
(
int
*
atomIndices
,
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
parameters
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
{
RealOpenMM
*
totalEnergy
)
const
{
static
const
std
::
string
methodName
=
"
\n
ReferenceFreeEnergyLJCoulomb14Softcore::calculateBondIxn"
;
static
const
std
::
string
methodName
=
"
\n
ReferenceFreeEnergyLJCoulomb14Softcore::calculateBondIxn"
;
...
@@ -221,59 +224,6 @@ void ReferenceFreeEnergyLJCoulomb14Softcore::calculateBondIxn( int* atomIndices,
...
@@ -221,59 +224,6 @@ void ReferenceFreeEnergyLJCoulomb14Softcore::calculateBondIxn( int* atomIndices,
if
(
totalEnergy
!=
NULL
)
if
(
totalEnergy
!=
NULL
)
*
totalEnergy
+=
energy
;
*
totalEnergy
+=
energy
;
// debug
if
(
debug
){
static
bool
printHeader
=
false
;
std
::
stringstream
message
;
message
<<
methodName
;
message
<<
std
::
endl
;
if
(
!
printHeader
){
printHeader
=
true
;
message
<<
std
::
endl
;
message
<<
methodName
.
c_str
()
<<
" a0 k [c q p s] r1 r2 angle dt rp p[] dot cosine angle dEdR*r F[]"
<<
std
::
endl
;
}
message
<<
std
::
endl
;
for
(
int
ii
=
0
;
ii
<
LastAtomIndex
;
ii
++
){
message
<<
" Atm "
<<
atomIndices
[
ii
]
<<
" ["
<<
atomCoordinates
[
atomIndices
[
ii
]][
0
]
<<
" "
<<
atomCoordinates
[
atomIndices
[
ii
]][
1
]
<<
"] "
;
}
message
<<
std
::
endl
<<
" Delta:"
;
for
(
int
ii
=
0
;
ii
<
(
LastAtomIndex
-
1
);
ii
++
){
message
<<
" ["
;
for
(
int
jj
=
0
;
jj
<
ReferenceForce
::
LastDeltaRIndex
;
jj
++
){
message
<<
deltaR
[
ii
][
jj
]
<<
" "
;
}
message
<<
"]"
;
}
message
<<
std
::
endl
;
message
<<
" p1="
<<
parameters
[
0
];
message
<<
" p2="
<<
parameters
[
1
];
message
<<
" p3="
<<
parameters
[
2
];
message
<<
std
::
endl
<<
" "
;
message
<<
" dEdR="
<<
dEdR
;
message
<<
" E="
<<
energy
<<
" force factors: "
;
message
<<
"F=compute force; f=cumulative force"
;
message
<<
std
::
endl
<<
" "
;
for
(
int
ii
=
0
;
ii
<
LastAtomIndex
;
ii
++
){
message
<<
" F"
<<
(
ii
+
1
)
<<
"["
;
SimTKOpenMMUtilities
::
formatRealStringStream
(
message
,
deltaR
[
0
],
threeI
,
dEdR
);
message
<<
"]"
;
}
message
<<
std
::
endl
<<
" "
;
for
(
int
ii
=
0
;
ii
<
LastAtomIndex
;
ii
++
){
message
<<
" f"
<<
(
ii
+
1
)
<<
"["
;
SimTKOpenMMUtilities
::
formatRealStringStream
(
message
,
forces
[
atomIndices
[
ii
]],
threeI
);
message
<<
"]"
;
}
//SimTKOpenMMLog::printMessage( message );
}
}
}
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
...
plugins/freeEnergy/platforms/reference/src/SimTKReference/ReferenceFreeEnergyLJCoulomb14Softcore.h
View file @
0843c5f3
...
@@ -102,8 +102,8 @@ class ReferenceFreeEnergyLJCoulomb14Softcore : public ReferenceBondIxn {
...
@@ -102,8 +102,8 @@ class ReferenceFreeEnergyLJCoulomb14Softcore : public ReferenceBondIxn {
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
void
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
void
calculateBondIxn
(
int
*
atomIndices
,
std
::
vector
<
OpenMM
::
RealVec
>&
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
parameters
,
std
::
vector
<
OpenMM
::
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
;
RealOpenMM
*
totalEnergy
)
const
;
/**---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
...
...
Prev
1
2
3
4
5
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