173 |
|
pos[j] = oldPos[i*3 + j] + dt*(vel[j] + eta*rj[j]); |
174 |
|
|
175 |
|
atoms[i]->setPos( pos ); |
176 |
– |
|
176 |
|
} |
177 |
< |
|
177 |
> |
|
178 |
> |
if (nConstrained){ |
179 |
> |
constrainA(); |
180 |
> |
} |
181 |
|
} |
182 |
|
|
183 |
|
|
216 |
|
tt2 = tauThermostat * tauThermostat; |
217 |
|
tb2 = tauBarostat * tauBarostat; |
218 |
|
|
217 |
– |
|
219 |
|
// Set things up for the iteration: |
220 |
|
|
221 |
|
oldChi = chi; |
288 |
|
dAtom->setJ( ji ); |
289 |
|
} |
290 |
|
} |
291 |
< |
|
292 |
< |
if (fabs(prevChi - chi) <= chiTolerance && fabs(preEta -eta) <= etaTolerance) |
291 |
> |
|
292 |
> |
if (nConstrained){ |
293 |
> |
constrainB(); |
294 |
> |
} |
295 |
> |
|
296 |
> |
if (fabs(prevChi - chi) <= |
297 |
> |
chiTolerance && fabs(preEta -eta) <= etaTolerance) |
298 |
|
break; |
299 |
|
} |
300 |
|
|
369 |
|
simError(); |
370 |
|
} |
371 |
|
|
372 |
< |
if (!have_eta_tolerance) { |
372 |
> |
if (!have_eta_tolerance) { |
373 |
|
sprintf( painCave.errMsg, |
374 |
|
"NPTi warning: setting eta tolerance to 1e-6\n"); |
375 |
|
etaTolerance = 1e-6; |
377 |
|
painCave.isFatal = 0; |
378 |
|
simError(); |
379 |
|
} |
380 |
< |
// We need NkBT a lot, so just set it here: |
381 |
< |
|
380 |
> |
|
381 |
> |
|
382 |
> |
// We need NkBT a lot, so just set it here: This is the RAW number |
383 |
> |
// of particles, so no subtraction or addition of constraints or |
384 |
> |
// orientational degrees of freedom: |
385 |
> |
|
386 |
|
NkBT = (double)Nparticles * kB * targetTemp; |
387 |
+ |
|
388 |
+ |
// fkBT is used because the thermostat operates on more degrees of freedom |
389 |
+ |
// than the barostat (when there are particles with orientational degrees |
390 |
+ |
// of freedom). ndf = 3 * (n_atoms + n_oriented -1) - n_constraint - nZcons |
391 |
+ |
|
392 |
|
fkBT = (double)info->ndf * kB * targetTemp; |
393 |
|
|
394 |
|
return 1; |
397 |
|
template<typename T> double NPTi<T>::getConservedQuantity(void){ |
398 |
|
|
399 |
|
double conservedQuantity; |
400 |
+ |
double Three_NkBT; |
401 |
+ |
double Energy; |
402 |
+ |
double thermostat_kinetic; |
403 |
+ |
double thermostat_potential; |
404 |
+ |
double barostat_kinetic; |
405 |
+ |
double barostat_potential; |
406 |
|
double tb2; |
407 |
< |
double eta2; |
387 |
< |
double E_NPT; |
388 |
< |
double U; |
389 |
< |
double TS; |
390 |
< |
double PV; |
391 |
< |
double extra; |
407 |
> |
double eta2; |
408 |
|
|
409 |
< |
U = tStats->getTotalE(); |
409 |
> |
Energy = tStats->getTotalE(); |
410 |
|
|
411 |
< |
TS = fkBT * |
412 |
< |
(integralOfChidt + tauThermostat * tauThermostat * chi * chi / 2.0) / eConvert; |
411 |
> |
thermostat_kinetic = fkBT* tauThermostat * tauThermostat * chi * chi / |
412 |
> |
(2.0 * eConvert); |
413 |
|
|
414 |
< |
PV = (targetPressure * tStats->getVolume() / p_convert) / eConvert; |
414 |
> |
thermostat_potential = fkBT* integralOfChidt / eConvert; |
415 |
|
|
400 |
– |
tb2 = tauBarostat * tauBarostat; |
401 |
– |
eta2 = eta * eta; |
416 |
|
|
417 |
+ |
barostat_kinetic = 3.0 * NkBT * tauBarostat * tauBarostat * eta * eta / |
418 |
+ |
(2.0 * eConvert); |
419 |
+ |
|
420 |
+ |
barostat_potential = (targetPressure * tStats->getVolume() / p_convert) / |
421 |
+ |
eConvert; |
422 |
|
|
423 |
< |
extra = ((double)info->ndfTrans * kB * targetTemp * tb2 * eta2 / 2.0) / eConvert; |
424 |
< |
|
423 |
> |
conservedQuantity = Energy + thermostat_kinetic + thermostat_potential + |
424 |
> |
barostat_kinetic + barostat_potential; |
425 |
> |
|
426 |
|
cout.width(8); |
427 |
|
cout.precision(8); |
428 |
|
|
429 |
< |
|
430 |
< |
cout << info->getTime() << "\t" |
431 |
< |
<< chi << "\t" |
412 |
< |
<< eta << "\t" |
413 |
< |
<< U << "\t" |
414 |
< |
<< TS << "\t" |
415 |
< |
<< PV << "\t" |
416 |
< |
<< extra << "\t" |
417 |
< |
<< U+TS+PV+extra << endl; |
429 |
> |
cerr << info->getTime() << "\t" << Energy << "\t" << thermostat_kinetic << |
430 |
> |
"\t" << thermostat_potential << "\t" << barostat_kinetic << |
431 |
> |
"\t" << barostat_potential << "\t" << conservedQuantity << endl; |
432 |
|
|
419 |
– |
conservedQuantity = U+TS+PV+extra; |
433 |
|
return conservedQuantity; |
434 |
|
} |