OpenMM
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends
CustomTorsionForce.h
1 #ifndef OPENMM_CUSTOMTORSIONFORCE_H_
2 #define OPENMM_CUSTOMTORSIONFORCE_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) 2010-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 <vector>
38 #include "internal/windowsExport.h"
39 
40 namespace OpenMM {
41 
72 class OPENMM_EXPORT CustomTorsionForce : public Force {
73 public:
80  explicit CustomTorsionForce(const std::string& energy);
84  int getNumTorsions() const {
85  return torsions.size();
86  }
91  return parameters.size();
92  }
96  int getNumGlobalParameters() const {
97  return globalParameters.size();
98  }
102  const std::string& getEnergyFunction() const;
106  void setEnergyFunction(const std::string& energy);
113  int addPerTorsionParameter(const std::string& name);
120  const std::string& getPerTorsionParameterName(int index) const;
127  void setPerTorsionParameterName(int index, const std::string& name);
135  int addGlobalParameter(const std::string& name, double defaultValue);
142  const std::string& getGlobalParameterName(int index) const;
149  void setGlobalParameterName(int index, const std::string& name);
156  double getGlobalParameterDefaultValue(int index) const;
163  void setGlobalParameterDefaultValue(int index, double defaultValue);
174  int addTorsion(int particle1, int particle2, int particle3, int particle4, const std::vector<double>& parameters);
185  void getTorsionParameters(int index, int& particle1, int& particle2, int& particle3, int& particle4, std::vector<double>& parameters) const;
196  void setTorsionParameters(int index, int particle1, int particle2, int particle3, int particle4, const std::vector<double>& parameters);
207  void updateParametersInContext(Context& context);
208 protected:
209  ForceImpl* createImpl() const;
210 private:
211  class TorsionInfo;
212  class TorsionParameterInfo;
213  class GlobalParameterInfo;
214  std::string energyExpression;
215  std::vector<TorsionParameterInfo> parameters;
216  std::vector<GlobalParameterInfo> globalParameters;
217  std::vector<TorsionInfo> torsions;
218 };
219 
224 class CustomTorsionForce::TorsionInfo {
225 public:
226  int particle1, particle2, particle3, particle4;
227  std::vector<double> parameters;
228  TorsionInfo() : particle1(-1), particle2(-1), particle3(-1), particle4(-1) {
229  }
230  TorsionInfo(int particle1, int particle2, int particle3, int particle4, const std::vector<double>& parameters) :
231  particle1(particle1), particle2(particle2), particle3(particle3), particle4(particle4), parameters(parameters) {
232  }
233 };
234 
239 class CustomTorsionForce::TorsionParameterInfo {
240 public:
241  std::string name;
242  TorsionParameterInfo() {
243  }
244  TorsionParameterInfo(const std::string& name) : name(name) {
245  }
246 };
247 
252 class CustomTorsionForce::GlobalParameterInfo {
253 public:
254  std::string name;
255  double defaultValue;
256  GlobalParameterInfo() {
257  }
258  GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
259  }
260 };
261 
262 } // namespace OpenMM
263 
264 #endif /*OPENMM_CUSTOMTORSIONFORCE_H_*/