Changes in src/analyzer.cpp [5bc4d0:437922]
- File:
-
- 1 edited
-
src/analyzer.cpp (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/analyzer.cpp
r5bc4d0 r437922 3 3 * Takes evaluated fragments (energy and forces) and does evaluation of how sensible the BOSSANOVA 4 4 * approach was, e.g. in the decay of the many-body-contributions. 5 * 5 * 6 6 */ 7 7 … … 9 9 10 10 #include "datacreator.hpp" 11 #include "helpers.hpp" 11 #include "helpers.hpp" 12 12 #include "parser.hpp" 13 #include "periodentafel.hpp" 13 #include "periodentafel.hpp" 14 14 15 15 // include config.h … … 29 29 ForceMatrix Shielding; 30 30 ForceMatrix ShieldingPAS; 31 ForceMatrix Chi;32 ForceMatrix ChiPAS;33 31 EnergyMatrix Time; 34 32 EnergyMatrix EnergyFragments; … … 37 35 ForceMatrix ShieldingFragments; 38 36 ForceMatrix ShieldingPASFragments; 39 ForceMatrix ChiFragments;40 ForceMatrix ChiPASFragments;41 37 KeySetsContainer KeySet; 42 38 ofstream output; … … 54 50 char *dir = NULL; 55 51 bool Hcorrected = true; 56 double norm;57 52 int counter; 58 53 59 54 cout << "ANOVA Analyzer" << endl; 60 55 cout << "==============" << endl; 61 56 62 57 // Get the command line options 63 58 if (argc < 4) { … … 73 68 strcat(dir, argv[2]); 74 69 } 75 70 76 71 if (argc > 4) { 77 72 cout << "Loading periodentafel." << endl; … … 79 74 periode->LoadPeriodentafel(argv[4]); 80 75 } 81 76 82 77 // Test the given directory 83 78 if (!TestParams(argc, argv)) … … 85 80 86 81 // +++++++++++++++++ PARSING +++++++++++++++++++++++++++++++ 87 82 88 83 // ------------- Parse through all Fragment subdirs -------- 89 84 if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix,0,0)) return 1; … … 94 89 if (!Shielding.ParseFragmentMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1; 95 90 if (!ShieldingPAS.ParseFragmentMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1; 96 if (!Chi.ParseFragmentMatrix(argv[1], dir, ChiSuffix, 1, 0)) return 1;97 if (!ChiPAS.ParseFragmentMatrix(argv[1], dir, ChiPASSuffix, 1, 0)) return 1;98 91 } 99 92 … … 101 94 if (!Energy.ParseIndices()) return 1; 102 95 if (Hcorrected) Hcorrection.ParseIndices(); 103 96 104 97 // ---------- Parse the Force indices into an array --------------- 105 98 if (!Force.ParseIndices(argv[1])) return 1; … … 115 108 if(!ShieldingFragments.ParseIndices(argv[1])) return 1; 116 109 if(!ShieldingPASFragments.ParseIndices(argv[1])) return 1; 117 if(!Chi.ParseIndices(argv[1])) return 1;118 if(!ChiPAS.ParseIndices(argv[1])) return 1;119 if (!ChiFragments.AllocateMatrix(Chi.Header, Chi.MatrixCounter, Chi.RowCounter, Chi.ColumnCounter)) return 1;120 if (!ChiPASFragments.AllocateMatrix(ChiPAS.Header, ChiPAS.MatrixCounter, ChiPAS.RowCounter, ChiPAS.ColumnCounter)) return 1;121 if(!ChiFragments.ParseIndices(argv[1])) return 1;122 if(!ChiPASFragments.ParseIndices(argv[1])) return 1;123 110 } 124 111 … … 126 113 if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1; 127 114 if (!KeySet.ParseManyBodyTerms()) return 1; 128 115 129 116 // ---------- Parse fragment files created by 'joiner' into an array ------------- 130 117 if (!EnergyFragments.ParseFragmentMatrix(argv[1], dir, EnergyFragmentSuffix,0,0)) return 1; … … 134 121 if (!ShieldingFragments.ParseFragmentMatrix(argv[1], dir, ShieldingFragmentSuffix, 1, 0)) return 1; 135 122 if (!ShieldingPASFragments.ParseFragmentMatrix(argv[1], dir, ShieldingPASFragmentSuffix, 1, 0)) return 1; 136 if (!ChiFragments.ParseFragmentMatrix(argv[1], dir, ChiFragmentSuffix, 1, 0)) return 1;137 if (!ChiPASFragments.ParseFragmentMatrix(argv[1], dir, ChiPASFragmentSuffix, 1, 0)) return 1;138 123 } 139 124 140 125 // +++++++++++++++ TESTING ++++++++++++++++++++++++++++++ 141 126 142 127 // print energy and forces to file 143 128 filename.str(""); … … 151 136 } 152 137 output << endl; 153 138 154 139 output << endl << "Total Forces" << endl << "===============" << endl << Force.Header << endl; 155 140 for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) { … … 168 153 } 169 154 output << endl; 170 155 171 156 output << endl << "Total Shieldings PAS" << endl << "===============" << endl << ShieldingPAS.Header << endl; 172 157 for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) { … … 176 161 } 177 162 output << endl; 178 179 output << endl << "Total Chis" << endl << "===============" << endl << Chi.Header[Chi.MatrixCounter] << endl; 180 for(int j=0;j<Chi.RowCounter[Chi.MatrixCounter];j++) { 181 for(int k=0;k<Chi.ColumnCounter;k++) 182 output << scientific << Chi.Matrix[ Chi.MatrixCounter ][j][k] << "\t"; 183 output << endl; 184 } 185 output << endl; 186 187 output << endl << "Total Chis PAS" << endl << "===============" << endl << ChiPAS.Header[ChiPAS.MatrixCounter] << endl; 188 for(int j=0;j<ChiPAS.RowCounter[ChiPAS.MatrixCounter];j++) { 189 for(int k=0;k<ChiPAS.ColumnCounter;k++) 190 output << scientific << ChiPAS.Matrix[ ChiPAS.MatrixCounter ][j][k] << "\t"; 191 output << endl; 192 } 193 output << endl; 194 } 195 163 } 164 196 165 output << endl << "Total Times" << endl << "===============" << endl << Time.Header << endl; 197 166 for(int j=0;j<Time.RowCounter[Time.MatrixCounter];j++) { … … 207 176 208 177 // +++++++++++++++ ANALYZING ++++++++++++++++++++++++++++++ 209 178 210 179 cout << "Analyzing ..." << endl; 211 180 … … 258 227 output << endl; 259 228 } 260 output.close(); 261 if (!CreateDataDeltaForcesOrderPerAtom(ChiPAS, ChiPASFragments, KeySet, argv[3], "DeltaChisPAS-Order", "Plot of error between approximated Chis and full Chis versus the Bond Order", datum)) return 1; 262 if (!CreateDataForcesOrderPerAtom(ChiPASFragments, KeySet, argv[3], "ChisPAS-Order", "Plot of approximated Chis versus the Bond Order", datum)) return 1; 263 if (!AppendOutputFile(output, argv[3], "ChisPAS-Order.dat" )) return false; 264 output << endl << "# Full" << endl; 265 for(int j=0;j<ChiPAS.RowCounter[ChiPAS.MatrixCounter];j++) { 266 output << j << "\t"; 267 for(int k=0;k<ChiPAS.ColumnCounter;k++) 268 output << scientific << ChiPAS.Matrix[ ChiPAS.MatrixCounter ][j][k] << "\t"; //*(((k>1) && (k<6))? 1.e6 : 1.) << "\t"; 269 output << endl; 270 } 271 output.close(); 272 } 273 274 229 } 230 output.close(); 231 232 275 233 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM 276 234 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; 277 235 278 236 // +++++++++++++++++++++++++++++++++++Plotting Energies vs. Order 279 237 if (!CreateDataEnergyOrder(EnergyFragments, KeySet, argv[3], "Energies-Order", "Plot of approximated energies versus the Bond Order", datum)) return 1; 280 238 281 239 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in forces to full QM 282 240 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; … … 341 299 342 300 // ======================================= Creating the plot files ============================================================== 343 301 344 302 Orderxrange << "[1:" << KeySet.Order << "]"; 345 303 Fragmentxrange << "[0:" << KeySet.FragmentCounter+1 << "]"; 346 304 yrange.str("[1e-8:1e+1]"); 347 305 348 306 // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order 349 307 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; 350 308 351 309 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM 352 310 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; 353 311 354 312 // +++++++++++++++++++++++++++++++++++Plotting Energies vs. Order 355 313 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; … … 369 327 if(!OpenOutputFile(output, argv[3], "DeltaMinMeanMaxTotalForce-Order.pyx")) return 1; 370 328 CreatePlotHeader(output, "DeltaMinMeanMaxTotalForce-Order", 1, "bottom left", "y", NULL, 1, 1, "bond order k", "absolute error in total forces [Ht/a.u.]"); 371 output << "plot " << Orderxrange.str().c_str() << " [1e-8:1e+0] \\" << endl; 329 output << "plot " << Orderxrange.str().c_str() << " [1e-8:1e+0] \\" << endl; 372 330 output << "'DeltaMinForces-Order.dat' title 'minimum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints, \\" << endl; 373 331 output << "'DeltaMeanForces-Order.dat' title 'mean' using 1:(abs($" << 8 << ")) with linespoints, \\" << endl; 374 332 output << "'DeltaMaxForces-Order.dat' title 'maximum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints" << endl; 375 output.close(); 333 output.close(); 376 334 377 335 // ++++++++++++++++++++++++++++++++++++++Plotting Forces vs. Order … … 388 346 if(!OpenOutputFile(output, argv[3],"MinMeanMaxTotalForce-Order.pyx")) return 1; 389 347 CreatePlotHeader(output, "MinMeanMaxTotalForce-Order", 1, "bottom left", "y", NULL, 1, 1, "bond order k", "absolute total force [Ht/a.u.]"); 390 output << "plot "<< Orderxrange.str().c_str() << " [1e-8:1e+0] \\" << endl; 348 output << "plot "<< Orderxrange.str().c_str() << " [1e-8:1e+0] \\" << endl; 391 349 output << "'MinForces-Order.dat' title 'minimum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints, \\" << endl; 392 350 output << "'MeanForces-Order.dat' title 'mean' using 1:(abs($" << 8 << ")) with linespoints, \\" << endl; 393 351 output << "'MaxForces-Order.dat' title 'maximum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints" << endl; 394 output.close(); 352 output.close(); 395 353 396 354 // ++++++++++++++++++++++++++++++++++++++Plotting vector sum vs. Order … … 411 369 // min 412 370 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; 413 371 414 372 // mean 415 373 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; 416 374 417 375 // max 418 376 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; … … 421 379 // min 422 380 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; 423 381 424 382 // mean 425 383 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; 426 384 427 385 // max 428 386 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; 429 387 430 388 // +++++++++++++++++++++++++++++++=Ploting approximated and true shielding for each atom 431 389 if (periode != NULL) { // also look for PAS values … … 445 403 } 446 404 output << "'ShieldingsPAS-Order.dat' index " << KeySet.Order << " title 'Full' using ($1+" << step*(double)KeySet.Order << "):7 with boxes" << endl; 447 output.close(); 448 output2.close(); 449 450 if(!OpenOutputFile(output, argv[3], "ChisPAS-Order.pyx")) return 1; 451 if(!OpenOutputFile(output2, argv[3], "DeltaChisPAS-Order.pyx")) return 1; 452 CreatePlotHeader(output, "ChisPAS-Order", 1, "top right", NULL, NULL, 1, 5, "nuclei index", "iso chemical Chi value [ppm]"); 453 CreatePlotHeader(output2, "DeltaChisPAS-Order", 1, "top right", NULL, NULL, 1, 5, "nuclei index", "iso chemical Chi value [ppm]"); 454 output << "set boxwidth " << step << endl; 455 output << "plot [0:" << ChiPAS.RowCounter[ChiPAS.MatrixCounter]+10 << "]\\" << endl; 456 output2 << "plot [0:" << ChiPAS.RowCounter[ChiPAS.MatrixCounter]+10 << "]\\" << endl; 457 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 458 output << "'ChisPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1+" << step*(double)BondOrder << "):7 with boxes, \\" << endl; 459 output2 << "'DeltaChisPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1):7 with linespoints"; 460 if (BondOrder-1 != KeySet.Order) 461 output2 << ", \\" << endl; 462 } 463 output << "'ChisPAS-Order.dat' index " << KeySet.Order << " title 'Full' using ($1+" << step*(double)KeySet.Order << "):7 with boxes" << endl; 464 output.close(); 465 output2.close(); 405 output.close(); 406 output2.close(); 466 407 } 467 408 … … 477 418 output << "\trm -rf $(EPS)" << endl; 478 419 output.close(); 479 420 480 421 // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++ 481 422 delete(periode);
Note:
See TracChangeset
for help on using the changeset viewer.
