/** \file analyzer.cpp * * Takes evaluated fragments (energy and forces) and does evaluation of how sensible the BOSSANOVA * approach was, e.g. in the decay of the many-body-contributions. * */ //============================ INCLUDES =========================== #include "datacreator.hpp" #include "helpers.hpp" #include "parser.hpp" #include "periodentafel.hpp" // include config.h #ifdef HAVE_CONFIG_H #include #endif //============================== MAIN ============================= int main(int argc, char **argv) { periodentafel *periode = NULL; // and a period table of all elements EnergyMatrix Energy; EnergyMatrix Hcorrection; ForceMatrix Force; ForceMatrix Shielding; ForceMatrix ShieldingPAS; EnergyMatrix Time; EnergyMatrix EnergyFragments; EnergyMatrix HcorrectionFragments; ForceMatrix ForceFragments; ForceMatrix ShieldingFragments; ForceMatrix ShieldingPASFragments; KeySetsContainer KeySet; ofstream output; ofstream output2; ofstream output3; ofstream output4; ifstream input; stringstream filename; time_t t = time(NULL); struct tm *ts = localtime(&t); char *datum = asctime(ts); stringstream Orderxrange; stringstream Fragmentxrange; stringstream yrange; char *dir = NULL; bool Hcorrected = true; double norm; int counter; cout << "ANOVA Analyzer" << endl; cout << "==============" << endl; // Get the command line options if (argc < 4) { cout << "Usage: " << argv[0] << " [elementsdb]" << endl; cout << "\ttherein the output of a molecuilder fragmentation is expected, each fragment with a subdir containing an energy.all and a forces.all file." << endl; cout << "\tprefix of energy and forces file." << endl; cout << "\tcreated plotfiles and datafiles are placed into this directory " << endl; cout << "[elementsdb]\tpath to elements database, needed for shieldings." << endl; return 1; } else { dir = (char *) Malloc(sizeof(char)*(strlen(argv[2])+2), "main: *dir"); strcpy(dir, "/"); strcat(dir, argv[2]); } if (argc > 4) { cout << "Loading periodentafel." << endl; periode = new periodentafel; periode->LoadPeriodentafel(argv[4]); } // Test the given directory if (!TestParams(argc, argv)) return 1; // +++++++++++++++++ PARSING +++++++++++++++++++++++++++++++ // ------------- Parse through all Fragment subdirs -------- if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix,0,0)) return 1; Hcorrected = Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX,0,0); if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix,0,0)) return 1; if (!Time.ParseFragmentMatrix(argv[1], dir, TimeSuffix, 10,1)) return 1; if (periode != NULL) { // also look for PAS values if (!Shielding.ParseFragmentMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1; if (!ShieldingPAS.ParseFragmentMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1; } // ---------- Parse the TE Factors into an array ----------------- if (!Energy.ParseIndices()) return 1; if (Hcorrected) Hcorrection.ParseIndices(); // ---------- Parse the Force indices into an array --------------- if (!Force.ParseIndices(argv[1])) return 1; if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1; if (!ForceFragments.ParseIndices(argv[1])) return 1; // ---------- Parse the shielding indices into an array --------------- if (periode != NULL) { // also look for PAS values if(!Shielding.ParseIndices(argv[1])) return 1; if(!ShieldingPAS.ParseIndices(argv[1])) return 1; if (!ShieldingFragments.AllocateMatrix(Shielding.Header, Shielding.MatrixCounter, Shielding.RowCounter, Shielding.ColumnCounter)) return 1; if (!ShieldingPASFragments.AllocateMatrix(ShieldingPAS.Header, ShieldingPAS.MatrixCounter, ShieldingPAS.RowCounter, ShieldingPAS.ColumnCounter)) return 1; if(!ShieldingFragments.ParseIndices(argv[1])) return 1; if(!ShieldingPASFragments.ParseIndices(argv[1])) return 1; } // ---------- Parse the KeySets into an array --------------- if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1; if (!KeySet.ParseManyBodyTerms()) return 1; // ---------- Parse fragment files created by 'joiner' into an array ------------- if (!EnergyFragments.ParseFragmentMatrix(argv[1], dir, EnergyFragmentSuffix,0,0)) return 1; if (Hcorrected) HcorrectionFragments.ParseFragmentMatrix(argv[1], dir, HcorrectionFragmentSuffix,0,0); if (!ForceFragments.ParseFragmentMatrix(argv[1], dir, ForceFragmentSuffix,0,0)) return 1; if (periode != NULL) { // also look for PAS values if (!ShieldingFragments.ParseFragmentMatrix(argv[1], dir, ShieldingFragmentSuffix, 1, 0)) return 1; if (!ShieldingPASFragments.ParseFragmentMatrix(argv[1], dir, ShieldingPASFragmentSuffix, 1, 0)) return 1; } // +++++++++++++++ TESTING ++++++++++++++++++++++++++++++ // print energy and forces to file filename.str(""); filename << argv[3] << "/" << "energy-forces.all"; output.open(filename.str().c_str(), ios::out); output << endl << "Total Energy" << endl << "==============" << endl << Energy.Header << endl; for(int j=0;j MYEPSILON) output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k] / Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k]; else output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k]; } output << endl; output2 << endl; } output.close(); output2.close(); // +++++++++++++++++++++++++++++++++++++++ Plotting shieldings if (periode != NULL) { // also look for PAS values if (!CreateDataDeltaForcesOrderPerAtom(ShieldingPAS, ShieldingPASFragments, KeySet, argv[3], "DeltaShieldingsPAS-Order", "Plot of error between approximated shieldings and full shieldings versus the Bond Order", datum)) return 1; if (!CreateDataForcesOrderPerAtom(ShieldingPASFragments, KeySet, argv[3], "ShieldingsPAS-Order", "Plot of approximated shieldings versus the Bond Order", datum)) return 1; if (!AppendOutputFile(output, argv[3], "ShieldingsPAS-Order.dat" )) return false; output << endl << "# Full" << endl; for(int j=0;j1) && (k<6))? 1.e6 : 1.) << "\t"; output << endl; } } output.close(); // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM if (!CreateDataDeltaEnergyOrder(Energy, EnergyFragments, KeySet, argv[3], "DeltaEnergies-Order", "Plot of error between approximated and full energies energies versus the Bond Order", datum)) return 1; // +++++++++++++++++++++++++++++++++++Plotting Energies vs. Order if (!CreateDataEnergyOrder(EnergyFragments, KeySet, argv[3], "Energies-Order", "Plot of approximated energies versus the Bond Order", datum)) return 1; // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in forces to full QM if (!CreateDataDeltaForcesOrderPerAtom(Force, ForceFragments, KeySet, argv[3], "DeltaForces-Order", "Plot of error between approximated forces and full forces versus the Bond Order", datum)) return 1; // min force if (!CreateDataDeltaForcesOrder(Force, ForceFragments, KeySet, argv[3], "DeltaMinForces-Order", "Plot of min error between approximated forces and full forces versus the Bond Order", datum, CreateMinimumForce)) return 1; // mean force if (!CreateDataDeltaForcesOrder(Force, ForceFragments, KeySet, argv[3], "DeltaMeanForces-Order", "Plot of mean error between approximated forces and full forces versus the Bond Order", datum, CreateMeanForce)) return 1; // max force if (!CreateDataDeltaForcesOrder(Force, ForceFragments, KeySet, argv[3], "DeltaMaxForces-Order", "Plot of max error between approximated forces and full forces versus the Bond Order", datum, CreateMaximumForce)) return 1; // ++++++++++++++++++++++++++++++++++++++Plotting Forces vs. Order if (!CreateDataForcesOrderPerAtom(ForceFragments, KeySet, argv[3], "Forces-Order", "Plot of approximated forces versus the Bond Order", datum)) return 1; if (!AppendOutputFile(output, argv[3], "Forces-Order.dat" )) return false; output << endl << "# Full" << endl; for(int j=0;j