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