source: src/analyzer.cpp@ 9cd807

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 9cd807 was bf3817, checked in by Frederik Heber <heber@…>, 14 years ago

Added ifdef HAVE_CONFIG and config.h include to each and every cpp file.

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