1 |
|
#ifndef _INTEGRATOR_H_ |
2 |
|
#define _INTEGRATOR_H_ |
3 |
|
|
4 |
+ |
#include <string> |
5 |
+ |
#include <vector> |
6 |
|
#include "Atom.hpp" |
7 |
|
#include "Molecule.hpp" |
8 |
|
#include "SRI.hpp" |
11 |
|
#include "ForceFields.hpp" |
12 |
|
#include "Thermo.hpp" |
13 |
|
#include "ReadWrite.hpp" |
14 |
+ |
#include "ZConsWriter.hpp" |
15 |
|
|
16 |
+ |
using namespace std; |
17 |
|
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 |
|
const double p_convert = 1.63882576e8; //converts amu*fs^-2*Ang^-1 -> atm |
38 |
|
virtual void constrainA( void ); |
39 |
|
virtual void constrainB( void ); |
40 |
|
virtual int readyCheck( void ) { return 1; } |
41 |
+ |
|
42 |
+ |
virtual void calcForce( int calcPot, int calcStress ); |
43 |
+ |
virtual void thermalize(); |
44 |
|
|
45 |
|
void checkConstraints( void ); |
46 |
|
void rotate( int axes1, int axes2, double angle, double j[3], |
47 |
|
double A[3][3] ); |
48 |
< |
|
42 |
< |
|
48 |
> |
|
49 |
|
ForceFields* myFF; |
50 |
|
|
51 |
|
SimInfo *info; // all the info we'll ever need |
295 |
|
|
296 |
|
short int have_tau_thermostat, have_tau_barostat, have_target_temp; |
297 |
|
short int have_target_pressure; |
298 |
+ |
|
299 |
+ |
}; |
300 |
+ |
|
301 |
+ |
template<typename T> class ZConstraint : public T { |
302 |
+ |
|
303 |
+ |
public: |
304 |
+ |
class ForceSubstractionPolicy{ |
305 |
+ |
public: |
306 |
+ |
ForceSubstractionPolicy(ZConstraint<T>* integrator) {zconsIntegrator = integrator;} |
307 |
+ |
|
308 |
+ |
virtual void update() = 0; |
309 |
+ |
virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0; |
310 |
+ |
virtual double getZFOfMovingMols(Atom* atom, double totalForce) = 0; |
311 |
+ |
virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0; |
312 |
+ |
virtual double getHFOfUnconsMols(Atom* atom, double totalForce) = 0; |
313 |
+ |
|
314 |
+ |
protected: |
315 |
+ |
ZConstraint<T>* zconsIntegrator;; |
316 |
+ |
}; |
317 |
+ |
|
318 |
+ |
class PolicyByNumber : ForceSubstractionPolicy{ |
319 |
+ |
public: |
320 |
+ |
PolicyByNumber(ZConstraint<T>* integrator) :ForceSubstractionPolicy(integrator) {} |
321 |
+ |
virtual void update(); |
322 |
+ |
virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ; |
323 |
+ |
virtual double getZFOfMovingMols(Atom* atom, double totalForce) ; |
324 |
+ |
virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce); |
325 |
+ |
virtual double getHFOfUnconsMols(Atom* atom, double totalForce); |
326 |
+ |
|
327 |
+ |
private: |
328 |
+ |
int totNumOfMovingAtoms; |
329 |
+ |
}; |
330 |
+ |
|
331 |
+ |
class PolicyByMass :ForceSubstractionPolicy{ |
332 |
+ |
public: |
333 |
+ |
PolicyByMass(ZConstraint<T>* integrator) :ForceSubstractionPolicy(integrator) {} |
334 |
+ |
|
335 |
+ |
virtual void update(); |
336 |
+ |
virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ; |
337 |
+ |
virtual double getZFOfMovingMols(Atom* atom, double totalForce) ; |
338 |
+ |
virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce); |
339 |
+ |
virtual double getHFOfUnconsMols(Atom* atom, double totalForce); |
340 |
+ |
|
341 |
+ |
private: |
342 |
+ |
double totMassOfMovingAtoms; |
343 |
+ |
}; |
344 |
+ |
|
345 |
+ |
public: |
346 |
+ |
|
347 |
+ |
ZConstraint( SimInfo *theInfo, ForceFields* the_ff); |
348 |
+ |
~ZConstraint(); |
349 |
+ |
|
350 |
+ |
void setZConsTime(double time) {this->zconsTime = time;} |
351 |
+ |
void getZConsTime() {return zconsTime;} |
352 |
+ |
|
353 |
+ |
void setIndexOfAllZConsMols(vector<int> index) {indexOfAllZConsMols = index;} |
354 |
+ |
void getIndexOfAllZConsMols() {return indexOfAllZConsMols;} |
355 |
+ |
|
356 |
+ |
void setZConsOutput(const char * fileName) {zconsOutput = fileName;} |
357 |
+ |
string getZConsOutput() {return zconsOutput;} |
358 |
+ |
|
359 |
+ |
virtual void integrate(); |
360 |
+ |
|
361 |
|
|
362 |
+ |
#ifdef IS_MPI |
363 |
+ |
virtual void update(); //which is called to indicate the molecules' migration |
364 |
+ |
#endif |
365 |
+ |
|
366 |
+ |
protected: |
367 |
+ |
|
368 |
+ |
enum ZConsState {zcsMoving, zcsFixed}; |
369 |
+ |
|
370 |
+ |
|
371 |
+ |
|
372 |
+ |
virtual void calcForce( int calcPot, int calcStress ); |
373 |
+ |
virtual void thermalize(void); |
374 |
+ |
|
375 |
+ |
void zeroOutVel(); |
376 |
+ |
void doZconstraintForce(); |
377 |
+ |
void doHarmonic(); |
378 |
+ |
bool checkZConsState(); |
379 |
+ |
|
380 |
+ |
bool haveFixedZMols(); |
381 |
+ |
bool haveMovingZMols(); |
382 |
+ |
|
383 |
+ |
double calcZSys(); |
384 |
+ |
|
385 |
+ |
int isZConstraintMol(Molecule* mol); |
386 |
+ |
|
387 |
+ |
|
388 |
+ |
double zconsTime; |
389 |
+ |
double zconsTol; |
390 |
+ |
double zForceConst; |
391 |
+ |
|
392 |
+ |
vector<Molecule*> zconsMols; |
393 |
+ |
vector<double> massOfZConsMols; |
394 |
+ |
vector<double> kz; |
395 |
+ |
vector<ZConsState> states; |
396 |
+ |
vector<double> zPos; |
397 |
+ |
|
398 |
+ |
|
399 |
+ |
vector<Molecule*> unconsMols; |
400 |
+ |
vector<double> massOfUnconsMols; |
401 |
+ |
double totalMassOfUncons; |
402 |
+ |
|
403 |
+ |
vector<ZConsParaItem>* parameters; |
404 |
+ |
|
405 |
+ |
vector<int> indexOfAllZConsMols; //index of All Z-Constraint Molecuels |
406 |
+ |
|
407 |
+ |
int* indexOfZConsMols; //index of local Z-Constraint Molecules |
408 |
+ |
double* fz; |
409 |
+ |
double* curZPos; |
410 |
+ |
|
411 |
+ |
int totNumOfUnconsAtoms; |
412 |
+ |
|
413 |
+ |
int whichDirection; //constraint direction |
414 |
+ |
|
415 |
+ |
private: |
416 |
+ |
|
417 |
+ |
string zconsOutput; |
418 |
+ |
ZConsWriter* fzOut; |
419 |
+ |
|
420 |
+ |
double curZconsTime; |
421 |
+ |
|
422 |
+ |
double calcMovingMolsCOMVel(); |
423 |
+ |
double calcSysCOMVel(); |
424 |
+ |
double calcTotalForce(); |
425 |
+ |
|
426 |
+ |
ForceSubstractionPolicy* forcePolicy; |
427 |
+ |
friend class ForceSubstractionPolicy; |
428 |
+ |
|
429 |
|
}; |
430 |
|
|
431 |
|
#endif |