OpenMM
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
CustomHbondForce.h
1 #ifndef OPENMM_CUSTOMHBONDFORCE_H_
2 #define OPENMM_CUSTOMHBONDFORCE_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 
99 class OPENMM_EXPORT CustomHbondForce : public Force {
100 public:
109  NoCutoff = 0,
113  CutoffNonPeriodic = 1,
118  CutoffPeriodic = 2,
119  };
127  explicit CustomHbondForce(const std::string& energy);
128  ~CustomHbondForce();
132  int getNumDonors() const {
133  return donors.size();
134  }
138  int getNumAcceptors() const {
139  return acceptors.size();
140  }
144  int getNumExclusions() const {
145  return exclusions.size();
146  }
151  return donorParameters.size();
152  }
157  return acceptorParameters.size();
158  }
163  return globalParameters.size();
164  }
169  return functions.size();
170  }
176  int getNumFunctions() const {
177  return functions.size();
178  }
182  const std::string& getEnergyFunction() const;
186  void setEnergyFunction(const std::string& energy);
190  NonbondedMethod getNonbondedMethod() const;
194  void setNonbondedMethod(NonbondedMethod method);
201  double getCutoffDistance() const;
208  void setCutoffDistance(double distance);
215  int addPerDonorParameter(const std::string& name);
222  const std::string& getPerDonorParameterName(int index) const;
229  void setPerDonorParameterName(int index, const std::string& name);
236  int addPerAcceptorParameter(const std::string& name);
243  const std::string& getPerAcceptorParameterName(int index) const;
250  void setPerAcceptorParameterName(int index, const std::string& name);
258  int addGlobalParameter(const std::string& name, double defaultValue);
265  const std::string& getGlobalParameterName(int index) const;
272  void setGlobalParameterName(int index, const std::string& name);
279  double getGlobalParameterDefaultValue(int index) const;
286  void setGlobalParameterDefaultValue(int index, double defaultValue);
298  int addDonor(int d1, int d2, int d3, const std::vector<double>& parameters);
310  void getDonorParameters(int index, int& d1, int& d2, int& d3, std::vector<double>& parameters) const;
322  void setDonorParameters(int index, int d1, int d2, int d3, const std::vector<double>& parameters);
334  int addAcceptor(int a1, int a2, int a3, const std::vector<double>& parameters);
346  void getAcceptorParameters(int index, int& a1, int& a2, int& a3, std::vector<double>& parameters) const;
358  void setAcceptorParameters(int index, int a1, int a2, int a3, const std::vector<double>& parameters);
366  int addExclusion(int donor, int acceptor);
374  void getExclusionParticles(int index, int& donor, int& acceptor) const;
382  void setExclusionParticles(int index, int donor, int acceptor);
392  int addTabulatedFunction(const std::string& name, TabulatedFunction* function);
399  const TabulatedFunction& getTabulatedFunction(int index) const;
406  TabulatedFunction& getTabulatedFunction(int index);
413  const std::string& getTabulatedFunctionName(int index) const;
419  int addFunction(const std::string& name, const std::vector<double>& values, double min, double max);
426  void getFunctionParameters(int index, std::string& name, std::vector<double>& values, double& min, double& max) const;
433  void setFunctionParameters(int index, const std::string& name, const std::vector<double>& values, double min, double max);
445  void updateParametersInContext(Context& context);
446 protected:
447  ForceImpl* createImpl() const;
448 private:
449  class GroupInfo;
450  class PerPairParameterInfo;
451  class GlobalParameterInfo;
452  class ExclusionInfo;
453  class FunctionInfo;
454  NonbondedMethod nonbondedMethod;
455  double cutoffDistance;
456  std::string energyExpression;
457  std::vector<PerPairParameterInfo> donorParameters;
458  std::vector<PerPairParameterInfo> acceptorParameters;
459  std::vector<GlobalParameterInfo> globalParameters;
460  std::vector<GroupInfo> donors;
461  std::vector<GroupInfo> acceptors;
462  std::vector<ExclusionInfo> exclusions;
463  std::vector<FunctionInfo> functions;
464 };
465 
470 class CustomHbondForce::GroupInfo {
471 public:
472  std::vector<double> parameters;
473  int p1, p2, p3;
474  GroupInfo() : p1(-1), p2(-1), p3(-1) {
475  }
476  GroupInfo(int p1, int p2, int p3, const std::vector<double>& parameters) :
477  p1(p1), p2(p2), p3(p3), parameters(parameters) {
478  }
479 };
480 
485 class CustomHbondForce::PerPairParameterInfo {
486 public:
487  std::string name;
488  PerPairParameterInfo() {
489  }
490  PerPairParameterInfo(const std::string& name) : name(name) {
491  }
492 };
493 
498 class CustomHbondForce::GlobalParameterInfo {
499 public:
500  std::string name;
501  double defaultValue;
502  GlobalParameterInfo() {
503  }
504  GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
505  }
506 };
507 
512 class CustomHbondForce::ExclusionInfo {
513 public:
514  int donor, acceptor;
515  ExclusionInfo() {
516  donor = acceptor = -1;
517  }
518  ExclusionInfo(int donor, int acceptor) :
519  donor(donor), acceptor(acceptor) {
520  }
521 };
522 
527 class CustomHbondForce::FunctionInfo {
528 public:
529  std::string name;
530  TabulatedFunction* function;
531  FunctionInfo() {
532  }
533  FunctionInfo(const std::string& name, TabulatedFunction* function) : name(name), function(function) {
534  }
535 };
536 
537 } // namespace OpenMM
538 
539 #endif /*OPENMM_CUSTOMHBONDFORCE_H_*/
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
int getNumAcceptors() const
Get the number of acceptors for which force field parameters have been defined.
Definition: CustomHbondForce.h:138
int getNumPerDonorParameters() const
Get the number of per-donor parameters that the interaction depends on.
Definition: CustomHbondForce.h:150
int getNumFunctions() const
Get the number of tabulated functions that have been defined.
Definition: CustomHbondForce.h:176
This class supports a wide variety of energy functions used to represent hydrogen bonding...
Definition: CustomHbondForce.h:99
Force objects apply forces to the particles in a System, or alter their behavior in other ways...
Definition: Force.h:65
int getNumExclusions() const
Get the number of donor-acceptor pairs whose interactions should be excluded.
Definition: CustomHbondForce.h:144
int getNumPerAcceptorParameters() const
Get the number of per-acceptor parameters that the interaction depends on.
Definition: CustomHbondForce.h:156
NonbondedMethod
This is an enumeration of the different methods that may be used for handling long range nonbonded fo...
Definition: CustomHbondForce.h:104
A ForceImpl provides the internal implementation of a Force.
Definition: ForceImpl.h:57
int getNumDonors() const
Get the number of donors for which force field parameters have been defined.
Definition: CustomHbondForce.h:132
int getNumTabulatedFunctions() const
Get the number of tabulated functions that have been defined.
Definition: CustomHbondForce.h:168
int getNumGlobalParameters() const
Get the number of global parameters that the interaction depends on.
Definition: CustomHbondForce.h:162