OpenMM
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
AmoebaTorsionTorsionForce.h
1 #ifndef OPENMM_AMOEBA_TORSION_TORSION_FORCE_H_
2 #define OPENMM_AMOEBA_TORSION_TORSION_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 "internal/windowsExportAmoeba.h"
37 
38 #include <vector>
39 #include <cmath>
40 
41 namespace OpenMM {
42 
43 typedef std::vector< std::vector< std::vector<double> > > TorsionTorsionGrid;
44 typedef std::vector< std::vector< std::vector<float> > > TorsionTorsionGridFloat;
45 
53 class OPENMM_EXPORT_AMOEBA AmoebaTorsionTorsionForce : public Force {
54 
55 public:
60 
64  int getNumTorsionTorsions(void) const {
65  return torsionTorsions.size();
66  }
67 
71  int getNumTorsionTorsionGrids(void) const {
72  return torsionTorsionGrids.size();
73  }
74 
87  int addTorsionTorsion(int particle1, int particle2, int particle3, int particle4, int particle5, int chiralCheckAtomIndex, int gridIndex);
88 
101  void getTorsionTorsionParameters(int index, int& particle1, int& particle2, int& particle3, int& particle4, int& particle5, int& chiralCheckAtomIndex, int& gridIndex) const;
102 
115  void setTorsionTorsionParameters(int index, int particle1, int particle2, int particle3, int particle4, int particle5, int chiralCheckAtomIndex, int gridIndex);
116 
123  const std::vector<std::vector<std::vector<double> > >& getTorsionTorsionGrid(int index) const;
124 
137  void setTorsionTorsionGrid(int index, const std::vector<std::vector<std::vector<double> > >& grid);
138 
139 protected:
140  ForceImpl* createImpl() const;
141 private:
142  class TorsionTorsionInfo;
143  class TorsionTorsionGridInfo;
144  std::vector<TorsionTorsionInfo> torsionTorsions;
145  std::vector<TorsionTorsionGridInfo> torsionTorsionGrids;
146 };
147 
152 class AmoebaTorsionTorsionForce::TorsionTorsionInfo {
153 
154 public:
155 
156  int particle1, particle2, particle3, particle4, particle5;
157  int chiralCheckAtomIndex;
158  int gridIndex;
159  TorsionTorsionInfo() {
160  particle1 = particle2 = particle3 = particle4 = particle5 = chiralCheckAtomIndex = -1;
161  gridIndex = 0;
162  }
163  TorsionTorsionInfo(int particle1, int particle2, int particle3, int particle4, int particle5, int chiralCheckAtomIndex, int gridIndex) :
164  particle1(particle1), particle2(particle2), particle3(particle3),
165  particle4(particle4), particle5(particle5), gridIndex(gridIndex), chiralCheckAtomIndex(chiralCheckAtomIndex) {
166 
167  }
168 };
169 
174 class AmoebaTorsionTorsionForce::TorsionTorsionGridInfo {
175 
176 public:
177 
178  TorsionTorsionGridInfo() {
179  _size[0] = _size[1] = 0;
180  _startValues[0] = _startValues[1] = 0.0;
181  _spacing[0] = _spacing[1] = 1.0;
182  }
183 
184  TorsionTorsionGridInfo(const TorsionTorsionGrid& grid) {
185 
186  _grid.resize(grid.size());
187  for(unsigned int kk = 0; kk < grid.size(); kk++){
188  _grid[kk].resize(grid[kk].size());
189  for(unsigned int jj = 0; jj < grid[kk].size(); jj++){
190  _grid[kk][jj].resize(grid[kk][jj].size());
191  for(unsigned int ii = 0; ii < grid[kk][jj].size(); ii++){
192  _grid[kk][jj][ii] = grid[kk][jj][ii];
193  }
194  }
195  }
196 
197  _startValues[0] = _grid[0][0][0];
198  _startValues[1] = _grid[0][0][1];
199 
200  _spacing[0] = static_cast<double>(_grid.size()-1)/360.0;
201  _spacing[1] = static_cast<double>(grid.size()-1)/360.0;
202 
203  _size[0] = static_cast<int>(grid.size());
204  _size[1] = static_cast<int>(grid[0].size());
205 
206  }
207 
208  const TorsionTorsionGrid& getTorsionTorsionGrid(void) const {
209  return _grid;
210  }
211  int getDimensionSize(int index) const {
212  return _size[index];
213  }
214  double getStartValue(int index) const {
215  return _startValues[index];
216  }
217  double getSpacing(int index) const {
218  return _spacing[index];
219  }
220 
221 private:
222 
223  TorsionTorsionGrid _grid;
224  int _size[2];
225  double _startValues[2];
226  double _spacing[2];
227 };
228 
229 } // namespace OpenMM
230 
231 #endif /*OPENMM_AMOEBA_TORSION_TORSION_FORCE_H_*/
std::vector< std::vector< std::vector< double > > > TorsionTorsionGrid
Definition: AmoebaTorsionTorsionForce.h:43
std::vector< std::vector< std::vector< float > > > TorsionTorsionGridFloat
Definition: AmoebaTorsionTorsionForce.h:44
const std::vector< std::vector< std::vector< double > > > & getTorsionTorsionGrid(int index) const
Get the torsion-torsion grid at the specified index.
This class implements the Amoeba torsion-torsion interaction.
Definition: AmoebaTorsionTorsionForce.h:53
Force objects apply forces to the particles in a System, or alter their behavior in other ways...
Definition: Force.h:65
A ForceImpl provides the internal implementation of a Force.
Definition: ForceImpl.h:57
int getNumTorsionTorsions(void) const
Get the number of torsion-torsion terms in the potential function.
Definition: AmoebaTorsionTorsionForce.h:64
int getNumTorsionTorsionGrids(void) const
Get the number of torsion-torsion grids.
Definition: AmoebaTorsionTorsionForce.h:71