48#include "brains/Thermo.hpp"
49#include "integrators/IntegratorCreator.hpp"
51#include "utils/Constants.hpp"
52#include "utils/simError.h"
57 Globals* simParams = info_->getSimParams();
60 if (simParams->getPrivilegedAxis() ==
"x")
62 else if (simParams->getPrivilegedAxis() ==
"y")
64 else if (simParams->getPrivilegedAxis() ==
"z")
68 void NPAT::evolveEtaA() {
71 (press(axis_, axis_) - targetPressure / Constants::pressureConvert) /
76 void NPAT::evolveEtaB() {
78 eta(axis_, axis_) = oldEta_(axis_, axis_) +
80 (press(axis_, axis_) -
81 targetPressure / Constants::pressureConvert) /
85 void NPAT::calcVelScale() {
86 for (
int i = 0; i < 3; i++) {
87 for (
int j = 0; j < 3; j++) {
88 vScale_(i, j) = eta(i, j);
90 if (i == j) { vScale_(i, j) += thermostat.first; }
99 void NPAT::getVelScaleB(
Vector3d& sc,
int index) {
100 sc = vScale_ * oldVel[index];
106 Vector3d rj = (oldPos[index] + pos) / (RealType)2.0 - COM;
110 void NPAT::scaleSimBox() {
113 for (
int i = 0; i < 3; i++) {
114 for (
int j = 0; j < 3; j++) {
115 scaleMat(i, j) = 0.0;
116 if (i == j) { scaleMat(i, j) = 1.0; }
120 scaleMat(axis_, axis_) = exp(dt * eta(axis_, axis_));
122 hmat = hmat * scaleMat;
126 bool NPAT::etaConverged() {
128 RealType diffEta, sumEta;
131 for (i = 0; i < 3; i++) {
132 sumEta += pow(prevEta_(i, i) - eta(i, i), 2);
135 diffEta = sqrt(sumEta / 3.0);
137 return (diffEta <= etaTolerance);
140 RealType NPAT::calcConservedQuantity() {
141 thermostat = snap->getThermostat();
152 fkBT = info_->
getNdf() * Constants::kB * targetTemp;
154 RealType conservedQuantity;
155 RealType totalEnergy;
156 RealType thermostat_kinetic;
157 RealType thermostat_potential;
158 RealType barostat_kinetic;
159 RealType barostat_potential;
162 totalEnergy = thermo.getTotalEnergy();
164 thermostat_kinetic = fkBT * tt2 * thermostat.first * thermostat.first /
165 (2.0 * Constants::energyConvert);
167 thermostat_potential = fkBT * thermostat.second / Constants::energyConvert;
172 barostat_kinetic = NkBT * tb2 * trEta / (2.0 * Constants::energyConvert);
175 (targetPressure * thermo.getVolume() / Constants::pressureConvert) /
176 Constants::energyConvert;
178 conservedQuantity = totalEnergy + thermostat_kinetic +
179 thermostat_potential + barostat_kinetic +
182 return conservedQuantity;
185 void NPAT::loadEta() {
186 eta = snap->getBarostat();
197 void NPAT::saveEta() { snap->setBarostat(eta); }
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.