45#include "applications/staticProps/StaticAnalyser.hpp"
57#include "utils/Revision.hpp"
58#include "utils/simError.h"
62 StaticAnalyser::StaticAnalyser(SimInfo* info,
const std::string& filename,
65 dumpFilename_(filename), step_(1), nBins_(nbins) {}
67 void StaticAnalyser::writeOutput() {
68 std::ofstream ofs(outputFilename_.c_str());
72 ofs <<
"# " << getAnalysisType() <<
"\n";
73 ofs <<
"# OpenMD " << r.getFullRevision() <<
"\n";
74 ofs <<
"# " << r.getBuildDate() <<
"\n";
77 if (!paramString_.empty())
78 ofs <<
"# parameters: " << paramString_ <<
"\n";
82 for (
const auto& data : data_) {
83 if (!data.accumulator.empty()) {
84 ofs <<
"\t" << data.title <<
"(" << data.units <<
")";
87 if (data.accumulator[0]->getType() ==
88 std::type_index(
typeid(Vector3d))) {
92 if (data.accumulator[0]->getType() ==
93 std::type_index(
typeid(std::vector<RealType>))) {
95 for (
unsigned int type = 0; type < outputTypes_.size(); type++) {
96 ofs << outputTypes_[type]->getName() <<
"\t";
107 for (
unsigned int bin = 0; bin < nBins_; bin++) {
108 for (
const auto& data : data_) {
109 if (!data.accumulator.empty()) {
110 std::string message =
111 "StaticAnalyser detected a numerical error writing: " +
112 data.title +
" for bin " + std::to_string(bin);
114 data.accumulator[bin]->writeData(ofs, message, data.dataHandling);
120 ofs <<
"#######################################################\n";
121 ofs <<
"# 95% confidence intervals in those quantities follow:\n";
122 ofs <<
"#######################################################\n";
124 for (
unsigned int bin = 0; bin < nBins_; bin++) {
127 for (
const auto& data : data_) {
128 if (!data.accumulator.empty()) {
129 std::string message =
130 "StaticAnalyser detected a numerical error writing: " +
131 data.title +
" std. dev. for bin " + std::to_string(bin);
133 data.accumulator[bin]->writeErrorBars(ofs, message);
142 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
143 "StaticAnalyser: unable to open %s\n", outputFilename_.c_str());
144 painCave.isFatal = 1;
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.