48#include "applications/sequentialProps/equipartitionTest.hpp"
55#include "utils/Revision.hpp"
56#include "utils/simError.h"
60 Equipartition::Equipartition(
SimInfo* info,
const std::string& filename,
61 const std::string& sele1,
62 const std::string& sele2) :
64 setOutputName(
getPrefix(filename) +
".temp");
67 void Equipartition::doFrame(
int) {
71 if (evaluator1_.isDynamic()) {
72 seleMan1_.setSelectionSet(evaluator1_.evaluate());
75 const RealType kb = 8.31451e-7;
79 for (sd = seleMan1_.beginSelected(i); sd != NULL;
80 sd = seleMan1_.nextSelected(i)) {
82 Vector3d linMom = sd->getVel() * sd->getMass();
83 linMom_Temp[0] += linMom[0] * linMom[0] / (kb * sd->getMass());
84 linMom_Temp[1] += linMom[1] * linMom[1] / (kb * sd->getMass());
85 linMom_Temp[2] += linMom[2] * linMom[2] / (kb * sd->getMass());
86 if (sd->isDirectional()) {
87 Vector3d angMom = sd->getJ();
88 Mat3x3d momentInertia = sd->getI();
89 angMom_Temp[0] += angMom[0] * angMom[0] / (kb * momentInertia(0, 0));
90 angMom_Temp[1] += angMom[1] * angMom[1] / (kb * momentInertia(1, 1));
91 angMom_Temp[2] += angMom[2] * angMom[2] / (kb * momentInertia(2, 2));
97 TempP_.push_back(linMom_Temp);
98 TempJ_.push_back(angMom_Temp);
101 void Equipartition::writeSequence() {
102 std::ofstream ofs(outputFilename_.c_str(), std::ios::binary);
107 ofs <<
"# " << getSequenceType() <<
"\n";
108 ofs <<
"# OpenMD " << r.getFullRevision() <<
"\n";
109 ofs <<
"# " << r.getBuildDate() <<
"\n";
110 ofs <<
"# selection script1: \"" << selectionScript1_;
111 if (!paramString_.empty())
112 ofs <<
"# parameters: " << paramString_ <<
"\n";
114 ofs <<
"#time\t Tpx\t Tpy \t Tpz \t Tjx \t Tjy \t Tjz\n";
116 for (
unsigned int i = 0; i < times_.size(); ++i) {
117 ofs << times_[i] <<
"\t" << TempP_[i].x() <<
"\t" << TempP_[i].y()
118 <<
"\t" << TempP_[i].z() <<
"\t" << TempJ_[i].x() <<
"\t"
119 << TempJ_[i].y() <<
"\t" << TempJ_[i].z() <<
"\n";
123 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
124 "Equipartition::writeSequence Error: failed to open %s\n",
125 outputFilename_.c_str());
126 painCave.isFatal = 1;
"applications/sequentialProps/SequentialAnalyzer"
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
std::string getPrefix(const std::string &str)