/** \file joiner.cpp * * Takes evaluated fragments (energy and forces) and by reading the factors files determines total energy * and each force for the whole molecule. * */ //============================ INCLUDES =========================== #include "datacreator.hpp" #include "helpers.hpp" #include "parser.hpp" #include "periodentafel.hpp" //============================== MAIN ============================= int main(int argc, char **argv) { periodentafel *periode = NULL; // and a period table of all elements EnergyMatrix Energy; EnergyMatrix EnergyFragments; EnergyMatrix Hcorrection; EnergyMatrix HcorrectionFragments; ForceMatrix Force; ForceMatrix ForceFragments; HessianMatrix Hessian; HessianMatrix HessianFragments; ForceMatrix Shielding; ForceMatrix ShieldingPAS; ForceMatrix ShieldingFragments; ForceMatrix ShieldingPASFragments; ForceMatrix Chi; ForceMatrix ChiPAS; ForceMatrix ChiFragments; ForceMatrix ChiPASFragments; KeySetsContainer KeySet; stringstream prefix; char *dir = NULL; bool NoHCorrection = false; bool NoHessian = false; cout << "Joiner" << endl; cout << "======" << endl; // Get the command line options if (argc < 3) { 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 << "[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 > 3) { periode = new periodentafel; periode->LoadPeriodentafel(argv[3]); } // 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; if (!Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX, 0,0)) { NoHCorrection = true; cout << "No HCorrection matrices found, skipping these." << endl; } if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix, 0,0)) return 1; if (!Hessian.ParseFragmentMatrix(argv[1], dir, HessianSuffix, 0,0)) { NoHessian = true; cout << "No hessian matrices found, skipping these." << endl; } 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; if (!Chi.ParseFragmentMatrix(argv[1], dir, ChiSuffix, 1, 0)) return 1; if (!ChiPAS.ParseFragmentMatrix(argv[1], dir, ChiPASSuffix, 1, 0)) return 1; } // ---------- Parse the TE Factors into an array ----------------- if (!Energy.InitialiseIndices()) return 1; if (!NoHCorrection) Hcorrection.InitialiseIndices(); // ---------- Parse the Force indices into an array --------------- if (!Force.ParseIndices(argv[1])) return 1; // ---------- Parse the Hessian (=force) indices into an array --------------- if (!NoHessian) if (!Hessian.InitialiseIndices((class MatrixContainer *)&Force)) 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(!Chi.ParseIndices(argv[1])) return 1; if(!ChiPAS.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; if (!EnergyFragments.AllocateMatrix(Energy.Header, Energy.MatrixCounter, Energy.RowCounter, Energy.ColumnCounter)) return 1; if (!NoHCorrection) HcorrectionFragments.AllocateMatrix(Hcorrection.Header, Hcorrection.MatrixCounter, Hcorrection.RowCounter, Hcorrection.ColumnCounter); if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1; if (!NoHessian) if (!HessianFragments.AllocateMatrix(Hessian.Header, Hessian.MatrixCounter, Hessian.RowCounter, Hessian.ColumnCounter)) return 1; if (periode != NULL) { // also look for PAS values 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 (!ChiFragments.AllocateMatrix(Chi.Header, Chi.MatrixCounter, Chi.RowCounter, Chi.ColumnCounter)) return 1; if (!ChiPASFragments.AllocateMatrix(ChiPAS.Header, ChiPAS.MatrixCounter, ChiPAS.RowCounter, ChiPAS.ColumnCounter)) return 1; } // ----------- Resetting last matrices (where full QM values are stored right now) if(!Energy.SetLastMatrix(0., 0)) return 1; if(!Force.SetLastMatrix(0., 2)) return 1; if (!NoHessian) if (!Hessian.SetLastMatrix(0., 0)) return 1; if (periode != NULL) { // also look for PAS values if(!Shielding.SetLastMatrix(0., 2)) return 1; if(!ShieldingPAS.SetLastMatrix(0., 2)) return 1; if(!Chi.SetLastMatrix(0., 2)) return 1; if(!ChiPAS.SetLastMatrix(0., 2)) return 1; } // +++++++++++++++++ SUMMING +++++++++++++++++++++++++++++++ // --------- sum up and write for each order---------------- for (int BondOrder=0;BondOrder