#ifndef AMOEBA_OPENMM_REFERENCE_KERNELS_H_
#define AMOEBA_OPENMM_REFERENCE_KERNELS_H_
/* -------------------------------------------------------------------------- *
* OpenMMAmoeba *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Authors: *
* Contributors: *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see . *
* -------------------------------------------------------------------------- */
#include "openmm/System.h"
#include "openmm/amoebaKernels.h"
//#include "openmm/AmoebaMultipoleForce.h"
#include "SimTKReference/ReferenceNeighborList.h"
#include "SimTKUtilities/SimTKOpenMMRealType.h"
namespace OpenMM {
/**
* This kernel is invoked by AmoebaBondForce to calculate the forces acting on the system and the energy of the system.
*/
class ReferenceCalcAmoebaBondForceKernel : public CalcAmoebaBondForceKernel {
public:
ReferenceCalcAmoebaBondForceKernel(std::string name,
const Platform& platform,
System& system);
~ReferenceCalcAmoebaBondForceKernel();
/**
* Initialize the kernel.
*
* @param system the System this kernel will be applied to
* @param force the AmoebaBondForce this kernel will be used for
*/
void initialize(const System& system, const AmoebaBondForce& force);
/**
* Execute the kernel to calculate the forces and/or energy.
*
* @param context the context in which to execute this kernel
* @param includeForces true if forces should be calculated
* @param includeEnergy true if the energy should be calculated
* @return the potential energy due to the force
*/
double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
private:
int numBonds;
std::vector particle1;
std::vector particle2;
std::vector length;
std::vector kQuadratic;
RealOpenMM globalBondCubic;
RealOpenMM globalBondQuartic;
System& system;
};
/**
* This kernel is invoked by AmoebaAngleForce to calculate the forces acting on the system and the energy of the system.
*/
class ReferenceCalcAmoebaAngleForceKernel : public CalcAmoebaAngleForceKernel {
public:
ReferenceCalcAmoebaAngleForceKernel(std::string name, const Platform& platform, System& system);
~ReferenceCalcAmoebaAngleForceKernel();
/**
* Initialize the kernel.
*
* @param system the System this kernel will be applied to
* @param force the AmoebaAngleForce this kernel will be used for
*/
void initialize(const System& system, const AmoebaAngleForce& force);
/**
* Execute the kernel to calculate the forces and/or energy.
*
* @param context the context in which to execute this kernel
* @param includeForces true if forces should be calculated
* @param includeEnergy true if the energy should be calculated
* @return the potential energy due to the force
*/
double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
private:
int numAngles;
std::vector particle1;
std::vector particle2;
std::vector particle3;
std::vector angle;
std::vector kQuadratic;
RealOpenMM globalAngleCubic;
RealOpenMM globalAngleQuartic;
RealOpenMM globalAnglePentic;
RealOpenMM globalAngleSextic;
System& system;
};
/**
* This kernel is invoked by AmoebaInPlaneAngleForce to calculate the forces acting on the system and the energy of the system.
*/
class ReferenceCalcAmoebaInPlaneAngleForceKernel : public CalcAmoebaInPlaneAngleForceKernel {
public:
ReferenceCalcAmoebaInPlaneAngleForceKernel(std::string name, const Platform& platform, System& system);
~ReferenceCalcAmoebaInPlaneAngleForceKernel();
/**
* Initialize the kernel.
*
* @param system the System this kernel will be applied to
* @param force the AmoebaInPlaneAngleForce this kernel will be used for
*/
void initialize(const System& system, const AmoebaInPlaneAngleForce& force);
/**
* Execute the kernel to calculate the forces and/or energy.
*
* @param context the context in which to execute this kernel
* @param includeForces true if forces should be calculated
* @param includeEnergy true if the energy should be calculated
* @return the potential energy due to the force
*/
double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
private:
int numAngles;
std::vector particle1;
std::vector particle2;
std::vector particle3;
std::vector particle4;
std::vector angle;
std::vector kQuadratic;
RealOpenMM globalInPlaneAngleCubic;
RealOpenMM globalInPlaneAngleQuartic;
RealOpenMM globalInPlaneAnglePentic;
RealOpenMM globalInPlaneAngleSextic;
System& system;
};
/**
* This kernel is invoked by AmoebaPiTorsionForce to calculate the forces acting on the system and the energy of the system.
*/
class ReferenceCalcAmoebaPiTorsionForceKernel : public CalcAmoebaPiTorsionForceKernel {
public:
ReferenceCalcAmoebaPiTorsionForceKernel(std::string name, const Platform& platform, System& system);
~ReferenceCalcAmoebaPiTorsionForceKernel();
/**
* Initialize the kernel.
*
* @param system the System this kernel will be applied to
* @param force the AmoebaPiTorsionForce this kernel will be used for
*/
void initialize(const System& system, const AmoebaPiTorsionForce& force);
/**
* Execute the kernel to calculate the forces and/or energy.
*
* @param context the context in which to execute this kernel
* @param includeForces true if forces should be calculated
* @param includeEnergy true if the energy should be calculated
* @return the potential energy due to the force
*/
double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
private:
int numPiTorsions;
std::vector particle1;
std::vector particle2;
std::vector particle3;
std::vector particle4;
std::vector particle5;
std::vector particle6;
std::vector kTorsion;
System& system;
};
/**
* This kernel is invoked by AmoebaStretchBendForce to calculate the forces acting on the system and the energy of the system.
*/
class ReferenceCalcAmoebaStretchBendForceKernel : public CalcAmoebaStretchBendForceKernel {
public:
ReferenceCalcAmoebaStretchBendForceKernel(std::string name, const Platform& platform, System& system);
~ReferenceCalcAmoebaStretchBendForceKernel();
/**
* Initialize the kernel.
*
* @param system the System this kernel will be applied to
* @param force the AmoebaStretchBendForce this kernel will be used for
*/
void initialize(const System& system, const AmoebaStretchBendForce& force);
/**
* Execute the kernel to calculate the forces and/or energy.
*
* @param context the context in which to execute this kernel
* @param includeForces true if forces should be calculated
* @param includeEnergy true if the energy should be calculated
* @return the potential energy due to the force
*/
double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
private:
int numStretchBends;
std::vector particle1;
std::vector particle2;
std::vector particle3;
std::vector lengthABParameters;
std::vector lengthCBParameters;
std::vector angleParameters;
std::vector kParameters;
System& system;
};
/**
* This kernel is invoked by AmoebaOutOfPlaneBendForce to calculate the forces acting on the system and the energy of the system.
*/
class ReferenceCalcAmoebaOutOfPlaneBendForceKernel : public CalcAmoebaOutOfPlaneBendForceKernel {
public:
ReferenceCalcAmoebaOutOfPlaneBendForceKernel(std::string name, const Platform& platform, System& system);
~ReferenceCalcAmoebaOutOfPlaneBendForceKernel();
/**
* Initialize the kernel.
*
* @param system the System this kernel will be applied to
* @param force the AmoebaOutOfPlaneBendForce this kernel will be used for
*/
void initialize(const System& system, const AmoebaOutOfPlaneBendForce& force);
/**
* Execute the kernel to calculate the forces and/or energy.
*
* @param context the context in which to execute this kernel
* @param includeForces true if forces should be calculated
* @param includeEnergy true if the energy should be calculated
* @return the potential energy due to the force
*/
double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
private:
int numOutOfPlaneBends;
std::vector particle1;
std::vector particle2;
std::vector particle3;
std::vector particle4;
std::vector kParameters;
RealOpenMM globalOutOfPlaneBendAngleCubic;
RealOpenMM globalOutOfPlaneBendAngleQuartic;
RealOpenMM globalOutOfPlaneBendAnglePentic;
RealOpenMM globalOutOfPlaneBendAngleSextic;
System& system;
};
/**
* This kernel is invoked by AmoebaTorsionTorsionForce to calculate the forces acting on the system and the energy of the system.
*/
class ReferenceCalcAmoebaTorsionTorsionForceKernel : public CalcAmoebaTorsionTorsionForceKernel {
public:
ReferenceCalcAmoebaTorsionTorsionForceKernel(std::string name, const Platform& platform, System& system);
~ReferenceCalcAmoebaTorsionTorsionForceKernel();
/**
* Initialize the kernel.
*
* @param system the System this kernel will be applied to
* @param force the AmoebaTorsionTorsionForce this kernel will be used for
*/
void initialize(const System& system, const AmoebaTorsionTorsionForce& force);
/**
* Execute the kernel to calculate the forces and/or energy.
*
* @param context the context in which to execute this kernel
* @param includeForces true if forces should be calculated
* @param includeEnergy true if the energy should be calculated
* @return the potential energy due to the force
*/
double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
private:
int numTorsionTorsions;
std::vector particle1;
std::vector particle2;
std::vector particle3;
std::vector particle4;
std::vector particle5;
std::vector chiralCheckAtom;
std::vector gridIndices;
int numTorsionTorsionGrids;
std::vector< std::vector< std::vector< std::vector > > > torsionTorsionGrids;
System& 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 {
public:
ReferenceCalcAmoebaMultipoleForceKernel(std::string name, const Platform& platform, System& system);
~ReferenceCalcAmoebaMultipoleForceKernel();
/**
* Initialize the kernel.
*
* @param system the System this kernel will be applied to
* @param force the AmoebaMultipoleForce this kernel will be used for
*/
void initialize(const System& system, const AmoebaMultipoleForce& force);
/**
* Execute the kernel to calculate the forces and/or energy.
*
* @param context the context in which to execute this kernel
* @param includeForces true if forces should be calculated
* @param includeEnergy true if the energy should be calculated
* @return the potential energy due to the force
*/
double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
/**
* Execute the kernel to calculate the electrostatic potential
*
* @param context the context in which to execute this kernel
* @param inputGrid input grid coordinates
* @param outputElectrostaticPotential output potential
*/
void getElectrostaticPotential(ContextImpl& context, const std::vector< Vec3 >& inputGrid,
std::vector< double >& outputElectrostaticPotential );
/**
* Get the system multipole moments
*
* @param context context
* @param outputMultipoleMonents (charge,
dipole_x, dipole_y, dipole_z,
quadrupole_xx, quadrupole_xy, quadrupole_xz,
quadrupole_yx, quadrupole_yy, quadrupole_yz,
quadrupole_zx, quadrupole_zy, quadrupole_zz )
*/
void getSystemMultipoleMoments(ContextImpl& context, std::vector< double >& outputMultipoleMonents);
private:
int numMultipoles;
AmoebaMultipoleForce::PolarizationType polarizationType;
std::vector charges;
std::vector dipoles;
std::vector quadrupoles;
std::vector tholes;
std::vector dampingFactors;
std::vector polarity;
std::vector axisTypes;
std::vector multipoleAtomZs;
std::vector multipoleAtomXs;
std::vector multipoleAtomYs;
std::vector< std::vector< std::vector > > multipoleAtomCovalentInfo;
//int iterativeMethod;
int nonbondedMethod;
int mutualInducedMaxIterations;
RealOpenMM mutualInducedTargetEpsilon;
System& system;
};
/**
* This kernel is invoked to calculate the vdw forces acting on the system and the energy of the system.
*/
class ReferenceCalcAmoebaVdwForceKernel : public CalcAmoebaVdwForceKernel {
public:
ReferenceCalcAmoebaVdwForceKernel(std::string name, const Platform& platform, System& system);
~ReferenceCalcAmoebaVdwForceKernel();
/**
* Initialize the kernel.
*
* @param system the System this kernel will be applied to
* @param force the AmoebaVdwForce this kernel will be used for
*/
void initialize(const System& system, const AmoebaVdwForce& force);
/**
* Execute the kernel to calculate the forces and/or energy.
*
* @param context the context in which to execute this kernel
* @param includeForces true if forces should be calculated
* @param includeEnergy true if the energy should be calculated
* @return the potential energy due to the force
*/
double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
private:
int numParticles;
int useCutoff;
int usePBC;
double cutoff;
double dispersionCoefficient;
std::vector indexIVs;
std::vector< std::set > allExclusions;
std::vector sigmas;
std::vector epsilons;
std::vector reductions;
std::string sigmaCombiningRule;
std::string epsilonCombiningRule;
System& system;
NeighborList* neighborList;
};
/**
* This kernel is invoked to calculate the WCA dispersion forces acting on the system and the energy of the system.
*/
class ReferenceCalcAmoebaWcaDispersionForceKernel : public CalcAmoebaWcaDispersionForceKernel {
public:
ReferenceCalcAmoebaWcaDispersionForceKernel(std::string name, const Platform& platform, System& system);
~ReferenceCalcAmoebaWcaDispersionForceKernel();
/**
* Initialize the kernel.
*
* @param system the System this kernel will be applied to
* @param force the AmoebaMultipoleForce this kernel will be used for
*/
void initialize(const System& system, const AmoebaWcaDispersionForce& force);
/**
* Execute the kernel to calculate the forces and/or energy.
*
* @param context the context in which to execute this kernel
* @param includeForces true if forces should be calculated
* @param includeEnergy true if the energy should be calculated
* @return the potential energy due to the force
*/
double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
private:
int numParticles;
std::vector radii;
std::vector epsilons;
RealOpenMM epso;
RealOpenMM epsh;
RealOpenMM rmino;
RealOpenMM rminh;
RealOpenMM awater;
RealOpenMM shctd;
RealOpenMM dispoff;
RealOpenMM slevy;
RealOpenMM totalMaximumDispersionEnergy;
System& system;
};
/**
* This kernel is invoked to calculate the Gerneralized Kirkwood forces acting on the system and the energy of the system.
*/
class ReferenceCalcAmoebaGeneralizedKirkwoodForceKernel : public CalcAmoebaGeneralizedKirkwoodForceKernel {
public:
ReferenceCalcAmoebaGeneralizedKirkwoodForceKernel(std::string name, const Platform& platform, System& system);
~ReferenceCalcAmoebaGeneralizedKirkwoodForceKernel();
/**
* Initialize the kernel.
*
* @param system the System this kernel will be applied to
* @param force the AmoebaMultipoleForce this kernel will be used for
*/
void initialize(const System& system, const AmoebaGeneralizedKirkwoodForce& force);
/**
* Execute the kernel to calculate the forces and/or energy.
*
* @param context the context in which to execute this kernel
* @param includeForces true if forces should be calculated
* @param includeEnergy true if the energy should be calculated
* @return the potential energy due to the force
*/
double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
/**
* Get include-cavity term flag
*
* @return includeCavityTerm
*/
int getIncludeCavityTerm( void ) const;
/**
* Get number of particles
*
* @return number of particles
*/
int getNumParticles( void ) const;
/**
* Get directPolarization flag
*
* @return directPolarization
*
*/
int getDirectPolarization( void ) const;
/**
* Get solute dielectric
*
* @return soluteDielectric
*
*/
RealOpenMM getSoluteDielectric( void ) const;
/**
* Get solvent dielectric
*
* @return solventDielectric
*
*/
RealOpenMM getSolventDielectric( void ) const;
/**
* Get dielectric offset
*
* @return dielectricOffset
*
*/
RealOpenMM getDielectricOffset( void ) const;
/**
* Get probeRadius
*
* @return probeRadius
*
*/
RealOpenMM getProbeRadius( void ) const;
/**
* Get surfaceAreaFactor
*
* @return surfaceAreaFactor
*
*/
RealOpenMM getSurfaceAreaFactor( void ) const;
/**
* Get atomic radii
*
* @param atomicRadii vector of atomic radii
*
*/
void getAtomicRadii( std::vector& atomicRadii ) const;
/**
* Get scale factors
*
* @param scaleFactors vector of scale factors
*
*/
void getScaleFactors( std::vector& scaleFactors ) const;
/**
* Get charges
*
* @param charges vector of charges
*
*/
void getCharges( std::vector& charges ) const;
private:
int numParticles;
std::vector atomicRadii;
std::vector scaleFactors;
std::vector charges;
RealOpenMM soluteDielectric;
RealOpenMM solventDielectric;
RealOpenMM dielectricOffset;
RealOpenMM probeRadius;
RealOpenMM surfaceAreaFactor;
int includeCavityTerm;
int directPolarization;
System& system;
};
} // namespace OpenMM
#endif /*AMOEBA_OPENMM_REFERENCE_KERNELS_H*/