Commit e20cc4f2 authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

Initial AmoebaReferenceMultipoleForce

parent 6d91d79d
...@@ -4733,7 +4733,7 @@ void testUsingAmoebaTinkerParameterFile( const std::string& amoebaTinkerParamete ...@@ -4733,7 +4733,7 @@ void testUsingAmoebaTinkerParameterFile( const std::string& amoebaTinkerParamete
} }
} }
if( gkIsActive == false ){ if( 0 && gkIsActive == false ){
isPresent = forceMap.find( AMOEBA_MULTIPOLE_FORCE ); isPresent = forceMap.find( AMOEBA_MULTIPOLE_FORCE );
if( isPresent != forceMap.end() && isPresent->second != 0 ){ if( isPresent != forceMap.end() && isPresent->second != 0 ){
//checkIntermediateMultipoleQuantities( context, supplementary, useOpenMMUnits, log ); //checkIntermediateMultipoleQuantities( context, supplementary, useOpenMMUnits, log );
......
...@@ -47,8 +47,8 @@ extern "C" void OPENMM_EXPORT registerKernelFactories() { ...@@ -47,8 +47,8 @@ extern "C" void OPENMM_EXPORT registerKernelFactories() {
platform.registerKernelFactory(CalcAmoebaOutOfPlaneBendForceKernel::Name(), factory); platform.registerKernelFactory(CalcAmoebaOutOfPlaneBendForceKernel::Name(), factory);
platform.registerKernelFactory(CalcAmoebaTorsionTorsionForceKernel::Name(), factory); platform.registerKernelFactory(CalcAmoebaTorsionTorsionForceKernel::Name(), factory);
platform.registerKernelFactory(CalcAmoebaVdwForceKernel::Name(), factory); platform.registerKernelFactory(CalcAmoebaVdwForceKernel::Name(), factory);
/*
platform.registerKernelFactory(CalcAmoebaMultipoleForceKernel::Name(), factory); platform.registerKernelFactory(CalcAmoebaMultipoleForceKernel::Name(), factory);
/*
platform.registerKernelFactory(CalcAmoebaGeneralizedKirkwoodForceKernel::Name(), factory); platform.registerKernelFactory(CalcAmoebaGeneralizedKirkwoodForceKernel::Name(), factory);
*/ */
platform.registerKernelFactory(CalcAmoebaWcaDispersionForceKernel::Name(), factory); platform.registerKernelFactory(CalcAmoebaWcaDispersionForceKernel::Name(), factory);
...@@ -87,11 +87,11 @@ KernelImpl* AmoebaReferenceKernelFactory::createKernelImpl(std::string name, con ...@@ -87,11 +87,11 @@ KernelImpl* AmoebaReferenceKernelFactory::createKernelImpl(std::string name, con
if (name == CalcAmoebaVdwForceKernel::Name()) if (name == CalcAmoebaVdwForceKernel::Name())
return new ReferenceCalcAmoebaVdwForceKernel(name, platform, context.getSystem()); return new ReferenceCalcAmoebaVdwForceKernel(name, platform, context.getSystem());
/*
if (name == CalcAmoebaMultipoleForceKernel::Name()) if (name == CalcAmoebaMultipoleForceKernel::Name())
return new ReferenceCalcAmoebaMultipoleForceKernel(name, platform, context.getSystem()); return new ReferenceCalcAmoebaMultipoleForceKernel(name, platform, context.getSystem());
/*
if (name == CalcAmoebaGeneralizedKirkwoodForceKernel::Name()) if (name == CalcAmoebaGeneralizedKirkwoodForceKernel::Name())
return new ReferenceCalcAmoebaGeneralizedKirkwoodForceKernel(name, platform, context.getSystem()); return new ReferenceCalcAmoebaGeneralizedKirkwoodForceKernel(name, platform, context.getSystem());
*/ */
......
...@@ -33,12 +33,14 @@ ...@@ -33,12 +33,14 @@
#include "AmoebaReferenceStretchBendForce.h" #include "AmoebaReferenceStretchBendForce.h"
#include "AmoebaReferenceOutOfPlaneBendForce.h" #include "AmoebaReferenceOutOfPlaneBendForce.h"
#include "AmoebaReferenceTorsionTorsionForce.h" #include "AmoebaReferenceTorsionTorsionForce.h"
#include "AmoebaReferenceMultipoleForce.h"
#include "AmoebaReferenceVdwForce.h" #include "AmoebaReferenceVdwForce.h"
#include "AmoebaReferenceWcaDispersionForce.h" #include "AmoebaReferenceWcaDispersionForce.h"
#include "internal/AmoebaWcaDispersionForceImpl.h" #include "internal/AmoebaWcaDispersionForceImpl.h"
#include "ReferencePlatform.h" #include "ReferencePlatform.h"
#include "openmm/internal/ContextImpl.h" #include "openmm/internal/ContextImpl.h"
//#include "internal/AmoebaMultipoleForceImpl.h" #include "AmoebaMultipoleForce.h"
#include "internal/AmoebaMultipoleForceImpl.h"
#include <cmath> #include <cmath>
#ifdef _MSC_VER #ifdef _MSC_VER
...@@ -399,178 +401,105 @@ double ReferenceCalcAmoebaTorsionTorsionForceKernel::execute(ContextImpl& contex ...@@ -399,178 +401,105 @@ double ReferenceCalcAmoebaTorsionTorsionForceKernel::execute(ContextImpl& contex
return static_cast<double>(energy); return static_cast<double>(energy);
} }
///* -------------------------------------------------------------------------- * /* -------------------------------------------------------------------------- *
// * AmoebaMultipole * * AmoebaMultipole *
// * -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
//
//static void computeAmoebaMultipoleForce( AmoebaCudaData& data ) { ReferenceCalcAmoebaMultipoleForceKernel::ReferenceCalcAmoebaMultipoleForceKernel(std::string name, const Platform& platform, System& system) :
// CalcAmoebaMultipoleForceKernel(name, platform), system(system) {
// amoebaGpuContext gpu = data.getAmoebaGpu(); }
// data.initializeGpu();
// ReferenceCalcAmoebaMultipoleForceKernel::~ReferenceCalcAmoebaMultipoleForceKernel() {
// if( 0 && data.getLog() ){ }
// (void) fprintf( data.getLog(), "computeAmoebaMultipoleForce\n" );
// (void) fflush( data.getLog()); void ReferenceCalcAmoebaMultipoleForceKernel::initialize(const System& system, const AmoebaMultipoleForce& force) {
// }
// numMultipoles = force.getNumMultipoles();
// // calculate Born radii
// charges.resize(numMultipoles);
// if( data.getHasAmoebaGeneralizedKirkwood() ){ dipoles.resize(3*numMultipoles);
// kCalculateObcGbsaBornSum(gpu->gpuContext); quadrupoles.resize(9*numMultipoles);
// kReduceObcGbsaBornSum(gpu->gpuContext); tholes.resize(numMultipoles);
// } dampingFactors.resize(numMultipoles);
// polarity.resize(numMultipoles);
// // multipoles axisTypes.resize(numMultipoles);
// multipoleAtomId1s.resize(numMultipoles);
// kCalculateAmoebaMultipoleForces(gpu, data.getHasAmoebaGeneralizedKirkwood() ); multipoleAtomId2s.resize(numMultipoles);
// multipoleAtomCovalentInfo.resize(numMultipoles);
////kClearForces(gpu->gpuContext);
////kClearEnergy(gpu->gpuContext); int dipoleIndex = 0;
////(void) fprintf( data.getLog(), "computeAmoebaMultipoleForce clearing forces/energy after kCalculateAmoebaMultipoleForces()\n" ); int quadrupoleIndex = 0;
// int maxCovalentRange = 0;
// // GK double totalCharge = 0.0;
// for( int ii = 0; ii < numMultipoles; ii++ ){
// if( data.getHasAmoebaGeneralizedKirkwood() ){
// kCalculateAmoebaKirkwood(gpu); // multipoles
// }
// int axisType, multipoleAtomId1, multipoleAtomId2;
// if( 0 && data.getLog() ){ double charge, tholeD, dampingFactorD, polarityD;
// (void) fprintf( data.getLog(), "completed computeAmoebaMultipoleForce\n" ); std::vector<double> dipolesD;
// (void) fflush( data.getLog()); std::vector<double> quadrupolesD;
// } force.getMultipoleParameters(ii, charge, dipolesD, quadrupolesD, axisType, multipoleAtomId1, multipoleAtomId2,
//} tholeD, dampingFactorD, polarityD );
//
//CudaCalcAmoebaMultipoleForceKernel::CudaCalcAmoebaMultipoleForceKernel(std::string name, const Platform& platform, AmoebaCudaData& data, System& system) : totalCharge += charge;
// CalcAmoebaMultipoleForceKernel(name, platform), system(system) { axisTypes[ii] = axisType;
// data.incrementKernelCount(); multipoleAtomId1s[ii] = multipoleAtomId1;
//} multipoleAtomId2s[ii] = multipoleAtomId2;
//
//CudaCalcAmoebaMultipoleForceKernel::~CudaCalcAmoebaMultipoleForceKernel() { charges[ii] = static_cast<RealOpenMM>(charge);
// data.decrementKernelCount(); tholes[ii] = static_cast<RealOpenMM>(tholeD);
//} dampingFactors[ii] = static_cast<RealOpenMM>(dampingFactorD);
// polarity[ii] = static_cast<RealOpenMM>(polarityD);
//void CudaCalcAmoebaMultipoleForceKernel::initialize(const System& system, const AmoebaMultipoleForce& force) {
// dipoles[dipoleIndex++] = static_cast<RealOpenMM>(dipolesD[0]);
// numMultipoles = force.getNumMultipoles(); dipoles[dipoleIndex++] = static_cast<RealOpenMM>(dipolesD[1]);
// dipoles[dipoleIndex++] = static_cast<RealOpenMM>(dipolesD[2]);
// data.setHasAmoebaMultipole( true );
// quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[0]);
// std::vector<RealOpenMM> charges(numMultipoles); quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[1]);
// std::vector<RealOpenMM> dipoles(3*numMultipoles); quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[2]);
// std::vector<RealOpenMM> quadrupoles(9*numMultipoles); quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[3]);
// std::vector<RealOpenMM> tholes(numMultipoles); quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[4]);
// std::vector<RealOpenMM> dampingFactors(numMultipoles); quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[5]);
// std::vector<RealOpenMM> polarity(numMultipoles); quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[6]);
// std::vector<int> axisTypes(numMultipoles); quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[7]);
// std::vector<int> multipoleAtomId1s(numMultipoles); quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[8]);
// std::vector<int> multipoleAtomId2s(numMultipoles);
// std::vector< std::vector< std::vector<int> > > multipoleAtomCovalentInfo(numMultipoles); // covalent info
// std::vector<int> minCovalentIndices(numMultipoles);
// std::vector<int> minCovalentPolarizationIndices(numMultipoles); std::vector< std::vector<int> > covalentLists;
// force.getCovalentMaps(ii, covalentLists );
// RealOpenMM scalingDistanceCutoff = static_cast<RealOpenMM>(force.getScalingDistanceCutoff()); multipoleAtomCovalentInfo[ii] = covalentLists;
//
// std::vector<AmoebaMultipoleForce::CovalentType> covalentList; }
// covalentList.push_back( AmoebaMultipoleForce::Covalent12 );
// covalentList.push_back( AmoebaMultipoleForce::Covalent13 ); mutualInducedMaxIterations = force.getMutualInducedMaxIterations();
// covalentList.push_back( AmoebaMultipoleForce::Covalent14 ); mutualInducedTargetEpsilon = force.getMutualInducedTargetEpsilon();
// covalentList.push_back( AmoebaMultipoleForce::Covalent15 );
// nonbondedMethod = static_cast<int>(force.getNonbondedMethod());
// std::vector<AmoebaMultipoleForce::CovalentType> polarizationCovalentList; if( nonbondedMethod != 0 && nonbondedMethod != 1 ){
// polarizationCovalentList.push_back( AmoebaMultipoleForce::PolarizationCovalent11 ); throw OpenMMException("AmoebaMultipoleForce nonbonded method not recognized.\n");
// polarizationCovalentList.push_back( AmoebaMultipoleForce::PolarizationCovalent12 ); }
// polarizationCovalentList.push_back( AmoebaMultipoleForce::PolarizationCovalent13 ); }
// polarizationCovalentList.push_back( AmoebaMultipoleForce::PolarizationCovalent14 );
// double ReferenceCalcAmoebaMultipoleForceKernel::execute(ContextImpl& context, bool includeForces, bool includeEnergy) {
// std::vector<int> covalentDegree; RealOpenMM** posData = extractPositions(context);
// AmoebaMultipoleForceImpl::getCovalentDegree( force, covalentDegree ); RealOpenMM** forceData = extractForces(context);
// int dipoleIndex = 0;
// int quadrupoleIndex = 0; AmoebaReferenceMultipoleForce amoebaReferenceMultipoleForce( AmoebaReferenceMultipoleForce::NoCutoff );
// int maxCovalentRange = 0; amoebaReferenceMultipoleForce.setMutualInducedDipoleTargetEpsilon( mutualInducedTargetEpsilon );
// double totalCharge = 0.0; amoebaReferenceMultipoleForce.setMaximumMutualInducedDipoleIterations( mutualInducedMaxIterations );
// for (int i = 0; i < numMultipoles; i++) {
// RealOpenMM energy = amoebaReferenceMultipoleForce.calculateForceAndEnergy( numMultipoles, posData,
// // multipoles charges, dipoles, quadrupoles, tholes,
// dampingFactors, polarity, axisTypes,
// int axisType, multipoleAtomId1, multipoleAtomId2; multipoleAtomId1s, multipoleAtomId2s,
// double charge, tholeD, dampingFactorD, polarityD; multipoleAtomCovalentInfo, forceData);
// std::vector<double> dipolesD;
// std::vector<double> quadrupolesD; return static_cast<double>(energy);
// force.getMultipoleParameters(i, charge, dipolesD, quadrupolesD, axisType, multipoleAtomId1, multipoleAtomId2, }
// tholeD, dampingFactorD, polarityD );
//
// totalCharge += charge;
// axisTypes[i] = axisType;
// multipoleAtomId1s[i] = multipoleAtomId1;
// multipoleAtomId2s[i] = multipoleAtomId2;
//
// charges[i] = static_cast<RealOpenMM>(charge);
// tholes[i] = static_cast<RealOpenMM>(tholeD);
// dampingFactors[i] = static_cast<RealOpenMM>(dampingFactorD);
// polarity[i] = static_cast<RealOpenMM>(polarityD);
//
// dipoles[dipoleIndex++] = static_cast<RealOpenMM>(dipolesD[0]);
// dipoles[dipoleIndex++] = static_cast<RealOpenMM>(dipolesD[1]);
// dipoles[dipoleIndex++] = static_cast<RealOpenMM>(dipolesD[2]);
//
// quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[0]);
// quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[1]);
// quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[2]);
// quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[3]);
// quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[4]);
// quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[5]);
// quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[6]);
// quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[7]);
// quadrupoles[quadrupoleIndex++] = static_cast<RealOpenMM>(quadrupolesD[8]);
//
// // covalent info
//
// std::vector< std::vector<int> > covalentLists;
// force.getCovalentMaps(i, covalentLists );
// multipoleAtomCovalentInfo[i] = covalentLists;
//
// int minCovalentIndex, maxCovalentIndex;
// AmoebaMultipoleForceImpl::getCovalentRange( force, i, covalentList, &minCovalentIndex, &maxCovalentIndex );
// minCovalentIndices[i] = minCovalentIndex;
// if( maxCovalentRange < (maxCovalentIndex - minCovalentIndex) ){
// maxCovalentRange = maxCovalentIndex - minCovalentIndex;
// }
//
// AmoebaMultipoleForceImpl::getCovalentRange( force, i, polarizationCovalentList, &minCovalentIndex, &maxCovalentIndex );
// minCovalentPolarizationIndices[i] = minCovalentIndex;
// if( maxCovalentRange < (maxCovalentIndex - minCovalentIndex) ){
// maxCovalentRange = maxCovalentIndex - minCovalentIndex;
// }
// }
//
// int iterativeMethod = static_cast<int>(force.getMutualInducedIterationMethod());
// if( iterativeMethod != 0 ){
// throw OpenMMException("Iterative method for mutual induced dipoles not recognized.\n");
// }
//
// int nonbondedMethod = static_cast<int>(force.getNonbondedMethod());
// if( nonbondedMethod != 0 && nonbondedMethod != 1 ){
// throw OpenMMException("AmoebaMultipoleForce nonbonded method not recognized.\n");
// }
//
// gpuSetAmoebaMultipoleParameters(data.getAmoebaGpu(), charges, dipoles, quadrupoles, axisTypes, multipoleAtomId1s, multipoleAtomId2s,
// tholes, scalingDistanceCutoff, dampingFactors, polarity,
// multipoleAtomCovalentInfo, covalentDegree, minCovalentIndices, minCovalentPolarizationIndices, (maxCovalentRange+2),
// static_cast<int>(force.getMutualInducedIterationMethod()),
// force.getMutualInducedMaxIterations(),
// static_cast<RealOpenMM>( force.getMutualInducedTargetEpsilon()),
// nonbondedMethod,
// static_cast<RealOpenMM>( force.getCutoffDistance()),
// static_cast<RealOpenMM>( force.getAEwald()),
// static_cast<RealOpenMM>( force.getElectricConstant()) );
//
//}
//
//double ReferenceCalcAmoebaMultipoleForceKernel::execute(ContextImpl& context, bool includeForces, bool includeEnergy) {
// computeAmoebaMultipoleForce( data );
// return 0.0;
//}
//
///* -------------------------------------------------------------------------- * ///* -------------------------------------------------------------------------- *
// * AmoebaGeneralizedKirkwood * // * AmoebaGeneralizedKirkwood *
// * -------------------------------------------------------------------------- */ // * -------------------------------------------------------------------------- */
......
...@@ -325,34 +325,50 @@ private: ...@@ -325,34 +325,50 @@ private:
System& system; System& system;
}; };
// /** /**
// * This kernel is invoked by AmoebaMultipoleForce to calculate the forces acting on the system and the energy of the system. * This kernel is invoked by AmoebaMultipoleForce to calculate the forces acting on the system and the energy of the system.
// */ */
// class ReferenceCalcAmoebaMultipoleForceKernel : public CalcAmoebaMultipoleForceKernel { class ReferenceCalcAmoebaMultipoleForceKernel : public CalcAmoebaMultipoleForceKernel {
// public: public:
// ReferenceCalcAmoebaMultipoleForceKernel(std::string name, const Platform& platform, System& system); ReferenceCalcAmoebaMultipoleForceKernel(std::string name, const Platform& platform, System& system);
// ~ReferenceCalcAmoebaMultipoleForceKernel(); ~ReferenceCalcAmoebaMultipoleForceKernel();
// /** /**
// * Initialize the kernel. * Initialize the kernel.
// * *
// * @param system the System this kernel will be applied to * @param system the System this kernel will be applied to
// * @param force the AmoebaMultipoleForce this kernel will be used for * @param force the AmoebaMultipoleForce this kernel will be used for
// */ */
// void initialize(const System& system, const AmoebaMultipoleForce& force); void initialize(const System& system, const AmoebaMultipoleForce& force);
// /** /**
// * Execute the kernel to calculate the forces and/or energy. * Execute the kernel to calculate the forces and/or energy.
// * *
// * @param context the context in which to execute this kernel * @param context the context in which to execute this kernel
// * @param includeForces true if forces should be calculated * @param includeForces true if forces should be calculated
// * @param includeEnergy true if the energy should be calculated * @param includeEnergy true if the energy should be calculated
// * @return the potential energy due to the force * @return the potential energy due to the force
// */ */
// double execute(ContextImpl& context, bool includeForces, bool includeEnergy); double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
// private: private:
// int numMultipoles; int numMultipoles;
// System& system; std::vector<RealOpenMM> charges;
// }; std::vector<RealOpenMM> dipoles;
// std::vector<RealOpenMM> quadrupoles;
std::vector<RealOpenMM> tholes;
std::vector<RealOpenMM> dampingFactors;
std::vector<RealOpenMM> polarity;
std::vector<int> axisTypes;
std::vector<int> multipoleAtomId1s;
std::vector<int> multipoleAtomId2s;
std::vector< std::vector< std::vector<int> > > multipoleAtomCovalentInfo;
//int iterativeMethod;
int nonbondedMethod;
int mutualInducedMaxIterations;
RealOpenMM mutualInducedTargetEpsilon;
System& system;
};
// /** // /**
// * This kernel is invoked by AmoebaMultipoleForce to calculate the forces acting on the system and the energy of the system. // * This kernel is invoked by AmoebaMultipoleForce to calculate the forces acting on the system and the energy of the system.
// */ // */
......
...@@ -74,6 +74,29 @@ RealOpenMM AmoebaReferenceForce::getNormSquared3( const std::vector<RealOpenMM>& ...@@ -74,6 +74,29 @@ RealOpenMM AmoebaReferenceForce::getNormSquared3( const std::vector<RealOpenMM>&
return ( inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2] ); return ( inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2] );
} }
/**---------------------------------------------------------------------------------------
Calculate norm squared of 3d vector
@param inputVector vector whose norm squared is to be computed
@return norm squared
--------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceForce::getNormSquared3( const RealOpenMM* inputVector ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceForce::getNorm3";
// ---------------------------------------------------------------------------------------
// get 3 norm
return ( inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2] );
}
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Calculate norm of 3d vector Calculate norm of 3d vector
...@@ -97,6 +120,36 @@ RealOpenMM AmoebaReferenceForce::getNorm3( const std::vector<RealOpenMM>& inputV ...@@ -97,6 +120,36 @@ RealOpenMM AmoebaReferenceForce::getNorm3( const std::vector<RealOpenMM>& inputV
return SQRT( inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2] ); return SQRT( inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2] );
} }
RealOpenMM AmoebaReferenceForce::getNorm3( const RealOpenMM* inputVector ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceForce::getNorm3";
// ---------------------------------------------------------------------------------------
// get 3 norm
return SQRT( inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2] );
}
void AmoebaReferenceForce::normalizeVector3( RealOpenMM* inputVector ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceForce::normalizeVector3";
// ---------------------------------------------------------------------------------------
RealOpenMM norm = SQRT( inputVector[0]*inputVector[0] + inputVector[1]*inputVector[1] + inputVector[2]*inputVector[2] );
if( norm > 0.0 ){
norm = 1.0/norm;
inputVector[0] *= norm;
inputVector[1] *= norm;
inputVector[2] *= norm;
}
}
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Calculate dot product of 3d vectors Calculate dot product of 3d vectors
...@@ -121,6 +174,55 @@ RealOpenMM AmoebaReferenceForce::getDotProduct3( const std::vector<RealOpenMM>& ...@@ -121,6 +174,55 @@ RealOpenMM AmoebaReferenceForce::getDotProduct3( const std::vector<RealOpenMM>&
return xVector[0]*yVector[0] + xVector[1]*yVector[1] + xVector[2]*yVector[2]; return xVector[0]*yVector[0] + xVector[1]*yVector[1] + xVector[2]*yVector[2];
} }
/**---------------------------------------------------------------------------------------
Calculate dot product of 3d vectors
@param xVector first vector
@param yVector second vector
@return dot product
--------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceForce::getDotProduct3( const RealOpenMM* xVector, const RealOpenMM* yVector ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceForce::getDotProduct3";
// ---------------------------------------------------------------------------------------
// get dot product
return xVector[0]*yVector[0] + xVector[1]*yVector[1] + xVector[2]*yVector[2];
}
/**---------------------------------------------------------------------------------------
Calculate dot product of 3d vectors
@param vectorOffset offset into first first vector
@param xVector first vector
@param yVector second vector
@return dot product
--------------------------------------------------------------------------------------- */
RealOpenMM AmoebaReferenceForce::getDotProduct3( unsigned int vectorOffset, const std::vector<RealOpenMM>& xVector, const RealOpenMM* yVector ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceForce::getDotProduct3";
// ---------------------------------------------------------------------------------------
// get dot product
return xVector[vectorOffset+0]*yVector[0] + xVector[vectorOffset+1]*yVector[1] + xVector[vectorOffset+2]*yVector[2];
}
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Calculate z = x X y Calculate z = x X y
...@@ -148,3 +250,30 @@ void AmoebaReferenceForce::getCrossProduct( const std::vector<RealOpenMM>& xVect ...@@ -148,3 +250,30 @@ void AmoebaReferenceForce::getCrossProduct( const std::vector<RealOpenMM>& xVect
return; return;
} }
/**---------------------------------------------------------------------------------------
Calculate z = x X y
@param xVector input vector
@param yVector input vector
@param zVector output vector: z = x X y
--------------------------------------------------------------------------------------- */
void AmoebaReferenceForce::getCrossProduct( const RealOpenMM* xVector,
const RealOpenMM* yVector,
RealOpenMM* zVector ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "AmoebaReferenceForce::getCrossProduct";
// ---------------------------------------------------------------------------------------
zVector[0] = xVector[1]*yVector[2] - xVector[2]*yVector[1];
zVector[1] = xVector[2]*yVector[0] - xVector[0]*yVector[2];
zVector[2] = xVector[0]*yVector[1] - xVector[1]*yVector[0];
return;
}
...@@ -75,6 +75,7 @@ public: ...@@ -75,6 +75,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
static RealOpenMM getNormSquared3( const std::vector<RealOpenMM>& inputVector ); static RealOpenMM getNormSquared3( const std::vector<RealOpenMM>& inputVector );
static RealOpenMM getNormSquared3( const RealOpenMM* inputVector );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -87,6 +88,17 @@ public: ...@@ -87,6 +88,17 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
static RealOpenMM getNorm3( const std::vector<RealOpenMM>& inputVector ); static RealOpenMM getNorm3( const std::vector<RealOpenMM>& inputVector );
static RealOpenMM getNorm3( const RealOpenMM* inputVector );
/**---------------------------------------------------------------------------------------
Normalize 3d vector
@param inputVector vector to normalize
--------------------------------------------------------------------------------------- */
static void normalizeVector3( RealOpenMM* inputVector );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -100,6 +112,8 @@ public: ...@@ -100,6 +112,8 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
static RealOpenMM getDotProduct3( const std::vector<RealOpenMM>& xVector, const std::vector<RealOpenMM>& yVector ); static RealOpenMM getDotProduct3( const std::vector<RealOpenMM>& xVector, const std::vector<RealOpenMM>& yVector );
static RealOpenMM getDotProduct3( const RealOpenMM* xVector, const RealOpenMM* yVector );
static RealOpenMM getDotProduct3( unsigned int vectorOffset, const std::vector<RealOpenMM>& xVector, const RealOpenMM* yVector );
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -114,6 +128,9 @@ public: ...@@ -114,6 +128,9 @@ public:
static void getCrossProduct( const std::vector<RealOpenMM>& xVector, const std::vector<RealOpenMM>& yVector, static void getCrossProduct( const std::vector<RealOpenMM>& xVector, const std::vector<RealOpenMM>& yVector,
std::vector<RealOpenMM>& zVector ); std::vector<RealOpenMM>& zVector );
static void getCrossProduct( const RealOpenMM* xVector, const RealOpenMM* yVector, RealOpenMM* zVector );
}; };
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
......
...@@ -164,7 +164,6 @@ public: ...@@ -164,7 +164,6 @@ public:
@param vdwExclusions particle exclusions @param vdwExclusions particle exclusions
@param forces add forces to this vector @param forces add forces to this vector
@return energy
@return energy @return energy
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
......
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