OpenMM
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
CustomGBForce.h
1 #ifndef OPENMM_CUSTOMGBFORCE_H_
2 #define OPENMM_CUSTOMGBFORCE_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 
142 class OPENMM_EXPORT CustomGBForce : public Force {
143 public:
152  NoCutoff = 0,
156  CutoffNonPeriodic = 1,
161  CutoffPeriodic = 2,
162  };
170  SingleParticle = 0,
174  ParticlePair = 1,
179  ParticlePairNoExclusions = 2
180  };
184  CustomGBForce();
185  ~CustomGBForce();
189  int getNumParticles() const {
190  return particles.size();
191  }
195  int getNumExclusions() const {
196  return exclusions.size();
197  }
202  return parameters.size();
203  }
208  return globalParameters.size();
209  }
214  return functions.size();
215  }
221  int getNumFunctions() const {
222  return functions.size();
223  }
227  int getNumComputedValues() const {
228  return computedValues.size();
229  }
233  int getNumEnergyTerms() const {
234  return energyTerms.size();
235  }
239  NonbondedMethod getNonbondedMethod() const;
243  void setNonbondedMethod(NonbondedMethod method);
250  double getCutoffDistance() const;
257  void setCutoffDistance(double distance);
264  int addPerParticleParameter(const std::string& name);
271  const std::string& getPerParticleParameterName(int index) const;
278  void setPerParticleParameterName(int index, const std::string& name);
286  int addGlobalParameter(const std::string& name, double defaultValue);
293  const std::string& getGlobalParameterName(int index) const;
300  void setGlobalParameterName(int index, const std::string& name);
307  double getGlobalParameterDefaultValue(int index) const;
314  void setGlobalParameterDefaultValue(int index, double defaultValue);
322  int addParticle(const std::vector<double>& parameters);
329  void getParticleParameters(int index, std::vector<double>& parameters) const;
336  void setParticleParameters(int index, const std::vector<double>& parameters);
353  int addComputedValue(const std::string& name, const std::string& expression, ComputationType type);
371  void getComputedValueParameters(int index, std::string& name, std::string& expression, ComputationType& type) const;
389  void setComputedValueParameters(int index, const std::string& name, const std::string& expression, ComputationType type);
405  int addEnergyTerm(const std::string& expression, ComputationType type);
422  void getEnergyTermParameters(int index, std::string& expression, ComputationType& type) const;
439  void setEnergyTermParameters(int index, const std::string& expression, ComputationType type);
447  int addExclusion(int particle1, int particle2);
455  void getExclusionParticles(int index, int& particle1, int& particle2) const;
463  void setExclusionParticles(int index, int particle1, int particle2);
473  int addTabulatedFunction(const std::string& name, TabulatedFunction* function);
480  const TabulatedFunction& getTabulatedFunction(int index) const;
487  TabulatedFunction& getTabulatedFunction(int index);
494  const std::string& getTabulatedFunctionName(int index) const;
500  int addFunction(const std::string& name, const std::vector<double>& values, double min, double max);
507  void getFunctionParameters(int index, std::string& name, std::vector<double>& values, double& min, double& max) const;
514  void setFunctionParameters(int index, const std::string& name, const std::vector<double>& values, double min, double max);
525  void updateParametersInContext(Context& context);
533  return nonbondedMethod == CustomGBForce::CutoffPeriodic;
534  }
535 protected:
536  ForceImpl* createImpl() const;
537 private:
538  class ParticleInfo;
539  class PerParticleParameterInfo;
540  class GlobalParameterInfo;
541  class ExclusionInfo;
542  class FunctionInfo;
543  class ComputationInfo;
544  NonbondedMethod nonbondedMethod;
545  double cutoffDistance;
546  std::vector<PerParticleParameterInfo> parameters;
547  std::vector<GlobalParameterInfo> globalParameters;
548  std::vector<ParticleInfo> particles;
549  std::vector<ExclusionInfo> exclusions;
550  std::vector<FunctionInfo> functions;
551  std::vector<ComputationInfo> computedValues;
552  std::vector<ComputationInfo> energyTerms;
553 };
554 
559 class CustomGBForce::ParticleInfo {
560 public:
561  std::vector<double> parameters;
562  ParticleInfo() {
563  }
564  ParticleInfo(const std::vector<double>& parameters) : parameters(parameters) {
565  }
566 };
567 
572 class CustomGBForce::PerParticleParameterInfo {
573 public:
574  std::string name;
575  PerParticleParameterInfo() {
576  }
577  PerParticleParameterInfo(const std::string& name) : name(name) {
578  }
579 };
580 
585 class CustomGBForce::GlobalParameterInfo {
586 public:
587  std::string name;
588  double defaultValue;
589  GlobalParameterInfo() {
590  }
591  GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
592  }
593 };
594 
599 class CustomGBForce::ExclusionInfo {
600 public:
601  int particle1, particle2;
602  ExclusionInfo() {
603  particle1 = particle2 = -1;
604  }
605  ExclusionInfo(int particle1, int particle2) :
606  particle1(particle1), particle2(particle2) {
607  }
608 };
609 
614 class CustomGBForce::FunctionInfo {
615 public:
616  std::string name;
617  TabulatedFunction* function;
618  FunctionInfo() {
619  }
620  FunctionInfo(const std::string& name, TabulatedFunction* function) : name(name), function(function) {
621  }
622 };
623 
628 class CustomGBForce::ComputationInfo {
629 public:
630  std::string name;
631  std::string expression;
633  ComputationInfo() {
634  }
635  ComputationInfo(const std::string& name, const std::string& expression, CustomGBForce::ComputationType type) :
636  name(name), expression(expression), type(type) {
637  }
638 };
639 
640 } // namespace OpenMM
641 
642 #endif /*OPENMM_CUSTOMGBFORCE_H_*/
int getNumFunctions() const
Get the number of tabulated functions that have been defined.
Definition: CustomGBForce.h:221
A TabulatedFunction uses a set of tabulated values to define a mathematical function.
Definition: TabulatedFunction.h:58
A Context stores the complete state of a simulation.
Definition: Context.h:67
This class implements complex, multiple stage nonbonded interactions between particles.
Definition: CustomGBForce.h:142
bool usesPeriodicBoundaryConditions() const
Returns whether or not this force makes use of periodic boundary conditions.
Definition: CustomGBForce.h:532
Force objects apply forces to the particles in a System, or alter their behavior in other ways...
Definition: Force.h:65
int getNumTabulatedFunctions() const
Get the number of tabulated functions that have been defined.
Definition: CustomGBForce.h:213
int getNumEnergyTerms() const
Get the number of terms in the energy computation.
Definition: CustomGBForce.h:233
NonbondedMethod
This is an enumeration of the different methods that may be used for handling long range nonbonded fo...
Definition: CustomGBForce.h:147
Periodic boundary conditions are used, so that each particle interacts only with the nearest periodic...
Definition: CustomGBForce.h:161
int getNumExclusions() const
Get the number of particle pairs whose interactions should be excluded.
Definition: CustomGBForce.h:195
int getNumComputedValues() const
Get the number of per-particle computed values the interaction depends on.
Definition: CustomGBForce.h:227
int getNumParticles() const
Get the number of particles for which force field parameters have been defined.
Definition: CustomGBForce.h:189
int getNumPerParticleParameters() const
Get the number of per-particle parameters that the interaction depends on.
Definition: CustomGBForce.h:201
Definition: AndersenThermostat.h:40
ComputationType
This is an enumeration of the different ways in which a computed value or energy term can be calculat...
Definition: CustomGBForce.h:166
int getNumGlobalParameters() const
Get the number of global parameters that the interaction depends on.
Definition: CustomGBForce.h:207