48#include "integrators/NPTsz.hpp"
51#include "brains/Thermo.hpp"
52#include "integrators/IntegratorCreator.hpp"
54#include "utils/Constants.hpp"
55#include "utils/simError.h"
66 Globals* simParams = info_->getSimParams();
69 if (simParams->getPrivilegedAxis() ==
"x")
71 else if (simParams->getPrivilegedAxis() ==
"y")
73 else if (simParams->getPrivilegedAxis() ==
"z")
77 axis1_ = (axis_ + 1) % 3;
78 axis2_ = (axis_ + 2) % 3;
81 RealType NPTsz::calcConservedQuantity() {
82 thermostat = snap->getThermostat();
93 fkBT = info_->
getNdf() * Constants::kB * targetTemp;
95 RealType conservedQuantity;
97 RealType thermostat_kinetic;
98 RealType thermostat_potential;
99 RealType barostat_kinetic;
100 RealType barostat_potential;
103 totalEnergy = thermo.getTotalEnergy();
105 thermostat_kinetic = fkBT * tt2 * thermostat.first * thermostat.first /
106 (2.0 * Constants::energyConvert);
108 thermostat_potential = fkBT * thermostat.second / Constants::energyConvert;
113 barostat_kinetic = NkBT * tb2 * trEta / (2.0 * Constants::energyConvert);
116 (targetPressure * thermo.getVolume() / Constants::pressureConvert) /
117 Constants::energyConvert;
119 conservedQuantity = totalEnergy + thermostat_kinetic +
120 thermostat_potential + barostat_kinetic +
123 return conservedQuantity;
126 void NPTsz::scaleSimBox() {
129 RealType scaleFactor;
130 RealType bigScale, smallScale;
143 for (i = 0; i < 3; i++) {
144 for (j = 0; j < 3; j++) {
145 scaleMat(i, j) = 0.0;
146 if (i == j) { scaleMat(i, j) = 1.0; }
152 0.5 * (exp(dt * eta(axis1_, axis1_)) + exp(dt * eta(axis2_, axis2_)));
153 scaleMat(axis1_, axis1_) = scaleFactor;
154 scaleMat(axis2_, axis2_) = scaleFactor;
156 bigScale = scaleFactor;
157 smallScale = scaleFactor;
160 scaleFactor = exp(dt * eta(axis_, axis_));
161 scaleMat(axis_, axis_) = scaleFactor;
162 if (scaleFactor > bigScale) bigScale = scaleFactor;
163 if (scaleFactor < smallScale) smallScale = scaleFactor;
165 if ((bigScale > 1.1) || (smallScale < 0.9)) {
166 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
167 "NPTsz: Attempting a Box scaling of more than 10 percent.\n"
168 "\tCheck your tauBarostat, as it is probably too small!\n\n"
169 "\tscaleMat = [%lf\t%lf\t%lf]\n"
170 "\t [%lf\t%lf\t%lf]\n"
171 "\t [%lf\t%lf\t%lf]\n",
172 scaleMat(0, 0), scaleMat(0, 1), scaleMat(0, 2), scaleMat(1, 0),
173 scaleMat(1, 1), scaleMat(1, 2), scaleMat(2, 0), scaleMat(2, 1),
175 painCave.severity = OPENMD_ERROR;
176 painCave.isFatal = 1;
179 Mat3x3d hmat = snap->getHmat();
180 hmat = hmat * scaleMat;
185 void NPTsz::loadEta() { eta = snap->getBarostat(); }
NPTsz(SimInfo *info)
There is no known conserved quantity for the NPTsz integrator, but we still compute the equivalent qu...
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
int getNdf()
Returns the number of degrees of freedom.
int getNGlobalIntegrableObjects()
Returns the total number of integrable objects (total number of rigid bodies plus the total number of...
Real trace() const
Returns the trace of this matrix.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.