Changes in molecuilder/src/analyzer.cpp [97c751:6ce722]
- File:
-
- 1 edited
-
molecuilder/src/analyzer.cpp (modified) (14 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/analyzer.cpp
-
Property mode
changed from
100755to100644
r97c751 r6ce722 25 25 periodentafel *periode = NULL; // and a period table of all elements 26 26 EnergyMatrix Energy; 27 EnergyMatrix EnergyFragments; 28 ForceMatrix Force; 29 ForceMatrix ForceFragments; 30 HessianMatrix Hessian; 31 HessianMatrix HessianFragments; 27 32 EnergyMatrix Hcorrection; 28 ForceMatrix Force;33 EnergyMatrix HcorrectionFragments; 29 34 ForceMatrix Shielding; 30 35 ForceMatrix ShieldingPAS; 31 ForceMatrix Chi;32 ForceMatrix ChiPAS;33 36 EnergyMatrix Time; 34 EnergyMatrix EnergyFragments;35 EnergyMatrix HcorrectionFragments;36 ForceMatrix ForceFragments;37 37 ForceMatrix ShieldingFragments; 38 38 ForceMatrix ShieldingPASFragments; 39 ForceMatrix ChiFragments;40 ForceMatrix ChiPASFragments;41 39 KeySetsContainer KeySet; 42 40 ofstream output; … … 53 51 stringstream yrange; 54 52 char *dir = NULL; 55 bool Hcorrected = true; 53 bool NoHCorrection = false; 54 bool NoHessian = false; 55 bool NoTime = false; 56 56 double norm; 57 57 int counter; … … 88 88 // ------------- Parse through all Fragment subdirs -------- 89 89 if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix,0,0)) return 1; 90 Hcorrected = Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX,0,0); 90 if (!Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX,0,0)) { 91 NoHCorrection = true; 92 cout << "No HCorrection file found, skipping these." << endl; 93 } 94 91 95 if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix,0,0)) return 1; 92 if (!Time.ParseFragmentMatrix(argv[1], dir, TimeSuffix, 10,1)) return 1; 96 if (!Hessian.ParseFragmentMatrix(argv[1], dir, HessianSuffix,0,0)) { 97 NoHessian = true; 98 cout << "No Hessian file found, skipping these." << endl; 99 } 100 if (!Time.ParseFragmentMatrix(argv[1], dir, TimeSuffix, 10,1)) { 101 NoTime = true; 102 cout << "No speed file found, skipping these." << endl; 103 } 93 104 if (periode != NULL) { // also look for PAS values 94 105 if (!Shielding.ParseFragmentMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1; 95 106 if (!ShieldingPAS.ParseFragmentMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1; 96 if (!Chi.ParseFragmentMatrix(argv[1], dir, ChiSuffix, 1, 0)) return 1;97 if (!ChiPAS.ParseFragmentMatrix(argv[1], dir, ChiPASSuffix, 1, 0)) return 1;98 107 } 99 108 100 109 // ---------- Parse the TE Factors into an array ----------------- 101 if (!Energy.ParseIndices()) return 1; 102 if (Hcorrected) Hcorrection.ParseIndices(); 110 if (!Energy.InitialiseIndices()) return 1; 111 if (!NoHCorrection) 112 Hcorrection.InitialiseIndices(); 103 113 104 114 // ---------- Parse the Force indices into an array --------------- 105 115 if (!Force.ParseIndices(argv[1])) return 1; 106 116 if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1; 107 if (!ForceFragments.ParseIndices(argv[1])) return 1; 117 if (!ForceFragments.InitialiseIndices((class MatrixContainer *)&Force)) return 1; 118 119 // ---------- Parse hessian indices into an array ----------------- 120 if (!NoHessian) { 121 if (!Hessian.InitialiseIndices((class MatrixContainer *)&Force)) return 1; 122 if (!HessianFragments.AllocateMatrix(Hessian.Header, Hessian.MatrixCounter, Hessian.RowCounter, Hessian.ColumnCounter)) return 1; 123 if (!HessianFragments.InitialiseIndices((class MatrixContainer *)&Force)) return 1; 124 } 108 125 109 126 // ---------- Parse the shielding indices into an array --------------- … … 115 132 if(!ShieldingFragments.ParseIndices(argv[1])) return 1; 116 133 if(!ShieldingPASFragments.ParseIndices(argv[1])) return 1; 117 if(!Chi.ParseIndices(argv[1])) return 1;118 if(!ChiPAS.ParseIndices(argv[1])) return 1;119 if (!ChiFragments.AllocateMatrix(Chi.Header, Chi.MatrixCounter, Chi.RowCounter, Chi.ColumnCounter)) return 1;120 if (!ChiPASFragments.AllocateMatrix(ChiPAS.Header, ChiPAS.MatrixCounter, ChiPAS.RowCounter, ChiPAS.ColumnCounter)) return 1;121 if(!ChiFragments.ParseIndices(argv[1])) return 1;122 if(!ChiPASFragments.ParseIndices(argv[1])) return 1;123 134 } 124 135 … … 129 140 // ---------- Parse fragment files created by 'joiner' into an array ------------- 130 141 if (!EnergyFragments.ParseFragmentMatrix(argv[1], dir, EnergyFragmentSuffix,0,0)) return 1; 131 if (Hcorrected) HcorrectionFragments.ParseFragmentMatrix(argv[1], dir, HcorrectionFragmentSuffix,0,0); 142 if (!NoHCorrection) 143 HcorrectionFragments.ParseFragmentMatrix(argv[1], dir, HcorrectionFragmentSuffix,0,0); 132 144 if (!ForceFragments.ParseFragmentMatrix(argv[1], dir, ForceFragmentSuffix,0,0)) return 1; 145 if (!NoHessian) 146 if (!HessianFragments.ParseFragmentMatrix(argv[1], dir, HessianFragmentSuffix,0,0)) return 1; 133 147 if (periode != NULL) { // also look for PAS values 134 148 if (!ShieldingFragments.ParseFragmentMatrix(argv[1], dir, ShieldingFragmentSuffix, 1, 0)) return 1; 135 149 if (!ShieldingPASFragments.ParseFragmentMatrix(argv[1], dir, ShieldingPASFragmentSuffix, 1, 0)) return 1; 136 if (!ChiFragments.ParseFragmentMatrix(argv[1], dir, ChiFragmentSuffix, 1, 0)) return 1;137 if (!ChiPASFragments.ParseFragmentMatrix(argv[1], dir, ChiPASFragmentSuffix, 1, 0)) return 1;138 150 } 139 151 … … 144 156 filename << argv[3] << "/" << "energy-forces.all"; 145 157 output.open(filename.str().c_str(), ios::out); 146 output << endl << "Total Energy" << endl << "==============" << endl << Energy.Header << endl;158 output << endl << "Total Energy" << endl << "==============" << endl << Energy.Header[Energy.MatrixCounter] << endl; 147 159 for(int j=0;j<Energy.RowCounter[Energy.MatrixCounter];j++) { 148 for(int k=0;k<Energy.ColumnCounter ;k++)160 for(int k=0;k<Energy.ColumnCounter[Energy.MatrixCounter];k++) 149 161 output << scientific << Energy.Matrix[ Energy.MatrixCounter ][j][k] << "\t"; 150 162 output << endl; … … 152 164 output << endl; 153 165 154 output << endl << "Total Forces" << endl << "===============" << endl << Force.Header << endl;166 output << endl << "Total Forces" << endl << "===============" << endl << Force.Header[Force.MatrixCounter] << endl; 155 167 for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) { 156 for(int k=0;k<Force.ColumnCounter ;k++)168 for(int k=0;k<Force.ColumnCounter[Force.MatrixCounter];k++) 157 169 output << scientific << Force.Matrix[ Force.MatrixCounter ][j][k] << "\t"; 158 170 output << endl; … … 160 172 output << endl; 161 173 162 if (periode != NULL) { // also look for PAS values 163 output << endl << "Total Shieldings" << endl << "===============" << endl << Shielding.Header << endl; 174 if (!NoHessian) { 175 output << endl << "Total Hessian" << endl << "===============" << endl << Hessian.Header[Hessian.MatrixCounter] << endl; 176 for(int j=0;j<Hessian.RowCounter[Hessian.MatrixCounter];j++) { 177 for(int k=0;k<Hessian.ColumnCounter[Hessian.MatrixCounter];k++) 178 output << scientific << Hessian.Matrix[ Hessian.MatrixCounter ][j][k] << "\t"; 179 output << endl; 180 } 181 output << endl; 182 } 183 184 if (periode != NULL) { // also look for PAS values 185 output << endl << "Total Shieldings" << endl << "===============" << endl << Shielding.Header[Hessian.MatrixCounter] << endl; 164 186 for(int j=0;j<Shielding.RowCounter[Shielding.MatrixCounter];j++) { 165 for(int k=0;k<Shielding.ColumnCounter ;k++)187 for(int k=0;k<Shielding.ColumnCounter[Shielding.MatrixCounter];k++) 166 188 output << scientific << Shielding.Matrix[ Shielding.MatrixCounter ][j][k] << "\t"; 167 189 output << endl; … … 169 191 output << endl; 170 192 171 output << endl << "Total Shieldings PAS" << endl << "===============" << endl << ShieldingPAS.Header << endl;193 output << endl << "Total Shieldings PAS" << endl << "===============" << endl << ShieldingPAS.Header[ShieldingPAS.MatrixCounter] << endl; 172 194 for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) { 173 for(int k=0;k<ShieldingPAS.ColumnCounter ;k++)195 for(int k=0;k<ShieldingPAS.ColumnCounter[ShieldingPAS.MatrixCounter];k++) 174 196 output << scientific << ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t"; 175 197 output << endl; 176 198 } 177 199 output << endl; 178 179 output << endl << "Total Chis" << endl << "===============" << endl << Chi.Header[Chi.MatrixCounter] << endl; 180 for(int j=0;j<Chi.RowCounter[Chi.MatrixCounter];j++) { 181 for(int k=0;k<Chi.ColumnCounter;k++) 182 output << scientific << Chi.Matrix[ Chi.MatrixCounter ][j][k] << "\t"; 183 output << endl; 184 } 185 output << endl; 186 187 output << endl << "Total Chis PAS" << endl << "===============" << endl << ChiPAS.Header[ChiPAS.MatrixCounter] << endl; 188 for(int j=0;j<ChiPAS.RowCounter[ChiPAS.MatrixCounter];j++) { 189 for(int k=0;k<ChiPAS.ColumnCounter;k++) 190 output << scientific << ChiPAS.Matrix[ ChiPAS.MatrixCounter ][j][k] << "\t"; 191 output << endl; 192 } 193 output << endl; 194 } 195 196 output << endl << "Total Times" << endl << "===============" << endl << Time.Header << endl; 197 for(int j=0;j<Time.RowCounter[Time.MatrixCounter];j++) { 198 for(int k=0;k<Time.ColumnCounter;k++) { 199 output << scientific << Time.Matrix[ Time.MatrixCounter ][j][k] << "\t"; 200 } 201 output << endl; 202 } 203 output << endl; 200 } 201 202 if (!NoTime) { 203 output << endl << "Total Times" << endl << "===============" << endl << Time.Header[Time.MatrixCounter] << endl; 204 for(int j=0;j<Time.RowCounter[Time.MatrixCounter];j++) { 205 for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) { 206 output << scientific << Time.Matrix[ Time.MatrixCounter ][j][k] << "\t"; 207 } 208 output << endl; 209 } 210 output << endl; 211 } 204 212 output.close(); 205 for(int k=0;k<Time.ColumnCounter;k++) 206 Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k] = Time.Matrix[ Time.MatrixCounter ][Time.RowCounter[Time.MatrixCounter]-1][k]; 213 if (!NoTime) 214 for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) 215 Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k] = Time.Matrix[ Time.MatrixCounter ][Time.RowCounter[Time.MatrixCounter]-1][k]; 207 216 208 217 // +++++++++++++++ ANALYZING ++++++++++++++++++++++++++++++ … … 214 223 // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order 215 224 // +++++++++++++++++++++++++++++++++++++++ Plotting Delta Simtime vs Bond Order 216 if (!OpenOutputFile(output, argv[3], "SimTime-Order.dat" )) return false; 217 if (!OpenOutputFile(output2, argv[3], "DeltaSimTime-Order.dat" )) return false; 218 for(int j=Time.RowCounter[Time.MatrixCounter];j--;) 219 for(int k=Time.ColumnCounter;k--;) { 220 Time.Matrix[ Time.MatrixCounter ][j][k] = 0.; 221 } 222 counter = 0; 223 output << "#Order\tFrag.No.\t" << Time.Header << endl; 224 output2 << "#Order\tFrag.No.\t" << Time.Header << endl; 225 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 226 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) 227 for(int j=Time.RowCounter[Time.MatrixCounter];j--;) 228 for(int k=Time.ColumnCounter;k--;) { 229 Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 230 } 231 counter += KeySet.FragmentsPerOrder[BondOrder]; 232 output << BondOrder+1 << "\t" << counter; 233 output2 << BondOrder+1 << "\t" << counter; 234 for(int k=0;k<Time.ColumnCounter;k++) { 235 output << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k]; 236 if (fabs(Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k]) > MYEPSILON) 237 output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k] / Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k]; 238 else 239 output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k]; 240 } 241 output << endl; 242 output2 << endl; 243 } 244 output.close(); 245 output2.close(); 225 if (!NoTime) { 226 if (!OpenOutputFile(output, argv[3], "SimTime-Order.dat" )) return false; 227 if (!OpenOutputFile(output2, argv[3], "DeltaSimTime-Order.dat" )) return false; 228 for(int j=Time.RowCounter[Time.MatrixCounter];j--;) 229 for(int k=Time.ColumnCounter[Time.MatrixCounter];k--;) { 230 Time.Matrix[ Time.MatrixCounter ][j][k] = 0.; 231 } 232 counter = 0; 233 output << "#Order\tFrag.No.\t" << Time.Header[Time.MatrixCounter] << endl; 234 output2 << "#Order\tFrag.No.\t" << Time.Header[Time.MatrixCounter] << endl; 235 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 236 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) 237 for(int j=Time.RowCounter[Time.MatrixCounter];j--;) 238 for(int k=Time.ColumnCounter[Time.MatrixCounter];k--;) { 239 Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 240 } 241 counter += KeySet.FragmentsPerOrder[BondOrder]; 242 output << BondOrder+1 << "\t" << counter; 243 output2 << BondOrder+1 << "\t" << counter; 244 for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) { 245 output << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k]; 246 if (fabs(Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k]) > MYEPSILON) 247 output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k] / Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k]; 248 else 249 output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k]; 250 } 251 output << endl; 252 output2 << endl; 253 } 254 output.close(); 255 output2.close(); 256 } 257 258 if (!NoHessian) { 259 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in hessian to full QM 260 if (!CreateDataDeltaHessianOrderPerAtom(Hessian, HessianFragments, KeySet, argv[3], "DeltaHessian_xx-Order", "Plot of error between approximated hessian and full hessian versus the Bond Order", datum)) return 1; 261 262 if (!CreateDataDeltaFrobeniusOrderPerAtom(Hessian, HessianFragments, KeySet, argv[3], "DeltaFrobeniusHessian_xx-Order", "Plot of error between approximated hessian and full hessian in the frobenius norm versus the Bond Order", datum)) return 1; 263 264 // ++++++++++++++++++++++++++++++++++++++Plotting Hessian vs. Order 265 if (!CreateDataHessianOrderPerAtom(HessianFragments, KeySet, argv[3], "Hessian_xx-Order", "Plot of approximated hessian versus the Bond Order", datum)) return 1; 266 if (!AppendOutputFile(output, argv[3], "Hessian_xx-Order.dat" )) return false; 267 output << endl << "# Full" << endl; 268 for(int j=0;j<Hessian.RowCounter[Hessian.MatrixCounter];j++) { 269 output << j << "\t"; 270 for(int k=0;k<Hessian.ColumnCounter[Force.MatrixCounter];k++) 271 output << scientific << Hessian.Matrix[ Hessian.MatrixCounter ][j][k] << "\t"; 272 output << endl; 273 } 274 output.close(); 275 } 246 276 247 277 // +++++++++++++++++++++++++++++++++++++++ Plotting shieldings … … 254 284 for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) { 255 285 output << j << "\t"; 256 for(int k=0;k<ShieldingPAS.ColumnCounter ;k++)286 for(int k=0;k<ShieldingPAS.ColumnCounter[ShieldingPAS.MatrixCounter];k++) 257 287 output << scientific << ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t"; //*(((k>1) && (k<6))? 1.e6 : 1.) << "\t"; 258 288 output << endl; 259 289 } 260 output.close(); 261 if (!CreateDataDeltaForcesOrderPerAtom(ChiPAS, ChiPASFragments, KeySet, argv[3], "DeltaChisPAS-Order", "Plot of error between approximated Chis and full Chis versus the Bond Order", datum)) return 1; 262 if (!CreateDataForcesOrderPerAtom(ChiPASFragments, KeySet, argv[3], "ChisPAS-Order", "Plot of approximated Chis versus the Bond Order", datum)) return 1; 263 if (!AppendOutputFile(output, argv[3], "ChisPAS-Order.dat" )) return false; 264 output << endl << "# Full" << endl; 265 for(int j=0;j<ChiPAS.RowCounter[ChiPAS.MatrixCounter];j++) { 266 output << j << "\t"; 267 for(int k=0;k<ChiPAS.ColumnCounter;k++) 268 output << scientific << ChiPAS.Matrix[ ChiPAS.MatrixCounter ][j][k] << "\t"; //*(((k>1) && (k<6))? 1.e6 : 1.) << "\t"; 269 output << endl; 270 } 271 output.close(); 272 } 290 } 291 output.close(); 273 292 274 293 … … 297 316 for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) { 298 317 output << j << "\t"; 299 for(int k=0;k<Force.ColumnCounter ;k++)318 for(int k=0;k<Force.ColumnCounter[Force.MatrixCounter];k++) 300 319 output << scientific << Force.Matrix[ Force.MatrixCounter ][j][k] << "\t"; 301 320 output << endl; … … 346 365 yrange.str("[1e-8:1e+1]"); 347 366 348 // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order 349 if (!CreatePlotOrder(Time, KeySet, argv[3], "SimTime-Order", 1, "below", "y", "", 1, 1, "bond order k", "Evaluation time [s]", Orderxrange.str().c_str(), "", "1" , "with linespoints", EnergyPlotLine)) return 1; 367 if (!NoTime) { 368 // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order 369 if (!CreatePlotOrder(Time, KeySet, argv[3], "SimTime-Order", 1, "below", "y", "", 1, 1, "bond order k", "Evaluation time [s]", Orderxrange.str().c_str(), "", "1" , "with linespoints", EnergyPlotLine)) return 1; 370 } 350 371 351 372 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM … … 445 466 } 446 467 output << "'ShieldingsPAS-Order.dat' index " << KeySet.Order << " title 'Full' using ($1+" << step*(double)KeySet.Order << "):7 with boxes" << endl; 447 output.close();448 output2.close();449 450 if(!OpenOutputFile(output, argv[3], "ChisPAS-Order.pyx")) return 1;451 if(!OpenOutputFile(output2, argv[3], "DeltaChisPAS-Order.pyx")) return 1;452 CreatePlotHeader(output, "ChisPAS-Order", 1, "top right", NULL, NULL, 1, 5, "nuclei index", "iso chemical Chi value [ppm]");453 CreatePlotHeader(output2, "DeltaChisPAS-Order", 1, "top right", NULL, NULL, 1, 5, "nuclei index", "iso chemical Chi value [ppm]");454 output << "set boxwidth " << step << endl;455 output << "plot [0:" << ChiPAS.RowCounter[ChiPAS.MatrixCounter]+10 << "]\\" << endl;456 output2 << "plot [0:" << ChiPAS.RowCounter[ChiPAS.MatrixCounter]+10 << "]\\" << endl;457 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {458 output << "'ChisPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1+" << step*(double)BondOrder << "):7 with boxes, \\" << endl;459 output2 << "'DeltaChisPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1):7 with linespoints";460 if (BondOrder-1 != KeySet.Order)461 output2 << ", \\" << endl;462 }463 output << "'ChisPAS-Order.dat' index " << KeySet.Order << " title 'Full' using ($1+" << step*(double)KeySet.Order << "):7 with boxes" << endl;464 468 output.close(); 465 469 output2.close(); -
Property mode
changed from
Note:
See TracChangeset
for help on using the changeset viewer.
