Commit 0843c5f3 authored by Peter Eastman's avatar Peter Eastman
Browse files

First stage of a refactoring to clean up the reference platform

parent bacc1eff
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "openmm/internal/MSVC_erfc.h" #include "openmm/internal/MSVC_erfc.h"
using std::vector; using std::vector;
using OpenMM::RealVec;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -238,9 +239,9 @@ int ReferenceFreeEnergyLJCoulombSoftcoreIxn::getDerivedParameters( RealOpenMM c6 ...@@ -238,9 +239,9 @@ int ReferenceFreeEnergyLJCoulombSoftcoreIxn::getDerivedParameters( RealOpenMM c6
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int ReferenceFreeEnergyLJCoulombSoftcoreIxn::calculateEwaldIxn( int numberOfAtoms, RealOpenMM** atomCoordinates, int ReferenceFreeEnergyLJCoulombSoftcoreIxn::calculateEwaldIxn( int numberOfAtoms, vector<RealVec>& atomCoordinates,
RealOpenMM** atomParameters, int** exclusions, RealOpenMM** atomParameters, int** exclusions,
RealOpenMM* fixedParameters, RealOpenMM** forces, RealOpenMM* fixedParameters, vector<RealVec>& forces,
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy) const { RealOpenMM* energyByAtom, RealOpenMM* totalEnergy) const {
#if 0 #if 0
typedef std::complex<RealOpenMM> d_complex; typedef std::complex<RealOpenMM> d_complex;
...@@ -546,9 +547,9 @@ int ReferenceFreeEnergyLJCoulombSoftcoreIxn::calculateEwaldIxn( int numberOfAtom ...@@ -546,9 +547,9 @@ int ReferenceFreeEnergyLJCoulombSoftcoreIxn::calculateEwaldIxn( int numberOfAtom
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int ReferenceFreeEnergyLJCoulombSoftcoreIxn::calculatePMEIxn( int numberOfAtoms, RealOpenMM** atomCoordinates, int ReferenceFreeEnergyLJCoulombSoftcoreIxn::calculatePMEIxn( int numberOfAtoms, vector<RealVec>& atomCoordinates,
RealOpenMM** atomParameters, int** exclusions, RealOpenMM** atomParameters, int** exclusions,
RealOpenMM* fixedParameters, RealOpenMM** forces, RealOpenMM* fixedParameters, vector<RealVec>& forces,
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy) const { RealOpenMM* energyByAtom, RealOpenMM* totalEnergy) const {
...@@ -678,9 +679,9 @@ int ReferenceFreeEnergyLJCoulombSoftcoreIxn::calculatePMEIxn( int numberOfAtoms, ...@@ -678,9 +679,9 @@ int ReferenceFreeEnergyLJCoulombSoftcoreIxn::calculatePMEIxn( int numberOfAtoms,
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int ReferenceFreeEnergyLJCoulombSoftcoreIxn::calculatePairIxn( int numberOfAtoms, RealOpenMM** atomCoordinates, int ReferenceFreeEnergyLJCoulombSoftcoreIxn::calculatePairIxn( int numberOfAtoms, vector<RealVec>& atomCoordinates,
RealOpenMM** atomParameters, int** exclusions, RealOpenMM** atomParameters, int** exclusions,
RealOpenMM* fixedParameters, RealOpenMM** forces, RealOpenMM* fixedParameters, vector<RealVec>& forces,
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const { RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const {
if (ewald || pme) if (ewald || pme)
...@@ -739,8 +740,8 @@ int ReferenceFreeEnergyLJCoulombSoftcoreIxn::calculatePairIxn( int numberOfAtoms ...@@ -739,8 +740,8 @@ int ReferenceFreeEnergyLJCoulombSoftcoreIxn::calculatePairIxn( int numberOfAtoms
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int ReferenceFreeEnergyLJCoulombSoftcoreIxn::calculateOneIxn( int ii, int jj, RealOpenMM** atomCoordinates, int ReferenceFreeEnergyLJCoulombSoftcoreIxn::calculateOneIxn( int ii, int jj, vector<RealVec>& atomCoordinates,
RealOpenMM** atomParameters, RealOpenMM** forces, RealOpenMM** atomParameters, vector<RealVec>& forces,
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const { RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const {
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -826,59 +827,6 @@ int ReferenceFreeEnergyLJCoulombSoftcoreIxn::calculateOneIxn( int ii, int jj, Re ...@@ -826,59 +827,6 @@ int ReferenceFreeEnergyLJCoulombSoftcoreIxn::calculateOneIxn( int ii, int jj, Re
energyByAtom[jj] += 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 );
}
return ReferenceForce::DefaultReturn; return ReferenceForce::DefaultReturn;
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "SimTKReference/ReferencePairIxn.h" #include "SimTKReference/ReferencePairIxn.h"
#include "SimTKReference/ReferenceNeighborList.h" #include "SimTKReference/ReferenceNeighborList.h"
#include <vector>
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -68,8 +69,8 @@ class ReferenceFreeEnergyLJCoulombSoftcoreIxn : public ReferencePairIxn { ...@@ -68,8 +69,8 @@ class ReferenceFreeEnergyLJCoulombSoftcoreIxn : public ReferencePairIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int calculateOneIxn( int atom1, int atom2, RealOpenMM** atomCoordinates, int calculateOneIxn( int atom1, int atom2, std::vector<OpenMM::RealVec>& atomCoordinates,
RealOpenMM** atomParameters, RealOpenMM** forces, RealOpenMM** atomParameters, std::vector<OpenMM::RealVec>& forces,
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const; RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const;
...@@ -194,9 +195,9 @@ class ReferenceFreeEnergyLJCoulombSoftcoreIxn : public ReferencePairIxn { ...@@ -194,9 +195,9 @@ class ReferenceFreeEnergyLJCoulombSoftcoreIxn : public ReferencePairIxn {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int calculatePairIxn( int numberOfAtoms, RealOpenMM** atomCoordinates, int calculatePairIxn( int numberOfAtoms, std::vector<OpenMM::RealVec>& atomCoordinates,
RealOpenMM** atomParameters, int** exclusions, RealOpenMM** atomParameters, int** exclusions,
RealOpenMM* fixedParameters, RealOpenMM** forces, RealOpenMM* fixedParameters, std::vector<OpenMM::RealVec>& forces,
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const; RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const;
private: private:
...@@ -220,9 +221,9 @@ private: ...@@ -220,9 +221,9 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int calculateEwaldIxn( int numberOfAtoms, RealOpenMM** atomCoordinates, int calculateEwaldIxn( int numberOfAtoms, std::vector<OpenMM::RealVec>& atomCoordinates,
RealOpenMM** atomParameters, int** exclusions, RealOpenMM** atomParameters, int** exclusions,
RealOpenMM* fixedParameters, RealOpenMM** forces, RealOpenMM* fixedParameters, std::vector<OpenMM::RealVec>& forces,
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const; RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -245,9 +246,9 @@ private: ...@@ -245,9 +246,9 @@ private:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int calculatePMEIxn( int numberOfAtoms, RealOpenMM** atomCoordinates, int calculatePMEIxn( int numberOfAtoms, std::vector<OpenMM::RealVec>& atomCoordinates,
RealOpenMM** atomParameters, int** exclusions, RealOpenMM** atomParameters, int** exclusions,
RealOpenMM* fixedParameters, RealOpenMM** forces, RealOpenMM* fixedParameters, std::vector<OpenMM::RealVec>& forces,
RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const; RealOpenMM* energyByAtom, RealOpenMM* totalEnergy ) const;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
......
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
#include "../SimTKReference/ReferenceForce.h" #include "../SimTKReference/ReferenceForce.h"
#include <math.h> #include <math.h>
using std::vector;
using OpenMM::RealVec;
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
CpuGBVISoftcore constructor CpuGBVISoftcore constructor
...@@ -319,7 +322,7 @@ int CpuGBVISoftcore::computeBornRadiiUsingQuinticSpline( RealOpenMM atomicRadius ...@@ -319,7 +322,7 @@ int CpuGBVISoftcore::computeBornRadiiUsingQuinticSpline( RealOpenMM atomicRadius
#define GBVISoftcoreDebug 0 #define GBVISoftcoreDebug 0
int CpuGBVISoftcore::computeBornRadii( RealOpenMM** atomCoordinates, RealOpenMM* bornRadii, RealOpenMM* switchDeriviative ){ int CpuGBVISoftcore::computeBornRadii( vector<RealVec>& atomCoordinates, RealOpenMM* bornRadii, RealOpenMM* switchDeriviative ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -604,7 +607,7 @@ RealOpenMM CpuGBVISoftcore::Sgb( RealOpenMM t ){ ...@@ -604,7 +607,7 @@ RealOpenMM CpuGBVISoftcore::Sgb( RealOpenMM t ){
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM CpuGBVISoftcore::computeBornEnergy( const RealOpenMM* bornRadii, RealOpenMM** atomCoordinates, RealOpenMM CpuGBVISoftcore::computeBornEnergy( const RealOpenMM* bornRadii, vector<RealVec>& atomCoordinates,
const RealOpenMM* partialCharges ){ const RealOpenMM* partialCharges ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
...@@ -720,8 +723,8 @@ RealOpenMM e3 = -partialChargeI2*partialCharges[atomJ]*Sgb( t )/deltaR[Reference ...@@ -720,8 +723,8 @@ RealOpenMM e3 = -partialChargeI2*partialCharges[atomJ]*Sgb( t )/deltaR[Reference
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int CpuGBVISoftcore::computeBornForces( const RealOpenMM* bornRadii, RealOpenMM** atomCoordinates, int CpuGBVISoftcore::computeBornForces( const RealOpenMM* bornRadii, vector<RealVec>& atomCoordinates,
const RealOpenMM* partialCharges, RealOpenMM** inputForces ){ const RealOpenMM* partialCharges, vector<RealVec>& inputForces ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
......
...@@ -115,7 +115,7 @@ class CpuGBVISoftcore : public CpuImplicitSolvent { ...@@ -115,7 +115,7 @@ class CpuGBVISoftcore : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int computeBornRadii( RealOpenMM** atomCoordinates, RealOpenMM* bornRadii, int computeBornRadii( std::vector<OpenMM::RealVec>& atomCoordinates, RealOpenMM* bornRadii,
RealOpenMM* switchDeriviative = NULL ); RealOpenMM* switchDeriviative = NULL );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -210,7 +210,7 @@ class CpuGBVISoftcore : public CpuImplicitSolvent { ...@@ -210,7 +210,7 @@ class CpuGBVISoftcore : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
RealOpenMM computeBornEnergy( const RealOpenMM* bornRadii, RealOpenMM** atomCoordinates, RealOpenMM computeBornEnergy( const RealOpenMM* bornRadii, std::vector<OpenMM::RealVec>& atomCoordinates,
const RealOpenMM* partialCharges ); const RealOpenMM* partialCharges );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -226,8 +226,8 @@ class CpuGBVISoftcore : public CpuImplicitSolvent { ...@@ -226,8 +226,8 @@ class CpuGBVISoftcore : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int computeBornForces( const RealOpenMM* bornRadii, RealOpenMM** atomCoordinates, int computeBornForces( const RealOpenMM* bornRadii, std::vector<OpenMM::RealVec>& atomCoordinates,
const RealOpenMM* partialCharges, RealOpenMM** inputForces ); const RealOpenMM* partialCharges, std::vector<OpenMM::RealVec>& inputForces );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
......
...@@ -128,7 +128,7 @@ class CpuObcSoftcore : public CpuImplicitSolvent { ...@@ -128,7 +128,7 @@ class CpuObcSoftcore : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int computeBornRadii( RealOpenMM** atomCoordinates, RealOpenMM* bornRadii, int computeBornRadii( std::vector<OpenMM::RealVec>& atomCoordinates, RealOpenMM* bornRadii,
RealOpenMM* obcChain = NULL ); RealOpenMM* obcChain = NULL );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -162,79 +162,8 @@ class CpuObcSoftcore : public CpuImplicitSolvent { ...@@ -162,79 +162,8 @@ class CpuObcSoftcore : public CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
int computeBornEnergyForces( RealOpenMM* bornRadii, RealOpenMM** atomCoordinates, int computeBornEnergyForces( RealOpenMM* bornRadii, std::vector<OpenMM::RealVec>& atomCoordinates,
const RealOpenMM* partialCharges, RealOpenMM** forces ); const RealOpenMM* partialCharges, std::vector<OpenMM::RealVec>& forces );
int computeBornEnergyForcesPrint( RealOpenMM* bornRadii, RealOpenMM** atomCoordinates,
const RealOpenMM* partialCharges, RealOpenMM** forces );
/**---------------------------------------------------------------------------------------
Get state
title title (optional)
@return state string
--------------------------------------------------------------------------------------- */
std::string getStateString( const char* title ) const;
/**---------------------------------------------------------------------------------------
Write Born energy and forces (Simbios)
@param atomCoordinates atomic coordinates
@param partialCharges partial atom charges
@param forces force array
@param resultsFileName output file name
@return SimTKOpenMMCommon::DefaultReturn if file opened; else return SimTKOpenMMCommon::ErrorReturn
--------------------------------------------------------------------------------------- */
int writeBornEnergyForces( RealOpenMM** atomCoordinates,
const RealOpenMM* partialCharges, RealOpenMM** forces,
const std::string& resultsFileName ) const;
/**---------------------------------------------------------------------------------------
Write results from first loop
@param atomCoordinates atomic coordinates
@param RealOpenMM forces forces
@param outputFileName output file name
@return SimTKOpenMMCommon::DefaultReturn unless
file cannot be opened
in which case return SimTKOpenMMCommon::ErrorReturn
--------------------------------------------------------------------------------------- */
static int writeForceLoop1( int numberOfAtoms, RealOpenMM** forces, const RealOpenMM* bornForce,
const std::string& outputFileName );
/**---------------------------------------------------------------------------------------
Write results
@param numberOfAtoms number of atoms
@param chunkSizes vector of chunk sizes for realRealOpenMMVector
@param realRealOpenMMVector vector of RealOpenMM**
@param realVector vector of RealOpenMM*
@param outputFileName output file name
@return SimTKOpenMMCommon::DefaultReturn unless
file cannot be opened
in which case return SimTKOpenMMCommon::ErrorReturn
--------------------------------------------------------------------------------------- */
static int writeForceLoop( int numberOfAtoms, const IntVector& chunkSizes,
const RealOpenMMPtrPtrVector& realRealOpenMMVector,
const RealOpenMMPtrVector& realVector,
const std::string& outputFileName );
}; };
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment