Changes in src/joiner.cpp [042f82:29812d]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/joiner.cpp
r042f82 r29812d 10 10 #include "datacreator.hpp" 11 11 #include "helpers.hpp" 12 #include "memoryallocator.hpp" 12 13 #include "parser.hpp" 13 14 #include "periodentafel.hpp" … … 19 20 periodentafel *periode = NULL; // and a period table of all elements 20 21 EnergyMatrix Energy; 22 EnergyMatrix EnergyFragments; 23 21 24 EnergyMatrix Hcorrection; 25 EnergyMatrix HcorrectionFragments; 26 22 27 ForceMatrix Force; 23 EnergyMatrix EnergyFragments;24 EnergyMatrix HcorrectionFragments;25 28 ForceMatrix ForceFragments; 29 30 HessianMatrix Hessian; 31 HessianMatrix HessianFragments; 32 26 33 ForceMatrix Shielding; 27 34 ForceMatrix ShieldingPAS; 28 35 ForceMatrix ShieldingFragments; 29 36 ForceMatrix ShieldingPASFragments; 30 KeySetsContainer KeySet; 37 ForceMatrix Chi; 38 ForceMatrix ChiPAS; 39 ForceMatrix ChiFragments; 40 ForceMatrix ChiPASFragments; 41 KeySetsContainer KeySet; 31 42 stringstream prefix; 32 43 char *dir = NULL; 33 bool Hcorrected = true; 44 bool NoHCorrection = false; 45 bool NoHessian = false; 34 46 35 47 cout << "Joiner" << endl; … … 44 56 return 1; 45 57 } else { 46 dir = (char *) Malloc(sizeof(char)*(strlen(argv[2])+2), "main: *dir");58 dir = Malloc<char>(strlen(argv[2]) + 2, "main: *dir"); 47 59 strcpy(dir, "/"); 48 60 strcat(dir, argv[2]); … … 61 73 // ------------- Parse through all Fragment subdirs -------- 62 74 if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix, 0,0)) return 1; 63 Hcorrected = Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX, 0,0); 75 if (!Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX, 0,0)) { 76 NoHCorrection = true; 77 cout << "No HCorrection matrices found, skipping these." << endl; 78 } 64 79 if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix, 0,0)) return 1; 80 if (!Hessian.ParseFragmentMatrix(argv[1], dir, HessianSuffix, 0,0)) { 81 NoHessian = true; 82 cout << "No hessian matrices found, skipping these." << endl; 83 } 65 84 if (periode != NULL) { // also look for PAS values 66 85 if (!Shielding.ParseFragmentMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1; 67 86 if (!ShieldingPAS.ParseFragmentMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1; 87 if (!Chi.ParseFragmentMatrix(argv[1], dir, ChiSuffix, 1, 0)) return 1; 88 if (!ChiPAS.ParseFragmentMatrix(argv[1], dir, ChiPASSuffix, 1, 0)) return 1; 68 89 } 69 90 70 91 // ---------- Parse the TE Factors into an array ----------------- 71 if (!Energy.ParseIndices()) return 1; 72 if (Hcorrected) Hcorrection.ParseIndices(); 73 92 if (!Energy.InitialiseIndices()) return 1; 93 if (!NoHCorrection) 94 Hcorrection.InitialiseIndices(); 95 74 96 // ---------- Parse the Force indices into an array --------------- 75 97 if (!Force.ParseIndices(argv[1])) return 1; 76 98 99 // ---------- Parse the Hessian (=force) indices into an array --------------- 100 if (!NoHessian) 101 if (!Hessian.InitialiseIndices((class MatrixContainer *)&Force)) return 1; 102 77 103 // ---------- Parse the shielding indices into an array --------------- 78 104 if (periode != NULL) { // also look for PAS values 79 105 if(!Shielding.ParseIndices(argv[1])) return 1; 80 106 if(!ShieldingPAS.ParseIndices(argv[1])) return 1; 107 if(!Chi.ParseIndices(argv[1])) return 1; 108 if(!ChiPAS.ParseIndices(argv[1])) return 1; 81 109 } 82 110 … … 85 113 86 114 if (!KeySet.ParseManyBodyTerms()) return 1; 115 87 116 if (!EnergyFragments.AllocateMatrix(Energy.Header, Energy.MatrixCounter, Energy.RowCounter, Energy.ColumnCounter)) return 1; 88 if (Hcorrected) HcorrectionFragments.AllocateMatrix(Hcorrection.Header, Hcorrection.MatrixCounter, Hcorrection.RowCounter, Hcorrection.ColumnCounter); 117 if (!NoHCorrection) 118 HcorrectionFragments.AllocateMatrix(Hcorrection.Header, Hcorrection.MatrixCounter, Hcorrection.RowCounter, Hcorrection.ColumnCounter); 89 119 if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1; 120 if (!NoHessian) 121 if (!HessianFragments.AllocateMatrix(Hessian.Header, Hessian.MatrixCounter, Hessian.RowCounter, Hessian.ColumnCounter)) return 1; 90 122 if (periode != NULL) { // also look for PAS values 91 123 if (!ShieldingFragments.AllocateMatrix(Shielding.Header, Shielding.MatrixCounter, Shielding.RowCounter, Shielding.ColumnCounter)) return 1; 92 124 if (!ShieldingPASFragments.AllocateMatrix(ShieldingPAS.Header, ShieldingPAS.MatrixCounter, ShieldingPAS.RowCounter, ShieldingPAS.ColumnCounter)) return 1; 125 if (!ChiFragments.AllocateMatrix(Chi.Header, Chi.MatrixCounter, Chi.RowCounter, Chi.ColumnCounter)) return 1; 126 if (!ChiPASFragments.AllocateMatrix(ChiPAS.Header, ChiPAS.MatrixCounter, ChiPAS.RowCounter, ChiPAS.ColumnCounter)) return 1; 93 127 } 94 128 … … 96 130 if(!Energy.SetLastMatrix(0., 0)) return 1; 97 131 if(!Force.SetLastMatrix(0., 2)) return 1; 132 if (!NoHessian) 133 if (!Hessian.SetLastMatrix(0., 0)) return 1; 98 134 if (periode != NULL) { // also look for PAS values 99 135 if(!Shielding.SetLastMatrix(0., 2)) return 1; 100 136 if(!ShieldingPAS.SetLastMatrix(0., 2)) return 1; 137 if(!Chi.SetLastMatrix(0., 2)) return 1; 138 if(!ChiPAS.SetLastMatrix(0., 2)) return 1; 101 139 } 102 140 … … 108 146 cout << "Summing energy of order " << BondOrder+1 << " ..." << endl; 109 147 if (!EnergyFragments.SumSubManyBodyTerms(Energy, KeySet, BondOrder)) return 1; 110 if ( Hcorrected) {148 if (!NoHCorrection) { 111 149 HcorrectionFragments.SumSubManyBodyTerms(Hcorrection, KeySet, BondOrder); 112 150 if (!Energy.SumSubEnergy(EnergyFragments, &HcorrectionFragments, KeySet, BondOrder, 1.)) return 1; 113 if (Hcorrected)Hcorrection.SumSubEnergy(HcorrectionFragments, NULL, KeySet, BondOrder, 1.);114 } else 151 Hcorrection.SumSubEnergy(HcorrectionFragments, NULL, KeySet, BondOrder, 1.); 152 } else 115 153 if (!Energy.SumSubEnergy(EnergyFragments, NULL, KeySet, BondOrder, 1.)) return 1; 116 154 // --------- sum up Forces -------------------- … … 118 156 if (!ForceFragments.SumSubManyBodyTerms(Force, KeySet, BondOrder)) return 1; 119 157 if (!Force.SumSubForces(ForceFragments, KeySet, BondOrder, 1.)) return 1; 158 // --------- sum up Hessian -------------------- 159 if (!NoHessian) { 160 cout << "Summing Hessian of order " << BondOrder+1 << " ..." << endl; 161 if (!HessianFragments.SumSubManyBodyTerms(Hessian, KeySet, BondOrder)) return 1; 162 if (!Hessian.SumSubHessians(HessianFragments, KeySet, BondOrder, 1.)) return 1; 163 } 120 164 if (periode != NULL) { // also look for PAS values 121 cout << "Summing shieldings of order " << BondOrder+1 << " ..." << endl;165 cout << "Summing shieldings and susceptibilities of order " << BondOrder+1 << " ..." << endl; 122 166 if (!ShieldingFragments.SumSubManyBodyTerms(Shielding, KeySet, BondOrder)) return 1; 123 167 if (!Shielding.SumSubForces(ShieldingFragments, KeySet, BondOrder, 1.)) return 1; 124 168 if (!ShieldingPASFragments.SumSubManyBodyTerms(ShieldingPAS, KeySet, BondOrder)) return 1; 125 169 if (!ShieldingPAS.SumSubForces(ShieldingPASFragments, KeySet, BondOrder, 1.)) return 1; 170 if (!ChiFragments.SumSubManyBodyTerms(Chi, KeySet, BondOrder)) return 1; 171 if (!Chi.SumSubForces(ChiFragments, KeySet, BondOrder, 1.)) return 1; 172 if (!ChiPASFragments.SumSubManyBodyTerms(ChiPAS, KeySet, BondOrder)) return 1; 173 if (!ChiPAS.SumSubForces(ChiPASFragments, KeySet, BondOrder, 1.)) return 1; 126 174 } 127 175 … … 134 182 // forces 135 183 if (!Force.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ForcesSuffix)) return 1; 184 // hessian 185 if (!NoHessian) 186 if (!Hessian.WriteLastMatrix(argv[1], (prefix.str()).c_str(), HessianSuffix)) return 1; 136 187 // shieldings 137 188 if (periode != NULL) { // also look for PAS values 138 189 if (!Shielding.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ShieldingSuffix)) return 1; 139 190 if (!ShieldingPAS.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ShieldingPASSuffix)) return 1; 191 if (!Chi.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ChiSuffix)) return 1; 192 if (!ChiPAS.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ChiPASSuffix)) return 1; 140 193 } 141 194 } … … 144 197 prefix << dir << EnergyFragmentSuffix; 145 198 if (!EnergyFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1; 146 if ( Hcorrected) {199 if (!NoHCorrection) { 147 200 prefix.str(" "); 148 201 prefix << dir << HcorrectionFragmentSuffix; … … 153 206 if (!ForceFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1; 154 207 if (!CreateDataFragment(EnergyFragments, KeySet, argv[1], FRAGMENTPREFIX ENERGYPERFRAGMENT, "fragment energy versus the Fragment No", "today", CreateEnergy)) return 1; 208 if (!NoHessian) { 209 prefix.str(" "); 210 prefix << dir << HessianFragmentSuffix; 211 if (!HessianFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1; 212 } 155 213 if (periode != NULL) { // also look for PAS values 156 214 prefix.str(" "); … … 160 218 prefix << dir << ShieldingPASFragmentSuffix; 161 219 if (!ShieldingPASFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1; 220 prefix.str(" "); 221 prefix << dir << ChiFragmentSuffix; 222 if (!ChiFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1; 223 prefix.str(" "); 224 prefix << dir << ChiPASFragmentSuffix; 225 if (!ChiPASFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1; 162 226 } 163 227 164 228 // write last matrices as fragments into central dir (not subdir as above), for analyzer to know index bounds 165 229 if (!Energy.WriteLastMatrix(argv[1], dir, EnergyFragmentSuffix)) return 1; 166 if ( Hcorrected) Hcorrection.WriteLastMatrix(argv[1], dir, HcorrectionFragmentSuffix);230 if (!NoHCorrection) Hcorrection.WriteLastMatrix(argv[1], dir, HcorrectionFragmentSuffix); 167 231 if (!Force.WriteLastMatrix(argv[1], dir, ForceFragmentSuffix)) return 1; 232 if (!NoHessian) 233 if (!Hessian.WriteLastMatrix(argv[1], dir, HessianFragmentSuffix)) return 1; 168 234 if (periode != NULL) { // also look for PAS values 169 235 if (!Shielding.WriteLastMatrix(argv[1], dir, ShieldingFragmentSuffix)) return 1; 170 236 if (!ShieldingPAS.WriteLastMatrix(argv[1], dir, ShieldingPASFragmentSuffix)) return 1; 237 if (!Chi.WriteLastMatrix(argv[1], dir, ChiFragmentSuffix)) return 1; 238 if (!ChiPAS.WriteLastMatrix(argv[1], dir, ChiPASFragmentSuffix)) return 1; 171 239 } 172 240 173 241 // exit 174 242 delete(periode); 175 Free( (void **)&dir, "main: *dir");243 Free(&dir); 176 244 cout << "done." << endl; 177 245 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.