OpenMM
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
CustomManyParticleForce.h
1 #ifndef OPENMM_CUSTOMTHREEBODYFORCE_H_
2 #define OPENMM_CUSTOMTHREEBODYFORCE_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 "Force.h"
36 #include "TabulatedFunction.h"
37 #include "internal/windowsExport.h"
38 #include <set>
39 #include <string>
40 #include <vector>
41 
42 namespace OpenMM {
43 
162 class OPENMM_EXPORT CustomManyParticleForce : public Force {
163 public:
172  NoCutoff = 0,
176  CutoffNonPeriodic = 1,
181  CutoffPeriodic = 2,
182  };
194  SinglePermutation = 0,
201  UniqueCentralParticle = 1
202  };
210  explicit CustomManyParticleForce(int particlesPerSet, const std::string& energy);
215  int getNumParticlesPerSet() const {
216  return particlesPerSet;
217  }
221  int getNumParticles() const {
222  return particles.size();
223  }
227  int getNumExclusions() const {
228  return exclusions.size();
229  }
234  return particleParameters.size();
235  }
240  return globalParameters.size();
241  }
246  return functions.size();
247  }
251  const std::string& getEnergyFunction() const;
255  void setEnergyFunction(const std::string& energy);
259  NonbondedMethod getNonbondedMethod() const;
263  void setNonbondedMethod(NonbondedMethod method);
267  PermutationMode getPermutationMode() const;
271  void setPermutationMode(PermutationMode mode);
278  double getCutoffDistance() const;
285  void setCutoffDistance(double distance);
292  int addPerParticleParameter(const std::string& name);
299  const std::string& getPerParticleParameterName(int index) const;
306  void setPerParticleParameterName(int index, const std::string& name);
314  int addGlobalParameter(const std::string& name, double defaultValue);
321  const std::string& getGlobalParameterName(int index) const;
328  void setGlobalParameterName(int index, const std::string& name);
335  double getGlobalParameterDefaultValue(int index) const;
342  void setGlobalParameterDefaultValue(int index, double defaultValue);
351  int addParticle(const std::vector<double>& parameters, int type=0);
359  void getParticleParameters(int index, std::vector<double>& parameters, int& type) const;
367  void setParticleParameters(int index, const std::vector<double>& parameters, int type);
377  int addExclusion(int particle1, int particle2);
385  void getExclusionParticles(int index, int& particle1, int& particle2) const;
393  void setExclusionParticles(int index, int particle1, int particle2);
402  void createExclusionsFromBonds(const std::vector<std::pair<int, int> >& bonds, int bondCutoff);
411  void getTypeFilter(int index, std::set<int>& types) const;
420  void setTypeFilter(int index, const std::set<int>& types);
430  int addTabulatedFunction(const std::string& name, TabulatedFunction* function);
437  const TabulatedFunction& getTabulatedFunction(int index) const;
444  TabulatedFunction& getTabulatedFunction(int index);
451  const std::string& getTabulatedFunctionName(int index) const;
463  void updateParametersInContext(Context& context);
471  return nonbondedMethod == CustomManyParticleForce::CutoffPeriodic;
472  }
473 protected:
474  ForceImpl* createImpl() const;
475 private:
476  class ParticleInfo;
477  class ParticleParameterInfo;
478  class GlobalParameterInfo;
479  class ExclusionInfo;
480  class FunctionInfo;
481  int particlesPerSet;
482  NonbondedMethod nonbondedMethod;
483  PermutationMode permutationMode;
484  double cutoffDistance;
485  std::string energyExpression;
486  std::vector<ParticleParameterInfo> particleParameters;
487  std::vector<GlobalParameterInfo> globalParameters;
488  std::vector<ParticleInfo> particles;
489  std::vector<ExclusionInfo> exclusions;
490  std::vector<FunctionInfo> functions;
491  std::vector<std::set<int> > typeFilters;
492 };
493 
494 
499 class CustomManyParticleForce::ParticleInfo {
500 public:
501  std::vector<double> parameters;
502  int type;
503  ParticleInfo() {
504  }
505  ParticleInfo(const std::vector<double>& parameters, int type) : parameters(parameters), type(type) {
506  }
507 };
508 
513 class CustomManyParticleForce::ParticleParameterInfo {
514 public:
515  std::string name;
516  ParticleParameterInfo() {
517  }
518  ParticleParameterInfo(const std::string& name) : name(name) {
519  }
520 };
521 
526 class CustomManyParticleForce::GlobalParameterInfo {
527 public:
528  std::string name;
529  double defaultValue;
530  GlobalParameterInfo() {
531  }
532  GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
533  }
534 };
535 
540 class CustomManyParticleForce::ExclusionInfo {
541 public:
542  int particle1, particle2;
543  ExclusionInfo() {
544  particle1 = particle2 = -1;
545  }
546  ExclusionInfo(int particle1, int particle2) :
547  particle1(particle1), particle2(particle2) {
548  }
549 };
550 
555 class CustomManyParticleForce::FunctionInfo {
556 public:
557  std::string name;
558  TabulatedFunction* function;
559  FunctionInfo() {
560  }
561  FunctionInfo(const std::string& name, TabulatedFunction* function) : name(name), function(function) {
562  }
563 };
564 
565 } // namespace OpenMM
566 
567 #endif /*OPENMM_CUSTOMTHREEBODYFORCE_H_*/
int getNumParticles() const
Get the number of particles for which force field parameters have been defined.
Definition: CustomManyParticleForce.h:221
int getNumExclusions() const
Get the number of particle pairs whose interactions should be excluded.
Definition: CustomManyParticleForce.h:227
int getNumPerParticleParameters() const
Get the number of per-particle parameters that the interaction depends on.
Definition: CustomManyParticleForce.h:233
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
PermutationMode
This is an enumeration of the different modes for selecting which permutations of a set of particles ...
Definition: CustomManyParticleForce.h:187
int getNumTabulatedFunctions() const
Get the number of tabulated functions that have been defined.
Definition: CustomManyParticleForce.h:245
NonbondedMethod
This is an enumeration of the different methods that may be used for handling long range nonbonded fo...
Definition: CustomManyParticleForce.h:167
int getNumParticlesPerSet() const
Get the number of particles in each set for which the energy is evaluated.
Definition: CustomManyParticleForce.h:215
Force objects apply forces to the particles in a System, or alter their behavior in other ways...
Definition: Force.h:65
Periodic boundary conditions are used, so that each particle interacts only with the nearest periodic...
Definition: CustomManyParticleForce.h:181
bool usesPeriodicBoundaryConditions() const
Returns whether or not this force makes use of periodic boundary conditions.
Definition: CustomManyParticleForce.h:470
Definition: AndersenThermostat.h:40
This class supports a wide variety of nonbonded N-particle interactions, where N is user specified...
Definition: CustomManyParticleForce.h:162
int getNumGlobalParameters() const
Get the number of global parameters that the interaction depends on.
Definition: CustomManyParticleForce.h:239