Changeset 09f4dc for molecuilder/src/analyzer.cpp
- Timestamp:
- Jul 23, 2009, 9:14:18 AM (16 years ago)
- Children:
- 3b470f
- Parents:
- 2218dca (diff), 6ce722 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
molecuilder/src/analyzer.cpp (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/analyzer.cpp
r2218dca r09f4dc 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; … … 32 37 ForceMatrix ChiPAS; 33 38 EnergyMatrix Time; 34 EnergyMatrix EnergyFragments;35 EnergyMatrix HcorrectionFragments;36 ForceMatrix ForceFragments;37 39 ForceMatrix ShieldingFragments; 38 40 ForceMatrix ShieldingPASFragments; … … 53 55 stringstream yrange; 54 56 char *dir = NULL; 55 bool Hcorrected = true; 57 bool NoHCorrection = false; 58 bool NoHessian = false; 59 bool NoTime = false; 56 60 double norm; 57 61 int counter; … … 88 92 // ------------- Parse through all Fragment subdirs -------- 89 93 if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix,0,0)) return 1; 90 Hcorrected = Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX,0,0); 94 if (!Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX,0,0)) { 95 NoHCorrection = true; 96 cout << "No HCorrection file found, skipping these." << endl; 97 } 98 91 99 if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix,0,0)) return 1; 92 if (!Time.ParseFragmentMatrix(argv[1], dir, TimeSuffix, 10,1)) return 1; 100 if (!Hessian.ParseFragmentMatrix(argv[1], dir, HessianSuffix,0,0)) { 101 NoHessian = true; 102 cout << "No Hessian file found, skipping these." << endl; 103 } 104 if (!Time.ParseFragmentMatrix(argv[1], dir, TimeSuffix, 10,1)) { 105 NoTime = true; 106 cout << "No speed file found, skipping these." << endl; 107 } 93 108 if (periode != NULL) { // also look for PAS values 94 109 if (!Shielding.ParseFragmentMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1; … … 99 114 100 115 // ---------- Parse the TE Factors into an array ----------------- 101 if (!Energy.ParseIndices()) return 1; 102 if (Hcorrected) Hcorrection.ParseIndices(); 116 if (!Energy.InitialiseIndices()) return 1; 117 if (!NoHCorrection) 118 Hcorrection.InitialiseIndices(); 103 119 104 120 // ---------- Parse the Force indices into an array --------------- 105 121 if (!Force.ParseIndices(argv[1])) return 1; 106 122 if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1; 107 if (!ForceFragments.ParseIndices(argv[1])) return 1; 123 if (!ForceFragments.InitialiseIndices((class MatrixContainer *)&Force)) return 1; 124 125 // ---------- Parse hessian indices into an array ----------------- 126 if (!NoHessian) { 127 if (!Hessian.InitialiseIndices((class MatrixContainer *)&Force)) return 1; 128 if (!HessianFragments.AllocateMatrix(Hessian.Header, Hessian.MatrixCounter, Hessian.RowCounter, Hessian.ColumnCounter)) return 1; 129 if (!HessianFragments.InitialiseIndices((class MatrixContainer *)&Force)) return 1; 130 } 108 131 109 132 // ---------- Parse the shielding indices into an array --------------- … … 129 152 // ---------- Parse fragment files created by 'joiner' into an array ------------- 130 153 if (!EnergyFragments.ParseFragmentMatrix(argv[1], dir, EnergyFragmentSuffix,0,0)) return 1; 131 if (Hcorrected) HcorrectionFragments.ParseFragmentMatrix(argv[1], dir, HcorrectionFragmentSuffix,0,0); 154 if (!NoHCorrection) 155 HcorrectionFragments.ParseFragmentMatrix(argv[1], dir, HcorrectionFragmentSuffix,0,0); 132 156 if (!ForceFragments.ParseFragmentMatrix(argv[1], dir, ForceFragmentSuffix,0,0)) return 1; 157 if (!NoHessian) 158 if (!HessianFragments.ParseFragmentMatrix(argv[1], dir, HessianFragmentSuffix,0,0)) return 1; 133 159 if (periode != NULL) { // also look for PAS values 134 160 if (!ShieldingFragments.ParseFragmentMatrix(argv[1], dir, ShieldingFragmentSuffix, 1, 0)) return 1; … … 144 170 filename << argv[3] << "/" << "energy-forces.all"; 145 171 output.open(filename.str().c_str(), ios::out); 146 output << endl << "Total Energy" << endl << "==============" << endl << Energy.Header << endl;172 output << endl << "Total Energy" << endl << "==============" << endl << Energy.Header[Energy.MatrixCounter] << endl; 147 173 for(int j=0;j<Energy.RowCounter[Energy.MatrixCounter];j++) { 148 for(int k=0;k<Energy.ColumnCounter ;k++)174 for(int k=0;k<Energy.ColumnCounter[Energy.MatrixCounter];k++) 149 175 output << scientific << Energy.Matrix[ Energy.MatrixCounter ][j][k] << "\t"; 150 176 output << endl; … … 152 178 output << endl; 153 179 154 output << endl << "Total Forces" << endl << "===============" << endl << Force.Header << endl;180 output << endl << "Total Forces" << endl << "===============" << endl << Force.Header[Force.MatrixCounter] << endl; 155 181 for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) { 156 for(int k=0;k<Force.ColumnCounter ;k++)182 for(int k=0;k<Force.ColumnCounter[Force.MatrixCounter];k++) 157 183 output << scientific << Force.Matrix[ Force.MatrixCounter ][j][k] << "\t"; 158 184 output << endl; … … 160 186 output << endl; 161 187 188 if (!NoHessian) { 189 output << endl << "Total Hessian" << endl << "===============" << endl << Hessian.Header[Hessian.MatrixCounter] << endl; 190 for(int j=0;j<Hessian.RowCounter[Hessian.MatrixCounter];j++) { 191 for(int k=0;k<Hessian.ColumnCounter[Hessian.MatrixCounter];k++) 192 output << scientific << Hessian.Matrix[ Hessian.MatrixCounter ][j][k] << "\t"; 193 output << endl; 194 } 195 output << endl; 196 } 197 162 198 if (periode != NULL) { // also look for PAS values 163 output << endl << "Total Shieldings" << endl << "===============" << endl << Shielding.Header << endl;199 output << endl << "Total Shieldings" << endl << "===============" << endl << Shielding.Header[Hessian.MatrixCounter] << endl; 164 200 for(int j=0;j<Shielding.RowCounter[Shielding.MatrixCounter];j++) { 165 for(int k=0;k<Shielding.ColumnCounter ;k++)201 for(int k=0;k<Shielding.ColumnCounter[Shielding.MatrixCounter];k++) 166 202 output << scientific << Shielding.Matrix[ Shielding.MatrixCounter ][j][k] << "\t"; 167 203 output << endl; … … 169 205 output << endl; 170 206 171 output << endl << "Total Shieldings PAS" << endl << "===============" << endl << ShieldingPAS.Header << endl;207 output << endl << "Total Shieldings PAS" << endl << "===============" << endl << ShieldingPAS.Header[ShieldingPAS.MatrixCounter] << endl; 172 208 for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) { 173 for(int k=0;k<ShieldingPAS.ColumnCounter ;k++)209 for(int k=0;k<ShieldingPAS.ColumnCounter[ShieldingPAS.MatrixCounter];k++) 174 210 output << scientific << ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t"; 175 211 output << endl; … … 194 230 } 195 231 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; 232 if (!NoTime) { 233 output << endl << "Total Times" << endl << "===============" << endl << Time.Header[Time.MatrixCounter] << endl; 234 for(int j=0;j<Time.RowCounter[Time.MatrixCounter];j++) { 235 for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) { 236 output << scientific << Time.Matrix[ Time.MatrixCounter ][j][k] << "\t"; 237 } 238 output << endl; 239 } 240 output << endl; 241 } 204 242 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]; 243 if (!NoTime) 244 for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) 245 Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k] = Time.Matrix[ Time.MatrixCounter ][Time.RowCounter[Time.MatrixCounter]-1][k]; 207 246 208 247 // +++++++++++++++ ANALYZING ++++++++++++++++++++++++++++++ … … 214 253 // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order 215 254 // +++++++++++++++++++++++++++++++++++++++ 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(); 255 if (!NoTime) { 256 if (!OpenOutputFile(output, argv[3], "SimTime-Order.dat" )) return false; 257 if (!OpenOutputFile(output2, argv[3], "DeltaSimTime-Order.dat" )) return false; 258 for(int j=Time.RowCounter[Time.MatrixCounter];j--;) 259 for(int k=Time.ColumnCounter[Time.MatrixCounter];k--;) { 260 Time.Matrix[ Time.MatrixCounter ][j][k] = 0.; 261 } 262 counter = 0; 263 output << "#Order\tFrag.No.\t" << Time.Header[Time.MatrixCounter] << endl; 264 output2 << "#Order\tFrag.No.\t" << Time.Header[Time.MatrixCounter] << endl; 265 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 266 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) 267 for(int j=Time.RowCounter[Time.MatrixCounter];j--;) 268 for(int k=Time.ColumnCounter[Time.MatrixCounter];k--;) { 269 Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 270 } 271 counter += KeySet.FragmentsPerOrder[BondOrder]; 272 output << BondOrder+1 << "\t" << counter; 273 output2 << BondOrder+1 << "\t" << counter; 274 for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) { 275 output << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k]; 276 if (fabs(Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k]) > MYEPSILON) 277 output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k] / Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k]; 278 else 279 output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k]; 280 } 281 output << endl; 282 output2 << endl; 283 } 284 output.close(); 285 output2.close(); 286 } 287 288 if (!NoHessian) { 289 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in hessian to full QM 290 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; 291 292 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; 293 294 // ++++++++++++++++++++++++++++++++++++++Plotting Hessian vs. Order 295 if (!CreateDataHessianOrderPerAtom(HessianFragments, KeySet, argv[3], "Hessian_xx-Order", "Plot of approximated hessian versus the Bond Order", datum)) return 1; 296 if (!AppendOutputFile(output, argv[3], "Hessian_xx-Order.dat" )) return false; 297 output << endl << "# Full" << endl; 298 for(int j=0;j<Hessian.RowCounter[Hessian.MatrixCounter];j++) { 299 output << j << "\t"; 300 for(int k=0;k<Hessian.ColumnCounter[Force.MatrixCounter];k++) 301 output << scientific << Hessian.Matrix[ Hessian.MatrixCounter ][j][k] << "\t"; 302 output << endl; 303 } 304 output.close(); 305 } 246 306 247 307 // +++++++++++++++++++++++++++++++++++++++ Plotting shieldings … … 254 314 for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) { 255 315 output << j << "\t"; 256 for(int k=0;k<ShieldingPAS.ColumnCounter ;k++)316 for(int k=0;k<ShieldingPAS.ColumnCounter[ShieldingPAS.MatrixCounter];k++) 257 317 output << scientific << ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t"; //*(((k>1) && (k<6))? 1.e6 : 1.) << "\t"; 258 318 output << endl; … … 297 357 for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) { 298 358 output << j << "\t"; 299 for(int k=0;k<Force.ColumnCounter ;k++)359 for(int k=0;k<Force.ColumnCounter[Force.MatrixCounter];k++) 300 360 output << scientific << Force.Matrix[ Force.MatrixCounter ][j][k] << "\t"; 301 361 output << endl; … … 346 406 yrange.str("[1e-8:1e+1]"); 347 407 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; 408 if (!NoTime) { 409 // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order 410 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; 411 } 350 412 351 413 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM
Note:
See TracChangeset
for help on using the changeset viewer.
