OpenMM

- Main Page
- Related Pages
- Classes

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
CustomNonbondedForce.h
1 #ifndef OPENMM_CUSTOMNONBONDEDFORCE_H_
2 #define OPENMM_CUSTOMNONBONDEDFORCE_H_
3
4 /* -------------------------------------------------------------------------- *
5 * OpenMM *
6 * -------------------------------------------------------------------------- *
7 * This is part of the OpenMM molecular simulation toolkit originating from *
8 * Simbios, the NIH National Center for Physics-Based Simulation of *
9 * Biological Structures at Stanford, funded under the NIH Roadmap for *
10 * Medical Research, grant U54 GM072970. See https://simtk.org. *
11 * *
12 * Portions copyright (c) 2008-2014 Stanford University and the Authors. *
13 * Authors: Peter Eastman *
14 * Contributors: *
15 * *
16 * Permission is hereby granted, free of charge, to any person obtaining a *
17 * copy of this software and associated documentation files (the "Software"), *
18 * to deal in the Software without restriction, including without limitation *
19 * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
20 * and/or sell copies of the Software, and to permit persons to whom the *
21 * Software is furnished to do so, subject to the following conditions: *
22 * *
23 * The above copyright notice and this permission notice shall be included in *
24 * all copies or substantial portions of the Software. *
25 * *
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
27 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
28 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
29 * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
30 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
31 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
32 * USE OR OTHER DEALINGS IN THE SOFTWARE. *
33 * -------------------------------------------------------------------------- */
34
35 #include "TabulatedFunction.h"
36 #include "Force.h"
37 #include "Vec3.h"
38 #include <map>
39 #include <set>
40 #include <utility>
41 #include <vector>
42 #include "internal/windowsExport.h"
43
44 namespace OpenMM {
45
133 class OPENMM_EXPORT CustomNonbondedForce : public Force {
134 public:
138 enum NonbondedMethod {
143 NoCutoff = 0,
147 CutoffNonPeriodic = 1,
152 CutoffPeriodic = 2,
153 };
160 explicit CustomNonbondedForce(const std::string& energy);
161 CustomNonbondedForce(const CustomNonbondedForce& rhs); // copy constructor
162 ~CustomNonbondedForce();
166 int getNumParticles() const {
167 return particles.size();
168 }
172 int getNumExclusions() const {
173 return exclusions.size();
174 }
178 int getNumPerParticleParameters() const {
179 return parameters.size();
180 }
184 int getNumGlobalParameters() const {
185 return globalParameters.size();
186 }
190 int getNumTabulatedFunctions() const {
191 return functions.size();
192 }
198 int getNumFunctions() const {
199 return functions.size();
200 }
204 int getNumInteractionGroups() const {
205 return interactionGroups.size();
206 }
210 const std::string& getEnergyFunction() const;
214 void setEnergyFunction(const std::string& energy);
218 NonbondedMethod getNonbondedMethod() const;
222 void setNonbondedMethod(NonbondedMethod method);
229 double getCutoffDistance() const;
236 void setCutoffDistance(double distance);
241 bool getUseSwitchingFunction() const;
246 void setUseSwitchingFunction(bool use);
251 double getSwitchingDistance() const;
256 void setSwitchingDistance(double distance);
261 bool getUseLongRangeCorrection() const;
266 void setUseLongRangeCorrection(bool use);
273 int addPerParticleParameter(const std::string& name);
280 const std::string& getPerParticleParameterName(int index) const;
287 void setPerParticleParameterName(int index, const std::string& name);
295 int addGlobalParameter(const std::string& name, double defaultValue);
302 const std::string& getGlobalParameterName(int index) const;
309 void setGlobalParameterName(int index, const std::string& name);
316 double getGlobalParameterDefaultValue(int index) const;
323 void setGlobalParameterDefaultValue(int index, double defaultValue);
331 int addParticle(const std::vector<double>& parameters);
338 void getParticleParameters(int index, std::vector<double>& parameters) const;
345 void setParticleParameters(int index, const std::vector<double>& parameters);
355 int addExclusion(int particle1, int particle2);
363 void getExclusionParticles(int index, int& particle1, int& particle2) const;
371 void setExclusionParticles(int index, int particle1, int particle2);
380 void createExclusionsFromBonds(const std::vector<std::pair<int, int> >& bonds, int bondCutoff);
390 int addTabulatedFunction(const std::string& name, TabulatedFunction* function);
397 const TabulatedFunction& getTabulatedFunction(int index) const;
404 TabulatedFunction& getTabulatedFunction(int index);
411 const std::string& getTabulatedFunctionName(int index) const;
417 int addFunction(const std::string& name, const std::vector<double>& values, double min, double max);
424 void getFunctionParameters(int index, std::string& name, std::vector<double>& values, double& min, double& max) const;
431 void setFunctionParameters(int index, const std::string& name, const std::vector<double>& values, double min, double max);
439 int addInteractionGroup(const std::set<int>& set1, const std::set<int>& set2);
447 void getInteractionGroupParameters(int index, std::set<int>& set1, std::set<int>& set2) const;
455 void setInteractionGroupParameters(int index, const std::set<int>& set1, const std::set<int>& set2);
467 void updateParametersInContext(Context& context);
474 bool usesPeriodicBoundaryConditions() const {
475 return nonbondedMethod == CustomNonbondedForce::CutoffPeriodic;
476 }
477 protected:
478 ForceImpl* createImpl() const;
479 private:
480 // REMEMBER TO UPDATE THE COPY CONSTRUCTOR IF YOU ADD ANY NEW FIELDS !!
481 class ParticleInfo;
482 class PerParticleParameterInfo;
483 class GlobalParameterInfo;
484 class ExclusionInfo;
485 class FunctionInfo;
486 class InteractionGroupInfo;
487 NonbondedMethod nonbondedMethod;
488 double cutoffDistance, switchingDistance;
489 bool useSwitchingFunction, useLongRangeCorrection;
490 std::string energyExpression;
491 std::vector<PerParticleParameterInfo> parameters;
492 std::vector<GlobalParameterInfo> globalParameters;
493 std::vector<ParticleInfo> particles;
494 std::vector<ExclusionInfo> exclusions;
495 std::vector<FunctionInfo> functions;
496 std::vector<InteractionGroupInfo> interactionGroups;
497 };
498
503 class CustomNonbondedForce::ParticleInfo {
504 public:
505 std::vector<double> parameters;
506 ParticleInfo() {
507 }
508 ParticleInfo(const std::vector<double>& parameters) : parameters(parameters) {
509 }
510 };
511
516 class CustomNonbondedForce::PerParticleParameterInfo {
517 public:
518 std::string name;
519 PerParticleParameterInfo() {
520 }
521 PerParticleParameterInfo(const std::string& name) : name(name) {
522 }
523 };
524
529 class CustomNonbondedForce::GlobalParameterInfo {
530 public:
531 std::string name;
532 double defaultValue;
533 GlobalParameterInfo() {
534 }
535 GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
536 }
537 };
538
543 class CustomNonbondedForce::ExclusionInfo {
544 public:
545 int particle1, particle2;
546 ExclusionInfo() {
547 particle1 = particle2 = -1;
548 }
549 ExclusionInfo(int particle1, int particle2) :
550 particle1(particle1), particle2(particle2) {
551 }
552 };
553
558 class CustomNonbondedForce::FunctionInfo {
559 public:
560 std::string name;
561 TabulatedFunction* function;
562 FunctionInfo() {
563 }
564 FunctionInfo(const std::string& name, TabulatedFunction* function) : name(name), function(function) {
565 }
566 };
567
572 class CustomNonbondedForce::InteractionGroupInfo {
573 public:
574 std::set<int> set1, set2;
575 InteractionGroupInfo() {
576 }
577 InteractionGroupInfo(const std::set<int>& set1, const std::set<int>& set2) :
578 set1(set1), set2(set2) {
579 }
580 };
581
582 } // namespace OpenMM
583
584 #endif /*OPENMM_CUSTOMNONBONDEDFORCE_H_*/
OpenMM::CustomNonbondedForce::getNumGlobalParameters
int getNumGlobalParameters() const
Get the number of global parameters that the interaction depends on.
Definition: CustomNonbondedForce.h:184
OpenMM::TabulatedFunction
A TabulatedFunction uses a set of tabulated values to define a mathematical function.
Definition: TabulatedFunction.h:58
OpenMM::CustomNonbondedForce::usesPeriodicBoundaryConditions
bool usesPeriodicBoundaryConditions() const
Returns whether or not this force makes use of periodic boundary conditions.
Definition: CustomNonbondedForce.h:474
OpenMM::CustomNonbondedForce::getNumFunctions
int getNumFunctions() const
Get the number of tabulated functions that have been defined.
Definition: CustomNonbondedForce.h:198
OpenMM::Context
A Context stores the complete state of a simulation.
Definition: Context.h:67
OpenMM::CustomNonbondedForce::getNumExclusions
int getNumExclusions() const
Get the number of particle pairs whose interactions should be excluded.
Definition: CustomNonbondedForce.h:172
OpenMM::CustomNonbondedForce::getNumPerParticleParameters
int getNumPerParticleParameters() const
Get the number of per-particle parameters that the interaction depends on.
Definition: CustomNonbondedForce.h:178
OpenMM::CustomNonbondedForce::CutoffPeriodic
Periodic boundary conditions are used, so that each particle interacts only with the nearest periodic...
Definition: CustomNonbondedForce.h:152
OpenMM::Force
Force objects apply forces to the particles in a System, or alter their behavior in other ways...
Definition: Force.h:65
OpenMM::CustomNonbondedForce::getNumTabulatedFunctions
int getNumTabulatedFunctions() const
Get the number of tabulated functions that have been defined.
Definition: CustomNonbondedForce.h:190
OpenMM::CustomNonbondedForce::getNumInteractionGroups
int getNumInteractionGroups() const
Get the number of interaction groups that have been defined.
Definition: CustomNonbondedForce.h:204
OpenMM::CustomNonbondedForce::getNumParticles
int getNumParticles() const
Get the number of particles for which force field parameters have been defined.
Definition: CustomNonbondedForce.h:166
OpenMM::CustomNonbondedForce::NonbondedMethod
NonbondedMethod
This is an enumeration of the different methods that may be used for handling long range nonbonded fo...
Definition: CustomNonbondedForce.h:138
OpenMM
Definition: AndersenThermostat.h:40
OpenMM::CustomNonbondedForce
This class implements nonbonded interactions between particles.
Definition: CustomNonbondedForce.h:133