45#include "applications/sequentialProps/CenterOfMass.hpp"
52#include "utils/Revision.hpp"
53#include "utils/simError.h"
57 CenterOfMass::CenterOfMass(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) +
".com");
64 void CenterOfMass::doFrame(
int) {
68 if (evaluator1_.isDynamic()) {
69 seleMan1_.setSelectionSet(evaluator1_.evaluate());
76 for (sd = seleMan1_.beginSelected(i); sd != NULL;
77 sd = seleMan1_.nextSelected(i)) {
80 com += sd->getPos() * mass;
85 values_.push_back(com);
88 void CenterOfMass::writeSequence() {
89 std::ofstream ofs(outputFilename_.c_str(), std::ios::binary);
94 ofs <<
"# " << getSequenceType() <<
"\n";
95 ofs <<
"# OpenMD " << r.getFullRevision() <<
"\n";
96 ofs <<
"# " << r.getBuildDate() <<
"\n";
97 ofs <<
"# selection script1: \"" << selectionScript1_;
98 ofs <<
"\"\tselection script2: \"" << selectionScript2_ <<
"\"\n";
99 if (!paramString_.empty())
100 ofs <<
"# parameters: " << paramString_ <<
"\n";
102 ofs <<
"#time\tvalue\n";
104 for (
unsigned int i = 0; i < times_.size(); ++i) {
105 ofs << times_[i] <<
"\t" << values_[i].x() <<
"\t" << values_[i].y()
106 <<
"\t" << values_[i].z() <<
"\n";
110 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
111 "CenterOfMass::writeSequence Error: failed to open %s\n",
112 outputFilename_.c_str());
113 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)