OpenMM
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends
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-2012 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 "Force.h"
36 #include "Vec3.h"
37 #include <map>
38 #include <set>
39 #include <utility>
40 #include <vector>
41 #include "internal/windowsExport.h"
42 
43 namespace OpenMM {
44 
141 class OPENMM_EXPORT CustomGBForce : public Force {
142 public:
151  NoCutoff = 0,
155  CutoffNonPeriodic = 1,
160  CutoffPeriodic = 2,
161  };
169  SingleParticle = 0,
173  ParticlePair = 1,
178  ParticlePairNoExclusions = 2
179  };
183  CustomGBForce();
187  int getNumParticles() const {
188  return particles.size();
189  }
193  int getNumExclusions() const {
194  return exclusions.size();
195  }
200  return parameters.size();
201  }
206  return globalParameters.size();
207  }
211  int getNumFunctions() const {
212  return functions.size();
213  }
217  int getNumComputedValues() const {
218  return computedValues.size();
219  }
223  int getNumEnergyTerms() const {
224  return energyTerms.size();
225  }
229  NonbondedMethod getNonbondedMethod() const;
233  void setNonbondedMethod(NonbondedMethod method);
240  double getCutoffDistance() const;
247  void setCutoffDistance(double distance);
254  int addPerParticleParameter(const std::string& name);
261  const std::string& getPerParticleParameterName(int index) const;
268  void setPerParticleParameterName(int index, const std::string& name);
276  int addGlobalParameter(const std::string& name, double defaultValue);
283  const std::string& getGlobalParameterName(int index) const;
290  void setGlobalParameterName(int index, const std::string& name);
297  double getGlobalParameterDefaultValue(int index) const;
304  void setGlobalParameterDefaultValue(int index, double defaultValue);
312  int addParticle(const std::vector<double>& parameters);
319  void getParticleParameters(int index, std::vector<double>& parameters) const;
326  void setParticleParameters(int index, const std::vector<double>& parameters);
343  int addComputedValue(const std::string& name, const std::string& expression, ComputationType type);
361  void getComputedValueParameters(int index, std::string& name, std::string& expression, ComputationType& type) const;
379  void setComputedValueParameters(int index, const std::string& name, const std::string& expression, ComputationType type);
395  int addEnergyTerm(const std::string& expression, ComputationType type);
412  void getEnergyTermParameters(int index, std::string& expression, ComputationType& type) const;
429  void setEnergyTermParameters(int index, const std::string& expression, ComputationType type);
437  int addExclusion(int particle1, int particle2);
445  void getExclusionParticles(int index, int& particle1, int& particle2) const;
453  void setExclusionParticles(int index, int particle1, int particle2);
464  int addFunction(const std::string& name, const std::vector<double>& values, double min, double max);
475  void getFunctionParameters(int index, std::string& name, std::vector<double>& values, double& min, double& max) const;
486  void setFunctionParameters(int index, const std::string& name, const std::vector<double>& values, double min, double max);
497  void updateParametersInContext(Context& context);
498 protected:
499  ForceImpl* createImpl();
500 private:
501  class ParticleInfo;
502  class PerParticleParameterInfo;
503  class GlobalParameterInfo;
504  class ExclusionInfo;
505  class FunctionInfo;
506  class ComputationInfo;
507  NonbondedMethod nonbondedMethod;
508  double cutoffDistance;
509  std::vector<PerParticleParameterInfo> parameters;
510  std::vector<GlobalParameterInfo> globalParameters;
511  std::vector<ParticleInfo> particles;
512  std::vector<ExclusionInfo> exclusions;
513  std::vector<FunctionInfo> functions;
514  std::vector<ComputationInfo> computedValues;
515  std::vector<ComputationInfo> energyTerms;
516 };
517 
522 class CustomGBForce::ParticleInfo {
523 public:
524  std::vector<double> parameters;
525  ParticleInfo() {
526  }
527  ParticleInfo(const std::vector<double>& parameters) : parameters(parameters) {
528  }
529 };
530 
535 class CustomGBForce::PerParticleParameterInfo {
536 public:
537  std::string name;
538  PerParticleParameterInfo() {
539  }
540  PerParticleParameterInfo(const std::string& name) : name(name) {
541  }
542 };
543 
548 class CustomGBForce::GlobalParameterInfo {
549 public:
550  std::string name;
551  double defaultValue;
552  GlobalParameterInfo() {
553  }
554  GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
555  }
556 };
557 
562 class CustomGBForce::ExclusionInfo {
563 public:
564  int particle1, particle2;
565  ExclusionInfo() {
566  particle1 = particle2 = -1;
567  }
568  ExclusionInfo(int particle1, int particle2) :
569  particle1(particle1), particle2(particle2) {
570  }
571 };
572 
577 class CustomGBForce::FunctionInfo {
578 public:
579  std::string name;
580  std::vector<double> values;
581  double min, max;
582  FunctionInfo() {
583  }
584  FunctionInfo(const std::string& name, const std::vector<double>& values, double min, double max) :
585  name(name), values(values), min(min), max(max) {
586  }
587 };
588 
593 class CustomGBForce::ComputationInfo {
594 public:
595  std::string name;
596  std::string expression;
598  ComputationInfo() {
599  }
600  ComputationInfo(const std::string& name, const std::string& expression, CustomGBForce::ComputationType type) :
601  name(name), expression(expression), type(type) {
602  }
603 };
604 
605 } // namespace OpenMM
606 
607 #endif /*OPENMM_CUSTOMGBFORCE_H_*/