Changeset b38b64


Ignore:
Timestamp:
Jul 23, 2009, 9:14:18 AM (16 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
631dcb
Parents:
b77416 (diff), 72744a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'HessianMatrix'

Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/analyzer.cpp

    rb77416 rb38b64  
    2525  periodentafel *periode = NULL; // and a period table of all elements
    2626  EnergyMatrix Energy;
     27  EnergyMatrix EnergyFragments;
     28  ForceMatrix Force;
     29  ForceMatrix ForceFragments;
     30  HessianMatrix Hessian;
     31  HessianMatrix HessianFragments;
    2732  EnergyMatrix Hcorrection;
    28   ForceMatrix Force;
     33  EnergyMatrix HcorrectionFragments;
    2934  ForceMatrix Shielding;
    3035  ForceMatrix ShieldingPAS;
     
    3237  ForceMatrix ChiPAS;
    3338  EnergyMatrix Time;
    34   EnergyMatrix EnergyFragments;
    35   EnergyMatrix HcorrectionFragments;
    36   ForceMatrix ForceFragments;
    3739  ForceMatrix ShieldingFragments;
    3840  ForceMatrix ShieldingPASFragments;
     
    5355  stringstream yrange;
    5456  char *dir = NULL;
    55   bool Hcorrected = true;
     57  bool NoHCorrection = false;
     58  bool NoHessian = false;
     59  bool NoTime = false;
    5660  double norm;
    5761  int counter;
     
    8892  // ------------- Parse through all Fragment subdirs --------
    8993  if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix,0,0)) return 1;
    90   Hcorrected = Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX,0,0);
     94  if (!Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX,0,0)) {
     95    NoHCorrection = true;
     96    cout << "No HCorrection file found, skipping these." << endl;
     97  }
     98 
    9199  if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix,0,0)) return 1;
    92   if (!Time.ParseFragmentMatrix(argv[1], dir, TimeSuffix, 10,1)) return 1;
     100  if (!Hessian.ParseFragmentMatrix(argv[1], dir, HessianSuffix,0,0)) {
     101    NoHessian = true;
     102    cout << "No Hessian file found, skipping these." << endl;
     103  }
     104  if (!Time.ParseFragmentMatrix(argv[1], dir, TimeSuffix, 10,1)) {
     105    NoTime = true;
     106    cout << "No speed file found, skipping these." << endl;
     107  }
    93108  if (periode != NULL) { // also look for PAS values
    94109    if (!Shielding.ParseFragmentMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1;
     
    99114
    100115  // ---------- Parse the TE Factors into an array -----------------
    101   if (!Energy.ParseIndices()) return 1;
    102   if (Hcorrected) Hcorrection.ParseIndices();
     116  if (!Energy.InitialiseIndices()) return 1;
     117  if (!NoHCorrection)
     118    Hcorrection.InitialiseIndices();
    103119 
    104120  // ---------- Parse the Force indices into an array ---------------
    105121  if (!Force.ParseIndices(argv[1])) return 1;
    106122  if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1;
    107   if (!ForceFragments.ParseIndices(argv[1])) return 1;
     123  if (!ForceFragments.InitialiseIndices((class MatrixContainer *)&Force)) return 1;
     124
     125  // ---------- Parse hessian indices into an array -----------------
     126  if (!NoHessian) {
     127    if (!Hessian.InitialiseIndices((class MatrixContainer *)&Force)) return 1;
     128    if (!HessianFragments.AllocateMatrix(Hessian.Header, Hessian.MatrixCounter, Hessian.RowCounter, Hessian.ColumnCounter)) return 1;
     129    if (!HessianFragments.InitialiseIndices((class MatrixContainer *)&Force)) return 1;
     130  }
    108131
    109132  // ---------- Parse the shielding indices into an array ---------------
     
    129152  // ---------- Parse fragment files created by 'joiner' into an array -------------
    130153  if (!EnergyFragments.ParseFragmentMatrix(argv[1], dir, EnergyFragmentSuffix,0,0)) return 1;
    131   if (Hcorrected) HcorrectionFragments.ParseFragmentMatrix(argv[1], dir, HcorrectionFragmentSuffix,0,0);
     154  if (!NoHCorrection)
     155    HcorrectionFragments.ParseFragmentMatrix(argv[1], dir, HcorrectionFragmentSuffix,0,0);
    132156  if (!ForceFragments.ParseFragmentMatrix(argv[1], dir, ForceFragmentSuffix,0,0)) return 1;
     157  if (!NoHessian)
     158    if (!HessianFragments.ParseFragmentMatrix(argv[1], dir, HessianFragmentSuffix,0,0)) return 1;
    133159  if (periode != NULL) { // also look for PAS values
    134160    if (!ShieldingFragments.ParseFragmentMatrix(argv[1], dir, ShieldingFragmentSuffix, 1, 0)) return 1;
     
    144170  filename << argv[3] << "/" << "energy-forces.all";
    145171  output.open(filename.str().c_str(), ios::out);
    146   output << endl << "Total Energy" << endl << "==============" << endl << Energy.Header << endl;
     172  output << endl << "Total Energy" << endl << "==============" << endl << Energy.Header[Energy.MatrixCounter] << endl;
    147173  for(int j=0;j<Energy.RowCounter[Energy.MatrixCounter];j++) {
    148     for(int k=0;k<Energy.ColumnCounter;k++)
     174    for(int k=0;k<Energy.ColumnCounter[Energy.MatrixCounter];k++)
    149175      output << scientific << Energy.Matrix[ Energy.MatrixCounter ][j][k] << "\t";
    150176    output << endl;
     
    152178  output << endl;
    153179 
    154   output << endl << "Total Forces" << endl << "===============" << endl << Force.Header << endl;
     180  output << endl << "Total Forces" << endl << "===============" << endl << Force.Header[Force.MatrixCounter] << endl;
    155181  for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) {
    156     for(int k=0;k<Force.ColumnCounter;k++)
     182    for(int k=0;k<Force.ColumnCounter[Force.MatrixCounter];k++)
    157183      output << scientific << Force.Matrix[ Force.MatrixCounter ][j][k] << "\t";
    158184    output << endl;
     
    160186  output << endl;
    161187
     188  if (!NoHessian) {
     189    output << endl << "Total Hessian" << endl << "===============" << endl << Hessian.Header[Hessian.MatrixCounter] << endl;
     190    for(int j=0;j<Hessian.RowCounter[Hessian.MatrixCounter];j++) {
     191      for(int k=0;k<Hessian.ColumnCounter[Hessian.MatrixCounter];k++)
     192        output << scientific << Hessian.Matrix[ Hessian.MatrixCounter ][j][k] << "\t";
     193      output << endl;
     194    }
     195    output << endl;
     196  }
     197
    162198  if (periode != NULL) { // also look for PAS values
    163     output << endl << "Total Shieldings" << endl << "===============" << endl << Shielding.Header << endl;
     199    output << endl << "Total Shieldings" << endl << "===============" << endl << Shielding.Header[Hessian.MatrixCounter] << endl;
    164200    for(int j=0;j<Shielding.RowCounter[Shielding.MatrixCounter];j++) {
    165       for(int k=0;k<Shielding.ColumnCounter;k++)
     201      for(int k=0;k<Shielding.ColumnCounter[Shielding.MatrixCounter];k++)
    166202        output << scientific << Shielding.Matrix[ Shielding.MatrixCounter ][j][k] << "\t";
    167203      output << endl;
     
    169205    output << endl;
    170206 
    171     output << endl << "Total Shieldings PAS" << endl << "===============" << endl << ShieldingPAS.Header << endl;
     207    output << endl << "Total Shieldings PAS" << endl << "===============" << endl << ShieldingPAS.Header[ShieldingPAS.MatrixCounter] << endl;
    172208    for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) {
    173       for(int k=0;k<ShieldingPAS.ColumnCounter;k++)
     209      for(int k=0;k<ShieldingPAS.ColumnCounter[ShieldingPAS.MatrixCounter];k++)
    174210        output << scientific << ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t";
    175211      output << endl;
     
    194230  }
    195231 
    196   output << endl << "Total Times" << endl << "===============" << endl << Time.Header << endl;
    197   for(int j=0;j<Time.RowCounter[Time.MatrixCounter];j++) {
    198     for(int k=0;k<Time.ColumnCounter;k++) {
    199       output << scientific << Time.Matrix[ Time.MatrixCounter ][j][k] << "\t";
    200     }
    201     output << endl;
    202   }
    203   output << endl;
     232  if (!NoTime) {
     233    output << endl << "Total Times" << endl << "===============" << endl << Time.Header[Time.MatrixCounter] << endl;
     234    for(int j=0;j<Time.RowCounter[Time.MatrixCounter];j++) {
     235      for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) {
     236        output << scientific << Time.Matrix[ Time.MatrixCounter ][j][k] << "\t";
     237      }
     238      output << endl;
     239    }
     240    output << endl;
     241  }
    204242  output.close();
    205   for(int k=0;k<Time.ColumnCounter;k++)
    206     Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k] = Time.Matrix[ Time.MatrixCounter ][Time.RowCounter[Time.MatrixCounter]-1][k];
     243  if (!NoTime)
     244    for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++)
     245      Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k] = Time.Matrix[ Time.MatrixCounter ][Time.RowCounter[Time.MatrixCounter]-1][k];
    207246
    208247  // +++++++++++++++ ANALYZING ++++++++++++++++++++++++++++++
     
    214253  // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order
    215254  // +++++++++++++++++++++++++++++++++++++++ Plotting Delta Simtime vs Bond Order
    216   if (!OpenOutputFile(output, argv[3], "SimTime-Order.dat" )) return false;
    217   if (!OpenOutputFile(output2, argv[3], "DeltaSimTime-Order.dat" )) return false;
    218   for(int j=Time.RowCounter[Time.MatrixCounter];j--;)
    219     for(int k=Time.ColumnCounter;k--;) {
    220       Time.Matrix[ Time.MatrixCounter ][j][k] = 0.;
    221     }
    222   counter = 0;
    223   output << "#Order\tFrag.No.\t" << Time.Header << endl;
    224   output2 << "#Order\tFrag.No.\t" << Time.Header << endl;
    225   for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
    226     for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;)
    227       for(int j=Time.RowCounter[Time.MatrixCounter];j--;)
    228         for(int k=Time.ColumnCounter;k--;) {
    229           Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
    230         }
    231     counter += KeySet.FragmentsPerOrder[BondOrder];
    232     output << BondOrder+1 << "\t" << counter;
    233     output2 << BondOrder+1 << "\t" << counter;
    234     for(int k=0;k<Time.ColumnCounter;k++) {
    235       output << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k];
    236       if (fabs(Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k]) > MYEPSILON)
    237         output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k] / Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k];
    238       else
    239         output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k];
    240     }
    241     output << endl;
    242     output2 << endl;
    243   }
    244   output.close();
    245   output2.close();
     255  if (!NoTime) {
     256    if (!OpenOutputFile(output, argv[3], "SimTime-Order.dat" )) return false;
     257    if (!OpenOutputFile(output2, argv[3], "DeltaSimTime-Order.dat" )) return false;
     258    for(int j=Time.RowCounter[Time.MatrixCounter];j--;)
     259      for(int k=Time.ColumnCounter[Time.MatrixCounter];k--;) {
     260        Time.Matrix[ Time.MatrixCounter ][j][k] = 0.;
     261      }
     262    counter = 0;
     263    output << "#Order\tFrag.No.\t" << Time.Header[Time.MatrixCounter] << endl;
     264    output2 << "#Order\tFrag.No.\t" << Time.Header[Time.MatrixCounter] << endl;
     265    for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
     266      for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;)
     267        for(int j=Time.RowCounter[Time.MatrixCounter];j--;)
     268          for(int k=Time.ColumnCounter[Time.MatrixCounter];k--;) {
     269            Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
     270          }
     271      counter += KeySet.FragmentsPerOrder[BondOrder];
     272      output << BondOrder+1 << "\t" << counter;
     273      output2 << BondOrder+1 << "\t" << counter;
     274      for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) {
     275        output << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k];
     276        if (fabs(Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k]) > MYEPSILON)
     277          output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k] / Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k];
     278        else
     279          output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k];
     280      }
     281      output << endl;
     282      output2 << endl;
     283    }
     284    output.close();
     285    output2.close();
     286  }
     287
     288  if (!NoHessian) {
     289    // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in hessian to full QM
     290    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;
     291
     292    if (!CreateDataDeltaFrobeniusOrderPerAtom(Hessian, HessianFragments, KeySet, argv[3], "DeltaFrobeniusHessian_xx-Order", "Plot of error between approximated hessian and full hessian in the frobenius norm versus the Bond Order", datum)) return 1;
     293
     294    // ++++++++++++++++++++++++++++++++++++++Plotting Hessian vs. Order
     295    if (!CreateDataHessianOrderPerAtom(HessianFragments, KeySet, argv[3], "Hessian_xx-Order", "Plot of approximated hessian versus the Bond Order", datum)) return 1;
     296    if (!AppendOutputFile(output, argv[3], "Hessian_xx-Order.dat" )) return false;
     297    output << endl << "# Full" << endl;
     298    for(int j=0;j<Hessian.RowCounter[Hessian.MatrixCounter];j++) {
     299      output << j << "\t";
     300      for(int k=0;k<Hessian.ColumnCounter[Force.MatrixCounter];k++)
     301        output << scientific <<  Hessian.Matrix[ Hessian.MatrixCounter ][j][k] << "\t";
     302      output << endl;
     303    }
     304    output.close();
     305  }
    246306
    247307  // +++++++++++++++++++++++++++++++++++++++ Plotting shieldings
     
    254314    for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) {
    255315      output << j << "\t";
    256       for(int k=0;k<ShieldingPAS.ColumnCounter;k++)
     316      for(int k=0;k<ShieldingPAS.ColumnCounter[ShieldingPAS.MatrixCounter];k++)
    257317        output << scientific <<  ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t"; //*(((k>1) && (k<6))? 1.e6 : 1.) << "\t";
    258318      output << endl;
     
    297357  for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) {
    298358    output << j << "\t";
    299     for(int k=0;k<Force.ColumnCounter;k++)
     359    for(int k=0;k<Force.ColumnCounter[Force.MatrixCounter];k++)
    300360      output << scientific <<  Force.Matrix[ Force.MatrixCounter ][j][k] << "\t";
    301361    output << endl;
     
    346406  yrange.str("[1e-8:1e+1]");
    347407 
    348   // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order
    349   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;
     408  if (!NoTime) {
     409    // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order
     410    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;
     411  }
    350412 
    351413  // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM
  • src/datacreator.cpp

    rb77416 rb38b64  
    6363  cout << msg << endl;
    6464  output << "# " << msg << ", created on " << datum;
    65   output << "#Order\tFrag.No.\t" << Fragments.Header << endl;
     65  output << "#Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
    6666  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
    6767    for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) {
    6868      for(int j=Fragments.RowCounter[ KeySet.OrderSet[BondOrder][i] ];j--;)
    69         for(int k=Fragments.ColumnCounter;k--;)
     69        for(int k=Fragments.ColumnCounter[ KeySet.OrderSet[BondOrder][i] ];k--;)
    7070          Fragments.Matrix[Fragments.MatrixCounter][j][k] += Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
    7171    }
    7272    output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
    73     for (int l=0;l<Fragments.ColumnCounter;l++)
     73    for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++)
    7474      output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l];
    7575    output << endl;
     
    9696  cout << msg << endl;
    9797  output << "# " << msg << ", created on " << datum;
    98   output << "#Order\tFrag.No.\t" << Fragments.Header << endl;
     98  output << "#Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
    9999  Fragments.SetLastMatrix(Energy.Matrix[Energy.MatrixCounter],0);
    100100  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
    101101    for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) {
    102102      for(int j=Fragments.RowCounter[ KeySet.OrderSet[BondOrder][i] ];j--;)
    103         for(int k=Fragments.ColumnCounter;k--;)
     103        for(int k=Fragments.ColumnCounter[ KeySet.OrderSet[BondOrder][i] ];k--;)
    104104          Fragments.Matrix[Fragments.MatrixCounter][j][k] -= Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
    105105    }
    106106    output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
    107     for (int l=0;l<Fragments.ColumnCounter;l++)
     107    for (int l=0;l<Fragments.ColumnCounter[Energy.MatrixCounter];l++)
    108108      if (fabs(Energy.Matrix[Energy.MatrixCounter][ Energy.RowCounter[Energy.MatrixCounter]-1 ][l]) < MYEPSILON)
    109109        output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l];
     
    133133  cout << msg << endl;
    134134  output << "# " << msg << ", created on " << datum;
    135   output << "# Order\tFrag.No.\t" << Fragments.Header << endl;
     135  output << "# Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
    136136  Fragments.SetLastMatrix(0.,0);
    137137  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
     
    139139    output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
    140140    CreateForce(Fragments, Fragments.MatrixCounter);
    141     for (int l=0;l<Fragments.ColumnCounter;l++)
     141    for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++)
    142142       output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter] ][l];
    143143    output << endl;
     
    165165  cout << msg << endl;
    166166  output << "# " << msg << ", created on " << datum;
    167   output << "# Order\tFrag.No.\t" << Fragments.Header << endl;
     167  output << "# Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
    168168  Fragments.SetLastMatrix(Force.Matrix[Force.MatrixCounter],0);
    169169  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
     
    171171    output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
    172172    CreateForce(Fragments, Fragments.MatrixCounter);
    173     for (int l=0;l<Fragments.ColumnCounter;l++)
     173    for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++)
    174174       output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter] ][l];
    175175    output << endl;
     
    198198  cout << msg << endl;
    199199  output << "# " << msg << ", created on " << datum;
    200   output << "# AtomNo\t" << Fragments.Header << endl;
     200  output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
    201201  Fragments.SetLastMatrix(Force.Matrix[Force.MatrixCounter], 0);
    202202  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
     
    207207    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
    208208      output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t";
    209       for (int l=0;l<Fragments.ColumnCounter;l++) {
     209      for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) {
    210210        if (((l+1) % 3) == 0) {
    211211          norm = 0.;
     
    244244  cout << msg << endl;
    245245  output << "# " << msg << ", created on " << datum;
    246   output << "# AtomNo\t" << Fragments.Header << endl;
     246  output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
    247247  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
    248248    //cout << "Current order is " << BondOrder << "." << endl;
     
    252252    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
    253253      output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t";
    254       for (int l=0;l<Fragments.ColumnCounter;l++)
     254      for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++)
    255255        output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t";
    256256      output << endl;
     
    262262};
    263263
     264
     265/** Plot hessian error vs. vs atom vs. order.
     266 * \param &Hessian HessianMatrix containing reference values (in MatrixCounter matrix)
     267 * \param &Fragments HessianMatrix class containing matrix values
     268 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order
     269 * \param *prefix prefix in filename (without ending)
     270 * \param *msg message to be place in first line as a comment
     271 * \param *datum current date and time
     272 * \return true if file was written successfully
     273 */
     274bool CreateDataDeltaHessianOrderPerAtom(class HessianMatrix &Hessian, class HessianMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum)
     275{
     276  stringstream filename;
     277  ofstream output;
     278  double norm = 0.;
     279
     280  filename << prefix << ".dat";
     281  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
     282  cout << msg << endl;
     283  output << "# " << msg << ", created on " << datum;
     284  output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
     285  Fragments.SetLastMatrix(Hessian.Matrix[Hessian.MatrixCounter], 0);
     286  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
     287    //cout << "Current order is " << BondOrder << "." << endl;
     288    Fragments.SumSubHessians(Fragments, KeySet, BondOrder, -1.);
     289    // errors per atom
     290    output << endl << "#Order\t" << BondOrder+1 << endl;
     291    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
     292      output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t";
     293      for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) {
     294        output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t";
     295      }
     296      output << endl;
     297    }
     298    output << endl;
     299  }
     300  output.close();
     301  return true;
     302};
     303
     304/** Plot hessian error vs. vs atom vs. order in the frobenius norm.
     305 * \param &Hessian HessianMatrix containing reference values (in MatrixCounter matrix)
     306 * \param &Fragments HessianMatrix class containing matrix values
     307 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order
     308 * \param *prefix prefix in filename (without ending)
     309 * \param *msg message to be place in first line as a comment
     310 * \param *datum current date and time
     311 * \return true if file was written successfully
     312 */
     313bool CreateDataDeltaFrobeniusOrderPerAtom(class HessianMatrix &Hessian, class HessianMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum)
     314{
     315  stringstream filename;
     316  ofstream output;
     317  double norm = 0;
     318  double tmp;
     319
     320  filename << prefix << ".dat";
     321  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
     322  cout << msg << endl;
     323  output << "# " << msg << ", created on " << datum;
     324  output << "# AtomNo\t";
     325  Fragments.SetLastMatrix(Hessian.Matrix[Hessian.MatrixCounter], 0);
     326  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
     327    output << "Order" << BondOrder+1 << "\t";
     328  }
     329  output << endl;
     330  output << Fragments.RowCounter[ Fragments.MatrixCounter ] << "\t";
     331  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
     332    //cout << "Current order is " << BondOrder << "." << endl;
     333    Fragments.SumSubHessians(Fragments, KeySet, BondOrder, -1.);
     334    // frobenius norm of errors per atom
     335    norm = 0.;
     336    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
     337      for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) {
     338        tmp = Fragments.Matrix[Fragments.MatrixCounter][ j ][l];
     339        norm += tmp*tmp;
     340      }
     341    }
     342    output << scientific << sqrt(norm)/(Fragments.RowCounter[ Fragments.MatrixCounter ]*Fragments.ColumnCounter[ Fragments.MatrixCounter] ) << "\t";
     343  }
     344  output << endl;
     345  output.close();
     346  return true;
     347};
     348
     349/** Plot hessian error vs. vs atom vs. order.
     350 * \param &Fragments HessianMatrix class containing matrix values
     351 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order
     352 * \param *prefix prefix in filename (without ending)
     353 * \param *msg message to be place in first line as a comment
     354 * \param *datum current date and time
     355 * \return true if file was written successfully
     356 */
     357bool CreateDataHessianOrderPerAtom(class HessianMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum)
     358{
     359  stringstream filename;
     360  ofstream output;
     361
     362  filename << prefix << ".dat";
     363  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
     364  cout << msg << endl;
     365  output << "# " << msg << ", created on " << datum;
     366  output << "# AtomNo\t" << Fragments.Header[ Fragments.MatrixCounter ] << endl;
     367  Fragments.SetLastMatrix(0., 0);
     368  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
     369    //cout << "Current order is " << BondOrder << "." << endl;
     370    Fragments.SumSubHessians(Fragments, KeySet, BondOrder, 1.);
     371    // errors per atom
     372    output << endl << "#Order\t" << BondOrder+1 << endl;
     373    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
     374      output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t";
     375      for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++)
     376        output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t";
     377      output << endl;
     378    }
     379    output << endl;
     380  }
     381  output.close();
     382  return true;
     383};
     384
    264385/** Plot matrix vs. fragment.
    265386 */
     
    273394  cout << msg << endl;
    274395  output << "# " << msg << ", created on " << datum << endl;
    275   output << "#Order\tFrag.No.\t" << Fragment.Header << endl;
     396  output << "#Order\tFrag.No.\t" << Fragment.Header[ Fragment.MatrixCounter ] << endl;
    276397  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
    277398    for(int i=0;i<KeySet.FragmentsPerOrder[BondOrder];i++) {
    278399      output << BondOrder+1 << "\t" << KeySet.OrderSet[BondOrder][i]+1;
    279400      CreateFragment(Fragment, KeySet.OrderSet[BondOrder][i]);
    280       for (int l=0;l<Fragment.ColumnCounter;l++)
     401      for (int l=0;l<Fragment.ColumnCounter[ KeySet.OrderSet[BondOrder][i] ];l++)
    281402        output << scientific << "\t" << Fragment.Matrix[ KeySet.OrderSet[BondOrder][i] ][ Fragment.RowCounter[ KeySet.OrderSet[BondOrder][i] ] ][l];
    282403      output << endl;
     
    297418    for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) {
    298419      if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < fabs(Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][1])) {
    299         for (int k=Fragments.ColumnCounter;k--;)
     420        for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;)
    300421          Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
    301422      }
     
    314435    int i=0;
    315436    do {  // first get a minimum value unequal to 0
    316       for (int k=Fragments.ColumnCounter;k--;)
     437      for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;)
    317438        Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
    318439      i++;
     
    320441    for(;i<KeySet.FragmentsPerOrder[BondOrder];i++) { // then find lowest
    321442      if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) > fabs(Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][1])) {
    322         for (int k=Fragments.ColumnCounter;k--;)
     443        for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;)
    323444          Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
    324445      }
     
    338459  cout << msg << endl;
    339460  output << "# " << msg << ", created on " << datum;
    340   output << "#Order\tFrag.No.\t" << Fragment.Header << endl;
     461  output << "#Order\tFrag.No.\t" << Fragment.Header[ Fragment.MatrixCounter ] << endl;
    341462  // max
    342463  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
     
    344465    CreateFragmentOrder(Fragment, KeySet, BondOrder);
    345466    output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
    346     for (int l=0;l<Fragment.ColumnCounter;l++)
     467    for (int l=0;l<Fragment.ColumnCounter[ Fragment.MatrixCounter ];l++)
    347468      output << scientific << "\t" << Fragment.Matrix[ Fragment.MatrixCounter ][ Fragment.RowCounter[ Fragment.MatrixCounter ]-1 ][l];
    348469    output << endl;
     
    358479void CreateEnergy(class MatrixContainer &Energy, int MatrixNumber)
    359480{
    360   for(int k=0;k<Energy.ColumnCounter;k++)
     481  for(int k=0;k<Energy.ColumnCounter[MatrixNumber];k++)
    361482    Energy.Matrix[MatrixNumber][ Energy.RowCounter[MatrixNumber] ] [k] =  Energy.Matrix[MatrixNumber][ Energy.RowCounter[MatrixNumber]-1 ] [k];
    362483};
     
    369490void CreateMinimumForce(class MatrixContainer &Force, int MatrixNumber)
    370491{
    371   for (int l=Force.ColumnCounter;l--;)
     492  for (int l=Force.ColumnCounter[MatrixNumber];l--;)
    372493    Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
    373   for (int l=5;l<Force.ColumnCounter;l+=3) {
     494  for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) {
    374495    double stored = 0;
    375496    int k=0;
     
    404525{
    405526  int divisor = 0;
    406   for (int l=Force.ColumnCounter;l--;)
     527  for (int l=Force.ColumnCounter[MatrixNumber];l--;)
    407528    Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
    408   for (int l=5;l<Force.ColumnCounter;l+=3) {
     529  for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) {
    409530    double tmp = 0;
    410531    for (int k=Force.RowCounter[MatrixNumber];k--;) {
     
    428549void CreateMaximumForce(class MatrixContainer &Force, int MatrixNumber)
    429550{
    430   for (int l=5;l<Force.ColumnCounter;l+=3) {
     551  for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) {
    431552    double stored = 0;
    432553    for (int k=Force.RowCounter[MatrixNumber];k--;) {
     
    460581void CreateVectorSumForce(class MatrixContainer &Force, int MatrixNumber)
    461582{
    462   for (int l=Force.ColumnCounter;l--;)
     583  for (int l=Force.ColumnCounter[MatrixNumber];l--;)
    463584    Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
    464   for (int l=0;l<Force.ColumnCounter;l++) {
     585  for (int l=0;l<Force.ColumnCounter[MatrixNumber];l++) {
    465586    for (int k=Force.RowCounter[MatrixNumber];k--;)
    466587      Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] += Force.Matrix[MatrixNumber][k][l];
     
    538659void AbsEnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses)
    539660{
    540   stringstream line(Energy.Header);
     661  stringstream line(Energy.Header[ Energy.MatrixCounter ]);
    541662  string token;
    542663
    543664  getline(line, token, '\t');
    544   for (int i=2; i<= Energy.ColumnCounter;i++) {
     665  for (int i=2; i<= Energy.ColumnCounter[Energy.MatrixCounter];i++) {
    545666    getline(line, token, '\t');
    546667    while (token[0] == ' ') // remove leading white spaces
    547668      token.erase(0,1);
    548669    output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(abs($" << i+2 << ")) " << uses;
    549     if (i != (Energy.ColumnCounter))
     670    if (i != (Energy.ColumnCounter[Energy.MatrixCounter]))
    550671      output << ", \\";
    551672    output << endl;
     
    562683void EnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses)
    563684{
    564   stringstream line(Energy.Header);
     685  stringstream line(Energy.Header[Energy.MatrixCounter]);
    565686  string token;
    566687
    567688  getline(line, token, '\t');
    568   for (int i=1; i<= Energy.ColumnCounter;i++) {
     689  for (int i=1; i<= Energy.ColumnCounter[Energy.MatrixCounter];i++) {
    569690    getline(line, token, '\t');
    570691    while (token[0] == ' ') // remove leading white spaces
    571692      token.erase(0,1);
    572693    output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":" << i+2 << " " << uses;
    573     if (i != (Energy.ColumnCounter))
     694    if (i != (Energy.ColumnCounter[Energy.MatrixCounter]))
    574695      output << ", \\";
    575696    output << endl;
     
    586707void ForceMagnitudePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
    587708{
    588   stringstream line(Force.Header);
     709  stringstream line(Force.Header[Force.MatrixCounter]);
    589710  string token;
    590711
     
    594715  getline(line, token, '\t');
    595716  getline(line, token, '\t');
    596   for (int i=7; i< Force.ColumnCounter;i+=NDIM) {
     717  for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
    597718    getline(line, token, '\t');
    598719    while (token[0] == ' ') // remove leading white spaces
     
    600721    token.erase(token.length(), 1);  // kill residual index char (the '0')
    601722    output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(sqrt($" << i+1 << "*$" << i+1 << "+$" << i+2 << "*$" << i+2 << "+$" << i+3 << "*$" << i+3 << ")) " << uses;
    602     if (i != (Force.ColumnCounter-1))
     723    if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
    603724      output << ", \\";
    604725    output << endl;
     
    617738void AbsFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
    618739{
    619   stringstream line(Force.Header);
     740  stringstream line(Force.Header[Force.MatrixCounter]);
    620741  string token;
    621742
     
    625746  getline(line, token, '\t');
    626747  getline(line, token, '\t');
    627   for (int i=7; i< Force.ColumnCounter;i+=NDIM) {
     748  for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
    628749    getline(line, token, '\t');
    629750    while (token[0] == ' ') // remove leading white spaces
     
    631752    token.erase(token.length(), 1);  // kill residual index char (the '0')
    632753    output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(abs($" << i+1 << ")) " << uses;
    633     if (i != (Force.ColumnCounter-1))
     754    if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
    634755      output << ", \\";
    635756    output << endl;
     
    648769void BoxesForcePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
    649770{
    650   stringstream line(Force.Header);
     771  stringstream line(Force.Header[Force.MatrixCounter]);
    651772  char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
    652773  string token;
     
    657778  getline(line, token, '\t');
    658779  getline(line, token, '\t');
    659   for (int i=7; i< Force.ColumnCounter;i+=NDIM) {
     780  for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
    660781    getline(line, token, '\t');
    661782    while (token[0] == ' ') // remove leading white spaces
     
    663784    token.erase(token.length(), 1);  // kill residual index char (the '0')
    664785    output << "'" << prefix << ".dat' title '" << token << "' using ($" << xargument << "+" << fixed << setprecision(1) << (double)((i-7)/3)*0.2 << "):(sqrt($" << i+1 << "*$" << i+1 << "+$" << i+2 << "*$" << i+2 << "+$" << i+3 << "*$" << i+3 << ")) " << uses << " " << fillcolor[(i-7)/3];
    665     if (i != (Force.ColumnCounter-1))
     786    if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
    666787      output << ", \\";
    667788    output << endl;
     
    680801void BoxesFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
    681802{
    682   stringstream line(Force.Header);
     803  stringstream line(Force.Header[Force.MatrixCounter]);
    683804  char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
    684805  string token;
     
    689810  getline(line, token, '\t');
    690811  getline(line, token, '\t');
    691   for (int i=7; i< Force.ColumnCounter;i+=NDIM) {
     812  for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
    692813    getline(line, token, '\t');
    693814    while (token[0] == ' ') // remove leading white spaces
     
    695816    token.erase(token.length(), 1);  // kill residual index char (the '0')
    696817    output << "'" << prefix << ".dat' title '" << token << "' using ($" << xargument << "+" << fixed << setprecision(1) << (double)((i-7)/3)*0.2 << "):" << i+1 << " " << uses << " " << fillcolor[(i-7)/3];
    697     if (i != (Force.ColumnCounter-1))
     818    if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
    698819      output << ", \\";
    699820    output << endl;
  • src/datacreator.hpp

    rb77416 rb38b64  
    2626bool CreateDataDeltaForcesOrder(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateForce)(class MatrixContainer &, int));
    2727bool CreateDataDeltaForcesOrderPerAtom(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum);
     28bool CreateDataHessianOrderPerAtom(class HessianMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum);
     29bool CreateDataDeltaHessianOrderPerAtom(class HessianMatrix &Hessian, class HessianMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum);
     30bool CreateDataDeltaFrobeniusOrderPerAtom(class HessianMatrix &Hessian, class HessianMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum);
    2831bool CreateDataFragment(class MatrixContainer &ForceFragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateForce)(class MatrixContainer &, int));
    2932bool CreateDataFragmentOrder(class MatrixContainer &Fragment, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateFragmentOrder)(class MatrixContainer &, class KeySetsContainer &, int));
  • src/joiner.cpp

    rb77416 rb38b64  
    1919  periodentafel *periode = NULL; // and a period table of all elements
    2020  EnergyMatrix Energy;
     21  EnergyMatrix EnergyFragments;
     22 
    2123  EnergyMatrix Hcorrection;
     24  EnergyMatrix HcorrectionFragments;
     25 
    2226  ForceMatrix Force;
    23   EnergyMatrix EnergyFragments;
    24   EnergyMatrix HcorrectionFragments;
    2527  ForceMatrix ForceFragments;
     28
     29  HessianMatrix Hessian;
     30  HessianMatrix HessianFragments;
     31 
    2632  ForceMatrix Shielding;
    2733  ForceMatrix ShieldingPAS;
     
    3541  stringstream prefix;
    3642  char *dir = NULL;
    37   bool Hcorrected = true;
     43  bool NoHCorrection = false;
     44  bool NoHessian = false;
    3845
    3946  cout << "Joiner" << endl;
     
    6572  // ------------- Parse through all Fragment subdirs --------
    6673  if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix, 0,0)) return 1;
    67   Hcorrected = Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX, 0,0);
     74  if (!Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX, 0,0)) {
     75    NoHCorrection = true;
     76    cout << "No HCorrection matrices found, skipping these." << endl;
     77  }
    6878  if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix, 0,0)) return 1;
     79  if (!Hessian.ParseFragmentMatrix(argv[1], dir, HessianSuffix, 0,0)) {
     80    NoHessian = true;
     81    cout << "No hessian matrices found, skipping these." << endl;
     82  }
    6983  if (periode != NULL) { // also look for PAS values
    7084    if (!Shielding.ParseFragmentMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1;
     
    7589
    7690  // ---------- Parse the TE Factors into an array -----------------
    77   if (!Energy.ParseIndices()) return 1;
    78   if (Hcorrected) Hcorrection.ParseIndices();
     91  if (!Energy.InitialiseIndices()) return 1;
     92  if (!NoHCorrection)
     93    Hcorrection.InitialiseIndices();
    7994 
    8095  // ---------- Parse the Force indices into an array ---------------
    8196  if (!Force.ParseIndices(argv[1])) return 1;
     97
     98  // ---------- Parse the Hessian (=force) indices into an array ---------------
     99  if (!NoHessian)
     100    if (!Hessian.InitialiseIndices((class MatrixContainer *)&Force)) return 1;
    82101
    83102  // ---------- Parse the shielding indices into an array ---------------
     
    94113
    95114  if (!EnergyFragments.AllocateMatrix(Energy.Header, Energy.MatrixCounter, Energy.RowCounter, Energy.ColumnCounter)) return 1;
    96   if (Hcorrected)  HcorrectionFragments.AllocateMatrix(Hcorrection.Header, Hcorrection.MatrixCounter, Hcorrection.RowCounter, Hcorrection.ColumnCounter);
     115  if (!NoHCorrection) 
     116    HcorrectionFragments.AllocateMatrix(Hcorrection.Header, Hcorrection.MatrixCounter, Hcorrection.RowCounter, Hcorrection.ColumnCounter);
    97117  if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1;
     118  if (!NoHessian)
     119    if (!HessianFragments.AllocateMatrix(Hessian.Header, Hessian.MatrixCounter, Hessian.RowCounter, Hessian.ColumnCounter)) return 1;
    98120  if (periode != NULL) { // also look for PAS values
    99121    if (!ShieldingFragments.AllocateMatrix(Shielding.Header, Shielding.MatrixCounter, Shielding.RowCounter, Shielding.ColumnCounter)) return 1;
     
    106128  if(!Energy.SetLastMatrix(0., 0)) return 1;
    107129  if(!Force.SetLastMatrix(0., 2)) return 1;
     130  if (!NoHessian)
     131    if (!Hessian.SetLastMatrix(0., 0)) return 1;
    108132  if (periode != NULL) { // also look for PAS values
    109133    if(!Shielding.SetLastMatrix(0., 2)) return 1;
     
    120144    cout << "Summing energy of order " << BondOrder+1 << " ..." << endl;
    121145    if (!EnergyFragments.SumSubManyBodyTerms(Energy, KeySet, BondOrder)) return 1;
    122     if (Hcorrected) {
     146    if (!NoHCorrection) {
    123147      HcorrectionFragments.SumSubManyBodyTerms(Hcorrection, KeySet, BondOrder);
    124148      if (!Energy.SumSubEnergy(EnergyFragments, &HcorrectionFragments, KeySet, BondOrder, 1.)) return 1;
    125       if (Hcorrected) Hcorrection.SumSubEnergy(HcorrectionFragments, NULL, KeySet, BondOrder, 1.);
     149      Hcorrection.SumSubEnergy(HcorrectionFragments, NULL, KeySet, BondOrder, 1.);
    126150    } else
    127151      if (!Energy.SumSubEnergy(EnergyFragments, NULL, KeySet, BondOrder, 1.)) return 1;
     
    130154    if (!ForceFragments.SumSubManyBodyTerms(Force, KeySet, BondOrder)) return 1;
    131155    if (!Force.SumSubForces(ForceFragments, KeySet, BondOrder, 1.)) return 1;
     156    // --------- sum up Hessian --------------------
     157    if (!NoHessian) {
     158      cout << "Summing Hessian of order " << BondOrder+1 << " ..." << endl;
     159      if (!HessianFragments.SumSubManyBodyTerms(Hessian, KeySet, BondOrder)) return 1;
     160      if (!Hessian.SumSubHessians(HessianFragments, KeySet, BondOrder, 1.)) return 1;
     161    }
    132162    if (periode != NULL) { // also look for PAS values
    133163      cout << "Summing shieldings and susceptibilities of order " << BondOrder+1 << " ..." << endl;
     
    150180    // forces
    151181    if (!Force.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ForcesSuffix)) return 1;
     182    // hessian
     183    if (!NoHessian)
     184      if (!Hessian.WriteLastMatrix(argv[1], (prefix.str()).c_str(), HessianSuffix)) return 1;
    152185    // shieldings
    153186    if (periode != NULL) { // also look for PAS values
     
    162195  prefix << dir << EnergyFragmentSuffix;
    163196  if (!EnergyFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
    164   if (Hcorrected) {
     197  if (!NoHCorrection) {
    165198    prefix.str(" ");
    166199    prefix << dir << HcorrectionFragmentSuffix;
     
    171204  if (!ForceFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
    172205  if (!CreateDataFragment(EnergyFragments, KeySet, argv[1], FRAGMENTPREFIX ENERGYPERFRAGMENT, "fragment energy versus the Fragment No", "today", CreateEnergy)) return 1;
     206  if (!NoHessian) {
     207    prefix.str(" ");
     208    prefix << dir << HessianFragmentSuffix;
     209    if (!HessianFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
     210  }
    173211  if (periode != NULL) { // also look for PAS values
    174212    prefix.str(" ");
     
    188226  // write last matrices as fragments into central dir (not subdir as above), for analyzer to know index bounds
    189227  if (!Energy.WriteLastMatrix(argv[1], dir, EnergyFragmentSuffix)) return 1;
    190   if (Hcorrected) Hcorrection.WriteLastMatrix(argv[1], dir, HcorrectionFragmentSuffix);
     228  if (!NoHCorrection) Hcorrection.WriteLastMatrix(argv[1], dir, HcorrectionFragmentSuffix);
    191229  if (!Force.WriteLastMatrix(argv[1], dir, ForceFragmentSuffix)) return 1;
     230  if (!NoHessian)
     231    if (!Hessian.WriteLastMatrix(argv[1], dir, HessianFragmentSuffix)) return 1;
    192232  if (periode != NULL) { // also look for PAS values
    193233    if (!Shielding.WriteLastMatrix(argv[1], dir, ShieldingFragmentSuffix)) return 1;
  • src/parser.cpp

    rb77416 rb38b64  
    5656MatrixContainer::MatrixContainer() {
    5757  Indices = NULL;
    58   Header = (char *) Malloc(sizeof(char)*1023, "MatrixContainer::MatrixContainer: *Header");
     58  Header = (char **) Malloc(sizeof(char)*1, "MatrixContainer::MatrixContainer: **Header");
    5959  Matrix = (double ***) Malloc(sizeof(double **)*(1), "MatrixContainer::MatrixContainer: ***Matrix"); // one more each for the total molecule
    6060  RowCounter = (int *) Malloc(sizeof(int)*(1), "MatrixContainer::MatrixContainer: *RowCounter");
     61  ColumnCounter = (int *) Malloc(sizeof(int)*(1), "MatrixContainer::MatrixContainer: *ColumnCounter");
     62  Header[0] = NULL;
    6163  Matrix[0] = NULL;
    6264  RowCounter[0] = -1;
    6365  MatrixCounter = 0;
    64   ColumnCounter = 0;
     66  ColumnCounter[0] = -1;
    6567};
    6668
     
    7072  if (Matrix != NULL) {
    7173    for(int i=MatrixCounter;i--;) {
    72       if (RowCounter != NULL) {
     74      if ((ColumnCounter != NULL) && (RowCounter != NULL)) {
    7375          for(int j=RowCounter[i]+1;j--;)
    7476            Free((void **)&Matrix[i][j], "MatrixContainer::~MatrixContainer: *Matrix[][]");
     
    7678      }
    7779    }
    78     if ((RowCounter != NULL) && (Matrix[MatrixCounter] != NULL))
     80    if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL))
    7981      for(int j=RowCounter[MatrixCounter]+1;j--;)
    8082        Free((void **)&Matrix[MatrixCounter][j], "MatrixContainer::~MatrixContainer: *Matrix[MatrixCounter][]");
     
    8991  Free((void **)&Indices, "MatrixContainer::~MatrixContainer: **Indices");
    9092 
    91   Free((void **)&Header, "MatrixContainer::~MatrixContainer: *Header");
     93  if (Header != NULL)
     94    for(int i=MatrixCounter+1;i--;)
     95      Free((void **)&Header[i], "MatrixContainer::~MatrixContainer: *Header[]");
     96  Free((void **)&Header, "MatrixContainer::~MatrixContainer: **Header");
    9297  Free((void **)&RowCounter, "MatrixContainer::~MatrixContainer: *RowCounter");
    93 };
    94 
     98  Free((void **)&ColumnCounter, "MatrixContainer::~MatrixContainer: *RowCounter");
     99};
     100
     101/** Either copies index matrix from another MatrixContainer or initialises with trivial mapping if NULL.
     102 * This either copies the index matrix or just maps 1 to 1, 2 to 2 and so on for all fragments.
     103 * \param *Matrix pointer to other MatrixContainer
     104 * \return true - copy/initialisation sucessful, false - dimension false for copying
     105 */
     106bool MatrixContainer::InitialiseIndices(class MatrixContainer *Matrix)
     107{
     108  cout << "Initialising indices";
     109  if (Matrix == NULL) {
     110    cout << " with trivial mapping." << endl;
     111    Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "MatrixContainer::InitialiseIndices: **Indices");
     112    for(int i=MatrixCounter+1;i--;) {
     113      Indices[i] = (int *) Malloc(sizeof(int)*RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");
     114      for(int j=RowCounter[i];j--;)
     115        Indices[i][j] = j;
     116    }
     117  } else {
     118    cout << " from other MatrixContainer." << endl;
     119    if (MatrixCounter != Matrix->MatrixCounter)
     120      return false;
     121    Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "MatrixContainer::InitialiseIndices: **Indices");
     122    for(int i=MatrixCounter+1;i--;) {
     123      if (RowCounter[i] != Matrix->RowCounter[i])
     124        return false;
     125      Indices[i] = (int *) Malloc(sizeof(int)*Matrix->RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");
     126      for(int j=Matrix->RowCounter[i];j--;) {
     127        Indices[i][j] = Matrix->Indices[i][j];
     128        //cout << Indices[i][j] << "\t";
     129      }
     130      //cout << endl;
     131    }
     132  }
     133  return true;
     134};
    95135
    96136/** Parsing a number of matrices.
     
    120160    return false;
    121161  }
    122  
    123   // skip some initial lines
     162
     163  // parse header
     164  Header[MatrixNr] = (char *) Malloc(sizeof(char)*1024, "MatrixContainer::ParseMatrix: *Header[]");
    124165  for (int m=skiplines+1;m--;)
    125     input.getline(Header, 1023);
     166    input.getline(Header[MatrixNr], 1023);
    126167 
    127168  // scan header for number of columns
    128   line.str(Header);
     169  line.str(Header[MatrixNr]);
    129170  for(int k=skipcolumns;k--;)
    130     line >> Header;
     171    line >> Header[MatrixNr];
    131172  //cout << line.str() << endl;
    132   ColumnCounter=0;
     173  ColumnCounter[MatrixNr]=0;
    133174  while ( getline(line,token, '\t') ) {
    134175    if (token.length() > 0)
    135       ColumnCounter++;
     176      ColumnCounter[MatrixNr]++;
    136177  }
    137178  //cout << line.str() << endl;
    138   //cout << "ColumnCounter: " << ColumnCounter << "." << endl;
    139   if (ColumnCounter == 0)
    140     cerr << "ColumnCounter: " << ColumnCounter << " from file " << name << ", this is probably an error!" << endl;
     179  //cout << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl;
     180  if (ColumnCounter[MatrixNr] == 0)
     181    cerr << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl;
    141182 
    142183  // scan rest for number of rows/lines
     
    155196 
    156197  // allocate matrix if it's not zero dimension in one direction
    157   if ((ColumnCounter > 0) && (RowCounter[MatrixNr] > -1)) {
    158     Matrix[MatrixNr] = (double **) Malloc(sizeof(double *)*(RowCounter[MatrixNr]+1), "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
     198  if ((ColumnCounter[MatrixNr] > 0) && (RowCounter[MatrixNr] > -1)) {
     199    Matrix[MatrixNr] = (double **) Malloc(sizeof(double *)*(RowCounter[MatrixNr]+1), "MatrixContainer::ParseMatrix: **Matrix[]");
    159200 
    160201    // parse in each entry for this matrix
     
    162203    input.seekg(ios::beg);
    163204    for (int m=skiplines+1;m--;)
    164       input.getline(Header, 1023);    // skip header
    165     line.str(Header);
     205      input.getline(Header[MatrixNr], 1023);    // skip header
     206    line.str(Header[MatrixNr]);
    166207    for(int k=skipcolumns;k--;)  // skip columns in header too
    167208      line >> filename;
    168     strncpy(Header, line.str().c_str(), 1023); 
     209    strncpy(Header[MatrixNr], line.str().c_str(), 1023); 
    169210    for(int j=0;j<RowCounter[MatrixNr];j++) {
    170       Matrix[MatrixNr][j] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
     211      Matrix[MatrixNr][j] = (double *) Malloc(sizeof(double)*ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[][]");
    171212      input.getline(filename, 1023);
    172213      stringstream lines(filename);
     
    174215      for(int k=skipcolumns;k--;)
    175216        lines >> filename;
    176       for(int k=0;(k<ColumnCounter) && (!lines.eof());k++) {
     217      for(int k=0;(k<ColumnCounter[MatrixNr]) && (!lines.eof());k++) {
    177218        lines >> Matrix[MatrixNr][j][k];
    178219        //cout << " " << setprecision(2) << Matrix[MatrixNr][j][k];;
    179220      }
    180221      //cout << endl;
    181       Matrix[MatrixNr][ RowCounter[MatrixNr] ] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseFragmentMatrix: *Matrix[RowCounter[MatrixNr]][]");
    182       for(int j=ColumnCounter;j--;)
     222      Matrix[MatrixNr][ RowCounter[MatrixNr] ] = (double *) Malloc(sizeof(double)*ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[RowCounter[MatrixNr]][]");
     223      for(int j=ColumnCounter[MatrixNr];j--;)
    183224        Matrix[MatrixNr][ RowCounter[MatrixNr] ][j] = 0.;
    184225    }
    185226  } else {
    186     cerr << "ERROR: Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!" << endl;
     227    cerr << "ERROR: Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter[MatrixNr] << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!" << endl;
    187228  }
    188229  input.close();
     
    233274 
    234275  cout << "Parsing through each fragment and retrieving " << prefix << suffix << "." << endl;
     276  Header = (char **) ReAlloc(Header, sizeof(char *)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: **Header"); // one more each for the total molecule
    235277  Matrix = (double ***) ReAlloc(Matrix, sizeof(double **)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule
    236278  RowCounter = (int *) ReAlloc(RowCounter, sizeof(int)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: *RowCounter");
     279  ColumnCounter = (int *) ReAlloc(ColumnCounter, sizeof(int)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: *ColumnCounter");
    237280  for(int i=MatrixCounter+1;i--;) {
    238281    Matrix[i] = NULL;
     282    Header[i] = NULL;
    239283    RowCounter[i] = -1;
     284    ColumnCounter[i] = -1;
    240285  }
    241286  for(int i=0; i < MatrixCounter;i++) {
     
    252297
    253298/** Allocates and resets the memory for a number \a MCounter of matrices.
    254  * \param *GivenHeader Header line
     299 * \param **GivenHeader Header line for each matrix
    255300 * \param MCounter number of matrices
    256301 * \param *RCounter number of rows for each matrix
    257  * \param CCounter number of columns for all matrices
     302 * \param *CCounter number of columns for each matrix
    258303 * \return Allocation successful
    259304 */
    260 bool MatrixContainer::AllocateMatrix(char *GivenHeader, int MCounter, int *RCounter, int CCounter)
    261 {
    262   Header = (char *) Malloc(sizeof(char)*1024, "MatrixContainer::ParseFragmentMatrix: *EnergyHeader");
    263   strncpy(Header, GivenHeader, 1023);
    264 
     305bool MatrixContainer::AllocateMatrix(char **GivenHeader, int MCounter, int *RCounter, int *CCounter)
     306{
    265307  MatrixCounter = MCounter;
    266   ColumnCounter = CCounter;
    267   Matrix = (double ***) Malloc(sizeof(double **)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule
    268   RowCounter = (int *) Malloc(sizeof(int)*(MatrixCounter+1), "MatrixContainer::ParseFragmentMatrix: *RowCounter");
     308  Header = (char **) Malloc(sizeof(char *)*(MatrixCounter+1), "MatrixContainer::AllocateMatrix: *Header");
     309  Matrix = (double ***) Malloc(sizeof(double **)*(MatrixCounter+1), "MatrixContainer::AllocateMatrix: ***Matrix"); // one more each for the total molecule
     310  RowCounter = (int *) Malloc(sizeof(int)*(MatrixCounter+1), "MatrixContainer::AllocateMatrix: *RowCounter");
     311  ColumnCounter = (int *) Malloc(sizeof(int)*(MatrixCounter+1), "MatrixContainer::AllocateMatrix: *ColumnCounter");
    269312  for(int i=MatrixCounter+1;i--;) {
     313    Header[i] = (char *) Malloc(sizeof(char)*1024, "MatrixContainer::AllocateMatrix: *Header[i]");
     314    strncpy(Header[i], GivenHeader[i], 1023);
    270315    RowCounter[i] = RCounter[i];
    271     Matrix[i] = (double **) Malloc(sizeof(double *)*(RowCounter[i]+1), "MatrixContainer::ParseFragmentMatrix: **Matrix[]"); 
     316    ColumnCounter[i] = CCounter[i];
     317    Matrix[i] = (double **) Malloc(sizeof(double *)*(RowCounter[i]+1), "MatrixContainer::AllocateMatrix: **Matrix[]"); 
    272318    for(int j=RowCounter[i]+1;j--;) {
    273       Matrix[i][j] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
    274       for(int k=ColumnCounter;k--;)
     319      Matrix[i][j] = (double *) Malloc(sizeof(double)*ColumnCounter[i], "MatrixContainer::AllocateMatrix: *Matrix[][]");
     320      for(int k=ColumnCounter[i];k--;)
    275321        Matrix[i][j][k] = 0.;
    276322    }
     
    286332  for(int i=MatrixCounter+1;i--;)
    287333    for(int j=RowCounter[i]+1;j--;)
    288       for(int k=ColumnCounter;k--;)
     334      for(int k=ColumnCounter[i];k--;)
    289335        Matrix[i][j][k] = 0.;
    290336   return true;
     
    299345  for(int i=MatrixCounter+1;i--;)
    300346    for(int j=RowCounter[i]+1;j--;)
    301       for(int k=ColumnCounter;k--;)
     347      for(int k=ColumnCounter[i];k--;)
    302348        if (fabs(Matrix[i][j][k]) > max)
    303349          max = fabs(Matrix[i][j][k]);
     
    315361  for(int i=MatrixCounter+1;i--;)
    316362    for(int j=RowCounter[i]+1;j--;)
    317       for(int k=ColumnCounter;k--;)
     363      for(int k=ColumnCounter[i];k--;)
    318364        if (fabs(Matrix[i][j][k]) < min)
    319365          min = fabs(Matrix[i][j][k]);
     
    331377{
    332378  for(int j=RowCounter[MatrixCounter]+1;j--;)
    333     for(int k=skipcolumns;k<ColumnCounter;k++)
     379    for(int k=skipcolumns;k<ColumnCounter[MatrixCounter];k++)
    334380      Matrix[MatrixCounter][j][k] = value;
    335381   return true;
     
    344390{
    345391  for(int j=RowCounter[MatrixCounter]+1;j--;)
    346     for(int k=skipcolumns;k<ColumnCounter;k++)
     392    for(int k=skipcolumns;k<ColumnCounter[MatrixCounter];k++)
    347393      Matrix[MatrixCounter][j][k] = values[j][k];
    348394   return true;
    349395};
    350396
    351 /** Sums the energy with each factor and put into last element of \a ***Energies.
     397/** Sums the entries with each factor and put into last element of \a ***Matrix.
    352398 * Sums over "E"-terms to create the "F"-terms
    353  * \param Matrix MatrixContainer with matrices (LevelCounter by ColumnCounter) with all the energies.
     399 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies.
    354400 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order
    355401 * \param Order bond order
     
    384430              }
    385431              if (Order == SubOrder) { // equal order is always copy from Energies
    386                 for(int l=ColumnCounter;l--;) // then adds/subtract each column
     432                for(int l=ColumnCounter[ KeySet.OrderSet[SubOrder][j] ];l--;) // then adds/subtract each column
    387433                  Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][m][l] += MatrixValues.Matrix[ KeySet.OrderSet[SubOrder][j] ][k][l];
    388434              } else {
    389                 for(int l=ColumnCounter;l--;)
     435                for(int l=ColumnCounter[ KeySet.OrderSet[SubOrder][j] ];l--;)
    390436                  Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][m][l] -= Matrix[ KeySet.OrderSet[SubOrder][j] ][k][l];
    391437              }
    392438            }
    393             //if ((ColumnCounter>1) && (RowCounter[0]-1 >= 1))
     439            //if ((ColumnCounter[ KeySet.OrderSet[SubOrder][j] ]>1) && (RowCounter[0]-1 >= 1))
    394440             //cout << "Fragments[ KeySet.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySet.OrderSet[Order][CurrentFragment] << " ][" << RowCounter[0]-1 << "][" << 1 << "] = " <<  Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][RowCounter[0]-1][1] << endl;
    395441          }
     
    426472      return false;
    427473    }
    428     output << Header << endl;
     474    output << Header[i] << endl;
    429475    for(int j=0;j<RowCounter[i];j++) {
    430       for(int k=0;k<ColumnCounter;k++)
     476      for(int k=0;k<ColumnCounter[i];k++)
    431477        output << scientific << Matrix[i][j][k] << "\t";
    432478      output << endl;
     
    455501    return false;
    456502  }
    457   output << Header << endl;
     503  output << Header[MatrixCounter] << endl;
    458504  for(int j=0;j<RowCounter[MatrixCounter];j++) {
    459     for(int k=0;k<ColumnCounter;k++)
     505    for(int k=0;k<ColumnCounter[MatrixCounter];k++)
    460506      output << scientific << Matrix[MatrixCounter][j][k] << "\t";
    461507    output << endl;
     
    467513// ======================================= CLASS EnergyMatrix =============================
    468514
    469 /** Create a trivial energy index mapping.
    470  * This just maps 1 to 1, 2 to 2 and so on for all fragments.
    471  * \return creation sucessful
    472  */
    473 bool EnergyMatrix::ParseIndices()
    474 {
    475   cout << "Parsing energy indices." << endl;
    476   Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "EnergyMatrix::ParseIndices: **Indices");
    477   for(int i=MatrixCounter+1;i--;) {
    478     Indices[i] = (int *) Malloc(sizeof(int)*RowCounter[i], "EnergyMatrix::ParseIndices: *Indices[]");
    479     for(int j=RowCounter[i];j--;)
    480       Indices[i][j] = j;
    481   }
    482   return true;
    483 };
    484 
    485515/** Sums the energy with each factor and put into last element of \a EnergyMatrix::Matrix.
    486516 * Sums over the "F"-terms in ANOVA decomposition.
    487  * \param Matrix MatrixContainer with matrices (LevelCounter by ColumnCounter) with all the energies.
     517 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies.
    488518 * \param CorrectionFragments MatrixContainer with hydrogen saturation correction per fragments
    489519 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order
     
    498528    for(int i=KeySet.FragmentsPerOrder[Order];i--;)
    499529      for(int j=RowCounter[ KeySet.OrderSet[Order][i] ];j--;)
    500         for(int k=ColumnCounter;k--;)
     530        for(int k=ColumnCounter[ KeySet.OrderSet[Order][i] ];k--;)
    501531          Matrix[MatrixCounter][j][k] += sign*Fragments.Matrix[ KeySet.OrderSet[Order][i] ][j][k];
    502532  else
    503533    for(int i=KeySet.FragmentsPerOrder[Order];i--;)
    504534      for(int j=RowCounter[ KeySet.OrderSet[Order][i] ];j--;)
    505         for(int k=ColumnCounter;k--;)
     535        for(int k=ColumnCounter[ KeySet.OrderSet[Order][i] ];k--;)
    506536          Matrix[MatrixCounter][j][k] += sign*(Fragments.Matrix[ KeySet.OrderSet[Order][i] ][j][k] + CorrectionFragments->Matrix[ KeySet.OrderSet[Order][i] ][j][k]);
    507537  return true;
     
    524554    // count maximum of columns
    525555    RowCounter[MatrixCounter] = 0;
    526     for(int j=0; j < MatrixCounter;j++) // (energy matrix might be bigger than number of atoms in terms of rows)
     556    ColumnCounter[MatrixCounter] = 0;
     557    for(int j=0; j < MatrixCounter;j++) { // (energy matrix might be bigger than number of atoms in terms of rows)
    527558      if (RowCounter[j] > RowCounter[MatrixCounter])
    528559        RowCounter[MatrixCounter] = RowCounter[j];
     560      if (ColumnCounter[j] > ColumnCounter[MatrixCounter])  // take maximum of all for last matrix
     561        ColumnCounter[MatrixCounter] = ColumnCounter[j];
     562    }
    529563    // allocate last plus one matrix
    530     cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter << " columns." << endl;
     564    cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl;
    531565    Matrix[MatrixCounter] = (double **) Malloc(sizeof(double *)*(RowCounter[MatrixCounter]+1), "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    532566    for(int j=0;j<=RowCounter[MatrixCounter];j++)
    533       Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
     567      Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
    534568   
    535569    // try independently to parse global energysuffix file if present
     
    589623
    590624/** Sums the forces and puts into last element of \a ForceMatrix::Matrix.
    591  * \param Matrix MatrixContainer with matrices (LevelCounter by ColumnCounter) with all the energies.
     625 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies.
    592626 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order
    593627 * \param Order bond order
     
    609643      if (j != -1) {
    610644        //if (j == 0) cout << "Summing onto ion 0, type 0 from fragment " << FragmentNr << ", ion " << l << "." << endl;
    611         for(int k=2;k<ColumnCounter;k++)
     645        for(int k=2;k<ColumnCounter[MatrixCounter];k++)
    612646          Matrix[MatrixCounter][j][k] += sign*Fragments.Matrix[ FragmentNr ][l][k];
    613647      }
     
    655689    RowCounter[MatrixCounter]++;    // nr start at 0, count starts at 1
    656690    input.close();
     691
     692    ColumnCounter[MatrixCounter] = 0;
     693    for(int j=0; j < MatrixCounter;j++) { // (energy matrix might be bigger than number of atoms in terms of rows)
     694      if (ColumnCounter[j] > ColumnCounter[MatrixCounter])  // take maximum of all for last matrix
     695        ColumnCounter[MatrixCounter] = ColumnCounter[j];
     696    }
    657697 
    658698    // allocate last plus one matrix
    659     cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter << " columns." << endl;
     699    cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl;
    660700    Matrix[MatrixCounter] = (double **) Malloc(sizeof(double *)*(RowCounter[MatrixCounter]+1), "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    661701    for(int j=0;j<=RowCounter[MatrixCounter];j++)
    662       Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
     702      Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
     703
     704    // try independently to parse global forcesuffix file if present
     705    strncpy(filename, name, 1023);
     706    strncat(filename, prefix, 1023-strlen(filename));
     707    strncat(filename, suffix.c_str(), 1023-strlen(filename));
     708    ParseMatrix(filename, skiplines, skipcolumns, MatrixCounter);
     709  }
     710 
     711
     712  return status;
     713};
     714
     715// ======================================= CLASS HessianMatrix =============================
     716
     717/** Parsing force Indices of each fragment
     718 * \param *name directory with \a ForcesFile
     719 * \return parsing successful
     720 */
     721bool HessianMatrix::ParseIndices(char *name)
     722{
     723  ifstream input;
     724  char *FragmentNumber = NULL;
     725  char filename[1023];
     726  stringstream line;
     727 
     728  cout << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl;
     729  Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "HessianMatrix::ParseIndices: **Indices");
     730  line << name << FRAGMENTPREFIX << FORCESFILE;
     731  input.open(line.str().c_str(), ios::in);
     732  //cout << "Opening " << line.str() << " ... "  << input << endl;
     733  if (input == NULL) {
     734    cout << endl << "Unable to open " << line.str() << ", is the directory correct?" << endl;
     735    return false;
     736  }
     737  for (int i=0;(i<MatrixCounter) && (!input.eof());i++) {
     738    // get the number of atoms for this fragment
     739    input.getline(filename, 1023);
     740    line.str(filename);
     741    // parse the values
     742    Indices[i] = (int *) Malloc(sizeof(int)*RowCounter[i], "HessianMatrix::ParseIndices: *Indices[]");
     743    FragmentNumber = FixedDigitNumber(MatrixCounter, i);
     744    //cout << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:";
     745    Free((void **)&FragmentNumber, "HessianMatrix::ParseIndices: *FragmentNumber");
     746    for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) {
     747      line >> Indices[i][j];
     748      //cout << " " << Indices[i][j];
     749    }
     750    //cout << endl;
     751  }
     752  Indices[MatrixCounter] = (int *) Malloc(sizeof(int)*RowCounter[MatrixCounter], "HessianMatrix::ParseIndices: *Indices[]");
     753  for(int j=RowCounter[MatrixCounter];j--;) {
     754    Indices[MatrixCounter][j] = j;
     755  }
     756  input.close();
     757  return true;
     758};
     759
     760
     761/** Sums the hessian entries and puts into last element of \a HessianMatrix::Matrix.
     762 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies.
     763 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order
     764 * \param Order bond order
     765 *  \param sign +1 or -1
     766 * \return true if summing was successful
     767 */
     768bool HessianMatrix::SumSubHessians(class HessianMatrix &Fragments, class KeySetsContainer &KeySet, int Order, double sign)
     769{
     770  int FragmentNr;
     771  // sum forces
     772  for(int i=0;i<KeySet.FragmentsPerOrder[Order];i++) {
     773    FragmentNr = KeySet.OrderSet[Order][i];
     774    for(int l=0;l<RowCounter[ FragmentNr ];l++) {
     775      int j = Indices[ FragmentNr ][l];
     776      if (j > RowCounter[MatrixCounter]) {
     777        cerr << "Current hessian index " << j << " is greater than " << RowCounter[MatrixCounter] << ", where i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl;
     778        return false;
     779      }
     780      if (j != -1) {
     781        for(int m=0;m<ColumnCounter[ FragmentNr ];m++) {
     782          int k = Indices[ FragmentNr ][m];
     783          if (k > ColumnCounter[MatrixCounter]) {
     784            cerr << "Current hessian index " << k << " is greater than " << ColumnCounter[MatrixCounter] << ", where m=" << m << ", j=" << j << ", i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl;
     785            return false;
     786          }
     787          if (k != -1) {
     788                //cout << "Adding " << sign*Fragments.Matrix[ FragmentNr ][l][m] << " from [" << l << "][" << m << "] onto [" << j << "][" << k << "]." << endl;
     789            Matrix[MatrixCounter][j][k] += sign*Fragments.Matrix[ FragmentNr ][l][m];
     790          }
     791        }
     792      }
     793    }
     794  }
     795  return true;
     796};
     797
     798/** Constructor for class HessianMatrix.
     799 */
     800HessianMatrix::HessianMatrix() : MatrixContainer()
     801{
     802   IsSymmetric = true;
     803}
     804
     805/** Sums the hessian entries with each factor and put into last element of \a ***Matrix.
     806 * Sums over "E"-terms to create the "F"-terms
     807 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies.
     808 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order
     809 * \param Order bond order
     810 * \return true if summing was successful
     811 */
     812bool HessianMatrix::SumSubManyBodyTerms(class MatrixContainer &MatrixValues, class KeySetsContainer &KeySet, int Order)
     813{
     814  // go through each order
     815  for (int CurrentFragment=0;CurrentFragment<KeySet.FragmentsPerOrder[Order];CurrentFragment++) {
     816    //cout << "Current Fragment is " << CurrentFragment << "/" << KeySet.OrderSet[Order][CurrentFragment] << "." << endl;
     817    // then go per order through each suborder and pick together all the terms that contain this fragment
     818    for(int SubOrder=0;SubOrder<=Order;SubOrder++) { // go through all suborders up to the desired order
     819      for (int j=0;j<KeySet.FragmentsPerOrder[SubOrder];j++) { // go through all possible fragments of size suborder
     820        if (KeySet.Contains(KeySet.OrderSet[Order][CurrentFragment], KeySet.OrderSet[SubOrder][j])) {
     821          //cout << "Current other fragment is " << j << "/" << KeySet.OrderSet[SubOrder][j] << "." << endl;
     822          // if the fragment's indices are all in the current fragment
     823          for(int k=0;k<RowCounter[ KeySet.OrderSet[SubOrder][j] ];k++) { // go through all atoms in this fragment
     824            int m = MatrixValues.Indices[ KeySet.OrderSet[SubOrder][j] ][k];
     825            //cout << "Current row index is " << k << "/" << m << "." << endl;
     826            if (m != -1) { // if it's not an added hydrogen
     827              for (int l=0;l<RowCounter[ KeySet.OrderSet[Order][CurrentFragment] ];l++) { // look for the corresponding index in the current fragment
     828                //cout << "Comparing " << m << " with " << MatrixValues.Indices[ KeySet.OrderSet[Order][CurrentFragment] ][l] << "." << endl;
     829                if (m == MatrixValues.Indices[ KeySet.OrderSet[Order][CurrentFragment] ][l]) {
     830                  m = l;
     831                  break; 
     832                }
     833              }
     834              //cout << "Corresponding row index for " << k << " in CurrentFragment is " << m << "." << endl;
     835              if (m > RowCounter[ KeySet.OrderSet[Order][CurrentFragment] ]) {
     836                cerr << "In fragment No. " << KeySet.OrderSet[Order][CurrentFragment]   << " current row index " << m << " is greater than " << RowCounter[ KeySet.OrderSet[Order][CurrentFragment] ] << "!" << endl;
     837                return false;
     838              }
     839             
     840              for(int l=0;l<ColumnCounter[ KeySet.OrderSet[SubOrder][j] ];l++) {
     841                int n = MatrixValues.Indices[ KeySet.OrderSet[SubOrder][j] ][l];
     842                //cout << "Current column index is " << l << "/" << n << "." << endl;
     843                if (n != -1) { // if it's not an added hydrogen
     844                  for (int p=0;p<ColumnCounter[ KeySet.OrderSet[Order][CurrentFragment] ];p++) { // look for the corresponding index in the current fragment
     845                    //cout << "Comparing " << n << " with " << MatrixValues.Indices[ KeySet.OrderSet[Order][CurrentFragment] ][p] << "." << endl;
     846                    if (n == MatrixValues.Indices[ KeySet.OrderSet[Order][CurrentFragment] ][p]) {
     847                      n = p;
     848                      break; 
     849                    }
     850                  }
     851                  //cout << "Corresponding column index for " << l << " in CurrentFragment is " << n << "." << endl;
     852                  if (n > ColumnCounter[ KeySet.OrderSet[Order][CurrentFragment] ]) {
     853                    cerr << "In fragment No. " << KeySet.OrderSet[Order][CurrentFragment]   << " current column index " << n << " is greater than " << ColumnCounter[ KeySet.OrderSet[Order][CurrentFragment] ] << "!" << endl;
     854                    return false;
     855                  }
     856                  if (Order == SubOrder) { // equal order is always copy from Energies
     857                        //cout << "Adding " << MatrixValues.Matrix[ KeySet.OrderSet[SubOrder][j] ][k][l] << " from [" << k << "][" << l << "] onto [" << m << "][" << n << "]." << endl;
     858                    Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][m][n] += MatrixValues.Matrix[ KeySet.OrderSet[SubOrder][j] ][k][l];
     859                  } else {
     860                        //cout << "Subtracting " << Matrix[ KeySet.OrderSet[SubOrder][j] ][k][l] << " from [" << k << "][" << l << "] onto [" << m << "][" << n << "]." << endl;
     861                    Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][m][n] -= Matrix[ KeySet.OrderSet[SubOrder][j] ][k][l];
     862                  }
     863                }
     864              }
     865            }
     866            //if ((ColumnCounter[ KeySet.OrderSet[SubOrder][j] ]>1) && (RowCounter[0]-1 >= 1))
     867             //cout << "Fragments[ KeySet.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySet.OrderSet[Order][CurrentFragment] << " ][" << RowCounter[0]-1 << "][" << 1 << "] = " <<  Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][RowCounter[0]-1][1] << endl;
     868          }
     869        } else {
     870          //cout << "Fragment " << KeySet.OrderSet[SubOrder][j] << " is not contained in fragment " << KeySet.OrderSet[Order][CurrentFragment] << "." << endl;
     871        }
     872      }
     873    }
     874   //cout << "Final Fragments[ KeySet.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySet.OrderSet[Order][CurrentFragment] << " ][" << KeySet.AtomCounter[0]-1 << "][" << 1 << "] = " <<  Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][KeySet.AtomCounter[0]-1][1] << endl;
     875  }
     876 
     877  return true;
     878};
     879
     880/** Calls MatrixContainer::ParseFragmentMatrix() and additionally allocates last plus one matrix.
     881 * \param *name directory with files
     882 * \param *prefix prefix of each matrix file
     883 * \param *suffix suffix of each matrix file
     884 * \param skiplines number of inital lines to skip
     885 * \param skiplines number of inital columns to skip
     886 * \return parsing successful
     887 */
     888bool HessianMatrix::ParseFragmentMatrix(char *name, char *prefix, string suffix, int skiplines, int skipcolumns)
     889{
     890  char filename[1023];
     891  ifstream input;
     892  stringstream file;
     893  int nr;
     894  bool status = MatrixContainer::ParseFragmentMatrix(name, prefix, suffix, skiplines, skipcolumns);
     895
     896  if (status) {
     897    // count number of atoms for last plus one matrix
     898    file << name << FRAGMENTPREFIX << KEYSETFILE;
     899    input.open(file.str().c_str(), ios::in);
     900    if (input == NULL) {
     901      cout << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl;
     902      return false;
     903    }
     904    RowCounter[MatrixCounter] = 0;
     905    ColumnCounter[MatrixCounter] = 0;
     906    while (!input.eof()) {
     907      input.getline(filename, 1023);
     908      stringstream zeile(filename);
     909      while (!zeile.eof()) {
     910        zeile >> nr;
     911        //cout << "Current index: " << nr << "." << endl;
     912        if (nr > RowCounter[MatrixCounter]) {
     913          RowCounter[MatrixCounter] = nr;
     914          ColumnCounter[MatrixCounter] = nr;
     915        }
     916      }
     917    }
     918    RowCounter[MatrixCounter]++;    // nr start at 0, count starts at 1
     919    ColumnCounter[MatrixCounter]++;    // nr start at 0, count starts at 1
     920    input.close();
     921 
     922    // allocate last plus one matrix
     923    cout << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl;
     924    Matrix[MatrixCounter] = (double **) Malloc(sizeof(double *)*(RowCounter[MatrixCounter]+1), "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
     925    for(int j=0;j<=RowCounter[MatrixCounter];j++)
     926      Matrix[MatrixCounter][j] = (double *) Malloc(sizeof(double)*ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
    663927
    664928    // try independently to parse global forcesuffix file if present
  • src/parser.hpp

    rb77416 rb38b64  
    1919
    2020#define EnergySuffix ".energy.all"
     21#define EnergyFragmentSuffix ".energyfragment.all"
     22#define ForcesSuffix ".forces.all"
     23#define ForceFragmentSuffix ".forcefragment.all"
    2124#define HcorrectionSuffix ".Hcorrection.all"
    22 #define ForcesSuffix ".forces.all"
     25#define HcorrectionFragmentSuffix ".Hcorrectionfragment.all"
     26#define HessianSuffix ".hessian_xx.all"
     27#define HessianFragmentSuffix ".hessianfragment_xx.all"
     28#define OrderSuffix ".Order"
    2329#define ShieldingSuffix ".sigma_all.csv"
    2430#define ShieldingPASSuffix ".sigma_all_PAS.csv"
     
    3036#define ChiPASFragmentSuffix ".chi_all_PAS_fragment.all"
    3137#define TimeSuffix ".speed"
    32 #define EnergyFragmentSuffix ".energyfragment.all"
    33 #define HcorrectionFragmentSuffix ".Hcorrectionfragment.all"
    34 #define ForceFragmentSuffix ".forcefragment.all"
    35 #define OrderSuffix ".Order"
    3638
    3739// ======================================= FUNCTIONS ==========================================
     
    4749    double ***Matrix;
    4850    int **Indices;
    49     char *Header;
     51    char **Header;
    5052    int MatrixCounter;
    5153    int *RowCounter;
    52     int ColumnCounter;
     54    int *ColumnCounter;
    5355 
    5456  MatrixContainer();
    5557  ~MatrixContainer();
    5658 
     59  bool InitialiseIndices(class MatrixContainer *Matrix = NULL);
    5760  bool ParseMatrix(const char *name, int skiplines, int skipcolumns, int MatrixNr);
    5861  virtual bool ParseFragmentMatrix(char *name, char *prefix, string suffix, int skiplines, int skipcolumns);
    59   bool AllocateMatrix(char *GivenHeader, int MCounter, int *RCounter, int CCounter);
     62  bool AllocateMatrix(char **GivenHeader, int MCounter, int *RCounter, int *CCounter);
    6063  bool ResetMatrix();
    6164  double FindMinValue();
     
    7477class EnergyMatrix : public MatrixContainer {
    7578  public:
    76     bool ParseIndices();
    7779    bool SumSubEnergy(class EnergyMatrix &Fragments, class EnergyMatrix *CorrectionFragments, class KeySetsContainer &KeySet, int Order, double sign);
    7880    bool ParseFragmentMatrix(char *name, char *prefix, string suffix, int skiplines, int skipcolumns);
     
    8688    bool SumSubForces(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, int Order, double sign);
    8789    bool ParseFragmentMatrix(char *name, char *prefix, string suffix, int skiplines, int skipcolumns);
     90};
     91
     92// ======================================= CLASS HessianMatrix =============================
     93
     94class HessianMatrix : public MatrixContainer {
     95  public:
     96    HessianMatrix();
     97    //~HessianMatrix();
     98    bool ParseIndices(char *name);
     99    bool SumSubManyBodyTerms(class MatrixContainer &MatrixValues, class KeySetsContainer &KeySet, int Order);
     100    bool SumSubHessians(class HessianMatrix &Fragments, class KeySetsContainer &KeySet, int Order, double sign);
     101    bool ParseFragmentMatrix(char *name, char *prefix, string suffix, int skiplines, int skipcolumns);
     102  private:
     103    bool IsSymmetric;
    88104};
    89105
Note: See TracChangeset for help on using the changeset viewer.