source: src/Fragmentation/analyzer.cpp@ 5ac92e

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 5ac92e was 0aa122, checked in by Frederik Heber <heber@…>, 13 years ago

Updated all source files's copyright note to current year 2012.

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