source: src/analyzer.cpp@ d4fa23

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

Merge branch 'MultipleMolecules'

Conflicts:

molecuilder/src/analyzer.cpp
molecuilder/src/atom.cpp
molecuilder/src/boundary.cpp
molecuilder/src/boundary.hpp
molecuilder/src/builder.cpp
molecuilder/src/config.cpp
molecuilder/src/datacreator.hpp
molecuilder/src/helpers.cpp
molecuilder/src/joiner.cpp
molecuilder/src/moleculelist.cpp
molecuilder/src/molecules.cpp
molecuilder/src/molecules.hpp
molecuilder/src/parser.cpp
molecuilder/src/parser.hpp
molecuilder/src/vector.cpp
molecuilder/src/verbose.cpp

merges:

compilation fixes:

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