All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
NonbondedForce.h
#ifndef OPENMM_NONBONDEDFORCE_H_
#define OPENMM_NONBONDEDFORCE_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "Context.h"
#include "Force.h"
#include <map>
#include <set>
#include <utility>
#include <vector>
#include "internal/windowsExport.h"
namespace OpenMM {
class OPENMM_EXPORT NonbondedForce : public Force {
public:
enum NonbondedMethod {
NoCutoff = 0,
CutoffNonPeriodic = 1,
CutoffPeriodic = 2,
Ewald = 3,
PME = 4
};
NonbondedForce();
int getNumParticles() const {
return particles.size();
}
int getNumExceptions() const {
return exceptions.size();
}
NonbondedMethod getNonbondedMethod() const;
void setNonbondedMethod(NonbondedMethod method);
double getCutoffDistance() const;
void setCutoffDistance(double distance);
bool getUseSwitchingFunction() const;
void setUseSwitchingFunction(bool use);
double getSwitchingDistance() const;
void setSwitchingDistance(double distance);
double getReactionFieldDielectric() const;
void setReactionFieldDielectric(double dielectric);
double getEwaldErrorTolerance() const;
void setEwaldErrorTolerance(double tol);
void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const;
void setPMEParameters(double alpha, int nx, int ny, int nz);
int addParticle(double charge, double sigma, double epsilon);
void getParticleParameters(int index, double& charge, double& sigma, double& epsilon) const;
void setParticleParameters(int index, double charge, double sigma, double epsilon);
int addException(int particle1, int particle2, double chargeProd, double sigma, double epsilon, bool replace = false);
void getExceptionParameters(int index, int& particle1, int& particle2, double& chargeProd, double& sigma, double& epsilon) const;
void setExceptionParameters(int index, int particle1, int particle2, double chargeProd, double sigma, double epsilon);
void createExceptionsFromBonds(const std::vector<std::pair<int, int> >& bonds, double coulomb14Scale, double lj14Scale);
bool getUseDispersionCorrection() const {
return useDispersionCorrection;
}
void setUseDispersionCorrection(bool useCorrection) {
useDispersionCorrection = useCorrection;
}
int getReciprocalSpaceForceGroup() const;
void setReciprocalSpaceForceGroup(int group);
void updateParametersInContext(Context& context);
bool usesPeriodicBoundaryConditions() const {
return nonbondedMethod == NonbondedForce::CutoffPeriodic ||
nonbondedMethod == NonbondedForce::Ewald ||
nonbondedMethod == NonbondedForce::PME;
}
protected:
ForceImpl* createImpl() const;
private:
class ParticleInfo;
class ExceptionInfo;
NonbondedMethod nonbondedMethod;
double cutoffDistance, switchingDistance, rfDielectric, ewaldErrorTol, alpha;
bool useSwitchingFunction, useDispersionCorrection;
int recipForceGroup, nx, ny, nz;
void addExclusionsToSet(const std::vector<std::set<int> >& bonded12, std::set<int>& exclusions, int baseParticle, int fromParticle, int currentLevel) const;
std::vector<ParticleInfo> particles;
std::vector<ExceptionInfo> exceptions;
std::map<std::pair<int, int>, int> exceptionMap;
};
class NonbondedForce::ParticleInfo {
public:
double charge, sigma, epsilon;
ParticleInfo() {
charge = sigma = epsilon = 0.0;
}
ParticleInfo(double charge, double sigma, double epsilon) :
charge(charge), sigma(sigma), epsilon(epsilon) {
}
};
class NonbondedForce::ExceptionInfo {
public:
int particle1, particle2;
double chargeProd, sigma, epsilon;
ExceptionInfo() {
particle1 = particle2 = -1;
chargeProd = sigma = epsilon = 0.0;
}
ExceptionInfo(int particle1, int particle2, double chargeProd, double sigma, double epsilon) :
particle1(particle1), particle2(particle2), chargeProd(chargeProd), sigma(sigma), epsilon(epsilon) {
}
};
} // namespace OpenMM
#endif /*OPENMM_NONBONDEDFORCE_H_*/
OpenMM::Context
A Context stores the complete state of a simulation.
Definition: Context.h:67
OpenMM::NonbondedForce::CutoffPeriodic
Periodic boundary conditions are used, so that each particle interacts only with the nearest periodic...
Definition: NonbondedForce.h:102
OpenMM::NonbondedForce::Ewald
Periodic boundary conditions are used, and Ewald summation is used to compute the interaction of each...
Definition: NonbondedForce.h:107
OpenMM::NonbondedForce::PME
Periodic boundary conditions are used, and Particle-Mesh Ewald (PME) summation is used to compute the...
Definition: NonbondedForce.h:112
OpenMM::NonbondedForce::getUseDispersionCorrection
bool getUseDispersionCorrection() const
Get whether to add a contribution to the energy that approximately represents the effect of Lennard-J...
Definition: NonbondedForce.h:313
OpenMM::Force
Force objects apply forces to the particles in a System, or alter their behavior in other ways...
Definition: Force.h:65
OpenMM::NonbondedForce::setUseDispersionCorrection
void setUseDispersionCorrection(bool useCorrection)
Set whether to add a contribution to the energy that approximately represents the effect of Lennard-J...
Definition: NonbondedForce.h:322
OpenMM::NonbondedForce::getNumExceptions
int getNumExceptions() const
Get the number of special interactions that should be calculated differently from other interactions...
Definition: NonbondedForce.h:127
OpenMM::NonbondedForce::getNumParticles
int getNumParticles() const
Get the number of particles for which force field parameters have been defined.
Definition: NonbondedForce.h:121
OpenMM::NonbondedForce::usesPeriodicBoundaryConditions
bool usesPeriodicBoundaryConditions() const
Returns whether or not this force makes use of periodic boundary conditions.
Definition: NonbondedForce.h:361
OpenMM::NonbondedForce::NonbondedMethod
NonbondedMethod
This is an enumeration of the different methods that may be used for handling long range nonbonded fo...
Definition: NonbondedForce.h:86
OpenMM::NonbondedForce
This class implements nonbonded interactions between particles, including a Coulomb force to represen...
Definition: NonbondedForce.h:81
OpenMM
Definition: AndersenThermostat.h:40