51#include "brains/Thermo.hpp"
52#include "integrators/IntegratorCreator.hpp"
54#include "utils/Constants.hpp"
55#include "utils/simError.h"
69 RealType NPTxyz::calcConservedQuantity() {
70 thermostat = snap->getThermostat();
76 NkBT = info_->getNGlobalIntegrableObjects() * Constants::kB * targetTemp;
81 fkBT = info_->getNdf() * Constants::kB * targetTemp;
83 RealType conservedQuantity;
85 RealType thermostat_kinetic;
86 RealType thermostat_potential;
87 RealType barostat_kinetic;
88 RealType barostat_potential;
91 totalEnergy = thermo.getTotalEnergy();
93 thermostat_kinetic = fkBT * tt2 * thermostat.first * thermostat.first /
94 (2.0 * Constants::energyConvert);
96 thermostat_potential = fkBT * thermostat.second / Constants::energyConvert;
98 SquareMatrix<RealType, 3> tmp = eta.transpose() * eta;
101 barostat_kinetic = NkBT * tb2 * trEta / (2.0 * Constants::energyConvert);
104 (targetPressure * thermo.getVolume() / Constants::pressureConvert) /
105 Constants::energyConvert;
107 conservedQuantity = totalEnergy + thermostat_kinetic +
108 thermostat_potential + barostat_kinetic +
111 return conservedQuantity;
114 void NPTxyz::scaleSimBox() {
117 RealType scaleFactor;
118 RealType bigScale, smallScale;
130 for (i = 0; i < 3; i++) {
131 for (j = 0; j < 3; j++) {
132 scaleMat(i, j) = 0.0;
133 if (i == j) { scaleMat(i, j) = 1.0; }
137 for (i = 0; i < 3; i++) {
140 scaleFactor = exp(dt * eta(i, i));
142 scaleMat(i, i) = scaleFactor;
144 if (scaleMat(i, i) > bigScale) { bigScale = scaleMat(i, i); }
146 if (scaleMat(i, i) < smallScale) { smallScale = scaleMat(i, i); }
149 if ((bigScale > 1.1) || (smallScale < 0.9)) {
151 painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
152 "NPTxyz error: Attempting a Box scaling of more than 10 percent.\n"
153 " Check your tauBarostat, as it is probably too small!\n\n"
154 " scaleMat = [%lf\t%lf\t%lf]\n"
156 " [%lf\t%lf\t%lf]\n",
157 scaleMat(0, 0), scaleMat(0, 1), scaleMat(0, 2), scaleMat(1, 0),
158 scaleMat(1, 1), scaleMat(1, 2), scaleMat(2, 0), scaleMat(2, 1),
160 painCave.isFatal = 1;
163 Mat3x3d hmat = snap->getHmat();
164 hmat = hmat * scaleMat;
169 void NPTxyz::loadEta() { eta = snap->getBarostat(); }
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.