"plugins/drude/openmmapi/vscode:/vscode.git/clone" did not exist on "0644f054bd6608210c3b5f644f2831e668002707"
ReferenceLincsAlgorithm.h 5.81 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* Portions copyright (c) 2006-2009 Stanford University and Simbios.
 * Contributors: Pande Group
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject
 * to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef __ReferenceLincsAlgorithm_H__
#define __ReferenceLincsAlgorithm_H__

#include "ReferenceConstraintAlgorithm.h"
28
#include "SimTKOpenMMRealType.h"
29
30
#include <vector>

31
namespace OpenMM {
32
33
34
35
36
37
38
39

class ReferenceLincsAlgorithm : public ReferenceConstraintAlgorithm {

   protected:

      int _numTerms;
      int _numberOfConstraints;
      int** _atomIndices;
peastman's avatar
peastman committed
40
      double* _distance;
41
42
43

      bool _hasInitialized;
      std::vector<std::vector<int> > _linkedConstraints;
peastman's avatar
peastman committed
44
45
46
47
48
49
      std::vector<double> _sMatrix;
      std::vector<double> _rhs1;
      std::vector<double> _rhs2;
      std::vector<double> _solution;
      std::vector<std::vector<double> > _couplingMatrix;
      std::vector<OpenMM::Vec3> _constraintDir;
50
51
52
53
54
55
56
57
58
59
60


      /**---------------------------------------------------------------------------------------

         Set the number of terms to use in the series expansion

         @param numberOfAtoms    number of atoms
         @param inverseMasses    1/mass

         --------------------------------------------------------------------------------------- */

peastman's avatar
peastman committed
61
      void initialize(int numberOfAtoms, std::vector<double>& inverseMasses);
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

      /**---------------------------------------------------------------------------------------

         Solve the matrix equation

         --------------------------------------------------------------------------------------- */

      void solveMatrix();

      /**---------------------------------------------------------------------------------------

         Update the atom position based on the solution to the matrix equation.

         @param numberOfAtoms    number of atoms
         @param atomCoordinates  atom coordinates
         @param inverseMasses    1/mass

         --------------------------------------------------------------------------------------- */

peastman's avatar
peastman committed
81
      void updateAtomPositions(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates, std::vector<double>& inverseMasses);
82
83
84
85
86
87
88
89
90
91
92
93
94

   public:

      /**---------------------------------------------------------------------------------------

         ReferenceLincsAlgorithm constructor

         @param numberOfConstraints      number of constraints
         @param atomIndices              atom indices for contraints
         @param distance                 distances for constraints

         --------------------------------------------------------------------------------------- */

peastman's avatar
peastman committed
95
      ReferenceLincsAlgorithm(int numberOfConstraints, int** atomIndices, double* distance);
96
97
98
99
100
101
102
103
104

      /**---------------------------------------------------------------------------------------

         Get number of constraints

         @return number of constraints

         --------------------------------------------------------------------------------------- */

105
      int getNumberOfConstraints() const;
106
107
108
109
110
111
112
113
114

      /**---------------------------------------------------------------------------------------

         Get the number of terms to use in the series expansion

         @return terms

         --------------------------------------------------------------------------------------- */

115
      int getNumTerms() const;
116
117
118
119
120
121
122

      /**---------------------------------------------------------------------------------------

         Set the number of terms to use in the series expansion

         --------------------------------------------------------------------------------------- */

123
      void setNumTerms(int terms);
124
125
126
127
128
129
130
131
132
133
134
135

      /**---------------------------------------------------------------------------------------

         Apply Lincs algorithm

         @param numberOfAtoms    number of atoms
         @param atomCoordinates  atom coordinates
         @param atomCoordinatesP atom coordinates prime
         @param inverseMasses    1/mass

         --------------------------------------------------------------------------------------- */

peastman's avatar
peastman committed
136
137
      void apply(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates,
                       std::vector<OpenMM::Vec3>& atomCoordinatesP, std::vector<double>& inverseMasses);
138
139
140
141
142
143
144
145
146
147
148
149

      /**---------------------------------------------------------------------------------------

         Apply constraint algorithm to velocities.

         @param numberOfAtoms    number of atoms
         @param atomCoordinates  atom coordinates
         @param velocities       atom velocities
         @param inverseMasses    1/mass

         --------------------------------------------------------------------------------------- */

peastman's avatar
peastman committed
150
151
      void applyToVelocities(int numberOfAtoms, std::vector<OpenMM::Vec3>& atomCoordinates,
                     std::vector<OpenMM::Vec3>& velocities, std::vector<double>& inverseMasses);
152
153
};

154
} // namespace OpenMM
155
156

#endif // __ReferenceLincsAlgorithm_H__