45#include "integrators/NPTsz.hpp"
48#include "brains/Thermo.hpp"
49#include "integrators/IntegratorCreator.hpp"
51#include "utils/Constants.hpp"
52#include "utils/simError.h"
63 Globals* simParams = info_->getSimParams();
66 if (simParams->getPrivilegedAxis() ==
"x")
68 else if (simParams->getPrivilegedAxis() ==
"y")
70 else if (simParams->getPrivilegedAxis() ==
"z")
74 axis1_ = (axis_ + 1) % 3;
75 axis2_ = (axis_ + 2) % 3;
78 RealType NPTsz::calcConservedQuantity() {
79 thermostat = snap->getThermostat();
90 fkBT = info_->
getNdf() * Constants::kB * targetTemp;
92 RealType conservedQuantity;
94 RealType thermostat_kinetic;
95 RealType thermostat_potential;
96 RealType barostat_kinetic;
97 RealType barostat_potential;
100 totalEnergy = thermo.getTotalEnergy();
102 thermostat_kinetic = fkBT * tt2 * thermostat.first * thermostat.first /
103 (2.0 * Constants::energyConvert);
105 thermostat_potential = fkBT * thermostat.second / Constants::energyConvert;
110 barostat_kinetic = NkBT * tb2 * trEta / (2.0 * Constants::energyConvert);
113 (targetPressure * thermo.getVolume() / Constants::pressureConvert) /
114 Constants::energyConvert;
116 conservedQuantity = totalEnergy + thermostat_kinetic +
117 thermostat_potential + barostat_kinetic +
120 return conservedQuantity;
123 void NPTsz::scaleSimBox() {
126 RealType scaleFactor;
127 RealType bigScale, smallScale;
140 for (i = 0; i < 3; i++) {
141 for (j = 0; j < 3; j++) {
142 scaleMat(i, j) = 0.0;
143 if (i == j) { scaleMat(i, j) = 1.0; }
149 0.5 * (exp(dt * eta(axis1_, axis1_)) + exp(dt * eta(axis2_, axis2_)));
150 scaleMat(axis1_, axis1_) = scaleFactor;
151 scaleMat(axis2_, axis2_) = scaleFactor;
153 bigScale = scaleFactor;
154 smallScale = scaleFactor;
157 scaleFactor = exp(dt * eta(axis_, axis_));
158 scaleMat(axis_, axis_) = scaleFactor;
159 if (scaleFactor > bigScale) bigScale = scaleFactor;
160 if (scaleFactor < smallScale) smallScale = scaleFactor;
162 if ((bigScale > 1.1) || (smallScale < 0.9)) {
163 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
164 "NPTsz: Attempting a Box scaling of more than 10 percent.\n"
165 "\tCheck your tauBarostat, as it is probably too small!\n\n"
166 "\tscaleMat = [%lf\t%lf\t%lf]\n"
167 "\t [%lf\t%lf\t%lf]\n"
168 "\t [%lf\t%lf\t%lf]\n",
169 scaleMat(0, 0), scaleMat(0, 1), scaleMat(0, 2), scaleMat(1, 0),
170 scaleMat(1, 1), scaleMat(1, 2), scaleMat(2, 0), scaleMat(2, 1),
172 painCave.severity = OPENMD_ERROR;
173 painCave.isFatal = 1;
177 hmat = hmat * scaleMat;
182 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...
Mat3x3d getHmat()
Returns the H-Matrix.
void setHmat(const Mat3x3d &m)
Sets the H-Matrix.
Real trace() const
Returns the trace of this matrix.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.