source: src/analyzer.cpp@ 1a6bda

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 1a6bda was ad011c, checked in by Frederik Heber <heber@…>, 14 years ago

CodePatterns places all includes now in subfolder CodePatterns/.

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