45#include "applications/sequentialProps/COMVel.hpp"
52#include "utils/Revision.hpp"
53#include "utils/simError.h"
57 COMVel::COMVel(SimInfo* info,
const std::string& filename,
58 const std::string& sele1,
const std::string& sele2) :
59 SequentialAnalyzer(info, filename, sele1, sele2) {
60 setOutputName(
getPrefix(filename) +
".comVel");
63 void COMVel::doFrame(
int) {
67 if (evaluator1_.isDynamic()) {
68 seleMan1_.setSelectionSet(evaluator1_.evaluate());
72 Vector3d comVel(V3Zero);
75 for (sd = seleMan1_.beginSelected(i); sd != NULL;
76 sd = seleMan1_.nextSelected(i)) {
79 comVel += sd->getVel() * mass;
84 values_.push_back(comVel);
87 void COMVel::writeSequence() {
88 std::ofstream ofs(outputFilename_.c_str(), std::ios::binary);
93 ofs <<
"# " << getSequenceType() <<
"\n";
94 ofs <<
"# OpenMD " << r.getFullRevision() <<
"\n";
95 ofs <<
"# " << r.getBuildDate() <<
"\n";
96 ofs <<
"# selection script1: \"" << selectionScript1_;
97 ofs <<
"\"\tselection script2: \"" << selectionScript2_ <<
"\"\n";
98 if (!paramString_.empty())
99 ofs <<
"# parameters: " << paramString_ <<
"\n";
101 ofs <<
"#time\tvalue\n";
103 for (
unsigned int i = 0; i < times_.size(); ++i) {
104 ofs << times_[i] <<
"\t" << values_[i].x() <<
"\t" << values_[i].y()
105 <<
"\t" << values_[i].z() <<
"\n";
109 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
110 "COMVel::writeSequence Error: failed to open %s\n",
111 outputFilename_.c_str());
112 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)