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
76e2849c
"platforms/common/src/kernels/customIntegrator.cc" did not exist on "8eb6850dba9fb13c8fee94524318f134c9b298af"
Commit
76e2849c
authored
Apr 17, 2008
by
Peter Eastman
Browse files
Moving the reference code into the platforms folder
parent
ae4c6f96
Changes
36
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
4159 additions
and
0 deletions
+4159
-0
platforms/reference/src/ReferenceAngleBondIxn.cpp
platforms/reference/src/ReferenceAngleBondIxn.cpp
+272
-0
platforms/reference/src/ReferenceAngleBondIxn.h
platforms/reference/src/ReferenceAngleBondIxn.h
+96
-0
platforms/reference/src/ReferenceBondForce.cpp
platforms/reference/src/ReferenceBondForce.cpp
+124
-0
platforms/reference/src/ReferenceBondForce.h
platforms/reference/src/ReferenceBondForce.h
+84
-0
platforms/reference/src/ReferenceBondIxn.cpp
platforms/reference/src/ReferenceBondIxn.cpp
+293
-0
platforms/reference/src/ReferenceBondIxn.h
platforms/reference/src/ReferenceBondIxn.h
+148
-0
platforms/reference/src/ReferenceConstraint.cpp
platforms/reference/src/ReferenceConstraint.cpp
+248
-0
platforms/reference/src/ReferenceConstraint.h
platforms/reference/src/ReferenceConstraint.h
+160
-0
platforms/reference/src/ReferenceDynamics.cpp
platforms/reference/src/ReferenceDynamics.cpp
+905
-0
platforms/reference/src/ReferenceDynamics.h
platforms/reference/src/ReferenceDynamics.h
+364
-0
platforms/reference/src/ReferenceForce.cpp
platforms/reference/src/ReferenceForce.cpp
+230
-0
platforms/reference/src/ReferenceForce.h
platforms/reference/src/ReferenceForce.h
+131
-0
platforms/reference/src/ReferenceHarmonicBondIxn.cpp
platforms/reference/src/ReferenceHarmonicBondIxn.cpp
+136
-0
platforms/reference/src/ReferenceHarmonicBondIxn.h
platforms/reference/src/ReferenceHarmonicBondIxn.h
+77
-0
platforms/reference/src/ReferenceLJ14.cpp
platforms/reference/src/ReferenceLJ14.cpp
+251
-0
platforms/reference/src/ReferenceLJ14.h
platforms/reference/src/ReferenceLJ14.h
+100
-0
platforms/reference/src/ReferenceLJCoulombIxn.cpp
platforms/reference/src/ReferenceLJCoulombIxn.cpp
+286
-0
platforms/reference/src/ReferenceLJCoulombIxn.h
platforms/reference/src/ReferenceLJCoulombIxn.h
+110
-0
platforms/reference/src/ReferencePairIxn.cpp
platforms/reference/src/ReferencePairIxn.cpp
+64
-0
platforms/reference/src/ReferencePairIxn.h
platforms/reference/src/ReferencePairIxn.h
+80
-0
No files found.
platforms/reference/src/ReferenceAngleBondIxn.cpp
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceAngleBondIxn.h"
#include "ReferenceForce.h"
/**---------------------------------------------------------------------------------------
ReferenceAngleBondIxn constructor
--------------------------------------------------------------------------------------- */
ReferenceAngleBondIxn
::
ReferenceAngleBondIxn
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceAngleBondIxn::ReferenceAngleBondIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceAngleBondIxn destructor
--------------------------------------------------------------------------------------- */
ReferenceAngleBondIxn
::~
ReferenceAngleBondIxn
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceAngleBondIxn::~ReferenceAngleBondIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Get dEdR and energy term for angle bond
@param cosine cosine of angle
@param angleParameters angleParameters: angleParameters[0] = angle in degrees
angleParameters[1] = k (force constant)
@param dEdR output dEdR
@param energyTerm output energyTerm
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceAngleBondIxn
::
getPrefactorsGivenAngleCosine
(
RealOpenMM
cosine
,
RealOpenMM
*
angleParameters
,
RealOpenMM
*
dEdR
,
RealOpenMM
*
energyTerm
)
const
{
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceAngleBondIxn::getPrefactorsGivenAngleCosine";
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
static
const
RealOpenMM
half
=
0.5
;
// ---------------------------------------------------------------------------------------
RealOpenMM
angle
;
if
(
cosine
>=
one
){
angle
=
zero
;
}
else
if
(
cosine
<=
-
one
){
angle
=
PI_M
;
}
else
{
angle
=
ACOS
(
cosine
);
}
RealOpenMM
deltaIdeal
=
angle
-
(
angleParameters
[
0
]
*
DEGREE_TO_RADIAN
);
RealOpenMM
deltaIdeal2
=
deltaIdeal
*
deltaIdeal
;
*
dEdR
=
angleParameters
[
1
]
*
deltaIdeal
;
*
energyTerm
=
half
*
angleParameters
[
1
]
*
deltaIdeal2
;
return
ReferenceForce
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Calculate Angle Bond ixn
@param atomIndices two bond indices
@param atomCoordinates atom coordinates
@param parameters parameters: parameters[0] = ideal bond length
parameters[1] = bond k (includes factor of 2)
@param forces force array (forces added)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceAngleBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
energiesByAtom
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceAngleBondIxn::calculateBondIxn";
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"
\n
ReferenceAngleBondIxn::calculateBondIxn"
;
// constants -- reduce Visual Studio warnings regarding conversions between float & double
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
oneM
=
-
1.0
;
static
const
int
threeI
=
3
;
// debug flag
static
const
int
debug
=
0
;
static
const
int
LastAtomIndex
=
3
;
RealOpenMM
deltaR
[
2
][
ReferenceForce
::
LastDeltaRIndex
];
// ---------------------------------------------------------------------------------------
// get deltaR, R2, and R between 2 atoms
int
atomAIndex
=
atomIndices
[
0
];
int
atomBIndex
=
atomIndices
[
1
];
int
atomCIndex
=
atomIndices
[
2
];
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
[
0
]
);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomCIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
[
1
]
);
RealOpenMM
pVector
[
threeI
];
SimTKOpenMMUtilities
::
crossProductVector3
(
deltaR
[
0
],
deltaR
[
1
],
pVector
);
RealOpenMM
rp
=
DOT3
(
pVector
,
pVector
);
rp
=
SQRT
(
rp
);
if
(
rp
<
1.0e-06
){
rp
=
(
RealOpenMM
)
1.0e-06
;
}
RealOpenMM
dot
=
DOT3
(
deltaR
[
0
],
deltaR
[
1
]
);
RealOpenMM
cosine
=
dot
/
SQRT
(
(
deltaR
[
0
][
ReferenceForce
::
R2Index
]
*
deltaR
[
1
][
ReferenceForce
::
R2Index
])
);
RealOpenMM
dEdR
;
RealOpenMM
energy
;
getPrefactorsGivenAngleCosine
(
cosine
,
parameters
,
&
dEdR
,
&
energy
);
RealOpenMM
termA
=
dEdR
/
(
deltaR
[
0
][
ReferenceForce
::
R2Index
]
*
rp
);
RealOpenMM
termC
=
-
dEdR
/
(
deltaR
[
1
][
ReferenceForce
::
R2Index
]
*
rp
);
RealOpenMM
deltaCrossP
[
LastAtomIndex
][
threeI
];
SimTKOpenMMUtilities
::
crossProductVector3
(
deltaR
[
0
],
pVector
,
deltaCrossP
[
0
]
);
SimTKOpenMMUtilities
::
crossProductVector3
(
deltaR
[
1
],
pVector
,
deltaCrossP
[
2
]
);
for
(
int
ii
=
0
;
ii
<
threeI
;
ii
++
){
deltaCrossP
[
0
][
ii
]
*=
termA
;
deltaCrossP
[
2
][
ii
]
*=
termC
;
deltaCrossP
[
1
][
ii
]
=
oneM
*
(
deltaCrossP
[
0
][
ii
]
+
deltaCrossP
[
2
][
ii
]);
}
// accumulate forces
for
(
int
jj
=
0
;
jj
<
LastAtomIndex
;
jj
++
){
for
(
int
ii
=
0
;
ii
<
threeI
;
ii
++
){
forces
[
atomIndices
[
jj
]][
ii
]
+=
deltaCrossP
[
jj
][
ii
];
}
}
// accumulate energies
updateEnergy
(
energy
,
energiesByBond
,
LastAtomIndex
,
atomIndices
,
energiesByAtom
);
// 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
<
3
;
ii
++
){
message
<<
" Atm "
<<
atomIndices
[
ii
]
<<
" ["
<<
atomCoordinates
[
ii
][
0
]
<<
" "
<<
atomCoordinates
[
ii
][
1
]
<<
" "
<<
atomCoordinates
[
ii
][
2
]
<<
"] "
;
}
message
<<
std
::
endl
<<
" Delta:"
;
for
(
int
ii
=
0
;
ii
<
2
;
ii
++
){
message
<<
" ["
;
for
(
int
jj
=
0
;
jj
<
ReferenceForce
::
LastDeltaRIndex
;
jj
++
){
message
<<
deltaR
[
ii
][
jj
]
<<
" "
;
}
message
<<
"]"
;
}
message
<<
std
::
endl
;
message
<<
" a0="
<<
parameters
[
0
];
message
<<
" k="
<<
parameters
[
1
];
message
<<
" rab2="
<<
deltaR
[
0
][
ReferenceForce
::
R2Index
];
message
<<
" rcb2="
<<
deltaR
[
1
][
ReferenceForce
::
R2Index
];
message
<<
std
::
endl
<<
" "
;
message
<<
" rp="
<<
rp
;
message
<<
" p["
;
SimTKOpenMMUtilities
::
formatRealStringStream
(
message
,
pVector
);
message
<<
"] dot="
<<
dot
;
message
<<
" cos="
<<
cosine
;
message
<<
std
::
endl
<<
" "
;
message
<<
" dEdr="
<<
dEdR
;
message
<<
" trmA="
<<
termA
;
message
<<
" trmC="
<<
termC
;
message
<<
" E="
<<
energy
<<
" F=compute force; f=cumulative force"
;
message
<<
std
::
endl
<<
" "
;
for
(
int
ii
=
0
;
ii
<
3
;
ii
++
){
message
<<
" F"
<<
(
ii
+
1
)
<<
"["
;
SimTKOpenMMUtilities
::
formatRealStringStream
(
message
,
deltaCrossP
[
ii
],
threeI
);
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
);
}
return
ReferenceForce
::
DefaultReturn
;
}
platforms/reference/src/ReferenceAngleBondIxn.h
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceAngleBondIxn_H__
#define __ReferenceAngleBondIxn_H__
#include "ReferenceBondIxn.h"
// ---------------------------------------------------------------------------------------
class
ReferenceAngleBondIxn
:
public
ReferenceBondIxn
{
private:
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferenceAngleBondIxn
(
);
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~
ReferenceAngleBondIxn
(
);
/**---------------------------------------------------------------------------------------
Get dEdR and energy term for angle bond
@param cosine cosine of angle
@param angleParameters angleParameters: angleParameters[0] = angle in degrees
angleParameters[1] = k (force constant)
@param dEdR output dEdR
@param energyTerm output energyTerm
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
getPrefactorsGivenAngleCosine
(
RealOpenMM
cosine
,
RealOpenMM
*
angleParameters
,
RealOpenMM
*
dEdR
,
RealOpenMM
*
energyTerm
)
const
;
/**---------------------------------------------------------------------------------------
Calculate Angle Bond ixn
@param atomIndices two bond indices
@param atomCoordinates atom coordinates
@param parameters parameters: parameters[0] = ideal bond length
parameters[1] = bond k (includes factor of 2)
@param forces force array (forces added)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
energiesByAtom
)
const
;
};
// ---------------------------------------------------------------------------------------
#endif // __ReferenceAngleBondIxn_H__
platforms/reference/src/ReferenceBondForce.cpp
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceBondForce.h"
/**---------------------------------------------------------------------------------------
ReferenceBondForce constructor
--------------------------------------------------------------------------------------- */
ReferenceBondForce
::
ReferenceBondForce
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceBondForce::ReferenceBondForce";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceBondForce destructor
--------------------------------------------------------------------------------------- */
ReferenceBondForce
::~
ReferenceBondForce
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceBondForce::~ReferenceBondForce";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Calculate forces/energy for bonds
@param numberOfBonds number of bonds
@param atomIndices indices of atoms participating in bond ixn: atomIndices[bondIndex][indices]
@param atomCoordinates atom coordinates: atomCoordinates[atomIndex][3]
@param parameters parameters: parameters[bondIndex][*]; contents of array
depend on ixn
@param forces force array (forces added to current values): forces[atomIndex][3]
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@param totalEnergy totalEnergy: sum over { energies[atomIndex] }
@param ReferenceBondIxn ixn to be calculated
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceBondForce
::
calculateForce
(
int
numberOfBonds
,
int
**
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
energiesByAtom
,
RealOpenMM
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
){
// ---------------------------------------------------------------------------------------
static
const
char
*
methodName
=
"
\n
ReferenceBondForce::calculateForce"
;
// ---------------------------------------------------------------------------------------
for
(
int
ii
=
0
;
ii
<
numberOfBonds
;
ii
++
){
// diagnostics
if
(
0
){
std
::
stringstream
message
;
message
<<
methodName
<<
" "
<<
ii
;
//message << " XAtm" << (unsigned int) atomIndices << " " << (unsigned int) atomIndices[0];
//message << " atm[" << atomIndices[ii][0] << " " << atomIndices[ii][1] << "]";
SimTKOpenMMLog
::
printMessage
(
message
);
}
// calculate bond ixn
referenceBondIxn
.
calculateBondIxn
(
atomIndices
[
ii
],
atomCoordinates
,
parameters
[
ii
],
forces
,
(
energiesByBond
==
NULL
?
NULL
:
energiesByBond
+
ii
),
energiesByAtom
);
if
(
energiesByBond
!=
NULL
){
*
totalEnergy
+=
energiesByBond
[
ii
];
}
}
return
ReferenceForce
::
DefaultReturn
;
}
platforms/reference/src/ReferenceBondForce.h
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceBondForce_H__
#define __ReferenceBondForce_H__
#include "ReferenceForce.h"
#include "ReferenceBondIxn.h"
// ---------------------------------------------------------------------------------------
class
ReferenceBondForce
:
public
ReferenceForce
{
private:
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferenceBondForce
(
);
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~
ReferenceBondForce
(
);
/**---------------------------------------------------------------------------------------
Calculate forces/energy for bonds
@param numberOfBonds number of bonds
@param atomIndices indices of atoms participating in bond ixn: atomIndices[bondIndex][indices]
@param atomCoordinates atom coordinates: atomCoordinates[atomIndex][3]
@param parameters parameters: parameters[bondIndex][*]; contents of array
depend on ixn
@param forces force array (forces added to current values): forces[atomIndex][3]
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@param totalEnergy totalEnergy: sum over { energies[atomIndex] }
@param ReferenceBondIxn ixn to be calculated
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
calculateForce
(
int
numberOfBonds
,
int
**
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
energiesByAtom
,
RealOpenMM
*
totalEnergy
,
ReferenceBondIxn
&
referenceBondIxn
);
};
// ---------------------------------------------------------------------------------------
#endif // __ReferenceBondForce_H__
platforms/reference/src/ReferenceBondIxn.cpp
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferenceBondIxn.h"
/**---------------------------------------------------------------------------------------
ReferenceBondIxn constructor
--------------------------------------------------------------------------------------- */
ReferenceBondIxn
::
ReferenceBondIxn
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceBondIxn::ReferenceBondIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceBondIxn destructor
--------------------------------------------------------------------------------------- */
ReferenceBondIxn
::~
ReferenceBondIxn
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceBondIxn::~ReferenceBondIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Update energy
@param energy energy value to update
@param energyByBond ptr to energyByBond accumulator (may be null)
@param numberOfAtomIndices number of atoms in bond
@param atomIndices array of atom indices of size 'numberOfAtomIndices'
@param energyByAtom array of energies by atom (may be null)
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceBondIxn
::
updateEnergy
(
RealOpenMM
energy
,
RealOpenMM
*
energyByBond
,
int
numberOfAtomIndices
,
int
*
atomIndices
,
RealOpenMM
*
energyByAtom
)
const
{
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceBondIxn::updateEnergy";
// ---------------------------------------------------------------------------------------
if
(
energyByBond
){
*
energyByBond
+=
energy
;
}
if
(
energyByAtom
){
for
(
int
ii
=
0
;
ii
<
numberOfAtomIndices
;
ii
++
){
energyByAtom
[
atomIndices
[
ii
]]
+=
energy
;
}
}
return
ReferenceForce
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Calculate Bond Ixn -- virtual method -- does nothing
@param atomIndices bond indices
@param atomCoordinates atom coordinates
@param parameters parameters
@param forces force array (forces added)
@param energyByBond bond energy
@param energy atom energy
--------------------------------------------------------------------------------------- */
int
ReferenceBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energyByBond
,
RealOpenMM
*
energyByAtom
)
const
{
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceBondIxn::calculateBondIxn";
// ---------------------------------------------------------------------------------------
return
ReferenceForce
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Get normed dot product between two vectors
Do computation in double?
@param vector1 first vector
@param vector2 second vector
@param hasREntry if set, then vector1[ReferenceForce::RIndex] = norm of vector
defaults to 0 (i.e., R unavailable)
@return dot product
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceBondIxn
::
getNormedDotProduct
(
RealOpenMM
*
vector1
,
RealOpenMM
*
vector2
,
int
hasREntry
=
0
)
const
{
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceBondIxn::getNormedDotProduct";
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
// ---------------------------------------------------------------------------------------
RealOpenMM
dotProduct
=
DOT3
(
vector1
,
vector2
);
if
(
dotProduct
!=
zero
){
if
(
hasREntry
){
dotProduct
/=
(
vector1
[
ReferenceForce
::
RIndex
]
*
vector2
[
ReferenceForce
::
RIndex
]
);
}
else
{
RealOpenMM
norm1
=
DOT3
(
vector1
,
vector1
);
RealOpenMM
norm2
=
DOT3
(
vector2
,
vector2
);
dotProduct
/=
SQRT
(
norm1
*
norm2
);
}
}
// clamp dot product to [-1,1]
if
(
dotProduct
>
one
){
dotProduct
=
one
;
}
else
if
(
dotProduct
<
-
one
){
dotProduct
=
-
one
;
}
return
dotProduct
;
}
/**---------------------------------------------------------------------------------------
Get angle between two vectors
@param vector1 first vector
@param vector2 second vector
@param outputDotProduct output cosine of angle between two vectors (optional)
@param hasREntry if set, then vector1[ReferenceForce::RIndex] = norm of vector
defaults to 0 -> R unavailable
@return cosine of angles in radians
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceBondIxn
::
getAngleBetweenTwoVectors
(
RealOpenMM
*
vector1
,
RealOpenMM
*
vector2
,
RealOpenMM
*
outputDotProduct
=
NULL
,
int
hasREntry
=
0
)
const
{
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceBondIxn::getAngle";
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
// ---------------------------------------------------------------------------------------
// get dot product betweenn vectors and then angle
RealOpenMM
dotProduct
=
getNormedDotProduct
(
vector1
,
vector2
,
hasREntry
);
RealOpenMM
angle
;
if
(
dotProduct
>=
one
){
angle
=
zero
;
}
else
if
(
dotProduct
<=
-
one
){
angle
=
PI_M
;
}
else
{
angle
=
ACOS
(
dotProduct
);
}
if
(
outputDotProduct
){
*
outputDotProduct
=
dotProduct
;
}
return
angle
;
}
/**---------------------------------------------------------------------------------------
Get dihedral angle between three vectors
@param vector1 first vector
@param vector2 second vector
@param vector3 third vector
@param outputCrossProduct output cross product vectors
@param cosineOfAngle cosine of angle (output)
@param signVector vector to test sign (optional)
@param signOfAngle sign of angle (output) (optional)
@param hasREntry if set, then vector1[ReferenceForce::RIndex] = norm of vector
defaults to 0
@return cosine of dihedral angle in radians
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceBondIxn
::
getDihedralAngleBetweenThreeVectors
(
RealOpenMM
*
vector1
,
RealOpenMM
*
vector2
,
RealOpenMM
*
vector3
,
RealOpenMM
**
outputCrossProduct
=
NULL
,
RealOpenMM
*
cosineOfAngle
=
NULL
,
RealOpenMM
*
signVector
=
NULL
,
RealOpenMM
*
signOfAngle
=
NULL
,
int
hasREntry
=
0
)
const
{
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceBondIxn::getDihedralAngleBetweenThreeVectors";
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
RealOpenMM
tempVectors
[
6
]
=
{
zero
,
zero
,
zero
,
zero
,
zero
,
zero
};
// ---------------------------------------------------------------------------------------
// get cross products between vectors and then angle between cross product vectors
RealOpenMM
*
crossProduct
[
2
];
if
(
outputCrossProduct
){
crossProduct
[
0
]
=
outputCrossProduct
[
0
];
crossProduct
[
1
]
=
outputCrossProduct
[
1
];
}
else
{
crossProduct
[
0
]
=
tempVectors
;
crossProduct
[
1
]
=
tempVectors
+
3
;
}
SimTKOpenMMUtilities
::
crossProductVector3
(
vector1
,
vector2
,
crossProduct
[
0
]
);
SimTKOpenMMUtilities
::
crossProductVector3
(
vector2
,
vector3
,
crossProduct
[
1
]
);
RealOpenMM
angle
=
getAngleBetweenTwoVectors
(
crossProduct
[
0
],
crossProduct
[
1
],
cosineOfAngle
,
0
);
// take care of sign of angle
if
(
signVector
){
RealOpenMM
dotProduct
=
DOT3
(
signVector
,
crossProduct
[
1
]
);
RealOpenMM
sign
=
dotProduct
<
zero
?
-
one
:
one
;
if
(
signOfAngle
){
*
signOfAngle
=
sign
;
}
angle
*=
sign
;
}
return
angle
;
}
platforms/reference/src/ReferenceBondIxn.h
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceBondIxn_H__
#define __ReferenceBondIxn_H__
// #include "ReferenceIxn.h"
// ---------------------------------------------------------------------------------------
class
ReferenceBondIxn
{
private:
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferenceBondIxn
(
);
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~
ReferenceBondIxn
(
);
/**---------------------------------------------------------------------------------------
Calculate Bond Ixn -- virtual method
@param atomIndices bond indices
@param atomCoordinates atom coordinates
@param parameters parameters
@param forces force array (forces added)
@param energyByBond bond energy
@param energy atom energy
--------------------------------------------------------------------------------------- */
virtual
int
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energyByBond
,
RealOpenMM
*
energyByAtom
)
const
;
/**---------------------------------------------------------------------------------------
Update energy
@param energy energy value to update
@param energyByBond ptr to energyByBond accumulator (may be null)
@param numberOfAtomIndices number of atoms in bond
@param atomIndices array of atom indices of size 'numberOfAtomIndices'
@param energyByAtom array of energies by atom (may be null)
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
updateEnergy
(
RealOpenMM
energy
,
RealOpenMM
*
energyByBond
,
int
numberOfAtomIndices
,
int
*
atomIndices
,
RealOpenMM
*
energyByAtom
)
const
;
/**---------------------------------------------------------------------------------------
Get normed dot product between two vectors
@param vector1 first vector
@param vector2 second vector
@param hasREntry if set, then vector1[ReferenceForce::RIndex] = norm of vector;
defaults to 0
@return dot product
--------------------------------------------------------------------------------------- */
RealOpenMM
getNormedDotProduct
(
RealOpenMM
*
vector1
,
RealOpenMM
*
vector2
,
int
hasREntry
)
const
;
/**---------------------------------------------------------------------------------------
Get angle between two vectors
@param vector1 first vector
@param vector2 second vector
@param outputDotProduct cosine of angle between two vectors (optional)
@param hasREntry if set, then vector1[ReferenceForce::R2Index] = square norm of vector;
defaults to 0
@return cosine of angles in radians
--------------------------------------------------------------------------------------- */
RealOpenMM
getAngleBetweenTwoVectors
(
RealOpenMM
*
vector1
,
RealOpenMM
*
vector2
,
RealOpenMM
*
outputDotProduct
,
int
hasREntry
)
const
;
/**---------------------------------------------------------------------------------------
Get dihedral angle between two vectors
@param vector1 first vector
@param vector2 second vector
@param vector3 third vector
@param outputCrossProduct output cross product vectors
@param cosineOfAngle cosine of angle (output)
@param signVector vector to test sign (optional)
@param signOfAngle sign of angle (output) (optional)
@param hasREntry if set, then vector1[ReferenceForce::R2Index] = square norm of vector
defaults to 0
@return cosine of angles in radians
--------------------------------------------------------------------------------------- */
RealOpenMM
getDihedralAngleBetweenThreeVectors
(
RealOpenMM
*
vector1
,
RealOpenMM
*
vector2
,
RealOpenMM
*
vector3
,
RealOpenMM
**
outputCrossProduct
,
RealOpenMM
*
cosineOfAngle
,
RealOpenMM
*
signVector
,
RealOpenMM
*
signOfAngle
,
int
hasREntry
)
const
;
};
// ---------------------------------------------------------------------------------------
#endif // __ReferenceBondIxn_H__
platforms/reference/src/ReferenceConstraint.cpp
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceConstraint.h"
#include "ReferenceDynamics.h"
/**---------------------------------------------------------------------------------------
ReferenceConstraint constructor
--------------------------------------------------------------------------------------- */
ReferenceConstraint
::
ReferenceConstraint
(
){
// ---------------------------------------------------------------------------------------
//static const char* methodName = "\nReferenceConstraint::ReferenceConstraint";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceConstraint destructor
--------------------------------------------------------------------------------------- */
ReferenceConstraint
::~
ReferenceConstraint
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceConstraint::~ReferenceConstraint";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceShakeConstraint constructor
@param numberOfAtoms number of atoms
@param deltaT delta t for dynamics
@param tau viscosity
@param temperature temperature
--------------------------------------------------------------------------------------- */
ReferenceShakeConstraint
::
ReferenceShakeConstraint
(
int
atomIndex1
,
int
atomIndex2
,
RealOpenMM
constraintDistance
,
RealOpenMM
inverseMass1
,
RealOpenMM
inverseMass2
)
:
ReferenceConstraint
(
)
{
// ---------------------------------------------------------------------------------------
static
const
char
*
methodName
=
"
\n
ReferenceShakeConstraint::ReferenceShakeConstraint"
;
// ---------------------------------------------------------------------------------------
// insure heavy atom is in 0 slot
if
(
inverseMass1
>
inverseMass2
){
int
temp
=
atomIndex1
;
atomIndex1
=
atomIndex2
;
atomIndex2
=
temp
;
RealOpenMM
tempR
=
inverseMass1
;
inverseMass1
=
inverseMass2
;
inverseMass2
=
tempR
;
}
_atomIndices
[
0
]
=
atomIndex1
;
_atomIndices
[
1
]
=
atomIndex2
;
_inverseMasses
[
0
]
=
inverseMass1
;
_inverseMasses
[
1
]
=
inverseMass2
;
_constraintDistance
=
constraintDistance
;
}
/**---------------------------------------------------------------------------------------
ReferenceShakeConstraint destructor
--------------------------------------------------------------------------------------- */
ReferenceShakeConstraint
::~
ReferenceShakeConstraint
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceShakeConstraint::~ReferenceShakeConstraint";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Get constraint distance
@return constraintDistance
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceShakeConstraint
::
getConstraintDistance
(
void
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceShakeConstraint::getConstraintDistance";
// ---------------------------------------------------------------------------------------
return
_constraintDistance
;
}
/**---------------------------------------------------------------------------------------
Get inverse mass of heavy atom
@return inverse mass
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceShakeConstraint
::
getHeavyAtomInverseMass
(
void
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceShakeConstraint::getHeavyAtomInverseMass";
// ---------------------------------------------------------------------------------------
return
_inverseMasses
[
0
];
}
/**---------------------------------------------------------------------------------------
Get inverse mass of light atom
@return inverse mass
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceShakeConstraint
::
getLightAtomInverseMass
(
void
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceShakeConstraint::getLightAtomInverseMass";
// ---------------------------------------------------------------------------------------
return
_inverseMasses
[
1
];
}
/**---------------------------------------------------------------------------------------
Get index of heavy atom
@return index
--------------------------------------------------------------------------------------- */
int
ReferenceShakeConstraint
::
getHeavyAtomIndex
(
void
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceShakeConstraint::getHeavyAtomIndex";
// ---------------------------------------------------------------------------------------
return
_atomIndices
[
0
];
}
/**---------------------------------------------------------------------------------------
Get index of light atom
@return index
--------------------------------------------------------------------------------------- */
int
ReferenceShakeConstraint
::
getLightAtomIndex
(
void
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceShakeConstraint::getLightAtomIndex";
// ---------------------------------------------------------------------------------------
return
_atomIndices
[
1
];
}
/**---------------------------------------------------------------------------------------
Print state
@param message message
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceShakeConstraint
::
printState
(
std
::
stringstream
&
message
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceShakeConstraint::printState";
// ---------------------------------------------------------------------------------------
// print state
message
<<
" atoms["
<<
_atomIndices
[
0
]
<<
" "
<<
_atomIndices
[
1
]
<<
"]"
;
message
<<
" d="
<<
_constraintDistance
;
message
<<
" massI["
<<
_inverseMasses
[
0
]
<<
" "
<<
_inverseMasses
[
1
]
<<
"]"
;
return
ReferenceDynamics
::
DefaultReturn
;
}
platforms/reference/src/ReferenceConstraint.h
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceConstraint_H__
#define __ReferenceConstraint_H__
// ---------------------------------------------------------------------------------------
class
ReferenceConstraint
{
private:
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferenceConstraint
(
);
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~
ReferenceConstraint
(
);
};
class
ReferenceShakeConstraint
:
public
ReferenceConstraint
{
private:
// force heavy atom into index 0
int
_atomIndices
[
2
];
RealOpenMM
_inverseMasses
[
2
];
RealOpenMM
_constraintDistance
;
public:
/**---------------------------------------------------------------------------------------
Constructor
@param atomIndex1 atom index 1
@param atomIndex2 atom index 2
@param distance distance constraint
@param inverseMass1 inverseMass of atom 1
@param inverseMass2 inverseMass of atom 2
--------------------------------------------------------------------------------------- */
ReferenceShakeConstraint
(
int
atomIndex1
,
int
atomIndex2
,
RealOpenMM
distance
,
RealOpenMM
inverseMass1
,
RealOpenMM
inverseMass2
);
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~
ReferenceShakeConstraint
(
);
/**---------------------------------------------------------------------------------------
Get constraint distance
@return distance
--------------------------------------------------------------------------------------- */
RealOpenMM
getConstraintDistance
(
void
);
/**---------------------------------------------------------------------------------------
Get inverse mass of heavy atom
@return inverse mass
--------------------------------------------------------------------------------------- */
RealOpenMM
getHeavyAtomInverseMass
(
void
);
/**---------------------------------------------------------------------------------------
Get inverse mass of light atom
@return inverse mass
--------------------------------------------------------------------------------------- */
RealOpenMM
getLightAtomInverseMass
(
void
);
/**---------------------------------------------------------------------------------------
Get index of heavy atom
@return index
--------------------------------------------------------------------------------------- */
int
getHeavyAtomIndex
(
void
);
/**---------------------------------------------------------------------------------------
Get index of light atom
@return index
--------------------------------------------------------------------------------------- */
int
getLightAtomIndex
(
void
);
/**---------------------------------------------------------------------------------------
Print state
@param message message
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
printState
(
std
::
stringstream
&
message
);
};
typedef
std
::
vector
<
ReferenceShakeConstraint
*>
ShakeVector
;
typedef
ShakeVector
::
iterator
ShakeVectorI
;
typedef
std
::
map
<
int
,
ShakeVector
*>
IntShakeMap
;
typedef
IntShakeMap
::
iterator
IntShakeMapI
;
// ---------------------------------------------------------------------------------------
#endif // __ReferenceShakeConstraint_H__
platforms/reference/src/ReferenceDynamics.cpp
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceDynamics.h"
/**---------------------------------------------------------------------------------------
ReferenceDynamics constructor
@param numberOfAtoms number of atoms
@param deltaT delta t for dynamics
@param temperature temperature
--------------------------------------------------------------------------------------- */
ReferenceDynamics
::
ReferenceDynamics
(
int
numberOfAtoms
,
RealOpenMM
deltaT
,
RealOpenMM
temperature
)
:
_numberOfAtoms
(
numberOfAtoms
),
_deltaT
(
deltaT
),
_temperature
(
temperature
)
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceDynamics::ReferenceDynamics";
static
const
RealOpenMM
one
=
1.0
;
// ---------------------------------------------------------------------------------------
_timeStep
=
0
;
_randomNumberSeed
=
one
;
_twoDTempArrays
=
0
;
_twoDTempArrays
=
NULL
;
_oneDTempArrays
=
0
;
_oneDTempArrays
=
NULL
;
_ownReferenceShake
=
false
;
_referenceShake
=
NULL
;
}
/**---------------------------------------------------------------------------------------
ReferenceDynamics destructor
--------------------------------------------------------------------------------------- */
ReferenceDynamics
::~
ReferenceDynamics
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceDynamics::~ReferenceDynamics";
// ---------------------------------------------------------------------------------------
_freeTwoDArrays
();
_freeOneDArrays
();
if
(
_ownReferenceShake
){
delete
_referenceShake
;
}
}
/**---------------------------------------------------------------------------------------
Free memory associated w/ 2D arrays
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
_freeTwoDArrays
(
void
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceDynamics::_freeTwoDArrays";
// ---------------------------------------------------------------------------------------
if
(
_twoDTempArrays
){
delete
[]
_twoDTempArrays
[
0
][
0
];
delete
[]
_twoDTempArrays
[
0
];
delete
[]
_twoDTempArrays
;
}
_twoDTempArrays
=
NULL
;
_numberOf2DTempArrays
=
0
;
return
ReferenceDynamics
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Free memory associated w/ 1D arrays
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
_freeOneDArrays
(
void
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceDynamics::_freeOneDArrays";
// ---------------------------------------------------------------------------------------
if
(
_oneDTempArrays
){
delete
[]
_oneDTempArrays
[
0
];
delete
[]
_oneDTempArrays
;
}
_oneDTempArrays
=
NULL
;
_numberOf1DTempArrays
=
0
;
return
ReferenceDynamics
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Allocate memory associated w/ 2D arrays
@param dimension1 first dimension
@param dimension2 second dimension
@param numberOfArrays number of arrays to allocate
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
allocate2DArrays
(
int
dimension1
,
int
dimension2
,
int
numberOfArrays
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceDynamics::allocate2DArrays";
// ---------------------------------------------------------------------------------------
_freeTwoDArrays
();
_numberOf2DTempArrays
=
numberOfArrays
;
_twoDTempArrays
=
new
RealOpenMM
**
[
_numberOf2DTempArrays
];
RealOpenMM
**
totalArray
=
new
RealOpenMM
*
[
dimension1
*
numberOfArrays
];
RealOpenMM
*
totalBlock
=
new
RealOpenMM
[
dimension1
*
dimension2
*
numberOfArrays
];
memset
(
totalBlock
,
0
,
sizeof
(
RealOpenMM
)
*
dimension1
*
dimension2
*
numberOfArrays
);
for
(
int
ii
=
0
;
ii
<
_numberOf2DTempArrays
;
ii
++
){
_twoDTempArrays
[
ii
]
=
totalArray
;
totalArray
+=
dimension1
;
for
(
int
jj
=
0
;
jj
<
dimension1
;
jj
++
){
_twoDTempArrays
[
ii
][
jj
]
=
totalBlock
;
totalBlock
+=
dimension2
;
}
}
return
ReferenceDynamics
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Get array at specified index
@param index array index
@return array or NULL if index invalid or arrays not allocated
--------------------------------------------------------------------------------------- */
RealOpenMM
**
ReferenceDynamics
::
get2DArrayAtIndex
(
int
index
)
const
{
// ---------------------------------------------------------------------------------------
static
const
char
*
methodName
=
"
\n
ReferenceDynamics::get2DArrayAtIndex"
;
// ---------------------------------------------------------------------------------------
if
(
index
<
0
||
index
>=
_numberOf2DTempArrays
){
std
::
stringstream
message
;
message
<<
methodName
;
message
<<
" requested 2d array at index="
<<
index
<<
" is unavailable."
;
SimTKOpenMMLog
::
printError
(
message
);
return
NULL
;
}
return
_twoDTempArrays
[
index
];
}
/**---------------------------------------------------------------------------------------
Allocate memory associated w/ 1D arrays
@param dimension1 dimension
@param numberOfArrays number of arrays to allocate
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
allocate1DArrays
(
int
dimension
,
int
numberOfArrays
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceDynamics::allocate1DArrays";
// ---------------------------------------------------------------------------------------
_freeOneDArrays
();
_numberOf1DTempArrays
=
numberOfArrays
;
_oneDTempArrays
=
new
RealOpenMM
*
[
_numberOf1DTempArrays
];
RealOpenMM
*
totalArray
=
new
RealOpenMM
[
dimension
*
numberOfArrays
];
memset
(
totalArray
,
0
,
sizeof
(
RealOpenMM
)
*
dimension
*
numberOfArrays
);
for
(
int
ii
=
0
;
ii
<
_numberOf1DTempArrays
;
ii
++
){
_oneDTempArrays
[
ii
]
=
totalArray
;
totalArray
+=
dimension
;
}
return
ReferenceDynamics
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Get array at specified index
@param index array index
@return array or NULL if index invalid or arrays not allocated
--------------------------------------------------------------------------------------- */
RealOpenMM
*
ReferenceDynamics
::
get1DArrayAtIndex
(
int
index
)
const
{
// ---------------------------------------------------------------------------------------
static
const
char
*
methodName
=
"
\n
ReferenceDynamics::get1DArrayAtIndex"
;
// ---------------------------------------------------------------------------------------
if
(
index
<
0
||
index
>=
_numberOf1DTempArrays
){
std
::
stringstream
message
;
message
<<
methodName
;
message
<<
" requested 1d array at index="
<<
index
<<
" is unavailable."
;
SimTKOpenMMLog
::
printError
(
message
);
return
NULL
;
}
return
_oneDTempArrays
[
index
];
}
/**---------------------------------------------------------------------------------------
Get number of atoms
@return number of atoms
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
getNumberOfAtoms
(
void
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceDynamics::getNumberOfAtoms";
// ---------------------------------------------------------------------------------------
return
_numberOfAtoms
;
}
/**---------------------------------------------------------------------------------------
Get time step
@return time step
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
getTimeStep
(
void
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceDynamics::getTimeStep";
// ---------------------------------------------------------------------------------------
return
_timeStep
;
}
/**---------------------------------------------------------------------------------------
Increment time step
@return incremented time step
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
incrementTimeStep
(
void
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceDynamics::getTimeStep";
// ---------------------------------------------------------------------------------------
return
(
++
_timeStep
);
}
/**---------------------------------------------------------------------------------------
Get delta t
@return deltaT
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceDynamics
::
getDeltaT
(
void
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceDynamics::getDeltaT";
// ---------------------------------------------------------------------------------------
return
_deltaT
;
}
/**---------------------------------------------------------------------------------------
Get temperature
@return temperature
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceDynamics
::
getTemperature
(
void
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceDynamics::getTemperature";
// ---------------------------------------------------------------------------------------
return
_temperature
;
}
/**---------------------------------------------------------------------------------------
Get normally distributed random number
@return random value
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceDynamics
::
getNormallyDistributedRandomNumber
(
void
){
// ---------------------------------------------------------------------------------------
static
const
char
*
methodName
=
"
\n
ReferenceDynamics::getNormallyDistributedRandomNumber"
;
static
const
RealOpenMM
randomValue
=
(
RealOpenMM
)
0.1
;
static
int
printOnce
=
0
;
// ---------------------------------------------------------------------------------------
// for now just using fixed random value to allow for testing
if
(
!
printOnce
){
std
::
stringstream
message
;
message
<<
methodName
;
message
<<
" random value fixed at value="
<<
randomValue
;
SimTKOpenMMLog
::
printMessage
(
message
);
printOnce
++
;
}
return
randomValue
;
}
/**---------------------------------------------------------------------------------------
Get random number seed
@return random number seed
--------------------------------------------------------------------------------------- */
RealOpenMM
ReferenceDynamics
::
getRandomNumberSeed
(
void
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceDynamics::getRandomNumberSeed";
// ---------------------------------------------------------------------------------------
return
_randomNumberSeed
;
}
/**---------------------------------------------------------------------------------------
Set random number seed
@param seed new seed value
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
setRandomNumberSeed
(
RealOpenMM
seed
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceDynamics::setRandomNumberSeed";
// ---------------------------------------------------------------------------------------
_randomNumberSeed
=
seed
;
return
ReferenceDynamics
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Get ReferenceShake
@return referenceShake object
--------------------------------------------------------------------------------------- */
ReferenceShakeAlgorithm
*
ReferenceDynamics
::
getReferenceShakeAlgorithm
(
void
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceDynamics::getReferenceShake";
// ---------------------------------------------------------------------------------------
return
_referenceShake
;
}
/**---------------------------------------------------------------------------------------
Set ReferenceShake
@param referenceShake referenceShake object
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
setReferenceShakeAlgorithm
(
ReferenceShakeAlgorithm
*
referenceShake
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceDynamics::setReferenceShake";
// ---------------------------------------------------------------------------------------
// delete if own
if
(
_referenceShake
&&
_ownReferenceShake
){
delete
_referenceShake
;
}
_referenceShake
=
referenceShake
;
_ownReferenceShake
=
0
;
return
ReferenceDynamics
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Update -- driver routine for performing stochastic dynamics update of coordinates
and velocities
@param numberOfAtoms number of atoms
@param atomCoordinates atom coordinates
@param velocities velocities
@param forces forces
@param masses atom masses
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
update
(
int
numberOfAtoms
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
velocities
,
RealOpenMM
**
forces
,
RealOpenMM
*
masses
){
// ---------------------------------------------------------------------------------------
static
const
char
*
methodName
=
"
\n
ReferenceDynamics::update"
;
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
static
int
debug
=
0
;
// ---------------------------------------------------------------------------------------
return
ReferenceDynamics
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Remove total linear momentum
@param numberOfAtoms number of atoms
@param masses masses
@param velocities velocities
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
removeTotalLinearMomentum
(
int
numberOfAtoms
,
RealOpenMM
*
masses
,
RealOpenMM
**
velocities
)
const
{
// ---------------------------------------------------------------------------------------
static
const
char
*
methodName
=
"
\n
ReferenceDynamics::removeTotalLinearMomentum"
;
static
const
int
debug
=
1
;
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
// ---------------------------------------------------------------------------------------
RealOpenMM
totalMass
=
zero
;
RealOpenMM
linearMomentum
[
3
]
=
{
zero
,
zero
,
zero
};
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
){
totalMass
+=
masses
[
ii
];
linearMomentum
[
0
]
+=
masses
[
ii
]
*
velocities
[
ii
][
0
];
linearMomentum
[
1
]
+=
masses
[
ii
]
*
velocities
[
ii
][
1
];
linearMomentum
[
2
]
+=
masses
[
ii
]
*
velocities
[
ii
][
2
];
/*
if( debug ){
std::stringstream message;
message << ii << " TotalM=" << totalMass << " m=" << masses[ii] << " linearMomentum [";
SimTKOpenMMUtilities::formatRealStringStream( message, linearMomentum, 3, one );
message << "] [";
SimTKOpenMMUtilities::formatRealStringStream( message, velocities[ii], 3, one );
message << "]\n";
SimTKOpenMMLog::printMessage( message );
}
*/
}
if
(
totalMass
>
zero
){
RealOpenMM
totalMassI
=
one
/
totalMass
;
/*
if( debug ){
std::stringstream message;
message << " Pre scale linearMomentum [";
SimTKOpenMMUtilities::formatRealStringStream( message, linearMomentum, 3, one );
message << "]\n";
SimTKOpenMMLog::printMessage( message );
}
*/
linearMomentum
[
0
]
*=
totalMassI
;
linearMomentum
[
1
]
*=
totalMassI
;
linearMomentum
[
2
]
*=
totalMassI
;
/*
if( debug ){
std::stringstream message;
message << " Pre sub linearMomentum [";
SimTKOpenMMUtilities::formatRealStringStream( message, linearMomentum, 3, one );
message << "]\n";
SimTKOpenMMLog::printMessage( message );
}
*/
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
){
velocities
[
ii
][
0
]
-=
linearMomentum
[
0
];
velocities
[
ii
][
1
]
-=
linearMomentum
[
1
];
velocities
[
ii
][
2
]
-=
linearMomentum
[
2
];
}
// debug
if
(
debug
){
RealOpenMM
tempV
[
3
];
std
::
stringstream
message
;
int
maxPrint
=
5
;
message
<<
methodName
;
message
<<
" TotalM="
<<
totalMass
<<
" linearMomentum: ["
;
SimTKOpenMMUtilities
::
formatRealStringStream
(
message
,
linearMomentum
,
3
,
one
);
message
<<
"]
\n
Sample v:
\n
"
;
for
(
int
ii
=
0
;
ii
<
maxPrint
;
ii
++
){
tempV
[
0
]
=
velocities
[
ii
][
0
]
+
linearMomentum
[
0
];
tempV
[
1
]
=
velocities
[
ii
][
1
]
+
linearMomentum
[
1
];
tempV
[
2
]
=
velocities
[
ii
][
2
]
+
linearMomentum
[
2
];
message
<<
"OldV[ "
;
SimTKOpenMMUtilities
::
formatRealStringStream
(
message
,
tempV
,
3
,
one
);
message
<<
"] NewV[ "
;
SimTKOpenMMUtilities
::
formatRealStringStream
(
message
,
velocities
[
ii
],
3
,
one
);
message
<<
"]"
<<
std
::
endl
;
}
SimTKOpenMMLog
::
printMessage
(
message
);
}
}
return
ReferenceDynamics
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Print parameters
@param message message
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
printParameters
(
std
::
stringstream
&
message
)
const
{
// ---------------------------------------------------------------------------------------
static
const
char
*
methodName
=
"
\n
ReferenceDynamics::printParameters"
;
// ---------------------------------------------------------------------------------------
message
<<
"atoms="
<<
getNumberOfAtoms
()
<<
" "
;
message
<<
"delta_t="
<<
getDeltaT
()
<<
" "
;
message
<<
"temperature="
<<
getTemperature
()
<<
" "
;
message
<<
"step="
<<
getTimeStep
()
<<
" "
;
message
<<
"seed="
<<
getRandomNumberSeed
()
<<
" "
;
message
<<
std
::
endl
;
return
ReferenceDynamics
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Write state
@param numberOfAtoms number of atoms
@param atomCoordinates atom coordinates
@param velocities velocities
@param forces forces
@param masses atom masses
@param state 0 if initial state; otherwise nonzero
@param baseFileName base file name
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
writeState
(
int
numberOfAtoms
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
velocities
,
RealOpenMM
**
forces
,
RealOpenMM
*
masses
,
int
state
,
const
std
::
string
&
baseFileName
)
const
{
// ---------------------------------------------------------------------------------------
static
const
char
*
methodName
=
"
\n
ReferenceStochasticDynamics::writeState"
;
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
static
const
int
threeI
=
3
;
// ---------------------------------------------------------------------------------------
std
::
stringstream
stateFileName
;
stateFileName
<<
baseFileName
;
stateFileName
<<
"_Step"
<<
getTimeStep
();
// stateFileName << "_State" << state;
stateFileName
<<
".txt"
;
// ---------------------------------------------------------------------------------------
// open file -- return if unsuccessful
FILE
*
stateFile
=
NULL
;
#ifdef WIN32
fopen_s
(
&
stateFile
,
stateFileName
.
str
().
c_str
(),
"w"
);
#else
stateFile
=
fopen
(
stateFileName
.
str
().
c_str
(),
"w"
);
#endif
// ---------------------------------------------------------------------------------------
// diagnostics
if
(
stateFile
!=
NULL
){
std
::
stringstream
message
;
message
<<
methodName
;
message
<<
" Opened file=<"
<<
stateFileName
.
str
()
<<
">.
\n
"
;
SimTKOpenMMLog
::
printMessage
(
message
);
}
else
{
std
::
stringstream
message
;
message
<<
methodName
;
message
<<
" could not open file=<"
<<
stateFileName
.
str
()
<<
"> -- abort output.
\n
"
;
SimTKOpenMMLog
::
printMessage
(
message
);
return
ReferenceDynamics
::
ErrorReturn
;
}
// ---------------------------------------------------------------------------------------
StringVector
scalarNameI
;
IntVector
scalarI
;
StringVector
scalarNameR
;
RealOpenMMVector
scalarR
;
StringVector
scalarNameR1
;
RealOpenMMPtrVector
scalarR1
;
StringVector
scalarNameR2
;
RealOpenMMPtrPtrVector
scalarR2
;
scalarI
.
push_back
(
getNumberOfAtoms
()
);
scalarNameI
.
push_back
(
"Atoms"
);
scalarI
.
push_back
(
getTimeStep
()
);
scalarNameI
.
push_back
(
"Timestep"
);
scalarR
.
push_back
(
getDeltaT
()
);
scalarNameR
.
push_back
(
"delta_t"
);
scalarR
.
push_back
(
getRandomNumberSeed
()
);
scalarNameR
.
push_back
(
"seed"
);
scalarR
.
push_back
(
getTemperature
()
);
scalarNameR
.
push_back
(
"T"
);
if
(
masses
){
scalarR1
.
push_back
(
masses
);
scalarNameR1
.
push_back
(
"mass"
);
}
if
(
atomCoordinates
){
scalarR2
.
push_back
(
atomCoordinates
);
scalarNameR2
.
push_back
(
"coord"
);
}
if
(
velocities
){
scalarR2
.
push_back
(
velocities
);
scalarNameR2
.
push_back
(
"velocities"
);
}
if
(
forces
){
scalarR2
.
push_back
(
forces
);
scalarNameR2
.
push_back
(
"forces"
);
}
writeStateToFile
(
stateFile
,
scalarNameI
,
scalarI
,
scalarNameR
,
scalarR
,
getNumberOfAtoms
(),
scalarNameR1
,
scalarR1
,
threeI
,
scalarNameR2
,
scalarR2
);
(
void
)
fclose
(
stateFile
);
return
ReferenceDynamics
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Write state
@param stateFile file to write to
@param scalarNameI vector of scalar names for ints
@param scalarI vector of scalar ints
@param scalarNameR vector of scalar names for real
@param scalarR vector of scalar reals
@param dimension1 size of first dimension for 1D & 2D real arrays
@param scalarNameR1 vector of names for 1D real arrays
@param scalarR1 vector of 1D real arrays
@param dimension2 size of second dimension for 2D real arrays
@param scalarNameR2 vector of names for 2D real arrays
@param scalarR2 vector of 2D real arrays
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceDynamics
::
writeStateToFile
(
FILE
*
stateFile
,
StringVector
&
scalarNameI
,
IntVector
&
scalarI
,
StringVector
&
scalarNameR
,
RealOpenMMVector
&
scalarR
,
int
dimension1
,
StringVector
&
scalarNameR1
,
RealOpenMMPtrVector
&
scalarR1
,
int
dimension2
,
StringVector
&
scalarNameR2
,
RealOpenMMPtrPtrVector
&
scalarR2
)
const
{
// ---------------------------------------------------------------------------------------
static
const
char
*
methodName
=
"
\n
ReferenceDynamics::writeState"
;
// ---------------------------------------------------------------------------------------
// validate vector sizes
std
::
stringstream
message
;
message
<<
methodName
<<
std
::
endl
;
int
errors
=
0
;
if
(
scalarNameI
.
size
()
!=
scalarI
.
size
()
){
message
<<
" int name size="
<<
scalarNameI
.
size
()
<<
" != "
<<
" int vector size="
<<
scalarI
.
size
()
<<
std
::
endl
;
errors
++
;
}
if
(
scalarNameR
.
size
()
!=
scalarR
.
size
()
){
message
<<
" real name size="
<<
scalarNameR
.
size
()
<<
" != "
<<
" real vector size="
<<
scalarR
.
size
()
<<
std
::
endl
;
errors
++
;
}
if
(
scalarNameR1
.
size
()
!=
scalarR1
.
size
()
){
message
<<
" real* name size="
<<
scalarNameR1
.
size
()
<<
" != "
<<
" real* vector size="
<<
scalarR1
.
size
()
<<
std
::
endl
;
errors
++
;
}
if
(
scalarNameR2
.
size
()
!=
scalarR2
.
size
()
){
message
<<
" real** name size="
<<
scalarNameR2
.
size
()
<<
" != "
<<
" real** vector size="
<<
scalarR2
.
size
()
<<
std
::
endl
;
errors
++
;
}
if
(
errors
){
SimTKOpenMMLog
::
printError
(
message
);
return
ReferenceDynamics
::
ErrorReturn
;
}
// ---------------------------------------------------------------------------------------
// array header
(
void
)
fprintf
(
stateFile
,
"# "
);
for
(
unsigned
int
ii
=
0
;
ii
<
scalarNameR1
.
size
();
ii
++
){
(
void
)
fprintf
(
stateFile
,
" %s"
,
scalarNameR1
[
ii
].
c_str
()
);
}
for
(
unsigned
int
ii
=
0
;
ii
<
scalarNameR2
.
size
();
ii
++
){
(
void
)
fprintf
(
stateFile
,
" %s"
,
scalarNameR2
[
ii
].
c_str
()
);
}
(
void
)
fprintf
(
stateFile
,
"
\n
"
);
// int scalars
for
(
unsigned
int
ii
=
0
;
ii
<
scalarI
.
size
();
ii
++
){
(
void
)
fprintf
(
stateFile
,
"%6d # %s
\n
"
,
scalarI
[
ii
],
scalarNameI
[
ii
].
c_str
()
);
}
// real scalars
for
(
unsigned
int
ii
=
0
;
ii
<
scalarR
.
size
();
ii
++
){
(
void
)
fprintf
(
stateFile
,
"%14.6e # %s
\n
"
,
scalarR
[
ii
],
scalarNameR
[
ii
].
c_str
()
);
}
// arrays
int
maxPerLine
=
3
;
for
(
unsigned
int
ii
=
0
;
ii
<
(
unsigned
int
)
dimension1
;
ii
++
){
(
void
)
fprintf
(
stateFile
,
"%5d "
,
ii
);
for
(
RealOpenMMPtrVectorI
jj
=
scalarR1
.
begin
();
jj
!=
scalarR1
.
end
();
jj
++
){
(
void
)
fprintf
(
stateFile
,
"%14.6e "
,
(
*
jj
)[
ii
]
);
}
int
r2Count
=
0
;
for
(
RealOpenMMPtrPtrVectorI
jj
=
scalarR2
.
begin
();
jj
!=
scalarR2
.
end
();
jj
++
){
RealOpenMM
**
array
=
*
jj
;
for
(
int
kk
=
0
;
kk
<
dimension2
;
kk
++
){
(
void
)
fprintf
(
stateFile
,
"%14.6e "
,
array
[
ii
][
kk
]
);
}
(
void
)
fprintf
(
stateFile
,
" "
);
r2Count
++
;
if
(
r2Count
==
maxPerLine
&&
(
(
r2Count
%
(
int
)
(
scalarR2
.
size
()
-
1
))
>
2
)
){
(
void
)
fprintf
(
stateFile
,
"
\n
"
);
r2Count
=
0
;
}
}
(
void
)
fprintf
(
stateFile
,
"
\n
"
);
}
return
ReferenceDynamics
::
DefaultReturn
;
}
platforms/reference/src/ReferenceDynamics.h
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceDynamics_H__
#define __ReferenceDynamics_H__
#include "ReferenceShakeAlgorithm.h"
// ---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Abstract class for dynamics
Main method (virtual) is update()
'Random' numbers are currently fixed to allow testing
--------------------------------------------------------------------------------------- */
class
ReferenceDynamics
{
public:
/**---------------------------------------------------------------------------------------
Fixed static variables
--------------------------------------------------------------------------------------- */
static
const
int
DefaultReturn
=
0
;
static
const
int
ErrorReturn
=
-
1
;
private:
int
_numberOfAtoms
;
int
_timeStep
;
RealOpenMM
_deltaT
;
RealOpenMM
_temperature
;
RealOpenMM
_randomNumberSeed
;
int
_numberOf2DTempArrays
;
RealOpenMM
***
_twoDTempArrays
;
int
_numberOf1DTempArrays
;
RealOpenMM
**
_oneDTempArrays
;
int
_ownReferenceShake
;
ReferenceShakeAlgorithm
*
_referenceShake
;
/**---------------------------------------------------------------------------------------
Free memory associated w/ 2D arrays
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
_freeTwoDArrays
(
void
);
/**---------------------------------------------------------------------------------------
Free memory associated w/ 1D arrays
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
_freeOneDArrays
(
void
);
protected:
/**---------------------------------------------------------------------------------------
Allocate memory associated w/ 2D arrays
@param dimension1 first dimension
@param dimension2 second dimension
@param numberOfArrays number of arrays to allocate
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
allocate2DArrays
(
int
dimension1
,
int
dimension2
,
int
numberOfArrays
);
/**---------------------------------------------------------------------------------------
Get array at specified index
@param index array index
@return array or NULL if index invalid or arrays not allocated
--------------------------------------------------------------------------------------- */
RealOpenMM
**
get2DArrayAtIndex
(
int
index
)
const
;
/**---------------------------------------------------------------------------------------
Allocate memory associated w/ 1D arrays
@param dimension1 dimension
@param numberOfArrays number of arrays to allocate
@return DefaultReturn
--------------------------------------------------------------------------------------- */
int
allocate1DArrays
(
int
dimension
,
int
numberOfArrays
);
/**---------------------------------------------------------------------------------------
Get array at specified index
@param index array index
@return array or NULL if index invalid or arrays not allocated
--------------------------------------------------------------------------------------- */
RealOpenMM
*
get1DArrayAtIndex
(
int
index
)
const
;
public:
/**---------------------------------------------------------------------------------------
Constructor
@param numberOfAtoms number of atoms
@param deltaT delta t for dynamics
@param temperature temperature
--------------------------------------------------------------------------------------- */
ReferenceDynamics
(
int
numberOfAtoms
,
RealOpenMM
_deltaT
,
RealOpenMM
temperature
);
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~
ReferenceDynamics
(
);
/**---------------------------------------------------------------------------------------
Get number of atoms
@return number of atoms
--------------------------------------------------------------------------------------- */
int
getNumberOfAtoms
(
void
)
const
;
/**---------------------------------------------------------------------------------------
Get time step
@return time step
--------------------------------------------------------------------------------------- */
int
getTimeStep
(
void
)
const
;
/**---------------------------------------------------------------------------------------
Increment time step
@return incremented time step
--------------------------------------------------------------------------------------- */
int
incrementTimeStep
(
void
);
/**---------------------------------------------------------------------------------------
Get delta t
@return deltaT
--------------------------------------------------------------------------------------- */
RealOpenMM
getDeltaT
(
void
)
const
;
/**---------------------------------------------------------------------------------------
Get temperature
@return temperature
--------------------------------------------------------------------------------------- */
RealOpenMM
getTemperature
(
void
)
const
;
/**---------------------------------------------------------------------------------------
Remove total linear momentum
@param numberOfAtoms number of atoms
@param masses masses
@param velocities velocities
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
removeTotalLinearMomentum
(
int
numberOfAtoms
,
RealOpenMM
*
masses
,
RealOpenMM
**
velocities
)
const
;
/**---------------------------------------------------------------------------------------
Print parameters
@param message message
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
printParameters
(
std
::
stringstream
&
message
)
const
;
/**---------------------------------------------------------------------------------------
Update
@param numberOfAtoms number of atoms
@param atomCoordinates atom coordinates
@param velocities velocities
@param forces forces
@param masses atom masses
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
virtual
int
update
(
int
numberOfAtoms
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
velocities
,
RealOpenMM
**
forces
,
RealOpenMM
*
masses
);
/**---------------------------------------------------------------------------------------
Get normally distributed random number
@return random value
--------------------------------------------------------------------------------------- */
RealOpenMM
getNormallyDistributedRandomNumber
(
void
);
/**---------------------------------------------------------------------------------------
Get random number seed
@return random number seed
--------------------------------------------------------------------------------------- */
RealOpenMM
getRandomNumberSeed
(
void
)
const
;
/**---------------------------------------------------------------------------------------
Set random number seed
@param seed new seed value
@return DefaultReturn
--------------------------------------------------------------------------------------- */
int
setRandomNumberSeed
(
RealOpenMM
seed
);
/**---------------------------------------------------------------------------------------
Get ReferenceShake
@return referenceShake object
--------------------------------------------------------------------------------------- */
ReferenceShakeAlgorithm
*
getReferenceShakeAlgorithm
(
void
)
const
;
/**---------------------------------------------------------------------------------------
Set ReferenceShake
@param referenceShake referenceShake object
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
setReferenceShakeAlgorithm
(
ReferenceShakeAlgorithm
*
referenceShake
);
/**---------------------------------------------------------------------------------------
Write state
@param numberOfAtoms number of atoms
@param atomCoordinates atom coordinates
@param velocities velocities
@param forces forces
@param masses atom masses
@param state 0 if initial state; otherwise nonzero
@param baseFileName base file name
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
writeState
(
int
numberOfAtoms
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
velocities
,
RealOpenMM
**
forces
,
RealOpenMM
*
masses
,
int
state
,
const
std
::
string
&
baseFileName
)
const
;
/**---------------------------------------------------------------------------------------
Write state
@param stateFile file to write to
@param scalarNameI vector of scalar names for ints
@param scalarI vector of scalar ints
@param scalarNameR vector of scalar names for real
@param scalarR vector of scalar reals
@param dimension1 size of first dimension for 1D & 2D real arrays
@param scalarNameR1 vector of names for 1D real arrays
@param scalarR1 vector of 1D real arrays
@param dimension2 size of second dimension for 2D real arrays
@param scalarNameR2 vector of names for 2D real arrays
@param scalarR2 vector of 2D real arrays
@return ReferenceDynamics::DefaultReturn
--------------------------------------------------------------------------------------- */
int
writeStateToFile
(
FILE
*
stateFile
,
StringVector
&
scalarNameI
,
IntVector
&
scalarI
,
StringVector
&
scalarNameR
,
RealOpenMMVector
&
scalarR
,
int
dimension1
,
StringVector
&
scalarNameR1
,
RealOpenMMPtrVector
&
scalarR1
,
int
dimension2
,
StringVector
&
scalarNameR2
,
RealOpenMMPtrPtrVector
&
scalarR2
)
const
;
};
// ---------------------------------------------------------------------------------------
#endif // __ReferenceDynamics_H__
platforms/reference/src/ReferenceForce.cpp
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
/**---------------------------------------------------------------------------------------
ReferenceForce constructor
--------------------------------------------------------------------------------------- */
ReferenceForce
::
ReferenceForce
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceForce::ReferenceForce";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceForce destructor
--------------------------------------------------------------------------------------- */
ReferenceForce
::~
ReferenceForce
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceForce::~ReferenceForce";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Get deltaR and distance and distance**2 between atomI and atomJ (static method)
deltaR: j - i
@param atomCoordinatesI atom i coordinates
@param atomCoordinatesI atom j coordinates
@param deltaR deltaX, deltaY, deltaZ, R2, R upon return
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceForce
::
getDeltaR
(
const
RealOpenMM
*
atomCoordinatesI
,
const
RealOpenMM
*
atomCoordinatesJ
,
RealOpenMM
*
deltaR
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceForce::getDeltaR";
// ---------------------------------------------------------------------------------------
deltaR
[
XIndex
]
=
atomCoordinatesJ
[
0
]
-
atomCoordinatesI
[
0
];
deltaR
[
YIndex
]
=
atomCoordinatesJ
[
1
]
-
atomCoordinatesI
[
1
];
deltaR
[
ZIndex
]
=
atomCoordinatesJ
[
2
]
-
atomCoordinatesI
[
2
];
deltaR
[
R2Index
]
=
DOT3
(
deltaR
,
deltaR
);
deltaR
[
RIndex
]
=
(
RealOpenMM
)
SQRT
(
deltaR
[
R2Index
]
);
return
ReferenceForce
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Get deltaR between atomI and atomJ (static method); deltaR: j - i
@param atomCoordinatesI atom i coordinates
@param atomCoordinatesI atom j coordinates
@param deltaR deltaX, deltaY, deltaZ upon return
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceForce
::
getDeltaROnly
(
const
RealOpenMM
*
atomCoordinatesI
,
const
RealOpenMM
*
atomCoordinatesJ
,
RealOpenMM
*
deltaR
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nReferenceForce::getDeltaR";
// ---------------------------------------------------------------------------------------
deltaR
[
XIndex
]
=
atomCoordinatesJ
[
0
]
-
atomCoordinatesI
[
0
];
deltaR
[
YIndex
]
=
atomCoordinatesJ
[
1
]
-
atomCoordinatesI
[
1
];
deltaR
[
ZIndex
]
=
atomCoordinatesJ
[
2
]
-
atomCoordinatesI
[
2
];
return
ReferenceForce
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Write coordinates, energies and forces (Simbios)
@param numberOfAtoms number of atoms
@param atomsPerBond atoms/bond
@param atomCoordinates atomic coordinates
@param forces forces
@param energies energies (optional)
@param resultsFileName output file name
@param lengthConversion length conversion (optional defaults to 1)
@param energyConversion energy conversion (optional defaults to 1)
@param forceConversion force conversion (optional defaults to 1)
@return ReferenceForce::DefaultReturn unless
file cannot be opened
in which case return ReferenceForce::ErrorReturn
--------------------------------------------------------------------------------------- */
int
ReferenceForce
::
writeForces
(
int
numberOfAtoms
,
int
atomsPerBond
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
forces
,
RealOpenMM
*
energies
,
const
std
::
string
&
resultsFileName
,
RealOpenMM
lengthConversion
=
1.0
,
RealOpenMM
forceConversion
=
1.0
,
RealOpenMM
energyConversion
=
1.0
){
// ---------------------------------------------------------------------------------------
static
const
char
*
methodName
=
"
\n
ReferenceForce::writeBornEnergyForces"
;
static
const
RealOpenMM
zero
=
0.0
;
// ---------------------------------------------------------------------------------------
// open file -- return if unsuccessful
FILE
*
resultsFile
=
NULL
;
#ifdef WIN32
fopen_s
(
&
resultsFile
,
resultsFileName
.
c_str
(),
"w"
);
#else
resultsFile
=
fopen
(
resultsFileName
.
c_str
(),
"w"
);
#endif
// ---------------------------------------------------------------------------------------
// diagnostics
std
::
stringstream
message
;
message
<<
methodName
;
if
(
resultsFile
!=
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
ReferenceForce
::
ErrorReturn
;
}
// total energy and normalize by number of atoms/bond
RealOpenMM
totalEnergy
=
zero
;
if
(
energies
){
for
(
int
ii
=
1
;
ii
<
numberOfAtoms
;
ii
++
){
totalEnergy
+=
energies
[
ii
];
}
if
(
atomsPerBond
>
0
){
totalEnergy
/=
(
RealOpenMM
)
atomsPerBond
;
}
}
// header
(
void
)
fprintf
(
resultsFile
,
"# %d atoms E=%.7e format: coords(3) forces(3) energies
\n
"
,
numberOfAtoms
,
totalEnergy
);
// output
if
(
forces
!=
NULL
&&
atomCoordinates
!=
NULL
){
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
){
(
void
)
fprintf
(
resultsFile
,
"%5d %15.7e %15.7e %15.7e %15.7e %15.7e %15.7e"
,
ii
,
lengthConversion
*
atomCoordinates
[
ii
][
0
],
lengthConversion
*
atomCoordinates
[
ii
][
1
],
lengthConversion
*
atomCoordinates
[
ii
][
2
],
forceConversion
*
forces
[
ii
][
0
],
forceConversion
*
forces
[
ii
][
1
],
forceConversion
*
forces
[
ii
][
2
]
);
if
(
energies
!=
NULL
){
(
void
)
fprintf
(
resultsFile
,
" %15.7e"
,
energyConversion
*
energies
[
ii
]
);
}
(
void
)
fprintf
(
resultsFile
,
"
\n
"
);
}
}
(
void
)
fclose
(
resultsFile
);
return
ReferenceForce
::
DefaultReturn
;
}
platforms/reference/src/ReferenceForce.h
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceForce_H__
#define __ReferenceForce_H__
// ---------------------------------------------------------------------------------------
class
ReferenceForce
{
private:
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferenceForce
(
);
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~
ReferenceForce
(
);
/**---------------------------------------------------------------------------------------
Static variables
--------------------------------------------------------------------------------------- */
static
const
int
XIndex
=
0
;
static
const
int
YIndex
=
1
;
static
const
int
ZIndex
=
2
;
static
const
int
R2Index
=
3
;
static
const
int
RIndex
=
4
;
static
const
int
LastDeltaRIndex
=
5
;
static
const
int
DeltaRMaxIndex
=
5
;
static
const
int
DefaultReturn
=
0
;
static
const
int
ErrorReturn
=
-
1
;
/**---------------------------------------------------------------------------------------
Get deltaR and distance and distance**2 between atomI and atomJ (static method)
deltaR: j - i
@param atomCoordinatesI atom i coordinates
@param atomCoordinatesI atom j coordinates
@param deltaR deltaX, deltaY, deltaZ, R2, R upon return
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
static
int
getDeltaR
(
const
RealOpenMM
*
atomCoordinatesI
,
const
RealOpenMM
*
atomCoordinatesJ
,
RealOpenMM
*
deltaR
);
/**---------------------------------------------------------------------------------------
Get deltaR between atomI and atomJ (static method): deltaR: j - i
@param atomCoordinatesI atom i coordinates
@param atomCoordinatesI atom j coordinates
@param deltaR deltaX, deltaY, deltaZ upon return
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
static
int
getDeltaROnly
(
const
RealOpenMM
*
atomCoordinatesI
,
const
RealOpenMM
*
atomCoordinatesJ
,
RealOpenMM
*
deltaR
);
/**---------------------------------------------------------------------------------------
Write coordinates, energies and forces (Simbios)
@param numberOfAtoms number of atoms
@param atomsPerBond atoms/bond (used to normalize total energy)
@param atomCoordinates atomic coordinates
@param forces forces
@param energies energies (optional)
@param resultsFileName output file name
@param lengthConversion length conversion (optional defaults to 1)
@param forceConversion force conversion (optional defaults to 1)
@param energyConversion energy conversion (optional defaults to 1)
@return ReferenceForce::DefaultReturn unless
file cannot be opened
in which case return ReferenceForce::ErrorReturn
--------------------------------------------------------------------------------------- */
static
int
writeForces
(
int
numberOfAtoms
,
int
atomsPerBond
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
forces
,
RealOpenMM
*
energies
,
const
std
::
string
&
resultsFileName
,
RealOpenMM
lengthConversion
,
RealOpenMM
forceConversion
,
RealOpenMM
energyConversion
);
};
// ---------------------------------------------------------------------------------------
#endif // __ReferenceForce_H__
platforms/reference/src/ReferenceHarmonicBondIxn.cpp
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceHarmonicBondIxn.h"
#include "ReferenceForce.h"
/**---------------------------------------------------------------------------------------
ReferenceHarmonicBondIxn constructor
--------------------------------------------------------------------------------------- */
ReferenceHarmonicBondIxn
::
ReferenceHarmonicBondIxn
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceHarmonicBondIxn::ReferenceHarmonicBondIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceHarmonicBondIxn destructor
--------------------------------------------------------------------------------------- */
ReferenceHarmonicBondIxn
::~
ReferenceHarmonicBondIxn
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceHarmonicBondIxn::~ReferenceHarmonicBondIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Calculate Harmonic Bond Ixn
@param atomIndices atom indices of atom participating in bond
@param atomCoordinates atom coordinates
@param parameters parameters: parameters[0] = ideal bond length
parameters[1] = bond k
@param forces force array (forces added to input values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn;
--------------------------------------------------------------------------------------- */
int
ReferenceHarmonicBondIxn
::
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
energiesByAtom
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceHarmonicBondIxn::calculateBondIxn";
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"
\n
ReferenceHarmonicBondIxn::calculateBondIxn"
;
static
const
int
twoI
=
2
;
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
two
=
2.0
;
static
const
RealOpenMM
half
=
0.5
;
RealOpenMM
deltaR
[
ReferenceForce
::
LastDeltaRIndex
];
// ---------------------------------------------------------------------------------------
// get deltaR, R2, and R between 2 atoms
int
atomAIndex
=
atomIndices
[
0
];
int
atomBIndex
=
atomIndices
[
1
];
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
);
// deltaIdeal = r - r_0
RealOpenMM
deltaIdeal
=
deltaR
[
ReferenceForce
::
RIndex
]
-
parameters
[
0
];
RealOpenMM
deltaIdeal2
=
deltaIdeal
*
deltaIdeal
;
RealOpenMM
dEdR
=
parameters
[
1
]
*
deltaIdeal
;
// chain rule
dEdR
=
deltaR
[
ReferenceForce
::
RIndex
]
>
zero
?
(
dEdR
/
deltaR
[
ReferenceForce
::
RIndex
])
:
zero
;
forces
[
atomAIndex
][
0
]
+=
dEdR
*
deltaR
[
ReferenceForce
::
XIndex
];
forces
[
atomAIndex
][
1
]
+=
dEdR
*
deltaR
[
ReferenceForce
::
YIndex
];
forces
[
atomAIndex
][
2
]
+=
dEdR
*
deltaR
[
ReferenceForce
::
ZIndex
];
forces
[
atomBIndex
][
0
]
-=
dEdR
*
deltaR
[
ReferenceForce
::
XIndex
];
forces
[
atomBIndex
][
1
]
-=
dEdR
*
deltaR
[
ReferenceForce
::
YIndex
];
forces
[
atomBIndex
][
2
]
-=
dEdR
*
deltaR
[
ReferenceForce
::
ZIndex
];
RealOpenMM
energy
=
half
*
parameters
[
1
]
*
deltaIdeal2
;
updateEnergy
(
energy
,
energiesByBond
,
twoI
,
atomIndices
,
energiesByAtom
);
return
ReferenceForce
::
DefaultReturn
;
}
platforms/reference/src/ReferenceHarmonicBondIxn.h
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceHarmonicBondIxn_H__
#define __ReferenceHarmonicBondIxn_H__
#include "ReferenceBondIxn.h"
// ---------------------------------------------------------------------------------------
class
ReferenceHarmonicBondIxn
:
public
ReferenceBondIxn
{
private:
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferenceHarmonicBondIxn
(
);
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~
ReferenceHarmonicBondIxn
(
);
/**---------------------------------------------------------------------------------------
Calculate Harmonic Bond Ixn
@param atomIndices two bond indices
@param atomCoordinates atom coordinates
@param parameters parameters: parameters[0] = ideal bond length
parameters[1] = bond k
@param forces force array (forces added)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
--------------------------------------------------------------------------------------- */
int
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
energiesByAtom
)
const
;
};
// ---------------------------------------------------------------------------------------
#endif // _ReferenceHarmonicBondIxn___
platforms/reference/src/ReferenceLJ14.cpp
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceLJ14.h"
#include "ReferenceForce.h"
/**---------------------------------------------------------------------------------------
ReferenceLJ14 constructor
--------------------------------------------------------------------------------------- */
ReferenceLJ14
::
ReferenceLJ14
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJ14::ReferenceLJ14";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceLJ14 destructor
--------------------------------------------------------------------------------------- */
ReferenceLJ14
::~
ReferenceLJ14
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJ14::~ReferenceLJ14";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Calculate parameters for LJ 1-4 ixn
@param c6 c6
@param c12 c12
@param q1 q1 charge atom 1
@param q2 q2 charge atom 2
@param epsfac epsfac ????????????/
@param parameters output parameters:
parameter[0]= c6*c6/c12
parameter[1]= (c12/c6)**1/6
parameter[2]= epsfactor*q1*q2
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceLJ14
::
getDerivedParameters
(
RealOpenMM
c6
,
RealOpenMM
c12
,
RealOpenMM
q1
,
RealOpenMM
q2
,
RealOpenMM
epsfac
,
RealOpenMM
*
parameters
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJ14::getDerivedParameters";
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
static
const
RealOpenMM
six
=
6.0
;
static
const
RealOpenMM
oneSixth
=
one
/
six
;
// ---------------------------------------------------------------------------------------
if
(
c12
<=
zero
){
parameters
[
0
]
=
one
;
parameters
[
1
]
=
zero
;
}
else
{
parameters
[
0
]
=
(
c6
*
c6
)
/
c12
;
parameters
[
1
]
=
POW
(
(
c12
/
c6
),
oneSixth
);
}
parameters
[
2
]
=
epsfac
*
q1
*
q2
;
return
ReferenceForce
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Calculate LJ 1-4 ixn
@param atomIndices atom indices of 4 atoms in bond
@param atomCoordinates atom coordinates
@param parameters two parameters:
parameter[0]= c6*c6/c12
parameter[1]= (c12/c6)**1/6
parameter[2]= epsfac*q1*q2
@param forces force array (forces added to current values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceLJ14
::
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
energiesByAtom
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJ14::calculateBondIxn";
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"
\n
ReferenceLJ14::calculateBondIxn"
;
// constants -- reduce Visual Studio warnings regarding conversions between float & double
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
six
=
6.0
;
static
const
RealOpenMM
twelve
=
12.0
;
static
const
RealOpenMM
oneM
=
-
1.0
;
static
const
int
threeI
=
3
;
// number of parameters
static
const
int
numberOfParameters
=
3
;
// debug flag
static
const
int
debug
=
0
;
static
const
int
LastAtomIndex
=
2
;
RealOpenMM
deltaR
[
2
][
ReferenceForce
::
LastDeltaRIndex
];
// ---------------------------------------------------------------------------------------
// get deltaR, R2, and R between 2 atoms
int
atomAIndex
=
atomIndices
[
0
];
int
atomBIndex
=
atomIndices
[
1
];
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
deltaR
[
0
]
);
RealOpenMM
inverseR
=
one
/
(
deltaR
[
0
][
ReferenceForce
::
RIndex
]);
RealOpenMM
sig2
=
inverseR
*
parameters
[
1
];
sig2
*=
sig2
;
RealOpenMM
sig6
=
sig2
*
sig2
*
sig2
;
RealOpenMM
dEdR
=
parameters
[
0
]
*
(
twelve
*
sig6
-
six
)
*
sig6
;
dEdR
+=
parameters
[
2
]
*
inverseR
;
dEdR
*=
inverseR
*
inverseR
;
// accumulate forces
for
(
int
ii
=
0
;
ii
<
3
;
ii
++
){
RealOpenMM
force
=
dEdR
*
deltaR
[
0
][
ii
];
forces
[
atomAIndex
][
ii
]
+=
force
;
forces
[
atomBIndex
][
ii
]
-=
force
;
}
RealOpenMM
energy
=
0.0
;
// accumulate energies
//updateEnergy( energy, energiesByBond, LastAtomIndex, atomIndices, energiesByAtom );
// 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
);
}
return
ReferenceForce
::
DefaultReturn
;
}
platforms/reference/src/ReferenceLJ14.h
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceLJ14_H__
#define __ReferenceLJ14_H__
#include "ReferenceBondIxn.h"
// ---------------------------------------------------------------------------------------
class
ReferenceLJ14
:
public
ReferenceBondIxn
{
private:
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferenceLJ14
(
);
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~
ReferenceLJ14
(
);
/**---------------------------------------------------------------------------------------
Calculate parameters for LJ 1-4 ixn
@param c6 c6
@param c12 c12
@param q1 q1 charge atom 1
@param q2 q2 charge atom 2
@param epsfac epsfac ????????????/
@param parameters output parameters:
parameter[0]= c6*c6/c12
parameter[1]= (c12/c6)**1/6
parameter[2]= epsfactor*q1*q2
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceLJ14
::
getDerivedParameters
(
RealOpenMM
c6
,
RealOpenMM
c12
,
RealOpenMM
q1
,
RealOpenMM
q2
,
RealOpenMM
epsfac
,
RealOpenMM
*
parameters
)
const
;
/**---------------------------------------------------------------------------------------
Calculate Ryckaert-Bellemans bond ixn
@param atomIndices atom indices of 4 atoms in bond
@param atomCoordinates atom coordinates
@param parameters six RB parameters
@param forces force array (forces added to current values)
@param energiesByBond energies by bond: energiesByBond[bondIndex]
@param energiesByAtom energies by atom: energiesByAtom[atomIndex]
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
calculateBondIxn
(
int
*
atomIndices
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
*
parameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energiesByBond
,
RealOpenMM
*
energiesByAtom
)
const
;
};
// ---------------------------------------------------------------------------------------
#endif // __ReferenceLJ14_H__
platforms/reference/src/ReferenceLJCoulombIxn.cpp
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceLJCoulombIxn.h"
#include "ReferenceForce.h"
/**---------------------------------------------------------------------------------------
ReferenceLJCoulombIxn constructor
--------------------------------------------------------------------------------------- */
ReferenceLJCoulombIxn
::
ReferenceLJCoulombIxn
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJCoulombIxn::ReferenceLJCoulombIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferenceLJCoulombIxn destructor
--------------------------------------------------------------------------------------- */
ReferenceLJCoulombIxn
::~
ReferenceLJCoulombIxn
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJCoulombIxn::~ReferenceLJCoulombIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
Calculate parameters for LJ Coulomb ixn
@param c6 c6
@param c12 c12
@param q1 q1 charge atom 1
@param epsfac epsfacSqrt ????????????/
@param parameters output parameters:
parameter[SigIndex] = sqrt(c6*c6/c12)
parameter[EpsIndex] = 0.5*( (c12/c6)**1/6 )
parameter[QIndex] = epsfactorSqrt*q1
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceLJCoulombIxn
::
getDerivedParameters
(
RealOpenMM
c6
,
RealOpenMM
c12
,
RealOpenMM
q1
,
RealOpenMM
epsfacSqrt
,
RealOpenMM
*
parameters
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJCoulombIxn::getDerivedParameters";
static
const
RealOpenMM
zero
=
0.0
;
static
const
RealOpenMM
one
=
1.0
;
static
const
RealOpenMM
six
=
6.0
;
static
const
RealOpenMM
half
=
0.5
;
static
const
RealOpenMM
oneSixth
=
one
/
six
;
static
const
RealOpenMM
oneTweleth
=
half
*
oneSixth
;
// ---------------------------------------------------------------------------------------
if
(
c12
<=
0.0
){
parameters
[
EpsIndex
]
=
zero
;
parameters
[
SigIndex
]
=
half
;
}
else
{
parameters
[
EpsIndex
]
=
c6
*
SQRT
(
one
/
c12
);
parameters
[
SigIndex
]
=
POW
(
(
c12
/
c6
),
oneSixth
);
parameters
[
SigIndex
]
*=
half
;
}
parameters
[
QIndex
]
=
epsfacSqrt
*
q1
;
return
ReferenceForce
::
DefaultReturn
;
}
/**---------------------------------------------------------------------------------------
Calculate LJ Coulomb pair ixn
@param numberOfAtoms number of atoms
@param atomCoordinates atom coordinates
@param atomParameters atom parameters atomParameters[atomIndex][paramterIndex]
@param exclusions atom exclusion indices exclusions[atomIndex][atomToExcludeIndex]
exclusions[atomIndex][0] = number of exclusions
exclusions[atomIndex][1-no.] = atom indices of atoms to excluded from
interacting w/ atom atomIndex
@param fixedParameters non atom parameters (not currently used)
@param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
ReferenceLJCoulombIxn
::
calculatePairIxn
(
int
numberOfAtoms
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
atomParameters
,
int
**
exclusions
,
RealOpenMM
*
fixedParameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energyByAtom
,
RealOpenMM
*
totalEnergy
)
const
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceLJCoulombIxn::calculatePairIxn";
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"
\n
ReferenceLJCoulombIxn::calculatePairIxn"
;
// constants -- reduce Visual Studio warnings regarding conversions between float & double
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
six
=
6.0
;
static
const
RealOpenMM
twelve
=
12.0
;
static
const
RealOpenMM
oneM
=
-
1.0
;
static
const
int
threeI
=
3
;
// debug flag
static
const
int
debug
=
-
1
;
static
const
int
LastAtomIndex
=
2
;
RealOpenMM
deltaR
[
2
][
ReferenceForce
::
LastDeltaRIndex
];
// ---------------------------------------------------------------------------------------
// allocate and initialize exclusion array
int
*
exclusionIndices
=
new
int
[
numberOfAtoms
];
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
){
exclusionIndices
[
ii
]
=
-
1
;
}
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
){
// set exclusions
for
(
int
jj
=
1
;
jj
<=
exclusions
[
ii
][
0
];
jj
++
){
exclusionIndices
[
exclusions
[
ii
][
jj
]]
=
ii
;
}
// loop over atom pairs
for
(
int
jj
=
ii
+
1
;
jj
<
numberOfAtoms
;
jj
++
){
if
(
exclusionIndices
[
jj
]
!=
ii
){
// get deltaR, R2, and R between 2 atoms
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
jj
],
atomCoordinates
[
ii
],
deltaR
[
0
]
);
RealOpenMM
inverseR
=
one
/
(
deltaR
[
0
][
ReferenceForce
::
RIndex
]);
RealOpenMM
sig
=
atomParameters
[
ii
][
SigIndex
]
+
atomParameters
[
jj
][
SigIndex
];
RealOpenMM
sig2
=
inverseR
*
sig
;
sig2
*=
sig2
;
RealOpenMM
sig6
=
sig2
*
sig2
*
sig2
;
RealOpenMM
eps
=
atomParameters
[
ii
][
EpsIndex
]
*
atomParameters
[
jj
][
EpsIndex
];
RealOpenMM
dEdR
=
eps
*
(
twelve
*
sig6
-
six
)
*
sig6
;
dEdR
+=
atomParameters
[
ii
][
QIndex
]
*
atomParameters
[
jj
][
QIndex
]
*
inverseR
;
dEdR
*=
inverseR
*
inverseR
;
// accumulate forces
for
(
int
kk
=
0
;
kk
<
3
;
kk
++
){
RealOpenMM
force
=
dEdR
*
deltaR
[
0
][
kk
];
forces
[
ii
][
kk
]
+=
force
;
forces
[
jj
][
kk
]
-=
force
;
}
RealOpenMM
energy
=
0.0
;
// accumulate energies
*
totalEnergy
+=
energy
;
if
(
energyByAtom
){
energyByAtom
[
ii
]
+=
energy
;
energyByAtom
[
jj
]
+=
energy
;
}
// debug
if
(
debug
==
ii
){
static
bool
printHeader
=
false
;
std
::
stringstream
message
;
message
<<
methodName
;
message
<<
std
::
endl
;
int
pairArray
[
2
]
=
{
ii
,
jj
};
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
kk
=
0
;
kk
<
2
;
kk
++
){
message
<<
" Atm "
<<
pairArray
[
kk
]
<<
" ["
<<
atomCoordinates
[
pairArray
[
kk
]][
0
]
<<
" "
<<
atomCoordinates
[
pairArray
[
kk
]][
1
]
<<
" "
<<
atomCoordinates
[
pairArray
[
kk
]][
2
]
<<
"] "
;
}
message
<<
std
::
endl
<<
" Delta:"
;
for
(
int
kk
=
0
;
kk
<
(
LastAtomIndex
-
1
);
kk
++
){
message
<<
" ["
;
for
(
int
jj
=
0
;
jj
<
ReferenceForce
::
LastDeltaRIndex
;
jj
++
){
message
<<
deltaR
[
kk
][
jj
]
<<
" "
;
}
message
<<
"]"
;
}
message
<<
std
::
endl
;
for
(
int
kk
=
0
;
kk
<
2
;
kk
++
){
message
<<
" p"
<<
pairArray
[
kk
]
<<
" ["
;
message
<<
atomParameters
[
pairArray
[
kk
]][
0
]
<<
" "
<<
atomParameters
[
pairArray
[
kk
]][
1
]
<<
" "
<<
atomParameters
[
pairArray
[
kk
]][
2
];
message
<<
"]"
;
}
message
<<
std
::
endl
;
message
<<
" dEdR="
<<
dEdR
;
message
<<
" E="
<<
energy
<<
" force factors: "
;
message
<<
"F=compute force; f=cumulative force"
;
message
<<
std
::
endl
<<
" "
;
message
<<
" f"
<<
ii
<<
"["
;
SimTKOpenMMUtilities
::
formatRealStringStream
(
message
,
deltaR
[
0
],
threeI
,
dEdR
);
message
<<
"]"
;
for
(
int
kk
=
0
;
kk
<
2
;
kk
++
){
message
<<
" F"
<<
pairArray
[
kk
]
<<
" ["
;
SimTKOpenMMUtilities
::
formatRealStringStream
(
message
,
forces
[
pairArray
[
kk
]],
threeI
);
message
<<
"]"
;
}
SimTKOpenMMLog
::
printMessage
(
message
);
}
}
}
}
delete
[]
exclusionIndices
;
return
ReferenceForce
::
DefaultReturn
;
}
platforms/reference/src/ReferenceLJCoulombIxn.h
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferenceLJCoulombIxn_H__
#define __ReferenceLJCoulombIxn_H__
#include "ReferencePairIxn.h"
// ---------------------------------------------------------------------------------------
class
ReferenceLJCoulombIxn
:
public
ReferencePairIxn
{
private:
// parameter indices
static
const
int
SigIndex
=
0
;
static
const
int
EpsIndex
=
1
;
static
const
int
QIndex
=
2
;
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferenceLJCoulombIxn
(
);
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~
ReferenceLJCoulombIxn
(
);
/**---------------------------------------------------------------------------------------
Calculate parameters for LJ 1-4 ixn
@param c6 c6
@param c12 c12
@param q1 q1 charge atom
@param epsfacSqrt epsfacSqrt ????????????/
@param parameters output parameters:
parameter[SigIndex] = sqrt(c6*c6/c12)
parameter[EpsIndex] = 0.5*( (c12/c6)**1/6 )
parameter[QIndex] = epsfactorSqrt*q1
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
getDerivedParameters
(
RealOpenMM
c6
,
RealOpenMM
c12
,
RealOpenMM
q1
,
RealOpenMM
epsfacSqrt
,
RealOpenMM
*
parameters
)
const
;
/**---------------------------------------------------------------------------------------
Calculate LJ Coulomb pair ixn
@param numberOfAtoms number of atoms
@param atomCoordinates atom coordinates
@param atomParameters atom parameters (charges, c6, c12, ...) atomParameters[atomIndex][paramterIndex]
@param exclusions atom exclusion indices exclusions[atomIndex][atomToExcludeIndex]
exclusions[atomIndex][0] = number of exclusions
exclusions[atomIndex][1-no.] = atom indices of atoms to excluded from
interacting w/ atom atomIndex
@param fixedParameters non atom parameters (not currently used)
@param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
int
calculatePairIxn
(
int
numberOfAtoms
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
atomParameters
,
int
**
exclusions
,
RealOpenMM
*
fixedParameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energyByAtom
,
RealOpenMM
*
totalEnergy
)
const
;
};
// ---------------------------------------------------------------------------------------
#endif // __ReferenceLJCoulombIxn_H__
platforms/reference/src/ReferencePairIxn.cpp
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "SimTKOpenMMLog.h"
#include "SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include "ReferencePairIxn.h"
/**---------------------------------------------------------------------------------------
ReferencePairIxn constructor
--------------------------------------------------------------------------------------- */
ReferencePairIxn
::
ReferencePairIxn
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferencePairIxn::ReferencePairIxn";
// ---------------------------------------------------------------------------------------
}
/**---------------------------------------------------------------------------------------
ReferencePairIxn destructor
--------------------------------------------------------------------------------------- */
ReferencePairIxn
::~
ReferencePairIxn
(
){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferencePairIxn::~ReferencePairIxn";
// ---------------------------------------------------------------------------------------
}
platforms/reference/src/ReferencePairIxn.h
0 → 100644
View file @
76e2849c
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ReferencePairIxn_H__
#define __ReferencePairIxn_H__
// #include "ReferenceIxn.h"
// ---------------------------------------------------------------------------------------
class
ReferencePairIxn
{
private:
public:
/**---------------------------------------------------------------------------------------
Constructor
--------------------------------------------------------------------------------------- */
ReferencePairIxn
(
);
/**---------------------------------------------------------------------------------------
Destructor
--------------------------------------------------------------------------------------- */
~
ReferencePairIxn
(
);
/**---------------------------------------------------------------------------------------
Calculate pair ixn
@param numberOfAtoms number of atoms
@param atomCoordinates atom coordinates
@param atomParameters atom parameters (charges, c6, c12, ...) atomParameters[atomIndex][paramterIndex]
@param exclusions atom exclusion indices exclusions[atomIndex][atomToExcludeIndex]
@param fixedParameters non-atom parameters
@param forces force array (forces added)
@param energyByAtom atom energy
@param totalEnergy total energy
@return ReferenceForce::DefaultReturn
--------------------------------------------------------------------------------------- */
virtual
int
calculatePairIxn
(
int
numberOfAtoms
,
RealOpenMM
**
atomCoordinates
,
RealOpenMM
**
atomParameters
,
int
**
exclusions
,
RealOpenMM
*
fixedParameters
,
RealOpenMM
**
forces
,
RealOpenMM
*
energyByAtom
,
RealOpenMM
*
totalEnergy
)
const
=
0
;
};
// ---------------------------------------------------------------------------------------
#endif // __ReferencePairIxn_H__
Prev
1
2
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