source: src/datacreator.cpp@ d2a294

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since d2a294 was 14de469, checked in by Frederik Heber <heber@…>, 17 years ago

-initial commit
-Minimum set of files needed from ESPACK SVN repository
-Switch to three tantamount package parts instead of all relating to pcp (as at some time Ralf's might find inclusion as well)

  • Property mode set to 100644
File size: 21.0 KB
RevLine 
[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 */
19bool OpenOutputFile(ofstream &output, const char *dir, const char *filename)
20{
21 stringstream name;
22 name << dir << "/" << filename;
23 output.open(name.str().c_str(), ios::out);
24 if (output == NULL) {
25 cout << "Unable to open " << name.str() << " for writing, is directory correct?" << endl;
26 return false;
27 }
28 return true;
29};
30
31/** Plots an energy vs. order.
32 * \param Energy EnergyMatrix class containing matrix values (last matrix is created by summing over Fragments)
33 * \param EnergyFragments EnergyMatrix class containing matrix values
34 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order
35 * \param *prefix prefix in filename (without ending)
36 * \param *msg message to be place in first line as a comment
37 * \return true if file was written successfully
38 */
39bool CreateDataEnergyOrder(class MatrixContainer &Energy, class MatrixContainer &EnergyFragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum)
40{
41 stringstream filename;
42 ofstream output;
43
44 filename << prefix << ".dat";
45 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
46 cout << msg << endl;
47 output << "# " << msg << ", created on " << datum;
48 output << "#Order\tFrag.No.\t" << Energy.Header << endl;
49 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
50 for(int i=0;i<KeySet.FragmentsPerOrder[BondOrder];i++) {
51 for(int j=0;j<Energy.RowCounter[ KeySet.OrderSet[BondOrder][i] ];j++)
52 for(int k=0;k<Energy.ColumnCounter;k++)
53 Energy.Matrix[Energy.MatrixCounter][j][k] -= EnergyFragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
54 }
55 output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
56 for (int l=0;l<Energy.ColumnCounter;l++)
57 if (fabs(EnergyFragments.Matrix[EnergyFragments.MatrixCounter][ EnergyFragments.RowCounter[EnergyFragments.MatrixCounter]-1 ][l]) < MYEPSILON)
58 output << scientific << "\t" << Energy.Matrix[Energy.MatrixCounter][ Energy.RowCounter[Energy.MatrixCounter]-1 ][l];
59 else
60 output << scientific << "\t" << (Energy.Matrix[Energy.MatrixCounter][ Energy.RowCounter[Energy.MatrixCounter]-1 ][l] / EnergyFragments.Matrix[EnergyFragments.MatrixCounter][ EnergyFragments.RowCounter[EnergyFragments.MatrixCounter]-1 ][l]);
61 output << endl;
62 }
63 output.close();
64 return true;
65};
66
67/** Plot forces vs. order.
68 */
69bool CreateDataForcesOrder(class MatrixContainer &Force, class MatrixContainer &ForceFragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateForce)(class MatrixContainer &, int))
70{
71 stringstream filename;
72 ofstream output;
73
74 filename << prefix << ".dat";
75 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
76 cout << msg << endl;
77 output << "# " << msg << ", created on " << datum;
78 output << "# Order\tFrag.No.\t" << Force.Header << endl;
79 for(int j=0;j<=Force.RowCounter[ Force.MatrixCounter ];j++)
80 for(int k=0;k<Force.ColumnCounter;k++)
81 Force.Matrix[Force.MatrixCounter][j][k] = 0.;
82 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
83 for(int i=0;i<KeySet.FragmentsPerOrder[BondOrder];i++) {
84 for(int l=0;l<Force.RowCounter[ KeySet.OrderSet[BondOrder][i] ];l++) {
85 int j = Force.Indices[ KeySet.OrderSet[BondOrder][i] ][l];
86 if (j > Force.RowCounter[Force.MatrixCounter]) {
87 cerr << "Current force index " << j << " is greater than " << Force.RowCounter[Force.MatrixCounter] << "!" << endl;
88 return 1;
89 }
90 if (j != -1)
91 for(int k=0;k<Force.ColumnCounter;k++) {
92 Force.Matrix[Force.MatrixCounter][j][k] += ForceFragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][l][k];
93 }
94 }
95 }
96 output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
97 CreateForce(Force, Force.MatrixCounter);
98 for (int l=0;l<Force.ColumnCounter;l++)
99 output << scientific << "\t" << Force.Matrix[Force.MatrixCounter][ Force.RowCounter[Force.MatrixCounter] ][l];
100 output << endl;
101 }
102 output.close();
103 return true;
104};
105
106/** Plot matrix vs. fragment.
107 */
108bool CreateDataFragment(class MatrixContainer &Fragment, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateFragment)(class MatrixContainer &, int))
109{
110 stringstream filename;
111 ofstream output;
112
113 filename << prefix << ".dat";
114 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
115 cout << msg << endl;
116 output << "# " << msg << ", created on " << datum;
117 output << "#Order\tFrag.No.\t" << Fragment.Header << endl;
118 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
119 for(int i=0;i<KeySet.FragmentsPerOrder[BondOrder];i++) {
120 output << BondOrder+1 << "\t" << KeySet.OrderSet[BondOrder][i]+1;
121 CreateFragment(Fragment, KeySet.OrderSet[BondOrder][i]);
122 for (int l=0;l<Fragment.ColumnCounter;l++)
123 output << scientific << "\t" << Fragment.Matrix[ KeySet.OrderSet[BondOrder][i] ][ Fragment.RowCounter[ KeySet.OrderSet[BondOrder][i] ] ][l];
124 output << endl;
125 }
126 }
127 output.close();
128 return true;
129};
130
131/** Copies fragment energy values into last matrix of \a Matrix with greatest total energy.
132 * \param &Matrix MatrixContainer with all fragment energy values
133 * \param &KeySet KeySetsContainer with associations of each fragment to a bond order
134 * \param BondOrder current bond order
135 */
136void CreateMaxFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySet, int BondOrder)
137{
138 for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
139 for(int i=0;i<KeySet.FragmentsPerOrder[BondOrder];i++) {
140 if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < fabs(Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][1])) {
141 for (int k=0;k<Fragments.ColumnCounter;k++)
142 Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
143 }
144 }
145 }
146};
147
148/** Copies fragment energy values into last matrix of \a Matrix with smallest total energy.
149 * \param &Matrix MatrixContainer with all fragment energy values
150 * \param &KeySet KeySetsContainer with associations of each fragment to a bond order
151 * \param BondOrder current bond order
152 */
153void CreateMinFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySet, int BondOrder)
154{
155 for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
156 int i=0;
157 do { // first get a minimum value unequal to 0
158 for (int k=0;k<Fragments.ColumnCounter;k++)
159 Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
160 i++;
161 } while ((fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) < MYEPSILON) && (i<KeySet.FragmentsPerOrder[BondOrder]));
162 for(;i<KeySet.FragmentsPerOrder[BondOrder];i++) { // then find lowest
163 if (fabs(Fragments.Matrix[ Fragments.MatrixCounter ][j][1]) > fabs(Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][1])) {
164 for (int k=0;k<Fragments.ColumnCounter;k++)
165 Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
166 }
167 }
168 }
169};
170
171/** Plot matrix vs. fragment.
172 */
173bool CreateDataFragmentOrder(class MatrixContainer &Fragment, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateFragmentOrder)(class MatrixContainer &, class KeySetsContainer &, int))
174{
175 stringstream filename;
176 ofstream output;
177
178 filename << prefix << ".dat";
179 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
180 cout << msg << endl;
181 output << "# " << msg << ", created on " << datum;
182 output << "#Order\tFrag.No.\t" << Fragment.Header << endl;
183 // max
184 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
185 Fragment.SetLastMatrix(0.,0);
186 CreateFragmentOrder(Fragment, KeySet, BondOrder);
187 output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];
188 for (int l=0;l<Fragment.ColumnCounter;l++)
189 output << scientific << "\t" << Fragment.Matrix[ Fragment.MatrixCounter ][ Fragment.RowCounter[ Fragment.MatrixCounter ]-1 ][l];
190 output << endl;
191 }
192 output.close();
193 return true;
194};
195
196/** Takes last but one row and copies into final row.
197 * \param Energy MatrixContainer with matrix values
198 * \param MatrixNumber the index for the ForceMatrix::matrix array
199 */
200void CreateEnergy(class MatrixContainer &Energy, int MatrixNumber)
201{
202 for(int k=0;k<Energy.ColumnCounter;k++)
203 Energy.Matrix[MatrixNumber][ Energy.RowCounter[MatrixNumber] ] [k] = Energy.Matrix[MatrixNumber][ Energy.RowCounter[MatrixNumber]-1 ] [k];
204};
205
206/** Scans forces for the minimum in magnitude.
207 * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force.
208 * \param Force ForceMatrix class containing matrix values
209 * \param MatrixNumber the index for the ForceMatrix::matrix array
210 */
211void CreateMinimumForce(class MatrixContainer &Force, int MatrixNumber)
212{
213 for (int l=0;l<Force.ColumnCounter;l++)
214 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
215 for (int l=5;l<Force.ColumnCounter;l+=3) {
216 double stored = 0;
217 int k=0;
218 do {
219 for (int m=0;m<3;m++) {
220 stored += Force.Matrix[MatrixNumber][ k ][l+m]
221 * Force.Matrix[MatrixNumber][ k ][l+m];
222 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m] = Force.Matrix[MatrixNumber][ k ][l+m];
223 }
224 k++;
225 } while ((fabs(stored) < MYEPSILON) && (k<Force.RowCounter[MatrixNumber]));
226 for (;k<Force.RowCounter[MatrixNumber];k++) {
227 double tmp = 0;
228 for (int m=0;m<3;m++)
229 tmp += Force.Matrix[MatrixNumber][ k ][l+m]
230 * Force.Matrix[MatrixNumber][ k ][l+m];
231 if ((fabs(tmp) > MYEPSILON) && (tmp < stored)) { // current force is greater than stored
232 for (int m=0;m<3;m++)
233 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m] = Force.Matrix[MatrixNumber][ k ][l+m];
234 stored = tmp;
235 }
236 }
237 }
238};
239
240/** Scans forces for the mean in magnitude.
241 * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force.
242 * \param Force ForceMatrix class containing matrix values
243 * \param MatrixNumber the index for the ForceMatrix::matrix array
244 */
245void CreateMeanForce(class MatrixContainer &Force, int MatrixNumber)
246{
247 int divisor = 0;
248 for (int l=0;l<Force.ColumnCounter;l++)
249 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
250 for (int l=5;l<Force.ColumnCounter;l+=3) {
251 double tmp = 0;
252 for (int k=0;k<Force.RowCounter[MatrixNumber];k++) {
253 double norm = 0.;
254 for (int m=0;m<3;m++)
255 norm += Force.Matrix[MatrixNumber][ k ][l+m]
256 * Force.Matrix[MatrixNumber][ k ][l+m];
257 tmp += sqrt(norm);
258 if (fabs(norm) > MYEPSILON) divisor++;
259 }
260 tmp /= (double)divisor;
261 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = tmp;
262 }
263};
264
265/** Scans forces for the maximum in magnitude.
266 * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force.
267 * \param Force ForceMatrix class containing matrix values
268 * \param MatrixNumber the index for the ForceMatrix::matrix array
269 */
270void CreateMaximumForce(class MatrixContainer &Force, int MatrixNumber)
271{
272 for (int l=5;l<Force.ColumnCounter;l+=3) {
273 double stored = 0;
274 for (int k=0;k<Force.RowCounter[MatrixNumber];k++) {
275 double tmp = 0;
276 for (int m=0;m<3;m++)
277 tmp += Force.Matrix[MatrixNumber][ k ][l+m]
278 * Force.Matrix[MatrixNumber][ k ][l+m];
279 if (tmp > stored) { // current force is greater than stored
280 for (int m=0;m<3;m++)
281 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m] = Force.Matrix[MatrixNumber][ k ][l+m];
282 stored = tmp;
283 }
284 }
285 }
286};
287
288/** Adds vectorwise all forces.
289 * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force.
290 * \param Force ForceMatrix class containing matrix values
291 * \param MatrixNumber the index for the ForceMatrix::matrix array
292 */
293void CreateVectorSumForce(class MatrixContainer &Force, int MatrixNumber)
294{
295 for (int l=0;l<Force.ColumnCounter;l++)
296 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.;
297 for (int l=5;l<Force.ColumnCounter;l++) {
298 for (int k=0;k<Force.RowCounter[MatrixNumber];k++)
299 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] += Force.Matrix[MatrixNumber][k][l];
300 }
301};
302
303/** Writes the standard pyxplot header info.
304 * \param keycolumns number of columns of the key
305 * \param *key position of key
306 * \param *logscale axis for logscale
307 * \param *extraline extra set lines if desired
308 * \param mxtics small tics at ...
309 * \param xtics large tics at ...
310 * \param *xlabel label for x axis
311 * \param *ylabel label for y axis
312 */
313void 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)
314{
315 //output << "#!/home/heber/build/pyxplot/pyxplot" << endl << endl;
316 output << "reset" << endl;
317 output << "set keycolumns "<< keycolumns << endl;
318 output << "set key " << key << endl;
319 output << "set mxtics "<< mxtics << endl;
320 output << "set xtics "<< xtics << endl;
321 if (logscale != "")
322 output << "set logscale " << logscale << endl;
323 if (extraline != "")
324 output << extraline << endl;
325 output << "set xlabel '" << xlabel << "'" << endl;
326 output << "set ylabel '" << ylabel << "'" << endl;
327 output << "set terminal eps color" << endl;
328 output << "set output '"<< prefix << ".eps'" << endl;
329};
330
331/** Creates the pyxplotfile for energy data.
332 * \param Matrix MatrixContainer with matrix values
333 * \param KeySet contains bond order
334 * \param *dir directory
335 * \param *prefix prefix for all filenames (without ending)
336 * \param keycolumns number of columns of the key
337 * \param *key position of key
338 * \param logscale axis for logscale
339 * \param mxtics small tics at ...
340 * \param xtics large tics at ...
341 * \param xlabel label for x axis
342 * \param xlabel label for x axis
343 * \param *xrange xrange
344 * \param *yrange yrange
345 * \param *xargument number of column to plot against (x axis)
346 * \param uses using string for plot command
347 * \param (*CreatePlotLines) function reference that writes a single plot line
348 * \return true if file was written successfully
349 */
350bool 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 *))
351{
352 stringstream filename;
353 ofstream output;
354
355 filename << prefix << ".pyx";
356 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
357 CreatePlotHeader(output, prefix, keycolumns, key, logscale, extraline, mxtics, xtics, xlabel, ylabel);
358 output << "plot " << xrange << " " << yrange << " \\" << endl;
359 CreatePlotLines(output, Matrix, prefix, xargument, uses);
360 output.close();
361 return true;
362};
363
364/** Writes plot lines for absolute energies.
365 * \param output file handler
366 * \param Energy MatrixContainer with matrix values
367 * \param *prefix prefix of data file
368 * \param *xargument number of column to plot against (x axis)
369 * \param *uses uses command
370 */
371void AbsEnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses)
372{
373 char item[1024];
374 stringstream line(Energy.Header);
375
376 line >> item;
377 for (int i=3; i< Energy.ColumnCounter;i++) {
378 line >> item;
379 output << "'" << prefix << ".dat' title '" << item << "' using " << xargument << ":(abs($" << i+1 << ")) " << uses;
380 if (i != (Energy.ColumnCounter-1))
381 output << ", \\";
382 output << endl;
383 }
384};
385
386/** Writes plot lines for energies.
387 * \param output file handler
388 * \param Energy MatrixContainer with matrix values
389 * \param *prefix prefix of data file
390 * \param *xargument number of column to plot against (x axis)
391 * \param *uses uses command
392 */
393void EnergyPlotLine(ofstream &output, class MatrixContainer &Energy, const char *prefix, const char *xargument, const char *uses)
394{
395 char item[1024];
396 stringstream line(Energy.Header);
397
398 line >> item;
399 for (int i=3; i< Energy.ColumnCounter;i++) {
400 line >> item;
401 output << "'" << prefix << ".dat' title '" << item << "' using " << xargument << ":" << i+1 << " " << uses;
402 if (i != (Energy.ColumnCounter-1))
403 output << ", \\";
404 output << endl;
405 }
406};
407
408/** Writes plot lines for absolute force magnitudes.
409 * \param output file handler
410 * \param Force MatrixContainer with matrix values
411 * \param *prefix prefix of data file
412 * \param *xargument number of column to plot against (x axis)
413 * \param *uses uses command
414 */
415void ForceMagnitudePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
416{
417 char item[1024];
418 stringstream line(Force.Header);
419
420 line >> item;
421 line >> item;
422 line >> item;
423 line >> item;
424 line >> item;
425 for (int i=7; i< Force.ColumnCounter;i+=3) {
426 line >> item;
427 item[strlen(item)-1] = '\0'; // kill residual index char (the '0')
428 output << "'" << prefix << ".dat' title '" << item << "' using " << xargument << ":(sqrt($" << i+1 << "*$" << i+1 << "+$" << i+2 << "*$" << i+2 << "+$" << i+3 << "*$" << i+3 << ")) " << uses;
429 if (i != (Force.ColumnCounter-1))
430 output << ", \\";
431 output << endl;
432 line >> item;
433 line >> item;
434 }
435};
436
437/** Writes plot lines for first component of force vector.
438 * \param output file handler
439 * \param Force MatrixContainer with matrix values
440 * \param *prefix prefix of data file
441 * \param *xargument number of column to plot against (x axis)
442 * \param *uses uses command
443 */
444void AbsFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
445{
446 char item[1024];
447 stringstream line(Force.Header);
448
449 line >> item;
450 line >> item;
451 line >> item;
452 line >> item;
453 line >> item;
454 for (int i=7; i< Force.ColumnCounter;i+=3) {
455 line >> item;
456 item[strlen(item)-1] = '\0'; // kill residual index char (the '0')
457 output << "'" << prefix << ".dat' title '" << item << "' using " << xargument << ":(abs($" << i+1 << ")) " << uses;
458 if (i != (Force.ColumnCounter-1))
459 output << ", \\";
460 output << endl;
461 line >> item;
462 line >> item;
463 }
464};
465
466/** Writes plot lines for force vector as boxes with a fillcolor.
467 * \param output file handler
468 * \param Force MatrixContainer with matrix values
469 * \param *prefix prefix of data file
470 * \param *xargument number of column to plot against (x axis)
471 * \param *uses uses command
472 */
473void BoxesForcePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
474{
475 char item[1024];
476 stringstream line(Force.Header);
477 char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
478
479 line >> item;
480 line >> item;
481 line >> item;
482 line >> item;
483 line >> item;
484 for (int i=7; i< Force.ColumnCounter;i+=3) {
485 line >> item;
486 item[strlen(item)-1] = '\0'; // kill residual index char (the '0')
487 output << "'" << prefix << ".dat' title '" << item << "' 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];
488 if (i != (Force.ColumnCounter-1))
489 output << ", \\";
490 output << endl;
491 line >> item;
492 line >> item;
493 }
494};
495
496/** Writes plot lines for first force vector component as boxes with a fillcolor.
497 * \param output file handler
498 * \param Force MatrixContainer with matrix values
499 * \param *prefix prefix of data file
500 * \param *xargument number of column to plot against (x axis)
501 * \param *uses uses command
502 */
503void BoxesFirstForceValuePlotLine(ofstream &output, class MatrixContainer &Force, const char *prefix, const char *xargument, const char *uses)
504{
505 char item[1024];
506 stringstream line(Force.Header);
507 char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
508
509 line >> item;
510 line >> item;
511 line >> item;
512 line >> item;
513 line >> item;
514 for (int i=7; i< Force.ColumnCounter;i+=3) {
515 line >> item;
516 item[strlen(item)-1] = '\0'; // kill residual index char (the '0')
517 output << "'" << prefix << ".dat' title '" << item << "' using ($" << xargument << "+" << fixed << setprecision(1) << (double)((i-7)/3)*0.2 << "):" << i+1 << " " << uses << " " << fillcolor[(i-7)/3];
518 if (i != (Force.ColumnCounter-1))
519 output << ", \\";
520 output << endl;
521 line >> item;
522 line >> item;
523 }
524};
Note: See TracBrowser for help on using the repository browser.