OpenMM
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
AmoebaMultipoleForce.h
1 #ifndef OPENMM_AMOEBA_MULTIPOLE_FORCE_H_
2 #define OPENMM_AMOEBA_MULTIPOLE_FORCE_H_
3 
4 /* -------------------------------------------------------------------------- *
5  * OpenMMAmoeba *
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: Mark Friedrichs, 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 "openmm/Force.h"
36 #include "openmm/OpenMMException.h"
37 #include "internal/windowsExportAmoeba.h"
38 #include "openmm/Vec3.h"
39 
40 #include <sstream>
41 #include <vector>
42 
43 namespace OpenMM {
44 
53 class OPENMM_EXPORT_AMOEBA AmoebaMultipoleForce : public Force {
54 
55 public:
56 
58 
63  NoCutoff = 0,
64 
69  PME = 1
70  };
71 
73 
77  Mutual = 0,
78 
82  Direct = 1
83  };
84 
85  enum MultipoleAxisTypes { ZThenX = 0, Bisector = 1, ZBisect = 2, ThreeFold = 3, ZOnly = 4, NoAxisType = 5, LastAxisTypeIndex = 6 };
86 
87  enum CovalentType {
88  Covalent12 = 0, Covalent13 = 1, Covalent14 = 2, Covalent15 = 3,
89  PolarizationCovalent11 = 4, PolarizationCovalent12 = 5, PolarizationCovalent13 = 6, PolarizationCovalent14 = 7, CovalentEnd = 8 };
90 
95 
99  int getNumMultipoles() const {
100  return multipoles.size();
101  }
102 
106  NonbondedMethod getNonbondedMethod() const;
107 
111  void setNonbondedMethod(NonbondedMethod method);
112 
116  PolarizationType getPolarizationType() const;
117 
121  void setPolarizationType(PolarizationType type);
122 
129  double getCutoffDistance() const;
130 
137  void setCutoffDistance(double distance);
138 
145  double getAEwald() const;
146 
153  void setAEwald(double aewald);
154 
160  int getPmeBSplineOrder() const;
161 
168  void getPmeGridDimensions(std::vector<int>& gridDimension) const;
169 
176  void setPmeGridDimensions(const std::vector<int>& gridDimension);
177 
194  int addMultipole(double charge, const std::vector<double>& molecularDipole, const std::vector<double>& molecularQuadrupole, int axisType,
195  int multipoleAtomZ, int multipoleAtomX, int multipoleAtomY, double thole, double dampingFactor, double polarity);
196 
212  void getMultipoleParameters(int index, double& charge, std::vector<double>& molecularDipole, std::vector<double>& molecularQuadrupole,
213  int& axisType, int& multipoleAtomZ, int& multipoleAtomX, int& multipoleAtomY, double& thole, double& dampingFactor, double& polarity) const;
214 
228  void setMultipoleParameters(int index, double charge, const std::vector<double>& molecularDipole, const std::vector<double>& molecularQuadrupole,
229  int axisType, int multipoleAtomZ, int multipoleAtomX, int multipoleAtomY, double thole, double dampingFactor, double polarity);
230 
238  void setCovalentMap(int index, CovalentType typeId, const std::vector<int>& covalentAtoms);
239 
247  void getCovalentMap(int index, CovalentType typeId, std::vector<int>& covalentAtoms) const;
248 
255  void getCovalentMaps(int index, std::vector < std::vector<int> >& covalentLists) const;
256 
262  int getMutualInducedMaxIterations(void) const;
263 
269  void setMutualInducedMaxIterations(int inputMutualInducedMaxIterations);
270 
276  double getMutualInducedTargetEpsilon(void) const;
277 
283  void setMutualInducedTargetEpsilon(double inputMutualInducedTargetEpsilon);
284 
293  double getEwaldErrorTolerance() const;
302  void setEwaldErrorTolerance(double tol);
303 
310  void getInducedDipoles(Context& context, std::vector<Vec3>& dipoles);
311 
320  void getElectrostaticPotential(const std::vector< Vec3 >& inputGrid,
321  Context& context, std::vector< double >& outputElectrostaticPotential);
322 
339  void getSystemMultipoleMoments(Context& context, std::vector< double >& outputMultipoleMoments);
351  void updateParametersInContext(Context& context);
359  return nonbondedMethod == AmoebaMultipoleForce::PME;
360  }
361 protected:
362  ForceImpl* createImpl() const;
363 private:
364  NonbondedMethod nonbondedMethod;
365  PolarizationType polarizationType;
366  double cutoffDistance;
367  double aewald;
368  int pmeBSplineOrder;
369  std::vector<int> pmeGridDimension;
370  int mutualInducedMaxIterations;
371  double mutualInducedTargetEpsilon;
372  double scalingDistanceCutoff;
373  double electricConstant;
374  double ewaldErrorTol;
375  class MultipoleInfo;
376  std::vector<MultipoleInfo> multipoles;
377 };
378 
383 class AmoebaMultipoleForce::MultipoleInfo {
384 public:
385 
386  int axisType, multipoleAtomZ, multipoleAtomX, multipoleAtomY;
387  double charge, thole, dampingFactor, polarity;
388 
389  std::vector<double> molecularDipole;
390  std::vector<double> molecularQuadrupole;
391  std::vector< std::vector<int> > covalentInfo;
392 
393  MultipoleInfo() {
394  axisType = multipoleAtomZ = multipoleAtomX = multipoleAtomY = -1;
395  charge = thole = dampingFactor = 0.0;
396 
397  molecularDipole.resize(3);
398  molecularQuadrupole.resize(9);
399 
400  }
401 
402  MultipoleInfo(double charge, const std::vector<double>& inputMolecularDipole, const std::vector<double>& inputMolecularQuadrupole,
403  int axisType, int multipoleAtomZ, int multipoleAtomX, int multipoleAtomY, double thole, double dampingFactor, double polarity) :
404  charge(charge), axisType(axisType), multipoleAtomZ(multipoleAtomZ), multipoleAtomX(multipoleAtomX), multipoleAtomY(multipoleAtomY),
405  thole(thole), dampingFactor(dampingFactor), polarity(polarity) {
406 
407  covalentInfo.resize(CovalentEnd);
408 
409  molecularDipole.resize(3);
410  molecularDipole[0] = inputMolecularDipole[0];
411  molecularDipole[1] = inputMolecularDipole[1];
412  molecularDipole[2] = inputMolecularDipole[2];
413 
414  molecularQuadrupole.resize(9);
415  molecularQuadrupole[0] = inputMolecularQuadrupole[0];
416  molecularQuadrupole[1] = inputMolecularQuadrupole[1];
417  molecularQuadrupole[2] = inputMolecularQuadrupole[2];
418  molecularQuadrupole[3] = inputMolecularQuadrupole[3];
419  molecularQuadrupole[4] = inputMolecularQuadrupole[4];
420  molecularQuadrupole[5] = inputMolecularQuadrupole[5];
421  molecularQuadrupole[6] = inputMolecularQuadrupole[6];
422  molecularQuadrupole[7] = inputMolecularQuadrupole[7];
423  molecularQuadrupole[8] = inputMolecularQuadrupole[8];
424  }
425 };
426 
427 } // namespace OpenMM
428 
429 #endif /*OPENMM_AMOEBA_MULTIPOLE_FORCE_H_*/
int getNumMultipoles() const
Get the number of particles in the potential function.
Definition: AmoebaMultipoleForce.h:99
A Context stores the complete state of a simulation.
Definition: Context.h:67
Force objects apply forces to the particles in a System, or alter their behavior in other ways...
Definition: Force.h:65
NonbondedMethod
Definition: AmoebaMultipoleForce.h:57
CovalentType
Definition: AmoebaMultipoleForce.h:87
PolarizationType
Definition: AmoebaMultipoleForce.h:72
This class implements the Amoeba multipole interaction.
Definition: AmoebaMultipoleForce.h:53
bool usesPeriodicBoundaryConditions() const
Returns whether or not this force makes use of periodic boundary conditions.
Definition: AmoebaMultipoleForce.h:358
Definition: AndersenThermostat.h:40
MultipoleAxisTypes
Definition: AmoebaMultipoleForce.h:85
Definition: AmoebaMultipoleForce.h:89
Periodic boundary conditions are used, and Particle-Mesh Ewald (PME) summation is used to compute the...
Definition: AmoebaMultipoleForce.h:69