OpenMM
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends
CustomCompoundBondForce.h
1 #ifndef OPENMM_CUSTOMCOMPOUNDBONDFORCE_H_
2 #define OPENMM_CUSTOMCOMPOUNDBONDFORCE_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 <vector>
38 #include "internal/windowsExport.h"
39 
40 namespace OpenMM {
41 
98 class OPENMM_EXPORT CustomCompoundBondForce : public Force {
99 public:
108  explicit CustomCompoundBondForce(int numParticles, const std::string& energy);
113  return particlesPerBond;
114  }
118  int getNumBonds() const {
119  return bonds.size();
120  }
125  return bondParameters.size();
126  }
131  return globalParameters.size();
132  }
136  int getNumFunctions() const {
137  return functions.size();
138  }
142  const std::string& getEnergyFunction() const;
146  void setEnergyFunction(const std::string& energy);
153  int addPerBondParameter(const std::string& name);
160  const std::string& getPerBondParameterName(int index) const;
167  void setPerBondParameterName(int index, const std::string& name);
175  int addGlobalParameter(const std::string& name, double defaultValue);
182  const std::string& getGlobalParameterName(int index) const;
189  void setGlobalParameterName(int index, const std::string& name);
196  double getGlobalParameterDefaultValue(int index) const;
203  void setGlobalParameterDefaultValue(int index, double defaultValue);
211  int addBond(const std::vector<int>& particles, const std::vector<double>& parameters);
219  void getBondParameters(int index, std::vector<int>& particles, std::vector<double>& parameters) const;
227  void setBondParameters(int index, const std::vector<int>& particles, const std::vector<double>& parameters);
238  int addFunction(const std::string& name, const std::vector<double>& values, double min, double max);
249  void getFunctionParameters(int index, std::string& name, std::vector<double>& values, double& min, double& max) const;
260  void setFunctionParameters(int index, const std::string& name, const std::vector<double>& values, double min, double max);
271  void updateParametersInContext(Context& context);
272 protected:
273  ForceImpl* createImpl() const;
274 private:
275  class BondInfo;
276  class BondParameterInfo;
277  class GlobalParameterInfo;
278  class FunctionInfo;
279  int particlesPerBond;
280  std::string energyExpression;
281  std::vector<BondParameterInfo> bondParameters;
282  std::vector<GlobalParameterInfo> globalParameters;
283  std::vector<BondInfo> bonds;
284  std::vector<FunctionInfo> functions;
285 };
286 
291 class CustomCompoundBondForce::BondInfo {
292 public:
293  std::vector<int> particles;
294  std::vector<double> parameters;
295  BondInfo() {
296  }
297  BondInfo(const std::vector<int>& particles, const std::vector<double>& parameters) :
298  particles(particles), parameters(parameters) {
299  }
300 };
301 
306 class CustomCompoundBondForce::BondParameterInfo {
307 public:
308  std::string name;
309  BondParameterInfo() {
310  }
311  BondParameterInfo(const std::string& name) : name(name) {
312  }
313 };
314 
319 class CustomCompoundBondForce::GlobalParameterInfo {
320 public:
321  std::string name;
322  double defaultValue;
323  GlobalParameterInfo() {
324  }
325  GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
326  }
327 };
328 
333 class CustomCompoundBondForce::FunctionInfo {
334 public:
335  std::string name;
336  std::vector<double> values;
337  double min, max;
338  FunctionInfo() {
339  }
340  FunctionInfo(const std::string& name, const std::vector<double>& values, double min, double max) :
341  name(name), values(values), min(min), max(max) {
342  }
343 };
344 
345 } // namespace OpenMM
346 
347 #endif /*OPENMM_CUSTOMCOMPOUNDBONDFORCE_H_*/