[14de469] | 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 |
|
---|
[19f3d6] | 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 |
|
---|
[14de469] | 49 | /** Plots an energy vs. order.
|
---|
[390248] | 50 | * \param &Fragments EnergyMatrix class containing matrix values
|
---|
[14de469] | 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 | */
|
---|
[390248] | 56 | bool CreateDataEnergyOrder(class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum)
|
---|
[14de469] | 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;
|
---|
[b12a35] | 65 | output << "#Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
|
---|
[14de469] | 66 | for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
|
---|
[7f3b9d] | 67 | for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) {
|
---|
[390248] | 68 | for(int j=Fragments.RowCounter[ KeySet.OrderSet[BondOrder][i] ];j--;)
|
---|
[f731ae] | 69 | for(int k=Fragments.ColumnCounter[ KeySet.OrderSet[BondOrder][i] ];k--;)
|
---|
[390248] | 70 | Fragments.Matrix[Fragments.MatrixCounter][j][k] += Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
|
---|
[14de469] | 71 | }
|
---|
| 72 | output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
|
---|
[f731ae] | 73 | for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++)
|
---|
[390248] | 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;
|
---|
[b12a35] | 98 | output << "#Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
|
---|
[390248] | 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--;)
|
---|
[f731ae] | 103 | for(int k=Fragments.ColumnCounter[ KeySet.OrderSet[BondOrder][i] ];k--;)
|
---|
[390248] | 104 | Fragments.Matrix[Fragments.MatrixCounter][j][k] -= Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
|
---|
| 105 | }
|
---|
| 106 | output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
|
---|
[f731ae] | 107 | for (int l=0;l<Fragments.ColumnCounter[Energy.MatrixCounter];l++)
|
---|
[390248] | 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];
|
---|
[14de469] | 110 | else
|
---|
[390248] | 111 | output << scientific << "\t" << (Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l] / Energy.Matrix[Energy.MatrixCounter][ Energy.RowCounter[Energy.MatrixCounter]-1 ][l]);
|
---|
[14de469] | 112 | output << endl;
|
---|
| 113 | }
|
---|
| 114 | output.close();
|
---|
| 115 | return true;
|
---|
| 116 | };
|
---|
| 117 |
|
---|
| 118 | /** Plot forces vs. order.
|
---|
[390248] | 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
|
---|
[14de469] | 125 | */
|
---|
[390248] | 126 | bool CreateDataForcesOrder(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateForce)(class MatrixContainer &, int))
|
---|
[14de469] | 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;
|
---|
[b12a35] | 135 | output << "# Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
|
---|
[390248] | 136 | Fragments.SetLastMatrix(0.,0);
|
---|
[14de469] | 137 | for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
|
---|
[390248] | 138 | Fragments.SumSubForces(Fragments, KeySet, BondOrder, 1.);
|
---|
| 139 | output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
|
---|
| 140 | CreateForce(Fragments, Fragments.MatrixCounter);
|
---|
[f731ae] | 141 | for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++)
|
---|
[390248] | 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;
|
---|
[b12a35] | 167 | output << "# Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
|
---|
[390248] | 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);
|
---|
[f731ae] | 173 | for (int l=0;l<Fragments.ColumnCounter[Fragments.MatrixCounter];l++)
|
---|
[390248] | 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;
|
---|
[b12a35] | 200 | output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
|
---|
[390248] | 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
|
---|
[4ee3df] | 206 | output << endl << "#Order\t" << BondOrder+1 << endl;
|
---|
[390248] | 207 | for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
|
---|
| 208 | output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t";
|
---|
[f731ae] | 209 | for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) {
|
---|
[390248] | 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";
|
---|
[14de469] | 220 | }
|
---|
[390248] | 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;
|
---|
[b12a35] | 246 | output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
|
---|
[390248] | 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
|
---|
[19f3d6] | 251 | output << endl << "#Order\t" << BondOrder+1 << endl;
|
---|
[390248] | 252 | for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
|
---|
| 253 | output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t";
|
---|
[f731ae] | 254 | for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++)
|
---|
[390248] | 255 | output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t";
|
---|
| 256 | output << endl;
|
---|
[14de469] | 257 | }
|
---|
| 258 | output << endl;
|
---|
| 259 | }
|
---|
| 260 | output.close();
|
---|
| 261 | return true;
|
---|
| 262 | };
|
---|
| 263 |
|
---|
[b12a35] | 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 | };
|
---|
[05d2b2] | 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 | };
|
---|
[b12a35] | 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 |
|
---|
[14de469] | 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;
|
---|
[bf2db1] | 395 | output << "# " << msg << ", created on " << datum << endl;
|
---|
[b12a35] | 396 | output << "#Order\tFrag.No.\t" << Fragment.Header[ Fragment.MatrixCounter ] << endl;
|
---|
[14de469] | 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]);
|
---|
[f731ae] | 401 | for (int l=0;l<Fragment.ColumnCounter[ KeySet.OrderSet[BondOrder][i] ];l++)
|
---|
[14de469] | 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 | {
|
---|
[7f3b9d] | 417 | for(int j=Fragments.RowCounter[ Fragments.MatrixCounter ];j--;) {
|
---|
| 418 | for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) {
|
---|
[14de469] | 419 | if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < fabs(Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][1])) {
|
---|
[f731ae] | 420 | for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;)
|
---|
[14de469] | 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
|
---|
[f731ae] | 437 | for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;)
|
---|
[14de469] | 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])) {
|
---|
[f731ae] | 443 | for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;)
|
---|
[14de469] | 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;
|
---|
[b12a35] | 461 | output << "#Order\tFrag.No.\t" << Fragment.Header[ Fragment.MatrixCounter ] << endl;
|
---|
[14de469] | 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];
|
---|
[f731ae] | 467 | for (int l=0;l<Fragment.ColumnCounter[ Fragment.MatrixCounter ];l++)
|
---|
[14de469] | 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 | {
|
---|
[f731ae] | 481 | for(int k=0;k<Energy.ColumnCounter[MatrixNumber];k++)
|
---|
[14de469] | 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 | {
|
---|
[f731ae] | 492 | for (int l=Force.ColumnCounter[MatrixNumber];l--;)
|
---|
[14de469] | 493 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
|
---|
[f731ae] | 494 | for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) {
|
---|
[14de469] | 495 | double stored = 0;
|
---|
| 496 | int k=0;
|
---|
| 497 | do {
|
---|
[7f3b9d] | 498 | for (int m=NDIM;m--;) {
|
---|
[14de469] | 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;
|
---|
[7f3b9d] | 507 | for (int m=NDIM;m--;)
|
---|
[14de469] | 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
|
---|
[7f3b9d] | 511 | for (int m=NDIM;m--;)
|
---|
[14de469] | 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;
|
---|
[f731ae] | 527 | for (int l=Force.ColumnCounter[MatrixNumber];l--;)
|
---|
[14de469] | 528 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
|
---|
[f731ae] | 529 | for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) {
|
---|
[14de469] | 530 | double tmp = 0;
|
---|
[7f3b9d] | 531 | for (int k=Force.RowCounter[MatrixNumber];k--;) {
|
---|
[14de469] | 532 | double norm = 0.;
|
---|
[7f3b9d] | 533 | for (int m=NDIM;m--;)
|
---|
[14de469] | 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 | {
|
---|
[f731ae] | 551 | for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) {
|
---|
[14de469] | 552 | double stored = 0;
|
---|
[7f3b9d] | 553 | for (int k=Force.RowCounter[MatrixNumber];k--;) {
|
---|
[14de469] | 554 | double tmp = 0;
|
---|
[7f3b9d] | 555 | for (int m=NDIM;m--;)
|
---|
[14de469] | 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
|
---|
[7f3b9d] | 559 | for (int m=NDIM;m--;)
|
---|
[14de469] | 560 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m] = Force.Matrix[MatrixNumber][ k ][l+m];
|
---|
| 561 | stored = tmp;
|
---|
| 562 | }
|
---|
| 563 | }
|
---|
| 564 | }
|
---|
| 565 | };
|
---|
| 566 |
|
---|
[390248] | 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 |
|
---|
[14de469] | 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 | {
|
---|
[f731ae] | 583 | for (int l=Force.ColumnCounter[MatrixNumber];l--;)
|
---|
[14de469] | 584 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
|
---|
[f731ae] | 585 | for (int l=0;l<Force.ColumnCounter[MatrixNumber];l++) {
|
---|
[7f3b9d] | 586 | for (int k=Force.RowCounter[MatrixNumber];k--;)
|
---|
[14de469] | 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;
|
---|
[fa40b5] | 609 | if (logscale != NULL)
|
---|
[14de469] | 610 | output << "set logscale " << logscale << endl;
|
---|
[fa40b5] | 611 | if (extraline != NULL)
|
---|
[14de469] | 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 | {
|
---|
[b12a35] | 661 | stringstream line(Energy.Header[ Energy.MatrixCounter ]);
|
---|
[fb9364] | 662 | string token;
|
---|
[14de469] | 663 |
|
---|
[fb9364] | 664 | getline(line, token, '\t');
|
---|
[f731ae] | 665 | for (int i=2; i<= Energy.ColumnCounter[Energy.MatrixCounter];i++) {
|
---|
[fb9364] | 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;
|
---|
[f731ae] | 670 | if (i != (Energy.ColumnCounter[Energy.MatrixCounter]))
|
---|
[14de469] | 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 | {
|
---|
[b12a35] | 685 | stringstream line(Energy.Header[Energy.MatrixCounter]);
|
---|
[fb9364] | 686 | string token;
|
---|
| 687 |
|
---|
| 688 | getline(line, token, '\t');
|
---|
[f731ae] | 689 | for (int i=1; i<= Energy.ColumnCounter[Energy.MatrixCounter];i++) {
|
---|
[fb9364] | 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;
|
---|
[f731ae] | 694 | if (i != (Energy.ColumnCounter[Energy.MatrixCounter]))
|
---|
[14de469] | 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 | {
|
---|
[b12a35] | 709 | stringstream line(Force.Header[Force.MatrixCounter]);
|
---|
[fb9364] | 710 | string token;
|
---|
[14de469] | 711 |
|
---|
[fb9364] | 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');
|
---|
[f731ae] | 717 | for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
|
---|
[fb9364] | 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;
|
---|
[f731ae] | 723 | if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
|
---|
[14de469] | 724 | output << ", \\";
|
---|
| 725 | output << endl;
|
---|
[fb9364] | 726 | getline(line, token, '\t');
|
---|
| 727 | getline(line, token, '\t');
|
---|
[14de469] | 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 | {
|
---|
[b12a35] | 740 | stringstream line(Force.Header[Force.MatrixCounter]);
|
---|
[fb9364] | 741 | string token;
|
---|
[14de469] | 742 |
|
---|
[fb9364] | 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');
|
---|
[f731ae] | 748 | for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
|
---|
[fb9364] | 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;
|
---|
[f731ae] | 754 | if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
|
---|
[14de469] | 755 | output << ", \\";
|
---|
| 756 | output << endl;
|
---|
[fb9364] | 757 | getline(line, token, '\t');
|
---|
| 758 | getline(line, token, '\t');
|
---|
[14de469] | 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 | {
|
---|
[b12a35] | 771 | stringstream line(Force.Header[Force.MatrixCounter]);
|
---|
[14de469] | 772 | char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
|
---|
[fb9364] | 773 | string token;
|
---|
[14de469] | 774 |
|
---|
[fb9364] | 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');
|
---|
[f731ae] | 780 | for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
|
---|
[fb9364] | 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];
|
---|
[f731ae] | 786 | if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
|
---|
[14de469] | 787 | output << ", \\";
|
---|
| 788 | output << endl;
|
---|
[fb9364] | 789 | getline(line, token, '\t');
|
---|
| 790 | getline(line, token, '\t');
|
---|
[14de469] | 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 | {
|
---|
[b12a35] | 803 | stringstream line(Force.Header[Force.MatrixCounter]);
|
---|
[14de469] | 804 | char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
|
---|
[fb9364] | 805 | string token;
|
---|
[14de469] | 806 |
|
---|
[fb9364] | 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');
|
---|
[f731ae] | 812 | for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
|
---|
[fb9364] | 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];
|
---|
[f731ae] | 818 | if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
|
---|
[14de469] | 819 | output << ", \\";
|
---|
| 820 | output << endl;
|
---|
[fb9364] | 821 | getline(line, token, '\t');
|
---|
| 822 | getline(line, token, '\t');
|
---|
[14de469] | 823 | }
|
---|
| 824 | };
|
---|