[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;
|
---|
[eeec8f] | 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;
|
---|
[eeec8f] | 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;
|
---|
[eeec8f] | 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;
|
---|
[eeec8f] | 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;
|
---|
[eeec8f] | 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;
|
---|
[eeec8f] | 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 |
|
---|
[eeec8f] | 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.
|
---|
| 305 | * \param &Fragments HessianMatrix class containing matrix values
|
---|
| 306 | * \param KeySet KeySetContainer class holding bond KeySetContainer::Order
|
---|
| 307 | * \param *prefix prefix in filename (without ending)
|
---|
| 308 | * \param *msg message to be place in first line as a comment
|
---|
| 309 | * \param *datum current date and time
|
---|
| 310 | * \return true if file was written successfully
|
---|
| 311 | */
|
---|
| 312 | bool CreateDataHessianOrderPerAtom(class HessianMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum)
|
---|
| 313 | {
|
---|
| 314 | stringstream filename;
|
---|
| 315 | ofstream output;
|
---|
| 316 |
|
---|
| 317 | filename << prefix << ".dat";
|
---|
| 318 | if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
|
---|
| 319 | cout << msg << endl;
|
---|
| 320 | output << "# " << msg << ", created on " << datum;
|
---|
| 321 | output << "# AtomNo\t" << Fragments.Header[ Fragments.MatrixCounter ] << endl;
|
---|
| 322 | Fragments.SetLastMatrix(0., 0);
|
---|
| 323 | for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
|
---|
| 324 | //cout << "Current order is " << BondOrder << "." << endl;
|
---|
| 325 | Fragments.SumSubHessians(Fragments, KeySet, BondOrder, 1.);
|
---|
| 326 | // errors per atom
|
---|
| 327 | output << endl << "#Order\t" << BondOrder+1 << endl;
|
---|
| 328 | for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
|
---|
| 329 | output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t";
|
---|
| 330 | for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++)
|
---|
| 331 | output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t";
|
---|
| 332 | output << endl;
|
---|
| 333 | }
|
---|
| 334 | output << endl;
|
---|
| 335 | }
|
---|
| 336 | output.close();
|
---|
| 337 | return true;
|
---|
| 338 | };
|
---|
| 339 |
|
---|
[14de469] | 340 | /** Plot matrix vs. fragment.
|
---|
| 341 | */
|
---|
| 342 | bool CreateDataFragment(class MatrixContainer &Fragment, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateFragment)(class MatrixContainer &, int))
|
---|
| 343 | {
|
---|
| 344 | stringstream filename;
|
---|
| 345 | ofstream output;
|
---|
| 346 |
|
---|
| 347 | filename << prefix << ".dat";
|
---|
| 348 | if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
|
---|
| 349 | cout << msg << endl;
|
---|
[bf2db1] | 350 | output << "# " << msg << ", created on " << datum << endl;
|
---|
[eeec8f] | 351 | output << "#Order\tFrag.No.\t" << Fragment.Header[ Fragment.MatrixCounter ] << endl;
|
---|
[14de469] | 352 | for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
|
---|
| 353 | for(int i=0;i<KeySet.FragmentsPerOrder[BondOrder];i++) {
|
---|
| 354 | output << BondOrder+1 << "\t" << KeySet.OrderSet[BondOrder][i]+1;
|
---|
| 355 | CreateFragment(Fragment, KeySet.OrderSet[BondOrder][i]);
|
---|
[f731ae] | 356 | for (int l=0;l<Fragment.ColumnCounter[ KeySet.OrderSet[BondOrder][i] ];l++)
|
---|
[14de469] | 357 | output << scientific << "\t" << Fragment.Matrix[ KeySet.OrderSet[BondOrder][i] ][ Fragment.RowCounter[ KeySet.OrderSet[BondOrder][i] ] ][l];
|
---|
| 358 | output << endl;
|
---|
| 359 | }
|
---|
| 360 | }
|
---|
| 361 | output.close();
|
---|
| 362 | return true;
|
---|
| 363 | };
|
---|
| 364 |
|
---|
| 365 | /** Copies fragment energy values into last matrix of \a Matrix with greatest total energy.
|
---|
| 366 | * \param &Matrix MatrixContainer with all fragment energy values
|
---|
| 367 | * \param &KeySet KeySetsContainer with associations of each fragment to a bond order
|
---|
| 368 | * \param BondOrder current bond order
|
---|
| 369 | */
|
---|
| 370 | void CreateMaxFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySet, int BondOrder)
|
---|
| 371 | {
|
---|
[7f3b9d] | 372 | for(int j=Fragments.RowCounter[ Fragments.MatrixCounter ];j--;) {
|
---|
| 373 | for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) {
|
---|
[14de469] | 374 | if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < fabs(Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][1])) {
|
---|
[f731ae] | 375 | for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;)
|
---|
[14de469] | 376 | Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
|
---|
| 377 | }
|
---|
| 378 | }
|
---|
| 379 | }
|
---|
| 380 | };
|
---|
| 381 |
|
---|
| 382 | /** Copies fragment energy values into last matrix of \a Matrix with smallest total energy.
|
---|
| 383 | * \param &Matrix MatrixContainer with all fragment energy values
|
---|
| 384 | * \param &KeySet KeySetsContainer with associations of each fragment to a bond order
|
---|
| 385 | * \param BondOrder current bond order
|
---|
| 386 | */
|
---|
| 387 | void CreateMinFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySet, int BondOrder)
|
---|
| 388 | {
|
---|
| 389 | for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
|
---|
| 390 | int i=0;
|
---|
| 391 | do { // first get a minimum value unequal to 0
|
---|
[f731ae] | 392 | for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;)
|
---|
[14de469] | 393 | Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
|
---|
| 394 | i++;
|
---|
| 395 | } while ((fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < MYEPSILON) && (i<KeySet.FragmentsPerOrder[BondOrder]));
|
---|
| 396 | for(;i<KeySet.FragmentsPerOrder[BondOrder];i++) { // then find lowest
|
---|
| 397 | if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) > fabs(Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][1])) {
|
---|
[f731ae] | 398 | for (int k=Fragments.ColumnCounter[ Fragments.MatrixCounter ];k--;)
|
---|
[14de469] | 399 | Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
|
---|
| 400 | }
|
---|
| 401 | }
|
---|
| 402 | }
|
---|
| 403 | };
|
---|
| 404 |
|
---|
| 405 | /** Plot matrix vs. fragment.
|
---|
| 406 | */
|
---|
| 407 | bool CreateDataFragmentOrder(class MatrixContainer &Fragment, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateFragmentOrder)(class MatrixContainer &, class KeySetsContainer &, int))
|
---|
| 408 | {
|
---|
| 409 | stringstream filename;
|
---|
| 410 | ofstream output;
|
---|
| 411 |
|
---|
| 412 | filename << prefix << ".dat";
|
---|
| 413 | if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
|
---|
| 414 | cout << msg << endl;
|
---|
| 415 | output << "# " << msg << ", created on " << datum;
|
---|
[eeec8f] | 416 | output << "#Order\tFrag.No.\t" << Fragment.Header[ Fragment.MatrixCounter ] << endl;
|
---|
[14de469] | 417 | // max
|
---|
| 418 | for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
|
---|
| 419 | Fragment.SetLastMatrix(0.,0);
|
---|
| 420 | CreateFragmentOrder(Fragment, KeySet, BondOrder);
|
---|
| 421 | output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
|
---|
[f731ae] | 422 | for (int l=0;l<Fragment.ColumnCounter[ Fragment.MatrixCounter ];l++)
|
---|
[14de469] | 423 | output << scientific << "\t" << Fragment.Matrix[ Fragment.MatrixCounter ][ Fragment.RowCounter[ Fragment.MatrixCounter ]-1 ][l];
|
---|
| 424 | output << endl;
|
---|
| 425 | }
|
---|
| 426 | output.close();
|
---|
| 427 | return true;
|
---|
| 428 | };
|
---|
| 429 |
|
---|
| 430 | /** Takes last but one row and copies into final row.
|
---|
| 431 | * \param Energy MatrixContainer with matrix values
|
---|
| 432 | * \param MatrixNumber the index for the ForceMatrix::matrix array
|
---|
| 433 | */
|
---|
| 434 | void CreateEnergy(class MatrixContainer &Energy, int MatrixNumber)
|
---|
| 435 | {
|
---|
[f731ae] | 436 | for(int k=0;k<Energy.ColumnCounter[MatrixNumber];k++)
|
---|
[14de469] | 437 | Energy.Matrix[MatrixNumber][ Energy.RowCounter[MatrixNumber] ] [k] = Energy.Matrix[MatrixNumber][ Energy.RowCounter[MatrixNumber]-1 ] [k];
|
---|
| 438 | };
|
---|
| 439 |
|
---|
| 440 | /** Scans forces for the minimum in magnitude.
|
---|
| 441 | * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force.
|
---|
| 442 | * \param Force ForceMatrix class containing matrix values
|
---|
| 443 | * \param MatrixNumber the index for the ForceMatrix::matrix array
|
---|
| 444 | */
|
---|
| 445 | void CreateMinimumForce(class MatrixContainer &Force, int MatrixNumber)
|
---|
| 446 | {
|
---|
[f731ae] | 447 | for (int l=Force.ColumnCounter[MatrixNumber];l--;)
|
---|
[14de469] | 448 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
|
---|
[f731ae] | 449 | for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) {
|
---|
[14de469] | 450 | double stored = 0;
|
---|
| 451 | int k=0;
|
---|
| 452 | do {
|
---|
[7f3b9d] | 453 | for (int m=NDIM;m--;) {
|
---|
[14de469] | 454 | stored += Force.Matrix[MatrixNumber][ k ][l+m]
|
---|
| 455 | * Force.Matrix[MatrixNumber][ k ][l+m];
|
---|
| 456 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m] = Force.Matrix[MatrixNumber][ k ][l+m];
|
---|
| 457 | }
|
---|
| 458 | k++;
|
---|
| 459 | } while ((fabs(stored) < MYEPSILON) && (k<Force.RowCounter[MatrixNumber]));
|
---|
| 460 | for (;k<Force.RowCounter[MatrixNumber];k++) {
|
---|
| 461 | double tmp = 0;
|
---|
[7f3b9d] | 462 | for (int m=NDIM;m--;)
|
---|
[14de469] | 463 | tmp += Force.Matrix[MatrixNumber][ k ][l+m]
|
---|
| 464 | * Force.Matrix[MatrixNumber][ k ][l+m];
|
---|
| 465 | if ((fabs(tmp) > MYEPSILON) && (tmp < stored)) { // current force is greater than stored
|
---|
[7f3b9d] | 466 | for (int m=NDIM;m--;)
|
---|
[14de469] | 467 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m] = Force.Matrix[MatrixNumber][ k ][l+m];
|
---|
| 468 | stored = tmp;
|
---|
| 469 | }
|
---|
| 470 | }
|
---|
| 471 | }
|
---|
| 472 | };
|
---|
| 473 |
|
---|
| 474 | /** Scans forces for the mean in magnitude.
|
---|
| 475 | * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force.
|
---|
| 476 | * \param Force ForceMatrix class containing matrix values
|
---|
| 477 | * \param MatrixNumber the index for the ForceMatrix::matrix array
|
---|
| 478 | */
|
---|
| 479 | void CreateMeanForce(class MatrixContainer &Force, int MatrixNumber)
|
---|
| 480 | {
|
---|
| 481 | int divisor = 0;
|
---|
[f731ae] | 482 | for (int l=Force.ColumnCounter[MatrixNumber];l--;)
|
---|
[14de469] | 483 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
|
---|
[f731ae] | 484 | for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) {
|
---|
[14de469] | 485 | double tmp = 0;
|
---|
[7f3b9d] | 486 | for (int k=Force.RowCounter[MatrixNumber];k--;) {
|
---|
[14de469] | 487 | double norm = 0.;
|
---|
[7f3b9d] | 488 | for (int m=NDIM;m--;)
|
---|
[14de469] | 489 | norm += Force.Matrix[MatrixNumber][ k ][l+m]
|
---|
| 490 | * Force.Matrix[MatrixNumber][ k ][l+m];
|
---|
| 491 | tmp += sqrt(norm);
|
---|
| 492 | if (fabs(norm) > MYEPSILON) divisor++;
|
---|
| 493 | }
|
---|
| 494 | tmp /= (double)divisor;
|
---|
| 495 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = tmp;
|
---|
| 496 | }
|
---|
| 497 | };
|
---|
| 498 |
|
---|
| 499 | /** Scans forces for the maximum in magnitude.
|
---|
| 500 | * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force.
|
---|
| 501 | * \param Force ForceMatrix class containing matrix values
|
---|
| 502 | * \param MatrixNumber the index for the ForceMatrix::matrix array
|
---|
| 503 | */
|
---|
| 504 | void CreateMaximumForce(class MatrixContainer &Force, int MatrixNumber)
|
---|
| 505 | {
|
---|
[f731ae] | 506 | for (int l=5;l<Force.ColumnCounter[MatrixNumber];l+=3) {
|
---|
[14de469] | 507 | double stored = 0;
|
---|
[7f3b9d] | 508 | for (int k=Force.RowCounter[MatrixNumber];k--;) {
|
---|
[14de469] | 509 | double tmp = 0;
|
---|
[7f3b9d] | 510 | for (int m=NDIM;m--;)
|
---|
[14de469] | 511 | tmp += Force.Matrix[MatrixNumber][ k ][l+m]
|
---|
| 512 | * Force.Matrix[MatrixNumber][ k ][l+m];
|
---|
| 513 | if (tmp > stored) { // current force is greater than stored
|
---|
[7f3b9d] | 514 | for (int m=NDIM;m--;)
|
---|
[14de469] | 515 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m] = Force.Matrix[MatrixNumber][ k ][l+m];
|
---|
| 516 | stored = tmp;
|
---|
| 517 | }
|
---|
| 518 | }
|
---|
| 519 | }
|
---|
| 520 | };
|
---|
| 521 |
|
---|
[390248] | 522 | /** Leaves the Force.Matrix as it is.
|
---|
| 523 | * \param Force ForceMatrix class containing matrix values
|
---|
| 524 | * \param MatrixNumber the index for the ForceMatrix::matrix array
|
---|
| 525 | */
|
---|
| 526 | void CreateSameForce(class MatrixContainer &Force, int MatrixNumber)
|
---|
| 527 | {
|
---|
| 528 | // does nothing
|
---|
| 529 | };
|
---|
| 530 |
|
---|
[14de469] | 531 | /** Adds vectorwise all forces.
|
---|
| 532 | * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force.
|
---|
| 533 | * \param Force ForceMatrix class containing matrix values
|
---|
| 534 | * \param MatrixNumber the index for the ForceMatrix::matrix array
|
---|
| 535 | */
|
---|
| 536 | void CreateVectorSumForce(class MatrixContainer &Force, int MatrixNumber)
|
---|
| 537 | {
|
---|
[f731ae] | 538 | for (int l=Force.ColumnCounter[MatrixNumber];l--;)
|
---|
[14de469] | 539 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
|
---|
[f731ae] | 540 | for (int l=0;l<Force.ColumnCounter[MatrixNumber];l++) {
|
---|
[7f3b9d] | 541 | for (int k=Force.RowCounter[MatrixNumber];k--;)
|
---|
[14de469] | 542 | Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] += Force.Matrix[MatrixNumber][k][l];
|
---|
| 543 | }
|
---|
| 544 | };
|
---|
| 545 |
|
---|
| 546 | /** Writes the standard pyxplot header info.
|
---|
| 547 | * \param keycolumns number of columns of the key
|
---|
| 548 | * \param *key position of key
|
---|
| 549 | * \param *logscale axis for logscale
|
---|
| 550 | * \param *extraline extra set lines if desired
|
---|
| 551 | * \param mxtics small tics at ...
|
---|
| 552 | * \param xtics large tics at ...
|
---|
| 553 | * \param *xlabel label for x axis
|
---|
| 554 | * \param *ylabel label for y axis
|
---|
| 555 | */
|
---|
| 556 | 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)
|
---|
| 557 | {
|
---|
| 558 | //output << "#!/home/heber/build/pyxplot/pyxplot" << endl << endl;
|
---|
| 559 | output << "reset" << endl;
|
---|
| 560 | output << "set keycolumns "<< keycolumns << endl;
|
---|
| 561 | output << "set key " << key << endl;
|
---|
| 562 | output << "set mxtics "<< mxtics << endl;
|
---|
| 563 | output << "set xtics "<< xtics << endl;
|
---|
[fa40b5] | 564 | if (logscale != NULL)
|
---|
[14de469] | 565 | output << "set logscale " << logscale << endl;
|
---|
[fa40b5] | 566 | if (extraline != NULL)
|
---|
[14de469] | 567 | output << extraline << endl;
|
---|
| 568 | output << "set xlabel '" << xlabel << "'" << endl;
|
---|
| 569 | output << "set ylabel '" << ylabel << "'" << endl;
|
---|
| 570 | output << "set terminal eps color" << endl;
|
---|
| 571 | output << "set output '"<< prefix << ".eps'" << endl;
|
---|
| 572 | };
|
---|
| 573 |
|
---|
| 574 | /** Creates the pyxplotfile for energy data.
|
---|
| 575 | * \param Matrix MatrixContainer with matrix values
|
---|
| 576 | * \param KeySet contains bond order
|
---|
| 577 | * \param *dir directory
|
---|
| 578 | * \param *prefix prefix for all filenames (without ending)
|
---|
| 579 | * \param keycolumns number of columns of the key
|
---|
| 580 | * \param *key position of key
|
---|
| 581 | * \param logscale axis for logscale
|
---|
| 582 | * \param mxtics small tics at ...
|
---|
| 583 | * \param xtics large tics at ...
|
---|
| 584 | * \param xlabel label for x axis
|
---|
| 585 | * \param xlabel label for x axis
|
---|
| 586 | * \param *xrange xrange
|
---|
| 587 | * \param *yrange yrange
|
---|
| 588 | * \param *xargument number of column to plot against (x axis)
|
---|
| 589 | * \param uses using string for plot command
|
---|
| 590 | * \param (*CreatePlotLines) function reference that writes a single plot line
|
---|
| 591 | * \return true if file was written successfully
|
---|
| 592 | */
|
---|
| 593 | 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 *))
|
---|
| 594 | {
|
---|
| 595 | stringstream filename;
|
---|
| 596 | ofstream output;
|
---|
| 597 |
|
---|
| 598 | filename << prefix << ".pyx";
|
---|
| 599 | if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
|
---|
| 600 | CreatePlotHeader(output, prefix, keycolumns, key, logscale, extraline, mxtics, xtics, xlabel, ylabel);
|
---|
| 601 | output << "plot " << xrange << " " << yrange << " \\" << endl;
|
---|
| 602 | CreatePlotLines(output, Matrix, prefix, xargument, uses);
|
---|
| 603 | output.close();
|
---|
| 604 | return true;
|
---|
| 605 | };
|
---|
| 606 |
|
---|
| 607 | /** Writes plot lines for absolute energies.
|
---|
| 608 | * \param output file handler
|
---|
| 609 | * \param Energy MatrixContainer with matrix values
|
---|
| 610 | * \param *prefix prefix of data file
|
---|
| 611 | * \param *xargument number of column to plot against (x axis)
|
---|
| 612 | * \param *uses uses command
|
---|
| 613 | */
|
---|
| 614 | void AbsEnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses)
|
---|
| 615 | {
|
---|
[eeec8f] | 616 | stringstream line(Energy.Header[ Energy.MatrixCounter ]);
|
---|
[fb9364] | 617 | string token;
|
---|
[14de469] | 618 |
|
---|
[fb9364] | 619 | getline(line, token, '\t');
|
---|
[f731ae] | 620 | for (int i=2; i<= Energy.ColumnCounter[Energy.MatrixCounter];i++) {
|
---|
[fb9364] | 621 | getline(line, token, '\t');
|
---|
| 622 | while (token[0] == ' ') // remove leading white spaces
|
---|
| 623 | token.erase(0,1);
|
---|
| 624 | output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(abs($" << i+2 << ")) " << uses;
|
---|
[f731ae] | 625 | if (i != (Energy.ColumnCounter[Energy.MatrixCounter]))
|
---|
[14de469] | 626 | output << ", \\";
|
---|
| 627 | output << endl;
|
---|
| 628 | }
|
---|
| 629 | };
|
---|
| 630 |
|
---|
| 631 | /** Writes plot lines for energies.
|
---|
| 632 | * \param output file handler
|
---|
| 633 | * \param Energy MatrixContainer with matrix values
|
---|
| 634 | * \param *prefix prefix of data file
|
---|
| 635 | * \param *xargument number of column to plot against (x axis)
|
---|
| 636 | * \param *uses uses command
|
---|
| 637 | */
|
---|
| 638 | void EnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses)
|
---|
| 639 | {
|
---|
[eeec8f] | 640 | stringstream line(Energy.Header[Energy.MatrixCounter]);
|
---|
[fb9364] | 641 | string token;
|
---|
| 642 |
|
---|
| 643 | getline(line, token, '\t');
|
---|
[f731ae] | 644 | for (int i=1; i<= Energy.ColumnCounter[Energy.MatrixCounter];i++) {
|
---|
[fb9364] | 645 | getline(line, token, '\t');
|
---|
| 646 | while (token[0] == ' ') // remove leading white spaces
|
---|
| 647 | token.erase(0,1);
|
---|
| 648 | output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":" << i+2 << " " << uses;
|
---|
[f731ae] | 649 | if (i != (Energy.ColumnCounter[Energy.MatrixCounter]))
|
---|
[14de469] | 650 | output << ", \\";
|
---|
| 651 | output << endl;
|
---|
| 652 | }
|
---|
| 653 | };
|
---|
| 654 |
|
---|
| 655 | /** Writes plot lines for absolute force magnitudes.
|
---|
| 656 | * \param output file handler
|
---|
| 657 | * \param Force MatrixContainer with matrix values
|
---|
| 658 | * \param *prefix prefix of data file
|
---|
| 659 | * \param *xargument number of column to plot against (x axis)
|
---|
| 660 | * \param *uses uses command
|
---|
| 661 | */
|
---|
| 662 | void ForceMagnitudePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
|
---|
| 663 | {
|
---|
[eeec8f] | 664 | stringstream line(Force.Header[Force.MatrixCounter]);
|
---|
[fb9364] | 665 | string token;
|
---|
[14de469] | 666 |
|
---|
[fb9364] | 667 | getline(line, token, '\t');
|
---|
| 668 | getline(line, token, '\t');
|
---|
| 669 | getline(line, token, '\t');
|
---|
| 670 | getline(line, token, '\t');
|
---|
| 671 | getline(line, token, '\t');
|
---|
[f731ae] | 672 | for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
|
---|
[fb9364] | 673 | getline(line, token, '\t');
|
---|
| 674 | while (token[0] == ' ') // remove leading white spaces
|
---|
| 675 | token.erase(0,1);
|
---|
| 676 | token.erase(token.length(), 1); // kill residual index char (the '0')
|
---|
| 677 | output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(sqrt($" << i+1 << "*$" << i+1 << "+$" << i+2 << "*$" << i+2 << "+$" << i+3 << "*$" << i+3 << ")) " << uses;
|
---|
[f731ae] | 678 | if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
|
---|
[14de469] | 679 | output << ", \\";
|
---|
| 680 | output << endl;
|
---|
[fb9364] | 681 | getline(line, token, '\t');
|
---|
| 682 | getline(line, token, '\t');
|
---|
[14de469] | 683 | }
|
---|
| 684 | };
|
---|
| 685 |
|
---|
| 686 | /** Writes plot lines for first component of force vector.
|
---|
| 687 | * \param output file handler
|
---|
| 688 | * \param Force MatrixContainer with matrix values
|
---|
| 689 | * \param *prefix prefix of data file
|
---|
| 690 | * \param *xargument number of column to plot against (x axis)
|
---|
| 691 | * \param *uses uses command
|
---|
| 692 | */
|
---|
| 693 | void AbsFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
|
---|
| 694 | {
|
---|
[eeec8f] | 695 | stringstream line(Force.Header[Force.MatrixCounter]);
|
---|
[fb9364] | 696 | string token;
|
---|
[14de469] | 697 |
|
---|
[fb9364] | 698 | getline(line, token, '\t');
|
---|
| 699 | getline(line, token, '\t');
|
---|
| 700 | getline(line, token, '\t');
|
---|
| 701 | getline(line, token, '\t');
|
---|
| 702 | getline(line, token, '\t');
|
---|
[f731ae] | 703 | for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
|
---|
[fb9364] | 704 | getline(line, token, '\t');
|
---|
| 705 | while (token[0] == ' ') // remove leading white spaces
|
---|
| 706 | token.erase(0,1);
|
---|
| 707 | token.erase(token.length(), 1); // kill residual index char (the '0')
|
---|
| 708 | output << "'" << prefix << ".dat' title '" << token << "' using " << xargument << ":(abs($" << i+1 << ")) " << uses;
|
---|
[f731ae] | 709 | if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
|
---|
[14de469] | 710 | output << ", \\";
|
---|
| 711 | output << endl;
|
---|
[fb9364] | 712 | getline(line, token, '\t');
|
---|
| 713 | getline(line, token, '\t');
|
---|
[14de469] | 714 | }
|
---|
| 715 | };
|
---|
| 716 |
|
---|
| 717 | /** Writes plot lines for force vector as boxes with a fillcolor.
|
---|
| 718 | * \param output file handler
|
---|
| 719 | * \param Force MatrixContainer with matrix values
|
---|
| 720 | * \param *prefix prefix of data file
|
---|
| 721 | * \param *xargument number of column to plot against (x axis)
|
---|
| 722 | * \param *uses uses command
|
---|
| 723 | */
|
---|
| 724 | void BoxesForcePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
|
---|
| 725 | {
|
---|
[eeec8f] | 726 | stringstream line(Force.Header[Force.MatrixCounter]);
|
---|
[14de469] | 727 | char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
|
---|
[fb9364] | 728 | string token;
|
---|
[14de469] | 729 |
|
---|
[fb9364] | 730 | getline(line, token, '\t');
|
---|
| 731 | getline(line, token, '\t');
|
---|
| 732 | getline(line, token, '\t');
|
---|
| 733 | getline(line, token, '\t');
|
---|
| 734 | getline(line, token, '\t');
|
---|
[f731ae] | 735 | for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
|
---|
[fb9364] | 736 | getline(line, token, '\t');
|
---|
| 737 | while (token[0] == ' ') // remove leading white spaces
|
---|
| 738 | token.erase(0,1);
|
---|
| 739 | token.erase(token.length(), 1); // kill residual index char (the '0')
|
---|
| 740 | 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] | 741 | if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
|
---|
[14de469] | 742 | output << ", \\";
|
---|
| 743 | output << endl;
|
---|
[fb9364] | 744 | getline(line, token, '\t');
|
---|
| 745 | getline(line, token, '\t');
|
---|
[14de469] | 746 | }
|
---|
| 747 | };
|
---|
| 748 |
|
---|
| 749 | /** Writes plot lines for first force vector component as boxes with a fillcolor.
|
---|
| 750 | * \param output file handler
|
---|
| 751 | * \param Force MatrixContainer with matrix values
|
---|
| 752 | * \param *prefix prefix of data file
|
---|
| 753 | * \param *xargument number of column to plot against (x axis)
|
---|
| 754 | * \param *uses uses command
|
---|
| 755 | */
|
---|
| 756 | void BoxesFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
|
---|
| 757 | {
|
---|
[eeec8f] | 758 | stringstream line(Force.Header[Force.MatrixCounter]);
|
---|
[14de469] | 759 | char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
|
---|
[fb9364] | 760 | string token;
|
---|
[14de469] | 761 |
|
---|
[fb9364] | 762 | getline(line, token, '\t');
|
---|
| 763 | getline(line, token, '\t');
|
---|
| 764 | getline(line, token, '\t');
|
---|
| 765 | getline(line, token, '\t');
|
---|
| 766 | getline(line, token, '\t');
|
---|
[f731ae] | 767 | for (int i=7; i< Force.ColumnCounter[Force.MatrixCounter];i+=NDIM) {
|
---|
[fb9364] | 768 | getline(line, token, '\t');
|
---|
| 769 | while (token[0] == ' ') // remove leading white spaces
|
---|
| 770 | token.erase(0,1);
|
---|
| 771 | token.erase(token.length(), 1); // kill residual index char (the '0')
|
---|
| 772 | output << "'" << prefix << ".dat' title '" << token << "' using ($" << xargument << "+" << fixed << setprecision(1) << (double)((i-7)/3)*0.2 << "):" << i+1 << " " << uses << " " << fillcolor[(i-7)/3];
|
---|
[f731ae] | 773 | if (i != (Force.ColumnCounter[Force.MatrixCounter]-1))
|
---|
[14de469] | 774 | output << ", \\";
|
---|
| 775 | output << endl;
|
---|
[fb9364] | 776 | getline(line, token, '\t');
|
---|
| 777 | getline(line, token, '\t');
|
---|
[14de469] | 778 | }
|
---|
| 779 | };
|
---|