Changes in src/datacreator.cpp [042f82:f66195]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/datacreator.cpp
r042f82 rf66195 8 8 9 9 #include "datacreator.hpp" 10 #include "helpers.hpp" 11 #include "parser.hpp" 10 12 11 13 //=========================== FUNCTIONS============================ … … 49 51 /** Plots an energy vs. order. 50 52 * \param &Fragments EnergyMatrix class containing matrix values 51 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order53 * \param KeySets KeySetContainer class holding bond KeySetContainer::Order 52 54 * \param *prefix prefix in filename (without ending) 53 55 * \param *msg message to be place in first line as a comment 54 56 * \return true if file was written successfully 55 57 */ 56 bool CreateDataEnergyOrder(class EnergyMatrix &Fragments, class KeySetsContainer &KeySet , const char *dir, const char *prefix, const char *msg, const char *datum)58 bool CreateDataEnergyOrder(class EnergyMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum) 57 59 { 58 60 stringstream filename; … … 63 65 cout << msg << endl; 64 66 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++) 74 76 output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l]; 75 77 output << endl; … … 82 84 * \param &Energy EnergyMatrix class containing reference values (in MatrixCounter matrix) 83 85 * \param &Fragments EnergyMatrix class containing matrix values 84 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order86 * \param KeySets KeySetContainer class holding bond KeySetContainer::Order 85 87 * \param *prefix prefix in filename (without ending) 86 88 * \param *msg message to be place in first line as a comment 87 89 * \return true if file was written successfully 88 90 */ 89 bool CreateDataDeltaEnergyOrder(class EnergyMatrix &Energy, class EnergyMatrix &Fragments, class KeySetsContainer &KeySet , const char *dir, const char *prefix, const char *msg, const char *datum)91 bool CreateDataDeltaEnergyOrder(class EnergyMatrix &Energy, class EnergyMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum) 90 92 { 91 93 stringstream filename; … … 96 98 cout << msg << endl; 97 99 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; 99 101 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++) 108 110 if (fabs(Energy.Matrix[Energy.MatrixCounter][ Energy.RowCounter[Energy.MatrixCounter]-1 ][l]) < MYEPSILON) 109 111 output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l]; … … 118 120 /** Plot forces vs. order. 119 121 * \param &Fragments ForceMatrix class containing matrix values 120 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order122 * \param KeySets KeySetContainer class holding bond KeySetContainer::Order 121 123 * \param *prefix prefix in filename (without ending) 122 124 * \param *msg message to be place in first line as a comment … … 124 126 * \return true if file was written successfully 125 127 */ 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))128 bool CreateDataForcesOrder(class ForceMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix,const char *msg, const char *datum, void (*CreateForce)(class MatrixContainer &, int)) 127 129 { 128 130 stringstream filename; … … 133 135 cout << msg << endl; 134 136 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; 136 138 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]; 140 142 CreateForce(Fragments, Fragments.MatrixCounter); 141 for (int l=0;l<Fragments.ColumnCounter ;l++)143 for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++) 142 144 output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter] ][l]; 143 145 output << endl; … … 150 152 * \param &Force ForceMatrix containing reference values (in MatrixCounter matrix) 151 153 * \param &Fragments ForceMatrix class containing matrix values 152 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order154 * \param KeySets KeySetContainer class holding bond KeySetContainer::Order 153 155 * \param *prefix prefix in filename (without ending) 154 156 * \param *msg message to be place in first line as a comment … … 156 158 * \return true if file was written successfully 157 159 */ 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))160 bool 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)) 159 161 { 160 162 stringstream filename; … … 165 167 cout << msg << endl; 166 168 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; 168 170 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]; 172 174 CreateForce(Fragments, Fragments.MatrixCounter); 173 for (int l=0;l<Fragments.ColumnCounter ;l++)175 for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++) 174 176 output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter] ][l]; 175 177 output << endl; … … 182 184 * \param &Force ForceMatrix containing reference values (in MatrixCounter matrix) 183 185 * \param &Fragments ForceMatrix class containing matrix values 184 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order186 * \param KeySets KeySetContainer class holding bond KeySetContainer::Order 185 187 * \param *prefix prefix in filename (without ending) 186 188 * \param *msg message to be place in first line as a comment … … 188 190 * \return true if file was written successfully 189 191 */ 190 bool CreateDataDeltaForcesOrderPerAtom(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySet , const char *dir, const char *prefix, const char *msg, const char *datum)192 bool CreateDataDeltaForcesOrderPerAtom(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum) 191 193 { 192 194 stringstream filename; … … 198 200 cout << msg << endl; 199 201 output << "# " << msg << ", created on " << datum; 200 output << "# AtomNo\t" << Fragments.Header << endl;202 output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl; 201 203 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++) { 203 205 //cout << "Current order is " << BondOrder << "." << endl; 204 Fragments.SumSubForces(Fragments, KeySet , BondOrder, -1.);206 Fragments.SumSubForces(Fragments, KeySets, BondOrder, -1.); 205 207 // errors per atom 206 208 output << endl << "#Order\t" << BondOrder+1 << endl; 207 209 for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { 208 210 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++) { 210 212 if (((l+1) % 3) == 0) { 211 213 norm = 0.; … … 213 215 norm += Force.Matrix[Force.MatrixCounter][ j ][l+m]*Force.Matrix[Force.MatrixCounter][ j ][l+m]; 214 216 norm = sqrt(norm); 215 } 217 } 216 218 // if (norm < MYEPSILON) 217 219 output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t"; … … 229 231 /** Plot forces error vs. vs atom vs. order. 230 232 * \param &Fragments ForceMatrix class containing matrix values 231 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order233 * \param KeySets KeySetContainer class holding bond KeySetContainer::Order 232 234 * \param *prefix prefix in filename (without ending) 233 235 * \param *msg message to be place in first line as a comment … … 235 237 * \return true if file was written successfully 236 238 */ 237 bool CreateDataForcesOrderPerAtom(class ForceMatrix &Fragments, class KeySetsContainer &KeySet , const char *dir, const char *prefix, const char *msg, const char *datum)239 bool CreateDataForcesOrderPerAtom(class ForceMatrix &Fragments, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum) 238 240 { 239 241 stringstream filename; … … 244 246 cout << msg << endl; 245 247 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++) { 248 250 //cout << "Current order is " << BondOrder << "." << endl; 249 Fragments.SumSubForces(Fragments, KeySet , BondOrder, 1.);251 Fragments.SumSubForces(Fragments, KeySets, BondOrder, 1.); 250 252 // errors per atom 251 253 output << endl << "#Order\t" << BondOrder+1 << endl; 252 254 for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { 253 255 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++) 255 257 output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t"; 256 258 output << endl; … … 262 264 }; 263 265 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 */ 276 bool 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 */ 314 bool 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 */ 358 bool 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 264 386 /** Plot matrix vs. fragment. 265 387 */ 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))388 bool CreateDataFragment(class MatrixContainer &Fragment, class KeySetsContainer &KeySets, const char *dir, const char *prefix, const char *msg, const char *datum, void (*CreateFragment)(class MatrixContainer &, int)) 267 389 { 268 390 stringstream filename; … … 273 395 cout << msg << endl; 274 396 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]; 282 404 output << endl; 283 405 } … … 289 411 /** Copies fragment energy values into last matrix of \a Matrix with greatest total energy. 290 412 * \param &Matrix MatrixContainer with all fragment energy values 291 * \param &KeySet KeySetsContainer with associations of each fragment to a bond order413 * \param &KeySets KeySetsContainer with associations of each fragment to a bond order 292 414 * \param BondOrder current bond order 293 415 */ 294 void CreateMaxFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySet , int BondOrder)416 void CreateMaxFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySets, int BondOrder) 295 417 { 296 418 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]; 301 423 } 302 424 } … … 306 428 /** Copies fragment energy values into last matrix of \a Matrix with smallest total energy. 307 429 * \param &Matrix MatrixContainer with all fragment energy values 308 * \param &KeySet KeySetsContainer with associations of each fragment to a bond order430 * \param &KeySets KeySetsContainer with associations of each fragment to a bond order 309 431 * \param BondOrder current bond order 310 432 */ 311 void CreateMinFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySet , int BondOrder)433 void CreateMinFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySets, int BondOrder) 312 434 { 313 435 for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { 314 436 int i=0; 315 437 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]; 318 440 i++; 319 } while ((fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < MYEPSILON) && (i<KeySet .FragmentsPerOrder[BondOrder]));320 for(;i<KeySet .FragmentsPerOrder[BondOrder];i++) { // then find lowest321 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]; 324 446 } 325 447 } … … 329 451 /** Plot matrix vs. fragment. 330 452 */ 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))453 bool 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)) 332 454 { 333 455 stringstream filename; … … 338 460 cout << msg << endl; 339 461 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; 341 463 // max 342 for (int BondOrder=0;BondOrder<KeySet .Order;BondOrder++) {464 for (int BondOrder=0;BondOrder<KeySets.Order;BondOrder++) { 343 465 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++) 347 469 output << scientific << "\t" << Fragment.Matrix[ Fragment.MatrixCounter ][ Fragment.RowCounter[ Fragment.MatrixCounter ]-1 ][l]; 348 470 output << endl; … … 358 480 void CreateEnergy(class MatrixContainer &Energy, int MatrixNumber) 359 481 { 360 for(int k=0;k<Energy.ColumnCounter ;k++)482 for(int k=0;k<Energy.ColumnCounter[MatrixNumber];k++) 361 483 Energy.Matrix[MatrixNumber][ Energy.RowCounter[MatrixNumber] ] [k] = Energy.Matrix[MatrixNumber][ Energy.RowCounter[MatrixNumber]-1 ] [k]; 362 484 }; … … 369 491 void CreateMinimumForce(class MatrixContainer &Force, int MatrixNumber) 370 492 { 371 for (int l=Force.ColumnCounter ;l--;)493 for (int l=Force.ColumnCounter[MatrixNumber];l--;) 372 494 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) { 374 496 double stored = 0; 375 497 int k=0; … … 404 526 { 405 527 int divisor = 0; 406 for (int l=Force.ColumnCounter ;l--;)528 for (int l=Force.ColumnCounter[MatrixNumber];l--;) 407 529 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) { 409 531 double tmp = 0; 410 532 for (int k=Force.RowCounter[MatrixNumber];k--;) { … … 428 550 void CreateMaximumForce(class MatrixContainer &Force, int MatrixNumber) 429 551 { 430 for (int l=5;l<Force.ColumnCounter ;l+=3) {552 for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) { 431 553 double stored = 0; 432 554 for (int k=Force.RowCounter[MatrixNumber];k--;) { … … 460 582 void CreateVectorSumForce(class MatrixContainer &Force, int MatrixNumber) 461 583 { 462 for (int l=Force.ColumnCounter ;l--;)584 for (int l=Force.ColumnCounter[MatrixNumber];l--;) 463 585 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++) { 465 587 for (int k=Force.RowCounter[MatrixNumber];k--;) 466 588 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] += Force.Matrix[MatrixNumber][k][l]; … … 498 620 /** Creates the pyxplotfile for energy data. 499 621 * \param Matrix MatrixContainer with matrix values 500 * \param KeySet contains bond order622 * \param KeySets contains bond order 501 623 * \param *dir directory 502 624 * \param *prefix prefix for all filenames (without ending) … … 515 637 * \return true if file was written successfully 516 638 */ 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 *))639 bool 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 *)) 518 640 { 519 641 stringstream filename; … … 538 660 void AbsEnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses) 539 661 { 540 stringstream line(Energy.Header );662 stringstream line(Energy.Header[ Energy.MatrixCounter ]); 541 663 string token; 542 664 543 665 getline(line, token, '\t'); 544 for (int i=2; i<= Energy.ColumnCounter ;i++) {666 for (int i=2; i<= Energy.ColumnCounter[Energy.MatrixCounter];i++) { 545 667 getline(line, token, '\t'); 546 668 while (token[0] == ' ') // remove leading white spaces 547 669 token.erase(0,1); 548 670 output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(abs($" << i+2 << ")) " << uses; 549 if (i != (Energy.ColumnCounter ))671 if (i != (Energy.ColumnCounter[Energy.MatrixCounter])) 550 672 output << ", \\"; 551 673 output << endl; … … 562 684 void EnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses) 563 685 { 564 stringstream line(Energy.Header );686 stringstream line(Energy.Header[Energy.MatrixCounter]); 565 687 string token; 566 688 567 689 getline(line, token, '\t'); 568 for (int i=1; i<= Energy.ColumnCounter ;i++) {690 for (int i=1; i<= Energy.ColumnCounter[Energy.MatrixCounter];i++) { 569 691 getline(line, token, '\t'); 570 692 while (token[0] == ' ') // remove leading white spaces 571 693 token.erase(0,1); 572 694 output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":" << i+2 << " " << uses; 573 if (i != (Energy.ColumnCounter ))695 if (i != (Energy.ColumnCounter[Energy.MatrixCounter])) 574 696 output << ", \\"; 575 697 output << endl; … … 586 708 void ForceMagnitudePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses) 587 709 { 588 stringstream line(Force.Header );710 stringstream line(Force.Header[Force.MatrixCounter]); 589 711 string token; 590 712 … … 594 716 getline(line, token, '\t'); 595 717 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) { 597 719 getline(line, token, '\t'); 598 720 while (token[0] == ' ') // remove leading white spaces … … 600 722 token.erase(token.length(), 1); // kill residual index char (the '0') 601 723 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)) 603 725 output << ", \\"; 604 726 output << endl; … … 617 739 void AbsFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses) 618 740 { 619 stringstream line(Force.Header );741 stringstream line(Force.Header[Force.MatrixCounter]); 620 742 string token; 621 743 … … 625 747 getline(line, token, '\t'); 626 748 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) { 628 750 getline(line, token, '\t'); 629 751 while (token[0] == ' ') // remove leading white spaces … … 631 753 token.erase(token.length(), 1); // kill residual index char (the '0') 632 754 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)) 634 756 output << ", \\"; 635 757 output << endl; … … 648 770 void BoxesForcePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses) 649 771 { 650 stringstream line(Force.Header );651 c onst char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};772 stringstream line(Force.Header[Force.MatrixCounter]); 773 char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"}; 652 774 string token; 653 775 … … 657 779 getline(line, token, '\t'); 658 780 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) { 660 782 getline(line, token, '\t'); 661 783 while (token[0] == ' ') // remove leading white spaces … … 663 785 token.erase(token.length(), 1); // kill residual index char (the '0') 664 786 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)) 666 788 output << ", \\"; 667 789 output << endl; … … 680 802 void BoxesFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses) 681 803 { 682 stringstream line(Force.Header );683 c onst char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};804 stringstream line(Force.Header[Force.MatrixCounter]); 805 char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"}; 684 806 string token; 685 807 … … 689 811 getline(line, token, '\t'); 690 812 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) { 692 814 getline(line, token, '\t'); 693 815 while (token[0] == ' ') // remove leading white spaces … … 695 817 token.erase(token.length(), 1); // kill residual index char (the '0') 696 818 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)) 698 820 output << ", \\"; 699 821 output << endl;
Note:
See TracChangeset
for help on using the changeset viewer.