[14de469] | 1 | /** \file analyzer.cpp
|
---|
| 2 | *
|
---|
| 3 | * Takes evaluated fragments (energy and forces) and does evaluation of how sensible the BOSSANOVA
|
---|
| 4 | * approach was, e.g. in the decay of the many-body-contributions.
|
---|
| 5 | *
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | //============================ INCLUDES ===========================
|
---|
| 9 |
|
---|
[68cb0f] | 10 | #include "datacreator.hpp"
|
---|
[14de469] | 11 | #include "helpers.hpp"
|
---|
| 12 | #include "parser.hpp"
|
---|
[68cb0f] | 13 | #include "periodentafel.hpp"
|
---|
| 14 |
|
---|
| 15 | // include config.h
|
---|
| 16 | #ifdef HAVE_CONFIG_H
|
---|
| 17 | #include <config.h>
|
---|
| 18 | #endif
|
---|
[14de469] | 19 |
|
---|
| 20 |
|
---|
| 21 | //============================== MAIN =============================
|
---|
| 22 |
|
---|
| 23 | int main(int argc, char **argv)
|
---|
| 24 | {
|
---|
[68cb0f] | 25 | periodentafel *periode = NULL; // and a period table of all elements
|
---|
[14de469] | 26 | EnergyMatrix Energy;
|
---|
[b12a35] | 27 | EnergyMatrix EnergyFragments;
|
---|
[14de469] | 28 | ForceMatrix Force;
|
---|
[b12a35] | 29 | ForceMatrix ForceFragments;
|
---|
| 30 | HessianMatrix Hessian;
|
---|
| 31 | HessianMatrix HessianFragments;
|
---|
| 32 | EnergyMatrix Hcorrection;
|
---|
| 33 | EnergyMatrix HcorrectionFragments;
|
---|
[68cb0f] | 34 | ForceMatrix Shielding;
|
---|
| 35 | ForceMatrix ShieldingPAS;
|
---|
[f05407] | 36 | EnergyMatrix Time;
|
---|
[68cb0f] | 37 | ForceMatrix ShieldingFragments;
|
---|
| 38 | ForceMatrix ShieldingPASFragments;
|
---|
| 39 | KeySetsContainer KeySet;
|
---|
[14de469] | 40 | ofstream output;
|
---|
| 41 | ofstream output2;
|
---|
| 42 | ofstream output3;
|
---|
| 43 | ofstream output4;
|
---|
[68cb0f] | 44 | ifstream input;
|
---|
[14de469] | 45 | stringstream filename;
|
---|
| 46 | time_t t = time(NULL);
|
---|
| 47 | struct tm *ts = localtime(&t);
|
---|
| 48 | char *datum = asctime(ts);
|
---|
| 49 | stringstream Orderxrange;
|
---|
| 50 | stringstream Fragmentxrange;
|
---|
[390248] | 51 | stringstream yrange;
|
---|
| 52 | char *dir = NULL;
|
---|
[b12a35] | 53 | bool NoHCorrection = false;
|
---|
| 54 | bool NoHessian = false;
|
---|
| 55 | bool NoTime = false;
|
---|
[390248] | 56 | double norm;
|
---|
[f05407] | 57 | int counter;
|
---|
[390248] | 58 |
|
---|
[14de469] | 59 | cout << "ANOVA Analyzer" << endl;
|
---|
| 60 | cout << "==============" << endl;
|
---|
| 61 |
|
---|
| 62 | // Get the command line options
|
---|
| 63 | if (argc < 4) {
|
---|
[68cb0f] | 64 | cout << "Usage: " << argv[0] << " <inputdir> <prefix> <outputdir> [elementsdb]" << endl;
|
---|
[14de469] | 65 | cout << "<inputdir>\ttherein the output of a molecuilder fragmentation is expected, each fragment with a subdir containing an energy.all and a forces.all file." << endl;
|
---|
| 66 | cout << "<prefix>\tprefix of energy and forces file." << endl;
|
---|
| 67 | cout << "<outputdir>\tcreated plotfiles and datafiles are placed into this directory " << endl;
|
---|
[68cb0f] | 68 | cout << "[elementsdb]\tpath to elements database, needed for shieldings." << endl;
|
---|
[14de469] | 69 | return 1;
|
---|
[390248] | 70 | } else {
|
---|
| 71 | dir = (char *) Malloc(sizeof(char)*(strlen(argv[2])+2), "main: *dir");
|
---|
| 72 | strcpy(dir, "/");
|
---|
| 73 | strcat(dir, argv[2]);
|
---|
[14de469] | 74 | }
|
---|
[390248] | 75 |
|
---|
[68cb0f] | 76 | if (argc > 4) {
|
---|
| 77 | cout << "Loading periodentafel." << endl;
|
---|
| 78 | periode = new periodentafel;
|
---|
| 79 | periode->LoadPeriodentafel(argv[4]);
|
---|
| 80 | }
|
---|
[14de469] | 81 |
|
---|
| 82 | // Test the given directory
|
---|
| 83 | if (!TestParams(argc, argv))
|
---|
| 84 | return 1;
|
---|
| 85 |
|
---|
| 86 | // +++++++++++++++++ PARSING +++++++++++++++++++++++++++++++
|
---|
| 87 |
|
---|
| 88 | // ------------- Parse through all Fragment subdirs --------
|
---|
[f05407] | 89 | if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix,0,0)) return 1;
|
---|
[b12a35] | 90 | if (!Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX,0,0)) {
|
---|
| 91 | NoHCorrection = true;
|
---|
| 92 | cout << "No HCorrection file found, skipping these." << endl;
|
---|
| 93 | }
|
---|
| 94 |
|
---|
[f05407] | 95 | if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix,0,0)) return 1;
|
---|
[b12a35] | 96 | if (!Hessian.ParseFragmentMatrix(argv[1], dir, HessianSuffix,0,0)) {
|
---|
| 97 | NoHessian = true;
|
---|
| 98 | cout << "No Hessian file found, skipping these." << endl;
|
---|
| 99 | }
|
---|
| 100 | if (!Time.ParseFragmentMatrix(argv[1], dir, TimeSuffix, 10,1)) {
|
---|
| 101 | NoTime = true;
|
---|
| 102 | cout << "No speed file found, skipping these." << endl;
|
---|
| 103 | }
|
---|
[68cb0f] | 104 | if (periode != NULL) { // also look for PAS values
|
---|
[f05407] | 105 | if (!Shielding.ParseFragmentMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1;
|
---|
| 106 | if (!ShieldingPAS.ParseFragmentMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1;
|
---|
[68cb0f] | 107 | }
|
---|
[14de469] | 108 |
|
---|
| 109 | // ---------- Parse the TE Factors into an array -----------------
|
---|
[f731ae] | 110 | if (!Energy.InitialiseIndices()) return 1;
|
---|
[b12a35] | 111 | if (!NoHCorrection)
|
---|
| 112 | Hcorrection.InitialiseIndices();
|
---|
[14de469] | 113 |
|
---|
| 114 | // ---------- Parse the Force indices into an array ---------------
|
---|
[2459b1] | 115 | if (!Force.ParseIndices(argv[1])) return 1;
|
---|
[390248] | 116 | if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1;
|
---|
[b12a35] | 117 | if (!ForceFragments.InitialiseIndices((class MatrixContainer *)&Force)) return 1;
|
---|
| 118 |
|
---|
| 119 | // ---------- Parse hessian indices into an array -----------------
|
---|
| 120 | if (!NoHessian) {
|
---|
| 121 | if (!Hessian.InitialiseIndices((class MatrixContainer *)&Force)) return 1;
|
---|
| 122 | if (!HessianFragments.AllocateMatrix(Hessian.Header, Hessian.MatrixCounter, Hessian.RowCounter, Hessian.ColumnCounter)) return 1;
|
---|
| 123 | if (!HessianFragments.InitialiseIndices((class MatrixContainer *)&Force)) return 1;
|
---|
| 124 | }
|
---|
[14de469] | 125 |
|
---|
[68cb0f] | 126 | // ---------- Parse the shielding indices into an array ---------------
|
---|
| 127 | if (periode != NULL) { // also look for PAS values
|
---|
| 128 | if(!Shielding.ParseIndices(argv[1])) return 1;
|
---|
| 129 | if(!ShieldingPAS.ParseIndices(argv[1])) return 1;
|
---|
[95634f] | 130 | if (!ShieldingFragments.AllocateMatrix(Shielding.Header, Shielding.MatrixCounter, Shielding.RowCounter, Shielding.ColumnCounter)) return 1;
|
---|
| 131 | if (!ShieldingPASFragments.AllocateMatrix(ShieldingPAS.Header, ShieldingPAS.MatrixCounter, ShieldingPAS.RowCounter, ShieldingPAS.ColumnCounter)) return 1;
|
---|
| 132 | if(!ShieldingFragments.ParseIndices(argv[1])) return 1;
|
---|
| 133 | if(!ShieldingPASFragments.ParseIndices(argv[1])) return 1;
|
---|
[68cb0f] | 134 | }
|
---|
| 135 |
|
---|
[14de469] | 136 | // ---------- Parse the KeySets into an array ---------------
|
---|
| 137 | if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1;
|
---|
| 138 | if (!KeySet.ParseManyBodyTerms()) return 1;
|
---|
[68cb0f] | 139 |
|
---|
| 140 | // ---------- Parse fragment files created by 'joiner' into an array -------------
|
---|
[f05407] | 141 | if (!EnergyFragments.ParseFragmentMatrix(argv[1], dir, EnergyFragmentSuffix,0,0)) return 1;
|
---|
[b12a35] | 142 | if (!NoHCorrection)
|
---|
| 143 | HcorrectionFragments.ParseFragmentMatrix(argv[1], dir, HcorrectionFragmentSuffix,0,0);
|
---|
[f05407] | 144 | if (!ForceFragments.ParseFragmentMatrix(argv[1], dir, ForceFragmentSuffix,0,0)) return 1;
|
---|
[b12a35] | 145 | if (!NoHessian)
|
---|
| 146 | if (!HessianFragments.ParseFragmentMatrix(argv[1], dir, HessianFragmentSuffix,0,0)) return 1;
|
---|
[68cb0f] | 147 | if (periode != NULL) { // also look for PAS values
|
---|
[95634f] | 148 | if (!ShieldingFragments.ParseFragmentMatrix(argv[1], dir, ShieldingFragmentSuffix, 1, 0)) return 1;
|
---|
| 149 | if (!ShieldingPASFragments.ParseFragmentMatrix(argv[1], dir, ShieldingPASFragmentSuffix, 1, 0)) return 1;
|
---|
[68cb0f] | 150 | }
|
---|
[14de469] | 151 |
|
---|
| 152 | // +++++++++++++++ TESTING ++++++++++++++++++++++++++++++
|
---|
| 153 |
|
---|
| 154 | // print energy and forces to file
|
---|
| 155 | filename.str("");
|
---|
| 156 | filename << argv[3] << "/" << "energy-forces.all";
|
---|
| 157 | output.open(filename.str().c_str(), ios::out);
|
---|
[b12a35] | 158 | output << endl << "Total Energy" << endl << "==============" << endl << Energy.Header[Energy.MatrixCounter] << endl;
|
---|
[14de469] | 159 | for(int j=0;j<Energy.RowCounter[Energy.MatrixCounter];j++) {
|
---|
[f731ae] | 160 | for(int k=0;k<Energy.ColumnCounter[Energy.MatrixCounter];k++)
|
---|
[14de469] | 161 | output << scientific << Energy.Matrix[ Energy.MatrixCounter ][j][k] << "\t";
|
---|
| 162 | output << endl;
|
---|
| 163 | }
|
---|
| 164 | output << endl;
|
---|
| 165 |
|
---|
[b12a35] | 166 | output << endl << "Total Forces" << endl << "===============" << endl << Force.Header[Force.MatrixCounter] << endl;
|
---|
[14de469] | 167 | for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) {
|
---|
[f731ae] | 168 | for(int k=0;k<Force.ColumnCounter[Force.MatrixCounter];k++)
|
---|
[14de469] | 169 | output << scientific << Force.Matrix[ Force.MatrixCounter ][j][k] << "\t";
|
---|
| 170 | output << endl;
|
---|
| 171 | }
|
---|
| 172 | output << endl;
|
---|
| 173 |
|
---|
[b12a35] | 174 | if (!NoHessian) {
|
---|
| 175 | output << endl << "Total Hessian" << endl << "===============" << endl << Hessian.Header[Hessian.MatrixCounter] << endl;
|
---|
| 176 | for(int j=0;j<Hessian.RowCounter[Hessian.MatrixCounter];j++) {
|
---|
| 177 | for(int k=0;k<Hessian.ColumnCounter[Hessian.MatrixCounter];k++)
|
---|
| 178 | output << scientific << Hessian.Matrix[ Hessian.MatrixCounter ][j][k] << "\t";
|
---|
| 179 | output << endl;
|
---|
| 180 | }
|
---|
| 181 | output << endl;
|
---|
| 182 | }
|
---|
| 183 |
|
---|
[68cb0f] | 184 | if (periode != NULL) { // also look for PAS values
|
---|
[b12a35] | 185 | output << endl << "Total Shieldings" << endl << "===============" << endl << Shielding.Header[Hessian.MatrixCounter] << endl;
|
---|
[68cb0f] | 186 | for(int j=0;j<Shielding.RowCounter[Shielding.MatrixCounter];j++) {
|
---|
[f731ae] | 187 | for(int k=0;k<Shielding.ColumnCounter[Shielding.MatrixCounter];k++)
|
---|
[68cb0f] | 188 | output << scientific << Shielding.Matrix[ Shielding.MatrixCounter ][j][k] << "\t";
|
---|
| 189 | output << endl;
|
---|
| 190 | }
|
---|
| 191 | output << endl;
|
---|
| 192 |
|
---|
[b12a35] | 193 | output << endl << "Total Shieldings PAS" << endl << "===============" << endl << ShieldingPAS.Header[ShieldingPAS.MatrixCounter] << endl;
|
---|
[68cb0f] | 194 | for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) {
|
---|
[f731ae] | 195 | for(int k=0;k<ShieldingPAS.ColumnCounter[ShieldingPAS.MatrixCounter];k++)
|
---|
[68cb0f] | 196 | output << scientific << ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t";
|
---|
| 197 | output << endl;
|
---|
| 198 | }
|
---|
| 199 | output << endl;
|
---|
| 200 | }
|
---|
| 201 |
|
---|
[b12a35] | 202 | if (!NoTime) {
|
---|
| 203 | output << endl << "Total Times" << endl << "===============" << endl << Time.Header[Time.MatrixCounter] << endl;
|
---|
| 204 | for(int j=0;j<Time.RowCounter[Time.MatrixCounter];j++) {
|
---|
| 205 | for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) {
|
---|
| 206 | output << scientific << Time.Matrix[ Time.MatrixCounter ][j][k] << "\t";
|
---|
| 207 | }
|
---|
| 208 | output << endl;
|
---|
[f05407] | 209 | }
|
---|
[b4b7c3] | 210 | output << endl;
|
---|
| 211 | }
|
---|
[14de469] | 212 | output.close();
|
---|
[b12a35] | 213 | if (!NoTime)
|
---|
| 214 | for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++)
|
---|
| 215 | Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k] = Time.Matrix[ Time.MatrixCounter ][Time.RowCounter[Time.MatrixCounter]-1][k];
|
---|
[14de469] | 216 |
|
---|
| 217 | // +++++++++++++++ ANALYZING ++++++++++++++++++++++++++++++
|
---|
| 218 |
|
---|
| 219 | cout << "Analyzing ..." << endl;
|
---|
| 220 |
|
---|
| 221 | // ======================================= Creating the data files ==============================================================
|
---|
| 222 |
|
---|
[b4b7c3] | 223 | // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order
|
---|
[f05407] | 224 | // +++++++++++++++++++++++++++++++++++++++ Plotting Delta Simtime vs Bond Order
|
---|
[b12a35] | 225 | if (!NoTime) {
|
---|
| 226 | if (!OpenOutputFile(output, argv[3], "SimTime-Order.dat" )) return false;
|
---|
| 227 | if (!OpenOutputFile(output2, argv[3], "DeltaSimTime-Order.dat" )) return false;
|
---|
| 228 | for(int j=Time.RowCounter[Time.MatrixCounter];j--;)
|
---|
| 229 | for(int k=Time.ColumnCounter[Time.MatrixCounter];k--;) {
|
---|
| 230 | Time.Matrix[ Time.MatrixCounter ][j][k] = 0.;
|
---|
| 231 | }
|
---|
| 232 | counter = 0;
|
---|
| 233 | output << "#Order\tFrag.No.\t" << Time.Header[Time.MatrixCounter] << endl;
|
---|
| 234 | output2 << "#Order\tFrag.No.\t" << Time.Header[Time.MatrixCounter] << endl;
|
---|
| 235 | for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
|
---|
| 236 | for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;)
|
---|
| 237 | for(int j=Time.RowCounter[Time.MatrixCounter];j--;)
|
---|
| 238 | for(int k=Time.ColumnCounter[Time.MatrixCounter];k--;) {
|
---|
| 239 | Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
|
---|
| 240 | }
|
---|
| 241 | counter += KeySet.FragmentsPerOrder[BondOrder];
|
---|
| 242 | output << BondOrder+1 << "\t" << counter;
|
---|
| 243 | output2 << BondOrder+1 << "\t" << counter;
|
---|
| 244 | for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) {
|
---|
| 245 | output << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k];
|
---|
| 246 | if (fabs(Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k]) > MYEPSILON)
|
---|
| 247 | output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k] / Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k];
|
---|
| 248 | else
|
---|
| 249 | output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k];
|
---|
| 250 | }
|
---|
| 251 | output << endl;
|
---|
| 252 | output2 << endl;
|
---|
[f05407] | 253 | }
|
---|
[b12a35] | 254 | output.close();
|
---|
| 255 | output2.close();
|
---|
| 256 | }
|
---|
| 257 |
|
---|
| 258 | if (!NoHessian) {
|
---|
| 259 | // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in hessian to full QM
|
---|
| 260 | if (!CreateDataDeltaHessianOrderPerAtom(Hessian, HessianFragments, KeySet, argv[3], "DeltaHessian_xx-Order", "Plot of error between approximated hessian and full hessian versus the Bond Order", datum)) return 1;
|
---|
| 261 |
|
---|
| 262 | // ++++++++++++++++++++++++++++++++++++++Plotting Hessian vs. Order
|
---|
| 263 | if (!CreateDataHessianOrderPerAtom(HessianFragments, KeySet, argv[3], "Hessian_xx-Order", "Plot of approximated hessian versus the Bond Order", datum)) return 1;
|
---|
| 264 | if (!AppendOutputFile(output, argv[3], "Hessian_xx-Order.dat" )) return false;
|
---|
| 265 | output << endl << "# Full" << endl;
|
---|
| 266 | for(int j=0;j<Hessian.RowCounter[Hessian.MatrixCounter];j++) {
|
---|
| 267 | output << j << "\t";
|
---|
| 268 | for(int k=0;k<Hessian.ColumnCounter[Force.MatrixCounter];k++)
|
---|
| 269 | output << scientific << Hessian.Matrix[ Hessian.MatrixCounter ][j][k] << "\t";
|
---|
| 270 | output << endl;
|
---|
[f05407] | 271 | }
|
---|
[b12a35] | 272 | output.close();
|
---|
[b4b7c3] | 273 | }
|
---|
[f05407] | 274 |
|
---|
[95634f] | 275 | // +++++++++++++++++++++++++++++++++++++++ Plotting shieldings
|
---|
[14de469] | 276 |
|
---|
[95634f] | 277 | if (periode != NULL) { // also look for PAS values
|
---|
| 278 | 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;
|
---|
| 279 | if (!CreateDataForcesOrderPerAtom(ShieldingPASFragments, KeySet, argv[3], "ShieldingsPAS-Order", "Plot of approximated shieldings versus the Bond Order", datum)) return 1;
|
---|
| 280 | if (!AppendOutputFile(output, argv[3], "ShieldingsPAS-Order.dat" )) return false;
|
---|
| 281 | output << endl << "# Full" << endl;
|
---|
| 282 | for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) {
|
---|
| 283 | output << j << "\t";
|
---|
[f731ae] | 284 | for(int k=0;k<ShieldingPAS.ColumnCounter[ShieldingPAS.MatrixCounter];k++)
|
---|
[95634f] | 285 | output << scientific << ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t"; //*(((k>1) && (k<6))? 1.e6 : 1.) << "\t";
|
---|
| 286 | output << endl;
|
---|
| 287 | }
|
---|
| 288 | }
|
---|
| 289 | output.close();
|
---|
| 290 |
|
---|
| 291 |
|
---|
[14de469] | 292 | // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM
|
---|
[390248] | 293 | 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;
|
---|
[14de469] | 294 |
|
---|
| 295 | // +++++++++++++++++++++++++++++++++++Plotting Energies vs. Order
|
---|
[390248] | 296 | if (!CreateDataEnergyOrder(EnergyFragments, KeySet, argv[3], "Energies-Order", "Plot of approximated energies versus the Bond Order", datum)) return 1;
|
---|
[14de469] | 297 |
|
---|
| 298 | // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in forces to full QM
|
---|
[390248] | 299 | 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;
|
---|
| 300 |
|
---|
| 301 | // min force
|
---|
| 302 | 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;
|
---|
| 303 |
|
---|
| 304 | // mean force
|
---|
| 305 | 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;
|
---|
| 306 |
|
---|
| 307 | // max force
|
---|
| 308 | 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;
|
---|
[14de469] | 309 |
|
---|
| 310 | // ++++++++++++++++++++++++++++++++++++++Plotting Forces vs. Order
|
---|
[390248] | 311 | if (!CreateDataForcesOrderPerAtom(ForceFragments, KeySet, argv[3], "Forces-Order", "Plot of approximated forces versus the Bond Order", datum)) return 1;
|
---|
[95634f] | 312 | if (!AppendOutputFile(output, argv[3], "Forces-Order.dat" )) return false;
|
---|
| 313 | output << endl << "# Full" << endl;
|
---|
| 314 | for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) {
|
---|
| 315 | output << j << "\t";
|
---|
[f731ae] | 316 | for(int k=0;k<Force.ColumnCounter[Force.MatrixCounter];k++)
|
---|
[95634f] | 317 | output << scientific << Force.Matrix[ Force.MatrixCounter ][j][k] << "\t";
|
---|
| 318 | output << endl;
|
---|
| 319 | }
|
---|
| 320 | output.close();
|
---|
[14de469] | 321 | // min force
|
---|
[390248] | 322 | if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "MinForces-Order", "Plot of min approximated forces versus the Bond Order", datum, CreateMinimumForce)) return 1;
|
---|
[14de469] | 323 |
|
---|
| 324 | // mean force
|
---|
[390248] | 325 | if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "MeanForces-Order", "Plot of mean approximated forces versus the Bond Order", datum, CreateMeanForce)) return 1;
|
---|
[14de469] | 326 |
|
---|
| 327 | // max force
|
---|
[390248] | 328 | if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "MaxForces-Order", "Plot of max approximated forces versus the Bond Order", datum, CreateMaximumForce)) return 1;
|
---|
[14de469] | 329 |
|
---|
| 330 | // ++++++++++++++++++++++++++++++++++++++Plotting vector sum (should be 0) vs. bond order
|
---|
[390248] | 331 | if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "VectorSum-Order", "Plot of vector sum of the approximated forces versus the Bond Order", datum, CreateVectorSumForce)) return 1;
|
---|
[14de469] | 332 |
|
---|
| 333 | // +++++++++++++++++++++++++++++++Plotting energyfragments vs. order
|
---|
| 334 | if (!CreateDataFragment(EnergyFragments, KeySet, argv[3], "Energies-Fragment", "Plot of fragment energy versus the Fragment No", datum, CreateEnergy)) return 1;
|
---|
| 335 | if (!CreateDataFragment(EnergyFragments, KeySet, argv[3], "Energies-FragmentOrder", "Plot of fragment energy of each Fragment No vs. Bond Order", datum, CreateEnergy)) return 1;
|
---|
| 336 | if (!CreateDataFragmentOrder(EnergyFragments, KeySet, argv[3], "MaxEnergies-FragmentOrder", "Plot of maximum of fragment energy vs. Bond Order", datum, CreateMaxFragmentOrder)) return 1;
|
---|
| 337 | if (!CreateDataFragmentOrder(EnergyFragments, KeySet, argv[3], "MinEnergies-FragmentOrder", "Plot of minimum of fragment energy vs. Bond Order", datum, CreateMinFragmentOrder)) return 1;
|
---|
| 338 |
|
---|
| 339 | // +++++++++++++++++++++++++++++++Ploting min/mean/max forces for each fragment
|
---|
| 340 | // min force
|
---|
| 341 | if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MinForces-Fragment", "Plot of min approximated forces versus the Fragment No", datum, CreateMinimumForce)) return 1;
|
---|
| 342 |
|
---|
| 343 | // mean force
|
---|
| 344 | if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MeanForces-Fragment", "Plot of mean approximated forces versus the Fragment No", datum, CreateMeanForce)) return 1;
|
---|
| 345 |
|
---|
| 346 | // max force
|
---|
| 347 | if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MaxForces-Fragment", "Plot of max approximated forces versus the Fragment No", datum, CreateMaximumForce)) return 1;
|
---|
| 348 |
|
---|
| 349 | // +++++++++++++++++++++++++++++++Ploting min/mean/max forces for each fragment per order
|
---|
| 350 | // min force
|
---|
| 351 | if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MinForces-FragmentOrder", "Plot of min approximated forces of each Fragment No vs. Bond Order", datum, CreateMinimumForce)) return 1;
|
---|
| 352 |
|
---|
| 353 | // mean force
|
---|
| 354 | if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MeanForces-FragmentOrder", "Plot of mean approximated forces of each Fragment No vs. Bond Order", datum, CreateMeanForce)) return 1;
|
---|
| 355 |
|
---|
| 356 | // max force
|
---|
| 357 | if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MaxForces-FragmentOrder", "Plot of max approximated forces of each Fragment No vs. Bond Order", datum, CreateMaximumForce)) return 1;
|
---|
| 358 |
|
---|
| 359 | // ======================================= Creating the plot files ==============================================================
|
---|
| 360 |
|
---|
| 361 | Orderxrange << "[1:" << KeySet.Order << "]";
|
---|
| 362 | Fragmentxrange << "[0:" << KeySet.FragmentCounter+1 << "]";
|
---|
[390248] | 363 | yrange.str("[1e-8:1e+1]");
|
---|
[14de469] | 364 |
|
---|
[b12a35] | 365 | if (!NoTime) {
|
---|
| 366 | // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order
|
---|
| 367 | if (!CreatePlotOrder(Time, KeySet, argv[3], "SimTime-Order", 1, "below", "y", "", 1, 1, "bond order k", "Evaluation time [s]", Orderxrange.str().c_str(), "", "1" , "with linespoints", EnergyPlotLine)) return 1;
|
---|
| 368 | }
|
---|
[14de469] | 369 |
|
---|
| 370 | // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM
|
---|
[390248] | 371 | if (!CreatePlotOrder(Energy, KeySet, argv[3], "DeltaEnergies-Order", 1, "outside", "y", "", 1, 1, "bond order k", "absolute error in energy [Ht]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", AbsEnergyPlotLine)) return 1;
|
---|
[14de469] | 372 |
|
---|
| 373 | // +++++++++++++++++++++++++++++++++++Plotting Energies vs. Order
|
---|
| 374 | if (!CreatePlotOrder(Energy, KeySet, argv[3], "Energies-Order", 1, "outside", "", "", 1, 1, "bond order k", "approximate energy [Ht]", Orderxrange.str().c_str(), "", "1" , "with linespoints", EnergyPlotLine)) return 1;
|
---|
| 375 |
|
---|
| 376 | // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in forces to full QM
|
---|
[390248] | 377 | yrange.str("[1e-8:1e+0]");
|
---|
[14de469] | 378 | // min force
|
---|
[390248] | 379 | if (!CreatePlotOrder(Force, KeySet, argv[3], "DeltaMinForces-Order", 2, "top right", "y", "", 1, 1, "bond order k", "absolute error in min force [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", ForceMagnitudePlotLine)) return 1;
|
---|
[14de469] | 380 |
|
---|
| 381 | // mean force
|
---|
[390248] | 382 | if (!CreatePlotOrder(Force, KeySet, argv[3], "DeltaMeanForces-Order", 2, "top right", "y", "", 1, 1, "bond order k", "absolute error in mean force [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", AbsFirstForceValuePlotLine)) return 1;
|
---|
[14de469] | 383 |
|
---|
| 384 | // max force
|
---|
[390248] | 385 | if (!CreatePlotOrder(Force, KeySet, argv[3], "DeltaMaxForces-Order", 2, "top right", "y", "", 1, 1, "bond order k", "absolute error in max force [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", ForceMagnitudePlotLine)) return 1;
|
---|
[14de469] | 386 |
|
---|
| 387 | // min/mean/max comparison for total force
|
---|
| 388 | if(!OpenOutputFile(output, argv[3], "DeltaMinMeanMaxTotalForce-Order.pyx")) return 1;
|
---|
[fa40b5] | 389 | CreatePlotHeader(output, "DeltaMinMeanMaxTotalForce-Order", 1, "bottom left", "y", NULL, 1, 1, "bond order k", "absolute error in total forces [Ht/a.u.]");
|
---|
[14de469] | 390 | output << "plot " << Orderxrange.str().c_str() << " [1e-8:1e+0] \\" << endl;
|
---|
| 391 | output << "'DeltaMinForces-Order.dat' title 'minimum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints, \\" << endl;
|
---|
| 392 | output << "'DeltaMeanForces-Order.dat' title 'mean' using 1:(abs($" << 8 << ")) with linespoints, \\" << endl;
|
---|
| 393 | output << "'DeltaMaxForces-Order.dat' title 'maximum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints" << endl;
|
---|
| 394 | output.close();
|
---|
| 395 |
|
---|
| 396 | // ++++++++++++++++++++++++++++++++++++++Plotting Forces vs. Order
|
---|
| 397 | // min force
|
---|
| 398 | if (!CreatePlotOrder(Force, KeySet, argv[3], "MinForces-Order", 2, "bottom right", "y", "", 1, 1, "bond order k", "absolute approximated min force [Ht/a.u.]", Orderxrange.str().c_str(), "", "1" , "with linespoints", ForceMagnitudePlotLine)) return 1;
|
---|
| 399 |
|
---|
| 400 | // mean force
|
---|
| 401 | if (!CreatePlotOrder(Force, KeySet, argv[3], "MeanForces-Order", 2, "bottom right", "y", "", 1, 1, "bond order k", "absolute approximated mean force [Ht/a.u.]", Orderxrange.str().c_str(), "", "1" , "with linespoints", AbsFirstForceValuePlotLine)) return 1;
|
---|
| 402 |
|
---|
| 403 | // max force
|
---|
| 404 | if (!CreatePlotOrder(Force, KeySet, argv[3], "MaxForces-Order", 2, "bottom right", "y", "", 1, 1, "bond order k", "absolute approximated max force [Ht/a.u.]", Orderxrange.str().c_str(), "", "1" , "with linespoints", ForceMagnitudePlotLine)) return 1;
|
---|
| 405 |
|
---|
| 406 | // min/mean/max comparison for total force
|
---|
| 407 | if(!OpenOutputFile(output, argv[3],"MinMeanMaxTotalForce-Order.pyx")) return 1;
|
---|
[fa40b5] | 408 | CreatePlotHeader(output, "MinMeanMaxTotalForce-Order", 1, "bottom left", "y", NULL, 1, 1, "bond order k", "absolute total force [Ht/a.u.]");
|
---|
[14de469] | 409 | output << "plot "<< Orderxrange.str().c_str() << " [1e-8:1e+0] \\" << endl;
|
---|
| 410 | output << "'MinForces-Order.dat' title 'minimum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints, \\" << endl;
|
---|
| 411 | output << "'MeanForces-Order.dat' title 'mean' using 1:(abs($" << 8 << ")) with linespoints, \\" << endl;
|
---|
| 412 | output << "'MaxForces-Order.dat' title 'maximum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints" << endl;
|
---|
| 413 | output.close();
|
---|
| 414 |
|
---|
| 415 | // ++++++++++++++++++++++++++++++++++++++Plotting vector sum vs. Order
|
---|
| 416 |
|
---|
| 417 | if (!CreatePlotOrder(Force, KeySet, argv[3], "VectorSum-Order", 2, "bottom right", "y" ,"", 1, 1, "bond order k", "vector sum of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), "", "1" , "with linespoints", ForceMagnitudePlotLine)) return 1;
|
---|
| 418 |
|
---|
| 419 | // +++++++++++++++++++++++++++++++Plotting energyfragments vs. order
|
---|
[390248] | 420 | yrange.str("");
|
---|
| 421 | yrange << "[" << EnergyFragments.FindMinValue() << ":" << EnergyFragments.FindMaxValue() << "]";
|
---|
| 422 | if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "Energies-Fragment", 5, "below", "y", "", 1, 5, "fragment number", "Energies of each fragment [Ht]", Fragmentxrange.str().c_str(), yrange.str().c_str(), "2" , "with points", AbsEnergyPlotLine)) return 1;
|
---|
| 423 | if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "Energies-FragmentOrder", 5, "below", "y", "", 1, 1, "bond order", "Energies of each fragment [Ht]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with points", AbsEnergyPlotLine)) return 1;
|
---|
| 424 | if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "MaxEnergies-FragmentOrder", 5, "below", "y", "", 1, 1, "bond order", "Maximum fragment energy [Ht]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", AbsEnergyPlotLine)) return 1;
|
---|
| 425 | if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "MinEnergies-FragmentOrder", 5, "below", "y", "", 1, 1, "bond order", "Minimum fragment energy [Ht]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", AbsEnergyPlotLine)) return 1;
|
---|
[14de469] | 426 |
|
---|
| 427 | // +++++++++++++++++++++++++++++++=Ploting min/mean/max forces for each fragment
|
---|
[390248] | 428 | yrange.str("");
|
---|
| 429 | yrange << "[" << ForceFragments.FindMinValue() << ":" << ForceFragments.FindMaxValue()<< "]";
|
---|
[14de469] | 430 | // min
|
---|
[390248] | 431 | if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MinForces-Fragment", 5, "below", "y", "set boxwidth 0.2", 1, 5, "fragment number", "minimum of approximated forces [Ht/a.u.]", Fragmentxrange.str().c_str(), yrange.str().c_str(), "2" , "with boxes fillcolor", BoxesForcePlotLine)) return 1;
|
---|
[14de469] | 432 |
|
---|
| 433 | // mean
|
---|
[390248] | 434 | if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MeanForces-Fragment", 5, "below", "y", "set boxwidth 0.2", 1, 5, "fragment number", "mean of approximated forces [Ht/a.u.]", Fragmentxrange.str().c_str(), yrange.str().c_str(), "2" , "with boxes fillcolor", BoxesFirstForceValuePlotLine)) return 1;
|
---|
[14de469] | 435 |
|
---|
| 436 | // max
|
---|
[390248] | 437 | if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MaxForces-Fragment", 5, "below", "y", "set boxwidth 0.2", 1, 5, "fragment number", "maximum of approximated forces [Ht/a.u.]", Fragmentxrange.str().c_str(), yrange.str().c_str(), "2" , "with boxes fillcolor", BoxesForcePlotLine)) return 1;
|
---|
[14de469] | 438 |
|
---|
| 439 | // +++++++++++++++++++++++++++++++=Ploting min/mean/max forces for each fragment per bond order
|
---|
| 440 | // min
|
---|
[390248] | 441 | if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MinForces-FragmentOrder", 5, "below", "y", "set boxwidth 0.2", 1, 1, "bond order", "minimum of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with boxes fillcolor", BoxesForcePlotLine)) return 1;
|
---|
[14de469] | 442 |
|
---|
| 443 | // mean
|
---|
[390248] | 444 | if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MeanForces-FragmentOrder", 5, "below", "y", "set boxwidth 0.2", 1, 1, "bond order", "mean of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with boxes fillcolor", BoxesFirstForceValuePlotLine)) return 1;
|
---|
[14de469] | 445 |
|
---|
| 446 | // max
|
---|
[390248] | 447 | if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MaxForces-FragmentOrder", 5, "below", "y", "set boxwidth 0.2", 1, 1, "bond order", "maximum of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with boxes fillcolor", BoxesForcePlotLine)) return 1;
|
---|
[14de469] | 448 |
|
---|
[95634f] | 449 | // +++++++++++++++++++++++++++++++=Ploting approximated and true shielding for each atom
|
---|
| 450 | if (periode != NULL) { // also look for PAS values
|
---|
| 451 | if(!OpenOutputFile(output, argv[3], "ShieldingsPAS-Order.pyx")) return 1;
|
---|
[4ee3df] | 452 | if(!OpenOutputFile(output2, argv[3], "DeltaShieldingsPAS-Order.pyx")) return 1;
|
---|
[95634f] | 453 | CreatePlotHeader(output, "ShieldingsPAS-Order", 1, "top right", NULL, NULL, 1, 5, "nuclei index", "iso chemical shielding value [ppm]");
|
---|
[4ee3df] | 454 | CreatePlotHeader(output2, "DeltaShieldingsPAS-Order", 1, "top right", NULL, NULL, 1, 5, "nuclei index", "iso chemical shielding value [ppm]");
|
---|
[95634f] | 455 | double step=0.8/KeySet.Order;
|
---|
| 456 | output << "set boxwidth " << step << endl;
|
---|
| 457 | output << "plot [0:" << ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter]+10 << "]\\" << endl;
|
---|
[4ee3df] | 458 | output2 << "plot [0:" << ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter]+10 << "]\\" << endl;
|
---|
[95634f] | 459 | for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
|
---|
| 460 | output << "'ShieldingsPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1+" << step*(double)BondOrder << "):7 with boxes, \\" << endl;
|
---|
[4ee3df] | 461 | output2 << "'DeltaShieldingsPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1):7 with linespoints";
|
---|
| 462 | if (BondOrder-1 != KeySet.Order)
|
---|
| 463 | output2 << ", \\" << endl;
|
---|
[95634f] | 464 | }
|
---|
| 465 | output << "'ShieldingsPAS-Order.dat' index " << KeySet.Order << " title 'Full' using ($1+" << step*(double)KeySet.Order << "):7 with boxes" << endl;
|
---|
| 466 | output.close();
|
---|
[4ee3df] | 467 | output2.close();
|
---|
[95634f] | 468 | }
|
---|
| 469 |
|
---|
[14de469] | 470 | // create Makefile
|
---|
| 471 | if(!OpenOutputFile(output, argv[3], "Makefile")) return 1;
|
---|
| 472 | output << "PYX = $(shell ls *.pyx)" << endl << endl;
|
---|
| 473 | output << "EPS = $(PYX:.pyx=.eps)" << endl << endl;
|
---|
| 474 | output << "%.eps: %.pyx" << endl;
|
---|
| 475 | output << "\t~/build/pyxplot/pyxplot $<" << endl << endl;
|
---|
| 476 | output << "all: $(EPS)" << endl << endl;
|
---|
| 477 | output << ".PHONY: clean" << endl;
|
---|
| 478 | output << "clean:" << endl;
|
---|
| 479 | output << "\trm -rf $(EPS)" << endl;
|
---|
| 480 | output.close();
|
---|
| 481 |
|
---|
[68cb0f] | 482 | // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++
|
---|
| 483 | delete(periode);
|
---|
[390248] | 484 | Free((void **)&dir, "main: *dir");
|
---|
[14de469] | 485 | cout << "done." << endl;
|
---|
| 486 | return 0;
|
---|
| 487 | };
|
---|
| 488 |
|
---|
| 489 | //============================ END ===========================
|
---|