source: src/Fragmentation/analyzer.cpp@ 0cd8cf

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 0cd8cf was 8b58ac, checked in by Frederik Heber <heber@…>, 12 years ago

KeySetsContainer::ParseKeySets() may now parse arbitrary files.

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