Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/datacreator.cpp

    r042f82 rf66195  
    88
    99#include "datacreator.hpp"
     10#include "helpers.hpp"
     11#include "parser.hpp"
    1012
    1113//=========================== FUNCTIONS============================
     
    4951/** Plots an energy vs. order.
    5052 * \param &Fragments EnergyMatrix class containing matrix values
    51  * \param KeySet KeySetContainer class holding bond KeySetContainer::Order
     53 * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
    5254 * \param *prefix prefix in filename (without ending)
    5355 * \param *msg message to be place in first line as a comment
    5456 * \return true if file was written successfully
    5557 */
    56 bool CreateDataEnergyOrder(class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum)
     58bool CreateDataEnergyOrder(class EnergyMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum)
    5759{
    5860  stringstream filename;
     
    6365  cout << msg << endl;
    6466  output << "# " << msg << ", created on " << datum;
    65   output << "#Order\tFrag.No.\t" << Fragments.Header << endl;
    66   for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
    67     for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) {
    68       for(int j=Fragments.RowCounter[ KeySet.OrderSet[BondOrder][i] ];j--;)
    69         for(int k=Fragments.ColumnCounter;k--;)
    70           Fragments.Matrix[Fragments.MatrixCounter][j][k] += Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
    71     }
    72     output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
    73     for (int l=0;l<Fragments.ColumnCounter;l++)
     67  output << "#Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
     68  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
     69    for(int i=KeySets.FragmentsPerOrder[BondOrder];i--;) {
     70      for(int j=Fragments.RowCounter[ KeySets.OrderSet[BondOrder][i] ];j--;)
     71        for(int k=Fragments.ColumnCounter[ KeySets.OrderSet[BondOrder][i] ];k--;)
     72          Fragments.Matrix[Fragments.MatrixCounter][j][k] += Fragments.Matrix[ KeySets.OrderSet[BondOrder][i] ][j][k];
     73    }
     74    output << BondOrder+1 << "\t" << KeySets.FragmentsPerOrder[BondOrder];
     75    for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++)
    7476      output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l];
    7577    output << endl;
     
    8284 * \param &Energy EnergyMatrix class containing reference values (in MatrixCounter matrix)
    8385 * \param &Fragments EnergyMatrix class containing matrix values
    84  * \param KeySet KeySetContainer class holding bond KeySetContainer::Order
     86 * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
    8587 * \param *prefix prefix in filename (without ending)
    8688 * \param *msg message to be place in first line as a comment
    8789 * \return true if file was written successfully
    8890 */
    89 bool CreateDataDeltaEnergyOrder(class EnergyMatrix &Energy, class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum)
     91bool CreateDataDeltaEnergyOrder(class EnergyMatrix &Energy, class EnergyMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum)
    9092{
    9193  stringstream filename;
     
    9698  cout << msg << endl;
    9799  output << "# " << msg << ", created on " << datum;
    98   output << "#Order\tFrag.No.\t" << Fragments.Header << endl;
     100  output << "#Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
    99101  Fragments.SetLastMatrix(Energy.Matrix[Energy.MatrixCounter],0);
    100   for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
    101     for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) {
    102       for(int j=Fragments.RowCounter[ KeySet.OrderSet[BondOrder][i] ];j--;)
    103         for(int k=Fragments.ColumnCounter;k--;)
    104           Fragments.Matrix[Fragments.MatrixCounter][j][k] -= Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
    105     }
    106     output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
    107     for (int l=0;l<Fragments.ColumnCounter;l++)
     102  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
     103    for(int i=KeySets.FragmentsPerOrder[BondOrder];i--;) {
     104      for(int j=Fragments.RowCounter[ KeySets.OrderSet[BondOrder][i] ];j--;)
     105        for(int k=Fragments.ColumnCounter[ KeySets.OrderSet[BondOrder][i] ];k--;)
     106          Fragments.Matrix[Fragments.MatrixCounter][j][k] -= Fragments.Matrix[ KeySets.OrderSet[BondOrder][i] ][j][k];
     107    }
     108    output << BondOrder+1 << "\t" << KeySets.FragmentsPerOrder[BondOrder];
     109    for (int l=0;l<Fragments.ColumnCounter[Energy.MatrixCounter];l++)
    108110      if (fabs(Energy.Matrix[Energy.MatrixCounter][ Energy.RowCounter[Energy.MatrixCounter]-1 ][l]) < MYEPSILON)
    109111        output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l];
     
    118120/** Plot forces vs. order.
    119121 * \param &Fragments ForceMatrix class containing matrix values
    120  * \param KeySet KeySetContainer class holding bond KeySetContainer::Order
     122 * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
    121123 * \param *prefix prefix in filename (without ending)
    122124 * \param *msg message to be place in first line as a comment
     
    124126 * \return true if file was written successfully
    125127 */
    126 bool CreateDataForcesOrder(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, const char *dir, const char *prefix,const  char *msg, const char *datum, void (*CreateForce)(class MatrixContainer &, int))
     128bool CreateDataForcesOrder(class ForceMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix,const  char *msg, const char *datum, void (*CreateForce)(class MatrixContainer &, int))
    127129{
    128130  stringstream filename;
     
    133135  cout << msg << endl;
    134136  output << "# " << msg << ", created on " << datum;
    135   output << "# Order\tFrag.No.\t" << Fragments.Header << endl;
     137  output << "# Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
    136138  Fragments.SetLastMatrix(0.,0);
    137   for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
    138     Fragments.SumSubForces(Fragments, KeySet, BondOrder, 1.);
    139     output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
     139  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
     140    Fragments.SumSubForces(Fragments, KeySets, BondOrder, 1.);
     141    output << BondOrder+1 << "\t" << KeySets.FragmentsPerOrder[BondOrder];
    140142    CreateForce(Fragments, Fragments.MatrixCounter);
    141     for (int l=0;l<Fragments.ColumnCounter;l++)
     143    for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++)
    142144       output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter] ][l];
    143145    output << endl;
     
    150152 * \param &Force ForceMatrix containing reference values (in MatrixCounter matrix)
    151153 * \param &Fragments ForceMatrix class containing matrix values
    152  * \param KeySet KeySetContainer class holding bond KeySetContainer::Order
     154 * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
    153155 * \param *prefix prefix in filename (without ending)
    154156 * \param *msg message to be place in first line as a comment
     
    156158 * \return true if file was written successfully
    157159 */
    158 bool CreateDataDeltaForcesOrder(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum, void (*CreateForce)(class MatrixContainer &, int))
     160bool CreateDataDeltaForcesOrder(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum, void (*CreateForce)(class MatrixContainer &, int))
    159161{
    160162  stringstream filename;
     
    165167  cout << msg << endl;
    166168  output << "# " << msg << ", created on " << datum;
    167   output << "# Order\tFrag.No.\t" << Fragments.Header << endl;
     169  output << "# Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
    168170  Fragments.SetLastMatrix(Force.Matrix[Force.MatrixCounter],0);
    169   for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
    170     Fragments.SumSubForces(Fragments, KeySet, BondOrder, -1.);
    171     output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
     171  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
     172    Fragments.SumSubForces(Fragments, KeySets, BondOrder, -1.);
     173    output << BondOrder+1 << "\t" << KeySets.FragmentsPerOrder[BondOrder];
    172174    CreateForce(Fragments, Fragments.MatrixCounter);
    173     for (int l=0;l<Fragments.ColumnCounter;l++)
     175    for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++)
    174176       output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter] ][l];
    175177    output << endl;
     
    182184 * \param &Force ForceMatrix containing reference values (in MatrixCounter matrix)
    183185 * \param &Fragments ForceMatrix class containing matrix values
    184  * \param KeySet KeySetContainer class holding bond KeySetContainer::Order
     186 * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
    185187 * \param *prefix prefix in filename (without ending)
    186188 * \param *msg message to be place in first line as a comment
     
    188190 * \return true if file was written successfully
    189191 */
    190 bool CreateDataDeltaForcesOrderPerAtom(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum)
     192bool CreateDataDeltaForcesOrderPerAtom(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum)
    191193{
    192194  stringstream filename;
     
    198200  cout << msg << endl;
    199201  output << "# " << msg << ", created on " << datum;
    200   output << "# AtomNo\t" << Fragments.Header << endl;
     202  output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
    201203  Fragments.SetLastMatrix(Force.Matrix[Force.MatrixCounter], 0);
    202   for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
     204  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
    203205    //cout << "Current order is " << BondOrder << "." << endl;
    204     Fragments.SumSubForces(Fragments, KeySet, BondOrder, -1.);
     206    Fragments.SumSubForces(Fragments, KeySets, BondOrder, -1.);
    205207    // errors per atom
    206208    output << endl << "#Order\t" << BondOrder+1 << endl;
    207209    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
    208210      output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t";
    209       for (int l=0;l<Fragments.ColumnCounter;l++) {
     211      for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) {
    210212        if (((l+1) % 3) == 0) {
    211213          norm = 0.;
     
    213215            norm += Force.Matrix[Force.MatrixCounter][ j ][l+m]*Force.Matrix[Force.MatrixCounter][ j ][l+m];
    214216          norm = sqrt(norm);
    215         }
     217        }                                                                                                   
    216218//        if (norm < MYEPSILON)
    217219          output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t";
     
    229231/** Plot forces error vs. vs atom vs. order.
    230232 * \param &Fragments ForceMatrix class containing matrix values
    231  * \param KeySet KeySetContainer class holding bond KeySetContainer::Order
     233 * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
    232234 * \param *prefix prefix in filename (without ending)
    233235 * \param *msg message to be place in first line as a comment
     
    235237 * \return true if file was written successfully
    236238 */
    237 bool CreateDataForcesOrderPerAtom(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum)
     239bool CreateDataForcesOrderPerAtom(class ForceMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum)
    238240{
    239241  stringstream filename;
     
    244246  cout << msg << endl;
    245247  output << "# " << msg << ", created on " << datum;
    246   output << "# AtomNo\t" << Fragments.Header << endl;
    247   for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
     248  output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
     249  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
    248250    //cout << "Current order is " << BondOrder << "." << endl;
    249     Fragments.SumSubForces(Fragments, KeySet, BondOrder, 1.);
     251    Fragments.SumSubForces(Fragments, KeySets, BondOrder, 1.);
    250252    // errors per atom
    251253    output << endl << "#Order\t" << BondOrder+1 << endl;
    252254    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
    253255      output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t";
    254       for (int l=0;l<Fragments.ColumnCounter;l++)
     256      for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++)
    255257        output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t";
    256258      output << endl;
     
    262264};
    263265
     266
     267/** Plot hessian error vs. vs atom vs. order.
     268 * \param &Hessian HessianMatrix containing reference values (in MatrixCounter matrix)
     269 * \param &Fragments HessianMatrix class containing matrix values
     270 * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
     271 * \param *prefix prefix in filename (without ending)
     272 * \param *msg message to be place in first line as a comment
     273 * \param *datum current date and time
     274 * \return true if file was written successfully
     275 */
     276bool CreateDataDeltaHessianOrderPerAtom(class HessianMatrix &Hessian, class HessianMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum)
     277{
     278  stringstream filename;
     279  ofstream output;
     280
     281  filename << prefix << ".dat";
     282  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
     283  cout << msg << endl;
     284  output << "# " << msg << ", created on " << datum;
     285  output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
     286  Fragments.SetLastMatrix(Hessian.Matrix[Hessian.MatrixCounter], 0);
     287  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
     288    //cout << "Current order is " << BondOrder << "." << endl;
     289    Fragments.SumSubHessians(Fragments, KeySets, BondOrder, -1.);
     290    // errors per atom
     291    output << endl << "#Order\t" << BondOrder+1 << endl;
     292    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
     293      output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t";
     294      for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) {
     295        output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t";
     296      }
     297      output << endl;
     298    }
     299    output << endl;
     300  }
     301  output.close();
     302  return true;
     303};
     304
     305/** Plot hessian error vs. vs atom vs. order in the frobenius norm.
     306 * \param &Hessian HessianMatrix containing reference values (in MatrixCounter matrix)
     307 * \param &Fragments HessianMatrix class containing matrix values
     308 * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
     309 * \param *prefix prefix in filename (without ending)
     310 * \param *msg message to be place in first line as a comment
     311 * \param *datum current date and time
     312 * \return true if file was written successfully
     313 */
     314bool CreateDataDeltaFrobeniusOrderPerAtom(class HessianMatrix &Hessian, class HessianMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum)
     315{
     316  stringstream filename;
     317  ofstream output;
     318  double norm = 0;
     319  double tmp;
     320
     321  filename << prefix << ".dat";
     322  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
     323  cout << msg << endl;
     324  output << "# " << msg << ", created on " << datum;
     325  output << "# AtomNo\t";
     326  Fragments.SetLastMatrix(Hessian.Matrix[Hessian.MatrixCounter], 0);
     327  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
     328    output << "Order" << BondOrder+1 << "\t";
     329  }
     330  output << endl;
     331  output << Fragments.RowCounter[ Fragments.MatrixCounter ] << "\t";
     332  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
     333    //cout << "Current order is " << BondOrder << "." << endl;
     334    Fragments.SumSubHessians(Fragments, KeySets, BondOrder, -1.);
     335    // frobenius norm of errors per atom
     336    norm = 0.;
     337    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
     338      for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) {
     339        tmp = Fragments.Matrix[Fragments.MatrixCounter][ j ][l];
     340        norm += tmp*tmp;
     341      }
     342    }
     343    output << scientific << sqrt(norm)/(Fragments.RowCounter[ Fragments.MatrixCounter ]*Fragments.ColumnCounter[ Fragments.MatrixCounter] ) << "\t";
     344  }
     345  output << endl;
     346  output.close();
     347  return true;
     348};
     349
     350/** Plot hessian error vs. vs atom vs. order.
     351 * \param &Fragments HessianMatrix class containing matrix values
     352 * \param KeySets KeySetContainer class holding bond KeySetContainer::Order
     353 * \param *prefix prefix in filename (without ending)
     354 * \param *msg message to be place in first line as a comment
     355 * \param *datum current date and time
     356 * \return true if file was written successfully
     357 */
     358bool CreateDataHessianOrderPerAtom(class HessianMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum)
     359{
     360  stringstream filename;
     361  ofstream output;
     362
     363  filename << prefix << ".dat";
     364  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
     365  cout << msg << endl;
     366  output << "# " << msg << ", created on " << datum;
     367  output << "# AtomNo\t" << Fragments.Header[ Fragments.MatrixCounter ] << endl;
     368  Fragments.SetLastMatrix(0., 0);
     369  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
     370    //cout << "Current order is " << BondOrder << "." << endl;
     371    Fragments.SumSubHessians(Fragments, KeySets, BondOrder, 1.);
     372    // errors per atom
     373    output << endl << "#Order\t" << BondOrder+1 << endl;
     374    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
     375      output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t";
     376      for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++)
     377        output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t";
     378      output << endl;
     379    }
     380    output << endl;
     381  }
     382  output.close();
     383  return true;
     384};
     385
    264386/** Plot matrix vs. fragment.
    265387 */
    266 bool CreateDataFragment(class MatrixContainer &Fragment, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum, void (*CreateFragment)(class MatrixContainer &, int))
     388bool CreateDataFragment(class MatrixContainer &Fragment, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum, void (*CreateFragment)(class MatrixContainer &, int))
    267389{
    268390  stringstream filename;
     
    273395  cout << msg << endl;
    274396  output << "# " << msg << ", created on " << datum << endl;
    275   output << "#Order\tFrag.No.\t" << Fragment.Header << endl;
    276   for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
    277     for(int i=0;i<KeySet.FragmentsPerOrder[BondOrder];i++) {
    278       output << BondOrder+1 << "\t" << KeySet.OrderSet[BondOrder][i]+1;
    279       CreateFragment(Fragment, KeySet.OrderSet[BondOrder][i]);
    280       for (int l=0;l<Fragment.ColumnCounter;l++)
    281         output << scientific << "\t" << Fragment.Matrix[ KeySet.OrderSet[BondOrder][i] ][ Fragment.RowCounter[ KeySet.OrderSet[BondOrder][i] ] ][l];
     397  output << "#Order\tFrag.No.\t" << Fragment.Header[ Fragment.MatrixCounter ] << endl;
     398  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
     399    for(int i=0;i<KeySets.FragmentsPerOrder[BondOrder];i++) {
     400      output << BondOrder+1 << "\t" << KeySets.OrderSet[BondOrder][i]+1;
     401      CreateFragment(Fragment, KeySets.OrderSet[BondOrder][i]);
     402      for (int l=0;l<Fragment.ColumnCounter[ KeySets.OrderSet[BondOrder][i] ];l++)
     403        output << scientific << "\t" << Fragment.Matrix[ KeySets.OrderSet[BondOrder][i] ][ Fragment.RowCounter[ KeySets.OrderSet[BondOrder][i] ] ][l];
    282404      output << endl;
    283405    }
     
    289411/** Copies fragment energy values into last matrix of \a Matrix with greatest total energy.
    290412 * \param &Matrix MatrixContainer with all fragment energy values
    291  * \param &KeySet KeySetsContainer with associations of each fragment to a bond order
     413 * \param &KeySets KeySetsContainer with associations of each fragment to a bond order
    292414 * \param BondOrder current bond order
    293415 */
    294 void CreateMaxFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySet, int BondOrder)
     416void CreateMaxFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySets, int BondOrder)
    295417{
    296418  for(int j=Fragments.RowCounter[ Fragments.MatrixCounter ];j--;) {
    297     for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) {
    298       if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < fabs(Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][1])) {
    299         for (int k=Fragments.ColumnCounter;k--;)
    300           Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
     419    for(int i=KeySets.FragmentsPerOrder[BondOrder];i--;) {
     420      if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < fabs(Fragments.Matrix[ KeySets.OrderSet[BondOrder][i] ][j][1])) {
     421        for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;)
     422          Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySets.OrderSet[BondOrder][i] ][j][k];
    301423      }
    302424    }
     
    306428/** Copies fragment energy values into last matrix of \a Matrix with smallest total energy.
    307429 * \param &Matrix MatrixContainer with all fragment energy values
    308  * \param &KeySet KeySetsContainer with associations of each fragment to a bond order
     430 * \param &KeySets KeySetsContainer with associations of each fragment to a bond order
    309431 * \param BondOrder current bond order
    310432 */
    311 void CreateMinFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySet, int BondOrder)
     433void CreateMinFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySets, int BondOrder)
    312434{
    313435  for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
    314436    int i=0;
    315437    do {  // first get a minimum value unequal to 0
    316       for (int k=Fragments.ColumnCounter;k--;)
    317         Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
     438      for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;)
     439        Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySets.OrderSet[BondOrder][i] ][j][k];
    318440      i++;
    319     } while ((fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < MYEPSILON) && (i<KeySet.FragmentsPerOrder[BondOrder]));
    320     for(;i<KeySet.FragmentsPerOrder[BondOrder];i++) { // then find lowest
    321       if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) > fabs(Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][1])) {
    322         for (int k=Fragments.ColumnCounter;k--;)
    323           Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
     441    } while ((fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < MYEPSILON) && (i<KeySets.FragmentsPerOrder[BondOrder]));
     442    for(;i<KeySets.FragmentsPerOrder[BondOrder];i++) { // then find lowest
     443      if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) > fabs(Fragments.Matrix[ KeySets.OrderSet[BondOrder][i] ][j][1])) {
     444        for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;)
     445          Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySets.OrderSet[BondOrder][i] ][j][k];
    324446      }
    325447    }
     
    329451/** Plot matrix vs. fragment.
    330452 */
    331 bool CreateDataFragmentOrder(class MatrixContainer &Fragment, class KeySetsContainer &KeySet, const char *dir, const char *prefix, const char *msg, const char *datum, void (*CreateFragmentOrder)(class MatrixContainer &, class KeySetsContainer &, int))
     453bool CreateDataFragmentOrder(class MatrixContainer &Fragment, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum, void (*CreateFragmentOrder)(class MatrixContainer &, class KeySetsContainer &, int))
    332454{
    333455  stringstream filename;
     
    338460  cout << msg << endl;
    339461  output << "# " << msg << ", created on " << datum;
    340   output << "#Order\tFrag.No.\t" << Fragment.Header << endl;
     462  output << "#Order\tFrag.No.\t" << Fragment.Header[ Fragment.MatrixCounter ] << endl;
    341463  // max
    342   for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
     464  for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) {
    343465    Fragment.SetLastMatrix(0.,0);
    344     CreateFragmentOrder(Fragment, KeySet, BondOrder);
    345     output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
    346     for (int l=0;l<Fragment.ColumnCounter;l++)
     466    CreateFragmentOrder(Fragment, KeySets, BondOrder);
     467    output << BondOrder+1 << "\t" << KeySets.FragmentsPerOrder[BondOrder];
     468    for (int l=0;l<Fragment.ColumnCounter[ Fragment.MatrixCounter ];l++)
    347469      output << scientific << "\t" << Fragment.Matrix[ Fragment.MatrixCounter ][ Fragment.RowCounter[ Fragment.MatrixCounter ]-1 ][l];
    348470    output << endl;
     
    358480void CreateEnergy(class MatrixContainer &Energy, int MatrixNumber)
    359481{
    360   for(int k=0;k<Energy.ColumnCounter;k++)
     482  for(int k=0;k<Energy.ColumnCounter[MatrixNumber];k++)
    361483    Energy.Matrix[MatrixNumber][ Energy.RowCounter[MatrixNumber] ] [k] =  Energy.Matrix[MatrixNumber][ Energy.RowCounter[MatrixNumber]-1 ] [k];
    362484};
     
    369491void CreateMinimumForce(class MatrixContainer &Force, int MatrixNumber)
    370492{
    371   for (int l=Force.ColumnCounter;l--;)
     493  for (int l=Force.ColumnCounter[MatrixNumber];l--;)
    372494    Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
    373   for (int l=5;l<Force.ColumnCounter;l+=3) {
     495  for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) {
    374496    double stored = 0;
    375497    int k=0;
     
    404526{
    405527  int divisor = 0;
    406   for (int l=Force.ColumnCounter;l--;)
     528  for (int l=Force.ColumnCounter[MatrixNumber];l--;)
    407529    Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
    408   for (int l=5;l<Force.ColumnCounter;l+=3) {
     530  for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) {
    409531    double tmp = 0;
    410532    for (int k=Force.RowCounter[MatrixNumber];k--;) {
     
    428550void CreateMaximumForce(class MatrixContainer &Force, int MatrixNumber)
    429551{
    430   for (int l=5;l<Force.ColumnCounter;l+=3) {
     552  for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) {
    431553    double stored = 0;
    432554    for (int k=Force.RowCounter[MatrixNumber];k--;) {
     
    460582void CreateVectorSumForce(class MatrixContainer &Force, int MatrixNumber)
    461583{
    462   for (int l=Force.ColumnCounter;l--;)
     584  for (int l=Force.ColumnCounter[MatrixNumber];l--;)
    463585    Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
    464   for (int l=0;l<Force.ColumnCounter;l++) {
     586  for (int l=0;l<Force.ColumnCounter[MatrixNumber];l++) {
    465587    for (int k=Force.RowCounter[MatrixNumber];k--;)
    466588      Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] += Force.Matrix[MatrixNumber][k][l];
     
    498620/** Creates the pyxplotfile for energy data.
    499621 * \param Matrix MatrixContainer with matrix values
    500  * \param KeySet contains bond order
     622 * \param KeySets contains bond order
    501623 * \param *dir directory
    502624 * \param *prefix prefix for all filenames (without ending)
     
    515637 * \return true if file was written successfully
    516638 */
    517 bool CreatePlotOrder(class MatrixContainer &Matrix, const class KeySetsContainer &KeySet, const char *dir, const char *prefix, const int keycolumns, const char *key, const char *logscale, const char *extraline, const int mxtics, const int xtics, const char *xlabel, const char *ylabel, const char *xrange, const char *yrange, const char *xargument, const char *uses, void (*CreatePlotLines)(ofstream &, class MatrixContainer &, const char *, const char *, const char *))
     639bool CreatePlotOrder(class MatrixContainer &Matrix, const class KeySetsContainer &KeySets, const char *dir, const char *prefix, const int keycolumns, const char *key, const char *logscale, const char *extraline, const int mxtics, const int xtics, const char *xlabel, const char *ylabel, const char *xrange, const char *yrange, const char *xargument, const char *uses, void (*CreatePlotLines)(ofstream &, class MatrixContainer &, const char *, const char *, const char *))
    518640{
    519641  stringstream filename;
     
    538660void AbsEnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses)
    539661{
    540   stringstream line(Energy.Header);
     662  stringstream line(Energy.Header[ Energy.MatrixCounter ]);
    541663  string token;
    542664
    543665  getline(line, token, '\t');
    544   for (int i=2; i<= Energy.ColumnCounter;i++) {
     666  for (int i=2; i<= Energy.ColumnCounter[Energy.MatrixCounter];i++) {
    545667    getline(line, token, '\t');
    546668    while (token[0] == ' ') // remove leading white spaces
    547669      token.erase(0,1);
    548670    output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(abs($" << i+2 << ")) " << uses;
    549     if (i != (Energy.ColumnCounter))
     671    if (i != (Energy.ColumnCounter[Energy.MatrixCounter]))
    550672      output << ", \\";
    551673    output << endl;
     
    562684void EnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses)
    563685{
    564   stringstream line(Energy.Header);
     686  stringstream line(Energy.Header[Energy.MatrixCounter]);
    565687  string token;
    566688
    567689  getline(line, token, '\t');
    568   for (int i=1; i<= Energy.ColumnCounter;i++) {
     690  for (int i=1; i<= Energy.ColumnCounter[Energy.MatrixCounter];i++) {
    569691    getline(line, token, '\t');
    570692    while (token[0] == ' ') // remove leading white spaces
    571693      token.erase(0,1);
    572694    output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":" << i+2 << " " << uses;
    573     if (i != (Energy.ColumnCounter))
     695    if (i != (Energy.ColumnCounter[Energy.MatrixCounter]))
    574696      output << ", \\";
    575697    output << endl;
     
    586708void ForceMagnitudePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
    587709{
    588   stringstream line(Force.Header);
     710  stringstream line(Force.Header[Force.MatrixCounter]);
    589711  string token;
    590712
     
    594716  getline(line, token, '\t');
    595717  getline(line, token, '\t');
    596   for (int i=7; i< Force.ColumnCounter;i+=NDIM) {
     718  for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
    597719    getline(line, token, '\t');
    598720    while (token[0] == ' ') // remove leading white spaces
     
    600722    token.erase(token.length(), 1);  // kill residual index char (the '0')
    601723    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))
     724    if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
    603725      output << ", \\";
    604726    output << endl;
     
    617739void AbsFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
    618740{
    619   stringstream line(Force.Header);
     741  stringstream line(Force.Header[Force.MatrixCounter]);
    620742  string token;
    621743
     
    625747  getline(line, token, '\t');
    626748  getline(line, token, '\t');
    627   for (int i=7; i< Force.ColumnCounter;i+=NDIM) {
     749  for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
    628750    getline(line, token, '\t');
    629751    while (token[0] == ' ') // remove leading white spaces
     
    631753    token.erase(token.length(), 1);  // kill residual index char (the '0')
    632754    output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(abs($" << i+1 << ")) " << uses;
    633     if (i != (Force.ColumnCounter-1))
     755    if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
    634756      output << ", \\";
    635757    output << endl;
     
    648770void BoxesForcePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
    649771{
    650   stringstream line(Force.Header);
    651   const char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
     772  stringstream line(Force.Header[Force.MatrixCounter]);
     773  char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
    652774  string token;
    653775
     
    657779  getline(line, token, '\t');
    658780  getline(line, token, '\t');
    659   for (int i=7; i< Force.ColumnCounter;i+=NDIM) {
     781  for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
    660782    getline(line, token, '\t');
    661783    while (token[0] == ' ') // remove leading white spaces
     
    663785    token.erase(token.length(), 1);  // kill residual index char (the '0')
    664786    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))
     787    if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
    666788      output << ", \\";
    667789    output << endl;
     
    680802void BoxesFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
    681803{
    682   stringstream line(Force.Header);
    683   const char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
     804  stringstream line(Force.Header[Force.MatrixCounter]);
     805  char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
    684806  string token;
    685807
     
    689811  getline(line, token, '\t');
    690812  getline(line, token, '\t');
    691   for (int i=7; i< Force.ColumnCounter;i+=NDIM) {
     813  for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
    692814    getline(line, token, '\t');
    693815    while (token[0] == ' ') // remove leading white spaces
     
    695817    token.erase(token.length(), 1);  // kill residual index char (the '0')
    696818    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))
     819    if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
    698820      output << ", \\";
    699821    output << endl;
Note: See TracChangeset for help on using the changeset viewer.