source: src/analyzer.cpp@ a98603

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 a98603 was a98603, checked in by Frederik Heber <heber@…>, 16 years ago

Merge ../espack3

  • Property mode set to 100755
File size: 29.2 KB
Line 
1/** \file analyzer.cpp
2 *
3 * Takes evaluated fragments (energy and forces) and does evaluation of how sensible the BOSSANOVA
4 * approach was, e.g. in the decay of the many-body-contributions.
5 *
6 */
7
8//============================ INCLUDES ===========================
9
10#include "datacreator.hpp"
11#include "helpers.hpp"
12#include "parser.hpp"
13#include "periodentafel.hpp"
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20
21//============================== MAIN =============================
22
23int main(int argc, char **argv)
24{
25 periodentafel *periode = NULL; // and a period table of all elements
26 EnergyMatrix Energy;
27 EnergyMatrix Hcorrection;
28 ForceMatrix Force;
29 ForceMatrix Shielding;
30 ForceMatrix ShieldingPAS;
31 ForceMatrix Chi;
32 ForceMatrix ChiPAS;
33 EnergyMatrix Time;
34 EnergyMatrix EnergyFragments;
35 EnergyMatrix HcorrectionFragments;
36 ForceMatrix ForceFragments;
37 ForceMatrix ShieldingFragments;
38 ForceMatrix ShieldingPASFragments;
39 ForceMatrix ChiFragments;
40 ForceMatrix ChiPASFragments;
41 KeySetsContainer KeySet;
42 ofstream output;
43 ofstream output2;
44 ofstream output3;
45 ofstream output4;
46 ifstream input;
47 stringstream filename;
48 time_t t = time(NULL);
49 struct tm *ts = localtime(&t);
50 char *datum = asctime(ts);
51 stringstream Orderxrange;
52 stringstream Fragmentxrange;
53 stringstream yrange;
54 char *dir = NULL;
55 bool Hcorrected = true;
56 double norm;
57 int counter;
58
59 cout << "ANOVA Analyzer" << endl;
60 cout << "==============" << endl;
61
62 // Get the command line options
63 if (argc < 4) {
64 cout << "Usage: " << argv[0] << " <inputdir> <prefix> <outputdir> [elementsdb]" << endl;
65 cout << "<inputdir>\ttherein the output of a molecuilder fragmentation is expected, each fragment with a subdir containing an energy.all and a forces.all file." << endl;
66 cout << "<prefix>\tprefix of energy and forces file." << endl;
67 cout << "<outputdir>\tcreated plotfiles and datafiles are placed into this directory " << endl;
68 cout << "[elementsdb]\tpath to elements database, needed for shieldings." << endl;
69 return 1;
70 } else {
71 dir = (char *) Malloc(sizeof(char)*(strlen(argv[2])+2), "main: *dir");
72 strcpy(dir, "/");
73 strcat(dir, argv[2]);
74 }
75
76 if (argc > 4) {
77 cout << "Loading periodentafel." << endl;
78 periode = new periodentafel;
79 periode->LoadPeriodentafel(argv[4]);
80 }
81
82 // Test the given directory
83 if (!TestParams(argc, argv))
84 return 1;
85
86 // +++++++++++++++++ PARSING +++++++++++++++++++++++++++++++
87
88 // ------------- Parse through all Fragment subdirs --------
89 if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix,0,0)) return 1;
90 Hcorrected = Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX,0,0);
91 if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix,0,0)) return 1;
92 if (!Time.ParseFragmentMatrix(argv[1], dir, TimeSuffix, 10,1)) return 1;
93 if (periode != NULL) { // also look for PAS values
94 if (!Shielding.ParseFragmentMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1;
95 if (!ShieldingPAS.ParseFragmentMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1;
96 if (!Chi.ParseFragmentMatrix(argv[1], dir, ChiSuffix, 1, 0)) return 1;
97 if (!ChiPAS.ParseFragmentMatrix(argv[1], dir, ChiPASSuffix, 1, 0)) return 1;
98 }
99
100 // ---------- Parse the TE Factors into an array -----------------
101 if (!Energy.ParseIndices()) return 1;
102 if (Hcorrected) Hcorrection.ParseIndices();
103
104 // ---------- Parse the Force indices into an array ---------------
105 if (!Force.ParseIndices(argv[1])) return 1;
106 if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1;
107 if (!ForceFragments.ParseIndices(argv[1])) return 1;
108
109 // ---------- Parse the shielding indices into an array ---------------
110 if (periode != NULL) { // also look for PAS values
111 if(!Shielding.ParseIndices(argv[1])) return 1;
112 if(!ShieldingPAS.ParseIndices(argv[1])) return 1;
113 if (!ShieldingFragments.AllocateMatrix(Shielding.Header, Shielding.MatrixCounter, Shielding.RowCounter, Shielding.ColumnCounter)) return 1;
114 if (!ShieldingPASFragments.AllocateMatrix(ShieldingPAS.Header, ShieldingPAS.MatrixCounter, ShieldingPAS.RowCounter, ShieldingPAS.ColumnCounter)) return 1;
115 if(!ShieldingFragments.ParseIndices(argv[1])) return 1;
116 if(!ShieldingPASFragments.ParseIndices(argv[1])) return 1;
117 if(!Chi.ParseIndices(argv[1])) return 1;
118 if(!ChiPAS.ParseIndices(argv[1])) return 1;
119 if (!ChiFragments.AllocateMatrix(Chi.Header, Chi.MatrixCounter, Chi.RowCounter, Chi.ColumnCounter)) return 1;
120 if (!ChiPASFragments.AllocateMatrix(ChiPAS.Header, ChiPAS.MatrixCounter, ChiPAS.RowCounter, ChiPAS.ColumnCounter)) return 1;
121 if(!ChiFragments.ParseIndices(argv[1])) return 1;
122 if(!ChiPASFragments.ParseIndices(argv[1])) return 1;
123 }
124
125 // ---------- Parse the KeySets into an array ---------------
126 if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1;
127 if (!KeySet.ParseManyBodyTerms()) return 1;
128
129 // ---------- Parse fragment files created by 'joiner' into an array -------------
130 if (!EnergyFragments.ParseFragmentMatrix(argv[1], dir, EnergyFragmentSuffix,0,0)) return 1;
131 if (Hcorrected) HcorrectionFragments.ParseFragmentMatrix(argv[1], dir, HcorrectionFragmentSuffix,0,0);
132 if (!ForceFragments.ParseFragmentMatrix(argv[1], dir, ForceFragmentSuffix,0,0)) return 1;
133 if (periode != NULL) { // also look for PAS values
134 if (!ShieldingFragments.ParseFragmentMatrix(argv[1], dir, ShieldingFragmentSuffix, 1, 0)) return 1;
135 if (!ShieldingPASFragments.ParseFragmentMatrix(argv[1], dir, ShieldingPASFragmentSuffix, 1, 0)) return 1;
136 if (!ChiFragments.ParseFragmentMatrix(argv[1], dir, ChiFragmentSuffix, 1, 0)) return 1;
137 if (!ChiPASFragments.ParseFragmentMatrix(argv[1], dir, ChiPASFragmentSuffix, 1, 0)) return 1;
138 }
139
140 // +++++++++++++++ TESTING ++++++++++++++++++++++++++++++
141
142 // print energy and forces to file
143 filename.str("");
144 filename << argv[3] << "/" << "energy-forces.all";
145 output.open(filename.str().c_str(), ios::out);
146 output << endl << "Total Energy" << endl << "==============" << endl << Energy.Header << endl;
147 for(int j=0;j<Energy.RowCounter[Energy.MatrixCounter];j++) {
148 for(int k=0;k<Energy.ColumnCounter;k++)
149 output << scientific << Energy.Matrix[ Energy.MatrixCounter ][j][k] << "\t";
150 output << endl;
151 }
152 output << endl;
153
154 output << endl << "Total Forces" << endl << "===============" << endl << Force.Header << endl;
155 for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) {
156 for(int k=0;k<Force.ColumnCounter;k++)
157 output << scientific << Force.Matrix[ Force.MatrixCounter ][j][k] << "\t";
158 output << endl;
159 }
160 output << endl;
161
162 if (periode != NULL) { // also look for PAS values
163 output << endl << "Total Shieldings" << endl << "===============" << endl << Shielding.Header << endl;
164 for(int j=0;j<Shielding.RowCounter[Shielding.MatrixCounter];j++) {
165 for(int k=0;k<Shielding.ColumnCounter;k++)
166 output << scientific << Shielding.Matrix[ Shielding.MatrixCounter ][j][k] << "\t";
167 output << endl;
168 }
169 output << endl;
170
171 output << endl << "Total Shieldings PAS" << endl << "===============" << endl << ShieldingPAS.Header << endl;
172 for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) {
173 for(int k=0;k<ShieldingPAS.ColumnCounter;k++)
174 output << scientific << ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t";
175 output << endl;
176 }
177 output << endl;
178
179 output << endl << "Total Chis" << endl << "===============" << endl << Chi.Header[Hessian.MatrixCounter] << endl;
180 for(int j=0;j<Chi.RowCounter[Chi.MatrixCounter];j++) {
181 for(int k=0;k<Chi.ColumnCounter[Chi.MatrixCounter];k++)
182 output << scientific << Chi.Matrix[ Chi.MatrixCounter ][j][k] << "\t";
183 output << endl;
184 }
185 output << endl;
186
187 output << endl << "Total Chis PAS" << endl << "===============" << endl << ChiPAS.Header[ChiPAS.MatrixCounter] << endl;
188 for(int j=0;j<ChiPAS.RowCounter[ChiPAS.MatrixCounter];j++) {
189 for(int k=0;k<ChiPAS.ColumnCounter[ChiPAS.MatrixCounter];k++)
190 output << scientific << ChiPAS.Matrix[ ChiPAS.MatrixCounter ][j][k] << "\t";
191 output << endl;
192 }
193 output << endl;
194 }
195
196 output << endl << "Total Times" << endl << "===============" << endl << Time.Header << endl;
197 for(int j=0;j<Time.RowCounter[Time.MatrixCounter];j++) {
198 for(int k=0;k<Time.ColumnCounter;k++) {
199 output << scientific << Time.Matrix[ Time.MatrixCounter ][j][k] << "\t";
200 }
201 output << endl;
202 }
203 output << endl;
204 output.close();
205 for(int k=0;k<Time.ColumnCounter;k++)
206 Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k] = Time.Matrix[ Time.MatrixCounter ][Time.RowCounter[Time.MatrixCounter]-1][k];
207
208 // +++++++++++++++ ANALYZING ++++++++++++++++++++++++++++++
209
210 cout << "Analyzing ..." << endl;
211
212 // ======================================= Creating the data files ==============================================================
213
214 // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order
215 // +++++++++++++++++++++++++++++++++++++++ Plotting Delta Simtime vs Bond Order
216 if (!OpenOutputFile(output, argv[3], "SimTime-Order.dat" )) return false;
217 if (!OpenOutputFile(output2, argv[3], "DeltaSimTime-Order.dat" )) return false;
218 for(int j=Time.RowCounter[Time.MatrixCounter];j--;)
219 for(int k=Time.ColumnCounter;k--;) {
220 Time.Matrix[ Time.MatrixCounter ][j][k] = 0.;
221 }
222 counter = 0;
223 output << "#Order\tFrag.No.\t" << Time.Header << endl;
224 output2 << "#Order\tFrag.No.\t" << Time.Header << endl;
225 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
226 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;)
227 for(int j=Time.RowCounter[Time.MatrixCounter];j--;)
228 for(int k=Time.ColumnCounter;k--;) {
229 Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
230 }
231 counter += KeySet.FragmentsPerOrder[BondOrder];
232 output << BondOrder+1 << "\t" << counter;
233 output2 << BondOrder+1 << "\t" << counter;
234 for(int k=0;k<Time.ColumnCounter;k++) {
235 output << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k];
236 if (fabs(Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k]) > MYEPSILON)
237 output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k] / Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k];
238 else
239 output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k];
240 }
241 output << endl;
242 output2 << endl;
243 }
244 output.close();
245 output2.close();
246
247 // +++++++++++++++++++++++++++++++++++++++ Plotting shieldings
248
249 if (periode != NULL) { // also look for PAS values
250 if (!CreateDataDeltaForcesOrderPerAtom(ShieldingPAS, ShieldingPASFragments, KeySet, argv[3], "DeltaShieldingsPAS-Order", "Plot of error between approximated shieldings and full shieldings versus the Bond Order", datum)) return 1;
251 if (!CreateDataForcesOrderPerAtom(ShieldingPASFragments, KeySet, argv[3], "ShieldingsPAS-Order", "Plot of approximated shieldings versus the Bond Order", datum)) return 1;
252 if (!AppendOutputFile(output, argv[3], "ShieldingsPAS-Order.dat" )) return false;
253 output << endl << "# Full" << endl;
254 for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) {
255 output << j << "\t";
256 for(int k=0;k<ShieldingPAS.ColumnCounter;k++)
257 output << scientific << ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t"; //*(((k>1) && (k<6))? 1.e6 : 1.) << "\t";
258 output << endl;
259 }
260 output.close();
261 if (!CreateDataDeltaForcesOrderPerAtom(ChiPAS, ChiPASFragments, KeySet, argv[3], "DeltaChisPAS-Order", "Plot of error between approximated Chis and full Chis versus the Bond Order", datum)) return 1;
262 if (!CreateDataForcesOrderPerAtom(ChiPASFragments, KeySet, argv[3], "ChisPAS-Order", "Plot of approximated Chis versus the Bond Order", datum)) return 1;
263 if (!AppendOutputFile(output, argv[3], "ChisPAS-Order.dat" )) return false;
264 output << endl << "# Full" << endl;
265 for(int j=0;j<ChiPAS.RowCounter[ChiPAS.MatrixCounter];j++) {
266 output << j << "\t";
267 for(int k=0;k<ChiPAS.ColumnCounter[ChiPAS.MatrixCounter];k++)
268 output << scientific << ChiPAS.Matrix[ ChiPAS.MatrixCounter ][j][k] << "\t"; //*(((k>1) && (k<6))? 1.e6 : 1.) << "\t";
269 output << endl;
270 }
271 output.close();
272 }
273
274
275 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM
276 if (!CreateDataDeltaEnergyOrder(Energy, EnergyFragments, KeySet, argv[3], "DeltaEnergies-Order", "Plot of error between approximated and full energies energies versus the Bond Order", datum)) return 1;
277
278 // +++++++++++++++++++++++++++++++++++Plotting Energies vs. Order
279 if (!CreateDataEnergyOrder(EnergyFragments, KeySet, argv[3], "Energies-Order", "Plot of approximated energies versus the Bond Order", datum)) return 1;
280
281 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in forces to full QM
282 if (!CreateDataDeltaForcesOrderPerAtom(Force, ForceFragments, KeySet, argv[3], "DeltaForces-Order", "Plot of error between approximated forces and full forces versus the Bond Order", datum)) return 1;
283
284 // min force
285 if (!CreateDataDeltaForcesOrder(Force, ForceFragments, KeySet, argv[3], "DeltaMinForces-Order", "Plot of min error between approximated forces and full forces versus the Bond Order", datum, CreateMinimumForce)) return 1;
286
287 // mean force
288 if (!CreateDataDeltaForcesOrder(Force, ForceFragments, KeySet, argv[3], "DeltaMeanForces-Order", "Plot of mean error between approximated forces and full forces versus the Bond Order", datum, CreateMeanForce)) return 1;
289
290 // max force
291 if (!CreateDataDeltaForcesOrder(Force, ForceFragments, KeySet, argv[3], "DeltaMaxForces-Order", "Plot of max error between approximated forces and full forces versus the Bond Order", datum, CreateMaximumForce)) return 1;
292
293 // ++++++++++++++++++++++++++++++++++++++Plotting Forces vs. Order
294 if (!CreateDataForcesOrderPerAtom(ForceFragments, KeySet, argv[3], "Forces-Order", "Plot of approximated forces versus the Bond Order", datum)) return 1;
295 if (!AppendOutputFile(output, argv[3], "Forces-Order.dat" )) return false;
296 output << endl << "# Full" << endl;
297 for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) {
298 output << j << "\t";
299 for(int k=0;k<Force.ColumnCounter;k++)
300 output << scientific << Force.Matrix[ Force.MatrixCounter ][j][k] << "\t";
301 output << endl;
302 }
303 output.close();
304 // min force
305 if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "MinForces-Order", "Plot of min approximated forces versus the Bond Order", datum, CreateMinimumForce)) return 1;
306
307 // mean force
308 if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "MeanForces-Order", "Plot of mean approximated forces versus the Bond Order", datum, CreateMeanForce)) return 1;
309
310 // max force
311 if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "MaxForces-Order", "Plot of max approximated forces versus the Bond Order", datum, CreateMaximumForce)) return 1;
312
313 // ++++++++++++++++++++++++++++++++++++++Plotting vector sum (should be 0) vs. bond order
314 if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "VectorSum-Order", "Plot of vector sum of the approximated forces versus the Bond Order", datum, CreateVectorSumForce)) return 1;
315
316 // +++++++++++++++++++++++++++++++Plotting energyfragments vs. order
317 if (!CreateDataFragment(EnergyFragments, KeySet, argv[3], "Energies-Fragment", "Plot of fragment energy versus the Fragment No", datum, CreateEnergy)) return 1;
318 if (!CreateDataFragment(EnergyFragments, KeySet, argv[3], "Energies-FragmentOrder", "Plot of fragment energy of each Fragment No vs. Bond Order", datum, CreateEnergy)) return 1;
319 if (!CreateDataFragmentOrder(EnergyFragments, KeySet, argv[3], "MaxEnergies-FragmentOrder", "Plot of maximum of fragment energy vs. Bond Order", datum, CreateMaxFragmentOrder)) return 1;
320 if (!CreateDataFragmentOrder(EnergyFragments, KeySet, argv[3], "MinEnergies-FragmentOrder", "Plot of minimum of fragment energy vs. Bond Order", datum, CreateMinFragmentOrder)) return 1;
321
322 // +++++++++++++++++++++++++++++++Ploting min/mean/max forces for each fragment
323 // min force
324 if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MinForces-Fragment", "Plot of min approximated forces versus the Fragment No", datum, CreateMinimumForce)) return 1;
325
326 // mean force
327 if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MeanForces-Fragment", "Plot of mean approximated forces versus the Fragment No", datum, CreateMeanForce)) return 1;
328
329 // max force
330 if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MaxForces-Fragment", "Plot of max approximated forces versus the Fragment No", datum, CreateMaximumForce)) return 1;
331
332 // +++++++++++++++++++++++++++++++Ploting min/mean/max forces for each fragment per order
333 // min force
334 if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MinForces-FragmentOrder", "Plot of min approximated forces of each Fragment No vs. Bond Order", datum, CreateMinimumForce)) return 1;
335
336 // mean force
337 if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MeanForces-FragmentOrder", "Plot of mean approximated forces of each Fragment No vs. Bond Order", datum, CreateMeanForce)) return 1;
338
339 // max force
340 if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MaxForces-FragmentOrder", "Plot of max approximated forces of each Fragment No vs. Bond Order", datum, CreateMaximumForce)) return 1;
341
342 // ======================================= Creating the plot files ==============================================================
343
344 Orderxrange << "[1:" << KeySet.Order << "]";
345 Fragmentxrange << "[0:" << KeySet.FragmentCounter+1 << "]";
346 yrange.str("[1e-8:1e+1]");
347
348 // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order
349 if (!CreatePlotOrder(Time, KeySet, argv[3], "SimTime-Order", 1, "below", "y", "", 1, 1, "bond order k", "Evaluation time [s]", Orderxrange.str().c_str(), "", "1" , "with linespoints", EnergyPlotLine)) return 1;
350
351 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM
352 if (!CreatePlotOrder(Energy, KeySet, argv[3], "DeltaEnergies-Order", 1, "outside", "y", "", 1, 1, "bond order k", "absolute error in energy [Ht]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", AbsEnergyPlotLine)) return 1;
353
354 // +++++++++++++++++++++++++++++++++++Plotting Energies vs. Order
355 if (!CreatePlotOrder(Energy, KeySet, argv[3], "Energies-Order", 1, "outside", "", "", 1, 1, "bond order k", "approximate energy [Ht]", Orderxrange.str().c_str(), "", "1" , "with linespoints", EnergyPlotLine)) return 1;
356
357 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in forces to full QM
358 yrange.str("[1e-8:1e+0]");
359 // min force
360 if (!CreatePlotOrder(Force, KeySet, argv[3], "DeltaMinForces-Order", 2, "top right", "y", "", 1, 1, "bond order k", "absolute error in min force [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", ForceMagnitudePlotLine)) return 1;
361
362 // mean force
363 if (!CreatePlotOrder(Force, KeySet, argv[3], "DeltaMeanForces-Order", 2, "top right", "y", "", 1, 1, "bond order k", "absolute error in mean force [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", AbsFirstForceValuePlotLine)) return 1;
364
365 // max force
366 if (!CreatePlotOrder(Force, KeySet, argv[3], "DeltaMaxForces-Order", 2, "top right", "y", "", 1, 1, "bond order k", "absolute error in max force [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", ForceMagnitudePlotLine)) return 1;
367
368 // min/mean/max comparison for total force
369 if(!OpenOutputFile(output, argv[3], "DeltaMinMeanMaxTotalForce-Order.pyx")) return 1;
370 CreatePlotHeader(output, "DeltaMinMeanMaxTotalForce-Order", 1, "bottom left", "y", NULL, 1, 1, "bond order k", "absolute error in total forces [Ht/a.u.]");
371 output << "plot " << Orderxrange.str().c_str() << " [1e-8:1e+0] \\" << endl;
372 output << "'DeltaMinForces-Order.dat' title 'minimum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints, \\" << endl;
373 output << "'DeltaMeanForces-Order.dat' title 'mean' using 1:(abs($" << 8 << ")) with linespoints, \\" << endl;
374 output << "'DeltaMaxForces-Order.dat' title 'maximum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints" << endl;
375 output.close();
376
377 // ++++++++++++++++++++++++++++++++++++++Plotting Forces vs. Order
378 // min force
379 if (!CreatePlotOrder(Force, KeySet, argv[3], "MinForces-Order", 2, "bottom right", "y", "", 1, 1, "bond order k", "absolute approximated min force [Ht/a.u.]", Orderxrange.str().c_str(), "", "1" , "with linespoints", ForceMagnitudePlotLine)) return 1;
380
381 // mean force
382 if (!CreatePlotOrder(Force, KeySet, argv[3], "MeanForces-Order", 2, "bottom right", "y", "", 1, 1, "bond order k", "absolute approximated mean force [Ht/a.u.]", Orderxrange.str().c_str(), "", "1" , "with linespoints", AbsFirstForceValuePlotLine)) return 1;
383
384 // max force
385 if (!CreatePlotOrder(Force, KeySet, argv[3], "MaxForces-Order", 2, "bottom right", "y", "", 1, 1, "bond order k", "absolute approximated max force [Ht/a.u.]", Orderxrange.str().c_str(), "", "1" , "with linespoints", ForceMagnitudePlotLine)) return 1;
386
387 // min/mean/max comparison for total force
388 if(!OpenOutputFile(output, argv[3],"MinMeanMaxTotalForce-Order.pyx")) return 1;
389 CreatePlotHeader(output, "MinMeanMaxTotalForce-Order", 1, "bottom left", "y", NULL, 1, 1, "bond order k", "absolute total force [Ht/a.u.]");
390 output << "plot "<< Orderxrange.str().c_str() << " [1e-8:1e+0] \\" << endl;
391 output << "'MinForces-Order.dat' title 'minimum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints, \\" << endl;
392 output << "'MeanForces-Order.dat' title 'mean' using 1:(abs($" << 8 << ")) with linespoints, \\" << endl;
393 output << "'MaxForces-Order.dat' title 'maximum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints" << endl;
394 output.close();
395
396 // ++++++++++++++++++++++++++++++++++++++Plotting vector sum vs. Order
397
398 if (!CreatePlotOrder(Force, KeySet, argv[3], "VectorSum-Order", 2, "bottom right", "y" ,"", 1, 1, "bond order k", "vector sum of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), "", "1" , "with linespoints", ForceMagnitudePlotLine)) return 1;
399
400 // +++++++++++++++++++++++++++++++Plotting energyfragments vs. order
401 yrange.str("");
402 yrange << "[" << EnergyFragments.FindMinValue() << ":" << EnergyFragments.FindMaxValue() << "]";
403 if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "Energies-Fragment", 5, "below", "y", "", 1, 5, "fragment number", "Energies of each fragment [Ht]", Fragmentxrange.str().c_str(), yrange.str().c_str(), "2" , "with points", AbsEnergyPlotLine)) return 1;
404 if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "Energies-FragmentOrder", 5, "below", "y", "", 1, 1, "bond order", "Energies of each fragment [Ht]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with points", AbsEnergyPlotLine)) return 1;
405 if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "MaxEnergies-FragmentOrder", 5, "below", "y", "", 1, 1, "bond order", "Maximum fragment energy [Ht]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", AbsEnergyPlotLine)) return 1;
406 if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "MinEnergies-FragmentOrder", 5, "below", "y", "", 1, 1, "bond order", "Minimum fragment energy [Ht]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", AbsEnergyPlotLine)) return 1;
407
408 // +++++++++++++++++++++++++++++++=Ploting min/mean/max forces for each fragment
409 yrange.str("");
410 yrange << "[" << ForceFragments.FindMinValue() << ":" << ForceFragments.FindMaxValue()<< "]";
411 // min
412 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MinForces-Fragment", 5, "below", "y", "set boxwidth 0.2", 1, 5, "fragment number", "minimum of approximated forces [Ht/a.u.]", Fragmentxrange.str().c_str(), yrange.str().c_str(), "2" , "with boxes fillcolor", BoxesForcePlotLine)) return 1;
413
414 // mean
415 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MeanForces-Fragment", 5, "below", "y", "set boxwidth 0.2", 1, 5, "fragment number", "mean of approximated forces [Ht/a.u.]", Fragmentxrange.str().c_str(), yrange.str().c_str(), "2" , "with boxes fillcolor", BoxesFirstForceValuePlotLine)) return 1;
416
417 // max
418 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MaxForces-Fragment", 5, "below", "y", "set boxwidth 0.2", 1, 5, "fragment number", "maximum of approximated forces [Ht/a.u.]", Fragmentxrange.str().c_str(), yrange.str().c_str(), "2" , "with boxes fillcolor", BoxesForcePlotLine)) return 1;
419
420 // +++++++++++++++++++++++++++++++=Ploting min/mean/max forces for each fragment per bond order
421 // min
422 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MinForces-FragmentOrder", 5, "below", "y", "set boxwidth 0.2", 1, 1, "bond order", "minimum of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with boxes fillcolor", BoxesForcePlotLine)) return 1;
423
424 // mean
425 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MeanForces-FragmentOrder", 5, "below", "y", "set boxwidth 0.2", 1, 1, "bond order", "mean of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with boxes fillcolor", BoxesFirstForceValuePlotLine)) return 1;
426
427 // max
428 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MaxForces-FragmentOrder", 5, "below", "y", "set boxwidth 0.2", 1, 1, "bond order", "maximum of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with boxes fillcolor", BoxesForcePlotLine)) return 1;
429
430 // +++++++++++++++++++++++++++++++=Ploting approximated and true shielding for each atom
431 if (periode != NULL) { // also look for PAS values
432 if(!OpenOutputFile(output, argv[3], "ShieldingsPAS-Order.pyx")) return 1;
433 if(!OpenOutputFile(output2, argv[3], "DeltaShieldingsPAS-Order.pyx")) return 1;
434 CreatePlotHeader(output, "ShieldingsPAS-Order", 1, "top right", NULL, NULL, 1, 5, "nuclei index", "iso chemical shielding value [ppm]");
435 CreatePlotHeader(output2, "DeltaShieldingsPAS-Order", 1, "top right", NULL, NULL, 1, 5, "nuclei index", "iso chemical shielding value [ppm]");
436 double step=0.8/KeySet.Order;
437 output << "set boxwidth " << step << endl;
438 output << "plot [0:" << ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter]+10 << "]\\" << endl;
439 output2 << "plot [0:" << ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter]+10 << "]\\" << endl;
440 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
441 output << "'ShieldingsPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1+" << step*(double)BondOrder << "):7 with boxes, \\" << endl;
442 output2 << "'DeltaShieldingsPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1):7 with linespoints";
443 if (BondOrder-1 != KeySet.Order)
444 output2 << ", \\" << endl;
445 }
446 output << "'ShieldingsPAS-Order.dat' index " << KeySet.Order << " title 'Full' using ($1+" << step*(double)KeySet.Order << "):7 with boxes" << endl;
447 output.close();
448 output2.close();
449
450 if(!OpenOutputFile(output, argv[3], "ChisPAS-Order.pyx")) return 1;
451 if(!OpenOutputFile(output2, argv[3], "DeltaChisPAS-Order.pyx")) return 1;
452 CreatePlotHeader(output, "ChisPAS-Order", 1, "top right", NULL, NULL, 1, 5, "nuclei index", "iso chemical Chi value [ppm]");
453 CreatePlotHeader(output2, "DeltaChisPAS-Order", 1, "top right", NULL, NULL, 1, 5, "nuclei index", "iso chemical Chi value [ppm]");
454 output << "set boxwidth " << step << endl;
455 output << "plot [0:" << ChiPAS.RowCounter[ChiPAS.MatrixCounter]+10 << "]\\" << endl;
456 output2 << "plot [0:" << ChiPAS.RowCounter[ChiPAS.MatrixCounter]+10 << "]\\" << endl;
457 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
458 output << "'ChisPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1+" << step*(double)BondOrder << "):7 with boxes, \\" << endl;
459 output2 << "'DeltaChisPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1):7 with linespoints";
460 if (BondOrder-1 != KeySet.Order)
461 output2 << ", \\" << endl;
462 }
463 output << "'ChisPAS-Order.dat' index " << KeySet.Order << " title 'Full' using ($1+" << step*(double)KeySet.Order << "):7 with boxes" << endl;
464 output.close();
465 output2.close();
466 }
467
468 // create Makefile
469 if(!OpenOutputFile(output, argv[3], "Makefile")) return 1;
470 output << "PYX = $(shell ls *.pyx)" << endl << endl;
471 output << "EPS = $(PYX:.pyx=.eps)" << endl << endl;
472 output << "%.eps: %.pyx" << endl;
473 output << "\t~/build/pyxplot/pyxplot $<" << endl << endl;
474 output << "all: $(EPS)" << endl << endl;
475 output << ".PHONY: clean" << endl;
476 output << "clean:" << endl;
477 output << "\trm -rf $(EPS)" << endl;
478 output.close();
479
480 // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++
481 delete(periode);
482 Free((void **)&dir, "main: *dir");
483 cout << "done." << endl;
484 return 0;
485};
486
487//============================ END ===========================
Note: See TracBrowser for help on using the repository browser.