OpenMM
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends
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-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 
98 class OPENMM_EXPORT CustomHbondForce : public Force {
99 public:
108  NoCutoff = 0,
112  CutoffNonPeriodic = 1,
117  CutoffPeriodic = 2,
118  };
126  explicit CustomHbondForce(const std::string& energy);
130  int getNumDonors() const {
131  return donors.size();
132  }
136  int getNumAcceptors() const {
137  return acceptors.size();
138  }
142  int getNumExclusions() const {
143  return exclusions.size();
144  }
149  return donorParameters.size();
150  }
155  return acceptorParameters.size();
156  }
161  return globalParameters.size();
162  }
166  int getNumFunctions() const {
167  return functions.size();
168  }
172  const std::string& getEnergyFunction() const;
176  void setEnergyFunction(const std::string& energy);
180  NonbondedMethod getNonbondedMethod() const;
184  void setNonbondedMethod(NonbondedMethod method);
191  double getCutoffDistance() const;
198  void setCutoffDistance(double distance);
205  int addPerDonorParameter(const std::string& name);
212  const std::string& getPerDonorParameterName(int index) const;
219  void setPerDonorParameterName(int index, const std::string& name);
226  int addPerAcceptorParameter(const std::string& name);
233  const std::string& getPerAcceptorParameterName(int index) const;
240  void setPerAcceptorParameterName(int index, const std::string& name);
248  int addGlobalParameter(const std::string& name, double defaultValue);
255  const std::string& getGlobalParameterName(int index) const;
262  void setGlobalParameterName(int index, const std::string& name);
269  double getGlobalParameterDefaultValue(int index) const;
276  void setGlobalParameterDefaultValue(int index, double defaultValue);
288  int addDonor(int d1, int d2, int d3, const std::vector<double>& parameters);
300  void getDonorParameters(int index, int& d1, int& d2, int& d3, std::vector<double>& parameters) const;
312  void setDonorParameters(int index, int d1, int d2, int d3, const std::vector<double>& parameters);
324  int addAcceptor(int a1, int a2, int a3, const std::vector<double>& parameters);
336  void getAcceptorParameters(int index, int& a1, int& a2, int& a3, std::vector<double>& parameters) const;
348  void setAcceptorParameters(int index, int a1, int a2, int a3, const std::vector<double>& parameters);
356  int addExclusion(int donor, int acceptor);
364  void getExclusionParticles(int index, int& donor, int& acceptor) const;
372  void setExclusionParticles(int index, int donor, int acceptor);
383  int addFunction(const std::string& name, const std::vector<double>& values, double min, double max);
394  void getFunctionParameters(int index, std::string& name, std::vector<double>& values, double& min, double& max) const;
405  void setFunctionParameters(int index, const std::string& name, const std::vector<double>& values, double min, double max);
417  void updateParametersInContext(Context& context);
418 protected:
419  ForceImpl* createImpl();
420 private:
421  class GroupInfo;
422  class PerPairParameterInfo;
423  class GlobalParameterInfo;
424  class ExclusionInfo;
425  class FunctionInfo;
426  NonbondedMethod nonbondedMethod;
427  double cutoffDistance;
428  std::string energyExpression;
429  std::vector<PerPairParameterInfo> donorParameters;
430  std::vector<PerPairParameterInfo> acceptorParameters;
431  std::vector<GlobalParameterInfo> globalParameters;
432  std::vector<GroupInfo> donors;
433  std::vector<GroupInfo> acceptors;
434  std::vector<ExclusionInfo> exclusions;
435  std::vector<FunctionInfo> functions;
436 };
437 
442 class CustomHbondForce::GroupInfo {
443 public:
444  std::vector<double> parameters;
445  int p1, p2, p3;
446  GroupInfo() : p1(-1), p2(-1), p3(-1) {
447  }
448  GroupInfo(int p1, int p2, int p3, const std::vector<double>& parameters) :
449  p1(p1), p2(p2), p3(p3), parameters(parameters) {
450  }
451 };
452 
457 class CustomHbondForce::PerPairParameterInfo {
458 public:
459  std::string name;
460  PerPairParameterInfo() {
461  }
462  PerPairParameterInfo(const std::string& name) : name(name) {
463  }
464 };
465 
470 class CustomHbondForce::GlobalParameterInfo {
471 public:
472  std::string name;
473  double defaultValue;
474  GlobalParameterInfo() {
475  }
476  GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
477  }
478 };
479 
484 class CustomHbondForce::ExclusionInfo {
485 public:
486  int donor, acceptor;
487  ExclusionInfo() {
488  donor = acceptor = -1;
489  }
490  ExclusionInfo(int donor, int acceptor) :
491  donor(donor), acceptor(acceptor) {
492  }
493 };
494 
499 class CustomHbondForce::FunctionInfo {
500 public:
501  std::string name;
502  std::vector<double> values;
503  double min, max;
504  FunctionInfo() {
505  }
506  FunctionInfo(const std::string& name, const std::vector<double>& values, double min, double max) :
507  name(name), values(values), min(min), max(max) {
508  }
509 };
510 
511 } // namespace OpenMM
512 
513 #endif /*OPENMM_CUSTOMHBONDFORCE_H_*/