source: src/Fragmentation/analyzer.cpp@ dcbb5d

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 dcbb5d was 94d5ac6, checked in by Frederik Heber <heber@…>, 12 years ago

FIX: As we use GSL internally, we are as of now required to use GPL v2 license.

  • GNU Scientific Library is used at every place in the code, especially the sub-package LinearAlgebra is based on it which in turn is used really everywhere in the remainder of MoleCuilder. Hence, we have to use the GPL license for the whole of MoleCuilder. In effect, GPL's COPYING was present all along and stated the terms of the GPL v2 license.
  • Hence, I added the default GPL v2 disclaimer to every source file and removed the note about a (actually missing) LICENSE file.
  • also, I added a help-redistribute action which again gives the disclaimer of the GPL v2.
  • also, I changed in the disclaimer that is printed at every program start in builder_init.cpp.
  • TEST: Added check on GPL statement present in every module to test CodeChecks project-disclaimer.
  • 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 if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1;
185 if (!KeySet.ParseManyBodyTerms()) return 1;
186
187 // ---------- Parse fragment files created by 'joiner' into an array -------------
188 if (!EnergyFragments.ParseFragmentMatrix(argv[1], dir, EnergyFragmentSuffix,0,0)) return 1;
189 if (!NoHCorrection)
190 HcorrectionFragments.ParseFragmentMatrix(argv[1], dir, HcorrectionFragmentSuffix,0,0);
191 if (!ForceFragments.ParseFragmentMatrix(argv[1], dir, ForceFragmentSuffix,0,0)) return 1;
192 if (!NoHessian)
193 if (!HessianFragments.ParseFragmentMatrix(argv[1], dir, HessianFragmentSuffix,0,0)) return 1;
194 if (periode != NULL) { // also look for PAS values
195 if (!ShieldingFragments.ParseFragmentMatrix(argv[1], dir, ShieldingFragmentSuffix, 1, 0)) return 1;
196 if (!ShieldingPASFragments.ParseFragmentMatrix(argv[1], dir, ShieldingPASFragmentSuffix, 1, 0)) return 1;
197 if (!ChiFragments.ParseFragmentMatrix(argv[1], dir, ChiFragmentSuffix, 1, 0)) return 1;
198 if (!ChiPASFragments.ParseFragmentMatrix(argv[1], dir, ChiPASFragmentSuffix, 1, 0)) return 1;
199 }
200
201 // +++++++++++++++ TESTING ++++++++++++++++++++++++++++++
202
203 // print energy and forces to file
204 filename.str("");
205 filename << argv[3] << "/" << "energy-forces.all";
206 output.open(filename.str().c_str(), ios::out);
207 output << endl << "Total Energy" << endl << "==============" << endl << Energy.Header[Energy.MatrixCounter] << endl;
208 for(int j=0;j<Energy.RowCounter[Energy.MatrixCounter];j++) {
209 for(int k=0;k<Energy.ColumnCounter[Energy.MatrixCounter];k++)
210 output << scientific << Energy.Matrix[ Energy.MatrixCounter ][j][k] << "\t";
211 output << endl;
212 }
213 output << endl;
214
215 output << endl << "Total Forces" << endl << "===============" << endl << Force.Header[Force.MatrixCounter] << endl;
216 for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) {
217 for(int k=0;k<Force.ColumnCounter[Force.MatrixCounter];k++)
218 output << scientific << Force.Matrix[ Force.MatrixCounter ][j][k] << "\t";
219 output << endl;
220 }
221 output << endl;
222
223 if (!NoHessian) {
224 output << endl << "Total Hessian" << endl << "===============" << endl << Hessian.Header[Hessian.MatrixCounter] << endl;
225 for(int j=0;j<Hessian.RowCounter[Hessian.MatrixCounter];j++) {
226 for(int k=0;k<Hessian.ColumnCounter[Hessian.MatrixCounter];k++)
227 output << scientific << Hessian.Matrix[ Hessian.MatrixCounter ][j][k] << "\t";
228 output << endl;
229 }
230 output << endl;
231 }
232
233 if (periode != NULL) { // also look for PAS values
234 output << endl << "Total Shieldings" << endl << "===============" << endl << Shielding.Header[Hessian.MatrixCounter] << endl;
235 for(int j=0;j<Shielding.RowCounter[Shielding.MatrixCounter];j++) {
236 for(int k=0;k<Shielding.ColumnCounter[Shielding.MatrixCounter];k++)
237 output << scientific << Shielding.Matrix[ Shielding.MatrixCounter ][j][k] << "\t";
238 output << endl;
239 }
240 output << endl;
241
242 output << endl << "Total Shieldings PAS" << endl << "===============" << endl << ShieldingPAS.Header[ShieldingPAS.MatrixCounter] << endl;
243 for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) {
244 for(int k=0;k<ShieldingPAS.ColumnCounter[ShieldingPAS.MatrixCounter];k++)
245 output << scientific << ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t";
246 output << endl;
247 }
248 output << endl;
249
250 output << endl << "Total Chis" << endl << "===============" << endl << Chi.Header[Chi.MatrixCounter] << endl;
251 for(int j=0;j<Chi.RowCounter[Chi.MatrixCounter];j++) {
252 for(int k=0;k<Chi.ColumnCounter[Chi.MatrixCounter];k++)
253 output << scientific << Chi.Matrix[ Chi.MatrixCounter ][j][k] << "\t";
254 output << endl;
255 }
256 output << endl;
257
258 output << endl << "Total Chis PAS" << endl << "===============" << endl << ChiPAS.Header[ChiPAS.MatrixCounter] << endl;
259 for(int j=0;j<ChiPAS.RowCounter[ChiPAS.MatrixCounter];j++) {
260 for(int k=0;k<ChiPAS.ColumnCounter[ChiPAS.MatrixCounter];k++)
261 output << scientific << ChiPAS.Matrix[ ChiPAS.MatrixCounter ][j][k] << "\t";
262 output << endl;
263 }
264 output << endl;
265 }
266
267 if (!NoTime) {
268 output << endl << "Total Times" << endl << "===============" << endl << Time.Header[Time.MatrixCounter] << endl;
269 for(int j=0;j<Time.RowCounter[Time.MatrixCounter];j++) {
270 for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) {
271 output << scientific << Time.Matrix[ Time.MatrixCounter ][j][k] << "\t";
272 }
273 output << endl;
274 }
275 output << endl;
276 }
277 output.close();
278 if (!NoTime)
279 for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++)
280 Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k] = Time.Matrix[ Time.MatrixCounter ][Time.RowCounter[Time.MatrixCounter]-1][k];
281
282 // +++++++++++++++ ANALYZING ++++++++++++++++++++++++++++++
283
284 LOG(0, "Analyzing ...");
285
286 // ======================================= Creating the data files ==============================================================
287
288 // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order
289 // +++++++++++++++++++++++++++++++++++++++ Plotting Delta Simtime vs Bond Order
290 if (!NoTime) {
291 if (!OpenOutputFile(output, argv[3], "SimTime-Order.dat" )) return false;
292 if (!OpenOutputFile(output2, argv[3], "DeltaSimTime-Order.dat" )) return false;
293 for(int j=Time.RowCounter[Time.MatrixCounter];j--;)
294 for(int k=Time.ColumnCounter[Time.MatrixCounter];k--;) {
295 Time.Matrix[ Time.MatrixCounter ][j][k] = 0.;
296 }
297 counter = 0;
298 output << "#Order\tFrag.No.\t" << Time.Header[Time.MatrixCounter] << endl;
299 output2 << "#Order\tFrag.No.\t" << Time.Header[Time.MatrixCounter] << endl;
300 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
301 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;)
302 for(int j=Time.RowCounter[Time.MatrixCounter];j--;)
303 for(int k=Time.ColumnCounter[Time.MatrixCounter];k--;) {
304 Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];
305 }
306 counter += KeySet.FragmentsPerOrder[BondOrder];
307 output << BondOrder+1 << "\t" << counter;
308 output2 << BondOrder+1 << "\t" << counter;
309 for(int k=0;k<Time.ColumnCounter[Time.MatrixCounter];k++) {
310 output << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k];
311 if (fabs(Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k]) > MYEPSILON)
312 output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k] / Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter] ][k];
313 else
314 output2 << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][ Time.RowCounter[Time.MatrixCounter]-1 ][k];
315 }
316 output << endl;
317 output2 << endl;
318 }
319 output.close();
320 output2.close();
321 }
322
323 if (!NoHessian) {
324 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in hessian to full QM
325 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;
326
327 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;
328
329 // ++++++++++++++++++++++++++++++++++++++Plotting Hessian vs. Order
330 if (!CreateDataHessianOrderPerAtom(HessianFragments, KeySet, argv[3], "Hessian_xx-Order", "Plot of approximated hessian versus the Bond Order", datum)) return 1;
331 if (!AppendOutputFile(output, argv[3], "Hessian_xx-Order.dat" )) return false;
332 output << endl << "# Full" << endl;
333 for(int j=0;j<Hessian.RowCounter[Hessian.MatrixCounter];j++) {
334 output << j << "\t";
335 for(int k=0;k<Hessian.ColumnCounter[Force.MatrixCounter];k++)
336 output << scientific << Hessian.Matrix[ Hessian.MatrixCounter ][j][k] << "\t";
337 output << endl;
338 }
339 output.close();
340 }
341
342 // +++++++++++++++++++++++++++++++++++++++ Plotting shieldings
343 if (periode != NULL) { // also look for PAS values
344 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;
345 if (!CreateDataForcesOrderPerAtom(ShieldingPASFragments, KeySet, argv[3], "ShieldingsPAS-Order", "Plot of approximated shieldings versus the Bond Order", datum)) return 1;
346 if (!AppendOutputFile(output, argv[3], "ShieldingsPAS-Order.dat" )) return false;
347 output << endl << "# Full" << endl;
348 for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) {
349 output << j << "\t";
350 for(int k=0;k<ShieldingPAS.ColumnCounter[ShieldingPAS.MatrixCounter];k++)
351 output << scientific << ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t"; //*(((k>1) && (k<6))? 1.e6 : 1.) << "\t";
352 output << endl;
353 }
354 output.close();
355 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;
356 if (!CreateDataForcesOrderPerAtom(ChiPASFragments, KeySet, argv[3], "ChisPAS-Order", "Plot of approximated Chis versus the Bond Order", datum)) return 1;
357 if (!AppendOutputFile(output, argv[3], "ChisPAS-Order.dat" )) return false;
358 output << endl << "# Full" << endl;
359 for(int j=0;j<ChiPAS.RowCounter[ChiPAS.MatrixCounter];j++) {
360 output << j << "\t";
361 for(int k=0;k<ChiPAS.ColumnCounter[ChiPAS.MatrixCounter];k++)
362 output << scientific << ChiPAS.Matrix[ ChiPAS.MatrixCounter ][j][k] << "\t"; //*(((k>1) && (k<6))? 1.e6 : 1.) << "\t";
363 output << endl;
364 }
365 output.close();
366 }
367
368
369 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM
370 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;
371
372 // +++++++++++++++++++++++++++++++++++Plotting Energies vs. Order
373 if (!CreateDataEnergyOrder(EnergyFragments, KeySet, argv[3], "Energies-Order", "Plot of approximated energies versus the Bond Order", datum)) return 1;
374
375 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in forces to full QM
376 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;
377
378 // min force
379 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;
380
381 // mean force
382 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;
383
384 // max force
385 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;
386
387 // ++++++++++++++++++++++++++++++++++++++Plotting Forces vs. Order
388 if (!CreateDataForcesOrderPerAtom(ForceFragments, KeySet, argv[3], "Forces-Order", "Plot of approximated forces versus the Bond Order", datum)) return 1;
389 if (!AppendOutputFile(output, argv[3], "Forces-Order.dat" )) return false;
390 output << endl << "# Full" << endl;
391 for(int j=0;j<Force.RowCounter[Force.MatrixCounter];j++) {
392 output << j << "\t";
393 for(int k=0;k<Force.ColumnCounter[Force.MatrixCounter];k++)
394 output << scientific << Force.Matrix[ Force.MatrixCounter ][j][k] << "\t";
395 output << endl;
396 }
397 output.close();
398 // min force
399 if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "MinForces-Order", "Plot of min approximated forces versus the Bond Order", datum, CreateMinimumForce)) return 1;
400
401 // mean force
402 if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "MeanForces-Order", "Plot of mean approximated forces versus the Bond Order", datum, CreateMeanForce)) return 1;
403
404 // max force
405 if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "MaxForces-Order", "Plot of max approximated forces versus the Bond Order", datum, CreateMaximumForce)) return 1;
406
407 // ++++++++++++++++++++++++++++++++++++++Plotting vector sum (should be 0) vs. bond order
408 if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "VectorSum-Order", "Plot of vector sum of the approximated forces versus the Bond Order", datum, CreateVectorSumForce)) return 1;
409
410 // +++++++++++++++++++++++++++++++Plotting energyfragments vs. order
411 if (!CreateDataFragment(EnergyFragments, KeySet, argv[3], "Energies-Fragment", "Plot of fragment energy versus the Fragment No", datum, CreateEnergy)) return 1;
412 if (!CreateDataFragment(EnergyFragments, KeySet, argv[3], "Energies-FragmentOrder", "Plot of fragment energy of each Fragment No vs. Bond Order", datum, CreateEnergy)) return 1;
413 if (!CreateDataFragmentOrder(EnergyFragments, KeySet, argv[3], "MaxEnergies-FragmentOrder", "Plot of maximum of fragment energy vs. Bond Order", datum, CreateMaxFragmentOrder)) return 1;
414 if (!CreateDataFragmentOrder(EnergyFragments, KeySet, argv[3], "MinEnergies-FragmentOrder", "Plot of minimum of fragment energy vs. Bond Order", datum, CreateMinFragmentOrder)) return 1;
415
416 // +++++++++++++++++++++++++++++++Ploting min/mean/max forces for each fragment
417 // min force
418 if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MinForces-Fragment", "Plot of min approximated forces versus the Fragment No", datum, CreateMinimumForce)) return 1;
419
420 // mean force
421 if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MeanForces-Fragment", "Plot of mean approximated forces versus the Fragment No", datum, CreateMeanForce)) return 1;
422
423 // max force
424 if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MaxForces-Fragment", "Plot of max approximated forces versus the Fragment No", datum, CreateMaximumForce)) return 1;
425
426 // +++++++++++++++++++++++++++++++Ploting min/mean/max forces for each fragment per order
427 // min force
428 if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MinForces-FragmentOrder", "Plot of min approximated forces of each Fragment No vs. Bond Order", datum, CreateMinimumForce)) return 1;
429
430 // mean force
431 if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MeanForces-FragmentOrder", "Plot of mean approximated forces of each Fragment No vs. Bond Order", datum, CreateMeanForce)) return 1;
432
433 // max force
434 if (!CreateDataFragment(ForceFragments, KeySet, argv[3], "MaxForces-FragmentOrder", "Plot of max approximated forces of each Fragment No vs. Bond Order", datum, CreateMaximumForce)) return 1;
435
436 // ======================================= Creating the plot files ==============================================================
437
438 Orderxrange << "[1:" << KeySet.Order << "]";
439 Fragmentxrange << "[0:" << KeySet.FragmentCounter+1 << "]";
440 yrange.str("[1e-8:1e+1]");
441
442 if (!NoTime) {
443 // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order
444 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;
445 }
446
447 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM
448 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;
449
450 // +++++++++++++++++++++++++++++++++++Plotting Energies vs. Order
451 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;
452
453 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in forces to full QM
454 yrange.str("[1e-8:1e+0]");
455 // min force
456 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;
457
458 // mean force
459 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;
460
461 // max force
462 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;
463
464 // min/mean/max comparison for total force
465 if(!OpenOutputFile(output, argv[3], "DeltaMinMeanMaxTotalForce-Order.pyx")) return 1;
466 CreatePlotHeader(output, "DeltaMinMeanMaxTotalForce-Order", 1, "bottom left", "y", NULL, 1, 1, "bond order k", "absolute error in total forces [Ht/a.u.]");
467 output << "plot " << Orderxrange.str().c_str() << " [1e-8:1e+0] \\" << endl;
468 output << "'DeltaMinForces-Order.dat' title 'minimum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints, \\" << endl;
469 output << "'DeltaMeanForces-Order.dat' title 'mean' using 1:(abs($" << 8 << ")) with linespoints, \\" << endl;
470 output << "'DeltaMaxForces-Order.dat' title 'maximum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints" << endl;
471 output.close();
472
473 // ++++++++++++++++++++++++++++++++++++++Plotting Forces vs. Order
474 // min force
475 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;
476
477 // mean force
478 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;
479
480 // max force
481 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;
482
483 // min/mean/max comparison for total force
484 if(!OpenOutputFile(output, argv[3],"MinMeanMaxTotalForce-Order.pyx")) return 1;
485 CreatePlotHeader(output, "MinMeanMaxTotalForce-Order", 1, "bottom left", "y", NULL, 1, 1, "bond order k", "absolute total force [Ht/a.u.]");
486 output << "plot "<< Orderxrange.str().c_str() << " [1e-8:1e+0] \\" << endl;
487 output << "'MinForces-Order.dat' title 'minimum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints, \\" << endl;
488 output << "'MeanForces-Order.dat' title 'mean' using 1:(abs($" << 8 << ")) with linespoints, \\" << endl;
489 output << "'MaxForces-Order.dat' title 'maximum' using 1:(sqrt($" << 8 << "*$" << 8 << "+$" << 8+1 << "*$" << 8+1 << "+$" << 8+2 << "*$" << 8+2 << ")) with linespoints" << endl;
490 output.close();
491
492 // ++++++++++++++++++++++++++++++++++++++Plotting vector sum vs. Order
493
494 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;
495
496 // +++++++++++++++++++++++++++++++Plotting energyfragments vs. order
497 yrange.str("");
498 yrange << "[" << EnergyFragments.FindMinValue() << ":" << EnergyFragments.FindMaxValue() << "]";
499 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;
500 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;
501 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;
502 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;
503
504 // +++++++++++++++++++++++++++++++=Ploting min/mean/max forces for each fragment
505 yrange.str("");
506 yrange << "[" << ForceFragments.FindMinValue() << ":" << ForceFragments.FindMaxValue()<< "]";
507 // min
508 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;
509
510 // mean
511 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;
512
513 // max
514 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;
515
516 // +++++++++++++++++++++++++++++++=Ploting min/mean/max forces for each fragment per bond order
517 // min
518 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;
519
520 // mean
521 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;
522
523 // max
524 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;
525
526 // +++++++++++++++++++++++++++++++=Ploting approximated and true shielding for each atom
527 if (periode != NULL) { // also look for PAS values
528 if(!OpenOutputFile(output, argv[3], "ShieldingsPAS-Order.pyx")) return 1;
529 if(!OpenOutputFile(output2, argv[3], "DeltaShieldingsPAS-Order.pyx")) return 1;
530 CreatePlotHeader(output, "ShieldingsPAS-Order", 1, "top right", NULL, NULL, 1, 5, "nuclei index", "iso chemical shielding value [ppm]");
531 CreatePlotHeader(output2, "DeltaShieldingsPAS-Order", 1, "top right", NULL, NULL, 1, 5, "nuclei index", "iso chemical shielding value [ppm]");
532 double step=0.8/KeySet.Order;
533 output << "set boxwidth " << step << endl;
534 output << "plot [0:" << ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter]+10 << "]\\" << endl;
535 output2 << "plot [0:" << ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter]+10 << "]\\" << endl;
536 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
537 output << "'ShieldingsPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1+" << step*(double)BondOrder << "):7 with boxes, \\" << endl;
538 output2 << "'DeltaShieldingsPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1):7 with linespoints";
539 if (BondOrder-1 != KeySet.Order)
540 output2 << ", \\" << endl;
541 }
542 output << "'ShieldingsPAS-Order.dat' index " << KeySet.Order << " title 'Full' using ($1+" << step*(double)KeySet.Order << "):7 with boxes" << endl;
543 output2.close();
544
545 if(!OpenOutputFile(output, argv[3], "ChisPAS-Order.pyx")) return 1;
546 if(!OpenOutputFile(output2, argv[3], "DeltaChisPAS-Order.pyx")) return 1;
547 CreatePlotHeader(output, "ChisPAS-Order", 1, "top right", NULL, NULL, 1, 5, "nuclei index", "iso chemical Chi value [ppm]");
548 CreatePlotHeader(output2, "DeltaChisPAS-Order", 1, "top right", NULL, NULL, 1, 5, "nuclei index", "iso chemical Chi value [ppm]");
549 output << "set boxwidth " << step << endl;
550 output << "plot [0:" << ChiPAS.RowCounter[ChiPAS.MatrixCounter]+10 << "]\\" << endl;
551 output2 << "plot [0:" << ChiPAS.RowCounter[ChiPAS.MatrixCounter]+10 << "]\\" << endl;
552 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
553 output << "'ChisPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1+" << step*(double)BondOrder << "):7 with boxes, \\" << endl;
554 output2 << "'DeltaChisPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1):7 with linespoints";
555 if (BondOrder-1 != KeySet.Order)
556 output2 << ", \\" << endl;
557 }
558 output << "'ChisPAS-Order.dat' index " << KeySet.Order << " title 'Full' using ($1+" << step*(double)KeySet.Order << "):7 with boxes" << endl;
559 output.close();
560 output2.close();
561
562 if(!OpenOutputFile(output, argv[3], "ChisPAS-Order.pyx")) return 1;
563 if(!OpenOutputFile(output2, argv[3], "DeltaChisPAS-Order.pyx")) return 1;
564 CreatePlotHeader(output, "ChisPAS-Order", 1, "top right", NULL, NULL, 1, 5, "nuclei index", "iso chemical Chi value [ppm]");
565 CreatePlotHeader(output2, "DeltaChisPAS-Order", 1, "top right", NULL, NULL, 1, 5, "nuclei index", "iso chemical Chi value [ppm]");
566 output << "set boxwidth " << step << endl;
567 output << "plot [0:" << ChiPAS.RowCounter[ChiPAS.MatrixCounter]+10 << "]\\" << endl;
568 output2 << "plot [0:" << ChiPAS.RowCounter[ChiPAS.MatrixCounter]+10 << "]\\" << endl;
569 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
570 output << "'ChisPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1+" << step*(double)BondOrder << "):7 with boxes, \\" << endl;
571 output2 << "'DeltaChisPAS-Order.dat' index " << BondOrder << " title 'Order " << BondOrder+1 << "' using ($1):7 with linespoints";
572 if (BondOrder-1 != KeySet.Order)
573 output2 << ", \\" << endl;
574 }
575 output << "'ChisPAS-Order.dat' index " << KeySet.Order << " title 'Full' using ($1+" << step*(double)KeySet.Order << "):7 with boxes" << endl;
576 output.close();
577 output2.close();
578 }
579
580 // create Makefile
581 if(!OpenOutputFile(output, argv[3], "Makefile")) return 1;
582 output << "PYX = $(shell ls *.pyx)" << endl << endl;
583 output << "EPS = $(PYX:.pyx=.eps)" << endl << endl;
584 output << "%.eps: %.pyx" << endl;
585 output << "\t~/build/pyxplot/pyxplot $<" << endl << endl;
586 output << "all: $(EPS)" << endl << endl;
587 output << ".PHONY: clean" << endl;
588 output << "clean:" << endl;
589 output << "\trm -rf $(EPS)" << endl;
590 output.close();
591
592 // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++
593 delete(periode);
594 delete[](dir);
595 LOG(0, "done.");
596 return 0;
597};
598
599//============================ END ===========================
Note: See TracBrowser for help on using the repository browser.