source: src/analyzer.cpp@ 2e6e7a

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 2e6e7a was 234af2, checked in by Frederik Heber <heber@…>, 17 years ago

Implemented analysis of magnetic susceptibilites.

This is very similar to Sigma(PAS), however not with ForceMatrix class but with EnergyMatrix. This is still not finished and yet not working. However, it does not impact on other functions of joiner or analyzer.

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