Ignore:
Timestamp:
Aug 18, 2008, 8:35:11 AM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
e6971b
Parents:
d24e8f0
Message:

Splitting MatrrixContainer::ParseMatrix in ParseMatrix

ParseMatrix just parses only a given matrix into a given part of the MatrixContainer::matrix array).
ParseFragmentMatrix calls ParseMatrix for a sequence of numbered files containing the matrices.
ForceMatrix::ParseFragmentMatrix overrides the routine from MatrixContainer in order to handle the parsing of the last and one ma
trix in a special way
EnergyMatrix::ParseFragmentMatrix overrides the routine from MatrixContainer in order to handle the parsing of the last and one matrix in a special way
Realloc() was fixed: ReAlloc would break if given oldptr is NULL, but now we simply switch to doing a malloc instead and only admonishing the wrong call to ReAlloc instead of Malloc
analyser.cpp and joiner.cpp have been adapted to these new calling schemes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/analyzer.cpp

    rd24e8f0 r7b67a3  
    2929  ForceMatrix Shielding;
    3030  ForceMatrix ShieldingPAS;
    31   EnergyMatrix Time;
     31  MatrixContainer Time;
    3232  EnergyMatrix EnergyFragments;
    3333  EnergyMatrix HcorrectionFragments;
     
    5151  bool Hcorrected = true;
    5252  double norm;
    53   int counter;
    5453 
    5554  cout << "ANOVA Analyzer" << endl;
     
    8382 
    8483  // ------------- Parse through all Fragment subdirs --------
    85   if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix,0,0)) return 1;
    86   Hcorrected = Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX,0,0);
    87   if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix,0,0)) return 1;
    88   if (!Time.ParseFragmentMatrix(argv[1], dir, TimeSuffix, 10,1)) return 1;
     84  if (!Energy.ParseMatrix(argv[1], dir, EnergySuffix,0,0)) return 1;
     85  Hcorrected = Hcorrection.ParseMatrix(argv[1], "", HCORRECTIONSUFFIX,0,0);
     86  if (!Force.ParseMatrix(argv[1], dir, ForcesSuffix,0,0)) return 1;
     87  if (!Time.ParseMatrix(argv[1], dir, TimeSuffix, 10,1)) return 1;
    8988  if (periode != NULL) { // also look for PAS values
    90     if (!Shielding.ParseFragmentMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1;
    91     if (!ShieldingPAS.ParseFragmentMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1;
     89    if (!Shielding.ParseMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1;
     90    if (!ShieldingPAS.ParseMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1;
    9291  }
    9392
     
    112111 
    113112  // ---------- Parse fragment files created by 'joiner' into an array -------------
    114   if (!EnergyFragments.ParseFragmentMatrix(argv[1], dir, EnergyFragmentSuffix,0,0)) return 1;
    115   if (Hcorrected) HcorrectionFragments.ParseFragmentMatrix(argv[1], dir, HcorrectionFragmentSuffix,0,0);
    116   if (!ForceFragments.ParseFragmentMatrix(argv[1], dir, ForceFragmentSuffix,0,0)) return 1;
     113  if (!EnergyFragments.ParseMatrix(argv[1], dir, EnergyFragmentSuffix,0,0)) return 1;
     114  if (Hcorrected) HcorrectionFragments.ParseMatrix(argv[1], dir, HcorrectionFragmentSuffix,0,0);
     115  if (!ForceFragments.ParseMatrix(argv[1], dir, ForceFragmentSuffix,0,0)) return 1;
    117116  if (periode != NULL) { // also look for PAS values
    118     if (!ShieldingFragments.ParseFragmentMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1;
    119     if (!ShieldingPASFragments.ParseFragmentMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1;
     117    if (!ShieldingFragments.ParseMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1;
     118    if (!ShieldingPASFragments.ParseMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1;
    120119  }
    121120
     
    161160 
    162161  output << endl << "Total Times" << endl << "===============" << endl << Time.Header << endl;
     162  Time.SetLastMatrix(0., 0);
     163  for (int BondOrder=KeySet.Order;BondOrder--;)
     164    for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;)
     165      for(int j=Time.RowCounter[Time.MatrixCounter];j--;)
     166        for(int k=Time.ColumnCounter;k--;) {
     167          Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
     168        }
    163169  for(int j=0;j<Time.RowCounter[Time.MatrixCounter];j++) {
    164     for(int k=0;k<Time.ColumnCounter;k++) {
     170    for(int k=0;k<Time.ColumnCounter;k++)
    165171      output << scientific << Time.Matrix[ Time.MatrixCounter ][j][k] << "\t";
    166     }
    167172    output << endl;
    168173  }
    169174  output << endl;
    170175  output.close();
    171   for(int k=0;k<Time.ColumnCounter;k++)
    172     Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k] = Time.Matrix[ Time.MatrixCounter ][Time.RowCounter[Time.MatrixCounter]-1][k];
    173176
    174177  // +++++++++++++++ ANALYZING ++++++++++++++++++++++++++++++
     
    179182
    180183  // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order
    181   // +++++++++++++++++++++++++++++++++++++++ Plotting Delta Simtime vs Bond Order
    182184  if (!OpenOutputFile(output, argv[3], "SimTime-Order.dat" )) return false;
    183   if (!OpenOutputFile(output2, argv[3], "DeltaSimTime-Order.dat" )) return false;
    184   for(int j=Time.RowCounter[Time.MatrixCounter];j--;)
    185     for(int k=Time.ColumnCounter;k--;) {
    186       Time.Matrix[ Time.MatrixCounter ][j][k] = 0.;
    187     }
    188   counter = 0;
     185  Time.SetLastMatrix(0., 0);
    189186  output << "#Order\tFrag.No.\t" << Time.Header << endl;
    190   output2 << "#Order\tFrag.No.\t" << Time.Header << endl;
    191187  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
    192188    for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;)
     
    195191          Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
    196192        }
    197     counter += KeySet.FragmentsPerOrder[BondOrder];
    198     output << BondOrder+1 << "\t" << counter;
    199     output2 << BondOrder+1 << "\t" << counter;
    200     for(int k=0;k<Time.ColumnCounter;k++) {
    201       output << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k];
    202       if (fabs(Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k]) > MYEPSILON)
    203         output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k] / Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k];
    204       else
    205         output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k];
    206     }
    207     output << endl;
    208     output2 << endl;
     193    output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
     194    for(int k=0;k<Time.ColumnCounter;k++)
     195      output << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][1][k];
     196    output << endl;
    209197  }
    210198  output.close();
    211   output2.close();
    212 
    213199
    214200  // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM
Note: See TracChangeset for help on using the changeset viewer.