All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
CustomManyParticleForce.h
#ifndef OPENMM_CUSTOMTHREEBODYFORCE_H_
#define OPENMM_CUSTOMTHREEBODYFORCE_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 "Force.h"
#include "TabulatedFunction.h"
#include "internal/windowsExport.h"
#include <set>
#include <string>
#include <vector>
namespace OpenMM {
class OPENMM_EXPORT CustomManyParticleForce : public Force {
public:
enum NonbondedMethod {
NoCutoff = 0,
CutoffNonPeriodic = 1,
CutoffPeriodic = 2,
};
enum PermutationMode {
SinglePermutation = 0,
UniqueCentralParticle = 1
};
explicit CustomManyParticleForce(int particlesPerSet, const std::string& energy);
~CustomManyParticleForce();
int getNumParticlesPerSet() const {
return particlesPerSet;
}
int getNumParticles() const {
return particles.size();
}
int getNumExclusions() const {
return exclusions.size();
}
int getNumPerParticleParameters() const {
return particleParameters.size();
}
int getNumGlobalParameters() const {
return globalParameters.size();
}
int getNumTabulatedFunctions() const {
return functions.size();
}
const std::string& getEnergyFunction() const;
void setEnergyFunction(const std::string& energy);
NonbondedMethod getNonbondedMethod() const;
void setNonbondedMethod(NonbondedMethod method);
PermutationMode getPermutationMode() const;
void setPermutationMode(PermutationMode mode);
double getCutoffDistance() const;
void setCutoffDistance(double distance);
int addPerParticleParameter(const std::string& name);
const std::string& getPerParticleParameterName(int index) const;
void setPerParticleParameterName(int index, const std::string& name);
int addGlobalParameter(const std::string& name, double defaultValue);
const std::string& getGlobalParameterName(int index) const;
void setGlobalParameterName(int index, const std::string& name);
double getGlobalParameterDefaultValue(int index) const;
void setGlobalParameterDefaultValue(int index, double defaultValue);
int addParticle(const std::vector<double>& parameters, int type=0);
void getParticleParameters(int index, std::vector<double>& parameters, int& type) const;
void setParticleParameters(int index, const std::vector<double>& parameters, int type);
int addExclusion(int particle1, int particle2);
void getExclusionParticles(int index, int& particle1, int& particle2) const;
void setExclusionParticles(int index, int particle1, int particle2);
void createExclusionsFromBonds(const std::vector<std::pair<int, int> >& bonds, int bondCutoff);
void getTypeFilter(int index, std::set<int>& types) const;
void setTypeFilter(int index, const std::set<int>& types);
int addTabulatedFunction(const std::string& name, TabulatedFunction* function);
const TabulatedFunction& getTabulatedFunction(int index) const;
TabulatedFunction& getTabulatedFunction(int index);
const std::string& getTabulatedFunctionName(int index) const;
void updateParametersInContext(Context& context);
bool usesPeriodicBoundaryConditions() const {
return nonbondedMethod == CustomManyParticleForce::CutoffPeriodic;
}
protected:
ForceImpl* createImpl() const;
private:
class ParticleInfo;
class ParticleParameterInfo;
class GlobalParameterInfo;
class ExclusionInfo;
class FunctionInfo;
int particlesPerSet;
NonbondedMethod nonbondedMethod;
PermutationMode permutationMode;
double cutoffDistance;
std::string energyExpression;
std::vector<ParticleParameterInfo> particleParameters;
std::vector<GlobalParameterInfo> globalParameters;
std::vector<ParticleInfo> particles;
std::vector<ExclusionInfo> exclusions;
std::vector<FunctionInfo> functions;
std::vector<std::set<int> > typeFilters;
};
class CustomManyParticleForce::ParticleInfo {
public:
std::vector<double> parameters;
int type;
ParticleInfo() {
}
ParticleInfo(const std::vector<double>& parameters, int type) : parameters(parameters), type(type) {
}
};
class CustomManyParticleForce::ParticleParameterInfo {
public:
std::string name;
ParticleParameterInfo() {
}
ParticleParameterInfo(const std::string& name) : name(name) {
}
};
class CustomManyParticleForce::GlobalParameterInfo {
public:
std::string name;
double defaultValue;
GlobalParameterInfo() {
}
GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
}
};
class CustomManyParticleForce::ExclusionInfo {
public:
int particle1, particle2;
ExclusionInfo() {
particle1 = particle2 = -1;
}
ExclusionInfo(int particle1, int particle2) :
particle1(particle1), particle2(particle2) {
}
};
class CustomManyParticleForce::FunctionInfo {
public:
std::string name;
TabulatedFunction* function;
FunctionInfo() {
}
FunctionInfo(const std::string& name, TabulatedFunction* function) : name(name), function(function) {
}
};
} // namespace OpenMM
#endif /*OPENMM_CUSTOMTHREEBODYFORCE_H_*/
OpenMM::CustomManyParticleForce::getNumParticles
int getNumParticles() const
Get the number of particles for which force field parameters have been defined.
Definition: CustomManyParticleForce.h:221
OpenMM::CustomManyParticleForce::getNumExclusions
int getNumExclusions() const
Get the number of particle pairs whose interactions should be excluded.
Definition: CustomManyParticleForce.h:227
OpenMM::CustomManyParticleForce::getNumPerParticleParameters
int getNumPerParticleParameters() const
Get the number of per-particle parameters that the interaction depends on.
Definition: CustomManyParticleForce.h:233
OpenMM::TabulatedFunction
A TabulatedFunction uses a set of tabulated values to define a mathematical function.
Definition: TabulatedFunction.h:58
OpenMM::Context
A Context stores the complete state of a simulation.
Definition: Context.h:67
OpenMM::CustomManyParticleForce::PermutationMode
PermutationMode
This is an enumeration of the different modes for selecting which permutations of a set of particles ...
Definition: CustomManyParticleForce.h:187
OpenMM::CustomManyParticleForce::getNumTabulatedFunctions
int getNumTabulatedFunctions() const
Get the number of tabulated functions that have been defined.
Definition: CustomManyParticleForce.h:245
OpenMM::CustomManyParticleForce::NonbondedMethod
NonbondedMethod
This is an enumeration of the different methods that may be used for handling long range nonbonded fo...
Definition: CustomManyParticleForce.h:167
OpenMM::CustomManyParticleForce::getNumParticlesPerSet
int getNumParticlesPerSet() const
Get the number of particles in each set for which the energy is evaluated.
Definition: CustomManyParticleForce.h:215
OpenMM::Force
Force objects apply forces to the particles in a System, or alter their behavior in other ways...
Definition: Force.h:65
OpenMM::CustomManyParticleForce::CutoffPeriodic
Periodic boundary conditions are used, so that each particle interacts only with the nearest periodic...
Definition: CustomManyParticleForce.h:181
OpenMM::CustomManyParticleForce::usesPeriodicBoundaryConditions
bool usesPeriodicBoundaryConditions() const
Returns whether or not this force makes use of periodic boundary conditions.
Definition: CustomManyParticleForce.h:470
OpenMM
Definition: AndersenThermostat.h:40
OpenMM::CustomManyParticleForce
This class supports a wide variety of nonbonded N-particle interactions, where N is user specified...
Definition: CustomManyParticleForce.h:162
OpenMM::CustomManyParticleForce::getNumGlobalParameters
int getNumGlobalParameters() const
Get the number of global parameters that the interaction depends on.
Definition: CustomManyParticleForce.h:239