48#include "brains/Thermo.hpp"
49#include "integrators/IntegratorCreator.hpp"
51#include "utils/Constants.hpp"
52#include "utils/simError.h"
66 RealType NPTxyz::calcConservedQuantity() {
67 thermostat = snap->getThermostat();
78 fkBT = info_->
getNdf() * Constants::kB * targetTemp;
80 RealType conservedQuantity;
82 RealType thermostat_kinetic;
83 RealType thermostat_potential;
84 RealType barostat_kinetic;
85 RealType barostat_potential;
88 totalEnergy = thermo.getTotalEnergy();
90 thermostat_kinetic = fkBT * tt2 * thermostat.first * thermostat.first /
91 (2.0 * Constants::energyConvert);
93 thermostat_potential = fkBT * thermostat.second / Constants::energyConvert;
98 barostat_kinetic = NkBT * tb2 * trEta / (2.0 * Constants::energyConvert);
101 (targetPressure * thermo.getVolume() / Constants::pressureConvert) /
102 Constants::energyConvert;
104 conservedQuantity = totalEnergy + thermostat_kinetic +
105 thermostat_potential + barostat_kinetic +
108 return conservedQuantity;
111 void NPTxyz::scaleSimBox() {
114 RealType scaleFactor;
115 RealType bigScale, smallScale;
127 for (i = 0; i < 3; i++) {
128 for (j = 0; j < 3; j++) {
129 scaleMat(i, j) = 0.0;
130 if (i == j) { scaleMat(i, j) = 1.0; }
134 for (i = 0; i < 3; i++) {
137 scaleFactor = exp(dt * eta(i, i));
139 scaleMat(i, i) = scaleFactor;
141 if (scaleMat(i, i) > bigScale) { bigScale = scaleMat(i, i); }
143 if (scaleMat(i, i) < smallScale) { smallScale = scaleMat(i, i); }
146 if ((bigScale > 1.1) || (smallScale < 0.9)) {
148 painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
149 "NPTxyz error: Attempting a Box scaling of more than 10 percent.\n"
150 " Check your tauBarostat, as it is probably too small!\n\n"
151 " scaleMat = [%lf\t%lf\t%lf]\n"
153 " [%lf\t%lf\t%lf]\n",
154 scaleMat(0, 0), scaleMat(0, 1), scaleMat(0, 2), scaleMat(1, 0),
155 scaleMat(1, 1), scaleMat(1, 2), scaleMat(2, 0), scaleMat(2, 1),
157 painCave.isFatal = 1;
161 hmat = hmat * scaleMat;
166 void NPTxyz::loadEta() { eta = snap->getBarostat(); }
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.