Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/analyzer.cpp

    r5bc4d0 r437922  
    33 * Takes evaluated fragments (energy and forces) and does evaluation of how sensible the BOSSANOVA
    44 * approach was, e.g. in the decay of the many-body-contributions.
    5  *   
     5 *
    66 */
    77
     
    99
    1010#include "datacreator.hpp"
    11 #include "helpers.hpp" 
     11#include "helpers.hpp"
    1212#include "parser.hpp"
    13 #include "periodentafel.hpp" 
     13#include "periodentafel.hpp"
    1414
    1515// include config.h
     
    2929  ForceMatrix Shielding;
    3030  ForceMatrix ShieldingPAS;
    31   ForceMatrix Chi;
    32   ForceMatrix ChiPAS;
    3331  EnergyMatrix Time;
    3432  EnergyMatrix EnergyFragments;
     
    3735  ForceMatrix ShieldingFragments;
    3836  ForceMatrix ShieldingPASFragments;
    39   ForceMatrix ChiFragments;
    40   ForceMatrix ChiPASFragments;
    4137  KeySetsContainer KeySet;
    4238  ofstream output;
     
    5450  char *dir = NULL;
    5551  bool Hcorrected = true;
    56   double norm;
    5752  int counter;
    58  
     53
    5954  cout << "ANOVA Analyzer" << endl;
    6055  cout << "==============" << endl;
    61  
     56
    6257  // Get the command line options
    6358  if (argc < 4) {
     
    7368    strcat(dir, argv[2]);
    7469  }
    75  
     70
    7671  if (argc > 4) {
    7772    cout << "Loading periodentafel." << endl;
     
    7974    periode->LoadPeriodentafel(argv[4]);
    8075  }
    81  
     76
    8277  // Test the given directory
    8378  if (!TestParams(argc, argv))
     
    8580
    8681  // +++++++++++++++++ PARSING +++++++++++++++++++++++++++++++
    87  
     82
    8883  // ------------- Parse through all Fragment subdirs --------
    8984  if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix,0,0)) return 1;
     
    9489    if (!Shielding.ParseFragmentMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1;
    9590    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;
    9891  }
    9992
     
    10194  if (!Energy.ParseIndices()) return 1;
    10295  if (Hcorrected) Hcorrection.ParseIndices();
    103  
     96
    10497  // ---------- Parse the Force indices into an array ---------------
    10598  if (!Force.ParseIndices(argv[1])) return 1;
     
    115108    if(!ShieldingFragments.ParseIndices(argv[1])) return 1;
    116109    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;
    123110  }
    124111
     
    126113  if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1;
    127114  if (!KeySet.ParseManyBodyTerms()) return 1;
    128  
     115
    129116  // ---------- Parse fragment files created by 'joiner' into an array -------------
    130117  if (!EnergyFragments.ParseFragmentMatrix(argv[1], dir, EnergyFragmentSuffix,0,0)) return 1;
     
    134121    if (!ShieldingFragments.ParseFragmentMatrix(argv[1], dir, ShieldingFragmentSuffix, 1, 0)) return 1;
    135122    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;
    138123  }
    139124
    140125  // +++++++++++++++ TESTING ++++++++++++++++++++++++++++++
    141  
     126
    142127  // print energy and forces to file
    143128  filename.str("");
     
    151136  }
    152137  output << endl;
    153  
     138
    154139  output << endl << "Total Forces" << endl << "===============" << endl << Force.Header << endl;
    155140  for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) {
     
    168153    }
    169154    output << endl;
    170  
     155
    171156    output << endl << "Total Shieldings PAS" << endl << "===============" << endl << ShieldingPAS.Header << endl;
    172157    for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) {
     
    176161    }
    177162    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
    196165  output << endl << "Total Times" << endl << "===============" << endl << Time.Header << endl;
    197166  for(int j=0;j<Time.RowCounter[Time.MatrixCounter];j++) {
     
    207176
    208177  // +++++++++++++++ ANALYZING ++++++++++++++++++++++++++++++
    209  
     178
    210179  cout << "Analyzing ..." << endl;
    211180
     
    258227      output << endl;
    259228    }
    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
    275233  // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM
    276234  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
    278236  // +++++++++++++++++++++++++++++++++++Plotting Energies vs. Order
    279237  if (!CreateDataEnergyOrder(EnergyFragments, KeySet, argv[3], "Energies-Order", "Plot of approximated energies versus the Bond Order", datum)) return 1;
    280  
     238
    281239  // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in forces to full QM
    282240  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;
     
    341299
    342300  // ======================================= Creating the plot files ==============================================================
    343  
     301
    344302  Orderxrange << "[1:" << KeySet.Order << "]";
    345303  Fragmentxrange << "[0:" << KeySet.FragmentCounter+1 << "]";
    346304  yrange.str("[1e-8:1e+1]");
    347  
     305
    348306  // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order
    349307  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
    351309  // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM
    352310  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
    354312  // +++++++++++++++++++++++++++++++++++Plotting Energies vs. Order
    355313  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;
     
    369327  if(!OpenOutputFile(output, argv[3], "DeltaMinMeanMaxTotalForce-Order.pyx")) return 1;
    370328  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;
    372330  output << "'DeltaMinForces-Order.dat' title 'minimum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints, \\" << endl;
    373331  output << "'DeltaMeanForces-Order.dat' title 'mean' using 1:(abs($" << 8 << ")) with linespoints, \\" << endl;
    374332  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();
    376334
    377335  // ++++++++++++++++++++++++++++++++++++++Plotting Forces vs. Order
     
    388346  if(!OpenOutputFile(output, argv[3],"MinMeanMaxTotalForce-Order.pyx")) return 1;
    389347  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;
    391349  output << "'MinForces-Order.dat' title 'minimum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints, \\" << endl;
    392350  output << "'MeanForces-Order.dat' title 'mean' using 1:(abs($" << 8 << ")) with linespoints, \\" << endl;
    393351  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();
    395353
    396354  // ++++++++++++++++++++++++++++++++++++++Plotting vector sum vs. Order
     
    411369  // min
    412370  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
    414372  // mean
    415373  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
    417375  // max
    418376  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;
     
    421379  // min
    422380  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
    424382  // mean
    425383  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
    427385  // max
    428386  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
    430388  // +++++++++++++++++++++++++++++++=Ploting approximated and true shielding for each atom
    431389  if (periode != NULL) { // also look for PAS values
     
    445403    }
    446404    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();
    466407  }
    467408
     
    477418  output << "\trm -rf $(EPS)" << endl;
    478419  output.close();
    479  
     420
    480421  // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++
    481422  delete(periode);
Note: See TracChangeset for help on using the changeset viewer.