Ignore:
Timestamp:
Jul 24, 2008, 2:00:19 PM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
747b10
Parents:
b3eb8e
Message:

BIG change: Hcorrection included and bugfix of analyzer (wrt forces)

  • Hcorrection is supplied via molecuilder which gives correction values if hydrogen atoms are to close and thus already feel each other's influence. This correction energy matrix is also parsed ans subtracted from the approximated energy matrix generated from the fragments. This impacts both on joiner, analyzer and molecuilder
  • Forces were not working which had multiple causes:
    • first, we stepped back down to absolute errors which rather gives a feel about convergence (1e-6 is simply small and neglegible)
    • there may have been bugs where (either in Force or in ForceFragments) adding up took place, this is cleaned up
    • more routines have been abstracted from analyzer into datacreator functions
      • the order of ions had changed, re-run with current molecuilder, calculation and subsequent joining/analyzing brought correct results finally
  • plots were bad still due to wrong axes (two more functions finding max/min values), use of wrong columns in plot file
File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/parser.cpp

    rb3eb8e rdb3ea3  
    146146    file.str(" ");
    147147    if (i != MatrixCounter) 
    148       file << name << FRAGMENTPREFIX << FragmentNumber << "/" << prefix << suffix;
     148      file << name << FRAGMENTPREFIX << FragmentNumber << prefix << suffix;
    149149    else
    150150      file << name << prefix << suffix;
     
    265265};
    266266
     267/** Scans all elements of MatrixContainer::Matrix for greatest absolute value.
     268 * \return greatest value of MatrixContainer::Matrix
     269 */
     270double MatrixContainer::FindMaxValue()
     271{
     272  double max = Matrix[0][0][0];
     273  for(int i=MatrixCounter+1;i--;)
     274    for(int j=RowCounter[i]+1;j--;)
     275      for(int k=ColumnCounter;k--;)
     276        if (fabs(Matrix[i][j][k]) > max)
     277          max = fabs(Matrix[i][j][k]);
     278  if (fabs(max) < MYEPSILON)
     279    max += MYEPSILON;
     280 return max;
     281};
     282
     283/** Scans all elements of MatrixContainer::Matrix for smallest absolute value.
     284 * \return smallest value of MatrixContainer::Matrix
     285 */
     286double MatrixContainer::FindMinValue()
     287{
     288  double min = Matrix[0][0][0];
     289  for(int i=MatrixCounter+1;i--;)
     290    for(int j=RowCounter[i]+1;j--;)
     291      for(int k=ColumnCounter;k--;)
     292        if (fabs(Matrix[i][j][k]) < min)
     293          min = fabs(Matrix[i][j][k]);
     294  if (fabs(min) < MYEPSILON)
     295    min += MYEPSILON;
     296  return min;
     297};
     298
    267299/** Sets all values in the last of MatrixContainer::Matrix to \a value.
    268300 * \param value reset value
     
    333365              }
    334366            }
    335           //if ((ColumnCounter>1) && (RowCounter[0]-1 >= 1))
    336             //cout << "Fragments[ KeySet.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySet.OrderSet[Order][CurrentFragment] << " ][" << RowCounter[0]-1 << "][" << 1 << "] = " <<  Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][RowCounter[0]-1][1] << endl;
     367            //if ((ColumnCounter>1) && (RowCounter[0]-1 >= 1))
     368             //cout << "Fragments[ KeySet.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySet.OrderSet[Order][CurrentFragment] << " ][" << RowCounter[0]-1 << "][" << 1 << "] = " <<  Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][RowCounter[0]-1][1] << endl;
    337369          }
    338370        } else {
     
    341373      }
    342374    }
    343     //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;
     375   //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;
    344376  }
    345377 
     
    428460 * Sums over the "F"-terms in ANOVA decomposition.
    429461 * \param Matrix MatrixContainer with matrices (LevelCounter by ColumnCounter) with all the energies.
     462 * \param CorrectionFragments MatrixContainer with hydrogen saturation correction per fragments
    430463 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order
    431464 * \param Order bond order
     465 * \parsm sign +1 or -1
    432466 * \return true if summing was successful
    433467 */
    434 bool EnergyMatrix::SumSubEnergy(class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, int Order)
     468bool EnergyMatrix::SumSubEnergy(class EnergyMatrix &Fragments, class EnergyMatrix *CorrectionFragments, class KeySetsContainer &KeySet, int Order, double sign)
    435469{
    436470  // sum energy
    437   for(int i=KeySet.FragmentsPerOrder[Order];i--;)
    438     for(int j=RowCounter[ KeySet.OrderSet[Order][i] ];j--;)
    439       for(int k=ColumnCounter;k--;)
    440         Matrix[MatrixCounter][j][k] += Fragments.Matrix[ KeySet.OrderSet[Order][i] ][j][k];
     471  if (CorrectionFragments == NULL)
     472    for(int i=KeySet.FragmentsPerOrder[Order];i--;)
     473      for(int j=RowCounter[ KeySet.OrderSet[Order][i] ];j--;)
     474        for(int k=ColumnCounter;k--;)
     475          Matrix[MatrixCounter][j][k] += sign*Fragments.Matrix[ KeySet.OrderSet[Order][i] ][j][k];
     476  else
     477    for(int i=KeySet.FragmentsPerOrder[Order];i--;)
     478      for(int j=RowCounter[ KeySet.OrderSet[Order][i] ];j--;)
     479        for(int k=ColumnCounter;k--;)
     480          Matrix[MatrixCounter][j][k] += sign*(Fragments.Matrix[ KeySet.OrderSet[Order][i] ][j][k] + CorrectionFragments->Matrix[ KeySet.OrderSet[Order][i] ][j][k]);
    441481  return true;
    442482};
     
    492532 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order
    493533 * \param Order bond order
     534 *  \param sign +1 or -1
    494535 * \return true if summing was successful
    495536 */
    496 bool ForceMatrix::SumSubForces(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, int Order)
    497 {
     537bool ForceMatrix::SumSubForces(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, int Order, double sign)
     538{
     539  int FragmentNr;
    498540  // sum forces
    499   for(int i=0;i<KeySet.FragmentsPerOrder[Order];i++)
    500     for(int l=0;l<RowCounter[ KeySet.OrderSet[Order][i] ];l++) {
    501       int j = Indices[ KeySet.OrderSet[Order][i] ][l];
     541  for(int i=0;i<KeySet.FragmentsPerOrder[Order];i++) {
     542    FragmentNr = KeySet.OrderSet[Order][i];
     543    for(int l=0;l<RowCounter[ FragmentNr ];l++) {
     544      int j = Indices[ FragmentNr ][l];
    502545      if (j > RowCounter[MatrixCounter]) {
    503546        cerr << "Current force index " << j << " is greater than " << RowCounter[MatrixCounter] << "!" << endl;
    504547        return false;
    505548      }
    506       if (j != -1)
     549      if (j != -1) {
     550        //if (j == 0) cout << "Summing onto ion 0, type 0 from fragment " << FragmentNr << ", ion " << l << "." << endl;
    507551        for(int k=2;k<ColumnCounter;k++)
    508           Matrix[MatrixCounter][j][k] += Fragments.Matrix[ KeySet.OrderSet[Order][i] ][l][k];
    509     }
     552          Matrix[MatrixCounter][j][k] += sign*Fragments.Matrix[ FragmentNr ][l][k];
     553      }
     554    }
     555  }
    510556  return true;
    511557};
     
    571617      KeySets[i][j] = -1;
    572618    FragmentNumber = FixedDigitNumber(FragmentCounter, i);
    573     cout << FRAGMENTPREFIX << FragmentNumber << "[" << AtomCounter[i] << "]:";
     619    //cout << FRAGMENTPREFIX << FragmentNumber << "[" << AtomCounter[i] << "]:";
    574620    Free((void **)&FragmentNumber, "KeySetsContainer::ParseKeySets: *FragmentNumber");
    575621    input.getline(filename, 1023);
     
    577623    for(int j=0;(j<AtomCounter[i]) && (!line.eof());j++) {
    578624      line >> KeySets[i][j];
    579       cout << " " << KeySets[i][j];
    580     }
    581     cout << endl;
     625      //cout << " " << KeySets[i][j];
     626    }
     627    //cout << endl;
    582628  }
    583629  input.close();
Note: See TracChangeset for help on using the changeset viewer.