1 | /** \file menu.cpp
|
---|
2 | * The class in this file is responsible for displaying the menu and enabling choices.
|
---|
3 | *
|
---|
4 | * This class is currently being refactored. Functions were copied from builder.cpp and are
|
---|
5 | * to be imported into the menu class.
|
---|
6 | *
|
---|
7 | */
|
---|
8 |
|
---|
9 | #include "menu.hpp"
|
---|
10 | #include "analysis_correlation.hpp"
|
---|
11 | #include "atom.hpp"
|
---|
12 | #include "bond.hpp"
|
---|
13 | #include "bondgraph.hpp"
|
---|
14 | #include "boundary.hpp"
|
---|
15 | #include "config.hpp"
|
---|
16 | #include "element.hpp"
|
---|
17 | #include "ellipsoid.hpp"
|
---|
18 | #include "helpers.hpp"
|
---|
19 | #include "leastsquaremin.hpp"
|
---|
20 | #include "linkedcell.hpp"
|
---|
21 | #include "log.hpp"
|
---|
22 | #include "memoryusageobserverunittest.hpp"
|
---|
23 | #include "molecule.hpp"
|
---|
24 | #include "periodentafel.hpp"
|
---|
25 |
|
---|
26 | #include "Menu/Menu.hpp"
|
---|
27 | #include "Menu/TextMenu.hpp"
|
---|
28 | #include "Menu/ActionMenuItem.hpp"
|
---|
29 | #include "Menu/SeperatorItem.hpp"
|
---|
30 | #include "Menu/DisplayMenuItem.hpp"
|
---|
31 | #include "Menu/SubMenuItem.hpp"
|
---|
32 | #include "Actions/MethodAction.hpp"
|
---|
33 | #include "Views/StreamStringView.hpp"
|
---|
34 | #include "Views/MethodStringView.hpp"
|
---|
35 |
|
---|
36 |
|
---|
37 | #include <boost/bind.hpp>
|
---|
38 |
|
---|
39 | /* copied methods for refactoring */
|
---|
40 | /*TODO: Move these methods inside menu class
|
---|
41 | * and restructure menu class*/
|
---|
42 |
|
---|
43 | /********************************************* Subsubmenu routine ************************************/
|
---|
44 |
|
---|
45 | /** Submenu for adding atoms to the molecule.
|
---|
46 | * \param *periode periodentafel
|
---|
47 | * \param *molecule molecules with atoms
|
---|
48 | */
|
---|
49 | void oldmenu::AddAtoms(periodentafel *periode, molecule *mol)
|
---|
50 | {
|
---|
51 | atom *first, *second, *third, *fourth;
|
---|
52 | Vector **atoms;
|
---|
53 | Vector x,y,z,n; // coordinates for absolute point in cell volume
|
---|
54 | double a,b,c;
|
---|
55 | char choice; // menu choice char
|
---|
56 | bool valid;
|
---|
57 |
|
---|
58 | Log() << Verbose(0) << "===========ADD ATOM============================" << endl;
|
---|
59 | Log() << Verbose(0) << " a - state absolute coordinates of atom" << endl;
|
---|
60 | Log() << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;
|
---|
61 | Log() << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;
|
---|
62 | Log() << Verbose(0) << " d - state two atoms, two angles and a distance" << endl;
|
---|
63 | Log() << Verbose(0) << " e - least square distance position to a set of atoms" << endl;
|
---|
64 | Log() << Verbose(0) << "all else - go back" << endl;
|
---|
65 | Log() << Verbose(0) << "===============================================" << endl;
|
---|
66 | Log() << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;
|
---|
67 | Log() << Verbose(0) << "INPUT: ";
|
---|
68 | cin >> choice;
|
---|
69 |
|
---|
70 | switch (choice) {
|
---|
71 | default:
|
---|
72 | eLog() << Verbose(2) << "Not a valid choice." << endl;
|
---|
73 | break;
|
---|
74 | case 'a': // absolute coordinates of atom
|
---|
75 | Log() << Verbose(0) << "Enter absolute coordinates." << endl;
|
---|
76 | first = new atom;
|
---|
77 | first->x.AskPosition(mol->cell_size, false);
|
---|
78 | first->type = periode->AskElement(); // give type
|
---|
79 | mol->AddAtom(first); // add to molecule
|
---|
80 | break;
|
---|
81 |
|
---|
82 | case 'b': // relative coordinates of atom wrt to reference point
|
---|
83 | first = new atom;
|
---|
84 | valid = true;
|
---|
85 | do {
|
---|
86 | if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
|
---|
87 | Log() << Verbose(0) << "Enter reference coordinates." << endl;
|
---|
88 | x.AskPosition(mol->cell_size, true);
|
---|
89 | Log() << Verbose(0) << "Enter relative coordinates." << endl;
|
---|
90 | first->x.AskPosition(mol->cell_size, false);
|
---|
91 | first->x.AddVector((const Vector *)&x);
|
---|
92 | Log() << Verbose(0) << "\n";
|
---|
93 | } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
|
---|
94 | first->type = periode->AskElement(); // give type
|
---|
95 | mol->AddAtom(first); // add to molecule
|
---|
96 | break;
|
---|
97 |
|
---|
98 | case 'c': // relative coordinates of atom wrt to already placed atom
|
---|
99 | first = new atom;
|
---|
100 | valid = true;
|
---|
101 | do {
|
---|
102 | if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
|
---|
103 | second = mol->AskAtom("Enter atom number: ");
|
---|
104 | Log() << Verbose(0) << "Enter relative coordinates." << endl;
|
---|
105 | first->x.AskPosition(mol->cell_size, false);
|
---|
106 | for (int i=NDIM;i--;) {
|
---|
107 | first->x.x[i] += second->x.x[i];
|
---|
108 | }
|
---|
109 | } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
|
---|
110 | first->type = periode->AskElement(); // give type
|
---|
111 | mol->AddAtom(first); // add to molecule
|
---|
112 | break;
|
---|
113 |
|
---|
114 | case 'd': // two atoms, two angles and a distance
|
---|
115 | first = new atom;
|
---|
116 | valid = true;
|
---|
117 | do {
|
---|
118 | if (!valid) {
|
---|
119 | eLog() << Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl;
|
---|
120 | }
|
---|
121 | Log() << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;
|
---|
122 | second = mol->AskAtom("Enter central atom: ");
|
---|
123 | third = mol->AskAtom("Enter second atom (specifying the axis for first angle): ");
|
---|
124 | fourth = mol->AskAtom("Enter third atom (specifying a plane for second angle): ");
|
---|
125 | a = ask_value("Enter distance between central (first) and new atom: ");
|
---|
126 | b = ask_value("Enter angle between new, first and second atom (degrees): ");
|
---|
127 | b *= M_PI/180.;
|
---|
128 | bound(&b, 0., 2.*M_PI);
|
---|
129 | c = ask_value("Enter second angle between new and normal vector of plane defined by first, second and third atom (degrees): ");
|
---|
130 | c *= M_PI/180.;
|
---|
131 | bound(&c, -M_PI, M_PI);
|
---|
132 | Log() << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl;
|
---|
133 | /*
|
---|
134 | second->Output(1,1,(ofstream *)&cout);
|
---|
135 | third->Output(1,2,(ofstream *)&cout);
|
---|
136 | fourth->Output(1,3,(ofstream *)&cout);
|
---|
137 | n.MakeNormalvector((const vector *)&second->x, (const vector *)&third->x, (const vector *)&fourth->x);
|
---|
138 | x.Copyvector(&second->x);
|
---|
139 | x.SubtractVector(&third->x);
|
---|
140 | x.Copyvector(&fourth->x);
|
---|
141 | x.SubtractVector(&third->x);
|
---|
142 |
|
---|
143 | if (!z.SolveSystem(&x,&y,&n, b, c, a)) {
|
---|
144 | Log() << Verbose(0) << "Failure solving self-dependent linear system!" << endl;
|
---|
145 | continue;
|
---|
146 | }
|
---|
147 | Log() << Verbose(0) << "resulting relative coordinates: ";
|
---|
148 | z.Output();
|
---|
149 | Log() << Verbose(0) << endl;
|
---|
150 | */
|
---|
151 | // calc axis vector
|
---|
152 | x.CopyVector(&second->x);
|
---|
153 | x.SubtractVector(&third->x);
|
---|
154 | x.Normalize();
|
---|
155 | Log() << Verbose(0) << "x: ",
|
---|
156 | x.Output();
|
---|
157 | Log() << Verbose(0) << endl;
|
---|
158 | z.MakeNormalVector(&second->x,&third->x,&fourth->x);
|
---|
159 | Log() << Verbose(0) << "z: ",
|
---|
160 | z.Output();
|
---|
161 | Log() << Verbose(0) << endl;
|
---|
162 | y.MakeNormalVector(&x,&z);
|
---|
163 | Log() << Verbose(0) << "y: ",
|
---|
164 | y.Output();
|
---|
165 | Log() << Verbose(0) << endl;
|
---|
166 |
|
---|
167 | // rotate vector around first angle
|
---|
168 | first->x.CopyVector(&x);
|
---|
169 | first->x.RotateVector(&z,b - M_PI);
|
---|
170 | Log() << Verbose(0) << "Rotated vector: ",
|
---|
171 | first->x.Output();
|
---|
172 | Log() << Verbose(0) << endl;
|
---|
173 | // remove the projection onto the rotation plane of the second angle
|
---|
174 | n.CopyVector(&y);
|
---|
175 | n.Scale(first->x.ScalarProduct(&y));
|
---|
176 | Log() << Verbose(0) << "N1: ",
|
---|
177 | n.Output();
|
---|
178 | Log() << Verbose(0) << endl;
|
---|
179 | first->x.SubtractVector(&n);
|
---|
180 | Log() << Verbose(0) << "Subtracted vector: ",
|
---|
181 | first->x.Output();
|
---|
182 | Log() << Verbose(0) << endl;
|
---|
183 | n.CopyVector(&z);
|
---|
184 | n.Scale(first->x.ScalarProduct(&z));
|
---|
185 | Log() << Verbose(0) << "N2: ",
|
---|
186 | n.Output();
|
---|
187 | Log() << Verbose(0) << endl;
|
---|
188 | first->x.SubtractVector(&n);
|
---|
189 | Log() << Verbose(0) << "2nd subtracted vector: ",
|
---|
190 | first->x.Output();
|
---|
191 | Log() << Verbose(0) << endl;
|
---|
192 |
|
---|
193 | // rotate another vector around second angle
|
---|
194 | n.CopyVector(&y);
|
---|
195 | n.RotateVector(&x,c - M_PI);
|
---|
196 | Log() << Verbose(0) << "2nd Rotated vector: ",
|
---|
197 | n.Output();
|
---|
198 | Log() << Verbose(0) << endl;
|
---|
199 |
|
---|
200 | // add the two linear independent vectors
|
---|
201 | first->x.AddVector(&n);
|
---|
202 | first->x.Normalize();
|
---|
203 | first->x.Scale(a);
|
---|
204 | first->x.AddVector(&second->x);
|
---|
205 |
|
---|
206 | Log() << Verbose(0) << "resulting coordinates: ";
|
---|
207 | first->x.Output();
|
---|
208 | Log() << Verbose(0) << endl;
|
---|
209 | } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
|
---|
210 | first->type = periode->AskElement(); // give type
|
---|
211 | mol->AddAtom(first); // add to molecule
|
---|
212 | break;
|
---|
213 |
|
---|
214 | case 'e': // least square distance position to a set of atoms
|
---|
215 | first = new atom;
|
---|
216 | atoms = new (Vector*[128]);
|
---|
217 | valid = true;
|
---|
218 | for(int i=128;i--;)
|
---|
219 | atoms[i] = NULL;
|
---|
220 | int i=0, j=0;
|
---|
221 | Log() << Verbose(0) << "Now we need at least three molecules.\n";
|
---|
222 | do {
|
---|
223 | Log() << Verbose(0) << "Enter " << i+1 << "th atom: ";
|
---|
224 | cin >> j;
|
---|
225 | if (j != -1) {
|
---|
226 | second = mol->FindAtom(j);
|
---|
227 | atoms[i++] = &(second->x);
|
---|
228 | }
|
---|
229 | } while ((j != -1) && (i<128));
|
---|
230 | if (i >= 2) {
|
---|
231 | first->x.LSQdistance((const Vector **)atoms, i);
|
---|
232 |
|
---|
233 | first->x.Output();
|
---|
234 | first->type = periode->AskElement(); // give type
|
---|
235 | mol->AddAtom(first); // add to molecule
|
---|
236 | } else {
|
---|
237 | delete first;
|
---|
238 | Log() << Verbose(0) << "Please enter at least two vectors!\n";
|
---|
239 | }
|
---|
240 | break;
|
---|
241 | };
|
---|
242 | };
|
---|
243 |
|
---|
244 | /** Submenu for centering the atoms in the molecule.
|
---|
245 | * \param *mol molecule with all the atoms
|
---|
246 | */
|
---|
247 | void oldmenu::CenterAtoms(molecule *mol)
|
---|
248 | {
|
---|
249 | Vector x, y, helper;
|
---|
250 | char choice; // menu choice char
|
---|
251 |
|
---|
252 | Log() << Verbose(0) << "===========CENTER ATOMS=========================" << endl;
|
---|
253 | Log() << Verbose(0) << " a - on origin" << endl;
|
---|
254 | Log() << Verbose(0) << " b - on center of gravity" << endl;
|
---|
255 | Log() << Verbose(0) << " c - within box with additional boundary" << endl;
|
---|
256 | Log() << Verbose(0) << " d - within given simulation box" << endl;
|
---|
257 | Log() << Verbose(0) << "all else - go back" << endl;
|
---|
258 | Log() << Verbose(0) << "===============================================" << endl;
|
---|
259 | Log() << Verbose(0) << "INPUT: ";
|
---|
260 | cin >> choice;
|
---|
261 |
|
---|
262 | switch (choice) {
|
---|
263 | default:
|
---|
264 | Log() << Verbose(0) << "Not a valid choice." << endl;
|
---|
265 | break;
|
---|
266 | case 'a':
|
---|
267 | Log() << Verbose(0) << "Centering atoms in config file on origin." << endl;
|
---|
268 | mol->CenterOrigin();
|
---|
269 | break;
|
---|
270 | case 'b':
|
---|
271 | Log() << Verbose(0) << "Centering atoms in config file on center of gravity." << endl;
|
---|
272 | mol->CenterPeriodic();
|
---|
273 | break;
|
---|
274 | case 'c':
|
---|
275 | Log() << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;
|
---|
276 | for (int i=0;i<NDIM;i++) {
|
---|
277 | Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
|
---|
278 | cin >> y.x[i];
|
---|
279 | }
|
---|
280 | mol->CenterEdge(&x); // make every coordinate positive
|
---|
281 | mol->Center.AddVector(&y); // translate by boundary
|
---|
282 | helper.CopyVector(&y);
|
---|
283 | helper.Scale(2.);
|
---|
284 | helper.AddVector(&x);
|
---|
285 | mol->SetBoxDimension(&helper); // update Box of atoms by boundary
|
---|
286 | break;
|
---|
287 | case 'd':
|
---|
288 | Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
|
---|
289 | for (int i=0;i<NDIM;i++) {
|
---|
290 | Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
|
---|
291 | cin >> x.x[i];
|
---|
292 | }
|
---|
293 | // update Box of atoms by boundary
|
---|
294 | mol->SetBoxDimension(&x);
|
---|
295 | // center
|
---|
296 | mol->CenterInBox();
|
---|
297 | break;
|
---|
298 | }
|
---|
299 | };
|
---|
300 |
|
---|
301 | /** Submenu for aligning the atoms in the molecule.
|
---|
302 | * \param *periode periodentafel
|
---|
303 | * \param *mol molecule with all the atoms
|
---|
304 | */
|
---|
305 | void oldmenu::AlignAtoms(periodentafel *periode, molecule *mol)
|
---|
306 | {
|
---|
307 | atom *first, *second, *third;
|
---|
308 | Vector x,n;
|
---|
309 | char choice; // menu choice char
|
---|
310 |
|
---|
311 | Log() << Verbose(0) << "===========ALIGN ATOMS=========================" << endl;
|
---|
312 | Log() << Verbose(0) << " a - state three atoms defining align plane" << endl;
|
---|
313 | Log() << Verbose(0) << " b - state alignment vector" << endl;
|
---|
314 | Log() << Verbose(0) << " c - state two atoms in alignment direction" << endl;
|
---|
315 | Log() << Verbose(0) << " d - align automatically by least square fit" << endl;
|
---|
316 | Log() << Verbose(0) << "all else - go back" << endl;
|
---|
317 | Log() << Verbose(0) << "===============================================" << endl;
|
---|
318 | Log() << Verbose(0) << "INPUT: ";
|
---|
319 | cin >> choice;
|
---|
320 |
|
---|
321 | switch (choice) {
|
---|
322 | default:
|
---|
323 | case 'a': // three atoms defining mirror plane
|
---|
324 | first = mol->AskAtom("Enter first atom: ");
|
---|
325 | second = mol->AskAtom("Enter second atom: ");
|
---|
326 | third = mol->AskAtom("Enter third atom: ");
|
---|
327 |
|
---|
328 | n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
|
---|
329 | break;
|
---|
330 | case 'b': // normal vector of mirror plane
|
---|
331 | Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
|
---|
332 | n.AskPosition(mol->cell_size,0);
|
---|
333 | n.Normalize();
|
---|
334 | break;
|
---|
335 | case 'c': // three atoms defining mirror plane
|
---|
336 | first = mol->AskAtom("Enter first atom: ");
|
---|
337 | second = mol->AskAtom("Enter second atom: ");
|
---|
338 |
|
---|
339 | n.CopyVector((const Vector *)&first->x);
|
---|
340 | n.SubtractVector((const Vector *)&second->x);
|
---|
341 | n.Normalize();
|
---|
342 | break;
|
---|
343 | case 'd':
|
---|
344 | char shorthand[4];
|
---|
345 | Vector a;
|
---|
346 | struct lsq_params param;
|
---|
347 | do {
|
---|
348 | fprintf(stdout, "Enter the element of atoms to be chosen: ");
|
---|
349 | fscanf(stdin, "%3s", shorthand);
|
---|
350 | } while ((param.type = periode->FindElement(shorthand)) == NULL);
|
---|
351 | Log() << Verbose(0) << "Element is " << param.type->name << endl;
|
---|
352 | mol->GetAlignvector(¶m);
|
---|
353 | for (int i=NDIM;i--;) {
|
---|
354 | x.x[i] = gsl_vector_get(param.x,i);
|
---|
355 | n.x[i] = gsl_vector_get(param.x,i+NDIM);
|
---|
356 | }
|
---|
357 | gsl_vector_free(param.x);
|
---|
358 | Log() << Verbose(0) << "Offset vector: ";
|
---|
359 | x.Output();
|
---|
360 | Log() << Verbose(0) << endl;
|
---|
361 | n.Normalize();
|
---|
362 | break;
|
---|
363 | };
|
---|
364 | Log() << Verbose(0) << "Alignment vector: ";
|
---|
365 | n.Output();
|
---|
366 | Log() << Verbose(0) << endl;
|
---|
367 | mol->Align(&n);
|
---|
368 | };
|
---|
369 |
|
---|
370 | /** Submenu for mirroring the atoms in the molecule.
|
---|
371 | * \param *mol molecule with all the atoms
|
---|
372 | */
|
---|
373 | void oldmenu::MirrorAtoms(molecule *mol)
|
---|
374 | {
|
---|
375 | atom *first, *second, *third;
|
---|
376 | Vector n;
|
---|
377 | char choice; // menu choice char
|
---|
378 |
|
---|
379 | Log() << Verbose(0) << "===========MIRROR ATOMS=========================" << endl;
|
---|
380 | Log() << Verbose(0) << " a - state three atoms defining mirror plane" << endl;
|
---|
381 | Log() << Verbose(0) << " b - state normal vector of mirror plane" << endl;
|
---|
382 | Log() << Verbose(0) << " c - state two atoms in normal direction" << endl;
|
---|
383 | Log() << Verbose(0) << "all else - go back" << endl;
|
---|
384 | Log() << Verbose(0) << "===============================================" << endl;
|
---|
385 | Log() << Verbose(0) << "INPUT: ";
|
---|
386 | cin >> choice;
|
---|
387 |
|
---|
388 | switch (choice) {
|
---|
389 | default:
|
---|
390 | case 'a': // three atoms defining mirror plane
|
---|
391 | first = mol->AskAtom("Enter first atom: ");
|
---|
392 | second = mol->AskAtom("Enter second atom: ");
|
---|
393 | third = mol->AskAtom("Enter third atom: ");
|
---|
394 |
|
---|
395 | n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
|
---|
396 | break;
|
---|
397 | case 'b': // normal vector of mirror plane
|
---|
398 | Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
|
---|
399 | n.AskPosition(mol->cell_size,0);
|
---|
400 | n.Normalize();
|
---|
401 | break;
|
---|
402 | case 'c': // three atoms defining mirror plane
|
---|
403 | first = mol->AskAtom("Enter first atom: ");
|
---|
404 | second = mol->AskAtom("Enter second atom: ");
|
---|
405 |
|
---|
406 | n.CopyVector((const Vector *)&first->x);
|
---|
407 | n.SubtractVector((const Vector *)&second->x);
|
---|
408 | n.Normalize();
|
---|
409 | break;
|
---|
410 | };
|
---|
411 | Log() << Verbose(0) << "Normal vector: ";
|
---|
412 | n.Output();
|
---|
413 | Log() << Verbose(0) << endl;
|
---|
414 | mol->Mirror((const Vector *)&n);
|
---|
415 | };
|
---|
416 |
|
---|
417 | /** Submenu for removing the atoms from the molecule.
|
---|
418 | * \param *mol molecule with all the atoms
|
---|
419 | */
|
---|
420 | void oldmenu::RemoveAtoms(molecule *mol)
|
---|
421 | {
|
---|
422 | atom *first, *second;
|
---|
423 | int axis;
|
---|
424 | double tmp1, tmp2;
|
---|
425 | char choice; // menu choice char
|
---|
426 |
|
---|
427 | Log() << Verbose(0) << "===========REMOVE ATOMS=========================" << endl;
|
---|
428 | Log() << Verbose(0) << " a - state atom for removal by number" << endl;
|
---|
429 | Log() << Verbose(0) << " b - keep only in radius around atom" << endl;
|
---|
430 | Log() << Verbose(0) << " c - remove this with one axis greater value" << endl;
|
---|
431 | Log() << Verbose(0) << "all else - go back" << endl;
|
---|
432 | Log() << Verbose(0) << "===============================================" << endl;
|
---|
433 | Log() << Verbose(0) << "INPUT: ";
|
---|
434 | cin >> choice;
|
---|
435 |
|
---|
436 | switch (choice) {
|
---|
437 | default:
|
---|
438 | case 'a':
|
---|
439 | if (mol->RemoveAtom(mol->AskAtom("Enter number of atom within molecule: ")))
|
---|
440 | Log() << Verbose(1) << "Atom removed." << endl;
|
---|
441 | else
|
---|
442 | Log() << Verbose(1) << "Atom not found." << endl;
|
---|
443 | break;
|
---|
444 | case 'b':
|
---|
445 | second = mol->AskAtom("Enter number of atom as reference point: ");
|
---|
446 | Log() << Verbose(0) << "Enter radius: ";
|
---|
447 | cin >> tmp1;
|
---|
448 | first = mol->start;
|
---|
449 | second = first->next;
|
---|
450 | while(second != mol->end) {
|
---|
451 | first = second;
|
---|
452 | second = first->next;
|
---|
453 | if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...
|
---|
454 | mol->RemoveAtom(first);
|
---|
455 | }
|
---|
456 | break;
|
---|
457 | case 'c':
|
---|
458 | Log() << Verbose(0) << "Which axis is it: ";
|
---|
459 | cin >> axis;
|
---|
460 | Log() << Verbose(0) << "Lower boundary: ";
|
---|
461 | cin >> tmp1;
|
---|
462 | Log() << Verbose(0) << "Upper boundary: ";
|
---|
463 | cin >> tmp2;
|
---|
464 | first = mol->start;
|
---|
465 | second = first->next;
|
---|
466 | while(second != mol->end) {
|
---|
467 | first = second;
|
---|
468 | second = first->next;
|
---|
469 | if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
|
---|
470 | //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
|
---|
471 | mol->RemoveAtom(first);
|
---|
472 | }
|
---|
473 | }
|
---|
474 | break;
|
---|
475 | };
|
---|
476 | //mol->Output();
|
---|
477 | choice = 'r';
|
---|
478 | };
|
---|
479 |
|
---|
480 | /** Submenu for measuring out the atoms in the molecule.
|
---|
481 | * \param *periode periodentafel
|
---|
482 | * \param *mol molecule with all the atoms
|
---|
483 | */
|
---|
484 | void oldmenu::MeasureAtoms(periodentafel *periode, molecule *mol, config *configuration)
|
---|
485 | {
|
---|
486 | atom *first, *second, *third;
|
---|
487 | Vector x,y;
|
---|
488 | double min[256], tmp1, tmp2, tmp3;
|
---|
489 | int Z;
|
---|
490 | char choice; // menu choice char
|
---|
491 |
|
---|
492 | Log() << Verbose(0) << "===========MEASURE ATOMS=========================" << endl;
|
---|
493 | Log() << Verbose(0) << " a - calculate bond length between one atom and all others" << endl;
|
---|
494 | Log() << Verbose(0) << " b - calculate bond length between two atoms" << endl;
|
---|
495 | Log() << Verbose(0) << " c - calculate bond angle" << endl;
|
---|
496 | Log() << Verbose(0) << " d - calculate principal axis of the system" << endl;
|
---|
497 | Log() << Verbose(0) << " e - calculate volume of the convex envelope" << endl;
|
---|
498 | Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl;
|
---|
499 | Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl;
|
---|
500 | Log() << Verbose(0) << "all else - go back" << endl;
|
---|
501 | Log() << Verbose(0) << "===============================================" << endl;
|
---|
502 | Log() << Verbose(0) << "INPUT: ";
|
---|
503 | cin >> choice;
|
---|
504 |
|
---|
505 | switch(choice) {
|
---|
506 | default:
|
---|
507 | Log() << Verbose(1) << "Not a valid choice." << endl;
|
---|
508 | break;
|
---|
509 | case 'a':
|
---|
510 | first = mol->AskAtom("Enter first atom: ");
|
---|
511 | for (int i=MAX_ELEMENTS;i--;)
|
---|
512 | min[i] = 0.;
|
---|
513 |
|
---|
514 | second = mol->start;
|
---|
515 | while ((second->next != mol->end)) {
|
---|
516 | second = second->next; // advance
|
---|
517 | Z = second->type->Z;
|
---|
518 | tmp1 = 0.;
|
---|
519 | if (first != second) {
|
---|
520 | x.CopyVector((const Vector *)&first->x);
|
---|
521 | x.SubtractVector((const Vector *)&second->x);
|
---|
522 | tmp1 = x.Norm();
|
---|
523 | }
|
---|
524 | if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
|
---|
525 | //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;
|
---|
526 | }
|
---|
527 | for (int i=MAX_ELEMENTS;i--;)
|
---|
528 | 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;
|
---|
529 | break;
|
---|
530 |
|
---|
531 | case 'b':
|
---|
532 | first = mol->AskAtom("Enter first atom: ");
|
---|
533 | second = mol->AskAtom("Enter second atom: ");
|
---|
534 | for (int i=NDIM;i--;)
|
---|
535 | min[i] = 0.;
|
---|
536 | x.CopyVector((const Vector *)&first->x);
|
---|
537 | x.SubtractVector((const Vector *)&second->x);
|
---|
538 | tmp1 = x.Norm();
|
---|
539 | Log() << Verbose(1) << "Distance vector is ";
|
---|
540 | x.Output();
|
---|
541 | Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl;
|
---|
542 | break;
|
---|
543 |
|
---|
544 | case 'c':
|
---|
545 | Log() << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl;
|
---|
546 | first = mol->AskAtom("Enter first atom: ");
|
---|
547 | second = mol->AskAtom("Enter central atom: ");
|
---|
548 | third = mol->AskAtom("Enter last atom: ");
|
---|
549 | tmp1 = tmp2 = tmp3 = 0.;
|
---|
550 | x.CopyVector((const Vector *)&first->x);
|
---|
551 | x.SubtractVector((const Vector *)&second->x);
|
---|
552 | y.CopyVector((const Vector *)&third->x);
|
---|
553 | y.SubtractVector((const Vector *)&second->x);
|
---|
554 | Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
|
---|
555 | Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
|
---|
556 | break;
|
---|
557 | case 'd':
|
---|
558 | Log() << Verbose(0) << "Evaluating prinicipal axis." << endl;
|
---|
559 | Log() << Verbose(0) << "Shall we rotate? [0/1]: ";
|
---|
560 | cin >> Z;
|
---|
561 | if ((Z >=0) && (Z <=1))
|
---|
562 | mol->PrincipalAxisSystem((bool)Z);
|
---|
563 | else
|
---|
564 | mol->PrincipalAxisSystem(false);
|
---|
565 | break;
|
---|
566 | case 'e':
|
---|
567 | {
|
---|
568 | Log() << Verbose(0) << "Evaluating volume of the convex envelope.";
|
---|
569 | class Tesselation *TesselStruct = NULL;
|
---|
570 | const LinkedCell *LCList = NULL;
|
---|
571 | LCList = new LinkedCell(mol, 10.);
|
---|
572 | FindConvexBorder(mol, TesselStruct, LCList, NULL);
|
---|
573 | double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
|
---|
574 | Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl;\
|
---|
575 | delete(LCList);
|
---|
576 | delete(TesselStruct);
|
---|
577 | }
|
---|
578 | break;
|
---|
579 | case 'f':
|
---|
580 | mol->OutputTemperatureFromTrajectories((ofstream *)&cout, mol->MDSteps-1, mol->MDSteps);
|
---|
581 | break;
|
---|
582 | case 'g':
|
---|
583 | {
|
---|
584 | char filename[255];
|
---|
585 | Log() << Verbose(0) << "Please enter filename: " << endl;
|
---|
586 | cin >> filename;
|
---|
587 | Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl;
|
---|
588 | ofstream *output = new ofstream(filename, ios::trunc);
|
---|
589 | if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))
|
---|
590 | Log() << Verbose(2) << "File could not be written." << endl;
|
---|
591 | else
|
---|
592 | Log() << Verbose(2) << "File stored." << endl;
|
---|
593 | output->close();
|
---|
594 | delete(output);
|
---|
595 | }
|
---|
596 | break;
|
---|
597 | }
|
---|
598 | };
|
---|
599 |
|
---|
600 | /** Submenu for measuring out the atoms in the molecule.
|
---|
601 | * \param *mol molecule with all the atoms
|
---|
602 | * \param *configuration configuration structure for the to be written config files of all fragments
|
---|
603 | */
|
---|
604 | void oldmenu::FragmentAtoms(molecule *mol, config *configuration)
|
---|
605 | {
|
---|
606 | int Order1;
|
---|
607 | clock_t start, end;
|
---|
608 |
|
---|
609 | Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
|
---|
610 | Log() << Verbose(0) << "What's the desired bond order: ";
|
---|
611 | cin >> Order1;
|
---|
612 | if (mol->first->next != mol->last) { // there are bonds
|
---|
613 | start = clock();
|
---|
614 | mol->FragmentMolecule(Order1, configuration);
|
---|
615 | end = clock();
|
---|
616 | Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
|
---|
617 | } else
|
---|
618 | Log() << Verbose(0) << "Connection matrix has not yet been generated!" << endl;
|
---|
619 | };
|
---|
620 |
|
---|
621 | /********************************************** Submenu routine **************************************/
|
---|
622 |
|
---|
623 | /** Submenu for manipulating atoms.
|
---|
624 | * \param *periode periodentafel
|
---|
625 | * \param *molecules list of molecules whose atoms are to be manipulated
|
---|
626 | */
|
---|
627 | void oldmenu::ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
|
---|
628 | {
|
---|
629 | atom *first, *second;
|
---|
630 | molecule *mol = NULL;
|
---|
631 | Vector x,y,z,n; // coordinates for absolute point in cell volume
|
---|
632 | double *factor; // unit factor if desired
|
---|
633 | double bond, minBond;
|
---|
634 | char choice; // menu choice char
|
---|
635 | bool valid;
|
---|
636 |
|
---|
637 | Log() << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl;
|
---|
638 | Log() << Verbose(0) << "a - add an atom" << endl;
|
---|
639 | Log() << Verbose(0) << "r - remove an atom" << endl;
|
---|
640 | Log() << Verbose(0) << "b - scale a bond between atoms" << endl;
|
---|
641 | Log() << Verbose(0) << "u - change an atoms element" << endl;
|
---|
642 | Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl;
|
---|
643 | Log() << Verbose(0) << "all else - go back" << endl;
|
---|
644 | Log() << Verbose(0) << "===============================================" << endl;
|
---|
645 | if (molecules->NumberOfActiveMolecules() > 1)
|
---|
646 | eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;
|
---|
647 | Log() << Verbose(0) << "INPUT: ";
|
---|
648 | cin >> choice;
|
---|
649 |
|
---|
650 | switch (choice) {
|
---|
651 | default:
|
---|
652 | Log() << Verbose(0) << "Not a valid choice." << endl;
|
---|
653 | break;
|
---|
654 |
|
---|
655 | case 'a': // add atom
|
---|
656 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
657 | if ((*ListRunner)->ActiveFlag) {
|
---|
658 | mol = *ListRunner;
|
---|
659 | Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
|
---|
660 | AddAtoms(periode, mol);
|
---|
661 | }
|
---|
662 | break;
|
---|
663 |
|
---|
664 | case 'b': // scale a bond
|
---|
665 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
666 | if ((*ListRunner)->ActiveFlag) {
|
---|
667 | mol = *ListRunner;
|
---|
668 | Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
|
---|
669 | Log() << Verbose(0) << "Scaling bond length between two atoms." << endl;
|
---|
670 | first = mol->AskAtom("Enter first (fixed) atom: ");
|
---|
671 | second = mol->AskAtom("Enter second (shifting) atom: ");
|
---|
672 | minBond = 0.;
|
---|
673 | for (int i=NDIM;i--;)
|
---|
674 | minBond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]);
|
---|
675 | minBond = sqrt(minBond);
|
---|
676 | Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;
|
---|
677 | Log() << Verbose(0) << "Enter new bond length [a.u.]: ";
|
---|
678 | cin >> bond;
|
---|
679 | for (int i=NDIM;i--;) {
|
---|
680 | second->x.x[i] -= (second->x.x[i]-first->x.x[i])/minBond*(minBond-bond);
|
---|
681 | }
|
---|
682 | //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";
|
---|
683 | //second->Output(second->type->No, 1);
|
---|
684 | }
|
---|
685 | break;
|
---|
686 |
|
---|
687 | case 'c': // unit scaling of the metric
|
---|
688 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
689 | if ((*ListRunner)->ActiveFlag) {
|
---|
690 | mol = *ListRunner;
|
---|
691 | Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
|
---|
692 | Log() << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl;
|
---|
693 | Log() << Verbose(0) << "Enter three factors: ";
|
---|
694 | factor = new double[NDIM];
|
---|
695 | cin >> factor[0];
|
---|
696 | cin >> factor[1];
|
---|
697 | cin >> factor[2];
|
---|
698 | valid = true;
|
---|
699 | mol->Scale((const double ** const)&factor);
|
---|
700 | delete[](factor);
|
---|
701 | }
|
---|
702 | break;
|
---|
703 |
|
---|
704 | case 'l': // measure distances or angles
|
---|
705 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
706 | if ((*ListRunner)->ActiveFlag) {
|
---|
707 | mol = *ListRunner;
|
---|
708 | Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
|
---|
709 | MeasureAtoms(periode, mol, configuration);
|
---|
710 | }
|
---|
711 | break;
|
---|
712 |
|
---|
713 | case 'r': // remove atom
|
---|
714 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
715 | if ((*ListRunner)->ActiveFlag) {
|
---|
716 | mol = *ListRunner;
|
---|
717 | Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
|
---|
718 | RemoveAtoms(mol);
|
---|
719 | }
|
---|
720 | break;
|
---|
721 |
|
---|
722 | case 'u': // change an atom's element
|
---|
723 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
724 | if ((*ListRunner)->ActiveFlag) {
|
---|
725 | int Z;
|
---|
726 | mol = *ListRunner;
|
---|
727 | Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
|
---|
728 | first = NULL;
|
---|
729 | do {
|
---|
730 | Log() << Verbose(0) << "Change the element of which atom: ";
|
---|
731 | cin >> Z;
|
---|
732 | } while ((first = mol->FindAtom(Z)) == NULL);
|
---|
733 | Log() << Verbose(0) << "New element by atomic number Z: ";
|
---|
734 | cin >> Z;
|
---|
735 | first->type = periode->FindElement(Z);
|
---|
736 | Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl;
|
---|
737 | }
|
---|
738 | break;
|
---|
739 | }
|
---|
740 | };
|
---|
741 |
|
---|
742 | /** Submenu for manipulating molecules.
|
---|
743 | * \param *periode periodentafel
|
---|
744 | * \param *molecules list of molecule to manipulate
|
---|
745 | */
|
---|
746 | void oldmenu::ManipulateMolecules(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
|
---|
747 | {
|
---|
748 | atom *first = NULL;
|
---|
749 | Vector x,y,z,n; // coordinates for absolute point in cell volume
|
---|
750 | int j, axis, count, faktor;
|
---|
751 | char choice; // menu choice char
|
---|
752 | molecule *mol = NULL;
|
---|
753 | element **Elements;
|
---|
754 | Vector **vectors;
|
---|
755 | MoleculeLeafClass *Subgraphs = NULL;
|
---|
756 |
|
---|
757 | Log() << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl;
|
---|
758 | Log() << Verbose(0) << "c - scale by unit transformation" << endl;
|
---|
759 | Log() << Verbose(0) << "d - duplicate molecule/periodic cell" << endl;
|
---|
760 | Log() << Verbose(0) << "f - fragment molecule many-body bond order style" << endl;
|
---|
761 | Log() << Verbose(0) << "g - center atoms in box" << endl;
|
---|
762 | Log() << Verbose(0) << "i - realign molecule" << endl;
|
---|
763 | Log() << Verbose(0) << "m - mirror all molecules" << endl;
|
---|
764 | Log() << Verbose(0) << "o - create connection matrix" << endl;
|
---|
765 | Log() << Verbose(0) << "t - translate molecule by vector" << endl;
|
---|
766 | Log() << Verbose(0) << "all else - go back" << endl;
|
---|
767 | Log() << Verbose(0) << "===============================================" << endl;
|
---|
768 | if (molecules->NumberOfActiveMolecules() > 1)
|
---|
769 | eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;
|
---|
770 | Log() << Verbose(0) << "INPUT: ";
|
---|
771 | cin >> choice;
|
---|
772 |
|
---|
773 | switch (choice) {
|
---|
774 | default:
|
---|
775 | Log() << Verbose(0) << "Not a valid choice." << endl;
|
---|
776 | break;
|
---|
777 |
|
---|
778 | case 'd': // duplicate the periodic cell along a given axis, given times
|
---|
779 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
780 | if ((*ListRunner)->ActiveFlag) {
|
---|
781 | mol = *ListRunner;
|
---|
782 | Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
|
---|
783 | Log() << Verbose(0) << "State the axis [(+-)123]: ";
|
---|
784 | cin >> axis;
|
---|
785 | Log() << Verbose(0) << "State the factor: ";
|
---|
786 | cin >> faktor;
|
---|
787 |
|
---|
788 | mol->CountAtoms(); // recount atoms
|
---|
789 | if (mol->AtomCount != 0) { // if there is more than none
|
---|
790 | count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand
|
---|
791 | Elements = new element *[count];
|
---|
792 | vectors = new Vector *[count];
|
---|
793 | j = 0;
|
---|
794 | first = mol->start;
|
---|
795 | while (first->next != mol->end) { // make a list of all atoms with coordinates and element
|
---|
796 | first = first->next;
|
---|
797 | Elements[j] = first->type;
|
---|
798 | vectors[j] = &first->x;
|
---|
799 | j++;
|
---|
800 | }
|
---|
801 | if (count != j)
|
---|
802 | eLog() << Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
|
---|
803 | x.Zero();
|
---|
804 | y.Zero();
|
---|
805 | y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
|
---|
806 | for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times
|
---|
807 | x.AddVector(&y); // per factor one cell width further
|
---|
808 | for (int k=count;k--;) { // go through every atom of the original cell
|
---|
809 | first = new atom(); // create a new body
|
---|
810 | first->x.CopyVector(vectors[k]); // use coordinate of original atom
|
---|
811 | first->x.AddVector(&x); // translate the coordinates
|
---|
812 | first->type = Elements[k]; // insert original element
|
---|
813 | mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
|
---|
814 | }
|
---|
815 | }
|
---|
816 | if (mol->first->next != mol->last) // if connect matrix is present already, redo it
|
---|
817 | mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
|
---|
818 | // free memory
|
---|
819 | delete[](Elements);
|
---|
820 | delete[](vectors);
|
---|
821 | // correct cell size
|
---|
822 | if (axis < 0) { // if sign was negative, we have to translate everything
|
---|
823 | x.Zero();
|
---|
824 | x.AddVector(&y);
|
---|
825 | x.Scale(-(faktor-1));
|
---|
826 | mol->Translate(&x);
|
---|
827 | }
|
---|
828 | mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
|
---|
829 | }
|
---|
830 | }
|
---|
831 | break;
|
---|
832 |
|
---|
833 | case 'f':
|
---|
834 | FragmentAtoms(mol, configuration);
|
---|
835 | break;
|
---|
836 |
|
---|
837 | case 'g': // center the atoms
|
---|
838 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
839 | if ((*ListRunner)->ActiveFlag) {
|
---|
840 | mol = *ListRunner;
|
---|
841 | Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
|
---|
842 | CenterAtoms(mol);
|
---|
843 | }
|
---|
844 | break;
|
---|
845 |
|
---|
846 | case 'i': // align all atoms
|
---|
847 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
848 | if ((*ListRunner)->ActiveFlag) {
|
---|
849 | mol = *ListRunner;
|
---|
850 | Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
|
---|
851 | AlignAtoms(periode, mol);
|
---|
852 | }
|
---|
853 | break;
|
---|
854 |
|
---|
855 | case 'm': // mirror atoms along a given axis
|
---|
856 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
857 | if ((*ListRunner)->ActiveFlag) {
|
---|
858 | mol = *ListRunner;
|
---|
859 | Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
|
---|
860 | MirrorAtoms(mol);
|
---|
861 | }
|
---|
862 | break;
|
---|
863 |
|
---|
864 | case 'o': // create the connection matrix
|
---|
865 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
866 | if ((*ListRunner)->ActiveFlag) {
|
---|
867 | mol = *ListRunner;
|
---|
868 | double bonddistance;
|
---|
869 | clock_t start,end;
|
---|
870 | Log() << Verbose(0) << "What's the maximum bond distance: ";
|
---|
871 | cin >> bonddistance;
|
---|
872 | start = clock();
|
---|
873 | mol->CreateAdjacencyList(bonddistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
|
---|
874 | end = clock();
|
---|
875 | Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
|
---|
876 | }
|
---|
877 | break;
|
---|
878 |
|
---|
879 | case 't': // translate all atoms
|
---|
880 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
881 | if ((*ListRunner)->ActiveFlag) {
|
---|
882 | mol = *ListRunner;
|
---|
883 | Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
|
---|
884 | Log() << Verbose(0) << "Enter translation vector." << endl;
|
---|
885 | x.AskPosition(mol->cell_size,0);
|
---|
886 | mol->Center.AddVector((const Vector *)&x);
|
---|
887 | }
|
---|
888 | break;
|
---|
889 | }
|
---|
890 | // Free all
|
---|
891 | if (Subgraphs != NULL) { // free disconnected subgraph list of DFS analysis was performed
|
---|
892 | while (Subgraphs->next != NULL) {
|
---|
893 | Subgraphs = Subgraphs->next;
|
---|
894 | delete(Subgraphs->previous);
|
---|
895 | }
|
---|
896 | delete(Subgraphs);
|
---|
897 | }
|
---|
898 | };
|
---|
899 |
|
---|
900 |
|
---|
901 | /** Submenu for merging molecules.
|
---|
902 | * \param *periode periodentafel
|
---|
903 | * \param *molecules list of molecules to add to
|
---|
904 | */
|
---|
905 | void oldmenu::MergeMolecules(periodentafel *periode, MoleculeListClass *molecules)
|
---|
906 | {
|
---|
907 | char choice; // menu choice char
|
---|
908 |
|
---|
909 | Log() << Verbose(0) << "===========MERGE MOLECULES=====================" << endl;
|
---|
910 | Log() << Verbose(0) << "a - simple add of one molecule to another" << endl;
|
---|
911 | Log() << Verbose(0) << "e - embedding merge of two molecules" << endl;
|
---|
912 | Log() << Verbose(0) << "m - multi-merge of all molecules" << endl;
|
---|
913 | Log() << Verbose(0) << "s - scatter merge of two molecules" << endl;
|
---|
914 | Log() << Verbose(0) << "t - simple merge of two molecules" << endl;
|
---|
915 | Log() << Verbose(0) << "all else - go back" << endl;
|
---|
916 | Log() << Verbose(0) << "===============================================" << endl;
|
---|
917 | Log() << Verbose(0) << "INPUT: ";
|
---|
918 | cin >> choice;
|
---|
919 |
|
---|
920 | switch (choice) {
|
---|
921 | default:
|
---|
922 | Log() << Verbose(0) << "Not a valid choice." << endl;
|
---|
923 | break;
|
---|
924 |
|
---|
925 | case 'a':
|
---|
926 | {
|
---|
927 | int src, dest;
|
---|
928 | molecule *srcmol = NULL, *destmol = NULL;
|
---|
929 | {
|
---|
930 | do {
|
---|
931 | Log() << Verbose(0) << "Enter index of destination molecule: ";
|
---|
932 | cin >> dest;
|
---|
933 | destmol = molecules->ReturnIndex(dest);
|
---|
934 | } while ((destmol == NULL) && (dest != -1));
|
---|
935 | do {
|
---|
936 | Log() << Verbose(0) << "Enter index of source molecule to add from: ";
|
---|
937 | cin >> src;
|
---|
938 | srcmol = molecules->ReturnIndex(src);
|
---|
939 | } while ((srcmol == NULL) && (src != -1));
|
---|
940 | if ((src != -1) && (dest != -1))
|
---|
941 | molecules->SimpleAdd(srcmol, destmol);
|
---|
942 | }
|
---|
943 | }
|
---|
944 | break;
|
---|
945 |
|
---|
946 | case 'e':
|
---|
947 | {
|
---|
948 | int src, dest;
|
---|
949 | molecule *srcmol = NULL, *destmol = NULL;
|
---|
950 | do {
|
---|
951 | Log() << Verbose(0) << "Enter index of matrix molecule (the variable one): ";
|
---|
952 | cin >> src;
|
---|
953 | srcmol = molecules->ReturnIndex(src);
|
---|
954 | } while ((srcmol == NULL) && (src != -1));
|
---|
955 | do {
|
---|
956 | Log() << Verbose(0) << "Enter index of molecule to merge into (the fixed one): ";
|
---|
957 | cin >> dest;
|
---|
958 | destmol = molecules->ReturnIndex(dest);
|
---|
959 | } while ((destmol == NULL) && (dest != -1));
|
---|
960 | if ((src != -1) && (dest != -1))
|
---|
961 | molecules->EmbedMerge(destmol, srcmol);
|
---|
962 | }
|
---|
963 | break;
|
---|
964 |
|
---|
965 | case 'm':
|
---|
966 | {
|
---|
967 | int nr;
|
---|
968 | molecule *mol = NULL;
|
---|
969 | do {
|
---|
970 | Log() << Verbose(0) << "Enter index of molecule to merge into: ";
|
---|
971 | cin >> nr;
|
---|
972 | mol = molecules->ReturnIndex(nr);
|
---|
973 | } while ((mol == NULL) && (nr != -1));
|
---|
974 | if (nr != -1) {
|
---|
975 | int N = molecules->ListOfMolecules.size()-1;
|
---|
976 | int *src = new int(N);
|
---|
977 | for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
|
---|
978 | if ((*ListRunner)->IndexNr != nr)
|
---|
979 | src[N++] = (*ListRunner)->IndexNr;
|
---|
980 | molecules->SimpleMultiMerge(mol, src, N);
|
---|
981 | delete[](src);
|
---|
982 | }
|
---|
983 | }
|
---|
984 | break;
|
---|
985 |
|
---|
986 | case 's':
|
---|
987 | Log() << Verbose(0) << "Not implemented yet." << endl;
|
---|
988 | break;
|
---|
989 |
|
---|
990 | case 't':
|
---|
991 | {
|
---|
992 | int src, dest;
|
---|
993 | molecule *srcmol = NULL, *destmol = NULL;
|
---|
994 | {
|
---|
995 | do {
|
---|
996 | Log() << Verbose(0) << "Enter index of destination molecule: ";
|
---|
997 | cin >> dest;
|
---|
998 | destmol = molecules->ReturnIndex(dest);
|
---|
999 | } while ((destmol == NULL) && (dest != -1));
|
---|
1000 | do {
|
---|
1001 | Log() << Verbose(0) << "Enter index of source molecule to merge into: ";
|
---|
1002 | cin >> src;
|
---|
1003 | srcmol = molecules->ReturnIndex(src);
|
---|
1004 | } while ((srcmol == NULL) && (src != -1));
|
---|
1005 | if ((src != -1) && (dest != -1))
|
---|
1006 | molecules->SimpleMerge(srcmol, destmol);
|
---|
1007 | }
|
---|
1008 | }
|
---|
1009 | break;
|
---|
1010 | }
|
---|
1011 | };
|
---|
1012 |
|
---|
1013 |
|
---|
1014 | /********************************************** Test routine **************************************/
|
---|
1015 |
|
---|
1016 | /** Is called always as option 'T' in the menu.
|
---|
1017 | * \param *molecules list of molecules
|
---|
1018 | */
|
---|
1019 | void oldmenu::testroutine(MoleculeListClass *molecules)
|
---|
1020 | {
|
---|
1021 | // the current test routine checks the functionality of the KeySet&Graph concept:
|
---|
1022 | // We want to have a multiindex (the KeySet) describing a unique subgraph
|
---|
1023 | int i, comp, counter=0;
|
---|
1024 |
|
---|
1025 | // create a clone
|
---|
1026 | molecule *mol = NULL;
|
---|
1027 | if (molecules->ListOfMolecules.size() != 0) // clone
|
---|
1028 | mol = (molecules->ListOfMolecules.front())->CopyMolecule();
|
---|
1029 | else {
|
---|
1030 | eLog() << Verbose(0) << "I don't have anything to test on ... ";
|
---|
1031 | performCriticalExit();
|
---|
1032 | return;
|
---|
1033 | }
|
---|
1034 | atom *Walker = mol->start;
|
---|
1035 |
|
---|
1036 | // generate some KeySets
|
---|
1037 | Log() << Verbose(0) << "Generating KeySets." << endl;
|
---|
1038 | KeySet TestSets[mol->AtomCount+1];
|
---|
1039 | i=1;
|
---|
1040 | while (Walker->next != mol->end) {
|
---|
1041 | Walker = Walker->next;
|
---|
1042 | for (int j=0;j<i;j++) {
|
---|
1043 | TestSets[j].insert(Walker->nr);
|
---|
1044 | }
|
---|
1045 | i++;
|
---|
1046 | }
|
---|
1047 | Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl;
|
---|
1048 | KeySetTestPair test;
|
---|
1049 | test = TestSets[mol->AtomCount-1].insert(Walker->nr);
|
---|
1050 | if (test.second) {
|
---|
1051 | Log() << Verbose(1) << "Insertion worked?!" << endl;
|
---|
1052 | } else {
|
---|
1053 | Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
|
---|
1054 | }
|
---|
1055 | TestSets[mol->AtomCount].insert(mol->end->previous->nr);
|
---|
1056 | TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
|
---|
1057 |
|
---|
1058 | // constructing Graph structure
|
---|
1059 | Log() << Verbose(0) << "Generating Subgraph class." << endl;
|
---|
1060 | Graph Subgraphs;
|
---|
1061 |
|
---|
1062 | // insert KeySets into Subgraphs
|
---|
1063 | Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl;
|
---|
1064 | for (int j=0;j<mol->AtomCount;j++) {
|
---|
1065 | Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
|
---|
1066 | }
|
---|
1067 | Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl;
|
---|
1068 | GraphTestPair test2;
|
---|
1069 | test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
|
---|
1070 | if (test2.second) {
|
---|
1071 | Log() << Verbose(1) << "Insertion worked?!" << endl;
|
---|
1072 | } else {
|
---|
1073 | Log() << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl;
|
---|
1074 | }
|
---|
1075 |
|
---|
1076 | // show graphs
|
---|
1077 | Log() << Verbose(0) << "Showing Subgraph's contents, checking that it's sorted." << endl;
|
---|
1078 | Graph::iterator A = Subgraphs.begin();
|
---|
1079 | while (A != Subgraphs.end()) {
|
---|
1080 | Log() << Verbose(0) << (*A).second.first << ": ";
|
---|
1081 | KeySet::iterator key = (*A).first.begin();
|
---|
1082 | comp = -1;
|
---|
1083 | while (key != (*A).first.end()) {
|
---|
1084 | if ((*key) > comp)
|
---|
1085 | Log() << Verbose(0) << (*key) << " ";
|
---|
1086 | else
|
---|
1087 | Log() << Verbose(0) << (*key) << "! ";
|
---|
1088 | comp = (*key);
|
---|
1089 | key++;
|
---|
1090 | }
|
---|
1091 | Log() << Verbose(0) << endl;
|
---|
1092 | A++;
|
---|
1093 | }
|
---|
1094 | delete(mol);
|
---|
1095 | };
|
---|
1096 |
|
---|
1097 | oldmenu::oldmenu()
|
---|
1098 | {
|
---|
1099 | // TODO Auto-generated constructor stub
|
---|
1100 | }
|
---|
1101 |
|
---|
1102 | oldmenu::~oldmenu()
|
---|
1103 | {
|
---|
1104 | // TODO Auto-generated destructor stub
|
---|
1105 | }
|
---|
1106 |
|
---|
1107 | void oldmenu::notImplementedYet() {
|
---|
1108 | Log() << Verbose(0) << "This method has not yet been moved to an appropriate class." << endl;
|
---|
1109 | }
|
---|
1110 |
|
---|
1111 | void oldmenu::perform(MoleculeListClass *molecules, config *configuration, periodentafel *periode, char *ConfigFileName)
|
---|
1112 | {
|
---|
1113 |
|
---|
1114 | // build the main menu
|
---|
1115 | TextMenu *main_menu = new TextMenu(Log() << Verbose(0), "Main Menu");
|
---|
1116 |
|
---|
1117 | StringView *moleculeView = new StreamStringView(boost::bind(&MoleculeListClass::Enumerate,molecules,_1));
|
---|
1118 | new DisplayMenuItem(main_menu,moleculeView,"Molecule List");
|
---|
1119 |
|
---|
1120 | new SeperatorItem(main_menu);
|
---|
1121 |
|
---|
1122 | Action *setMoleculeAction = new MethodAction(boost::bind(&MoleculeListClass::flipChosen,molecules));
|
---|
1123 | new ActionMenuItem('a',"set molecule (in)active",main_menu,setMoleculeAction);
|
---|
1124 |
|
---|
1125 | TextMenu *edit_molecules_menu = new TextMenu(Log() << Verbose(0), "Edit Molecules");
|
---|
1126 | new SubMenuItem('e',"edit molecules (load, parse, save)",main_menu,edit_molecules_menu);
|
---|
1127 |
|
---|
1128 | Action *manipulateMoleculeAction = new MethodAction(boost::bind(&oldmenu::ManipulateMolecules,this,periode, molecules, configuration));
|
---|
1129 | new ActionMenuItem('g',"globally manipulate atoms in molecule",main_menu,manipulateMoleculeAction);
|
---|
1130 |
|
---|
1131 | Action *mergeMoleculeAction = new MethodAction(boost::bind(&oldmenu::MergeMolecules,this,periode, molecules));
|
---|
1132 | new ActionMenuItem('M',"Merge molecules",main_menu,mergeMoleculeAction);
|
---|
1133 |
|
---|
1134 | Action *manipulateAtomsAction = new MethodAction(boost::bind(&oldmenu::ManipulateAtoms,this,periode, molecules, configuration));
|
---|
1135 | new ActionMenuItem('m',"manipulate atoms",main_menu,manipulateAtomsAction);
|
---|
1136 |
|
---|
1137 | new SeperatorItem(main_menu);
|
---|
1138 |
|
---|
1139 | Action *editConfigAction = new MethodAction(boost::bind(&config::Edit,configuration));
|
---|
1140 | new ActionMenuItem('c',"edit the current configuration",main_menu,editConfigAction);
|
---|
1141 |
|
---|
1142 | new SeperatorItem(main_menu);
|
---|
1143 |
|
---|
1144 | Action *saveConfigAction = new MethodAction(boost::bind(&oldmenu::SaveConfig,this,ConfigFileName, configuration, periode, molecules));
|
---|
1145 | new ActionMenuItem('s',"save current setup to config file",main_menu,saveConfigAction);
|
---|
1146 |
|
---|
1147 | Action *doTestAction = new MethodAction(boost::bind(&oldmenu::testroutine,this,molecules));
|
---|
1148 | new ActionMenuItem('T',"call the current test routine",main_menu,doTestAction);
|
---|
1149 |
|
---|
1150 | Action *quitAction = new MethodAction(boost::bind(&TextMenu::doQuit,main_menu));
|
---|
1151 | new ActionMenuItem('q',"quit",main_menu,quitAction);
|
---|
1152 |
|
---|
1153 |
|
---|
1154 |
|
---|
1155 | // build the EditMoleculesMenu
|
---|
1156 | Action *createMoleculeAction = new MethodAction(boost::bind(&MoleculeListClass::createNewMolecule,molecules,periode));
|
---|
1157 | new ActionMenuItem('c',"create new molecule",edit_molecules_menu,createMoleculeAction);
|
---|
1158 |
|
---|
1159 | Action *loadMoleculeAction = new MethodAction(boost::bind(&MoleculeListClass::loadFromXYZ,molecules,periode));
|
---|
1160 | new ActionMenuItem('l',"load molecule from xyz file",edit_molecules_menu,loadMoleculeAction);
|
---|
1161 |
|
---|
1162 | Action *changeFilenameAction = new MethodAction(boost::bind(&MoleculeListClass::changeName,molecules));
|
---|
1163 | new ActionMenuItem('n',"change molecule's name",edit_molecules_menu,changeFilenameAction);
|
---|
1164 |
|
---|
1165 | Action *giveFilenameAction = new MethodAction(boost::bind(&MoleculeListClass::setMoleculeFilename,molecules));
|
---|
1166 | new ActionMenuItem('N',"give molecules filename",edit_molecules_menu,giveFilenameAction);
|
---|
1167 |
|
---|
1168 | Action *parseAtomsAction = new MethodAction(boost::bind(&MoleculeListClass::parseXYZIntoMolecule,molecules));
|
---|
1169 | new ActionMenuItem('p',"parse atoms in xyz file into molecule",edit_molecules_menu,parseAtomsAction);
|
---|
1170 |
|
---|
1171 | Action *eraseMoleculeAction = new MethodAction(boost::bind(&MoleculeListClass::eraseMolecule,molecules));
|
---|
1172 | new ActionMenuItem('r',"remove a molecule",edit_molecules_menu,eraseMoleculeAction);
|
---|
1173 |
|
---|
1174 | Action *returnAction = new MethodAction(boost::bind(&TextMenu::doQuit,edit_molecules_menu));
|
---|
1175 | MenuItem *returnItem = new ActionMenuItem('q',"return to Main menu",edit_molecules_menu,returnAction);
|
---|
1176 |
|
---|
1177 | edit_molecules_menu->addDefault(returnItem);
|
---|
1178 |
|
---|
1179 | main_menu->display();
|
---|
1180 |
|
---|
1181 |
|
---|
1182 | delete main_menu;
|
---|
1183 |
|
---|
1184 | // delete all actions and views contained in Menu
|
---|
1185 | // TODO: find a better way to handle this
|
---|
1186 |
|
---|
1187 | delete moleculeView;
|
---|
1188 |
|
---|
1189 | delete setMoleculeAction;
|
---|
1190 | delete manipulateMoleculeAction;
|
---|
1191 | delete mergeMoleculeAction;
|
---|
1192 | delete manipulateAtomsAction;
|
---|
1193 | delete editConfigAction;
|
---|
1194 | delete saveConfigAction;
|
---|
1195 | delete doTestAction;
|
---|
1196 | delete quitAction;
|
---|
1197 |
|
---|
1198 | delete createMoleculeAction;
|
---|
1199 | delete loadMoleculeAction;
|
---|
1200 | delete changeFilenameAction;
|
---|
1201 | delete giveFilenameAction;
|
---|
1202 | delete parseAtomsAction;
|
---|
1203 | delete eraseMoleculeAction;
|
---|
1204 | delete returnAction;
|
---|
1205 | };
|
---|
1206 |
|
---|
1207 | /** Tries given filename or standard on saving the config file.
|
---|
1208 | * \param *ConfigFileName name of file
|
---|
1209 | * \param *configuration pointer to configuration structure with all the values
|
---|
1210 | * \param *periode pointer to periodentafel structure with all the elements
|
---|
1211 | * \param *molecules list of molecules structure with all the atoms and coordinates
|
---|
1212 | */
|
---|
1213 | void oldmenu::SaveConfig(char *ConfigFileName, config *configuration, periodentafel *periode, MoleculeListClass *molecules)
|
---|
1214 | {
|
---|
1215 | char filename[MAXSTRINGSIZE];
|
---|
1216 | ofstream output;
|
---|
1217 | molecule *mol = new molecule(periode);
|
---|
1218 |
|
---|
1219 | if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
|
---|
1220 | eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
|
---|
1221 | }
|
---|
1222 |
|
---|
1223 |
|
---|
1224 | // first save as PDB data
|
---|
1225 | if (ConfigFileName != NULL)
|
---|
1226 | strcpy(filename, ConfigFileName);
|
---|
1227 | else
|
---|
1228 | strcpy(filename,"main_pcp_linux");
|
---|
1229 | Log() << Verbose(0) << "Saving as pdb input ";
|
---|
1230 | if (configuration->SavePDB(filename, molecules))
|
---|
1231 | Log() << Verbose(0) << "done." << endl;
|
---|
1232 | else
|
---|
1233 | Log() << Verbose(0) << "failed." << endl;
|
---|
1234 |
|
---|
1235 | // then save as tremolo data file
|
---|
1236 | if (ConfigFileName != NULL)
|
---|
1237 | strcpy(filename, ConfigFileName);
|
---|
1238 | else
|
---|
1239 | strcpy(filename,"main_pcp_linux");
|
---|
1240 | Log() << Verbose(0) << "Saving as tremolo data input ";
|
---|
1241 | if (configuration->SaveTREMOLO(filename, molecules))
|
---|
1242 | Log() << Verbose(0) << "done." << endl;
|
---|
1243 | else
|
---|
1244 | Log() << Verbose(0) << "failed." << endl;
|
---|
1245 |
|
---|
1246 | // translate each to its center and merge all molecules in MoleculeListClass into this molecule
|
---|
1247 | int N = molecules->ListOfMolecules.size();
|
---|
1248 | int *src = new int[N];
|
---|
1249 | N=0;
|
---|
1250 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
|
---|
1251 | src[N++] = (*ListRunner)->IndexNr;
|
---|
1252 | (*ListRunner)->Translate(&(*ListRunner)->Center);
|
---|
1253 | }
|
---|
1254 | molecules->SimpleMultiAdd(mol, src, N);
|
---|
1255 | delete[](src);
|
---|
1256 |
|
---|
1257 | // ... and translate back
|
---|
1258 | for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
|
---|
1259 | (*ListRunner)->Center.Scale(-1.);
|
---|
1260 | (*ListRunner)->Translate(&(*ListRunner)->Center);
|
---|
1261 | (*ListRunner)->Center.Scale(-1.);
|
---|
1262 | }
|
---|
1263 |
|
---|
1264 | Log() << Verbose(0) << "Storing configuration ... " << endl;
|
---|
1265 | // get correct valence orbitals
|
---|
1266 | mol->CalculateOrbitals(*configuration);
|
---|
1267 | configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble;
|
---|
1268 | if (ConfigFileName != NULL) { // test the file name
|
---|
1269 | strcpy(filename, ConfigFileName);
|
---|
1270 | output.open(filename, ios::trunc);
|
---|
1271 | } else if (strlen(configuration->configname) != 0) {
|
---|
1272 | strcpy(filename, configuration->configname);
|
---|
1273 | output.open(configuration->configname, ios::trunc);
|
---|
1274 | } else {
|
---|
1275 | strcpy(filename, DEFAULTCONFIG);
|
---|
1276 | output.open(DEFAULTCONFIG, ios::trunc);
|
---|
1277 | }
|
---|
1278 | output.close();
|
---|
1279 | output.clear();
|
---|
1280 | Log() << Verbose(0) << "Saving of config file ";
|
---|
1281 | if (configuration->Save(filename, periode, mol))
|
---|
1282 | Log() << Verbose(0) << "successful." << endl;
|
---|
1283 | else
|
---|
1284 | Log() << Verbose(0) << "failed." << endl;
|
---|
1285 |
|
---|
1286 | // and save to xyz file
|
---|
1287 | if (ConfigFileName != NULL) {
|
---|
1288 | strcpy(filename, ConfigFileName);
|
---|
1289 | strcat(filename, ".xyz");
|
---|
1290 | output.open(filename, ios::trunc);
|
---|
1291 | }
|
---|
1292 | else {
|
---|
1293 | strcpy(filename,"main_pcp_linux");
|
---|
1294 | strcat(filename, ".xyz");
|
---|
1295 | output.open(filename, ios::trunc);
|
---|
1296 | }
|
---|
1297 | Log() << Verbose(0) << "Saving of XYZ file ";
|
---|
1298 | if (mol->MDSteps <= 1) {
|
---|
1299 | if (mol->OutputXYZ(&output))
|
---|
1300 | Log() << Verbose(0) << "successful." << endl;
|
---|
1301 | else
|
---|
1302 | Log() << Verbose(0) << "failed." << endl;
|
---|
1303 | } else {
|
---|
1304 | if (mol->OutputTrajectoriesXYZ(&output))
|
---|
1305 | Log() << Verbose(0) << "successful." << endl;
|
---|
1306 | else
|
---|
1307 | Log() << Verbose(0) << "failed." << endl;
|
---|
1308 | }
|
---|
1309 | output.close();
|
---|
1310 | output.clear();
|
---|
1311 |
|
---|
1312 | // and save as MPQC configuration
|
---|
1313 | if (ConfigFileName != NULL)
|
---|
1314 | strcpy(filename, ConfigFileName);
|
---|
1315 | else
|
---|
1316 | strcpy(filename,"main_pcp_linux");
|
---|
1317 | Log() << Verbose(0) << "Saving as mpqc input ";
|
---|
1318 | if (configuration->SaveMPQC(filename, mol))
|
---|
1319 | Log() << Verbose(0) << "done." << endl;
|
---|
1320 | else
|
---|
1321 | Log() << Verbose(0) << "failed." << endl;
|
---|
1322 |
|
---|
1323 | if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
|
---|
1324 | eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
|
---|
1325 | }
|
---|
1326 |
|
---|
1327 | delete(mol);
|
---|
1328 | };
|
---|