| 39 |
|
virtual void constrainB( void ); |
| 40 |
|
virtual int readyCheck( void ) { return 1; } |
| 41 |
|
|
| 42 |
+ |
virtual void resetIntegrator( void ) { } |
| 43 |
+ |
|
| 44 |
|
virtual void calcForce( int calcPot, int calcStress ); |
| 45 |
|
virtual void thermalize(); |
| 46 |
|
|
| 47 |
|
void checkConstraints( void ); |
| 48 |
|
void rotate( int axes1, int axes2, double angle, double j[3], |
| 49 |
< |
double A[3][3] ); |
| 50 |
< |
|
| 49 |
> |
double A[3][3] ); |
| 50 |
> |
|
| 51 |
|
ForceFields* myFF; |
| 52 |
|
|
| 53 |
|
SimInfo *info; // all the info we'll ever need |
| 58 |
|
int nMols; |
| 59 |
|
|
| 60 |
|
int isConstrained; // boolean to know whether the systems contains |
| 61 |
< |
// constraints. |
| 61 |
> |
// constraints. |
| 62 |
|
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 |
| 107 |
|
|
| 108 |
|
virtual int readyCheck(); |
| 109 |
|
|
| 110 |
+ |
virtual void resetIntegrator( void ); |
| 111 |
+ |
|
| 112 |
|
// chi is a propagated degree of freedom. |
| 113 |
|
|
| 114 |
|
double chi; |
| 148 |
|
|
| 149 |
|
virtual int readyCheck(); |
| 150 |
|
|
| 151 |
+ |
virtual void resetIntegrator( void ); |
| 152 |
+ |
|
| 153 |
|
// chi and eta are the propagated degrees of freedom |
| 154 |
|
|
| 155 |
|
double chi; |
| 193 |
|
|
| 194 |
|
virtual int readyCheck(); |
| 195 |
|
|
| 196 |
+ |
virtual void resetIntegrator( void ); |
| 197 |
+ |
|
| 198 |
|
Molecule* myMolecules; |
| 199 |
|
Atom** myAtoms; |
| 200 |
|
|
| 217 |
|
|
| 218 |
|
}; |
| 219 |
|
|
| 220 |
+ |
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 |
|
template<typename T> class NPTf : public T{ |
| 270 |
|
|
| 271 |
|
public: |
| 288 |
|
virtual void moveA( void ); |
| 289 |
|
virtual void moveB( void ); |
| 290 |
|
|
| 291 |
+ |
virtual void resetIntegrator( void ); |
| 292 |
+ |
|
| 293 |
|
virtual int readyCheck(); |
| 294 |
|
|
| 295 |
|
// chi and eta are the propagated degrees of freedom |
| 296 |
|
|
| 297 |
|
double chi; |
| 298 |
|
double eta[3][3]; |
| 299 |
+ |
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 |
+ |
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. |
| 361 |
|
|
| 362 |
|
}; |
| 363 |
|
|
| 364 |
+ |
|
| 365 |
|
template<typename T> class NPTfm : public T{ |
| 366 |
|
|
| 367 |
|
public: |
| 384 |
|
virtual void moveA( void ); |
| 385 |
|
virtual void moveB( void ); |
| 386 |
|
|
| 387 |
+ |
virtual void resetIntegrator( void ); |
| 388 |
+ |
|
| 389 |
|
virtual int readyCheck(); |
| 390 |
|
|
| 391 |
|
Molecule* myMolecules; |
| 392 |
|
Atom** myAtoms; |
| 393 |
+ |
|
| 394 |
+ |
// 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 |
+ |
|
| 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 |
+ |
virtual void resetIntegrator( void ); |
| 439 |
+ |
|
| 440 |
|
// chi and eta are the propagated degrees of freedom |
| 441 |
|
|
| 442 |
|
double chi; |
| 456 |
|
|
| 457 |
|
}; |
| 458 |
|
|
| 459 |
+ |
|
| 460 |
|
template<typename T> class ZConstraint : public T { |
| 461 |
+ |
|
| 462 |
+ |
public: |
| 463 |
+ |
class ForceSubtractionPolicy{ |
| 464 |
+ |
public: |
| 465 |
+ |
ForceSubtractionPolicy(ZConstraint<T>* integrator) {zconsIntegrator = integrator;} |
| 466 |
|
|
| 467 |
+ |
virtual void update() = 0; |
| 468 |
+ |
virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) = 0; |
| 469 |
+ |
virtual double getZFOfMovingMols(Atom* atom, double totalForce) = 0; |
| 470 |
+ |
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 |
+ |
}; |
| 476 |
+ |
|
| 477 |
+ |
class PolicyByNumber : public ForceSubtractionPolicy{ |
| 478 |
+ |
|
| 479 |
+ |
public: |
| 480 |
+ |
PolicyByNumber(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {} |
| 481 |
+ |
virtual void update(); |
| 482 |
+ |
virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ; |
| 483 |
+ |
virtual double getZFOfMovingMols(Atom* atom, double totalForce) ; |
| 484 |
+ |
virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce); |
| 485 |
+ |
virtual double getHFOfUnconsMols(Atom* atom, double totalForce); |
| 486 |
+ |
|
| 487 |
+ |
private: |
| 488 |
+ |
int totNumOfMovingAtoms; |
| 489 |
+ |
}; |
| 490 |
+ |
|
| 491 |
+ |
class PolicyByMass : public ForceSubtractionPolicy{ |
| 492 |
+ |
|
| 493 |
+ |
public: |
| 494 |
+ |
PolicyByMass(ZConstraint<T>* integrator) :ForceSubtractionPolicy(integrator) {} |
| 495 |
+ |
|
| 496 |
+ |
virtual void update(); |
| 497 |
+ |
virtual double getZFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce) ; |
| 498 |
+ |
virtual double getZFOfMovingMols(Atom* atom, double totalForce) ; |
| 499 |
+ |
virtual double getHFOfFixedZMols(Molecule* mol, Atom* atom, double totalForce); |
| 500 |
+ |
virtual double getHFOfUnconsMols(Atom* atom, double totalForce); |
| 501 |
+ |
|
| 502 |
+ |
private: |
| 503 |
+ |
double totMassOfMovingAtoms; |
| 504 |
+ |
}; |
| 505 |
+ |
|
| 506 |
|
public: |
| 507 |
|
|
| 508 |
|
ZConstraint( SimInfo *theInfo, ForceFields* the_ff); |
| 511 |
|
void setZConsTime(double time) {this->zconsTime = time;} |
| 512 |
|
void getZConsTime() {return zconsTime;} |
| 513 |
|
|
| 514 |
< |
void setIndexOfAllZConsMols(vector<int> index) {indexOfAllZConsMols = index;} |
| 515 |
< |
void getIndexOfAllZConsMols() {return indexOfAllZConsMols;} |
| 514 |
> |
void setIndexOfAllZConsMols(vector<int> index) {indexOfAllZConsMols = index;} |
| 515 |
> |
void getIndexOfAllZConsMols() {return indexOfAllZConsMols;} |
| 516 |
|
|
| 517 |
< |
void setZConsOutput(const char * fileName) {zconsOutput = fileName;} |
| 517 |
> |
void setZConsOutput(const char * fileName) {zconsOutput = fileName;} |
| 518 |
|
string getZConsOutput() {return zconsOutput;} |
| 519 |
|
|
| 520 |
|
virtual void integrate(); |
| 521 |
|
|
| 522 |
|
|
| 523 |
|
#ifdef IS_MPI |
| 524 |
< |
virtual void update(); //which is called to indicate the molecules' migration |
| 524 |
> |
virtual void update(); //which is called to indicate the molecules' migration |
| 525 |
|
#endif |
| 526 |
|
|
| 527 |
|
protected: |
| 528 |
|
|
| 529 |
< |
enum ZConsState {zcsMoving, zcsFixed}; |
| 327 |
< |
|
| 328 |
< |
|
| 529 |
> |
enum ZConsState {zcsMoving, zcsFixed}; |
| 530 |
|
|
| 531 |
|
virtual void calcForce( int calcPot, int calcStress ); |
| 532 |
|
virtual void thermalize(void); |
| 533 |
|
|
| 534 |
|
void zeroOutVel(); |
| 535 |
|
void doZconstraintForce(); |
| 536 |
+ |
void doHarmonic(); |
| 537 |
|
bool checkZConsState(); |
| 538 |
|
|
| 539 |
|
bool haveFixedZMols(); |
| 544 |
|
int isZConstraintMol(Molecule* mol); |
| 545 |
|
|
| 546 |
|
|
| 547 |
< |
double zconsTime; |
| 548 |
< |
double ztol; |
| 547 |
> |
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 |
|
|
| 552 |
< |
vector<Molecule*> zconsMols; |
| 553 |
< |
vector<double> massOfZConsMols; |
| 554 |
< |
vector<double> zconsPos; |
| 555 |
< |
vector<double> kz; |
| 556 |
< |
vector<ZConsState> states; |
| 353 |
< |
vector<double> ZPos; |
| 552 |
> |
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 |
|
|
| 558 |
|
|
| 559 |
< |
vector<Molecule*> unconsMols; |
| 560 |
< |
vector<double> massOfUnconsMols; |
| 561 |
< |
double totalMassOfUncons; |
| 559 |
> |
vector<Molecule*> unconsMols; //unconstraint molecules array |
| 560 |
> |
vector<double> massOfUnconsMols; //mass array of unconstraint molecules |
| 561 |
> |
double totalMassOfUncons; //total mas of unconstraint molecules |
| 562 |
> |
|
| 563 |
> |
vector<ZConsParaItem>* parameters; // |
| 564 |
|
|
| 565 |
|
vector<int> indexOfAllZConsMols; //index of All Z-Constraint Molecuels |
| 566 |
|
|
| 567 |
|
int* indexOfZConsMols; //index of local Z-Constraint Molecules |
| 568 |
|
double* fz; |
| 569 |
+ |
double* curZPos; |
| 570 |
|
|
| 571 |
< |
int totNumOfUnconsAtoms; |
| 571 |
> |
int totNumOfUnconsAtoms; //total number of uncontraint atoms |
| 572 |
|
|
| 573 |
|
int whichDirection; //constraint direction |
| 574 |
|
|
| 575 |
|
private: |
| 576 |
|
|
| 577 |
< |
string zconsOutput; |
| 578 |
< |
ZConsWriter* fzOut; |
| 577 |
> |
string zconsOutput; //filename of zconstraint output |
| 578 |
> |
ZConsWriter* fzOut; //z-constraint writer |
| 579 |
|
|
| 580 |
+ |
double curZconsTime; |
| 581 |
|
|
| 582 |
+ |
double calcMovingMolsCOMVel(); |
| 583 |
+ |
double calcSysCOMVel(); |
| 584 |
+ |
double calcTotalForce(); |
| 585 |
+ |
|
| 586 |
+ |
ForceSubtractionPolicy* forcePolicy; //force subtraction policy |
| 587 |
+ |
friend class ForceSubtractionPolicy; |
| 588 |
+ |
|
| 589 |
|
}; |
| 590 |
|
|
| 591 |
|
#endif |