48#include "applications/staticProps/StaticAnalyser.hpp"
60#include "utils/Revision.hpp"
61#include "utils/simError.h"
65 StaticAnalyser::StaticAnalyser(
SimInfo* info,
const std::string& filename,
68 dumpFilename_(filename), step_(1), nBins_(nbins) {}
70 void StaticAnalyser::writeOutput() {
71 std::ofstream ofs(outputFilename_.c_str());
75 ofs <<
"# " << getAnalysisType() <<
"\n";
76 ofs <<
"# OpenMD " << r.getFullRevision() <<
"\n";
77 ofs <<
"# " << r.getBuildDate() <<
"\n";
80 if (!paramString_.empty())
81 ofs <<
"# parameters: " << paramString_ <<
"\n";
85 for (
const auto& data : data_) {
86 if (!data.accumulator.empty()) {
87 ofs <<
"\t" << data.title <<
"(" << data.units <<
")";
90 if (data.accumulator[0]->getType() ==
91 std::type_index(
typeid(Vector3d))) {
95 if (data.accumulator[0]->getType() ==
96 std::type_index(
typeid(std::vector<RealType>))) {
98 for (
unsigned int type = 0; type < outputTypes_.size(); type++) {
99 ofs << outputTypes_[type]->getName() <<
"\t";
110 for (
unsigned int bin = 0; bin < nBins_; bin++) {
111 for (
const auto& data : data_) {
112 if (!data.accumulator.empty()) {
113 std::string message =
114 "StaticAnalyser detected a numerical error writing: " +
115 data.title +
" for bin " + std::to_string(bin);
117 data.accumulator[bin]->writeData(ofs, message, data.dataHandling);
123 ofs <<
"#######################################################\n";
124 ofs <<
"# 95% confidence intervals in those quantities follow:\n";
125 ofs <<
"#######################################################\n";
127 for (
unsigned int bin = 0; bin < nBins_; bin++) {
130 for (
const auto& data : data_) {
131 if (!data.accumulator.empty()) {
132 std::string message =
133 "StaticAnalyser detected a numerical error writing: " +
134 data.title +
" std. dev. for bin " + std::to_string(bin);
136 data.accumulator[bin]->writeErrorBars(ofs, message);
145 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
146 "StaticAnalyser: unable to open %s\n", outputFilename_.c_str());
147 painCave.isFatal = 1;
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.