45#include "applications/sequentialProps/equipartitionTest.hpp"
52#include "utils/Revision.hpp"
53#include "utils/simError.h"
57 Equipartition::Equipartition(SimInfo* info,
const std::string& filename,
58 const std::string& sele1,
59 const std::string& sele2) :
60 SequentialAnalyzer(info, filename, sele1, sele2) {
61 setOutputName(
getPrefix(filename) +
".temp");
64 void Equipartition::doFrame(
int) {
68 if (evaluator1_.isDynamic()) {
69 seleMan1_.setSelectionSet(evaluator1_.evaluate());
72 const RealType kb = 8.31451e-7;
76 for (sd = seleMan1_.beginSelected(i); sd != NULL;
77 sd = seleMan1_.nextSelected(i)) {
79 Vector3d linMom = sd->getVel() * sd->getMass();
80 linMom_Temp[0] += linMom[0] * linMom[0] / (kb * sd->getMass());
81 linMom_Temp[1] += linMom[1] * linMom[1] / (kb * sd->getMass());
82 linMom_Temp[2] += linMom[2] * linMom[2] / (kb * sd->getMass());
83 if (sd->isDirectional()) {
84 Vector3d angMom = sd->getJ();
85 Mat3x3d momentInertia = sd->getI();
86 angMom_Temp[0] += angMom[0] * angMom[0] / (kb * momentInertia(0, 0));
87 angMom_Temp[1] += angMom[1] * angMom[1] / (kb * momentInertia(1, 1));
88 angMom_Temp[2] += angMom[2] * angMom[2] / (kb * momentInertia(2, 2));
94 TempP_.push_back(linMom_Temp);
95 TempJ_.push_back(angMom_Temp);
98 void Equipartition::writeSequence() {
99 std::ofstream ofs(outputFilename_.c_str(), std::ios::binary);
104 ofs <<
"# " << getSequenceType() <<
"\n";
105 ofs <<
"# OpenMD " << r.getFullRevision() <<
"\n";
106 ofs <<
"# " << r.getBuildDate() <<
"\n";
107 ofs <<
"# selection script1: \"" << selectionScript1_;
108 if (!paramString_.empty())
109 ofs <<
"# parameters: " << paramString_ <<
"\n";
111 ofs <<
"#time\t Tpx\t Tpy \t Tpz \t Tjx \t Tjy \t Tjz\n";
113 for (
unsigned int i = 0; i < times_.size(); ++i) {
114 ofs << times_[i] <<
"\t" << TempP_[i].x() <<
"\t" << TempP_[i].y()
115 <<
"\t" << TempP_[i].z() <<
"\t" << TempJ_[i].x() <<
"\t"
116 << TempJ_[i].y() <<
"\t" << TempJ_[i].z() <<
"\n";
120 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
121 "Equipartition::writeSequence Error: failed to open %s\n",
122 outputFilename_.c_str());
123 painCave.isFatal = 1;
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
std::string getPrefix(const std::string &str)