38 |
|
myES = the_es; |
39 |
|
isFirst = 1; |
40 |
|
|
41 |
– |
std::cerr<< "calling symplectic constructor\n"; |
42 |
– |
|
41 |
|
molecules = entry_plug->molecules; |
42 |
|
nMols = entry_plug->n_mol; |
43 |
|
|
162 |
|
double dt2; // half the dt |
163 |
|
|
164 |
|
double vx, vy, vz; // the velocities |
165 |
< |
// double vx2, vy2, vz2; // the square of the velocities |
165 |
> |
double vx2, vy2, vz2; // the square of the velocities |
166 |
|
double rx, ry, rz; // the postitions |
167 |
|
|
168 |
|
double ji[3]; // the body frame angular momentum |
170 |
|
double Tb[3]; // torque in the body frame |
171 |
|
double angle; // the angle through which to rotate the rotation matrix |
172 |
|
double A[3][3]; // the rotation matrix |
173 |
+ |
double press[9]; |
174 |
|
|
175 |
|
int time; |
176 |
|
|
191 |
|
StatWriter* e_out; |
192 |
|
DumpWriter* dump_out; |
193 |
|
|
195 |
– |
std::cerr << "about to call new thermo\n"; |
196 |
– |
|
194 |
|
tStats = new Thermo( entry_plug ); |
195 |
|
e_out = new StatWriter( entry_plug ); |
199 |
– |
|
200 |
– |
std::cerr << "calling dumpWriter \n"; |
196 |
|
dump_out = new DumpWriter( entry_plug ); |
202 |
– |
std::cerr << "called dumpWriter \n"; |
197 |
|
|
198 |
|
Atom** atoms = entry_plug->atoms; |
199 |
|
DirectionalAtom* dAtom; |
213 |
|
|
214 |
|
calcPot = 0; |
215 |
|
|
216 |
+ |
if (!strcasecmp( entry_plug->ensemble, "NPT")) { |
217 |
+ |
calcStress = 1; |
218 |
+ |
} else { |
219 |
+ |
calcStress = 0; |
220 |
+ |
} |
221 |
+ |
|
222 |
|
if( n_constrained ){ |
223 |
|
|
224 |
|
double *Rx = new double[nAtoms]; |
235 |
|
|
236 |
|
|
237 |
|
for( tl=0; tl < n_loops; tl++ ){ |
238 |
+ |
|
239 |
|
|
240 |
|
for( j=0; j<nAtoms; j++ ){ |
241 |
|
|
334 |
|
} |
335 |
|
} |
336 |
|
|
337 |
+ |
if (!strcasecmp( entry_plug->ensemble, "NVT")) |
338 |
+ |
myES->NoseHooverNVT( dt / 2.0 , tStats->getKinetic() ); |
339 |
+ |
|
340 |
|
// calculate the forces |
341 |
|
|
342 |
|
myFF->doForces(calcPot, calcStress); |
404 |
|
} |
405 |
|
} |
406 |
|
|
407 |
+ |
|
408 |
+ |
if (!strcasecmp( entry_plug->ensemble, "NVT")) |
409 |
+ |
myES->NoseHooverNVT( dt / 2.0, tStats->getKinetic() ); |
410 |
+ |
|
411 |
+ |
if (!strcasecmp( entry_plug->ensemble, "NPT") ) { |
412 |
+ |
tStats->getPressureTensor(press); |
413 |
+ |
myES->NoseHooverAndersonNPT( dt, |
414 |
+ |
tStats->getKinetic(), |
415 |
+ |
press); |
416 |
+ |
} |
417 |
+ |
|
418 |
|
time = tl + 1; |
419 |
|
|
420 |
|
if( entry_plug->setTemp ){ |
423 |
|
if( !(time % sample_n) ) dump_out->writeDump( time * dt ); |
424 |
|
if( !((time+1) % status_n) ) { |
425 |
|
calcPot = 1; |
426 |
< |
calcStress = 1; |
426 |
> |
calcStress = 1; |
427 |
|
} |
428 |
|
if( !(time % status_n) ){ |
429 |
|
e_out->writeStat( time * dt ); |
430 |
|
calcPot = 0; |
431 |
< |
calcStress = 0; |
431 |
> |
if (!strcasecmp(entry_plug->ensemble, "NPT")) calcStress = 1; |
432 |
> |
else calcStress = 0; |
433 |
|
} |
434 |
|
} |
435 |
|
} |
440 |
|
kE = 0.0; |
441 |
|
rot_kE= 0.0; |
442 |
|
trans_kE = 0.0; |
443 |
< |
|
443 |
> |
|
444 |
|
for( i=0; i<nAtoms; i++ ){ |
445 |
|
|
446 |
|
// velocity half step |
525 |
|
dAtom->setJz( ji[2] ); |
526 |
|
} |
527 |
|
} |
528 |
+ |
|
529 |
+ |
if (!strcasecmp( entry_plug->ensemble, "NVT")) |
530 |
+ |
myES->NoseHooverNVT( dt / 2.0, tStats->getKinetic() ); |
531 |
|
|
532 |
+ |
|
533 |
|
// calculate the forces |
534 |
|
|
535 |
|
myFF->doForces(calcPot,calcStress); |
549 |
|
atoms[i]->set_vy( vy ); |
550 |
|
atoms[i]->set_vz( vz ); |
551 |
|
|
552 |
< |
// vx2 = vx * vx; |
553 |
< |
// vy2 = vy * vy; |
554 |
< |
// vz2 = vz * vz; |
552 |
> |
vx2 = vx * vx; |
553 |
> |
vy2 = vy * vy; |
554 |
> |
vz2 = vz * vz; |
555 |
|
|
556 |
|
if( atoms[i]->isDirectional() ){ |
557 |
|
|
583 |
|
dAtom->setJy( ji[1] ); |
584 |
|
dAtom->setJz( ji[2] ); |
585 |
|
} |
586 |
+ |
|
587 |
|
} |
588 |
< |
|
588 |
> |
|
589 |
> |
if (!strcasecmp( entry_plug->ensemble, "NVT")) |
590 |
> |
myES->NoseHooverNVT( dt / 2.0, tStats->getKinetic() ); |
591 |
> |
|
592 |
> |
if (!strcasecmp( entry_plug->ensemble, "NPT") ) { |
593 |
> |
tStats->getPressureTensor(press); |
594 |
> |
myES->NoseHooverAndersonNPT( dt, |
595 |
> |
tStats->getKinetic(), |
596 |
> |
press); |
597 |
> |
} |
598 |
> |
|
599 |
|
time = tl + 1; |
600 |
|
|
601 |
|
if( entry_plug->setTemp ){ |
604 |
|
if( !(time % sample_n) ) dump_out->writeDump( time * dt ); |
605 |
|
if( !((time+1) % status_n) ) { |
606 |
|
calcPot = 1; |
607 |
< |
calcStress = 1; |
607 |
> |
calcStress = 1; |
608 |
|
} |
609 |
|
if( !(time % status_n) ){ |
610 |
|
e_out->writeStat( time * dt ); |
611 |
|
calcPot = 0; |
612 |
< |
calcStress = 0; |
612 |
> |
if (!strcasecmp(entry_plug->ensemble, "NPT")) calcStress = 1; |
613 |
> |
else calcStress = 0; |
614 |
|
} |
615 |
|
} |
616 |
|
} |