OpenMM
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
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-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 <vector>
39 #include "internal/windowsExport.h"
40 
41 namespace OpenMM {
42 
99 class OPENMM_EXPORT CustomCompoundBondForce : public Force {
100 public:
109  explicit CustomCompoundBondForce(int numParticles, const std::string& energy);
115  return particlesPerBond;
116  }
120  int getNumBonds() const {
121  return bonds.size();
122  }
127  return bondParameters.size();
128  }
133  return globalParameters.size();
134  }
139  return functions.size();
140  }
146  int getNumFunctions() const {
147  return functions.size();
148  }
152  const std::string& getEnergyFunction() const;
156  void setEnergyFunction(const std::string& energy);
163  int addPerBondParameter(const std::string& name);
170  const std::string& getPerBondParameterName(int index) const;
177  void setPerBondParameterName(int index, const std::string& name);
185  int addGlobalParameter(const std::string& name, double defaultValue);
192  const std::string& getGlobalParameterName(int index) const;
199  void setGlobalParameterName(int index, const std::string& name);
206  double getGlobalParameterDefaultValue(int index) const;
213  void setGlobalParameterDefaultValue(int index, double defaultValue);
221  int addBond(const std::vector<int>& particles, const std::vector<double>& parameters);
229  void getBondParameters(int index, std::vector<int>& particles, std::vector<double>& parameters) const;
237  void setBondParameters(int index, const std::vector<int>& particles, const std::vector<double>& parameters);
247  int addTabulatedFunction(const std::string& name, TabulatedFunction* function);
254  const TabulatedFunction& getTabulatedFunction(int index) const;
261  TabulatedFunction& getTabulatedFunction(int index);
268  const std::string& getTabulatedFunctionName(int index) const;
274  int addFunction(const std::string& name, const std::vector<double>& values, double min, double max);
281  void getFunctionParameters(int index, std::string& name, std::vector<double>& values, double& min, double& max) const;
288  void setFunctionParameters(int index, const std::string& name, const std::vector<double>& values, double min, double max);
299  void updateParametersInContext(Context& context);
300 protected:
301  ForceImpl* createImpl() const;
302 private:
303  class BondInfo;
304  class BondParameterInfo;
305  class GlobalParameterInfo;
306  class FunctionInfo;
307  int particlesPerBond;
308  std::string energyExpression;
309  std::vector<BondParameterInfo> bondParameters;
310  std::vector<GlobalParameterInfo> globalParameters;
311  std::vector<BondInfo> bonds;
312  std::vector<FunctionInfo> functions;
313 };
314 
319 class CustomCompoundBondForce::BondInfo {
320 public:
321  std::vector<int> particles;
322  std::vector<double> parameters;
323  BondInfo() {
324  }
325  BondInfo(const std::vector<int>& particles, const std::vector<double>& parameters) :
326  particles(particles), parameters(parameters) {
327  }
328 };
329 
334 class CustomCompoundBondForce::BondParameterInfo {
335 public:
336  std::string name;
337  BondParameterInfo() {
338  }
339  BondParameterInfo(const std::string& name) : name(name) {
340  }
341 };
342 
347 class CustomCompoundBondForce::GlobalParameterInfo {
348 public:
349  std::string name;
350  double defaultValue;
351  GlobalParameterInfo() {
352  }
353  GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
354  }
355 };
356 
361 class CustomCompoundBondForce::FunctionInfo {
362 public:
363  std::string name;
364  TabulatedFunction* function;
365  FunctionInfo() {
366  }
367  FunctionInfo(const std::string& name, TabulatedFunction* function) : name(name), function(function) {
368  }
369 };
370 
371 } // namespace OpenMM
372 
373 #endif /*OPENMM_CUSTOMCOMPOUNDBONDFORCE_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 getNumPerBondParameters() const
Get the number of per-bond parameters that the interaction depends on.
Definition: CustomCompoundBondForce.h:126
int getNumTabulatedFunctions() const
Get the number of tabulated functions that have been defined.
Definition: CustomCompoundBondForce.h:138
Force objects apply forces to the particles in a System, or alter their behavior in other ways...
Definition: Force.h:65
int getNumBonds() const
Get the number of bonds for which force field parameters have been defined.
Definition: CustomCompoundBondForce.h:120
int getNumParticlesPerBond() const
Get the number of particles used to define each bond.
Definition: CustomCompoundBondForce.h:114
int getNumFunctions() const
Get the number of tabulated functions that have been defined.
Definition: CustomCompoundBondForce.h:146
int getNumGlobalParameters() const
Get the number of global parameters that the interaction depends on.
Definition: CustomCompoundBondForce.h:132
A ForceImpl provides the internal implementation of a Force.
Definition: ForceImpl.h:57
This class supports a wide variety of bonded interactions.
Definition: CustomCompoundBondForce.h:99