source: src/analyzer.cpp@ dc322a

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

Removed Helpers.hpp, deleted Helpers.cpp and libMoleCuilderHelpers.la is history.

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