| 1 | /** \file datacreator.cpp | 
|---|
| 2 | * | 
|---|
| 3 | * Declarations of assisting functions in creating data and plot files. | 
|---|
| 4 | * | 
|---|
| 5 | */ | 
|---|
| 6 |  | 
|---|
| 7 | //============================ INCLUDES =========================== | 
|---|
| 8 |  | 
|---|
| 9 | #include "datacreator.hpp" | 
|---|
| 10 |  | 
|---|
| 11 | //=========================== FUNCTIONS============================ | 
|---|
| 12 |  | 
|---|
| 13 | /** Opens a file with \a *filename in \a *dir. | 
|---|
| 14 | * \param output file handle on return | 
|---|
| 15 | * \param *dir directory | 
|---|
| 16 | * \param *filename name of file | 
|---|
| 17 | * \return true if file has been opened | 
|---|
| 18 | */ | 
|---|
| 19 | bool OpenOutputFile(ofstream &output, const char *dir, const char *filename) | 
|---|
| 20 | { | 
|---|
| 21 | stringstream name; | 
|---|
| 22 | name << dir << "/" << filename; | 
|---|
| 23 | output.open(name.str().c_str(), ios::out); | 
|---|
| 24 | if (output == NULL) { | 
|---|
| 25 | cout << "Unable to open " << name.str() << " for writing, is directory correct?" << endl; | 
|---|
| 26 | return false; | 
|---|
| 27 | } | 
|---|
| 28 | return true; | 
|---|
| 29 | }; | 
|---|
| 30 |  | 
|---|
| 31 | /** Opens a file for appending with \a *filename in \a *dir. | 
|---|
| 32 | * \param output file handle on return | 
|---|
| 33 | * \param *dir directory | 
|---|
| 34 | * \param *filename name of file | 
|---|
| 35 | * \return true if file has been opened | 
|---|
| 36 | */ | 
|---|
| 37 | bool AppendOutputFile(ofstream &output, const char *dir, const char *filename) | 
|---|
| 38 | { | 
|---|
| 39 | stringstream name; | 
|---|
| 40 | name << dir << "/" << filename; | 
|---|
| 41 | output.open(name.str().c_str(), ios::app); | 
|---|
| 42 | if (output == NULL) { | 
|---|
| 43 | cout << "Unable to open " << name.str() << " for writing, is directory correct?" << endl; | 
|---|
| 44 | return false; | 
|---|
| 45 | } | 
|---|
| 46 | return true; | 
|---|
| 47 | }; | 
|---|
| 48 |  | 
|---|
| 49 | /** Plots an energy vs. order. | 
|---|
| 50 | * \param &Fragments EnergyMatrix class containing matrix values | 
|---|
| 51 | * \param KeySet KeySetContainer class holding bond KeySetContainer::Order | 
|---|
| 52 | * \param *prefix prefix in filename (without ending) | 
|---|
| 53 | * \param *msg message to be place in first line as a comment | 
|---|
| 54 | * \return true if file was written successfully | 
|---|
| 55 | */ | 
|---|
| 56 | bool CreateDataEnergyOrder(class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) | 
|---|
| 57 | { | 
|---|
| 58 | stringstream filename; | 
|---|
| 59 | ofstream output; | 
|---|
| 60 |  | 
|---|
| 61 | filename << prefix << ".dat"; | 
|---|
| 62 | if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; | 
|---|
| 63 | cout << msg << endl; | 
|---|
| 64 | output << "# " << msg << ", created on " << datum; | 
|---|
| 65 | output << "#Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << 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[ KeySet.OrderSet[BondOrder][i] ];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[Fragments.MatrixCounter];l++) | 
|---|
| 74 | output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l]; | 
|---|
| 75 | output << endl; | 
|---|
| 76 | } | 
|---|
| 77 | output.close(); | 
|---|
| 78 | return true; | 
|---|
| 79 | }; | 
|---|
| 80 |  | 
|---|
| 81 | /** Plots an energy error vs. order. | 
|---|
| 82 | * \param &Energy EnergyMatrix class containing reference values (in MatrixCounter matrix) | 
|---|
| 83 | * \param &Fragments EnergyMatrix class containing matrix values | 
|---|
| 84 | * \param KeySet KeySetContainer class holding bond KeySetContainer::Order | 
|---|
| 85 | * \param *prefix prefix in filename (without ending) | 
|---|
| 86 | * \param *msg message to be place in first line as a comment | 
|---|
| 87 | * \return true if file was written successfully | 
|---|
| 88 | */ | 
|---|
| 89 | bool CreateDataDeltaEnergyOrder(class EnergyMatrix &Energy, class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) | 
|---|
| 90 | { | 
|---|
| 91 | stringstream filename; | 
|---|
| 92 | ofstream output; | 
|---|
| 93 |  | 
|---|
| 94 | filename << prefix << ".dat"; | 
|---|
| 95 | if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; | 
|---|
| 96 | cout << msg << endl; | 
|---|
| 97 | output << "# " << msg << ", created on " << datum; | 
|---|
| 98 | output << "#Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl; | 
|---|
| 99 | 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[ KeySet.OrderSet[BondOrder][i] ];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[Energy.MatrixCounter];l++) | 
|---|
| 108 | if (fabs(Energy.Matrix[Energy.MatrixCounter][ Energy.RowCounter[Energy.MatrixCounter]-1 ][l]) < MYEPSILON) | 
|---|
| 109 | output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l]; | 
|---|
| 110 | else | 
|---|
| 111 | output << scientific << "\t" << (Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l] / Energy.Matrix[Energy.MatrixCounter][ Energy.RowCounter[Energy.MatrixCounter]-1 ][l]); | 
|---|
| 112 | output << endl; | 
|---|
| 113 | } | 
|---|
| 114 | output.close(); | 
|---|
| 115 | return true; | 
|---|
| 116 | }; | 
|---|
| 117 |  | 
|---|
| 118 | /** Plot forces vs. order. | 
|---|
| 119 | * \param &Fragments ForceMatrix class containing matrix values | 
|---|
| 120 | * \param KeySet KeySetContainer class holding bond KeySetContainer::Order | 
|---|
| 121 | * \param *prefix prefix in filename (without ending) | 
|---|
| 122 | * \param *msg message to be place in first line as a comment | 
|---|
| 123 | * \param *datum current date and time | 
|---|
| 124 | * \return true if file was written successfully | 
|---|
| 125 | */ | 
|---|
| 126 | bool CreateDataForcesOrder(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateForce)(class MatrixContainer &, int)) | 
|---|
| 127 | { | 
|---|
| 128 | stringstream filename; | 
|---|
| 129 | ofstream output; | 
|---|
| 130 |  | 
|---|
| 131 | filename << prefix << ".dat"; | 
|---|
| 132 | if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; | 
|---|
| 133 | cout << msg << endl; | 
|---|
| 134 | output << "# " << msg << ", created on " << datum; | 
|---|
| 135 | output << "# Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl; | 
|---|
| 136 | 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]; | 
|---|
| 140 | CreateForce(Fragments, Fragments.MatrixCounter); | 
|---|
| 141 | for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++) | 
|---|
| 142 | output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter] ][l]; | 
|---|
| 143 | output << endl; | 
|---|
| 144 | } | 
|---|
| 145 | output.close(); | 
|---|
| 146 | return true; | 
|---|
| 147 | }; | 
|---|
| 148 |  | 
|---|
| 149 | /** Plot forces error vs. order. | 
|---|
| 150 | * \param &Force ForceMatrix containing reference values (in MatrixCounter matrix) | 
|---|
| 151 | * \param &Fragments ForceMatrix class containing matrix values | 
|---|
| 152 | * \param KeySet KeySetContainer class holding bond KeySetContainer::Order | 
|---|
| 153 | * \param *prefix prefix in filename (without ending) | 
|---|
| 154 | * \param *msg message to be place in first line as a comment | 
|---|
| 155 | * \param *datum current date and time | 
|---|
| 156 | * \return true if file was written successfully | 
|---|
| 157 | */ | 
|---|
| 158 | bool CreateDataDeltaForcesOrder(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateForce)(class MatrixContainer &, int)) | 
|---|
| 159 | { | 
|---|
| 160 | stringstream filename; | 
|---|
| 161 | ofstream output; | 
|---|
| 162 |  | 
|---|
| 163 | filename << prefix << ".dat"; | 
|---|
| 164 | if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; | 
|---|
| 165 | cout << msg << endl; | 
|---|
| 166 | output << "# " << msg << ", created on " << datum; | 
|---|
| 167 | output << "# Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl; | 
|---|
| 168 | 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]; | 
|---|
| 172 | CreateForce(Fragments, Fragments.MatrixCounter); | 
|---|
| 173 | for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++) | 
|---|
| 174 | output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter] ][l]; | 
|---|
| 175 | output << endl; | 
|---|
| 176 | } | 
|---|
| 177 | output.close(); | 
|---|
| 178 | return true; | 
|---|
| 179 | }; | 
|---|
| 180 |  | 
|---|
| 181 | /** Plot forces error vs. vs atom vs. order. | 
|---|
| 182 | * \param &Force ForceMatrix containing reference values (in MatrixCounter matrix) | 
|---|
| 183 | * \param &Fragments ForceMatrix class containing matrix values | 
|---|
| 184 | * \param KeySet KeySetContainer class holding bond KeySetContainer::Order | 
|---|
| 185 | * \param *prefix prefix in filename (without ending) | 
|---|
| 186 | * \param *msg message to be place in first line as a comment | 
|---|
| 187 | * \param *datum current date and time | 
|---|
| 188 | * \return true if file was written successfully | 
|---|
| 189 | */ | 
|---|
| 190 | bool CreateDataDeltaForcesOrderPerAtom(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) | 
|---|
| 191 | { | 
|---|
| 192 | stringstream filename; | 
|---|
| 193 | ofstream output; | 
|---|
| 194 | double norm = 0.; | 
|---|
| 195 |  | 
|---|
| 196 | filename << prefix << ".dat"; | 
|---|
| 197 | if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; | 
|---|
| 198 | cout << msg << endl; | 
|---|
| 199 | output << "# " << msg << ", created on " << datum; | 
|---|
| 200 | output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl; | 
|---|
| 201 | Fragments.SetLastMatrix(Force.Matrix[Force.MatrixCounter], 0); | 
|---|
| 202 | for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { | 
|---|
| 203 | //cout << "Current order is " << BondOrder << "." << endl; | 
|---|
| 204 | Fragments.SumSubForces(Fragments, KeySet, BondOrder, -1.); | 
|---|
| 205 | // errors per atom | 
|---|
| 206 | output << endl << "#Order\t" << BondOrder+1 << endl; | 
|---|
| 207 | for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { | 
|---|
| 208 | output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t"; | 
|---|
| 209 | for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) { | 
|---|
| 210 | if (((l+1) % 3) == 0) { | 
|---|
| 211 | norm = 0.; | 
|---|
| 212 | for (int m=0;m<NDIM;m++) | 
|---|
| 213 | norm += Force.Matrix[Force.MatrixCounter][ j ][l+m]*Force.Matrix[Force.MatrixCounter][ j ][l+m]; | 
|---|
| 214 | norm = sqrt(norm); | 
|---|
| 215 | } | 
|---|
| 216 | //        if (norm < MYEPSILON) | 
|---|
| 217 | output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t"; | 
|---|
| 218 | //        else | 
|---|
| 219 | //          output << scientific << (Fragments.Matrix[Fragments.MatrixCounter][ j ][l] / norm) << "\t"; | 
|---|
| 220 | } | 
|---|
| 221 | output << endl; | 
|---|
| 222 | } | 
|---|
| 223 | output << endl; | 
|---|
| 224 | } | 
|---|
| 225 | output.close(); | 
|---|
| 226 | return true; | 
|---|
| 227 | }; | 
|---|
| 228 |  | 
|---|
| 229 | /** Plot forces error vs. vs atom vs. order. | 
|---|
| 230 | * \param &Fragments ForceMatrix class containing matrix values | 
|---|
| 231 | * \param KeySet KeySetContainer class holding bond KeySetContainer::Order | 
|---|
| 232 | * \param *prefix prefix in filename (without ending) | 
|---|
| 233 | * \param *msg message to be place in first line as a comment | 
|---|
| 234 | * \param *datum current date and time | 
|---|
| 235 | * \return true if file was written successfully | 
|---|
| 236 | */ | 
|---|
| 237 | bool CreateDataForcesOrderPerAtom(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) | 
|---|
| 238 | { | 
|---|
| 239 | stringstream filename; | 
|---|
| 240 | ofstream output; | 
|---|
| 241 |  | 
|---|
| 242 | filename << prefix << ".dat"; | 
|---|
| 243 | if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; | 
|---|
| 244 | cout << msg << endl; | 
|---|
| 245 | output << "# " << msg << ", created on " << datum; | 
|---|
| 246 | output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl; | 
|---|
| 247 | for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { | 
|---|
| 248 | //cout << "Current order is " << BondOrder << "." << endl; | 
|---|
| 249 | Fragments.SumSubForces(Fragments, KeySet, BondOrder, 1.); | 
|---|
| 250 | // errors per atom | 
|---|
| 251 | output << endl << "#Order\t" << BondOrder+1 << endl; | 
|---|
| 252 | for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { | 
|---|
| 253 | output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t"; | 
|---|
| 254 | for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) | 
|---|
| 255 | output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t"; | 
|---|
| 256 | output << endl; | 
|---|
| 257 | } | 
|---|
| 258 | output << endl; | 
|---|
| 259 | } | 
|---|
| 260 | output.close(); | 
|---|
| 261 | return true; | 
|---|
| 262 | }; | 
|---|
| 263 |  | 
|---|
| 264 |  | 
|---|
| 265 | /** Plot hessian error vs. vs atom vs. order. | 
|---|
| 266 | * \param &Hessian HessianMatrix containing reference values (in MatrixCounter matrix) | 
|---|
| 267 | * \param &Fragments HessianMatrix class containing matrix values | 
|---|
| 268 | * \param KeySet KeySetContainer class holding bond KeySetContainer::Order | 
|---|
| 269 | * \param *prefix prefix in filename (without ending) | 
|---|
| 270 | * \param *msg message to be place in first line as a comment | 
|---|
| 271 | * \param *datum current date and time | 
|---|
| 272 | * \return true if file was written successfully | 
|---|
| 273 | */ | 
|---|
| 274 | bool CreateDataDeltaHessianOrderPerAtom(class HessianMatrix &Hessian, class HessianMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) | 
|---|
| 275 | { | 
|---|
| 276 | stringstream filename; | 
|---|
| 277 | ofstream output; | 
|---|
| 278 | double norm = 0.; | 
|---|
| 279 |  | 
|---|
| 280 | filename << prefix << ".dat"; | 
|---|
| 281 | if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; | 
|---|
| 282 | cout << msg << endl; | 
|---|
| 283 | output << "# " << msg << ", created on " << datum; | 
|---|
| 284 | output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl; | 
|---|
| 285 | Fragments.SetLastMatrix(Hessian.Matrix[Hessian.MatrixCounter], 0); | 
|---|
| 286 | for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { | 
|---|
| 287 | //cout << "Current order is " << BondOrder << "." << endl; | 
|---|
| 288 | Fragments.SumSubHessians(Fragments, KeySet, BondOrder, -1.); | 
|---|
| 289 | // errors per atom | 
|---|
| 290 | output << endl << "#Order\t" << BondOrder+1 << endl; | 
|---|
| 291 | for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { | 
|---|
| 292 | output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t"; | 
|---|
| 293 | for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) { | 
|---|
| 294 | output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t"; | 
|---|
| 295 | } | 
|---|
| 296 | output << endl; | 
|---|
| 297 | } | 
|---|
| 298 | output << endl; | 
|---|
| 299 | } | 
|---|
| 300 | output.close(); | 
|---|
| 301 | return true; | 
|---|
| 302 | }; | 
|---|
| 303 |  | 
|---|
| 304 | /** Plot hessian error vs. vs atom vs. order in the frobenius norm. | 
|---|
| 305 | * \param &Hessian HessianMatrix containing reference values (in MatrixCounter matrix) | 
|---|
| 306 | * \param &Fragments HessianMatrix class containing matrix values | 
|---|
| 307 | * \param KeySet KeySetContainer class holding bond KeySetContainer::Order | 
|---|
| 308 | * \param *prefix prefix in filename (without ending) | 
|---|
| 309 | * \param *msg message to be place in first line as a comment | 
|---|
| 310 | * \param *datum current date and time | 
|---|
| 311 | * \return true if file was written successfully | 
|---|
| 312 | */ | 
|---|
| 313 | bool CreateDataDeltaFrobeniusOrderPerAtom(class HessianMatrix &Hessian, class HessianMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) | 
|---|
| 314 | { | 
|---|
| 315 | stringstream filename; | 
|---|
| 316 | ofstream output; | 
|---|
| 317 | double norm = 0; | 
|---|
| 318 | double tmp; | 
|---|
| 319 |  | 
|---|
| 320 | filename << prefix << ".dat"; | 
|---|
| 321 | if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; | 
|---|
| 322 | cout << msg << endl; | 
|---|
| 323 | output << "# " << msg << ", created on " << datum; | 
|---|
| 324 | output << "# AtomNo\t"; | 
|---|
| 325 | Fragments.SetLastMatrix(Hessian.Matrix[Hessian.MatrixCounter], 0); | 
|---|
| 326 | for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { | 
|---|
| 327 | output << "Order" << BondOrder+1 << "\t"; | 
|---|
| 328 | } | 
|---|
| 329 | output << endl; | 
|---|
| 330 | output << Fragments.RowCounter[ Fragments.MatrixCounter ] << "\t"; | 
|---|
| 331 | for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { | 
|---|
| 332 | //cout << "Current order is " << BondOrder << "." << endl; | 
|---|
| 333 | Fragments.SumSubHessians(Fragments, KeySet, BondOrder, -1.); | 
|---|
| 334 | // frobenius norm of errors per atom | 
|---|
| 335 | norm = 0.; | 
|---|
| 336 | for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { | 
|---|
| 337 | for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) { | 
|---|
| 338 | tmp = Fragments.Matrix[Fragments.MatrixCounter][ j ][l]; | 
|---|
| 339 | norm += tmp*tmp; | 
|---|
| 340 | } | 
|---|
| 341 | } | 
|---|
| 342 | output << scientific << sqrt(norm)/(Fragments.RowCounter[ Fragments.MatrixCounter ]*Fragments.ColumnCounter[ Fragments.MatrixCounter] ) << "\t"; | 
|---|
| 343 | } | 
|---|
| 344 | output << endl; | 
|---|
| 345 | output.close(); | 
|---|
| 346 | return true; | 
|---|
| 347 | }; | 
|---|
| 348 |  | 
|---|
| 349 | /** Plot hessian error vs. vs atom vs. order. | 
|---|
| 350 | * \param &Fragments HessianMatrix class containing matrix values | 
|---|
| 351 | * \param KeySet KeySetContainer class holding bond KeySetContainer::Order | 
|---|
| 352 | * \param *prefix prefix in filename (without ending) | 
|---|
| 353 | * \param *msg message to be place in first line as a comment | 
|---|
| 354 | * \param *datum current date and time | 
|---|
| 355 | * \return true if file was written successfully | 
|---|
| 356 | */ | 
|---|
| 357 | bool CreateDataHessianOrderPerAtom(class HessianMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) | 
|---|
| 358 | { | 
|---|
| 359 | stringstream filename; | 
|---|
| 360 | ofstream output; | 
|---|
| 361 |  | 
|---|
| 362 | filename << prefix << ".dat"; | 
|---|
| 363 | if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; | 
|---|
| 364 | cout << msg << endl; | 
|---|
| 365 | output << "# " << msg << ", created on " << datum; | 
|---|
| 366 | output << "# AtomNo\t" << Fragments.Header[ Fragments.MatrixCounter ] << endl; | 
|---|
| 367 | Fragments.SetLastMatrix(0., 0); | 
|---|
| 368 | for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { | 
|---|
| 369 | //cout << "Current order is " << BondOrder << "." << endl; | 
|---|
| 370 | Fragments.SumSubHessians(Fragments, KeySet, BondOrder, 1.); | 
|---|
| 371 | // errors per atom | 
|---|
| 372 | output << endl << "#Order\t" << BondOrder+1 << endl; | 
|---|
| 373 | for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { | 
|---|
| 374 | output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t"; | 
|---|
| 375 | for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) | 
|---|
| 376 | output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t"; | 
|---|
| 377 | output << endl; | 
|---|
| 378 | } | 
|---|
| 379 | output << endl; | 
|---|
| 380 | } | 
|---|
| 381 | output.close(); | 
|---|
| 382 | return true; | 
|---|
| 383 | }; | 
|---|
| 384 |  | 
|---|
| 385 | /** Plot matrix vs. fragment. | 
|---|
| 386 | */ | 
|---|
| 387 | bool CreateDataFragment(class MatrixContainer &Fragment, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateFragment)(class MatrixContainer &, int)) | 
|---|
| 388 | { | 
|---|
| 389 | stringstream filename; | 
|---|
| 390 | ofstream output; | 
|---|
| 391 |  | 
|---|
| 392 | filename << prefix << ".dat"; | 
|---|
| 393 | if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; | 
|---|
| 394 | cout << msg << endl; | 
|---|
| 395 | output << "# " << msg << ", created on " << datum << endl; | 
|---|
| 396 | output << "#Order\tFrag.No.\t" << Fragment.Header[ Fragment.MatrixCounter ] << endl; | 
|---|
| 397 | for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { | 
|---|
| 398 | for(int i=0;i<KeySet.FragmentsPerOrder[BondOrder];i++) { | 
|---|
| 399 | output << BondOrder+1 << "\t" << KeySet.OrderSet[BondOrder][i]+1; | 
|---|
| 400 | CreateFragment(Fragment, KeySet.OrderSet[BondOrder][i]); | 
|---|
| 401 | for (int l=0;l<Fragment.ColumnCounter[ KeySet.OrderSet[BondOrder][i] ];l++) | 
|---|
| 402 | output << scientific << "\t" << Fragment.Matrix[ KeySet.OrderSet[BondOrder][i] ][ Fragment.RowCounter[ KeySet.OrderSet[BondOrder][i] ] ][l]; | 
|---|
| 403 | output << endl; | 
|---|
| 404 | } | 
|---|
| 405 | } | 
|---|
| 406 | output.close(); | 
|---|
| 407 | return true; | 
|---|
| 408 | }; | 
|---|
| 409 |  | 
|---|
| 410 | /** Copies fragment energy values into last matrix of \a Matrix with greatest total energy. | 
|---|
| 411 | * \param &Matrix MatrixContainer with all fragment energy values | 
|---|
| 412 | * \param &KeySet KeySetsContainer with associations of each fragment to a bond order | 
|---|
| 413 | * \param BondOrder current bond order | 
|---|
| 414 | */ | 
|---|
| 415 | void CreateMaxFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySet, int BondOrder) | 
|---|
| 416 | { | 
|---|
| 417 | for(int j=Fragments.RowCounter[ Fragments.MatrixCounter ];j--;) { | 
|---|
| 418 | for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) { | 
|---|
| 419 | if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < fabs(Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][1])) { | 
|---|
| 420 | for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;) | 
|---|
| 421 | Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; | 
|---|
| 422 | } | 
|---|
| 423 | } | 
|---|
| 424 | } | 
|---|
| 425 | }; | 
|---|
| 426 |  | 
|---|
| 427 | /** Copies fragment energy values into last matrix of \a Matrix with smallest total energy. | 
|---|
| 428 | * \param &Matrix MatrixContainer with all fragment energy values | 
|---|
| 429 | * \param &KeySet KeySetsContainer with associations of each fragment to a bond order | 
|---|
| 430 | * \param BondOrder current bond order | 
|---|
| 431 | */ | 
|---|
| 432 | void CreateMinFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySet, int BondOrder) | 
|---|
| 433 | { | 
|---|
| 434 | for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { | 
|---|
| 435 | int i=0; | 
|---|
| 436 | do {  // first get a minimum value unequal to 0 | 
|---|
| 437 | for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;) | 
|---|
| 438 | Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; | 
|---|
| 439 | i++; | 
|---|
| 440 | } while ((fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < MYEPSILON) && (i<KeySet.FragmentsPerOrder[BondOrder])); | 
|---|
| 441 | for(;i<KeySet.FragmentsPerOrder[BondOrder];i++) { // then find lowest | 
|---|
| 442 | if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) > fabs(Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][1])) { | 
|---|
| 443 | for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;) | 
|---|
| 444 | Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; | 
|---|
| 445 | } | 
|---|
| 446 | } | 
|---|
| 447 | } | 
|---|
| 448 | }; | 
|---|
| 449 |  | 
|---|
| 450 | /** Plot matrix vs. fragment. | 
|---|
| 451 | */ | 
|---|
| 452 | bool CreateDataFragmentOrder(class MatrixContainer &Fragment, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateFragmentOrder)(class MatrixContainer &, class KeySetsContainer &, int)) | 
|---|
| 453 | { | 
|---|
| 454 | stringstream filename; | 
|---|
| 455 | ofstream output; | 
|---|
| 456 |  | 
|---|
| 457 | filename << prefix << ".dat"; | 
|---|
| 458 | if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; | 
|---|
| 459 | cout << msg << endl; | 
|---|
| 460 | output << "# " << msg << ", created on " << datum; | 
|---|
| 461 | output << "#Order\tFrag.No.\t" << Fragment.Header[ Fragment.MatrixCounter ] << endl; | 
|---|
| 462 | // max | 
|---|
| 463 | for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { | 
|---|
| 464 | Fragment.SetLastMatrix(0.,0); | 
|---|
| 465 | CreateFragmentOrder(Fragment, KeySet, BondOrder); | 
|---|
| 466 | output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder]; | 
|---|
| 467 | for (int l=0;l<Fragment.ColumnCounter[ Fragment.MatrixCounter ];l++) | 
|---|
| 468 | output << scientific << "\t" << Fragment.Matrix[ Fragment.MatrixCounter ][ Fragment.RowCounter[ Fragment.MatrixCounter ]-1 ][l]; | 
|---|
| 469 | output << endl; | 
|---|
| 470 | } | 
|---|
| 471 | output.close(); | 
|---|
| 472 | return true; | 
|---|
| 473 | }; | 
|---|
| 474 |  | 
|---|
| 475 | /** Takes last but one row and copies into final row. | 
|---|
| 476 | * \param Energy MatrixContainer with matrix values | 
|---|
| 477 | * \param MatrixNumber the index for the ForceMatrix::matrix array | 
|---|
| 478 | */ | 
|---|
| 479 | void CreateEnergy(class MatrixContainer &Energy, int MatrixNumber) | 
|---|
| 480 | { | 
|---|
| 481 | for(int k=0;k<Energy.ColumnCounter[MatrixNumber];k++) | 
|---|
| 482 | Energy.Matrix[MatrixNumber][ Energy.RowCounter[MatrixNumber] ] [k] =  Energy.Matrix[MatrixNumber][ Energy.RowCounter[MatrixNumber]-1 ] [k]; | 
|---|
| 483 | }; | 
|---|
| 484 |  | 
|---|
| 485 | /** Scans forces for the minimum in magnitude. | 
|---|
| 486 | * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force. | 
|---|
| 487 | * \param Force ForceMatrix class containing matrix values | 
|---|
| 488 | * \param MatrixNumber the index for the ForceMatrix::matrix array | 
|---|
| 489 | */ | 
|---|
| 490 | void CreateMinimumForce(class MatrixContainer &Force, int MatrixNumber) | 
|---|
| 491 | { | 
|---|
| 492 | for (int l=Force.ColumnCounter[MatrixNumber];l--;) | 
|---|
| 493 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.; | 
|---|
| 494 | for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) { | 
|---|
| 495 | double stored = 0; | 
|---|
| 496 | int k=0; | 
|---|
| 497 | do { | 
|---|
| 498 | for (int m=NDIM;m--;) { | 
|---|
| 499 | stored += Force.Matrix[MatrixNumber][ k ][l+m] | 
|---|
| 500 | * Force.Matrix[MatrixNumber][ k ][l+m]; | 
|---|
| 501 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m]  = Force.Matrix[MatrixNumber][ k ][l+m]; | 
|---|
| 502 | } | 
|---|
| 503 | k++; | 
|---|
| 504 | } while ((fabs(stored) < MYEPSILON) && (k<Force.RowCounter[MatrixNumber])); | 
|---|
| 505 | for (;k<Force.RowCounter[MatrixNumber];k++) { | 
|---|
| 506 | double tmp = 0; | 
|---|
| 507 | for (int m=NDIM;m--;) | 
|---|
| 508 | tmp += Force.Matrix[MatrixNumber][ k ][l+m] | 
|---|
| 509 | * Force.Matrix[MatrixNumber][ k ][l+m]; | 
|---|
| 510 | if ((fabs(tmp) > MYEPSILON) && (tmp < stored)) {  // current force is greater than stored | 
|---|
| 511 | for (int m=NDIM;m--;) | 
|---|
| 512 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m]  = Force.Matrix[MatrixNumber][ k ][l+m]; | 
|---|
| 513 | stored = tmp; | 
|---|
| 514 | } | 
|---|
| 515 | } | 
|---|
| 516 | } | 
|---|
| 517 | }; | 
|---|
| 518 |  | 
|---|
| 519 | /** Scans forces for the mean in magnitude. | 
|---|
| 520 | * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force. | 
|---|
| 521 | * \param Force ForceMatrix class containing matrix values | 
|---|
| 522 | * \param MatrixNumber the index for the ForceMatrix::matrix array | 
|---|
| 523 | */ | 
|---|
| 524 | void CreateMeanForce(class MatrixContainer &Force, int MatrixNumber) | 
|---|
| 525 | { | 
|---|
| 526 | int divisor = 0; | 
|---|
| 527 | for (int l=Force.ColumnCounter[MatrixNumber];l--;) | 
|---|
| 528 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.; | 
|---|
| 529 | for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) { | 
|---|
| 530 | double tmp = 0; | 
|---|
| 531 | for (int k=Force.RowCounter[MatrixNumber];k--;) { | 
|---|
| 532 | double norm = 0.; | 
|---|
| 533 | for (int m=NDIM;m--;) | 
|---|
| 534 | norm += Force.Matrix[MatrixNumber][ k ][l+m] | 
|---|
| 535 | * Force.Matrix[MatrixNumber][ k ][l+m]; | 
|---|
| 536 | tmp += sqrt(norm); | 
|---|
| 537 | if (fabs(norm) > MYEPSILON) divisor++; | 
|---|
| 538 | } | 
|---|
| 539 | tmp /= (double)divisor; | 
|---|
| 540 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = tmp; | 
|---|
| 541 | } | 
|---|
| 542 | }; | 
|---|
| 543 |  | 
|---|
| 544 | /** Scans forces for the maximum in magnitude. | 
|---|
| 545 | * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force. | 
|---|
| 546 | * \param Force ForceMatrix class containing matrix values | 
|---|
| 547 | * \param MatrixNumber the index for the ForceMatrix::matrix array | 
|---|
| 548 | */ | 
|---|
| 549 | void CreateMaximumForce(class MatrixContainer &Force, int MatrixNumber) | 
|---|
| 550 | { | 
|---|
| 551 | for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) { | 
|---|
| 552 | double stored = 0; | 
|---|
| 553 | for (int k=Force.RowCounter[MatrixNumber];k--;) { | 
|---|
| 554 | double tmp = 0; | 
|---|
| 555 | for (int m=NDIM;m--;) | 
|---|
| 556 | tmp += Force.Matrix[MatrixNumber][ k ][l+m] | 
|---|
| 557 | * Force.Matrix[MatrixNumber][ k ][l+m]; | 
|---|
| 558 | if (tmp > stored) {  // current force is greater than stored | 
|---|
| 559 | for (int m=NDIM;m--;) | 
|---|
| 560 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m]  = Force.Matrix[MatrixNumber][ k ][l+m]; | 
|---|
| 561 | stored = tmp; | 
|---|
| 562 | } | 
|---|
| 563 | } | 
|---|
| 564 | } | 
|---|
| 565 | }; | 
|---|
| 566 |  | 
|---|
| 567 | /** Leaves the Force.Matrix as it is. | 
|---|
| 568 | * \param Force ForceMatrix class containing matrix values | 
|---|
| 569 | * \param MatrixNumber the index for the ForceMatrix::matrix array | 
|---|
| 570 | */ | 
|---|
| 571 | void CreateSameForce(class MatrixContainer &Force, int MatrixNumber) | 
|---|
| 572 | { | 
|---|
| 573 | // does nothing | 
|---|
| 574 | }; | 
|---|
| 575 |  | 
|---|
| 576 | /** Adds vectorwise all forces. | 
|---|
| 577 | * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force. | 
|---|
| 578 | * \param Force ForceMatrix class containing matrix values | 
|---|
| 579 | * \param MatrixNumber the index for the ForceMatrix::matrix array | 
|---|
| 580 | */ | 
|---|
| 581 | void CreateVectorSumForce(class MatrixContainer &Force, int MatrixNumber) | 
|---|
| 582 | { | 
|---|
| 583 | for (int l=Force.ColumnCounter[MatrixNumber];l--;) | 
|---|
| 584 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.; | 
|---|
| 585 | for (int l=0;l<Force.ColumnCounter[MatrixNumber];l++) { | 
|---|
| 586 | for (int k=Force.RowCounter[MatrixNumber];k--;) | 
|---|
| 587 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] += Force.Matrix[MatrixNumber][k][l]; | 
|---|
| 588 | } | 
|---|
| 589 | }; | 
|---|
| 590 |  | 
|---|
| 591 | /** Writes the standard pyxplot header info. | 
|---|
| 592 | * \param keycolumns number of columns of the key | 
|---|
| 593 | * \param *key position of key | 
|---|
| 594 | * \param *logscale axis for logscale | 
|---|
| 595 | * \param *extraline extra set lines if desired | 
|---|
| 596 | * \param mxtics small tics at ... | 
|---|
| 597 | * \param xtics large tics at ... | 
|---|
| 598 | * \param *xlabel label for x axis | 
|---|
| 599 | * \param *ylabel label for y axis | 
|---|
| 600 | */ | 
|---|
| 601 | void CreatePlotHeader(ofstream &output, 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) | 
|---|
| 602 | { | 
|---|
| 603 | //output << "#!/home/heber/build/pyxplot/pyxplot" << endl << endl; | 
|---|
| 604 | output << "reset" << endl; | 
|---|
| 605 | output << "set keycolumns "<< keycolumns << endl; | 
|---|
| 606 | output << "set key " << key << endl; | 
|---|
| 607 | output << "set mxtics "<< mxtics << endl; | 
|---|
| 608 | output << "set xtics "<< xtics << endl; | 
|---|
| 609 | if (logscale != NULL) | 
|---|
| 610 | output << "set logscale " << logscale << endl; | 
|---|
| 611 | if (extraline != NULL) | 
|---|
| 612 | output << extraline << endl; | 
|---|
| 613 | output << "set xlabel '" << xlabel << "'" << endl; | 
|---|
| 614 | output << "set ylabel '" << ylabel << "'" << endl; | 
|---|
| 615 | output << "set terminal eps color" << endl; | 
|---|
| 616 | output << "set output '"<< prefix << ".eps'" << endl; | 
|---|
| 617 | }; | 
|---|
| 618 |  | 
|---|
| 619 | /** Creates the pyxplotfile for energy data. | 
|---|
| 620 | * \param Matrix MatrixContainer with matrix values | 
|---|
| 621 | * \param KeySet contains bond order | 
|---|
| 622 | * \param *dir directory | 
|---|
| 623 | * \param *prefix prefix for all filenames (without ending) | 
|---|
| 624 | * \param keycolumns number of columns of the key | 
|---|
| 625 | * \param *key position of key | 
|---|
| 626 | * \param logscale axis for logscale | 
|---|
| 627 | * \param mxtics small tics at ... | 
|---|
| 628 | * \param xtics large tics at ... | 
|---|
| 629 | * \param xlabel label for x axis | 
|---|
| 630 | * \param xlabel label for x axis | 
|---|
| 631 | * \param *xrange xrange | 
|---|
| 632 | * \param *yrange yrange | 
|---|
| 633 | * \param *xargument number of column to plot against (x axis) | 
|---|
| 634 | * \param uses using string for plot command | 
|---|
| 635 | * \param (*CreatePlotLines) function reference that writes a single plot line | 
|---|
| 636 | * \return true if file was written successfully | 
|---|
| 637 | */ | 
|---|
| 638 | 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 | { | 
|---|
| 640 | stringstream filename; | 
|---|
| 641 | ofstream output; | 
|---|
| 642 |  | 
|---|
| 643 | filename << prefix << ".pyx"; | 
|---|
| 644 | if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; | 
|---|
| 645 | CreatePlotHeader(output, prefix, keycolumns, key, logscale, extraline, mxtics, xtics, xlabel, ylabel); | 
|---|
| 646 | output << "plot " << xrange << " " << yrange << " \\" << endl; | 
|---|
| 647 | CreatePlotLines(output, Matrix, prefix, xargument, uses); | 
|---|
| 648 | output.close(); | 
|---|
| 649 | return true; | 
|---|
| 650 | }; | 
|---|
| 651 |  | 
|---|
| 652 | /** Writes plot lines for absolute energies. | 
|---|
| 653 | * \param output file handler | 
|---|
| 654 | * \param Energy MatrixContainer with matrix values | 
|---|
| 655 | * \param *prefix prefix of data file | 
|---|
| 656 | * \param *xargument number of column to plot against (x axis) | 
|---|
| 657 | * \param *uses uses command | 
|---|
| 658 | */ | 
|---|
| 659 | void AbsEnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses) | 
|---|
| 660 | { | 
|---|
| 661 | stringstream line(Energy.Header[ Energy.MatrixCounter ]); | 
|---|
| 662 | string token; | 
|---|
| 663 |  | 
|---|
| 664 | getline(line, token, '\t'); | 
|---|
| 665 | for (int i=2; i<= Energy.ColumnCounter[Energy.MatrixCounter];i++) { | 
|---|
| 666 | getline(line, token, '\t'); | 
|---|
| 667 | while (token[0] == ' ') // remove leading white spaces | 
|---|
| 668 | token.erase(0,1); | 
|---|
| 669 | output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(abs($" << i+2 << ")) " << uses; | 
|---|
| 670 | if (i != (Energy.ColumnCounter[Energy.MatrixCounter])) | 
|---|
| 671 | output << ", \\"; | 
|---|
| 672 | output << endl; | 
|---|
| 673 | } | 
|---|
| 674 | }; | 
|---|
| 675 |  | 
|---|
| 676 | /** Writes plot lines for energies. | 
|---|
| 677 | * \param output file handler | 
|---|
| 678 | * \param Energy MatrixContainer with matrix values | 
|---|
| 679 | * \param *prefix prefix of data file | 
|---|
| 680 | * \param *xargument number of column to plot against (x axis) | 
|---|
| 681 | * \param *uses uses command | 
|---|
| 682 | */ | 
|---|
| 683 | void EnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses) | 
|---|
| 684 | { | 
|---|
| 685 | stringstream line(Energy.Header[Energy.MatrixCounter]); | 
|---|
| 686 | string token; | 
|---|
| 687 |  | 
|---|
| 688 | getline(line, token, '\t'); | 
|---|
| 689 | for (int i=1; i<= Energy.ColumnCounter[Energy.MatrixCounter];i++) { | 
|---|
| 690 | getline(line, token, '\t'); | 
|---|
| 691 | while (token[0] == ' ') // remove leading white spaces | 
|---|
| 692 | token.erase(0,1); | 
|---|
| 693 | output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":" << i+2 << " " << uses; | 
|---|
| 694 | if (i != (Energy.ColumnCounter[Energy.MatrixCounter])) | 
|---|
| 695 | output << ", \\"; | 
|---|
| 696 | output << endl; | 
|---|
| 697 | } | 
|---|
| 698 | }; | 
|---|
| 699 |  | 
|---|
| 700 | /** Writes plot lines for absolute force magnitudes. | 
|---|
| 701 | * \param output file handler | 
|---|
| 702 | * \param Force MatrixContainer with matrix values | 
|---|
| 703 | * \param *prefix prefix of data file | 
|---|
| 704 | * \param *xargument number of column to plot against (x axis) | 
|---|
| 705 | * \param *uses uses command | 
|---|
| 706 | */ | 
|---|
| 707 | void ForceMagnitudePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses) | 
|---|
| 708 | { | 
|---|
| 709 | stringstream line(Force.Header[Force.MatrixCounter]); | 
|---|
| 710 | string token; | 
|---|
| 711 |  | 
|---|
| 712 | getline(line, token, '\t'); | 
|---|
| 713 | getline(line, token, '\t'); | 
|---|
| 714 | getline(line, token, '\t'); | 
|---|
| 715 | getline(line, token, '\t'); | 
|---|
| 716 | getline(line, token, '\t'); | 
|---|
| 717 | for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) { | 
|---|
| 718 | getline(line, token, '\t'); | 
|---|
| 719 | while (token[0] == ' ') // remove leading white spaces | 
|---|
| 720 | token.erase(0,1); | 
|---|
| 721 | token.erase(token.length(), 1);  // kill residual index char (the '0') | 
|---|
| 722 | output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(sqrt($" << i+1 << "*$" << i+1 << "+$" << i+2 << "*$" << i+2 << "+$" << i+3 << "*$" << i+3 << ")) " << uses; | 
|---|
| 723 | if (i != (Force.ColumnCounter[Force.MatrixCounter]-1)) | 
|---|
| 724 | output << ", \\"; | 
|---|
| 725 | output << endl; | 
|---|
| 726 | getline(line, token, '\t'); | 
|---|
| 727 | getline(line, token, '\t'); | 
|---|
| 728 | } | 
|---|
| 729 | }; | 
|---|
| 730 |  | 
|---|
| 731 | /** Writes plot lines for first component of force vector. | 
|---|
| 732 | * \param output file handler | 
|---|
| 733 | * \param Force MatrixContainer with matrix values | 
|---|
| 734 | * \param *prefix prefix of data file | 
|---|
| 735 | * \param *xargument number of column to plot against (x axis) | 
|---|
| 736 | * \param *uses uses command | 
|---|
| 737 | */ | 
|---|
| 738 | void AbsFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses) | 
|---|
| 739 | { | 
|---|
| 740 | stringstream line(Force.Header[Force.MatrixCounter]); | 
|---|
| 741 | string token; | 
|---|
| 742 |  | 
|---|
| 743 | getline(line, token, '\t'); | 
|---|
| 744 | getline(line, token, '\t'); | 
|---|
| 745 | getline(line, token, '\t'); | 
|---|
| 746 | getline(line, token, '\t'); | 
|---|
| 747 | getline(line, token, '\t'); | 
|---|
| 748 | for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) { | 
|---|
| 749 | getline(line, token, '\t'); | 
|---|
| 750 | while (token[0] == ' ') // remove leading white spaces | 
|---|
| 751 | token.erase(0,1); | 
|---|
| 752 | token.erase(token.length(), 1);  // kill residual index char (the '0') | 
|---|
| 753 | output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(abs($" << i+1 << ")) " << uses; | 
|---|
| 754 | if (i != (Force.ColumnCounter[Force.MatrixCounter]-1)) | 
|---|
| 755 | output << ", \\"; | 
|---|
| 756 | output << endl; | 
|---|
| 757 | getline(line, token, '\t'); | 
|---|
| 758 | getline(line, token, '\t'); | 
|---|
| 759 | } | 
|---|
| 760 | }; | 
|---|
| 761 |  | 
|---|
| 762 | /** Writes plot lines for force vector as boxes with a fillcolor. | 
|---|
| 763 | * \param output file handler | 
|---|
| 764 | * \param Force MatrixContainer with matrix values | 
|---|
| 765 | * \param *prefix prefix of data file | 
|---|
| 766 | * \param *xargument number of column to plot against (x axis) | 
|---|
| 767 | * \param *uses uses command | 
|---|
| 768 | */ | 
|---|
| 769 | void BoxesForcePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses) | 
|---|
| 770 | { | 
|---|
| 771 | stringstream line(Force.Header[Force.MatrixCounter]); | 
|---|
| 772 | char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"}; | 
|---|
| 773 | string token; | 
|---|
| 774 |  | 
|---|
| 775 | getline(line, token, '\t'); | 
|---|
| 776 | getline(line, token, '\t'); | 
|---|
| 777 | getline(line, token, '\t'); | 
|---|
| 778 | getline(line, token, '\t'); | 
|---|
| 779 | getline(line, token, '\t'); | 
|---|
| 780 | for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) { | 
|---|
| 781 | getline(line, token, '\t'); | 
|---|
| 782 | while (token[0] == ' ') // remove leading white spaces | 
|---|
| 783 | token.erase(0,1); | 
|---|
| 784 | token.erase(token.length(), 1);  // kill residual index char (the '0') | 
|---|
| 785 | 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]; | 
|---|
| 786 | if (i != (Force.ColumnCounter[Force.MatrixCounter]-1)) | 
|---|
| 787 | output << ", \\"; | 
|---|
| 788 | output << endl; | 
|---|
| 789 | getline(line, token, '\t'); | 
|---|
| 790 | getline(line, token, '\t'); | 
|---|
| 791 | } | 
|---|
| 792 | }; | 
|---|
| 793 |  | 
|---|
| 794 | /** Writes plot lines for first force vector component as boxes with a fillcolor. | 
|---|
| 795 | * \param output file handler | 
|---|
| 796 | * \param Force MatrixContainer with matrix values | 
|---|
| 797 | * \param *prefix prefix of data file | 
|---|
| 798 | * \param *xargument number of column to plot against (x axis) | 
|---|
| 799 | * \param *uses uses command | 
|---|
| 800 | */ | 
|---|
| 801 | void BoxesFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses) | 
|---|
| 802 | { | 
|---|
| 803 | stringstream line(Force.Header[Force.MatrixCounter]); | 
|---|
| 804 | char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"}; | 
|---|
| 805 | string token; | 
|---|
| 806 |  | 
|---|
| 807 | getline(line, token, '\t'); | 
|---|
| 808 | getline(line, token, '\t'); | 
|---|
| 809 | getline(line, token, '\t'); | 
|---|
| 810 | getline(line, token, '\t'); | 
|---|
| 811 | getline(line, token, '\t'); | 
|---|
| 812 | for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) { | 
|---|
| 813 | getline(line, token, '\t'); | 
|---|
| 814 | while (token[0] == ' ') // remove leading white spaces | 
|---|
| 815 | token.erase(0,1); | 
|---|
| 816 | token.erase(token.length(), 1);  // kill residual index char (the '0') | 
|---|
| 817 | output << "'" << prefix << ".dat' title '" << token << "' using ($" << xargument << "+" << fixed << setprecision(1) << (double)((i-7)/3)*0.2 << "):" << i+1 << " " << uses << " " << fillcolor[(i-7)/3]; | 
|---|
| 818 | if (i != (Force.ColumnCounter[Force.MatrixCounter]-1)) | 
|---|
| 819 | output << ", \\"; | 
|---|
| 820 | output << endl; | 
|---|
| 821 | getline(line, token, '\t'); | 
|---|
| 822 | getline(line, token, '\t'); | 
|---|
| 823 | } | 
|---|
| 824 | }; | 
|---|