OpenMM
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends
CustomAngleForce.h
1 #ifndef OPENMM_CUSTOMANGLEFORCE_H_
2 #define OPENMM_CUSTOMANGLEFORCE_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 CustomAngleForce : public Force {
73 public:
80  explicit CustomAngleForce(const std::string& energy);
84  int getNumAngles() const {
85  return angles.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 addPerAngleParameter(const std::string& name);
120  const std::string& getPerAngleParameterName(int index) const;
127  void setPerAngleParameterName(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);
173  int addAngle(int particle1, int particle2, int particle3, const std::vector<double>& parameters);
183  void getAngleParameters(int index, int& particle1, int& particle2, int& particle3, std::vector<double>& parameters) const;
193  void setAngleParameters(int index, int particle1, int particle2, int particle3, const std::vector<double>& parameters);
204  void updateParametersInContext(Context& context);
205 protected:
206  ForceImpl* createImpl() const;
207 private:
208  class AngleInfo;
209  class AngleParameterInfo;
210  class GlobalParameterInfo;
211  std::string energyExpression;
212  std::vector<AngleParameterInfo> parameters;
213  std::vector<GlobalParameterInfo> globalParameters;
214  std::vector<AngleInfo> angles;
215 };
216 
221 class CustomAngleForce::AngleInfo {
222 public:
223  int particle1, particle2, particle3;
224  std::vector<double> parameters;
225  AngleInfo() : particle1(-1), particle2(-1), particle3(-1) {
226  }
227  AngleInfo(int particle1, int particle2, int particle3, const std::vector<double>& parameters) :
228  particle1(particle1), particle2(particle2), particle3(particle3), parameters(parameters) {
229  }
230 };
231 
236 class CustomAngleForce::AngleParameterInfo {
237 public:
238  std::string name;
239  AngleParameterInfo() {
240  }
241  AngleParameterInfo(const std::string& name) : name(name) {
242  }
243 };
244 
249 class CustomAngleForce::GlobalParameterInfo {
250 public:
251  std::string name;
252  double defaultValue;
253  GlobalParameterInfo() {
254  }
255  GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
256  }
257 };
258 
259 } // namespace OpenMM
260 
261 #endif /*OPENMM_CUSTOMANGLEFORCE_H_*/