Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/joiner.cpp

    r5bc4d0 r437922  
    22 *
    33 * Takes evaluated fragments (energy and forces) and by reading the factors files determines total energy
    4  * and each force for the whole molecule. 
    5  *   
     4 * and each force for the whole molecule.
     5 *
    66 */
    77
    88//============================ INCLUDES ===========================
    99
    10 #include "datacreator.hpp" 
    11 #include "helpers.hpp" 
    12 #include "parser.hpp" 
    13 #include "periodentafel.hpp" 
     10#include "datacreator.hpp"
     11#include "helpers.hpp"
     12#include "parser.hpp"
     13#include "periodentafel.hpp"
    1414
    1515//============================== MAIN =============================
     
    2828  ForceMatrix ShieldingFragments;
    2929  ForceMatrix ShieldingPASFragments;
    30   EnergyMatrix Chi;
    31   EnergyMatrix ChiPAS;
    32   EnergyMatrix ChiFragments;
    33   EnergyMatrix ChiPASFragments;
    34   KeySetsContainer KeySet; 
     30  KeySetsContainer KeySet;
    3531  stringstream prefix;
    3632  char *dir = NULL;
     
    3935  cout << "Joiner" << endl;
    4036  cout << "======" << endl;
    41  
     37
    4238  // Get the command line options
    4339  if (argc < 3) {
     
    5652    periode->LoadPeriodentafel(argv[3]);
    5753  }
    58  
     54
    5955  // Test the given directory
    6056  if (!TestParams(argc, argv))
    6157    return 1;
    62  
     58
    6359  // +++++++++++++++++ PARSING +++++++++++++++++++++++++++++++
    64  
     60
    6561  // ------------- Parse through all Fragment subdirs --------
    6662  if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix, 0,0)) return 1;
     
    7066    if (!Shielding.ParseFragmentMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1;
    7167    if (!ShieldingPAS.ParseFragmentMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1;
    72     if (!Chi.ParseFragmentMatrix(argv[1], dir, ChiSuffix, 1, 0)) return 1;
    73     if (!ChiPAS.ParseFragmentMatrix(argv[1], dir, ChiPASSuffix, 1, 0)) return 1;
    7468  }
    7569
     
    7771  if (!Energy.ParseIndices()) return 1;
    7872  if (Hcorrected) Hcorrection.ParseIndices();
    79  
     73
    8074  // ---------- Parse the Force indices into an array ---------------
    8175  if (!Force.ParseIndices(argv[1])) return 1;
     
    8579    if(!Shielding.ParseIndices(argv[1])) return 1;
    8680    if(!ShieldingPAS.ParseIndices(argv[1])) return 1;
    87     if(!Chi.ParseIndices()) return 1;
    88     if(!ChiPAS.ParseIndices()) return 1;
    8981  }
    9082
    9183  // ---------- Parse the KeySets into an array ---------------
    9284  if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1;
     85
    9386  if (!KeySet.ParseManyBodyTerms()) return 1;
    94 
    9587  if (!EnergyFragments.AllocateMatrix(Energy.Header, Energy.MatrixCounter, Energy.RowCounter, Energy.ColumnCounter)) return 1;
    9688  if (Hcorrected)  HcorrectionFragments.AllocateMatrix(Hcorrection.Header, Hcorrection.MatrixCounter, Hcorrection.RowCounter, Hcorrection.ColumnCounter);
     
    9991    if (!ShieldingFragments.AllocateMatrix(Shielding.Header, Shielding.MatrixCounter, Shielding.RowCounter, Shielding.ColumnCounter)) return 1;
    10092    if (!ShieldingPASFragments.AllocateMatrix(ShieldingPAS.Header, ShieldingPAS.MatrixCounter, ShieldingPAS.RowCounter, ShieldingPAS.ColumnCounter)) return 1;
    101     if (!ChiFragments.AllocateMatrix(Chi.Header, Chi.MatrixCounter, Chi.RowCounter, Chi.ColumnCounter)) return 1;
    102     if (!ChiPASFragments.AllocateMatrix(ChiPAS.Header, ChiPAS.MatrixCounter, ChiPAS.RowCounter, ChiPAS.ColumnCounter)) return 1;
    10393  }
    104  
     94
    10595  // ----------- Resetting last matrices (where full QM values are stored right now)
    10696  if(!Energy.SetLastMatrix(0., 0)) return 1;
     
    10999    if(!Shielding.SetLastMatrix(0., 2)) return 1;
    110100    if(!ShieldingPAS.SetLastMatrix(0., 2)) return 1;
    111     if(!Chi.SetLastMatrix(0., 2)) return 1;
    112     if(!ChiPAS.SetLastMatrix(0., 2)) return 1;
    113101  }
    114102
     
    120108    cout << "Summing energy of order " << BondOrder+1 << " ..." << endl;
    121109    if (!EnergyFragments.SumSubManyBodyTerms(Energy, KeySet, BondOrder)) return 1;
    122     if (Hcorrected) { 
     110    if (Hcorrected) {
    123111      HcorrectionFragments.SumSubManyBodyTerms(Hcorrection, KeySet, BondOrder);
    124112      if (!Energy.SumSubEnergy(EnergyFragments, &HcorrectionFragments, KeySet, BondOrder, 1.)) return 1;
    125113      if (Hcorrected) Hcorrection.SumSubEnergy(HcorrectionFragments, NULL, KeySet, BondOrder, 1.);
    126     } else 
     114    } else
    127115      if (!Energy.SumSubEnergy(EnergyFragments, NULL, KeySet, BondOrder, 1.)) return 1;
    128116    // --------- sum up Forces --------------------
     
    131119    if (!Force.SumSubForces(ForceFragments, KeySet, BondOrder, 1.)) return 1;
    132120    if (periode != NULL) { // also look for PAS values
    133       cout << "Summing shieldings and susceptibilities of order " << BondOrder+1 << " ..." << endl;
     121      cout << "Summing shieldings of order " << BondOrder+1 << " ..." << endl;
    134122      if (!ShieldingFragments.SumSubManyBodyTerms(Shielding, KeySet, BondOrder)) return 1;
    135123      if (!Shielding.SumSubForces(ShieldingFragments, KeySet, BondOrder, 1.)) return 1;
    136124      if (!ShieldingPASFragments.SumSubManyBodyTerms(ShieldingPAS, KeySet, BondOrder)) return 1;
    137125      if (!ShieldingPAS.SumSubForces(ShieldingPASFragments, KeySet, BondOrder, 1.)) return 1;
    138       if (!ChiFragments.SumSubManyBodyTerms(Chi, KeySet, BondOrder)) return 1;
    139       if (!Chi.SumSubEnergy(ChiFragments, NULL, KeySet, BondOrder, 1.)) return 1;
    140       if (!ChiPASFragments.SumSubManyBodyTerms(ChiPAS, KeySet, BondOrder)) return 1;
    141       if (!ChiPAS.SumSubEnergy(ChiPASFragments, NULL,KeySet, BondOrder, 1.)) return 1;
    142126    }
    143127
     
    154138      if (!Shielding.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ShieldingSuffix)) return 1;
    155139      if (!ShieldingPAS.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ShieldingPASSuffix)) return 1;
    156       if (!Chi.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ChiSuffix)) return 1;
    157       if (!ChiPAS.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ChiPASSuffix)) return 1;
    158140    }
    159141  }
     
    178160    prefix << dir << ShieldingPASFragmentSuffix;
    179161    if (!ShieldingPASFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
    180     prefix.str(" ");
    181     prefix << dir << ChiFragmentSuffix;
    182     if (!ChiFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
    183     prefix.str(" ");
    184     prefix << dir << ChiPASFragmentSuffix;
    185     if (!ChiPASFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
    186162  }
    187163
     
    193169    if (!Shielding.WriteLastMatrix(argv[1], dir, ShieldingFragmentSuffix)) return 1;
    194170    if (!ShieldingPAS.WriteLastMatrix(argv[1], dir, ShieldingPASFragmentSuffix)) return 1;
    195     if (!Chi.WriteLastMatrix(argv[1], dir, ChiFragmentSuffix)) return 1;
    196     if (!ChiPAS.WriteLastMatrix(argv[1], dir, ChiPASFragmentSuffix)) return 1;
    197171  }
    198172
    199   // exit 
     173  // exit
    200174  delete(periode);
    201175  Free((void **)&dir, "main: *dir");
Note: See TracChangeset for help on using the changeset viewer.