1 |
mmeineke |
377 |
#ifndef _INTEGRATOR_H_ |
2 |
|
|
#define _INTEGRATOR_H_ |
3 |
|
|
|
4 |
tim |
658 |
#include <string> |
5 |
|
|
#include <vector> |
6 |
mmeineke |
377 |
#include "Atom.hpp" |
7 |
gezelter |
604 |
#include "Molecule.hpp" |
8 |
mmeineke |
377 |
#include "SRI.hpp" |
9 |
|
|
#include "AbstractClasses.hpp" |
10 |
|
|
#include "SimInfo.hpp" |
11 |
|
|
#include "ForceFields.hpp" |
12 |
mmeineke |
540 |
#include "Thermo.hpp" |
13 |
|
|
#include "ReadWrite.hpp" |
14 |
tim |
658 |
#include "ZConsWriter.hpp" |
15 |
mmeineke |
377 |
|
16 |
tim |
658 |
using namespace std; |
17 |
mmeineke |
561 |
const double kB = 8.31451e-7;// boltzmann constant amu*Ang^2*fs^-2/K |
18 |
|
|
const double eConvert = 4.184e-4; // converts kcal/mol -> amu*A^2/fs^2 |
19 |
mmeineke |
586 |
const double p_convert = 1.63882576e8; //converts amu*fs^-2*Ang^-1 -> atm |
20 |
mmeineke |
561 |
const int maxIteration = 300; |
21 |
|
|
const double tol = 1.0e-6; |
22 |
|
|
|
23 |
mmeineke |
377 |
|
24 |
tim |
645 |
template<typename T = BaseIntegrator> class Integrator : public T { |
25 |
|
|
|
26 |
mmeineke |
377 |
public: |
27 |
mmeineke |
561 |
Integrator( SimInfo *theInfo, ForceFields* the_ff ); |
28 |
mmeineke |
548 |
virtual ~Integrator(); |
29 |
mmeineke |
377 |
void integrate( void ); |
30 |
|
|
|
31 |
|
|
|
32 |
mmeineke |
540 |
protected: |
33 |
mmeineke |
377 |
|
34 |
mmeineke |
540 |
virtual void integrateStep( int calcPot, int calcStress ); |
35 |
mmeineke |
548 |
virtual void preMove( void ); |
36 |
mmeineke |
540 |
virtual void moveA( void ); |
37 |
|
|
virtual void moveB( void ); |
38 |
|
|
virtual void constrainA( void ); |
39 |
|
|
virtual void constrainB( void ); |
40 |
mmeineke |
559 |
virtual int readyCheck( void ) { return 1; } |
41 |
tim |
677 |
|
42 |
mmeineke |
746 |
virtual void resetIntegrator( void ) { } |
43 |
|
|
|
44 |
tim |
677 |
virtual void calcForce( int calcPot, int calcStress ); |
45 |
|
|
virtual void thermalize(); |
46 |
mmeineke |
377 |
|
47 |
mmeineke |
540 |
void checkConstraints( void ); |
48 |
mmeineke |
377 |
void rotate( int axes1, int axes2, double angle, double j[3], |
49 |
tim |
701 |
double A[3][3] ); |
50 |
|
|
|
51 |
mmeineke |
377 |
ForceFields* myFF; |
52 |
|
|
|
53 |
mmeineke |
540 |
SimInfo *info; // all the info we'll ever need |
54 |
|
|
int nAtoms; /* the number of atoms */ |
55 |
mmeineke |
548 |
int oldAtoms; |
56 |
mmeineke |
540 |
Atom **atoms; /* array of atom pointers */ |
57 |
mmeineke |
423 |
Molecule* molecules; |
58 |
|
|
int nMols; |
59 |
|
|
|
60 |
mmeineke |
548 |
int isConstrained; // boolean to know whether the systems contains |
61 |
tim |
701 |
// constraints. |
62 |
mmeineke |
548 |
int nConstrained; // counter for number of constraints |
63 |
|
|
int *constrainedA; // the i of a constraint pair |
64 |
|
|
int *constrainedB; // the j of a constraint pair |
65 |
|
|
double *constrainedDsqr; // the square of the constraint distance |
66 |
|
|
|
67 |
|
|
int* moving; // tells whether we are moving atom i |
68 |
|
|
int* moved; // tells whether we have moved atom i |
69 |
mmeineke |
561 |
double* oldPos; // pre constrained positions |
70 |
mmeineke |
548 |
|
71 |
mmeineke |
540 |
short isFirst; /*boolean for the first time integrate is called */ |
72 |
|
|
|
73 |
|
|
double dt; |
74 |
mmeineke |
541 |
double dt2; |
75 |
gezelter |
560 |
|
76 |
mmeineke |
540 |
Thermo *tStats; |
77 |
|
|
StatWriter* statOut; |
78 |
|
|
DumpWriter* dumpOut; |
79 |
mmeineke |
377 |
|
80 |
|
|
}; |
81 |
|
|
|
82 |
tim |
645 |
typedef Integrator<BaseIntegrator> RealIntegrator; |
83 |
mmeineke |
540 |
|
84 |
tim |
645 |
template<typename T> class NVE : public T { |
85 |
|
|
|
86 |
mmeineke |
561 |
public: |
87 |
|
|
NVE ( SimInfo *theInfo, ForceFields* the_ff ): |
88 |
tim |
645 |
T( theInfo, the_ff ){} |
89 |
|
|
virtual ~NVE(){} |
90 |
|
|
}; |
91 |
mmeineke |
555 |
|
92 |
|
|
|
93 |
tim |
645 |
template<typename T> class NVT : public T { |
94 |
mmeineke |
555 |
|
95 |
gezelter |
560 |
public: |
96 |
|
|
|
97 |
mmeineke |
561 |
NVT ( SimInfo *theInfo, ForceFields* the_ff); |
98 |
|
|
virtual ~NVT() {} |
99 |
mmeineke |
540 |
|
100 |
gezelter |
560 |
void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} |
101 |
|
|
void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;} |
102 |
|
|
|
103 |
mmeineke |
540 |
protected: |
104 |
gezelter |
560 |
|
105 |
mmeineke |
561 |
virtual void moveA( void ); |
106 |
|
|
virtual void moveB( void ); |
107 |
mmeineke |
540 |
|
108 |
mmeineke |
561 |
virtual int readyCheck(); |
109 |
gezelter |
560 |
|
110 |
mmeineke |
746 |
virtual void resetIntegrator( void ); |
111 |
|
|
|
112 |
gezelter |
565 |
// chi is a propagated degree of freedom. |
113 |
gezelter |
560 |
|
114 |
gezelter |
565 |
double chi; |
115 |
gezelter |
560 |
|
116 |
gezelter |
565 |
// targetTemp must be set. tauThermostat must also be set; |
117 |
gezelter |
560 |
|
118 |
|
|
double targetTemp; |
119 |
|
|
double tauThermostat; |
120 |
mmeineke |
561 |
|
121 |
gezelter |
565 |
short int have_tau_thermostat, have_target_temp; |
122 |
gezelter |
560 |
|
123 |
mmeineke |
540 |
}; |
124 |
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
tim |
645 |
template<typename T> class NPTi : public T{ |
128 |
|
|
|
129 |
gezelter |
560 |
public: |
130 |
|
|
|
131 |
gezelter |
574 |
NPTi ( SimInfo *theInfo, ForceFields* the_ff); |
132 |
|
|
virtual ~NPTi() {}; |
133 |
gezelter |
560 |
|
134 |
mmeineke |
594 |
virtual void integrateStep( int calcPot, int calcStress ){ |
135 |
|
|
calcStress = 1; |
136 |
tim |
645 |
T::integrateStep( calcPot, calcStress ); |
137 |
mmeineke |
594 |
} |
138 |
|
|
|
139 |
gezelter |
560 |
void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} |
140 |
|
|
void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;} |
141 |
|
|
void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;} |
142 |
|
|
void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;} |
143 |
|
|
|
144 |
|
|
protected: |
145 |
|
|
|
146 |
mmeineke |
561 |
virtual void moveA( void ); |
147 |
|
|
virtual void moveB( void ); |
148 |
gezelter |
560 |
|
149 |
mmeineke |
561 |
virtual int readyCheck(); |
150 |
gezelter |
560 |
|
151 |
mmeineke |
746 |
virtual void resetIntegrator( void ); |
152 |
|
|
|
153 |
gezelter |
565 |
// chi and eta are the propagated degrees of freedom |
154 |
gezelter |
560 |
|
155 |
gezelter |
565 |
double chi; |
156 |
|
|
double eta; |
157 |
gezelter |
574 |
double NkBT; |
158 |
gezelter |
560 |
|
159 |
|
|
// targetTemp, targetPressure, and tauBarostat must be set. |
160 |
|
|
// One of qmass or tauThermostat must be set; |
161 |
|
|
|
162 |
|
|
double targetTemp; |
163 |
|
|
double targetPressure; |
164 |
|
|
double tauThermostat; |
165 |
|
|
double tauBarostat; |
166 |
|
|
|
167 |
|
|
short int have_tau_thermostat, have_tau_barostat, have_target_temp; |
168 |
gezelter |
565 |
short int have_target_pressure; |
169 |
gezelter |
560 |
|
170 |
|
|
}; |
171 |
|
|
|
172 |
tim |
645 |
template<typename T> class NPTim : public T{ |
173 |
gezelter |
596 |
|
174 |
|
|
public: |
175 |
|
|
|
176 |
|
|
NPTim ( SimInfo *theInfo, ForceFields* the_ff); |
177 |
|
|
virtual ~NPTim() {}; |
178 |
|
|
|
179 |
|
|
virtual void integrateStep( int calcPot, int calcStress ){ |
180 |
|
|
calcStress = 1; |
181 |
tim |
645 |
T::integrateStep( calcPot, calcStress ); |
182 |
gezelter |
596 |
} |
183 |
|
|
|
184 |
|
|
void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} |
185 |
|
|
void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;} |
186 |
|
|
void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;} |
187 |
|
|
void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;} |
188 |
|
|
|
189 |
|
|
protected: |
190 |
|
|
|
191 |
gezelter |
604 |
virtual void moveA( void ); |
192 |
gezelter |
596 |
virtual void moveB( void ); |
193 |
|
|
|
194 |
|
|
virtual int readyCheck(); |
195 |
|
|
|
196 |
mmeineke |
746 |
virtual void resetIntegrator( void ); |
197 |
|
|
|
198 |
gezelter |
604 |
Molecule* myMolecules; |
199 |
|
|
Atom** myAtoms; |
200 |
|
|
|
201 |
gezelter |
596 |
// chi and eta are the propagated degrees of freedom |
202 |
|
|
|
203 |
|
|
double chi; |
204 |
|
|
double eta; |
205 |
|
|
double NkBT; |
206 |
|
|
|
207 |
|
|
// targetTemp, targetPressure, and tauBarostat must be set. |
208 |
|
|
// One of qmass or tauThermostat must be set; |
209 |
|
|
|
210 |
|
|
double targetTemp; |
211 |
|
|
double targetPressure; |
212 |
|
|
double tauThermostat; |
213 |
|
|
double tauBarostat; |
214 |
|
|
|
215 |
|
|
short int have_tau_thermostat, have_tau_barostat, have_target_temp; |
216 |
|
|
short int have_target_pressure; |
217 |
|
|
|
218 |
|
|
}; |
219 |
|
|
|
220 |
mmeineke |
755 |
template<typename T> class NPTzm : public T{ |
221 |
|
|
|
222 |
|
|
public: |
223 |
|
|
|
224 |
|
|
NPTzm ( SimInfo *theInfo, ForceFields* the_ff); |
225 |
|
|
virtual ~NPTzm() {}; |
226 |
|
|
|
227 |
|
|
virtual void integrateStep( int calcPot, int calcStress ){ |
228 |
|
|
calcStress = 1; |
229 |
|
|
T::integrateStep( calcPot, calcStress ); |
230 |
|
|
} |
231 |
|
|
|
232 |
|
|
void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} |
233 |
|
|
void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;} |
234 |
|
|
void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;} |
235 |
|
|
void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;} |
236 |
|
|
|
237 |
|
|
protected: |
238 |
|
|
|
239 |
|
|
virtual void moveA( void ); |
240 |
|
|
virtual void moveB( void ); |
241 |
|
|
|
242 |
|
|
virtual int readyCheck(); |
243 |
|
|
|
244 |
|
|
virtual void resetIntegrator( void ); |
245 |
|
|
|
246 |
|
|
Molecule* myMolecules; |
247 |
|
|
Atom** myAtoms; |
248 |
|
|
|
249 |
|
|
// chi and eta are the propagated degrees of freedom |
250 |
|
|
|
251 |
|
|
double chi; |
252 |
|
|
double eta; |
253 |
|
|
double etaZ; |
254 |
|
|
double NkBT; |
255 |
|
|
|
256 |
|
|
// targetTemp, targetPressure, and tauBarostat must be set. |
257 |
|
|
// One of qmass or tauThermostat must be set; |
258 |
|
|
|
259 |
|
|
double targetTemp; |
260 |
|
|
double targetPressure; |
261 |
|
|
double tauThermostat; |
262 |
|
|
double tauBarostat; |
263 |
|
|
|
264 |
|
|
short int have_tau_thermostat, have_tau_barostat, have_target_temp; |
265 |
|
|
short int have_target_pressure; |
266 |
|
|
|
267 |
|
|
}; |
268 |
|
|
|
269 |
tim |
645 |
template<typename T> class NPTf : public T{ |
270 |
gezelter |
576 |
|
271 |
|
|
public: |
272 |
|
|
|
273 |
|
|
NPTf ( SimInfo *theInfo, ForceFields* the_ff); |
274 |
|
|
virtual ~NPTf() {}; |
275 |
|
|
|
276 |
mmeineke |
594 |
virtual void integrateStep( int calcPot, int calcStress ){ |
277 |
|
|
calcStress = 1; |
278 |
tim |
645 |
T::integrateStep( calcPot, calcStress ); |
279 |
mmeineke |
594 |
} |
280 |
|
|
|
281 |
gezelter |
576 |
void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} |
282 |
|
|
void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;} |
283 |
|
|
void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;} |
284 |
|
|
void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;} |
285 |
|
|
|
286 |
|
|
protected: |
287 |
|
|
|
288 |
|
|
virtual void moveA( void ); |
289 |
|
|
virtual void moveB( void ); |
290 |
|
|
|
291 |
mmeineke |
746 |
virtual void resetIntegrator( void ); |
292 |
|
|
|
293 |
gezelter |
576 |
virtual int readyCheck(); |
294 |
|
|
|
295 |
|
|
// chi and eta are the propagated degrees of freedom |
296 |
|
|
|
297 |
|
|
double chi; |
298 |
gezelter |
588 |
double eta[3][3]; |
299 |
gezelter |
576 |
double NkBT; |
300 |
|
|
|
301 |
|
|
// targetTemp, targetPressure, and tauBarostat must be set. |
302 |
|
|
// One of qmass or tauThermostat must be set; |
303 |
|
|
|
304 |
|
|
double targetTemp; |
305 |
|
|
double targetPressure; |
306 |
|
|
double tauThermostat; |
307 |
|
|
double tauBarostat; |
308 |
|
|
|
309 |
|
|
short int have_tau_thermostat, have_tau_barostat, have_target_temp; |
310 |
|
|
short int have_target_pressure; |
311 |
|
|
|
312 |
|
|
}; |
313 |
|
|
|
314 |
mmeineke |
755 |
template<typename T> class NPTxym : public T{ |
315 |
|
|
|
316 |
|
|
public: |
317 |
|
|
|
318 |
|
|
NPTxym ( SimInfo *theInfo, ForceFields* the_ff); |
319 |
|
|
virtual ~NPTxym() {}; |
320 |
|
|
|
321 |
|
|
virtual void integrateStep( int calcPot, int calcStress ){ |
322 |
|
|
calcStress = 1; |
323 |
|
|
T::integrateStep( calcPot, calcStress ); |
324 |
|
|
} |
325 |
|
|
|
326 |
|
|
void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} |
327 |
|
|
void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;} |
328 |
|
|
void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;} |
329 |
|
|
void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;} |
330 |
|
|
|
331 |
|
|
protected: |
332 |
|
|
|
333 |
|
|
virtual void moveA( void ); |
334 |
|
|
virtual void moveB( void ); |
335 |
|
|
|
336 |
|
|
virtual int readyCheck(); |
337 |
|
|
|
338 |
|
|
virtual void resetIntegrator( void ); |
339 |
|
|
|
340 |
|
|
Molecule* myMolecules; |
341 |
|
|
Atom** myAtoms; |
342 |
|
|
|
343 |
|
|
// chi and eta are the propagated degrees of freedom |
344 |
|
|
|
345 |
|
|
double chi; |
346 |
|
|
double eta; |
347 |
|
|
double etaX; |
348 |
|
|
double etaY; |
349 |
|
|
double NkBT; |
350 |
|
|
|
351 |
|
|
// targetTemp, targetPressure, and tauBarostat must be set. |
352 |
|
|
// One of qmass or tauThermostat must be set; |
353 |
|
|
|
354 |
|
|
double targetTemp; |
355 |
|
|
double targetPressure; |
356 |
|
|
double tauThermostat; |
357 |
|
|
double tauBarostat; |
358 |
|
|
|
359 |
|
|
short int have_tau_thermostat, have_tau_barostat, have_target_temp; |
360 |
|
|
short int have_target_pressure; |
361 |
|
|
|
362 |
|
|
}; |
363 |
|
|
|
364 |
|
|
|
365 |
tim |
645 |
template<typename T> class NPTfm : public T{ |
366 |
gezelter |
596 |
|
367 |
|
|
public: |
368 |
|
|
|
369 |
|
|
NPTfm ( SimInfo *theInfo, ForceFields* the_ff); |
370 |
|
|
virtual ~NPTfm() {}; |
371 |
|
|
|
372 |
|
|
virtual void integrateStep( int calcPot, int calcStress ){ |
373 |
|
|
calcStress = 1; |
374 |
tim |
645 |
T::integrateStep( calcPot, calcStress ); |
375 |
gezelter |
596 |
} |
376 |
|
|
|
377 |
|
|
void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} |
378 |
|
|
void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;} |
379 |
|
|
void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;} |
380 |
|
|
void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;} |
381 |
|
|
|
382 |
|
|
protected: |
383 |
|
|
|
384 |
|
|
virtual void moveA( void ); |
385 |
|
|
virtual void moveB( void ); |
386 |
|
|
|
387 |
mmeineke |
746 |
virtual void resetIntegrator( void ); |
388 |
|
|
|
389 |
gezelter |
596 |
virtual int readyCheck(); |
390 |
|
|
|
391 |
gezelter |
605 |
Molecule* myMolecules; |
392 |
|
|
Atom** myAtoms; |
393 |
|
|
|
394 |
gezelter |
596 |
// chi and eta are the propagated degrees of freedom |
395 |
|
|
|
396 |
|
|
double chi; |
397 |
|
|
double eta[3][3]; |
398 |
|
|
double NkBT; |
399 |
|
|
|
400 |
|
|
// targetTemp, targetPressure, and tauBarostat must be set. |
401 |
|
|
// One of qmass or tauThermostat must be set; |
402 |
|
|
|
403 |
|
|
double targetTemp; |
404 |
|
|
double targetPressure; |
405 |
|
|
double tauThermostat; |
406 |
|
|
double tauBarostat; |
407 |
|
|
|
408 |
|
|
short int have_tau_thermostat, have_tau_barostat, have_target_temp; |
409 |
|
|
short int have_target_pressure; |
410 |
|
|
|
411 |
|
|
}; |
412 |
|
|
|
413 |
gezelter |
718 |
|
414 |
|
|
template<typename T> class NPTpr : public T{ |
415 |
|
|
|
416 |
|
|
public: |
417 |
|
|
|
418 |
|
|
NPTpr ( SimInfo *theInfo, ForceFields* the_ff); |
419 |
|
|
virtual ~NPTpr() {}; |
420 |
|
|
|
421 |
|
|
virtual void integrateStep( int calcPot, int calcStress ){ |
422 |
|
|
calcStress = 1; |
423 |
|
|
T::integrateStep( calcPot, calcStress ); |
424 |
|
|
} |
425 |
|
|
|
426 |
|
|
void setTauThermostat(double tt) {tauThermostat = tt; have_tau_thermostat=1;} |
427 |
|
|
void setTauBarostat(double tb) {tauBarostat = tb; have_tau_barostat=1;} |
428 |
|
|
void setTargetTemp(double tt) {targetTemp = tt; have_target_temp = 1;} |
429 |
|
|
void setTargetPressure(double tp) {targetPressure = tp; have_target_pressure = 1;} |
430 |
|
|
|
431 |
|
|
protected: |
432 |
|
|
|
433 |
|
|
virtual void moveA( void ); |
434 |
|
|
virtual void moveB( void ); |
435 |
|
|
|
436 |
|
|
virtual int readyCheck(); |
437 |
|
|
|
438 |
mmeineke |
746 |
virtual void resetIntegrator( void ); |
439 |
|
|
|
440 |
gezelter |
718 |
// chi and eta are the propagated degrees of freedom |
441 |
|
|
|
442 |
|
|
double chi; |
443 |
|
|
double eta[3][3]; |
444 |
|
|
double NkBT; |
445 |
|
|
|
446 |
|
|
// targetTemp, targetPressure, and tauBarostat must be set. |
447 |
|
|
// One of qmass or tauThermostat must be set; |
448 |
|
|
|
449 |
|
|
double targetTemp; |
450 |
|
|
double targetPressure; |
451 |
|
|
double tauThermostat; |
452 |
|
|
double tauBarostat; |
453 |
|
|
|
454 |
|
|
short int have_tau_thermostat, have_tau_barostat, have_target_temp; |
455 |
|
|
short int have_target_pressure; |
456 |
|
|
|
457 |
|
|
}; |
458 |
|
|
|
459 |
|
|
|
460 |
tim |
658 |
template<typename T> class ZConstraint : public T { |
461 |
tim |
701 |
|
462 |
|
|
public: |
463 |
tim |
738 |
class ForceSubtractionPolicy{ |
464 |
tim |
699 |
public: |
465 |
tim |
738 |
ForceSubtractionPolicy(ZConstraint<T>* integrator) {zconsIntegrator = integrator;} |
466 |
tim |
658 |
|
467 |
tim |
701 |
virtual void update() = 0; |
468 |
tim |
699 |
virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0; |
469 |
|
|
virtual double getZFOfMovingMols(Atom* atom, double totalForce) = 0; |
470 |
tim |
701 |
virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0; |
471 |
|
|
virtual double getHFOfUnconsMols(Atom* atom, double totalForce) = 0; |
472 |
|
|
|
473 |
|
|
protected: |
474 |
|
|
ZConstraint<T>* zconsIntegrator;; |
475 |
tim |
699 |
}; |
476 |
|
|
|
477 |
tim |
738 |
class PolicyByNumber : public ForceSubtractionPolicy{ |
478 |
gezelter |
747 |
|
479 |
tim |
699 |
public: |
480 |
tim |
738 |
PolicyByNumber(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {} |
481 |
tim |
701 |
virtual void update(); |
482 |
tim |
699 |
virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ; |
483 |
|
|
virtual double getZFOfMovingMols(Atom* atom, double totalForce) ; |
484 |
tim |
701 |
virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce); |
485 |
|
|
virtual double getHFOfUnconsMols(Atom* atom, double totalForce); |
486 |
|
|
|
487 |
tim |
699 |
private: |
488 |
tim |
701 |
int totNumOfMovingAtoms; |
489 |
tim |
699 |
}; |
490 |
|
|
|
491 |
tim |
738 |
class PolicyByMass : public ForceSubtractionPolicy{ |
492 |
gezelter |
747 |
|
493 |
tim |
699 |
public: |
494 |
tim |
738 |
PolicyByMass(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {} |
495 |
tim |
701 |
|
496 |
|
|
virtual void update(); |
497 |
tim |
699 |
virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ; |
498 |
|
|
virtual double getZFOfMovingMols(Atom* atom, double totalForce) ; |
499 |
tim |
701 |
virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce); |
500 |
|
|
virtual double getHFOfUnconsMols(Atom* atom, double totalForce); |
501 |
tim |
699 |
|
502 |
tim |
701 |
private: |
503 |
|
|
double totMassOfMovingAtoms; |
504 |
tim |
699 |
}; |
505 |
|
|
|
506 |
tim |
658 |
public: |
507 |
|
|
|
508 |
|
|
ZConstraint( SimInfo *theInfo, ForceFields* the_ff); |
509 |
|
|
~ZConstraint(); |
510 |
tim |
677 |
|
511 |
tim |
658 |
void setZConsTime(double time) {this->zconsTime = time;} |
512 |
|
|
void getZConsTime() {return zconsTime;} |
513 |
|
|
|
514 |
tim |
701 |
void setIndexOfAllZConsMols(vector<int> index) {indexOfAllZConsMols = index;} |
515 |
|
|
void getIndexOfAllZConsMols() {return indexOfAllZConsMols;} |
516 |
tim |
658 |
|
517 |
tim |
701 |
void setZConsOutput(const char * fileName) {zconsOutput = fileName;} |
518 |
tim |
658 |
string getZConsOutput() {return zconsOutput;} |
519 |
tim |
677 |
|
520 |
|
|
virtual void integrate(); |
521 |
|
|
|
522 |
tim |
658 |
|
523 |
|
|
#ifdef IS_MPI |
524 |
tim |
701 |
virtual void update(); //which is called to indicate the molecules' migration |
525 |
mmeineke |
377 |
#endif |
526 |
tim |
658 |
|
527 |
|
|
protected: |
528 |
|
|
|
529 |
tim |
701 |
enum ZConsState {zcsMoving, zcsFixed}; |
530 |
tim |
677 |
|
531 |
|
|
virtual void calcForce( int calcPot, int calcStress ); |
532 |
|
|
virtual void thermalize(void); |
533 |
|
|
|
534 |
|
|
void zeroOutVel(); |
535 |
|
|
void doZconstraintForce(); |
536 |
tim |
682 |
void doHarmonic(); |
537 |
tim |
677 |
bool checkZConsState(); |
538 |
|
|
|
539 |
|
|
bool haveFixedZMols(); |
540 |
|
|
bool haveMovingZMols(); |
541 |
|
|
|
542 |
|
|
double calcZSys(); |
543 |
|
|
|
544 |
|
|
int isZConstraintMol(Molecule* mol); |
545 |
|
|
|
546 |
|
|
|
547 |
tim |
701 |
double zconsTime; //sample time |
548 |
|
|
double zconsTol; //tolerance of z-contratint |
549 |
|
|
double zForceConst; //base force constant term |
550 |
|
|
//which is estimate by OOPSE |
551 |
tim |
658 |
|
552 |
tim |
701 |
vector<Molecule*> zconsMols; //z-constraint molecules array |
553 |
|
|
vector<double> massOfZConsMols; //mass of z-constraint molecule |
554 |
|
|
vector<double> kz; //force constant array |
555 |
|
|
vector<ZConsState> states; //state of z-constraint molecules |
556 |
|
|
vector<double> zPos; // |
557 |
tim |
658 |
|
558 |
tim |
677 |
|
559 |
tim |
701 |
vector<Molecule*> unconsMols; //unconstraint molecules array |
560 |
|
|
vector<double> massOfUnconsMols; //mass array of unconstraint molecules |
561 |
|
|
double totalMassOfUncons; //total mas of unconstraint molecules |
562 |
tim |
682 |
|
563 |
tim |
701 |
vector<ZConsParaItem>* parameters; // |
564 |
tim |
658 |
|
565 |
|
|
vector<int> indexOfAllZConsMols; //index of All Z-Constraint Molecuels |
566 |
tim |
677 |
|
567 |
|
|
int* indexOfZConsMols; //index of local Z-Constraint Molecules |
568 |
tim |
658 |
double* fz; |
569 |
tim |
699 |
double* curZPos; |
570 |
tim |
658 |
|
571 |
tim |
701 |
int totNumOfUnconsAtoms; //total number of uncontraint atoms |
572 |
tim |
677 |
|
573 |
|
|
int whichDirection; //constraint direction |
574 |
|
|
|
575 |
tim |
658 |
private: |
576 |
tim |
677 |
|
577 |
tim |
701 |
string zconsOutput; //filename of zconstraint output |
578 |
|
|
ZConsWriter* fzOut; //z-constraint writer |
579 |
tim |
677 |
|
580 |
tim |
701 |
double curZconsTime; |
581 |
tim |
699 |
|
582 |
tim |
696 |
double calcMovingMolsCOMVel(); |
583 |
|
|
double calcSysCOMVel(); |
584 |
|
|
double calcTotalForce(); |
585 |
tim |
701 |
|
586 |
gezelter |
747 |
ForceSubtractionPolicy* forcePolicy; //force subtraction policy |
587 |
tim |
738 |
friend class ForceSubtractionPolicy; |
588 |
tim |
677 |
|
589 |
tim |
658 |
}; |
590 |
|
|
|
591 |
|
|
#endif |