ReferenceDynamics.cpp 6.14 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

/* Portions copyright (c) 2006 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.
 */

25
#include <cstring>
26
27
#include <sstream>

28
#include "SimTKOpenMMUtilities.h"
29
#include "ReferenceDynamics.h"
30
#include "openmm/OpenMMException.h"
31

32
33
#include <cstdio>

34
using std::vector;
35
using namespace OpenMM;
36

37

38
39
40
41
42
43
44
45
46
47
/**---------------------------------------------------------------------------------------

   ReferenceDynamics constructor

   @param numberOfAtoms  number of atoms
   @param deltaT         delta t for dynamics
   @param temperature    temperature

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

peastman's avatar
peastman committed
48
ReferenceDynamics::ReferenceDynamics(int numberOfAtoms,  double deltaT, double temperature) : 
49
                  _numberOfAtoms(numberOfAtoms), _deltaT(deltaT), _temperature(temperature), virtualSites(NULL) {
50

peastman's avatar
peastman committed
51
   _timeStep = 0;
52
   _referenceConstraint = NULL;
53
54
55
56
57
58
59
60
}

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

   ReferenceDynamics destructor

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

61
ReferenceDynamics::~ReferenceDynamics() {
62
63
64
65
66
67
68
69
70
71
}

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

   Get number of atoms

   @return number of atoms

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

72
int ReferenceDynamics::getNumberOfAtoms() const {
73
74
75
76
77
78
79
80
81
82
83
   return _numberOfAtoms;
}

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

   Get time step

   @return time step

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

84
int ReferenceDynamics::getTimeStep() const {
85
86
87
88
89
90
91
92
93
94
95
   return _timeStep;
}

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

   Increment time step

   @return incremented time step

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

96
int ReferenceDynamics::incrementTimeStep() {
97
98
99
100
101
102
103
104
105
106
107
   return (++_timeStep);
}

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

   Get delta t

   @return deltaT

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

peastman's avatar
peastman committed
108
double ReferenceDynamics::getDeltaT() const {
109
110
111
   return _deltaT;
}

112
113
114
115
116
117
/**---------------------------------------------------------------------------------------

   Set delta t

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

peastman's avatar
peastman committed
118
void ReferenceDynamics::setDeltaT(double deltaT) {
119
120
121
   _deltaT = deltaT;
}

122
123
124
125
126
127
128
129
/**---------------------------------------------------------------------------------------

   Get temperature

   @return temperature

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

peastman's avatar
peastman committed
130
double ReferenceDynamics::getTemperature() const {
131
132
133
   return _temperature;
}

Peter Eastman's avatar
Peter Eastman committed
134
135
136
137
138
139
140
141
142
143
/**---------------------------------------------------------------------------------------

   Set the temperature

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

void ReferenceDynamics::setTemperature(double temperature) {
    _temperature = temperature;
}

144
145
/**---------------------------------------------------------------------------------------

146
   Get ReferenceConstraint
147

148
   @return ReferenceConstraint  object
149
150
151

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

152
ReferenceConstraintAlgorithm* ReferenceDynamics::getReferenceConstraintAlgorithm() const {
153
   return _referenceConstraint;
154
155
156
157
}

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

158
   Set ReferenceConstraint
159

160
   @param referenceConstraint  ReferenceConstraint object
161
162
163

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

164
void ReferenceDynamics::setReferenceConstraintAlgorithm(ReferenceConstraintAlgorithm* referenceConstraint) {
165
   _referenceConstraint = referenceConstraint;
166
167
168
169
}

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

170
   Update -- driver routine for performing dynamics update of coordinates
171
172
   and velocities

173
   @param system              the System to be integrated
174
175
176
177
   @param atomCoordinates     atom coordinates
   @param velocities          velocities
   @param forces              forces
   @param masses              atom masses
178
   @param tolerance           the constraint tolerance
179
180
181

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

peastman's avatar
peastman committed
182
183
void ReferenceDynamics::update(const OpenMM::System& system, vector<Vec3>& atomCoordinates,
                               vector<Vec3>& velocities, vector<Vec3>& forces, vector<double>& masses, double tolerance) {
184
}
185
186
187
188
189
190
191
192
193
194

const ReferenceVirtualSites& ReferenceDynamics::getVirtualSites() const {
    if (virtualSites == NULL)
        throw OpenMMException("ReferenceVirtualSites has not been set");
    return *virtualSites;
}

void ReferenceDynamics::setVirtualSites(const ReferenceVirtualSites& sites) {
    virtualSites = &sites;
}