1 | /** \file builder.cpp
|
---|
2 | *
|
---|
3 | * By stating absolute positions or binding angles and distances atomic positions of a molecule can be constructed.
|
---|
4 | * The output is the complete configuration file for PCP for direct use.
|
---|
5 | * Features:
|
---|
6 | * -# Atomic data is retrieved from a file, if not found requested and stored there for later re-use
|
---|
7 | * -# step-by-step construction of the molecule beginning either at a centre of with a certain atom
|
---|
8 | *
|
---|
9 | */
|
---|
10 |
|
---|
11 | /*! \mainpage Molecuilder - a molecular set builder
|
---|
12 | *
|
---|
13 | * This introductory shall briefly make aquainted with the program, helping in installing and a first run.
|
---|
14 | *
|
---|
15 | * \section about About the Program
|
---|
16 | *
|
---|
17 | * Molecuilder is a short program, written in C++, that enables the construction of a coordinate set for the
|
---|
18 | * atoms making up an molecule by the successive statement of binding angles and distances and referencing to
|
---|
19 | * already constructed atoms.
|
---|
20 | *
|
---|
21 | * A configuration file may be written that is compatible to the format used by PCP - a parallel Car-Parrinello
|
---|
22 | * molecular dynamics implementation.
|
---|
23 | *
|
---|
24 | * \section install Installation
|
---|
25 | *
|
---|
26 | * Installation should without problems succeed as follows:
|
---|
27 | * -# ./configure (or: mkdir build;mkdir run;cd build; ../configure --bindir=../run)
|
---|
28 | * -# make
|
---|
29 | * -# make install
|
---|
30 | *
|
---|
31 | * Further useful commands are
|
---|
32 | * -# make clean uninstall: deletes .o-files and removes executable from the given binary directory\n
|
---|
33 | * -# make doxygen-doc: Creates these html pages out of the documented source
|
---|
34 | *
|
---|
35 | * \section run Running
|
---|
36 | *
|
---|
37 | * The program can be executed by running: ./molecuilder
|
---|
38 | *
|
---|
39 | * Note, that it uses a database, called "elements.db", in the executable's directory. If the file is not found,
|
---|
40 | * it is created and any given data on elements of the periodic table will be stored therein and re-used on
|
---|
41 | * later re-execution.
|
---|
42 | *
|
---|
43 | * \section ref References
|
---|
44 | *
|
---|
45 | * For the special configuration file format, see the documentation of pcp.
|
---|
46 | *
|
---|
47 | */
|
---|
48 |
|
---|
49 |
|
---|
50 | #include <boost/bind.hpp>
|
---|
51 |
|
---|
52 | using namespace std;
|
---|
53 |
|
---|
54 | #include <cstring>
|
---|
55 |
|
---|
56 | #include "analysis_bonds.hpp"
|
---|
57 | #include "analysis_correlation.hpp"
|
---|
58 | #include "atom.hpp"
|
---|
59 | #include "bond.hpp"
|
---|
60 | #include "bondgraph.hpp"
|
---|
61 | #include "boundary.hpp"
|
---|
62 | #include "config.hpp"
|
---|
63 | #include "element.hpp"
|
---|
64 | #include "ellipsoid.hpp"
|
---|
65 | #include "helpers.hpp"
|
---|
66 | #include "leastsquaremin.hpp"
|
---|
67 | #include "linkedcell.hpp"
|
---|
68 | #include "log.hpp"
|
---|
69 | #include "memoryusageobserver.hpp"
|
---|
70 | #include "molecule.hpp"
|
---|
71 | #include "periodentafel.hpp"
|
---|
72 | #include "tesselationhelpers.hpp"
|
---|
73 | #include "UIElements/UIFactory.hpp"
|
---|
74 | #include "UIElements/MainWindow.hpp"
|
---|
75 | #include "UIElements/Dialog.hpp"
|
---|
76 | #include "Menu/ActionMenuItem.hpp"
|
---|
77 | #include "Actions/ActionRegistry.hpp"
|
---|
78 | #include "Actions/ActionHistory.hpp"
|
---|
79 | #include "Actions/MethodAction.hpp"
|
---|
80 | #include "Actions/small_actions.hpp"
|
---|
81 | #include "World.hpp"
|
---|
82 | #include "version.h"
|
---|
83 | #include "World.hpp"
|
---|
84 | #include "Helpers/MemDebug.hpp"
|
---|
85 |
|
---|
86 | /********************************************* Subsubmenu routine ************************************/
|
---|
87 | #if 0
|
---|
88 | /** Submenu for adding atoms to the molecule.
|
---|
89 | * \param *periode periodentafel
|
---|
90 | * \param *molecule molecules with atoms
|
---|
91 | */
|
---|
92 | static void AddAtoms(periodentafel *periode, molecule *mol)
|
---|
93 | {
|
---|
94 | atom *first, *second, *third, *fourth;
|
---|
95 | Vector **atoms;
|
---|
96 | Vector x,y,z,n; // coordinates for absolute point in cell volume
|
---|
97 | double a,b,c;
|
---|
98 | char choice; // menu choice char
|
---|
99 | bool valid;
|
---|
100 |
|
---|
101 | cout << Verbose(0) << "===========ADD ATOM============================" << endl;
|
---|
102 | cout << Verbose(0) << " a - state absolute coordinates of atom" << endl;
|
---|
103 | cout << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;
|
---|
104 | cout << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;
|
---|
105 | cout << Verbose(0) << " d - state two atoms, two angles and a distance" << endl;
|
---|
106 | cout << Verbose(0) << " e - least square distance position to a set of atoms" << endl;
|
---|
107 | cout << Verbose(0) << "all else - go back" << endl;
|
---|
108 | cout << Verbose(0) << "===============================================" << endl;
|
---|
109 | cout << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;
|
---|
110 | cout << Verbose(0) << "INPUT: ";
|
---|
111 | cin >> choice;
|
---|
112 |
|
---|
113 | switch (choice) {
|
---|
114 | default:
|
---|
115 | DoeLog(2) && (eLog()<< Verbose(2) << "Not a valid choice." << endl);
|
---|
116 | break;
|
---|
117 | case 'a': // absolute coordinates of atom
|
---|
118 | cout << Verbose(0) << "Enter absolute coordinates." << endl;
|
---|
119 | first = new atom;
|
---|
120 | first->x.AskPosition(World::getInstance().getDomain(), false);
|
---|
121 | first->type = periode->AskElement(); // give type
|
---|
122 | mol->AddAtom(first); // add to molecule
|
---|
123 | break;
|
---|
124 |
|
---|
125 | case 'b': // relative coordinates of atom wrt to reference point
|
---|
126 | first = new atom;
|
---|
127 | valid = true;
|
---|
128 | do {
|
---|
129 | if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl);
|
---|
130 | cout << Verbose(0) << "Enter reference coordinates." << endl;
|
---|
131 | x.AskPosition(World::getInstance().getDomain(), true);
|
---|
132 | cout << Verbose(0) << "Enter relative coordinates." << endl;
|
---|
133 | first->x.AskPosition(World::getInstance().getDomain(), false);
|
---|
134 | first->x.AddVector((const Vector *)&x);
|
---|
135 | cout << Verbose(0) << "\n";
|
---|
136 | } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
|
---|
137 | first->type = periode->AskElement(); // give type
|
---|
138 | mol->AddAtom(first); // add to molecule
|
---|
139 | break;
|
---|
140 |
|
---|
141 | case 'c': // relative coordinates of atom wrt to already placed atom
|
---|
142 | first = new atom;
|
---|
143 | valid = true;
|
---|
144 | do {
|
---|
145 | if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl);
|
---|
146 | second = mol->AskAtom("Enter atom number: ");
|
---|
147 | DoLog(0) && (Log() << Verbose(0) << "Enter relative coordinates." << endl);
|
---|
148 | first->x.AskPosition(World::getInstance().getDomain(), false);
|
---|
149 | for (int i=NDIM;i--;) {
|
---|
150 | first->x.x[i] += second->x.x[i];
|
---|
151 | }
|
---|
152 | } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
|
---|
153 | first->type = periode->AskElement(); // give type
|
---|
154 | mol->AddAtom(first); // add to molecule
|
---|
155 | break;
|
---|
156 |
|
---|
157 | case 'd': // two atoms, two angles and a distance
|
---|
158 | first = new atom;
|
---|
159 | valid = true;
|
---|
160 | do {
|
---|
161 | if (!valid) {
|
---|
162 | DoeLog(2) && (eLog()<< Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl);
|
---|
163 | }
|
---|
164 | cout << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;
|
---|
165 | second = mol->AskAtom("Enter central atom: ");
|
---|
166 | third = mol->AskAtom("Enter second atom (specifying the axis for first angle): ");
|
---|
167 | fourth = mol->AskAtom("Enter third atom (specifying a plane for second angle): ");
|
---|
168 | a = ask_value("Enter distance between central (first) and new atom: ");
|
---|
169 | b = ask_value("Enter angle between new, first and second atom (degrees): ");
|
---|
170 | b *= M_PI/180.;
|
---|
171 | bound(&b, 0., 2.*M_PI);
|
---|
172 | c = ask_value("Enter second angle between new and normal vector of plane defined by first, second and third atom (degrees): ");
|
---|
173 | c *= M_PI/180.;
|
---|
174 | bound(&c, -M_PI, M_PI);
|
---|
175 | cout << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl;
|
---|
176 | /*
|
---|
177 | second->Output(1,1,(ofstream *)&cout);
|
---|
178 | third->Output(1,2,(ofstream *)&cout);
|
---|
179 | fourth->Output(1,3,(ofstream *)&cout);
|
---|
180 | n.MakeNormalvector((const vector *)&second->x, (const vector *)&third->x, (const vector *)&fourth->x);
|
---|
181 | x.Copyvector(&second->x);
|
---|
182 | x.SubtractVector(&third->x);
|
---|
183 | x.Copyvector(&fourth->x);
|
---|
184 | x.SubtractVector(&third->x);
|
---|
185 |
|
---|
186 | if (!z.SolveSystem(&x,&y,&n, b, c, a)) {
|
---|
187 | coutg() << Verbose(0) << "Failure solving self-dependent linear system!" << endl;
|
---|
188 | continue;
|
---|
189 | }
|
---|
190 | DoLog(0) && (Log() << Verbose(0) << "resulting relative coordinates: ");
|
---|
191 | z.Output();
|
---|
192 | DoLog(0) && (Log() << Verbose(0) << endl);
|
---|
193 | */
|
---|
194 | // calc axis vector
|
---|
195 | x.CopyVector(&second->x);
|
---|
196 | x.SubtractVector(&third->x);
|
---|
197 | x.Normalize();
|
---|
198 | Log() << Verbose(0) << "x: ",
|
---|
199 | x.Output();
|
---|
200 | DoLog(0) && (Log() << Verbose(0) << endl);
|
---|
201 | z.MakeNormalVector(&second->x,&third->x,&fourth->x);
|
---|
202 | Log() << Verbose(0) << "z: ",
|
---|
203 | z.Output();
|
---|
204 | DoLog(0) && (Log() << Verbose(0) << endl);
|
---|
205 | y.MakeNormalVector(&x,&z);
|
---|
206 | Log() << Verbose(0) << "y: ",
|
---|
207 | y.Output();
|
---|
208 | DoLog(0) && (Log() << Verbose(0) << endl);
|
---|
209 |
|
---|
210 | // rotate vector around first angle
|
---|
211 | first->x.CopyVector(&x);
|
---|
212 | first->x.RotateVector(&z,b - M_PI);
|
---|
213 | Log() << Verbose(0) << "Rotated vector: ",
|
---|
214 | first->x.Output();
|
---|
215 | DoLog(0) && (Log() << Verbose(0) << endl);
|
---|
216 | // remove the projection onto the rotation plane of the second angle
|
---|
217 | n.CopyVector(&y);
|
---|
218 | n.Scale(first->x.ScalarProduct(&y));
|
---|
219 | Log() << Verbose(0) << "N1: ",
|
---|
220 | n.Output();
|
---|
221 | DoLog(0) && (Log() << Verbose(0) << endl);
|
---|
222 | first->x.SubtractVector(&n);
|
---|
223 | Log() << Verbose(0) << "Subtracted vector: ",
|
---|
224 | first->x.Output();
|
---|
225 | DoLog(0) && (Log() << Verbose(0) << endl);
|
---|
226 | n.CopyVector(&z);
|
---|
227 | n.Scale(first->x.ScalarProduct(&z));
|
---|
228 | Log() << Verbose(0) << "N2: ",
|
---|
229 | n.Output();
|
---|
230 | DoLog(0) && (Log() << Verbose(0) << endl);
|
---|
231 | first->x.SubtractVector(&n);
|
---|
232 | Log() << Verbose(0) << "2nd subtracted vector: ",
|
---|
233 | first->x.Output();
|
---|
234 | DoLog(0) && (Log() << Verbose(0) << endl);
|
---|
235 |
|
---|
236 | // rotate another vector around second angle
|
---|
237 | n.CopyVector(&y);
|
---|
238 | n.RotateVector(&x,c - M_PI);
|
---|
239 | Log() << Verbose(0) << "2nd Rotated vector: ",
|
---|
240 | n.Output();
|
---|
241 | DoLog(0) && (Log() << Verbose(0) << endl);
|
---|
242 |
|
---|
243 | // add the two linear independent vectors
|
---|
244 | first->x.AddVector(&n);
|
---|
245 | first->x.Normalize();
|
---|
246 | first->x.Scale(a);
|
---|
247 | first->x.AddVector(&second->x);
|
---|
248 |
|
---|
249 | DoLog(0) && (Log() << Verbose(0) << "resulting coordinates: ");
|
---|
250 | first->x.Output();
|
---|
251 | DoLog(0) && (Log() << Verbose(0) << endl);
|
---|
252 | } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
|
---|
253 | first->type = periode->AskElement(); // give type
|
---|
254 | mol->AddAtom(first); // add to molecule
|
---|
255 | break;
|
---|
256 |
|
---|
257 | case 'e': // least square distance position to a set of atoms
|
---|
258 | first = new atom;
|
---|
259 | atoms = new (Vector*[128]);
|
---|
260 | valid = true;
|
---|
261 | for(int i=128;i--;)
|
---|
262 | atoms[i] = NULL;
|
---|
263 | int i=0, j=0;
|
---|
264 | cout << Verbose(0) << "Now we need at least three molecules.\n";
|
---|
265 | do {
|
---|
266 | cout << Verbose(0) << "Enter " << i+1 << "th atom: ";
|
---|
267 | cin >> j;
|
---|
268 | if (j != -1) {
|
---|
269 | second = mol->FindAtom(j);
|
---|
270 | atoms[i++] = &(second->x);
|
---|
271 | }
|
---|
272 | } while ((j != -1) && (i<128));
|
---|
273 | if (i >= 2) {
|
---|
274 | first->x.LSQdistance((const Vector **)atoms, i);
|
---|
275 | first->x.Output();
|
---|
276 | first->type = periode->AskElement(); // give type
|
---|
277 | mol->AddAtom(first); // add to molecule
|
---|
278 | } else {
|
---|
279 | delete first;
|
---|
280 | cout << Verbose(0) << "Please enter at least two vectors!\n";
|
---|
281 | }
|
---|
282 | break;
|
---|
283 | };
|
---|
284 | };
|
---|
285 |
|
---|
286 | /** Submenu for centering the atoms in the molecule.
|
---|
287 | * \param *mol molecule with all the atoms
|
---|
288 | */
|
---|
289 | static void CenterAtoms(molecule *mol)
|
---|
290 | {
|
---|
291 | Vector x, y, helper;
|
---|
292 | char choice; // menu choice char
|
---|
293 |
|
---|
294 | cout << Verbose(0) << "===========CENTER ATOMS=========================" << endl;
|
---|
295 | cout << Verbose(0) << " a - on origin" << endl;
|
---|
296 | cout << Verbose(0) << " b - on center of gravity" << endl;
|
---|
297 | cout << Verbose(0) << " c - within box with additional boundary" << endl;
|
---|
298 | cout << Verbose(0) << " d - within given simulation box" << endl;
|
---|
299 | cout << Verbose(0) << "all else - go back" << endl;
|
---|
300 | cout << Verbose(0) << "===============================================" << endl;
|
---|
301 | cout << Verbose(0) << "INPUT: ";
|
---|
302 | cin >> choice;
|
---|
303 |
|
---|
304 | switch (choice) {
|
---|
305 | default:
|
---|
306 | cout << Verbose(0) << "Not a valid choice." << endl;
|
---|
307 | break;
|
---|
308 | case 'a':
|
---|
309 | cout << Verbose(0) << "Centering atoms in config file on origin." << endl;
|
---|
310 | mol->CenterOrigin();
|
---|
311 | break;
|
---|
312 | case 'b':
|
---|
313 | cout << Verbose(0) << "Centering atoms in config file on center of gravity." << endl;
|
---|
314 | mol->CenterPeriodic();
|
---|
315 | break;
|
---|
316 | case 'c':
|
---|
317 | cout << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;
|
---|
318 | for (int i=0;i<NDIM;i++) {
|
---|
319 | cout << Verbose(0) << "Enter axis " << i << " boundary: ";
|
---|
320 | cin >> y.x[i];
|
---|
321 | }
|
---|
322 | mol->CenterEdge(&x); // make every coordinate positive
|
---|
323 | mol->Center.AddVector(&y); // translate by boundary
|
---|
324 | helper.CopyVector(&y);
|
---|
325 | helper.Scale(2.);
|
---|
326 | helper.AddVector(&x);
|
---|
327 | mol->SetBoxDimension(&helper); // update Box of atoms by boundary
|
---|
328 | break;
|
---|
329 | case 'd':
|
---|
330 | cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
|
---|
331 | for (int i=0;i<NDIM;i++) {
|
---|
332 | cout << Verbose(0) << "Enter axis " << i << " boundary: ";
|
---|
333 | cin >> x.x[i];
|
---|
334 | }
|
---|
335 | // update Box of atoms by boundary
|
---|
336 | mol->SetBoxDimension(&x);
|
---|
337 | // center
|
---|
338 | mol->CenterInBox();
|
---|
339 | break;
|
---|
340 | }
|
---|
341 | };
|
---|
342 |
|
---|
343 | /** Submenu for aligning the atoms in the molecule.
|
---|
344 | * \param *periode periodentafel
|
---|
345 | * \param *mol molecule with all the atoms
|
---|
346 | */
|
---|
347 | static void AlignAtoms(periodentafel *periode, molecule *mol)
|
---|
348 | {
|
---|
349 | atom *first, *second, *third;
|
---|
350 | Vector x,n;
|
---|
351 | char choice; // menu choice char
|
---|
352 |
|
---|
353 | cout << Verbose(0) << "===========ALIGN ATOMS=========================" << endl;
|
---|
354 | cout << Verbose(0) << " a - state three atoms defining align plane" << endl;
|
---|
355 | cout << Verbose(0) << " b - state alignment vector" << endl;
|
---|
356 | cout << Verbose(0) << " c - state two atoms in alignment direction" << endl;
|
---|
357 | cout << Verbose(0) << " d - align automatically by least square fit" << endl;
|
---|
358 | cout << Verbose(0) << "all else - go back" << endl;
|
---|
359 | cout << Verbose(0) << "===============================================" << endl;
|
---|
360 | cout << Verbose(0) << "INPUT: ";
|
---|
361 | cin >> choice;
|
---|
362 |
|
---|
363 | switch (choice) {
|
---|
364 | default:
|
---|
365 | case 'a': // three atoms defining mirror plane
|
---|
366 | first = mol->AskAtom("Enter first atom: ");
|
---|
367 | second = mol->AskAtom("Enter second atom: ");
|
---|
368 | third = mol->AskAtom("Enter third atom: ");
|
---|
369 |
|
---|
370 | n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
|
---|
371 | break;
|
---|
372 | case 'b': // normal vector of mirror plane
|
---|
373 | cout << Verbose(0) << "Enter normal vector of mirror plane." << endl;
|
---|
374 | n.AskPosition(World::getInstance().getDomain(),0);
|
---|
375 | n.Normalize();
|
---|
376 | break;
|
---|
377 | case 'c': // three atoms defining mirror plane
|
---|
378 | first = mol->AskAtom("Enter first atom: ");
|
---|
379 | second = mol->AskAtom("Enter second atom: ");
|
---|
380 |
|
---|
381 | n.CopyVector((const Vector *)&first->x);
|
---|
382 | n.SubtractVector((const Vector *)&second->x);
|
---|
383 | n.Normalize();
|
---|
384 | break;
|
---|
385 | case 'd':
|
---|
386 | char shorthand[4];
|
---|
387 | Vector a;
|
---|
388 | struct lsq_params param;
|
---|
389 | do {
|
---|
390 | fprintf(stdout, "Enter the element of atoms to be chosen: ");
|
---|
391 | fscanf(stdin, "%3s", shorthand);
|
---|
392 | } while ((param.type = periode->FindElement(shorthand)) == NULL);
|
---|
393 | cout << Verbose(0) << "Element is " << param.type->name << endl;
|
---|
394 | mol->GetAlignvector(¶m);
|
---|
395 | for (int i=NDIM;i--;) {
|
---|
396 | x.x[i] = gsl_vector_get(param.x,i);
|
---|
397 | n.x[i] = gsl_vector_get(param.x,i+NDIM);
|
---|
398 | }
|
---|
399 | gsl_vector_free(param.x);
|
---|
400 | cout << Verbose(0) << "Offset vector: ";
|
---|
401 | x.Output();
|
---|
402 | DoLog(0) && (Log() << Verbose(0) << endl);
|
---|
403 | n.Normalize();
|
---|
404 | break;
|
---|
405 | };
|
---|
406 | DoLog(0) && (Log() << Verbose(0) << "Alignment vector: ");
|
---|
407 | n.Output();
|
---|
408 | DoLog(0) && (Log() << Verbose(0) << endl);
|
---|
409 | mol->Align(&n);
|
---|
410 | };
|
---|
411 |
|
---|
412 | /** Submenu for mirroring the atoms in the molecule.
|
---|
413 | * \param *mol molecule with all the atoms
|
---|
414 | */
|
---|
415 | static void MirrorAtoms(molecule *mol)
|
---|
416 | {
|
---|
417 | atom *first, *second, *third;
|
---|
418 | Vector n;
|
---|
419 | char choice; // menu choice char
|
---|
420 |
|
---|
421 | DoLog(0) && (Log() << Verbose(0) << "===========MIRROR ATOMS=========================" << endl);
|
---|
422 | DoLog(0) && (Log() << Verbose(0) << " a - state three atoms defining mirror plane" << endl);
|
---|
423 | DoLog(0) && (Log() << Verbose(0) << " b - state normal vector of mirror plane" << endl);
|
---|
424 | DoLog(0) && (Log() << Verbose(0) << " c - state two atoms in normal direction" << endl);
|
---|
425 | DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
|
---|
426 | DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
|
---|
427 | DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
|
---|
428 | cin >> choice;
|
---|
429 |
|
---|
430 | switch (choice) {
|
---|
431 | default:
|
---|
432 | case 'a': // three atoms defining mirror plane
|
---|
433 | first = mol->AskAtom("Enter first atom: ");
|
---|
434 | second = mol->AskAtom("Enter second atom: ");
|
---|
435 | third = mol->AskAtom("Enter third atom: ");
|
---|
436 |
|
---|
437 | n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
|
---|
438 | break;
|
---|
439 | case 'b': // normal vector of mirror plane
|
---|
440 | DoLog(0) && (Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl);
|
---|
441 | n.AskPosition(World::getInstance().getDomain(),0);
|
---|
442 | n.Normalize();
|
---|
443 | break;
|
---|
444 | case 'c': // three atoms defining mirror plane
|
---|
445 | first = mol->AskAtom("Enter first atom: ");
|
---|
446 | second = mol->AskAtom("Enter second atom: ");
|
---|
447 |
|
---|
448 | n.CopyVector((const Vector *)&first->x);
|
---|
449 | n.SubtractVector((const Vector *)&second->x);
|
---|
450 | n.Normalize();
|
---|
451 | break;
|
---|
452 | };
|
---|
453 | DoLog(0) && (Log() << Verbose(0) << "Normal vector: ");
|
---|
454 | n.Output();
|
---|
455 | DoLog(0) && (Log() << Verbose(0) << endl);
|
---|
456 | mol->Mirror((const Vector *)&n);
|
---|
457 | };
|
---|
458 |
|
---|
459 | /** Submenu for removing the atoms from the molecule.
|
---|
460 | * \param *mol molecule with all the atoms
|
---|
461 | */
|
---|
462 | static void RemoveAtoms(molecule *mol)
|
---|
463 | {
|
---|
464 | atom *first, *second;
|
---|
465 | int axis;
|
---|
466 | double tmp1, tmp2;
|
---|
467 | char choice; // menu choice char
|
---|
468 |
|
---|
469 | DoLog(0) && (Log() << Verbose(0) << "===========REMOVE ATOMS=========================" << endl);
|
---|
470 | DoLog(0) && (Log() << Verbose(0) << " a - state atom for removal by number" << endl);
|
---|
471 | DoLog(0) && (Log() << Verbose(0) << " b - keep only in radius around atom" << endl);
|
---|
472 | DoLog(0) && (Log() << Verbose(0) << " c - remove this with one axis greater value" << endl);
|
---|
473 | DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
|
---|
474 | DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
|
---|
475 | DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
|
---|
476 | cin >> choice;
|
---|
477 |
|
---|
478 | switch (choice) {
|
---|
479 | default:
|
---|
480 | case 'a':
|
---|
481 | if (mol->RemoveAtom(mol->AskAtom("Enter number of atom within molecule: ")))
|
---|
482 | DoLog(1) && (Log() << Verbose(1) << "Atom removed." << endl);
|
---|
483 | else
|
---|
484 | DoLog(1) && (Log() << Verbose(1) << "Atom not found." << endl);
|
---|
485 | break;
|
---|
486 | case 'b':
|
---|
487 | second = mol->AskAtom("Enter number of atom as reference point: ");
|
---|
488 | DoLog(0) && (Log() << Verbose(0) << "Enter radius: ");
|
---|
489 | cin >> tmp1;
|
---|
490 | first = mol->start;
|
---|
491 | second = first->next;
|
---|
492 | while(second != mol->end) {
|
---|
493 | first = second;
|
---|
494 | second = first->next;
|
---|
495 | if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...
|
---|
496 | mol->RemoveAtom(first);
|
---|
497 | }
|
---|
498 | break;
|
---|
499 | case 'c':
|
---|
500 | DoLog(0) && (Log() << Verbose(0) << "Which axis is it: ");
|
---|
501 | cin >> axis;
|
---|
502 | DoLog(0) && (Log() << Verbose(0) << "Lower boundary: ");
|
---|
503 | cin >> tmp1;
|
---|
504 | DoLog(0) && (Log() << Verbose(0) << "Upper boundary: ");
|
---|
505 | cin >> tmp2;
|
---|
506 | first = mol->start;
|
---|
507 | second = first->next;
|
---|
508 | while(second != mol->end) {
|
---|
509 | first = second;
|
---|
510 | second = first->next;
|
---|
511 | if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
|
---|
512 | //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
|
---|
513 | mol->RemoveAtom(first);
|
---|
514 | }
|
---|
515 | }
|
---|
516 | break;
|
---|
517 | };
|
---|
518 | //mol->Output();
|
---|
519 | choice = 'r';
|
---|
520 | };
|
---|
521 |
|
---|
522 | /** Submenu for measuring out the atoms in the molecule.
|
---|
523 | * \param *periode periodentafel
|
---|
524 | * \param *mol molecule with all the atoms
|
---|
525 | */
|
---|
526 | static void MeasureAtoms(periodentafel *periode, molecule *mol, config *configuration)
|
---|
527 | {
|
---|
528 | atom *first, *second, *third;
|
---|
529 | Vector x,y;
|
---|
530 | double min[256], tmp1, tmp2, tmp3;
|
---|
531 | int Z;
|
---|
532 | char choice; // menu choice char
|
---|
533 |
|
---|
534 | DoLog(0) && (Log() << Verbose(0) << "===========MEASURE ATOMS=========================" << endl);
|
---|
535 | DoLog(0) && (Log() << Verbose(0) << " a - calculate bond length between one atom and all others" << endl);
|
---|
536 | DoLog(0) && (Log() << Verbose(0) << " b - calculate bond length between two atoms" << endl);
|
---|
537 | DoLog(0) && (Log() << Verbose(0) << " c - calculate bond angle" << endl);
|
---|
538 | DoLog(0) && (Log() << Verbose(0) << " d - calculate principal axis of the system" << endl);
|
---|
539 | DoLog(0) && (Log() << Verbose(0) << " e - calculate volume of the convex envelope" << endl);
|
---|
540 | DoLog(0) && (Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl);
|
---|
541 | DoLog(0) && (Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl);
|
---|
542 | DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
|
---|
543 | DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
|
---|
544 | DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
|
---|
545 | cin >> choice;
|
---|
546 |
|
---|
547 | switch(choice) {
|
---|
548 | default:
|
---|
549 | DoLog(1) && (Log() << Verbose(1) << "Not a valid choice." << endl);
|
---|
550 | break;
|
---|
551 | case 'a':
|
---|
552 | first = mol->AskAtom("Enter first atom: ");
|
---|
553 | for (int i=MAX_ELEMENTS;i--;)
|
---|
554 | min[i] = 0.;
|
---|
555 |
|
---|
556 | second = mol->start;
|
---|
557 | while ((second->next != mol->end)) {
|
---|
558 | second = second->next; // advance
|
---|
559 | Z = second->type->Z;
|
---|
560 | tmp1 = 0.;
|
---|
561 | if (first != second) {
|
---|
562 | x.CopyVector((const Vector *)&first->x);
|
---|
563 | x.SubtractVector((const Vector *)&second->x);
|
---|
564 | tmp1 = x.Norm();
|
---|
565 | }
|
---|
566 | if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
|
---|
567 | //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;
|
---|
568 | }
|
---|
569 | for (int i=MAX_ELEMENTS;i--;)
|
---|
570 | if (min[i] != 0.) Log() << Verbose(0) << "Minimum Bond length between " << first->type->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl;
|
---|
571 | break;
|
---|
572 |
|
---|
573 | case 'b':
|
---|
574 | first = mol->AskAtom("Enter first atom: ");
|
---|
575 | second = mol->AskAtom("Enter second atom: ");
|
---|
576 | for (int i=NDIM;i--;)
|
---|
577 | min[i] = 0.;
|
---|
578 | x.CopyVector((const Vector *)&first->x);
|
---|
579 | x.SubtractVector((const Vector *)&second->x);
|
---|
580 | tmp1 = x.Norm();
|
---|
581 | DoLog(1) && (Log() << Verbose(1) << "Distance vector is ");
|
---|
582 | x.Output();
|
---|
583 | DoLog(0) && (Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl);
|
---|
584 | break;
|
---|
585 |
|
---|
586 | case 'c':
|
---|
587 | DoLog(0) && (Log() << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl);
|
---|
588 | first = mol->AskAtom("Enter first atom: ");
|
---|
589 | second = mol->AskAtom("Enter central atom: ");
|
---|
590 | third = mol->AskAtom("Enter last atom: ");
|
---|
591 | tmp1 = tmp2 = tmp3 = 0.;
|
---|
592 | x.CopyVector((const Vector *)&first->x);
|
---|
593 | x.SubtractVector((const Vector *)&second->x);
|
---|
594 | y.CopyVector((const Vector *)&third->x);
|
---|
595 | y.SubtractVector((const Vector *)&second->x);
|
---|
596 | DoLog(0) && (Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ");
|
---|
597 | DoLog(0) && (Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl);
|
---|
598 | break;
|
---|
599 | case 'd':
|
---|
600 | DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
|
---|
601 | DoLog(0) && (Log() << Verbose(0) << "Shall we rotate? [0/1]: ");
|
---|
602 | cin >> Z;
|
---|
603 | if ((Z >=0) && (Z <=1))
|
---|
604 | mol->PrincipalAxisSystem((bool)Z);
|
---|
605 | else
|
---|
606 | mol->PrincipalAxisSystem(false);
|
---|
607 | break;
|
---|
608 | case 'e':
|
---|
609 | {
|
---|
610 | DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope.");
|
---|
611 | class Tesselation *TesselStruct = NULL;
|
---|
612 | const LinkedCell *LCList = NULL;
|
---|
613 | LCList = new LinkedCell(mol, 10.);
|
---|
614 | FindConvexBorder(mol, TesselStruct, LCList, NULL);
|
---|
615 | double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
|
---|
616 | DoLog(0) && (Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl);\
|
---|
617 | delete(LCList);
|
---|
618 | delete(TesselStruct);
|
---|
619 | }
|
---|
620 | break;
|
---|
621 | case 'f':
|
---|
622 | mol->OutputTemperatureFromTrajectories((ofstream *)&cout, mol->MDSteps-1, mol->MDSteps);
|
---|
623 | break;
|
---|
624 | case 'g':
|
---|
625 | {
|
---|
626 | char filename[255];
|
---|
627 | DoLog(0) && (Log() << Verbose(0) << "Please enter filename: " << endl);
|
---|
628 | cin >> filename;
|
---|
629 | DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl);
|
---|
630 | ofstream *output = new ofstream(filename, ios::trunc);
|
---|
631 | if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))
|
---|
632 | DoLog(2) && (Log() << Verbose(2) << "File could not be written." << endl);
|
---|
633 | else
|
---|
634 | DoLog(2) && (Log() << Verbose(2) << "File stored." << endl);
|
---|
635 | output->close();
|
---|
636 | delete(output);
|
---|
637 | }
|
---|
638 | break;
|
---|
639 | }
|
---|
640 | };
|
---|
641 |
|
---|
642 | /** Submenu for measuring out the atoms in the molecule.
|
---|
643 | * \param *mol molecule with all the atoms
|
---|
644 | * \param *configuration configuration structure for the to be written config files of all fragments
|
---|
645 | */
|
---|
646 | static void FragmentAtoms(molecule *mol, config *configuration)
|
---|
647 | {
|
---|
648 | int Order1;
|
---|
649 | clock_t start, end;
|
---|
650 |
|
---|
651 | DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
|
---|
652 | DoLog(0) && (Log() << Verbose(0) << "What's the desired bond order: ");
|
---|
653 | cin >> Order1;
|
---|
654 | if (mol->first->next != mol->last) { // there are bonds
|
---|
655 | start = clock();
|
---|
656 | mol->FragmentMolecule(Order1, configuration);
|
---|
657 | end = clock();
|
---|
658 | DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
|
---|
659 | } else
|
---|
660 | DoLog(0) && (Log() << Verbose(0) << "Connection matrix has not yet been generated!" << endl);
|
---|
661 | };
|
---|
662 |
|
---|
663 | /********************************************** Submenu routine **************************************/
|
---|
664 |
|
---|
665 | /** Submenu for manipulating atoms.
|
---|
666 | * \param *periode periodentafel
|
---|
667 | * \param *molecules list of molecules whose atoms are to be manipulated
|
---|
668 | */
|
---|
669 | static void ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
|
---|
670 | {
|
---|
671 | atom *first, *second, *third;
|
---|
672 | molecule *mol = NULL;
|
---|
673 | Vector x,y,z,n; // coordinates for absolute point in cell volume
|
---|
674 | double *factor; // unit factor if desired
|
---|
675 | double bond, minBond;
|
---|
676 | char choice; // menu choice char
|
---|
677 | bool valid;
|
---|
678 |
|
---|
679 | DoLog(0) && (Log() << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl);
|
---|
680 | DoLog(0) && (Log() << Verbose(0) << "a - add an atom" << endl);
|
---|
681 | DoLog(0) && (Log() << Verbose(0) << "r - remove an atom" << endl);
|
---|
682 | DoLog(0) && (Log() << Verbose(0) << "b - scale a bond between atoms" << endl);
|
---|
683 | DoLog(0) && (Log() << Verbose(0) << "t - turn an atom round another bond" << endl);
|
---|
684 | DoLog(0) && (Log() << Verbose(0) << "u - change an atoms element" << endl);
|
---|
685 | DoLog(0) && (Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl);
|
---|
686 | DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
|
---|
687 | DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
|
---|
688 | if (molecules->NumberOfActiveMolecules() > 1)
|
---|
689 | DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl);
|
---|
690 | DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
|
---|
691 | cin >> choice;
|
---|
692 |
|
---|
693 | switch (choice) {
|
---|
694 | default:
|
---|
695 | DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
|
---|
696 | break;
|
---|
697 |
|
---|
698 | case 'a': // add atom
|
---|
699 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
700 | if ((*ListRunner)->ActiveFlag) {
|
---|
701 | mol = *ListRunner;
|
---|
702 | DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
|
---|
703 | AddAtoms(periode, mol);
|
---|
704 | }
|
---|
705 | break;
|
---|
706 |
|
---|
707 | case 'b': // scale a bond
|
---|
708 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
709 | if ((*ListRunner)->ActiveFlag) {
|
---|
710 | mol = *ListRunner;
|
---|
711 | DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
|
---|
712 | DoLog(0) && (Log() << Verbose(0) << "Scaling bond length between two atoms." << endl);
|
---|
713 | first = mol->AskAtom("Enter first (fixed) atom: ");
|
---|
714 | second = mol->AskAtom("Enter second (shifting) atom: ");
|
---|
715 | minBond = 0.;
|
---|
716 | for (int i=NDIM;i--;)
|
---|
717 | minBond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]);
|
---|
718 | minBond = sqrt(minBond);
|
---|
719 | DoLog(0) && (Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl);
|
---|
720 | DoLog(0) && (Log() << Verbose(0) << "Enter new bond length [a.u.]: ");
|
---|
721 | cin >> bond;
|
---|
722 | for (int i=NDIM;i--;) {
|
---|
723 | second->x.x[i] -= (second->x.x[i]-first->x.x[i])/minBond*(minBond-bond);
|
---|
724 | }
|
---|
725 | //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";
|
---|
726 | //second->Output(second->type->No, 1);
|
---|
727 | }
|
---|
728 | break;
|
---|
729 |
|
---|
730 | case 'c': // unit scaling of the metric
|
---|
731 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
732 | if ((*ListRunner)->ActiveFlag) {
|
---|
733 | mol = *ListRunner;
|
---|
734 | DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
|
---|
735 | DoLog(0) && (Log() << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl);
|
---|
736 | DoLog(0) && (Log() << Verbose(0) << "Enter three factors: ");
|
---|
737 | factor = new double[NDIM];
|
---|
738 | cin >> factor[0];
|
---|
739 | cin >> factor[1];
|
---|
740 | cin >> factor[2];
|
---|
741 | valid = true;
|
---|
742 | mol->Scale((const double ** const)&factor);
|
---|
743 | delete[](factor);
|
---|
744 | }
|
---|
745 | break;
|
---|
746 |
|
---|
747 | case 'l': // measure distances or angles
|
---|
748 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
749 | if ((*ListRunner)->ActiveFlag) {
|
---|
750 | mol = *ListRunner;
|
---|
751 | DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
|
---|
752 | MeasureAtoms(periode, mol, configuration);
|
---|
753 | }
|
---|
754 | break;
|
---|
755 |
|
---|
756 | case 'r': // remove atom
|
---|
757 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
758 | if ((*ListRunner)->ActiveFlag) {
|
---|
759 | mol = *ListRunner;
|
---|
760 | DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
|
---|
761 | RemoveAtoms(mol);
|
---|
762 | }
|
---|
763 | break;
|
---|
764 |
|
---|
765 | case 't': // turn/rotate atom
|
---|
766 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
767 | if ((*ListRunner)->ActiveFlag) {
|
---|
768 | mol = *ListRunner;
|
---|
769 | DoLog(0) && (Log() << Verbose(0) << "Turning atom around another bond - first is atom to turn, second (central) and third specify bond" << endl);
|
---|
770 | first = mol->AskAtom("Enter turning atom: ");
|
---|
771 | second = mol->AskAtom("Enter central atom: ");
|
---|
772 | third = mol->AskAtom("Enter bond atom: ");
|
---|
773 | cout << Verbose(0) << "Enter new angle in degrees: ";
|
---|
774 | double tmp = 0.;
|
---|
775 | cin >> tmp;
|
---|
776 | // calculate old angle
|
---|
777 | x.CopyVector((const Vector *)&first->x);
|
---|
778 | x.SubtractVector((const Vector *)&second->x);
|
---|
779 | y.CopyVector((const Vector *)&third->x);
|
---|
780 | y.SubtractVector((const Vector *)&second->x);
|
---|
781 | double alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.);
|
---|
782 | cout << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
|
---|
783 | cout << Verbose(0) << alpha << " degrees" << endl;
|
---|
784 | // rotate
|
---|
785 | z.MakeNormalVector(&x,&y);
|
---|
786 | x.RotateVector(&z,(alpha-tmp)*M_PI/180.);
|
---|
787 | x.AddVector(&second->x);
|
---|
788 | first->x.CopyVector(&x);
|
---|
789 | // check new angle
|
---|
790 | x.CopyVector((const Vector *)&first->x);
|
---|
791 | x.SubtractVector((const Vector *)&second->x);
|
---|
792 | alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.);
|
---|
793 | cout << Verbose(0) << "new Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
|
---|
794 | cout << Verbose(0) << alpha << " degrees" << endl;
|
---|
795 | }
|
---|
796 | break;
|
---|
797 |
|
---|
798 | case 'u': // change an atom's element
|
---|
799 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
800 | if ((*ListRunner)->ActiveFlag) {
|
---|
801 | int Z;
|
---|
802 | mol = *ListRunner;
|
---|
803 | DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
|
---|
804 | first = NULL;
|
---|
805 | do {
|
---|
806 | DoLog(0) && (Log() << Verbose(0) << "Change the element of which atom: ");
|
---|
807 | cin >> Z;
|
---|
808 | } while ((first = mol->FindAtom(Z)) == NULL);
|
---|
809 | DoLog(0) && (Log() << Verbose(0) << "New element by atomic number Z: ");
|
---|
810 | cin >> Z;
|
---|
811 | first->type = periode->FindElement(Z);
|
---|
812 | DoLog(0) && (Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl);
|
---|
813 | }
|
---|
814 | break;
|
---|
815 | }
|
---|
816 | };
|
---|
817 |
|
---|
818 | /** Submenu for manipulating molecules.
|
---|
819 | * \param *periode periodentafel
|
---|
820 | * \param *molecules list of molecule to manipulate
|
---|
821 | */
|
---|
822 | static void ManipulateMolecules(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
|
---|
823 | {
|
---|
824 | atom *first = NULL;
|
---|
825 | Vector x,y,z,n; // coordinates for absolute point in cell volume
|
---|
826 | int j, axis, count, faktor;
|
---|
827 | char choice; // menu choice char
|
---|
828 | molecule *mol = NULL;
|
---|
829 | element **Elements;
|
---|
830 | Vector **vectors;
|
---|
831 | MoleculeLeafClass *Subgraphs = NULL;
|
---|
832 |
|
---|
833 | DoLog(0) && (Log() << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl);
|
---|
834 | DoLog(0) && (Log() << Verbose(0) << "c - scale by unit transformation" << endl);
|
---|
835 | DoLog(0) && (Log() << Verbose(0) << "d - duplicate molecule/periodic cell" << endl);
|
---|
836 | DoLog(0) && (Log() << Verbose(0) << "f - fragment molecule many-body bond order style" << endl);
|
---|
837 | DoLog(0) && (Log() << Verbose(0) << "g - center atoms in box" << endl);
|
---|
838 | DoLog(0) && (Log() << Verbose(0) << "i - realign molecule" << endl);
|
---|
839 | DoLog(0) && (Log() << Verbose(0) << "m - mirror all molecules" << endl);
|
---|
840 | DoLog(0) && (Log() << Verbose(0) << "o - create connection matrix" << endl);
|
---|
841 | DoLog(0) && (Log() << Verbose(0) << "t - translate molecule by vector" << endl);
|
---|
842 | DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
|
---|
843 | DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
|
---|
844 | if (molecules->NumberOfActiveMolecules() > 1)
|
---|
845 | DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl);
|
---|
846 | DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
|
---|
847 | cin >> choice;
|
---|
848 |
|
---|
849 | switch (choice) {
|
---|
850 | default:
|
---|
851 | DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
|
---|
852 | break;
|
---|
853 |
|
---|
854 | case 'd': // duplicate the periodic cell along a given axis, given times
|
---|
855 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
856 | if ((*ListRunner)->ActiveFlag) {
|
---|
857 | mol = *ListRunner;
|
---|
858 | DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
|
---|
859 | DoLog(0) && (Log() << Verbose(0) << "State the axis [(+-)123]: ");
|
---|
860 | cin >> axis;
|
---|
861 | DoLog(0) && (Log() << Verbose(0) << "State the factor: ");
|
---|
862 | cin >> faktor;
|
---|
863 |
|
---|
864 | mol->CountAtoms(); // recount atoms
|
---|
865 | if (mol->AtomCount != 0) { // if there is more than none
|
---|
866 | count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand
|
---|
867 | Elements = new element *[count];
|
---|
868 | vectors = new Vector *[count];
|
---|
869 | j = 0;
|
---|
870 | first = mol->start;
|
---|
871 | while (first->next != mol->end) { // make a list of all atoms with coordinates and element
|
---|
872 | first = first->next;
|
---|
873 | Elements[j] = first->type;
|
---|
874 | vectors[j] = &first->x;
|
---|
875 | j++;
|
---|
876 | }
|
---|
877 | if (count != j)
|
---|
878 | DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
|
---|
879 | x.Zero();
|
---|
880 | y.Zero();
|
---|
881 | y.x[abs(axis)-1] = World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
|
---|
882 | for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times
|
---|
883 | x.AddVector(&y); // per factor one cell width further
|
---|
884 | for (int k=count;k--;) { // go through every atom of the original cell
|
---|
885 | first = new atom(); // create a new body
|
---|
886 | first->x.CopyVector(vectors[k]); // use coordinate of original atom
|
---|
887 | first->x.AddVector(&x); // translate the coordinates
|
---|
888 | first->type = Elements[k]; // insert original element
|
---|
889 | mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
|
---|
890 | }
|
---|
891 | }
|
---|
892 | if (mol->first->next != mol->last) // if connect matrix is present already, redo it
|
---|
893 | mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
|
---|
894 | // free memory
|
---|
895 | delete[](Elements);
|
---|
896 | delete[](vectors);
|
---|
897 | // correct cell size
|
---|
898 | if (axis < 0) { // if sign was negative, we have to translate everything
|
---|
899 | x.Zero();
|
---|
900 | x.AddVector(&y);
|
---|
901 | x.Scale(-(faktor-1));
|
---|
902 | mol->Translate(&x);
|
---|
903 | }
|
---|
904 | World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
|
---|
905 | }
|
---|
906 | }
|
---|
907 | break;
|
---|
908 |
|
---|
909 | case 'f':
|
---|
910 | FragmentAtoms(mol, configuration);
|
---|
911 | break;
|
---|
912 |
|
---|
913 | case 'g': // center the atoms
|
---|
914 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
915 | if ((*ListRunner)->ActiveFlag) {
|
---|
916 | mol = *ListRunner;
|
---|
917 | DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
|
---|
918 | CenterAtoms(mol);
|
---|
919 | }
|
---|
920 | break;
|
---|
921 |
|
---|
922 | case 'i': // align all atoms
|
---|
923 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
924 | if ((*ListRunner)->ActiveFlag) {
|
---|
925 | mol = *ListRunner;
|
---|
926 | DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
|
---|
927 | AlignAtoms(periode, mol);
|
---|
928 | }
|
---|
929 | break;
|
---|
930 |
|
---|
931 | case 'm': // mirror atoms along a given axis
|
---|
932 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
933 | if ((*ListRunner)->ActiveFlag) {
|
---|
934 | mol = *ListRunner;
|
---|
935 | DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
|
---|
936 | MirrorAtoms(mol);
|
---|
937 | }
|
---|
938 | break;
|
---|
939 |
|
---|
940 | case 'o': // create the connection matrix
|
---|
941 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
942 | if ((*ListRunner)->ActiveFlag) {
|
---|
943 | mol = *ListRunner;
|
---|
944 | double bonddistance;
|
---|
945 | clock_t start,end;
|
---|
946 | DoLog(0) && (Log() << Verbose(0) << "What's the maximum bond distance: ");
|
---|
947 | cin >> bonddistance;
|
---|
948 | start = clock();
|
---|
949 | mol->CreateAdjacencyList(bonddistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
|
---|
950 | end = clock();
|
---|
951 | DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
|
---|
952 | }
|
---|
953 | break;
|
---|
954 |
|
---|
955 | case 't': // translate all atoms
|
---|
956 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
957 | if ((*ListRunner)->ActiveFlag) {
|
---|
958 | mol = *ListRunner;
|
---|
959 | DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
|
---|
960 | DoLog(0) && (Log() << Verbose(0) << "Enter translation vector." << endl);
|
---|
961 | x.AskPosition(World::getInstance().getDomain(),0);
|
---|
962 | mol->Center.AddVector((const Vector *)&x);
|
---|
963 | }
|
---|
964 | break;
|
---|
965 | }
|
---|
966 | // Free all
|
---|
967 | if (Subgraphs != NULL) { // free disconnected subgraph list of DFS analysis was performed
|
---|
968 | while (Subgraphs->next != NULL) {
|
---|
969 | Subgraphs = Subgraphs->next;
|
---|
970 | delete(Subgraphs->previous);
|
---|
971 | }
|
---|
972 | delete(Subgraphs);
|
---|
973 | }
|
---|
974 | };
|
---|
975 |
|
---|
976 |
|
---|
977 | /** Submenu for creating new molecules.
|
---|
978 | * \param *periode periodentafel
|
---|
979 | * \param *molecules list of molecules to add to
|
---|
980 | */
|
---|
981 | static void EditMolecules(periodentafel *periode, MoleculeListClass *molecules)
|
---|
982 | {
|
---|
983 | char choice; // menu choice char
|
---|
984 | Vector center;
|
---|
985 | int nr, count;
|
---|
986 | molecule *mol = NULL;
|
---|
987 |
|
---|
988 | DoLog(0) && (Log() << Verbose(0) << "==========EDIT MOLECULES=====================" << endl);
|
---|
989 | DoLog(0) && (Log() << Verbose(0) << "c - create new molecule" << endl);
|
---|
990 | DoLog(0) && (Log() << Verbose(0) << "l - load molecule from xyz file" << endl);
|
---|
991 | DoLog(0) && (Log() << Verbose(0) << "n - change molecule's name" << endl);
|
---|
992 | DoLog(0) && (Log() << Verbose(0) << "N - give molecules filename" << endl);
|
---|
993 | DoLog(0) && (Log() << Verbose(0) << "p - parse atoms in xyz file into molecule" << endl);
|
---|
994 | DoLog(0) && (Log() << Verbose(0) << "r - remove a molecule" << endl);
|
---|
995 | DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
|
---|
996 | DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
|
---|
997 | DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
|
---|
998 | cin >> choice;
|
---|
999 |
|
---|
1000 | switch (choice) {
|
---|
1001 | default:
|
---|
1002 | DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
|
---|
1003 | break;
|
---|
1004 | case 'c':
|
---|
1005 | mol = World::getInstance().createMolecule();
|
---|
1006 | molecules->insert(mol);
|
---|
1007 | break;
|
---|
1008 |
|
---|
1009 | case 'l': // load from XYZ file
|
---|
1010 | {
|
---|
1011 | char filename[MAXSTRINGSIZE];
|
---|
1012 | DoLog(0) && (Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl);
|
---|
1013 | mol = World::getInstance().createMolecule();
|
---|
1014 | do {
|
---|
1015 | DoLog(0) && (Log() << Verbose(0) << "Enter file name: ");
|
---|
1016 | cin >> filename;
|
---|
1017 | } while (!mol->AddXYZFile(filename));
|
---|
1018 | mol->SetNameFromFilename(filename);
|
---|
1019 | // center at set box dimensions
|
---|
1020 | mol->CenterEdge(¢er);
|
---|
1021 | double * const cell_size = World::getInstance().getDomain();
|
---|
1022 | cell_size[0] = center.x[0];
|
---|
1023 | cell_size[1] = 0;
|
---|
1024 | cell_size[2] = center.x[1];
|
---|
1025 | cell_size[3] = 0;
|
---|
1026 | cell_size[4] = 0;
|
---|
1027 | cell_size[5] = center.x[2];
|
---|
1028 | molecules->insert(mol);
|
---|
1029 | }
|
---|
1030 | break;
|
---|
1031 |
|
---|
1032 | case 'n':
|
---|
1033 | {
|
---|
1034 | char filename[MAXSTRINGSIZE];
|
---|
1035 | do {
|
---|
1036 | DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
|
---|
1037 | cin >> nr;
|
---|
1038 | mol = molecules->ReturnIndex(nr);
|
---|
1039 | } while (mol == NULL);
|
---|
1040 | DoLog(0) && (Log() << Verbose(0) << "Enter name: ");
|
---|
1041 | cin >> filename;
|
---|
1042 | strcpy(mol->name, filename);
|
---|
1043 | }
|
---|
1044 | break;
|
---|
1045 |
|
---|
1046 | case 'N':
|
---|
1047 | {
|
---|
1048 | char filename[MAXSTRINGSIZE];
|
---|
1049 | do {
|
---|
1050 | DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
|
---|
1051 | cin >> nr;
|
---|
1052 | mol = molecules->ReturnIndex(nr);
|
---|
1053 | } while (mol == NULL);
|
---|
1054 | DoLog(0) && (Log() << Verbose(0) << "Enter name: ");
|
---|
1055 | cin >> filename;
|
---|
1056 | mol->SetNameFromFilename(filename);
|
---|
1057 | }
|
---|
1058 | break;
|
---|
1059 |
|
---|
1060 | case 'p': // parse XYZ file
|
---|
1061 | {
|
---|
1062 | char filename[MAXSTRINGSIZE];
|
---|
1063 | mol = NULL;
|
---|
1064 | do {
|
---|
1065 | DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
|
---|
1066 | cin >> nr;
|
---|
1067 | mol = molecules->ReturnIndex(nr);
|
---|
1068 | } while (mol == NULL);
|
---|
1069 | DoLog(0) && (Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl);
|
---|
1070 | do {
|
---|
1071 | DoLog(0) && (Log() << Verbose(0) << "Enter file name: ");
|
---|
1072 | cin >> filename;
|
---|
1073 | } while (!mol->AddXYZFile(filename));
|
---|
1074 | mol->SetNameFromFilename(filename);
|
---|
1075 | }
|
---|
1076 | break;
|
---|
1077 |
|
---|
1078 | case 'r':
|
---|
1079 | DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
|
---|
1080 | cin >> nr;
|
---|
1081 | count = 1;
|
---|
1082 | for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
1083 | if (nr == (*ListRunner)->IndexNr) {
|
---|
1084 | mol = *ListRunner;
|
---|
1085 | molecules->ListOfMolecules.erase(ListRunner);
|
---|
1086 | delete(mol);
|
---|
1087 | break;
|
---|
1088 | }
|
---|
1089 | break;
|
---|
1090 | }
|
---|
1091 | };
|
---|
1092 |
|
---|
1093 |
|
---|
1094 | /** Submenu for merging molecules.
|
---|
1095 | * \param *periode periodentafel
|
---|
1096 | * \param *molecules list of molecules to add to
|
---|
1097 | */
|
---|
1098 | static void MergeMolecules(periodentafel *periode, MoleculeListClass *molecules)
|
---|
1099 | {
|
---|
1100 | char choice; // menu choice char
|
---|
1101 |
|
---|
1102 | DoLog(0) && (Log() << Verbose(0) << "===========MERGE MOLECULES=====================" << endl);
|
---|
1103 | DoLog(0) && (Log() << Verbose(0) << "a - simple add of one molecule to another" << endl);
|
---|
1104 | DoLog(0) && (Log() << Verbose(0) << "b - count the number of bonds of two elements" << endl);
|
---|
1105 | DoLog(0) && (Log() << Verbose(0) << "B - count the number of bonds of three elements " << endl);
|
---|
1106 | DoLog(0) && (Log() << Verbose(0) << "e - embedding merge of two molecules" << endl);
|
---|
1107 | DoLog(0) && (Log() << Verbose(0) << "h - count the number of hydrogen bonds" << endl);
|
---|
1108 | DoLog(0) && (Log() << Verbose(0) << "b - count the number of hydrogen bonds" << endl);
|
---|
1109 | DoLog(0) && (Log() << Verbose(0) << "m - multi-merge of all molecules" << endl);
|
---|
1110 | DoLog(0) && (Log() << Verbose(0) << "s - scatter merge of two molecules" << endl);
|
---|
1111 | DoLog(0) && (Log() << Verbose(0) << "t - simple merge of two molecules" << endl);
|
---|
1112 | DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
|
---|
1113 | DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
|
---|
1114 | DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
|
---|
1115 | cin >> choice;
|
---|
1116 |
|
---|
1117 | switch (choice) {
|
---|
1118 | default:
|
---|
1119 | DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
|
---|
1120 | break;
|
---|
1121 |
|
---|
1122 | case 'a':
|
---|
1123 | {
|
---|
1124 | int src, dest;
|
---|
1125 | molecule *srcmol = NULL, *destmol = NULL;
|
---|
1126 | {
|
---|
1127 | do {
|
---|
1128 | DoLog(0) && (Log() << Verbose(0) << "Enter index of destination molecule: ");
|
---|
1129 | cin >> dest;
|
---|
1130 | destmol = molecules->ReturnIndex(dest);
|
---|
1131 | } while ((destmol == NULL) && (dest != -1));
|
---|
1132 | do {
|
---|
1133 | DoLog(0) && (Log() << Verbose(0) << "Enter index of source molecule to add from: ");
|
---|
1134 | cin >> src;
|
---|
1135 | srcmol = molecules->ReturnIndex(src);
|
---|
1136 | } while ((srcmol == NULL) && (src != -1));
|
---|
1137 | if ((src != -1) && (dest != -1))
|
---|
1138 | molecules->SimpleAdd(srcmol, destmol);
|
---|
1139 | }
|
---|
1140 | }
|
---|
1141 | break;
|
---|
1142 |
|
---|
1143 | case 'b':
|
---|
1144 | {
|
---|
1145 | const int nr = 2;
|
---|
1146 | char *names[nr] = {"first", "second"};
|
---|
1147 | int Z[nr];
|
---|
1148 | element *elements[nr];
|
---|
1149 | for (int i=0;i<nr;i++) {
|
---|
1150 | Z[i] = 0;
|
---|
1151 | do {
|
---|
1152 | cout << "Enter " << names[i] << " element: ";
|
---|
1153 | cin >> Z[i];
|
---|
1154 | } while ((Z[i] <= 0) && (Z[i] > MAX_ELEMENTS));
|
---|
1155 | elements[i] = periode->FindElement(Z[i]);
|
---|
1156 | }
|
---|
1157 | const int count = CountBondsOfTwo(molecules, elements[0], elements[1]);
|
---|
1158 | cout << endl << "There are " << count << " ";
|
---|
1159 | for (int i=0;i<nr;i++) {
|
---|
1160 | if (i==0)
|
---|
1161 | cout << elements[i]->symbol;
|
---|
1162 | else
|
---|
1163 | cout << "-" << elements[i]->symbol;
|
---|
1164 | }
|
---|
1165 | cout << " bonds." << endl;
|
---|
1166 | }
|
---|
1167 | break;
|
---|
1168 |
|
---|
1169 | case 'B':
|
---|
1170 | {
|
---|
1171 | const int nr = 3;
|
---|
1172 | char *names[nr] = {"first", "second", "third"};
|
---|
1173 | int Z[nr];
|
---|
1174 | element *elements[nr];
|
---|
1175 | for (int i=0;i<nr;i++) {
|
---|
1176 | Z[i] = 0;
|
---|
1177 | do {
|
---|
1178 | cout << "Enter " << names[i] << " element: ";
|
---|
1179 | cin >> Z[i];
|
---|
1180 | } while ((Z[i] <= 0) && (Z[i] > MAX_ELEMENTS));
|
---|
1181 | elements[i] = periode->FindElement(Z[i]);
|
---|
1182 | }
|
---|
1183 | const int count = CountBondsOfThree(molecules, elements[0], elements[1], elements[2]);
|
---|
1184 | cout << endl << "There are " << count << " ";
|
---|
1185 | for (int i=0;i<nr;i++) {
|
---|
1186 | if (i==0)
|
---|
1187 | cout << elements[i]->symbol;
|
---|
1188 | else
|
---|
1189 | cout << "-" << elements[i]->symbol;
|
---|
1190 | }
|
---|
1191 | cout << " bonds." << endl;
|
---|
1192 | }
|
---|
1193 | break;
|
---|
1194 |
|
---|
1195 | case 'e':
|
---|
1196 | {
|
---|
1197 | int src, dest;
|
---|
1198 | molecule *srcmol = NULL, *destmol = NULL;
|
---|
1199 | do {
|
---|
1200 | DoLog(0) && (Log() << Verbose(0) << "Enter index of matrix molecule (the variable one): ");
|
---|
1201 | cin >> src;
|
---|
1202 | srcmol = molecules->ReturnIndex(src);
|
---|
1203 | } while ((srcmol == NULL) && (src != -1));
|
---|
1204 | do {
|
---|
1205 | DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule to merge into (the fixed one): ");
|
---|
1206 | cin >> dest;
|
---|
1207 | destmol = molecules->ReturnIndex(dest);
|
---|
1208 | } while ((destmol == NULL) && (dest != -1));
|
---|
1209 | if ((src != -1) && (dest != -1))
|
---|
1210 | molecules->EmbedMerge(destmol, srcmol);
|
---|
1211 | }
|
---|
1212 | break;
|
---|
1213 |
|
---|
1214 | case 'h':
|
---|
1215 | {
|
---|
1216 | int Z;
|
---|
1217 | cout << "Please enter interface element: ";
|
---|
1218 | cin >> Z;
|
---|
1219 | element * const InterfaceElement = periode->FindElement(Z);
|
---|
1220 | cout << endl << "There are " << CountHydrogenBridgeBonds(molecules, InterfaceElement) << " hydrogen bridges with connections to " << (InterfaceElement != 0 ? InterfaceElement->name : "None") << "." << endl;
|
---|
1221 | }
|
---|
1222 | break;
|
---|
1223 |
|
---|
1224 | case 'm':
|
---|
1225 | {
|
---|
1226 | int nr;
|
---|
1227 | molecule *mol = NULL;
|
---|
1228 | do {
|
---|
1229 | DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule to merge into: ");
|
---|
1230 | cin >> nr;
|
---|
1231 | mol = molecules->ReturnIndex(nr);
|
---|
1232 | } while ((mol == NULL) && (nr != -1));
|
---|
1233 | if (nr != -1) {
|
---|
1234 | int N = molecules->ListOfMolecules.size()-1;
|
---|
1235 | int *src = new int(N);
|
---|
1236 | for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
1237 | if ((*ListRunner)->IndexNr != nr)
|
---|
1238 | src[N++] = (*ListRunner)->IndexNr;
|
---|
1239 | molecules->SimpleMultiMerge(mol, src, N);
|
---|
1240 | delete[](src);
|
---|
1241 | }
|
---|
1242 | }
|
---|
1243 | break;
|
---|
1244 |
|
---|
1245 | case 's':
|
---|
1246 | DoLog(0) && (Log() << Verbose(0) << "Not implemented yet." << endl);
|
---|
1247 | break;
|
---|
1248 |
|
---|
1249 | case 't':
|
---|
1250 | {
|
---|
1251 | int src, dest;
|
---|
1252 | molecule *srcmol = NULL, *destmol = NULL;
|
---|
1253 | {
|
---|
1254 | do {
|
---|
1255 | DoLog(0) && (Log() << Verbose(0) << "Enter index of destination molecule: ");
|
---|
1256 | cin >> dest;
|
---|
1257 | destmol = molecules->ReturnIndex(dest);
|
---|
1258 | } while ((destmol == NULL) && (dest != -1));
|
---|
1259 | do {
|
---|
1260 | DoLog(0) && (Log() << Verbose(0) << "Enter index of source molecule to merge into: ");
|
---|
1261 | cin >> src;
|
---|
1262 | srcmol = molecules->ReturnIndex(src);
|
---|
1263 | } while ((srcmol == NULL) && (src != -1));
|
---|
1264 | if ((src != -1) && (dest != -1))
|
---|
1265 | molecules->SimpleMerge(srcmol, destmol);
|
---|
1266 | }
|
---|
1267 | }
|
---|
1268 | break;
|
---|
1269 | }
|
---|
1270 | };
|
---|
1271 |
|
---|
1272 | /********************************************** Test routine **************************************/
|
---|
1273 |
|
---|
1274 | /** Is called always as option 'T' in the menu.
|
---|
1275 | * \param *molecules list of molecules
|
---|
1276 | */
|
---|
1277 | static void testroutine(MoleculeListClass *molecules)
|
---|
1278 | {
|
---|
1279 | // the current test routine checks the functionality of the KeySet&Graph concept:
|
---|
1280 | // We want to have a multiindex (the KeySet) describing a unique subgraph
|
---|
1281 | int i, comp, counter=0;
|
---|
1282 |
|
---|
1283 | // create a clone
|
---|
1284 | molecule *mol = NULL;
|
---|
1285 | if (molecules->ListOfMolecules.size() != 0) // clone
|
---|
1286 | mol = (molecules->ListOfMolecules.front())->CopyMolecule();
|
---|
1287 | else {
|
---|
1288 | DoeLog(0) && (eLog()<< Verbose(0) << "I don't have anything to test on ... ");
|
---|
1289 | performCriticalExit();
|
---|
1290 | return;
|
---|
1291 | }
|
---|
1292 | atom *Walker = mol->start;
|
---|
1293 |
|
---|
1294 | // generate some KeySets
|
---|
1295 | DoLog(0) && (Log() << Verbose(0) << "Generating KeySets." << endl);
|
---|
1296 | KeySet TestSets[mol->AtomCount+1];
|
---|
1297 | i=1;
|
---|
1298 | while (Walker->next != mol->end) {
|
---|
1299 | Walker = Walker->next;
|
---|
1300 | for (int j=0;j<i;j++) {
|
---|
1301 | TestSets[j].insert(Walker->nr);
|
---|
1302 | }
|
---|
1303 | i++;
|
---|
1304 | }
|
---|
1305 | DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl);
|
---|
1306 | KeySetTestPair test;
|
---|
1307 | test = TestSets[mol->AtomCount-1].insert(Walker->nr);
|
---|
1308 | if (test.second) {
|
---|
1309 | DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
|
---|
1310 | } else {
|
---|
1311 | DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl);
|
---|
1312 | }
|
---|
1313 | TestSets[mol->AtomCount].insert(mol->end->previous->nr);
|
---|
1314 | TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
|
---|
1315 |
|
---|
1316 | // constructing Graph structure
|
---|
1317 | DoLog(0) && (Log() << Verbose(0) << "Generating Subgraph class." << endl);
|
---|
1318 | Graph Subgraphs;
|
---|
1319 |
|
---|
1320 | // insert KeySets into Subgraphs
|
---|
1321 | DoLog(0) && (Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl);
|
---|
1322 | for (int j=0;j<mol->AtomCount;j++) {
|
---|
1323 | Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
|
---|
1324 | }
|
---|
1325 | DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl);
|
---|
1326 | GraphTestPair test2;
|
---|
1327 | test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
|
---|
1328 | if (test2.second) {
|
---|
1329 | DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
|
---|
1330 | } else {
|
---|
1331 | DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl);
|
---|
1332 | }
|
---|
1333 |
|
---|
1334 | // show graphs
|
---|
1335 | DoLog(0) && (Log() << Verbose(0) << "Showing Subgraph's contents, checking that it's sorted." << endl);
|
---|
1336 | Graph::iterator A = Subgraphs.begin();
|
---|
1337 | while (A != Subgraphs.end()) {
|
---|
1338 | DoLog(0) && (Log() << Verbose(0) << (*A).second.first << ": ");
|
---|
1339 | KeySet::iterator key = (*A).first.begin();
|
---|
1340 | comp = -1;
|
---|
1341 | while (key != (*A).first.end()) {
|
---|
1342 | if ((*key) > comp)
|
---|
1343 | DoLog(0) && (Log() << Verbose(0) << (*key) << " ");
|
---|
1344 | else
|
---|
1345 | DoLog(0) && (Log() << Verbose(0) << (*key) << "! ");
|
---|
1346 | comp = (*key);
|
---|
1347 | key++;
|
---|
1348 | }
|
---|
1349 | DoLog(0) && (Log() << Verbose(0) << endl);
|
---|
1350 | A++;
|
---|
1351 | }
|
---|
1352 | delete(mol);
|
---|
1353 | };
|
---|
1354 |
|
---|
1355 | #endif
|
---|
1356 |
|
---|
1357 | /** Tries given filename or standard on saving the config file.
|
---|
1358 | * \param *ConfigFileName name of file
|
---|
1359 | * \param *configuration pointer to configuration structure with all the values
|
---|
1360 | * \param *periode pointer to periodentafel structure with all the elements
|
---|
1361 | * \param *molecules list of molecules structure with all the atoms and coordinates
|
---|
1362 | */
|
---|
1363 | static void SaveConfig(char *ConfigFileName, config *configuration, periodentafel *periode, MoleculeListClass *molecules)
|
---|
1364 | {
|
---|
1365 | char filename[MAXSTRINGSIZE];
|
---|
1366 | ofstream output;
|
---|
1367 | molecule *mol = World::getInstance().createMolecule();
|
---|
1368 | mol->SetNameFromFilename(ConfigFileName);
|
---|
1369 |
|
---|
1370 | if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
|
---|
1371 | DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl);
|
---|
1372 | }
|
---|
1373 |
|
---|
1374 |
|
---|
1375 | // first save as PDB data
|
---|
1376 | if (ConfigFileName != NULL)
|
---|
1377 | strcpy(filename, ConfigFileName);
|
---|
1378 | if (output == NULL)
|
---|
1379 | strcpy(filename,"main_pcp_linux");
|
---|
1380 | DoLog(0) && (Log() << Verbose(0) << "Saving as pdb input ");
|
---|
1381 | if (configuration->SavePDB(filename, molecules))
|
---|
1382 | DoLog(0) && (Log() << Verbose(0) << "done." << endl);
|
---|
1383 | else
|
---|
1384 | DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
|
---|
1385 |
|
---|
1386 | // then save as tremolo data file
|
---|
1387 | if (ConfigFileName != NULL)
|
---|
1388 | strcpy(filename, ConfigFileName);
|
---|
1389 | if (output == NULL)
|
---|
1390 | strcpy(filename,"main_pcp_linux");
|
---|
1391 | DoLog(0) && (Log() << Verbose(0) << "Saving as tremolo data input ");
|
---|
1392 | if (configuration->SaveTREMOLO(filename, molecules))
|
---|
1393 | DoLog(0) && (Log() << Verbose(0) << "done." << endl);
|
---|
1394 | else
|
---|
1395 | DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
|
---|
1396 |
|
---|
1397 | // translate each to its center and merge all molecules in MoleculeListClass into this molecule
|
---|
1398 | int N = molecules->ListOfMolecules.size();
|
---|
1399 | int *src = new int[N];
|
---|
1400 | N=0;
|
---|
1401 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
|
---|
1402 | src[N++] = (*ListRunner)->IndexNr;
|
---|
1403 | (*ListRunner)->Translate(&(*ListRunner)->Center);
|
---|
1404 | }
|
---|
1405 | molecules->SimpleMultiAdd(mol, src, N);
|
---|
1406 | delete[](src);
|
---|
1407 |
|
---|
1408 | // ... and translate back
|
---|
1409 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
|
---|
1410 | (*ListRunner)->Center.Scale(-1.);
|
---|
1411 | (*ListRunner)->Translate(&(*ListRunner)->Center);
|
---|
1412 | (*ListRunner)->Center.Scale(-1.);
|
---|
1413 | }
|
---|
1414 |
|
---|
1415 | DoLog(0) && (Log() << Verbose(0) << "Storing configuration ... " << endl);
|
---|
1416 | // get correct valence orbitals
|
---|
1417 | mol->CalculateOrbitals(*configuration);
|
---|
1418 | configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble;
|
---|
1419 | if (ConfigFileName != NULL) { // test the file name
|
---|
1420 | strcpy(filename, ConfigFileName);
|
---|
1421 | output.open(filename, ios::trunc);
|
---|
1422 | } else if (strlen(configuration->configname) != 0) {
|
---|
1423 | strcpy(filename, configuration->configname);
|
---|
1424 | output.open(configuration->configname, ios::trunc);
|
---|
1425 | } else {
|
---|
1426 | strcpy(filename, DEFAULTCONFIG);
|
---|
1427 | output.open(DEFAULTCONFIG, ios::trunc);
|
---|
1428 | }
|
---|
1429 | output.close();
|
---|
1430 | output.clear();
|
---|
1431 | DoLog(0) && (Log() << Verbose(0) << "Saving of config file ");
|
---|
1432 | if (configuration->Save(filename, periode, mol))
|
---|
1433 | DoLog(0) && (Log() << Verbose(0) << "successful." << endl);
|
---|
1434 | else
|
---|
1435 | DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
|
---|
1436 |
|
---|
1437 | // and save to xyz file
|
---|
1438 | if (ConfigFileName != NULL) {
|
---|
1439 | strcpy(filename, ConfigFileName);
|
---|
1440 | strcat(filename, ".xyz");
|
---|
1441 | output.open(filename, ios::trunc);
|
---|
1442 | }
|
---|
1443 | if (output == NULL) {
|
---|
1444 | strcpy(filename,"main_pcp_linux");
|
---|
1445 | strcat(filename, ".xyz");
|
---|
1446 | output.open(filename, ios::trunc);
|
---|
1447 | }
|
---|
1448 | DoLog(0) && (Log() << Verbose(0) << "Saving of XYZ file ");
|
---|
1449 | if (mol->MDSteps <= 1) {
|
---|
1450 | if (mol->OutputXYZ(&output))
|
---|
1451 | DoLog(0) && (Log() << Verbose(0) << "successful." << endl);
|
---|
1452 | else
|
---|
1453 | DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
|
---|
1454 | } else {
|
---|
1455 | if (mol->OutputTrajectoriesXYZ(&output))
|
---|
1456 | DoLog(0) && (Log() << Verbose(0) << "successful." << endl);
|
---|
1457 | else
|
---|
1458 | DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
|
---|
1459 | }
|
---|
1460 | output.close();
|
---|
1461 | output.clear();
|
---|
1462 |
|
---|
1463 | // and save as MPQC configuration
|
---|
1464 | if (ConfigFileName != NULL)
|
---|
1465 | strcpy(filename, ConfigFileName);
|
---|
1466 | if (output == NULL)
|
---|
1467 | strcpy(filename,"main_pcp_linux");
|
---|
1468 | DoLog(0) && (Log() << Verbose(0) << "Saving as mpqc input ");
|
---|
1469 | if (configuration->SaveMPQC(filename, mol))
|
---|
1470 | DoLog(0) && (Log() << Verbose(0) << "done." << endl);
|
---|
1471 | else
|
---|
1472 | DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
|
---|
1473 |
|
---|
1474 | if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
|
---|
1475 | DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl);
|
---|
1476 | }
|
---|
1477 |
|
---|
1478 | World::getInstance().destroyMolecule(mol);
|
---|
1479 | };
|
---|
1480 |
|
---|
1481 | /** Parses the command line options.
|
---|
1482 | * \param argc argument count
|
---|
1483 | * \param **argv arguments array
|
---|
1484 | * \param *molecules list of molecules structure
|
---|
1485 | * \param *periode elements structure
|
---|
1486 | * \param configuration config file structure
|
---|
1487 | * \param *ConfigFileName pointer to config file name in **argv
|
---|
1488 | * \param *PathToDatabases pointer to db's path in **argv
|
---|
1489 | * \return exit code (0 - successful, all else - something's wrong)
|
---|
1490 | */
|
---|
1491 | static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode,\
|
---|
1492 | config& configuration, char *&ConfigFileName)
|
---|
1493 | {
|
---|
1494 | Vector x,y,z,n; // coordinates for absolute point in cell volume
|
---|
1495 | double *factor; // unit factor if desired
|
---|
1496 | ifstream test;
|
---|
1497 | ofstream output;
|
---|
1498 | string line;
|
---|
1499 | atom *first;
|
---|
1500 | bool SaveFlag = false;
|
---|
1501 | int ExitFlag = 0;
|
---|
1502 | int j;
|
---|
1503 | double volume = 0.;
|
---|
1504 | enum ConfigStatus configPresent = absent;
|
---|
1505 | clock_t start,end;
|
---|
1506 | double MaxDistance = -1;
|
---|
1507 | int argptr;
|
---|
1508 | molecule *mol = NULL;
|
---|
1509 | string BondGraphFileName("\n");
|
---|
1510 | int verbosity = 0;
|
---|
1511 | strncpy(configuration.databasepath, LocalPath, MAXSTRINGSIZE-1);
|
---|
1512 |
|
---|
1513 | if (argc > 1) { // config file specified as option
|
---|
1514 | // 1. : Parse options that just set variables or print help
|
---|
1515 | argptr = 1;
|
---|
1516 | do {
|
---|
1517 | if (argv[argptr][0] == '-') {
|
---|
1518 | DoLog(0) && (Log() << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n");
|
---|
1519 | argptr++;
|
---|
1520 | switch(argv[argptr-1][1]) {
|
---|
1521 | case 'h':
|
---|
1522 | case '?':
|
---|
1523 | DoLog(0) && (Log() << Verbose(0) << "MoleCuilder suite" << endl << "==================" << endl << endl);
|
---|
1524 | DoLog(0) && (Log() << Verbose(0) << "Usage: " << argv[0] << "[config file] [-{acefpsthH?vfrp}] [further arguments]" << endl);
|
---|
1525 | DoLog(0) && (Log() << Verbose(0) << "or simply " << argv[0] << " without arguments for interactive session." << endl);
|
---|
1526 | DoLog(0) && (Log() << Verbose(0) << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl);
|
---|
1527 | DoLog(0) && (Log() << Verbose(0) << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl);
|
---|
1528 | DoLog(0) && (Log() << Verbose(0) << "\t-b xx xy xz yy yz zz\tCenter atoms in domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl);
|
---|
1529 | DoLog(0) && (Log() << Verbose(0) << "\t-B xx xy xz yy yz zz\tBound atoms by domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl);
|
---|
1530 | DoLog(0) && (Log() << Verbose(0) << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl);
|
---|
1531 | DoLog(0) && (Log() << Verbose(0) << "\t-C <type> [params] <output> <bin output> <BinWidth> <BinStart> <BinEnd>\tPair Correlation analysis." << endl);
|
---|
1532 | DoLog(0) && (Log() << Verbose(0) << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl);
|
---|
1533 | DoLog(0) && (Log() << Verbose(0) << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl);
|
---|
1534 | DoLog(0) && (Log() << Verbose(0) << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl);
|
---|
1535 | DoLog(0) && (Log() << Verbose(0) << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl);
|
---|
1536 | DoLog(0) && (Log() << Verbose(0) << "\t-f <dist> <order>\tFragments the molecule in BOSSANOVA manner (with/out rings compressed) and stores config files in same dir as config (return code 0 - fragmented, 2 - no fragmentation necessary)." << endl);
|
---|
1537 | DoLog(0) && (Log() << Verbose(0) << "\t-F <xyz of filler> <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl);
|
---|
1538 | DoLog(0) && (Log() << Verbose(0) << "\t-FF <MaxDistance> <xyz of filler> <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl);
|
---|
1539 | DoLog(0) && (Log() << Verbose(0) << "\t-g <file>\tParses a bond length table from the given file." << endl);
|
---|
1540 | DoLog(0) && (Log() << Verbose(0) << "\t-h/-?\tGive this help screen." << endl);
|
---|
1541 | DoLog(0) && (Log() << Verbose(0) << "\t-H\tCount Hydrogen bridge bonds." << endl);
|
---|
1542 | DoLog(0) && (Log() << Verbose(0) << "\t-I\t Dissect current system of molecules into a set of disconnected (subgraphs of) molecules." << endl);
|
---|
1543 | DoLog(0) && (Log() << Verbose(0) << "\t-j\t<path> Store all bonds to file." << endl);
|
---|
1544 | DoLog(0) && (Log() << Verbose(0) << "\t-J\t<path> Store adjacency per atom to file." << endl);
|
---|
1545 | DoLog(0) && (Log() << Verbose(0) << "\t-L <step0> <step1> <prefix>\tStore a linear interpolation between two configurations <step0> and <step1> into single config files with prefix <prefix> and as Trajectories into the current config file." << endl);
|
---|
1546 | DoLog(0) && (Log() << Verbose(0) << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl);
|
---|
1547 | DoLog(0) && (Log() << Verbose(0) << "\t-M <basis>\tSetting basis to store to MPQC config files." << endl);
|
---|
1548 | DoLog(0) && (Log() << Verbose(0) << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl);
|
---|
1549 | DoLog(0) && (Log() << Verbose(0) << "\t-N <radius> <file>\tGet non-convex-envelope." << endl);
|
---|
1550 | DoLog(0) && (Log() << Verbose(0) << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl);
|
---|
1551 | DoLog(0) && (Log() << Verbose(0) << "\t-O\tCenter atoms in origin." << endl);
|
---|
1552 | DoLog(0) && (Log() << Verbose(0) << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl);
|
---|
1553 | DoLog(0) && (Log() << Verbose(0) << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl);
|
---|
1554 | DoLog(0) && (Log() << Verbose(0) << "\t-r <id>\t\tRemove an atom with given id." << endl);
|
---|
1555 | DoLog(0) && (Log() << Verbose(0) << "\t-R <id> <radius>\t\tRemove all atoms out of sphere around a given one." << endl);
|
---|
1556 | DoLog(0) && (Log() << Verbose(0) << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl);
|
---|
1557 | DoLog(0) && (Log() << Verbose(0) << "\t-S <file> Store temperatures from the config file in <file>." << endl);
|
---|
1558 | DoLog(0) && (Log() << Verbose(0) << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl);
|
---|
1559 | DoLog(0) && (Log() << Verbose(0) << "\t-T x1 x2 x3\tTranslate periodically all atoms by this vector (x1,x2,x3)." << endl);
|
---|
1560 | DoLog(0) && (Log() << Verbose(0) << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl);
|
---|
1561 | DoLog(0) && (Log() << Verbose(0) << "\t-v\t\tsets verbosity (more is more)." << endl);
|
---|
1562 | DoLog(0) && (Log() << Verbose(0) << "\t-V\t\tGives version information." << endl);
|
---|
1563 | DoLog(0) && (Log() << Verbose(0) << "\t-X\t\tset default name of a molecule." << endl);
|
---|
1564 | DoLog(0) && (Log() << Verbose(0) << "Note: config files must not begin with '-' !" << endl);
|
---|
1565 | return (1);
|
---|
1566 | break;
|
---|
1567 | case 'v':
|
---|
1568 | while (argv[argptr-1][verbosity+1] == 'v') {
|
---|
1569 | verbosity++;
|
---|
1570 | }
|
---|
1571 | setVerbosity(verbosity);
|
---|
1572 | DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl);
|
---|
1573 | break;
|
---|
1574 | case 'V':
|
---|
1575 | DoLog(0) && (Log() << Verbose(0) << argv[0] << " " << VERSIONSTRING << endl);
|
---|
1576 | DoLog(0) && (Log() << Verbose(0) << "Build your own molecule position set." << endl);
|
---|
1577 | return (1);
|
---|
1578 | break;
|
---|
1579 | case 'B':
|
---|
1580 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
1581 | if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
|
---|
1582 | ExitFlag = 255;
|
---|
1583 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl);
|
---|
1584 | performCriticalExit();
|
---|
1585 | } else {
|
---|
1586 | SaveFlag = true;
|
---|
1587 | j = -1;
|
---|
1588 | DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);
|
---|
1589 | double * const cell_size = World::getInstance().getDomain();
|
---|
1590 | for (int i=0;i<6;i++) {
|
---|
1591 | cell_size[i] = atof(argv[argptr+i]);
|
---|
1592 | }
|
---|
1593 | argptr+=6;
|
---|
1594 | }
|
---|
1595 | break;
|
---|
1596 | case 'e':
|
---|
1597 | if ((argptr >= argc) || (argv[argptr][0] == '-')) {
|
---|
1598 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl);
|
---|
1599 | performCriticalExit();
|
---|
1600 | } else {
|
---|
1601 | DoLog(0) && (Log() << Verbose(0) << "Using " << argv[argptr] << " as elements database." << endl);
|
---|
1602 | strncpy (configuration.databasepath, argv[argptr], MAXSTRINGSIZE-1);
|
---|
1603 | argptr+=1;
|
---|
1604 | }
|
---|
1605 | break;
|
---|
1606 | case 'g':
|
---|
1607 | if ((argptr >= argc) || (argv[argptr][0] == '-')) {
|
---|
1608 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying bond length table: -g <table file>" << endl);
|
---|
1609 | performCriticalExit();
|
---|
1610 | } else {
|
---|
1611 | BondGraphFileName = argv[argptr];
|
---|
1612 | DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl);
|
---|
1613 | argptr+=1;
|
---|
1614 | }
|
---|
1615 | break;
|
---|
1616 | case 'n':
|
---|
1617 | DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl);
|
---|
1618 | configuration.FastParsing = true;
|
---|
1619 | break;
|
---|
1620 | case 'X':
|
---|
1621 | {
|
---|
1622 | World::getInstance().setDefaultName(argv[argptr]);
|
---|
1623 | DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << *World::getInstance().getDefaultName() << "." << endl);
|
---|
1624 | }
|
---|
1625 | break;
|
---|
1626 | default: // no match? Step on
|
---|
1627 | argptr++;
|
---|
1628 | break;
|
---|
1629 | }
|
---|
1630 | } else
|
---|
1631 | argptr++;
|
---|
1632 | } while (argptr < argc);
|
---|
1633 |
|
---|
1634 | // 3a. Parse the element database
|
---|
1635 | if (periode->LoadPeriodentafel(configuration.databasepath)) {
|
---|
1636 | DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);
|
---|
1637 | //periode->Output();
|
---|
1638 | } else {
|
---|
1639 | DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
|
---|
1640 | return 1;
|
---|
1641 | }
|
---|
1642 | // 3b. Find config file name and parse if possible, also BondGraphFileName
|
---|
1643 | if (argv[1][0] != '-') {
|
---|
1644 | // simply create a new molecule, wherein the config file is loaded and the manipulation takes place
|
---|
1645 | DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl);
|
---|
1646 | test.open(argv[1], ios::in);
|
---|
1647 | if (test == NULL) {
|
---|
1648 | //return (1);
|
---|
1649 | output.open(argv[1], ios::out);
|
---|
1650 | if (output == NULL) {
|
---|
1651 | DoLog(1) && (Log() << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl);
|
---|
1652 | configPresent = absent;
|
---|
1653 | } else {
|
---|
1654 | DoLog(0) && (Log() << Verbose(0) << "Empty configuration file." << endl);
|
---|
1655 | ConfigFileName = argv[1];
|
---|
1656 | configPresent = empty;
|
---|
1657 | output.close();
|
---|
1658 | }
|
---|
1659 | } else {
|
---|
1660 | test.close();
|
---|
1661 | ConfigFileName = argv[1];
|
---|
1662 | DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
|
---|
1663 | switch (configuration.TestSyntax(ConfigFileName, periode)) {
|
---|
1664 | case 1:
|
---|
1665 | DoLog(0) && (Log() << Verbose(0) << "new syntax." << endl);
|
---|
1666 | configuration.Load(ConfigFileName, BondGraphFileName, periode, molecules);
|
---|
1667 | configPresent = present;
|
---|
1668 | break;
|
---|
1669 | case 0:
|
---|
1670 | DoLog(0) && (Log() << Verbose(0) << "old syntax." << endl);
|
---|
1671 | configuration.LoadOld(ConfigFileName, BondGraphFileName, periode, molecules);
|
---|
1672 | configPresent = present;
|
---|
1673 | break;
|
---|
1674 | default:
|
---|
1675 | DoLog(0) && (Log() << Verbose(0) << "Unknown syntax or empty, yet present file." << endl);
|
---|
1676 | configPresent = empty;
|
---|
1677 | }
|
---|
1678 | }
|
---|
1679 | } else
|
---|
1680 | configPresent = absent;
|
---|
1681 | // set mol to first active molecule
|
---|
1682 | if (molecules->ListOfMolecules.size() != 0) {
|
---|
1683 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
1684 | if ((*ListRunner)->ActiveFlag) {
|
---|
1685 | mol = *ListRunner;
|
---|
1686 | break;
|
---|
1687 | }
|
---|
1688 | }
|
---|
1689 | if (mol == NULL) {
|
---|
1690 | mol = World::getInstance().createMolecule();
|
---|
1691 | mol->ActiveFlag = true;
|
---|
1692 | if (ConfigFileName != NULL)
|
---|
1693 | mol->SetNameFromFilename(ConfigFileName);
|
---|
1694 | molecules->insert(mol);
|
---|
1695 | }
|
---|
1696 | if (configuration.BG == NULL) {
|
---|
1697 | configuration.BG = new BondGraph(configuration.GetIsAngstroem());
|
---|
1698 | if ((!BondGraphFileName.empty()) && (configuration.BG->LoadBondLengthTable(BondGraphFileName))) {
|
---|
1699 | DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
|
---|
1700 | } else {
|
---|
1701 | DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
|
---|
1702 | }
|
---|
1703 | }
|
---|
1704 |
|
---|
1705 | // 4. parse again through options, now for those depending on elements db and config presence
|
---|
1706 | argptr = 1;
|
---|
1707 | do {
|
---|
1708 | DoLog(0) && (Log() << Verbose(0) << "Current Command line argument: " << argv[argptr] << "." << endl);
|
---|
1709 | if (argv[argptr][0] == '-') {
|
---|
1710 | argptr++;
|
---|
1711 | if ((configPresent == present) || (configPresent == empty)) {
|
---|
1712 | switch(argv[argptr-1][1]) {
|
---|
1713 | case 'p':
|
---|
1714 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
1715 | if ((argptr >= argc) || (argv[argptr][0] == '-')) {
|
---|
1716 | ExitFlag = 255;
|
---|
1717 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough arguments for parsing: -p <xyz file>" << endl);
|
---|
1718 | performCriticalExit();
|
---|
1719 | } else {
|
---|
1720 | SaveFlag = true;
|
---|
1721 | DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);
|
---|
1722 | if (!mol->AddXYZFile(argv[argptr]))
|
---|
1723 | DoLog(2) && (Log() << Verbose(2) << "File not found." << endl);
|
---|
1724 | else {
|
---|
1725 | DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl);
|
---|
1726 | configPresent = present;
|
---|
1727 | }
|
---|
1728 | }
|
---|
1729 | break;
|
---|
1730 | case 'a':
|
---|
1731 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
1732 | if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3]))) {
|
---|
1733 | ExitFlag = 255;
|
---|
1734 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl);
|
---|
1735 | performCriticalExit();
|
---|
1736 | } else {
|
---|
1737 | SaveFlag = true;
|
---|
1738 | Log() << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), ";
|
---|
1739 | first = World::getInstance().createAtom();
|
---|
1740 | first->type = periode->FindElement(atoi(argv[argptr]));
|
---|
1741 | if (first->type != NULL)
|
---|
1742 | DoLog(2) && (Log() << Verbose(2) << "found element " << first->type->name << endl);
|
---|
1743 | for (int i=NDIM;i--;)
|
---|
1744 | first->x[i] = atof(argv[argptr+1+i]);
|
---|
1745 | if (first->type != NULL) {
|
---|
1746 | mol->AddAtom(first); // add to molecule
|
---|
1747 | if ((configPresent == empty) && (mol->AtomCount != 0))
|
---|
1748 | configPresent = present;
|
---|
1749 | } else
|
---|
1750 | DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the specified element." << endl);
|
---|
1751 | argptr+=4;
|
---|
1752 | }
|
---|
1753 | break;
|
---|
1754 | default: // no match? Don't step on (this is done in next switch's default)
|
---|
1755 | break;
|
---|
1756 | }
|
---|
1757 | }
|
---|
1758 | if (configPresent == present) {
|
---|
1759 | switch(argv[argptr-1][1]) {
|
---|
1760 | case 'M':
|
---|
1761 | if ((argptr >= argc) || (argv[argptr][0] == '-')) {
|
---|
1762 | ExitFlag = 255;
|
---|
1763 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl);
|
---|
1764 | performCriticalExit();
|
---|
1765 | } else {
|
---|
1766 | configuration.basis = argv[argptr];
|
---|
1767 | DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration.basis << "." << endl);
|
---|
1768 | argptr+=1;
|
---|
1769 | }
|
---|
1770 | break;
|
---|
1771 | case 'D':
|
---|
1772 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
1773 | {
|
---|
1774 | DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
|
---|
1775 | MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis
|
---|
1776 | int *MinimumRingSize = new int[mol->AtomCount];
|
---|
1777 | atom ***ListOfLocalAtoms = NULL;
|
---|
1778 | class StackClass<bond *> *BackEdgeStack = NULL;
|
---|
1779 | class StackClass<bond *> *LocalBackEdgeStack = NULL;
|
---|
1780 | mol->CreateAdjacencyList(atof(argv[argptr]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
|
---|
1781 | Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
|
---|
1782 | if (Subgraphs != NULL) {
|
---|
1783 | int FragmentCounter = 0;
|
---|
1784 | while (Subgraphs->next != NULL) {
|
---|
1785 | Subgraphs = Subgraphs->next;
|
---|
1786 | Subgraphs->FillBondStructureFromReference(mol, FragmentCounter, ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms
|
---|
1787 | LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
|
---|
1788 | Subgraphs->Leaf->PickLocalBackEdges(ListOfLocalAtoms[FragmentCounter], BackEdgeStack, LocalBackEdgeStack);
|
---|
1789 | Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
|
---|
1790 | delete(LocalBackEdgeStack);
|
---|
1791 | delete(Subgraphs->previous);
|
---|
1792 | FragmentCounter++;
|
---|
1793 | }
|
---|
1794 | delete(Subgraphs);
|
---|
1795 | for (int i=0;i<FragmentCounter;i++)
|
---|
1796 | Free(&ListOfLocalAtoms[i]);
|
---|
1797 | Free(&ListOfLocalAtoms);
|
---|
1798 | }
|
---|
1799 | delete(BackEdgeStack);
|
---|
1800 | delete[](MinimumRingSize);
|
---|
1801 | }
|
---|
1802 | //argptr+=1;
|
---|
1803 | break;
|
---|
1804 | case 'I':
|
---|
1805 | DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);
|
---|
1806 | // @TODO rather do the dissection afterwards
|
---|
1807 | molecules->DissectMoleculeIntoConnectedSubgraphs(periode, &configuration);
|
---|
1808 | mol = NULL;
|
---|
1809 | if (molecules->ListOfMolecules.size() != 0) {
|
---|
1810 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
1811 | if ((*ListRunner)->ActiveFlag) {
|
---|
1812 | mol = *ListRunner;
|
---|
1813 | break;
|
---|
1814 | }
|
---|
1815 | }
|
---|
1816 | if ((mol == NULL) && (!molecules->ListOfMolecules.empty())) {
|
---|
1817 | mol = *(molecules->ListOfMolecules.begin());
|
---|
1818 | if (mol != NULL)
|
---|
1819 | mol->ActiveFlag = true;
|
---|
1820 | }
|
---|
1821 | break;
|
---|
1822 | case 'H':
|
---|
1823 | if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (argv[argptr+1][0] == '-')) {
|
---|
1824 | ExitFlag = 255;
|
---|
1825 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for calculating hydrogen bridge bonds: -H <Z1> <Z2>" << endl);
|
---|
1826 | performCriticalExit();
|
---|
1827 | } else {
|
---|
1828 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
1829 | const element *elemental = periode->FindElement((const int) atoi(argv[argptr]));
|
---|
1830 | const element *elemental2 = periode->FindElement((const int) atoi(argv[argptr+1]));
|
---|
1831 | cout << endl << "There are " << CountHydrogenBridgeBonds(molecules, elemental, elemental2) << " hydrogen bridges with connections to " << (elemental != 0 ? elemental->name : "None") << " and " << (elemental2 != 0 ? elemental2->name : "None") << "." << endl;
|
---|
1832 | argptr+=1;
|
---|
1833 | }
|
---|
1834 | break;
|
---|
1835 | case 'C':
|
---|
1836 | {
|
---|
1837 | int ranges[3] = {1, 1, 1};
|
---|
1838 | bool periodic = (argv[argptr-1][2] =='p');
|
---|
1839 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
1840 | if ((argptr >= argc)) {
|
---|
1841 | ExitFlag = 255;
|
---|
1842 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C[p] <type: E/P/S> [more params] <output> <bin output> <BinStart> <BinEnd>" << endl);
|
---|
1843 | performCriticalExit();
|
---|
1844 | } else {
|
---|
1845 | switch(argv[argptr][0]) {
|
---|
1846 | case 'E':
|
---|
1847 | {
|
---|
1848 | if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (!IsValidNumber(argv[argptr+2])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-') || (argv[argptr+4][0] == '-')) {
|
---|
1849 | ExitFlag = 255;
|
---|
1850 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C E <Z1> <Z2> <output> <bin output>" << endl);
|
---|
1851 | performCriticalExit();
|
---|
1852 | } else {
|
---|
1853 | ofstream output(argv[argptr+3]);
|
---|
1854 | ofstream binoutput(argv[argptr+4]);
|
---|
1855 | const double BinStart = atof(argv[argptr+5]);
|
---|
1856 | const double BinEnd = atof(argv[argptr+6]);
|
---|
1857 |
|
---|
1858 | const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
|
---|
1859 | const element *elemental2 = periode->FindElement((const int) atoi(argv[argptr+2]));
|
---|
1860 | PairCorrelationMap *correlationmap = NULL;
|
---|
1861 | if (periodic)
|
---|
1862 | correlationmap = PeriodicPairCorrelation(molecules, elemental, elemental2, ranges);
|
---|
1863 | else
|
---|
1864 | correlationmap = PairCorrelation(molecules, elemental, elemental2);
|
---|
1865 | //OutputCorrelationToSurface(&output, correlationmap);
|
---|
1866 | BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
|
---|
1867 | OutputCorrelation ( &binoutput, binmap );
|
---|
1868 | output.close();
|
---|
1869 | binoutput.close();
|
---|
1870 | delete(binmap);
|
---|
1871 | delete(correlationmap);
|
---|
1872 | argptr+=7;
|
---|
1873 | }
|
---|
1874 | }
|
---|
1875 | break;
|
---|
1876 |
|
---|
1877 | case 'P':
|
---|
1878 | {
|
---|
1879 | if ((argptr+8 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+7])) || (!IsValidNumber(argv[argptr+8])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-') || (argv[argptr+4][0] == '-') || (argv[argptr+5][0] == '-') || (argv[argptr+6][0] == '-')) {
|
---|
1880 | ExitFlag = 255;
|
---|
1881 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C P <Z1> <x> <y> <z> <output> <bin output>" << endl);
|
---|
1882 | performCriticalExit();
|
---|
1883 | } else {
|
---|
1884 | ofstream output(argv[argptr+5]);
|
---|
1885 | ofstream binoutput(argv[argptr+6]);
|
---|
1886 | const double BinStart = atof(argv[argptr+7]);
|
---|
1887 | const double BinEnd = atof(argv[argptr+8]);
|
---|
1888 |
|
---|
1889 | const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
|
---|
1890 | Vector *Point = new Vector((const double) atof(argv[argptr+1]),(const double) atof(argv[argptr+2]),(const double) atof(argv[argptr+3]));
|
---|
1891 | CorrelationToPointMap *correlationmap = NULL;
|
---|
1892 | if (periodic)
|
---|
1893 | correlationmap = PeriodicCorrelationToPoint(molecules, elemental, Point, ranges);
|
---|
1894 | else
|
---|
1895 | correlationmap = CorrelationToPoint(molecules, elemental, Point);
|
---|
1896 | //OutputCorrelationToSurface(&output, correlationmap);
|
---|
1897 | BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
|
---|
1898 | OutputCorrelation ( &binoutput, binmap );
|
---|
1899 | output.close();
|
---|
1900 | binoutput.close();
|
---|
1901 | delete(Point);
|
---|
1902 | delete(binmap);
|
---|
1903 | delete(correlationmap);
|
---|
1904 | argptr+=9;
|
---|
1905 | }
|
---|
1906 | }
|
---|
1907 | break;
|
---|
1908 |
|
---|
1909 | case 'S':
|
---|
1910 | {
|
---|
1911 | if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-')) {
|
---|
1912 | ExitFlag = 255;
|
---|
1913 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C S <Z> <output> <bin output> <BinWidth> <BinStart> <BinEnd>" << endl);
|
---|
1914 | performCriticalExit();
|
---|
1915 | } else {
|
---|
1916 | ofstream output(argv[argptr+2]);
|
---|
1917 | ofstream binoutput(argv[argptr+3]);
|
---|
1918 | const double radius = 4.;
|
---|
1919 | const double BinWidth = atof(argv[argptr+4]);
|
---|
1920 | const double BinStart = atof(argv[argptr+5]);
|
---|
1921 | const double BinEnd = atof(argv[argptr+6]);
|
---|
1922 | double LCWidth = 20.;
|
---|
1923 | if (BinEnd > 0) {
|
---|
1924 | if (BinEnd > 2.*radius)
|
---|
1925 | LCWidth = BinEnd;
|
---|
1926 | else
|
---|
1927 | LCWidth = 2.*radius;
|
---|
1928 | }
|
---|
1929 |
|
---|
1930 | // get the boundary
|
---|
1931 | class molecule *Boundary = NULL;
|
---|
1932 | class Tesselation *TesselStruct = NULL;
|
---|
1933 | const LinkedCell *LCList = NULL;
|
---|
1934 | // find biggest molecule
|
---|
1935 | int counter = 0;
|
---|
1936 | for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
|
---|
1937 | if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) {
|
---|
1938 | Boundary = *BigFinder;
|
---|
1939 | }
|
---|
1940 | counter++;
|
---|
1941 | }
|
---|
1942 | bool *Actives = Malloc<bool>(counter, "ParseCommandLineOptions() - case C -- *Actives");
|
---|
1943 | counter = 0;
|
---|
1944 | for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
|
---|
1945 | Actives[counter++] = (*BigFinder)->ActiveFlag;
|
---|
1946 | (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
|
---|
1947 | }
|
---|
1948 | LCList = new LinkedCell(Boundary, LCWidth);
|
---|
1949 | const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
|
---|
1950 | FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
|
---|
1951 | CorrelationToSurfaceMap *surfacemap = NULL;
|
---|
1952 | if (periodic)
|
---|
1953 | surfacemap = PeriodicCorrelationToSurface( molecules, elemental, TesselStruct, LCList, ranges);
|
---|
1954 | else
|
---|
1955 | surfacemap = CorrelationToSurface( molecules, elemental, TesselStruct, LCList);
|
---|
1956 | OutputCorrelationToSurface(&output, surfacemap);
|
---|
1957 | // check whether radius was appropriate
|
---|
1958 | {
|
---|
1959 | double start; double end;
|
---|
1960 | GetMinMax( surfacemap, start, end);
|
---|
1961 | if (LCWidth < end)
|
---|
1962 | DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl);
|
---|
1963 | }
|
---|
1964 | BinPairMap *binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
|
---|
1965 | OutputCorrelation ( &binoutput, binmap );
|
---|
1966 | output.close();
|
---|
1967 | binoutput.close();
|
---|
1968 | for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++)
|
---|
1969 | (*BigFinder)->ActiveFlag = Actives[counter++];
|
---|
1970 | Free(&Actives);
|
---|
1971 | delete(LCList);
|
---|
1972 | delete(TesselStruct);
|
---|
1973 | delete(binmap);
|
---|
1974 | delete(surfacemap);
|
---|
1975 | argptr+=7;
|
---|
1976 | }
|
---|
1977 | }
|
---|
1978 | break;
|
---|
1979 |
|
---|
1980 | default:
|
---|
1981 | ExitFlag = 255;
|
---|
1982 | DoeLog(0) && (eLog()<< Verbose(0) << "Invalid type given for pair correlation analysis: -C <type: E/P/S> [more params] <output> <bin output>" << endl);
|
---|
1983 | performCriticalExit();
|
---|
1984 | break;
|
---|
1985 | }
|
---|
1986 | }
|
---|
1987 | break;
|
---|
1988 | }
|
---|
1989 | case 'E':
|
---|
1990 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
1991 | if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) {
|
---|
1992 | ExitFlag = 255;
|
---|
1993 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl);
|
---|
1994 | performCriticalExit();
|
---|
1995 | } else {
|
---|
1996 | SaveFlag = true;
|
---|
1997 | DoLog(1) && (Log() << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl);
|
---|
1998 | first = mol->FindAtom(atoi(argv[argptr]));
|
---|
1999 | first->type = periode->FindElement(atoi(argv[argptr+1]));
|
---|
2000 | argptr+=2;
|
---|
2001 | }
|
---|
2002 | break;
|
---|
2003 | case 'F':
|
---|
2004 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2005 | MaxDistance = -1;
|
---|
2006 | if (argv[argptr-1][2] == 'F') { // option is -FF?
|
---|
2007 | // fetch first argument as max distance to surface
|
---|
2008 | MaxDistance = atof(argv[argptr++]);
|
---|
2009 | DoLog(0) && (Log() << Verbose(0) << "Filling with maximum layer distance of " << MaxDistance << "." << endl);
|
---|
2010 | }
|
---|
2011 | if ((argptr+7 >=argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (!IsValidNumber(argv[argptr+7]))) {
|
---|
2012 | ExitFlag = 255;
|
---|
2013 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for filling box with water: -F <xyz of filler> <dist_x> <dist_y> <dist_z> <boundary> <randatom> <randmol> <DoRotate>" << endl);
|
---|
2014 | performCriticalExit();
|
---|
2015 | } else {
|
---|
2016 | SaveFlag = true;
|
---|
2017 | DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules." << endl);
|
---|
2018 | // construct water molecule
|
---|
2019 | molecule *filler = World::getInstance().createMolecule();
|
---|
2020 | if (!filler->AddXYZFile(argv[argptr])) {
|
---|
2021 | DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << argv[argptr] << "." << endl);
|
---|
2022 | }
|
---|
2023 | filler->SetNameFromFilename(argv[argptr]);
|
---|
2024 | configuration.BG->ConstructBondGraph(filler);
|
---|
2025 | molecule *Filling = NULL;
|
---|
2026 | atom *second = NULL, *third = NULL;
|
---|
2027 | first = World::getInstance().createAtom();
|
---|
2028 | first->type = periode->FindElement(1);
|
---|
2029 | first->x = Vector(0.441, -0.143, 0.);
|
---|
2030 | filler->AddAtom(first);
|
---|
2031 | second = World::getInstance().createAtom();
|
---|
2032 | second->type = periode->FindElement(1);
|
---|
2033 | second->x = Vector(-0.464, 1.137, 0.0);
|
---|
2034 | filler->AddAtom(second);
|
---|
2035 | third = World::getInstance().createAtom();
|
---|
2036 | third->type = periode->FindElement(8);
|
---|
2037 | third->x = Vector(-0.464, 0.177, 0.);
|
---|
2038 | filler->AddAtom(third);
|
---|
2039 | filler->AddBond(first, third, 1);
|
---|
2040 | filler->AddBond(second, third, 1);
|
---|
2041 | // call routine
|
---|
2042 | double distance[NDIM];
|
---|
2043 | for (int i=0;i<NDIM;i++)
|
---|
2044 | distance[i] = atof(argv[argptr+i+1]);
|
---|
2045 | Filling = FillBoxWithMolecule(molecules, filler, configuration, MaxDistance, distance, atof(argv[argptr+4]), atof(argv[argptr+5]), atof(argv[argptr+6]), atoi(argv[argptr+7]));
|
---|
2046 | if (Filling != NULL) {
|
---|
2047 | Filling->ActiveFlag = false;
|
---|
2048 | molecules->insert(Filling);
|
---|
2049 | }
|
---|
2050 | World::getInstance().destroyMolecule(filler);
|
---|
2051 | argptr+=6;
|
---|
2052 | }
|
---|
2053 | break;
|
---|
2054 | case 'A':
|
---|
2055 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2056 | if ((argptr >= argc) || (argv[argptr][0] == '-')) {
|
---|
2057 | ExitFlag =255;
|
---|
2058 | DoeLog(0) && (eLog()<< Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl);
|
---|
2059 | performCriticalExit();
|
---|
2060 | } else {
|
---|
2061 | DoLog(0) && (Log() << Verbose(0) << "Parsing bonds from " << argv[argptr] << "." << endl);
|
---|
2062 | ifstream *input = new ifstream(argv[argptr]);
|
---|
2063 | mol->CreateAdjacencyListFromDbondFile(input);
|
---|
2064 | input->close();
|
---|
2065 | argptr+=1;
|
---|
2066 | }
|
---|
2067 | break;
|
---|
2068 |
|
---|
2069 | case 'J':
|
---|
2070 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2071 | if ((argptr >= argc) || (argv[argptr][0] == '-')) {
|
---|
2072 | ExitFlag =255;
|
---|
2073 | DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of adjacency file: -j <path>" << endl);
|
---|
2074 | performCriticalExit();
|
---|
2075 | } else {
|
---|
2076 | DoLog(0) && (Log() << Verbose(0) << "Storing adjacency to path " << argv[argptr] << "." << endl);
|
---|
2077 | configuration.BG->ConstructBondGraph(mol);
|
---|
2078 | mol->StoreAdjacencyToFile(NULL, argv[argptr]);
|
---|
2079 | argptr+=1;
|
---|
2080 | }
|
---|
2081 | break;
|
---|
2082 |
|
---|
2083 | case 'j':
|
---|
2084 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2085 | if ((argptr >= argc) || (argv[argptr][0] == '-')) {
|
---|
2086 | ExitFlag =255;
|
---|
2087 | DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of bonds file: -j <path>" << endl);
|
---|
2088 | performCriticalExit();
|
---|
2089 | } else {
|
---|
2090 | DoLog(0) && (Log() << Verbose(0) << "Storing bonds to path " << argv[argptr] << "." << endl);
|
---|
2091 | configuration.BG->ConstructBondGraph(mol);
|
---|
2092 | mol->StoreBondsToFile(NULL, argv[argptr]);
|
---|
2093 | argptr+=1;
|
---|
2094 | }
|
---|
2095 | break;
|
---|
2096 |
|
---|
2097 | case 'N':
|
---|
2098 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2099 | if ((argptr+1 >= argc) || (argv[argptr+1][0] == '-')){
|
---|
2100 | ExitFlag = 255;
|
---|
2101 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl);
|
---|
2102 | performCriticalExit();
|
---|
2103 | } else {
|
---|
2104 | class Tesselation *T = NULL;
|
---|
2105 | class Tesselation *Convex = NULL;
|
---|
2106 | const LinkedCell *LCList = NULL;
|
---|
2107 | const LinkedCell *LCListConvex = NULL;
|
---|
2108 | molecule * Boundary = NULL;
|
---|
2109 | //string filename(argv[argptr+1]);
|
---|
2110 | //filename.append(".csv");
|
---|
2111 | DoLog(0) && (Log() << Verbose(0) << "Evaluating non-convex envelope of biggest molecule.");
|
---|
2112 | DoLog(1) && (Log() << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl);
|
---|
2113 | // find biggest molecule
|
---|
2114 | int counter = 0;
|
---|
2115 | for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
|
---|
2116 | (*BigFinder)->CountAtoms();
|
---|
2117 | if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) {
|
---|
2118 | Boundary = *BigFinder;
|
---|
2119 | }
|
---|
2120 | counter++;
|
---|
2121 | }
|
---|
2122 | DoLog(1) && (Log() << Verbose(1) << "Biggest molecule has " << Boundary->AtomCount << " atoms." << endl);
|
---|
2123 | start = clock();
|
---|
2124 | LCList = new LinkedCell(Boundary, atof(argv[argptr])*2.);
|
---|
2125 | if (!FindNonConvexBorder(Boundary, T, LCList, atof(argv[argptr]), argv[argptr+1]))
|
---|
2126 | ExitFlag = 255;
|
---|
2127 | const double ConvexRadius = 20.;
|
---|
2128 | LCListConvex = new LinkedCell(Boundary, 2.*ConvexRadius);
|
---|
2129 | // setVerbosity(3);
|
---|
2130 | if (!FindNonConvexBorder(Boundary, Convex, LCListConvex, ConvexRadius, "ConvexEnvelope"))
|
---|
2131 | ExitFlag = 255;
|
---|
2132 | CalculateConstrictionPerBoundaryPoint(T, Convex);
|
---|
2133 | StoreTrianglesinFile(mol, (const Tesselation *&)T, argv[argptr+1], "");
|
---|
2134 | //FindDistributionOfEllipsoids(T, &LCList, N, number, filename.c_str());
|
---|
2135 | end = clock();
|
---|
2136 | DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
|
---|
2137 | delete(LCList);
|
---|
2138 | delete(T);
|
---|
2139 | argptr+=2;
|
---|
2140 | }
|
---|
2141 | break;
|
---|
2142 | case 'S':
|
---|
2143 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2144 | if ((argptr >= argc) || (argv[argptr][0] == '-')) {
|
---|
2145 | ExitFlag = 255;
|
---|
2146 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file>" << endl);
|
---|
2147 | performCriticalExit();
|
---|
2148 | } else {
|
---|
2149 | DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl);
|
---|
2150 | ofstream *output = new ofstream(argv[argptr], ios::trunc);
|
---|
2151 | if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))
|
---|
2152 | DoLog(2) && (Log() << Verbose(2) << "File could not be written." << endl);
|
---|
2153 | else
|
---|
2154 | DoLog(2) && (Log() << Verbose(2) << "File stored." << endl);
|
---|
2155 | output->close();
|
---|
2156 | delete(output);
|
---|
2157 | argptr+=1;
|
---|
2158 | }
|
---|
2159 | break;
|
---|
2160 | case 'L':
|
---|
2161 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2162 | if ((argptr >= argc) || (argv[argptr][0] == '-')) {
|
---|
2163 | ExitFlag = 255;
|
---|
2164 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -L <step0> <step1> <prefix> <identity mapping?>" << endl);
|
---|
2165 | performCriticalExit();
|
---|
2166 | } else {
|
---|
2167 | SaveFlag = true;
|
---|
2168 | DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << argv[argptr] << " and " << argv[argptr+1] << "." << endl);
|
---|
2169 | if (atoi(argv[argptr+3]) == 1)
|
---|
2170 | DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl);
|
---|
2171 | if (!mol->LinearInterpolationBetweenConfiguration(atoi(argv[argptr]), atoi(argv[argptr+1]), argv[argptr+2], configuration, atoi(argv[argptr+3])) == 1 ? true : false)
|
---|
2172 | DoLog(2) && (Log() << Verbose(2) << "Could not store " << argv[argptr+2] << " files." << endl);
|
---|
2173 | else
|
---|
2174 | DoLog(2) && (Log() << Verbose(2) << "Steps created and " << argv[argptr+2] << " files stored." << endl);
|
---|
2175 | argptr+=4;
|
---|
2176 | }
|
---|
2177 | break;
|
---|
2178 | case 'P':
|
---|
2179 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2180 | if ((argptr >= argc) || (argv[argptr][0] == '-')) {
|
---|
2181 | ExitFlag = 255;
|
---|
2182 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl);
|
---|
2183 | performCriticalExit();
|
---|
2184 | } else {
|
---|
2185 | SaveFlag = true;
|
---|
2186 | DoLog(1) && (Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl);
|
---|
2187 | if (!mol->VerletForceIntegration(argv[argptr], configuration))
|
---|
2188 | DoLog(2) && (Log() << Verbose(2) << "File not found." << endl);
|
---|
2189 | else
|
---|
2190 | DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl);
|
---|
2191 | argptr+=1;
|
---|
2192 | }
|
---|
2193 | break;
|
---|
2194 | case 'R':
|
---|
2195 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2196 | if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {
|
---|
2197 | ExitFlag = 255;
|
---|
2198 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl);
|
---|
2199 | performCriticalExit();
|
---|
2200 | } else {
|
---|
2201 | SaveFlag = true;
|
---|
2202 | DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl);
|
---|
2203 | double tmp1 = atof(argv[argptr+1]);
|
---|
2204 | atom *third = mol->FindAtom(atoi(argv[argptr]));
|
---|
2205 | atom *first = mol->start;
|
---|
2206 | if ((third != NULL) && (first != mol->end)) {
|
---|
2207 | atom *second = first->next;
|
---|
2208 | while(second != mol->end) {
|
---|
2209 | first = second;
|
---|
2210 | second = first->next;
|
---|
2211 | if (first->x.DistanceSquared(third->x) > tmp1*tmp1) // distance to first above radius ...
|
---|
2212 | mol->RemoveAtom(first);
|
---|
2213 | }
|
---|
2214 | } else {
|
---|
2215 | DoeLog(1) && (eLog()<< Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl);
|
---|
2216 | }
|
---|
2217 | argptr+=2;
|
---|
2218 | }
|
---|
2219 | break;
|
---|
2220 | case 't':
|
---|
2221 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2222 | if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
|
---|
2223 | ExitFlag = 255;
|
---|
2224 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl);
|
---|
2225 | performCriticalExit();
|
---|
2226 | } else {
|
---|
2227 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2228 | SaveFlag = true;
|
---|
2229 | DoLog(1) && (Log() << Verbose(1) << "Translating all ions by given vector." << endl);
|
---|
2230 | for (int i=NDIM;i--;)
|
---|
2231 | x[i] = atof(argv[argptr+i]);
|
---|
2232 | mol->Translate((const Vector *)&x);
|
---|
2233 | argptr+=3;
|
---|
2234 | }
|
---|
2235 | break;
|
---|
2236 | case 'T':
|
---|
2237 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2238 | if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
|
---|
2239 | ExitFlag = 255;
|
---|
2240 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for periodic translation: -T <x> <y> <z>" << endl);
|
---|
2241 | performCriticalExit();
|
---|
2242 | } else {
|
---|
2243 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2244 | SaveFlag = true;
|
---|
2245 | DoLog(1) && (Log() << Verbose(1) << "Translating all ions periodically by given vector." << endl);
|
---|
2246 | for (int i=NDIM;i--;)
|
---|
2247 | x[i] = atof(argv[argptr+i]);
|
---|
2248 | mol->TranslatePeriodically((const Vector *)&x);
|
---|
2249 | argptr+=3;
|
---|
2250 | }
|
---|
2251 | break;
|
---|
2252 | case 's':
|
---|
2253 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2254 | if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
|
---|
2255 | ExitFlag = 255;
|
---|
2256 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl);
|
---|
2257 | performCriticalExit();
|
---|
2258 | } else {
|
---|
2259 | SaveFlag = true;
|
---|
2260 | j = -1;
|
---|
2261 | DoLog(1) && (Log() << Verbose(1) << "Scaling all ion positions by factor." << endl);
|
---|
2262 | factor = new double[NDIM];
|
---|
2263 | factor[0] = atof(argv[argptr]);
|
---|
2264 | factor[1] = atof(argv[argptr+1]);
|
---|
2265 | factor[2] = atof(argv[argptr+2]);
|
---|
2266 | mol->Scale((const double ** const)&factor);
|
---|
2267 | double * const cell_size = World::getInstance().getDomain();
|
---|
2268 | for (int i=0;i<NDIM;i++) {
|
---|
2269 | j += i+1;
|
---|
2270 | x[i] = atof(argv[NDIM+i]);
|
---|
2271 | cell_size[j]*=factor[i];
|
---|
2272 | }
|
---|
2273 | delete[](factor);
|
---|
2274 | argptr+=3;
|
---|
2275 | }
|
---|
2276 | break;
|
---|
2277 | case 'b':
|
---|
2278 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2279 | if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
|
---|
2280 | ExitFlag = 255;
|
---|
2281 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl);
|
---|
2282 | performCriticalExit();
|
---|
2283 | } else {
|
---|
2284 | SaveFlag = true;
|
---|
2285 | j = -1;
|
---|
2286 | DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);
|
---|
2287 | double * const cell_size = World::getInstance().getDomain();
|
---|
2288 | for (int i=0;i<6;i++) {
|
---|
2289 | cell_size[i] = atof(argv[argptr+i]);
|
---|
2290 | }
|
---|
2291 | // center
|
---|
2292 | mol->CenterInBox();
|
---|
2293 | argptr+=6;
|
---|
2294 | }
|
---|
2295 | break;
|
---|
2296 | case 'B':
|
---|
2297 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2298 | if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
|
---|
2299 | ExitFlag = 255;
|
---|
2300 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl);
|
---|
2301 | performCriticalExit();
|
---|
2302 | } else {
|
---|
2303 | SaveFlag = true;
|
---|
2304 | j = -1;
|
---|
2305 | DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);
|
---|
2306 | double * const cell_size = World::getInstance().getDomain();
|
---|
2307 | for (int i=0;i<6;i++) {
|
---|
2308 | cell_size[i] = atof(argv[argptr+i]);
|
---|
2309 | }
|
---|
2310 | // center
|
---|
2311 | mol->BoundInBox();
|
---|
2312 | argptr+=6;
|
---|
2313 | }
|
---|
2314 | break;
|
---|
2315 | case 'c':
|
---|
2316 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2317 | if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
|
---|
2318 | ExitFlag = 255;
|
---|
2319 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl);
|
---|
2320 | performCriticalExit();
|
---|
2321 | } else {
|
---|
2322 | SaveFlag = true;
|
---|
2323 | j = -1;
|
---|
2324 | DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl);
|
---|
2325 | // make every coordinate positive
|
---|
2326 | mol->CenterEdge(&x);
|
---|
2327 | // update Box of atoms by boundary
|
---|
2328 | mol->SetBoxDimension(&x);
|
---|
2329 | // translate each coordinate by boundary
|
---|
2330 | double * const cell_size = World::getInstance().getDomain();
|
---|
2331 | j=-1;
|
---|
2332 | for (int i=0;i<NDIM;i++) {
|
---|
2333 | j += i+1;
|
---|
2334 | x[i] = atof(argv[argptr+i]);
|
---|
2335 | cell_size[j] += x[i]*2.;
|
---|
2336 | }
|
---|
2337 | mol->Translate((const Vector *)&x);
|
---|
2338 | argptr+=3;
|
---|
2339 | }
|
---|
2340 | break;
|
---|
2341 | case 'O':
|
---|
2342 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2343 | SaveFlag = true;
|
---|
2344 | DoLog(1) && (Log() << Verbose(1) << "Centering atoms on edge and setting box dimensions." << endl);
|
---|
2345 | x.Zero();
|
---|
2346 | mol->CenterEdge(&x);
|
---|
2347 | mol->SetBoxDimension(&x);
|
---|
2348 | argptr+=0;
|
---|
2349 | break;
|
---|
2350 | case 'r':
|
---|
2351 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2352 | if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr]))) {
|
---|
2353 | ExitFlag = 255;
|
---|
2354 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -r <id>" << endl);
|
---|
2355 | performCriticalExit();
|
---|
2356 | } else {
|
---|
2357 | SaveFlag = true;
|
---|
2358 | DoLog(1) && (Log() << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl);
|
---|
2359 | atom *first = mol->FindAtom(atoi(argv[argptr]));
|
---|
2360 | mol->RemoveAtom(first);
|
---|
2361 | argptr+=1;
|
---|
2362 | }
|
---|
2363 | break;
|
---|
2364 | case 'f':
|
---|
2365 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2366 | if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {
|
---|
2367 | ExitFlag = 255;
|
---|
2368 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl);
|
---|
2369 | performCriticalExit();
|
---|
2370 | } else {
|
---|
2371 | DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl);
|
---|
2372 | DoLog(0) && (Log() << Verbose(0) << "Creating connection matrix..." << endl);
|
---|
2373 | start = clock();
|
---|
2374 | mol->CreateAdjacencyList(atof(argv[argptr]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
|
---|
2375 | DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
|
---|
2376 | if (mol->first->next != mol->last) {
|
---|
2377 | ExitFlag = mol->FragmentMolecule(atoi(argv[argptr+1]), &configuration);
|
---|
2378 | }
|
---|
2379 | end = clock();
|
---|
2380 | DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
|
---|
2381 | argptr+=2;
|
---|
2382 | }
|
---|
2383 | break;
|
---|
2384 | case 'm':
|
---|
2385 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2386 | j = atoi(argv[argptr++]);
|
---|
2387 | if ((j<0) || (j>1)) {
|
---|
2388 | DoeLog(1) && (eLog()<< Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl);
|
---|
2389 | j = 0;
|
---|
2390 | }
|
---|
2391 | if (j) {
|
---|
2392 | SaveFlag = true;
|
---|
2393 | DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
|
---|
2394 | } else
|
---|
2395 | DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
|
---|
2396 | mol->PrincipalAxisSystem((bool)j);
|
---|
2397 | break;
|
---|
2398 | case 'o':
|
---|
2399 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2400 | if ((argptr+1 >= argc) || (argv[argptr][0] == '-')){
|
---|
2401 | ExitFlag = 255;
|
---|
2402 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <convex output file> <non-convex output file>" << endl);
|
---|
2403 | performCriticalExit();
|
---|
2404 | } else {
|
---|
2405 | class Tesselation *TesselStruct = NULL;
|
---|
2406 | const LinkedCell *LCList = NULL;
|
---|
2407 | DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope.");
|
---|
2408 | DoLog(1) && (Log() << Verbose(1) << "Storing tecplot convex data in " << argv[argptr] << "." << endl);
|
---|
2409 | DoLog(1) && (Log() << Verbose(1) << "Storing tecplot non-convex data in " << argv[argptr+1] << "." << endl);
|
---|
2410 | LCList = new LinkedCell(mol, 10.);
|
---|
2411 | //FindConvexBorder(mol, LCList, argv[argptr]);
|
---|
2412 | FindNonConvexBorder(mol, TesselStruct, LCList, 5., argv[argptr+1]);
|
---|
2413 | // RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]);
|
---|
2414 | double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, argv[argptr]);
|
---|
2415 | double clustervolume = VolumeOfConvexEnvelope(TesselStruct, &configuration);
|
---|
2416 | DoLog(0) && (Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
|
---|
2417 | DoLog(0) && (Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
|
---|
2418 | delete(TesselStruct);
|
---|
2419 | delete(LCList);
|
---|
2420 | argptr+=2;
|
---|
2421 | }
|
---|
2422 | break;
|
---|
2423 | case 'U':
|
---|
2424 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2425 | if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) {
|
---|
2426 | ExitFlag = 255;
|
---|
2427 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl);
|
---|
2428 | performCriticalExit();
|
---|
2429 | } else {
|
---|
2430 | volume = atof(argv[argptr++]);
|
---|
2431 | DoLog(0) && (Log() << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl);
|
---|
2432 | }
|
---|
2433 | case 'u':
|
---|
2434 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2435 | if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) ) {
|
---|
2436 | if (volume != -1)
|
---|
2437 | ExitFlag = 255;
|
---|
2438 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension: -u <density>" << endl);
|
---|
2439 | performCriticalExit();
|
---|
2440 | } else {
|
---|
2441 | double density;
|
---|
2442 | SaveFlag = true;
|
---|
2443 | DoLog(0) && (Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.");
|
---|
2444 | density = atof(argv[argptr++]);
|
---|
2445 | if (density < 1.0) {
|
---|
2446 | DoeLog(1) && (eLog()<< Verbose(1) << "Density must be greater than 1.0g/cm^3 !" << endl);
|
---|
2447 | density = 1.3;
|
---|
2448 | }
|
---|
2449 | // for(int i=0;i<NDIM;i++) {
|
---|
2450 | // repetition[i] = atoi(argv[argptr++]);
|
---|
2451 | // if (repetition[i] < 1)
|
---|
2452 | // DoeLog(1) && (eLog()<< Verbose(1) << "repetition value must be greater 1!" << endl);
|
---|
2453 | // repetition[i] = 1;
|
---|
2454 | // }
|
---|
2455 | PrepareClustersinWater(&configuration, mol, volume, density); // if volume == 0, will calculate from ConvexEnvelope
|
---|
2456 | }
|
---|
2457 | break;
|
---|
2458 | case 'd':
|
---|
2459 | if (ExitFlag == 0) ExitFlag = 1;
|
---|
2460 | if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
|
---|
2461 | ExitFlag = 255;
|
---|
2462 | DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl);
|
---|
2463 | performCriticalExit();
|
---|
2464 | } else {
|
---|
2465 | SaveFlag = true;
|
---|
2466 | double * const cell_size = World::getInstance().getDomain();
|
---|
2467 | for (int axis = 1; axis <= NDIM; axis++) {
|
---|
2468 | int faktor = atoi(argv[argptr++]);
|
---|
2469 | int count;
|
---|
2470 | const element ** Elements;
|
---|
2471 | Vector ** vectors;
|
---|
2472 | if (faktor < 1) {
|
---|
2473 | DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor mus be greater than 1!" << endl);
|
---|
2474 | faktor = 1;
|
---|
2475 | }
|
---|
2476 | mol->CountAtoms(); // recount atoms
|
---|
2477 | if (mol->AtomCount != 0) { // if there is more than none
|
---|
2478 | count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand
|
---|
2479 | Elements = new const element *[count];
|
---|
2480 | vectors = new Vector *[count];
|
---|
2481 | j = 0;
|
---|
2482 | first = mol->start;
|
---|
2483 | while (first->next != mol->end) { // make a list of all atoms with coordinates and element
|
---|
2484 | first = first->next;
|
---|
2485 | Elements[j] = first->type;
|
---|
2486 | vectors[j] = &first->x;
|
---|
2487 | j++;
|
---|
2488 | }
|
---|
2489 | if (count != j)
|
---|
2490 | DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
|
---|
2491 | x.Zero();
|
---|
2492 | y.Zero();
|
---|
2493 | y[abs(axis)-1] = cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
|
---|
2494 | for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times
|
---|
2495 | x += y; // per factor one cell width further
|
---|
2496 | for (int k=count;k--;) { // go through every atom of the original cell
|
---|
2497 | first = World::getInstance().createAtom(); // create a new body
|
---|
2498 | first->x = (*vectors[k]) + x;
|
---|
2499 | first->type = Elements[k]; // insert original element
|
---|
2500 | mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
|
---|
2501 | }
|
---|
2502 | }
|
---|
2503 | // free memory
|
---|
2504 | delete[](Elements);
|
---|
2505 | delete[](vectors);
|
---|
2506 | // correct cell size
|
---|
2507 | if (axis < 0) { // if sign was negative, we have to translate everything
|
---|
2508 | x =(-(faktor-1)) * y;
|
---|
2509 | mol->Translate(&x);
|
---|
2510 | }
|
---|
2511 | cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
|
---|
2512 | }
|
---|
2513 | }
|
---|
2514 | }
|
---|
2515 | break;
|
---|
2516 | default: // no match? Step on
|
---|
2517 | if ((argptr < argc) && (argv[argptr][0] != '-')) // if it started with a '-' we've already made a step!
|
---|
2518 | argptr++;
|
---|
2519 | break;
|
---|
2520 | }
|
---|
2521 | }
|
---|
2522 | } else argptr++;
|
---|
2523 | } while (argptr < argc);
|
---|
2524 | if (SaveFlag)
|
---|
2525 | configuration.SaveAll(ConfigFileName, periode, molecules);
|
---|
2526 | } else { // no arguments, hence scan the elements db
|
---|
2527 | if (periode->LoadPeriodentafel(configuration.databasepath))
|
---|
2528 | DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);
|
---|
2529 | else
|
---|
2530 | DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
|
---|
2531 | configuration.RetrieveConfigPathAndName("main_pcp_linux");
|
---|
2532 | }
|
---|
2533 | return(ExitFlag);
|
---|
2534 | };
|
---|
2535 |
|
---|
2536 | /***************************************** Functions used to build all menus **********************/
|
---|
2537 |
|
---|
2538 | void populateEditMoleculesMenu(Menu* editMoleculesMenu,MoleculeListClass *molecules, config *configuration, periodentafel *periode){
|
---|
2539 | // build the EditMoleculesMenu
|
---|
2540 | Action *createMoleculeAction = new MethodAction("createMoleculeAction",boost::bind(&MoleculeListClass::createNewMolecule,molecules,periode));
|
---|
2541 | new ActionMenuItem('c',"create new molecule",editMoleculesMenu,createMoleculeAction);
|
---|
2542 |
|
---|
2543 | Action *loadMoleculeAction = new MethodAction("loadMoleculeAction",boost::bind(&MoleculeListClass::loadFromXYZ,molecules,periode));
|
---|
2544 | new ActionMenuItem('l',"load molecule from xyz file",editMoleculesMenu,loadMoleculeAction);
|
---|
2545 |
|
---|
2546 | Action *changeFilenameAction = new ChangeMoleculeNameAction(molecules);
|
---|
2547 | new ActionMenuItem('n',"change molecule's name",editMoleculesMenu,changeFilenameAction);
|
---|
2548 |
|
---|
2549 | Action *giveFilenameAction = new MethodAction("giveFilenameAction",boost::bind(&MoleculeListClass::setMoleculeFilename,molecules));
|
---|
2550 | new ActionMenuItem('N',"give molecules filename",editMoleculesMenu,giveFilenameAction);
|
---|
2551 |
|
---|
2552 | Action *parseAtomsAction = new MethodAction("parseAtomsAction",boost::bind(&MoleculeListClass::parseXYZIntoMolecule,molecules));
|
---|
2553 | new ActionMenuItem('p',"parse atoms in xyz file into molecule",editMoleculesMenu,parseAtomsAction);
|
---|
2554 |
|
---|
2555 | Action *eraseMoleculeAction = new MethodAction("eraseMoleculeAction",boost::bind(&MoleculeListClass::eraseMolecule,molecules));
|
---|
2556 | new ActionMenuItem('r',"remove a molecule",editMoleculesMenu,eraseMoleculeAction);
|
---|
2557 |
|
---|
2558 | }
|
---|
2559 |
|
---|
2560 |
|
---|
2561 | /********************************************** Main routine **************************************/
|
---|
2562 |
|
---|
2563 | void cleanUp(config *configuration){
|
---|
2564 | UIFactory::purgeInstance();
|
---|
2565 | World::purgeInstance();
|
---|
2566 | delete(configuration);
|
---|
2567 | Log() << Verbose(0) << "Maximum of allocated memory: "
|
---|
2568 | << MemoryUsageObserver::getInstance()->getMaximumUsedMemory() << endl;
|
---|
2569 | Log() << Verbose(0) << "Remaining non-freed memory: "
|
---|
2570 | << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;
|
---|
2571 | MemoryUsageObserver::purgeInstance();
|
---|
2572 | logger::purgeInstance();
|
---|
2573 | errorLogger::purgeInstance();
|
---|
2574 | ActionRegistry::purgeInstance();
|
---|
2575 | ActionHistory::purgeInstance();
|
---|
2576 | Memory::getState();
|
---|
2577 | }
|
---|
2578 |
|
---|
2579 | int main(int argc, char **argv)
|
---|
2580 | {
|
---|
2581 | molecule *mol = NULL;
|
---|
2582 | config *configuration = new config;
|
---|
2583 | Vector x, y, z, n;
|
---|
2584 | ifstream test;
|
---|
2585 | ofstream output;
|
---|
2586 | string line;
|
---|
2587 | char *ConfigFileName = NULL;
|
---|
2588 | int j;
|
---|
2589 |
|
---|
2590 | cout << ESPACKVersion << endl;
|
---|
2591 |
|
---|
2592 | setVerbosity(0);
|
---|
2593 | // need to init the history before any action is created
|
---|
2594 | ActionHistory::init();
|
---|
2595 | /* structure of ParseCommandLineOptions will be refactored later */
|
---|
2596 | j = ParseCommandLineOptions(argc, argv, World::getInstance().getMolecules(), World::getInstance().getPeriode(), *configuration, ConfigFileName);
|
---|
2597 | switch (j){
|
---|
2598 | case 255:
|
---|
2599 | case 2:
|
---|
2600 | case 1:
|
---|
2601 | cleanUp(configuration);
|
---|
2602 | return (j == 1 ? 0 : j);
|
---|
2603 | default:
|
---|
2604 | break;
|
---|
2605 | }
|
---|
2606 | if(World::getInstance().numMolecules() == 0){
|
---|
2607 | mol = World::getInstance().createMolecule();
|
---|
2608 | World::getInstance().getMolecules()->insert(mol);
|
---|
2609 | cout << "Molecule created" << endl;
|
---|
2610 | if(World::getInstance().getDomain()[0] == 0.){
|
---|
2611 | Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl;
|
---|
2612 | for(int i = 0;i < 6;i++){
|
---|
2613 | Log() << Verbose(1) << "Cell size" << i << ": ";
|
---|
2614 | cin >> World::getInstance().getDomain()[i];
|
---|
2615 | }
|
---|
2616 | }
|
---|
2617 | mol->ActiveFlag = true;
|
---|
2618 | }
|
---|
2619 |
|
---|
2620 | {
|
---|
2621 | cout << ESPACKVersion << endl;
|
---|
2622 |
|
---|
2623 | setVerbosity(0);
|
---|
2624 |
|
---|
2625 | menuPopulaters populaters;
|
---|
2626 | populaters.MakeEditMoleculesMenu = populateEditMoleculesMenu;
|
---|
2627 |
|
---|
2628 | UIFactory::makeUserInterface(UIFactory::Text);
|
---|
2629 | MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow(populaters,World::getInstance().getMolecules(), configuration, World::getInstance().getPeriode(), ConfigFileName);
|
---|
2630 | mainWindow->display();
|
---|
2631 | delete mainWindow;
|
---|
2632 | }
|
---|
2633 |
|
---|
2634 | if(World::getInstance().getPeriode()->StorePeriodentafel(configuration->databasepath))
|
---|
2635 | Log() << Verbose(0) << "Saving of elements.db successful." << endl;
|
---|
2636 |
|
---|
2637 | else
|
---|
2638 | Log() << Verbose(0) << "Saving of elements.db failed." << endl;
|
---|
2639 |
|
---|
2640 | cleanUp(configuration);
|
---|
2641 |
|
---|
2642 | return (0);
|
---|
2643 | }
|
---|
2644 |
|
---|
2645 | /********************************************** E N D **************************************************/
|
---|