45#include "applications/sequentialProps/SequentialAnalyzer.hpp"
52#include "utils/Revision.hpp"
53#include "utils/simError.h"
57 SequentialAnalyzer::SequentialAnalyzer(SimInfo* info,
58 const std::string& filename,
59 const std::string& sele1,
60 const std::string& sele2) :
62 currentSnapshot_(NULL), dumpFilename_(filename), seleMan1_(info),
63 selectionScript1_(sele1), evaluator1_(info), seleMan2_(info),
64 selectionScript2_(sele2), evaluator2_(info), step_(1) {
67 evaluator1_.loadScriptString(selectionScript1_);
68 evaluator2_.loadScriptString(selectionScript2_);
71 if (!evaluator1_.isDynamic()) {
72 seleMan1_.setSelectionSet(evaluator1_.evaluate());
74 if (!evaluator2_.isDynamic()) {
75 seleMan2_.setSelectionSet(evaluator2_.evaluate());
79 void SequentialAnalyzer::doSequence() {
82 DumpReader reader(info_, dumpFilename_);
83 int nFrames = reader.getNFrames();
87 for (frame_ = 0; frame_ < nFrames; frame_ += step_) {
88 reader.readFrame(frame_);
89 currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot();
90 times_.push_back(currentSnapshot_->getTime());
92 if (evaluator1_.isDynamic()) {
93 seleMan1_.setSelectionSet(evaluator1_.evaluate());
95 if (evaluator2_.isDynamic()) {
96 seleMan2_.setSelectionSet(evaluator2_.evaluate());
106 void SequentialAnalyzer::writeSequence() {
107 std::ofstream ofs(outputFilename_.c_str(), std::ios::binary);
112 ofs <<
"# " << getSequenceType() <<
"\n";
113 ofs <<
"# OpenMD " << r.getFullRevision() <<
"\n";
114 ofs <<
"# " << r.getBuildDate() <<
"\n";
115 ofs <<
"# selection script1: \"" << selectionScript1_;
116 ofs <<
"\"\tselection script2: \"" << selectionScript2_ <<
"\"\n";
117 if (!paramString_.empty())
118 ofs <<
"# parameters: " << paramString_ <<
"\n";
120 ofs <<
"#time\tvalue\n";
122 for (
unsigned int i = 0; i < times_.size(); ++i) {
123 ofs << times_[i] <<
"\t" << values_[i] <<
"\n";
127 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
128 "SequentialAnalyzer::writeSequence Error: failed to open %s\n",
129 outputFilename_.c_str());
130 painCave.isFatal = 1;
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.