51#include "brains/Thermo.hpp"
52#include "integrators/IntegratorCreator.hpp"
54#include "utils/Constants.hpp"
55#include "utils/simError.h"
60 Globals* simParams = info_->getSimParams();
63 if (simParams->getPrivilegedAxis() ==
"x")
65 else if (simParams->getPrivilegedAxis() ==
"y")
67 else if (simParams->getPrivilegedAxis() ==
"z")
71 void NPAT::evolveEtaA() {
74 (press(axis_, axis_) - targetPressure / Constants::pressureConvert) /
79 void NPAT::evolveEtaB() {
81 eta(axis_, axis_) = oldEta_(axis_, axis_) +
83 (press(axis_, axis_) -
84 targetPressure / Constants::pressureConvert) /
88 void NPAT::calcVelScale() {
89 for (
int i = 0; i < 3; i++) {
90 for (
int j = 0; j < 3; j++) {
91 vScale_(i, j) = eta(i, j);
93 if (i == j) { vScale_(i, j) += thermostat.first; }
98 void NPAT::getVelScaleA(Vector3d& sc,
const Vector3d& vel) {
102 void NPAT::getVelScaleB(Vector3d& sc,
int index) {
103 sc = vScale_ * oldVel[index];
106 void NPAT::getPosScale(
const Vector3d& pos,
const Vector3d& COM,
int index,
109 Vector3d rj = (oldPos[index] + pos) / (RealType)2.0 - COM;
113 void NPAT::scaleSimBox() {
116 for (
int i = 0; i < 3; i++) {
117 for (
int j = 0; j < 3; j++) {
118 scaleMat(i, j) = 0.0;
119 if (i == j) { scaleMat(i, j) = 1.0; }
123 scaleMat(axis_, axis_) = exp(dt * eta(axis_, axis_));
124 Mat3x3d hmat = snap->getHmat();
125 hmat = hmat * scaleMat;
129 bool NPAT::etaConverged() {
131 RealType diffEta, sumEta;
134 for (i = 0; i < 3; i++) {
135 sumEta += pow(prevEta_(i, i) - eta(i, i), 2);
138 diffEta = sqrt(sumEta / 3.0);
140 return (diffEta <= etaTolerance);
143 RealType NPAT::calcConservedQuantity() {
144 thermostat = snap->getThermostat();
150 NkBT = info_->getNGlobalIntegrableObjects() * Constants::kB * targetTemp;
155 fkBT = info_->getNdf() * Constants::kB * targetTemp;
157 RealType conservedQuantity;
158 RealType totalEnergy;
159 RealType thermostat_kinetic;
160 RealType thermostat_potential;
161 RealType barostat_kinetic;
162 RealType barostat_potential;
165 totalEnergy = thermo.getTotalEnergy();
167 thermostat_kinetic = fkBT * tt2 * thermostat.first * thermostat.first /
168 (2.0 * Constants::energyConvert);
170 thermostat_potential = fkBT * thermostat.second / Constants::energyConvert;
172 SquareMatrix<RealType, 3> tmp = eta.transpose() * eta;
175 barostat_kinetic = NkBT * tb2 * trEta / (2.0 * Constants::energyConvert);
178 (targetPressure * thermo.getVolume() / Constants::pressureConvert) /
179 Constants::energyConvert;
181 conservedQuantity = totalEnergy + thermostat_kinetic +
182 thermostat_potential + barostat_kinetic +
185 return conservedQuantity;
188 void NPAT::loadEta() {
189 eta = snap->getBarostat();
200 void NPAT::saveEta() { snap->setBarostat(eta); }
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.