source: src/builder.cpp@ c30180

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since c30180 was c30180, checked in by metzler <metzler@…>, 15 years ago

#19 Observe memory usage

  • Property mode set to 100644
File size: 89.1 KB
Line 
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
50using namespace std;
51
52#include "boundary.hpp"
53#include "ellipsoid.hpp"
54#include "helpers.hpp"
55#include "memoryusageobserverunittest.hpp"
56#include "molecules.hpp"
57/********************************************* Subsubmenu routine ************************************/
58
59/** Submenu for adding atoms to the molecule.
60 * \param *periode periodentafel
61 * \param *molecule molecules with atoms
62 */
63static void AddAtoms(periodentafel *periode, molecule *mol)
64{
65 atom *first, *second, *third, *fourth;
66 Vector **atoms;
67 Vector x,y,z,n; // coordinates for absolute point in cell volume
68 double a,b,c;
69 char choice; // menu choice char
70 bool valid;
71
72 cout << Verbose(0) << "===========ADD ATOM============================" << endl;
73 cout << Verbose(0) << " a - state absolute coordinates of atom" << endl;
74 cout << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;
75 cout << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;
76 cout << Verbose(0) << " d - state two atoms, two angles and a distance" << endl;
77 cout << Verbose(0) << " e - least square distance position to a set of atoms" << endl;
78 cout << Verbose(0) << "all else - go back" << endl;
79 cout << Verbose(0) << "===============================================" << endl;
80 cout << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;
81 cout << Verbose(0) << "INPUT: ";
82 cin >> choice;
83
84 switch (choice) {
85 default:
86 cout << Verbose(0) << "Not a valid choice." << endl;
87 break;
88 case 'a': // absolute coordinates of atom
89 cout << Verbose(0) << "Enter absolute coordinates." << endl;
90 first = new atom;
91 first->x.AskPosition(mol->cell_size, false);
92 first->type = periode->AskElement(); // give type
93 mol->AddAtom(first); // add to molecule
94 break;
95
96 case 'b': // relative coordinates of atom wrt to reference point
97 first = new atom;
98 valid = true;
99 do {
100 if (!valid) cout << Verbose(0) << "Resulting position out of cell." << endl;
101 cout << Verbose(0) << "Enter reference coordinates." << endl;
102 x.AskPosition(mol->cell_size, true);
103 cout << Verbose(0) << "Enter relative coordinates." << endl;
104 first->x.AskPosition(mol->cell_size, false);
105 first->x.AddVector((const Vector *)&x);
106 cout << Verbose(0) << "\n";
107 } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
108 first->type = periode->AskElement(); // give type
109 mol->AddAtom(first); // add to molecule
110 break;
111
112 case 'c': // relative coordinates of atom wrt to already placed atom
113 first = new atom;
114 valid = true;
115 do {
116 if (!valid) cout << Verbose(0) << "Resulting position out of cell." << endl;
117 second = mol->AskAtom("Enter atom number: ");
118 cout << Verbose(0) << "Enter relative coordinates." << endl;
119 first->x.AskPosition(mol->cell_size, false);
120 for (int i=NDIM;i--;) {
121 first->x.x[i] += second->x.x[i];
122 }
123 } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
124 first->type = periode->AskElement(); // give type
125 mol->AddAtom(first); // add to molecule
126 break;
127
128 case 'd': // two atoms, two angles and a distance
129 first = new atom;
130 valid = true;
131 do {
132 if (!valid) {
133 cout << Verbose(0) << "Resulting coordinates out of cell - ";
134 first->x.Output((ofstream *)&cout);
135 cout << Verbose(0) << endl;
136 }
137 cout << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;
138 second = mol->AskAtom("Enter central atom: ");
139 third = mol->AskAtom("Enter second atom (specifying the axis for first angle): ");
140 fourth = mol->AskAtom("Enter third atom (specifying a plane for second angle): ");
141 a = ask_value("Enter distance between central (first) and new atom: ");
142 b = ask_value("Enter angle between new, first and second atom (degrees): ");
143 b *= M_PI/180.;
144 bound(&b, 0., 2.*M_PI);
145 c = ask_value("Enter second angle between new and normal vector of plane defined by first, second and third atom (degrees): ");
146 c *= M_PI/180.;
147 bound(&c, -M_PI, M_PI);
148 cout << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl;
149/*
150 second->Output(1,1,(ofstream *)&cout);
151 third->Output(1,2,(ofstream *)&cout);
152 fourth->Output(1,3,(ofstream *)&cout);
153 n.MakeNormalvector((const vector *)&second->x, (const vector *)&third->x, (const vector *)&fourth->x);
154 x.Copyvector(&second->x);
155 x.SubtractVector(&third->x);
156 x.Copyvector(&fourth->x);
157 x.SubtractVector(&third->x);
158
159 if (!z.SolveSystem(&x,&y,&n, b, c, a)) {
160 cout << Verbose(0) << "Failure solving self-dependent linear system!" << endl;
161 continue;
162 }
163 cout << Verbose(0) << "resulting relative coordinates: ";
164 z.Output((ofstream *)&cout);
165 cout << Verbose(0) << endl;
166 */
167 // calc axis vector
168 x.CopyVector(&second->x);
169 x.SubtractVector(&third->x);
170 x.Normalize();
171 cout << "x: ",
172 x.Output((ofstream *)&cout);
173 cout << endl;
174 z.MakeNormalVector(&second->x,&third->x,&fourth->x);
175 cout << "z: ",
176 z.Output((ofstream *)&cout);
177 cout << endl;
178 y.MakeNormalVector(&x,&z);
179 cout << "y: ",
180 y.Output((ofstream *)&cout);
181 cout << endl;
182
183 // rotate vector around first angle
184 first->x.CopyVector(&x);
185 first->x.RotateVector(&z,b - M_PI);
186 cout << "Rotated vector: ",
187 first->x.Output((ofstream *)&cout);
188 cout << endl;
189 // remove the projection onto the rotation plane of the second angle
190 n.CopyVector(&y);
191 n.Scale(first->x.ScalarProduct(&y));
192 cout << "N1: ",
193 n.Output((ofstream *)&cout);
194 cout << endl;
195 first->x.SubtractVector(&n);
196 cout << "Subtracted vector: ",
197 first->x.Output((ofstream *)&cout);
198 cout << endl;
199 n.CopyVector(&z);
200 n.Scale(first->x.ScalarProduct(&z));
201 cout << "N2: ",
202 n.Output((ofstream *)&cout);
203 cout << endl;
204 first->x.SubtractVector(&n);
205 cout << "2nd subtracted vector: ",
206 first->x.Output((ofstream *)&cout);
207 cout << endl;
208
209 // rotate another vector around second angle
210 n.CopyVector(&y);
211 n.RotateVector(&x,c - M_PI);
212 cout << "2nd Rotated vector: ",
213 n.Output((ofstream *)&cout);
214 cout << endl;
215
216 // add the two linear independent vectors
217 first->x.AddVector(&n);
218 first->x.Normalize();
219 first->x.Scale(a);
220 first->x.AddVector(&second->x);
221
222 cout << Verbose(0) << "resulting coordinates: ";
223 first->x.Output((ofstream *)&cout);
224 cout << Verbose(0) << endl;
225 } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
226 first->type = periode->AskElement(); // give type
227 mol->AddAtom(first); // add to molecule
228 break;
229
230 case 'e': // least square distance position to a set of atoms
231 first = new atom;
232 atoms = new (Vector*[128]);
233 valid = true;
234 for(int i=128;i--;)
235 atoms[i] = NULL;
236 int i=0, j=0;
237 cout << Verbose(0) << "Now we need at least three molecules.\n";
238 do {
239 cout << Verbose(0) << "Enter " << i+1 << "th atom: ";
240 cin >> j;
241 if (j != -1) {
242 second = mol->FindAtom(j);
243 atoms[i++] = &(second->x);
244 }
245 } while ((j != -1) && (i<128));
246 if (i >= 2) {
247 first->x.LSQdistance(atoms, i);
248
249 first->x.Output((ofstream *)&cout);
250 first->type = periode->AskElement(); // give type
251 mol->AddAtom(first); // add to molecule
252 } else {
253 delete first;
254 cout << Verbose(0) << "Please enter at least two vectors!\n";
255 }
256 break;
257 };
258};
259
260/** Submenu for centering the atoms in the molecule.
261 * \param *mol molecule with all the atoms
262 */
263static void CenterAtoms(molecule *mol)
264{
265 Vector x, y, helper;
266 char choice; // menu choice char
267
268 cout << Verbose(0) << "===========CENTER ATOMS=========================" << endl;
269 cout << Verbose(0) << " a - on origin" << endl;
270 cout << Verbose(0) << " b - on center of gravity" << endl;
271 cout << Verbose(0) << " c - within box with additional boundary" << endl;
272 cout << Verbose(0) << " d - within given simulation box" << endl;
273 cout << Verbose(0) << "all else - go back" << endl;
274 cout << Verbose(0) << "===============================================" << endl;
275 cout << Verbose(0) << "INPUT: ";
276 cin >> choice;
277
278 switch (choice) {
279 default:
280 cout << Verbose(0) << "Not a valid choice." << endl;
281 break;
282 case 'a':
283 cout << Verbose(0) << "Centering atoms in config file on origin." << endl;
284 mol->CenterOrigin((ofstream *)&cout);
285 break;
286 case 'b':
287 cout << Verbose(0) << "Centering atoms in config file on center of gravity." << endl;
288 mol->CenterPeriodic((ofstream *)&cout);
289 break;
290 case 'c':
291 cout << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;
292 for (int i=0;i<NDIM;i++) {
293 cout << Verbose(0) << "Enter axis " << i << " boundary: ";
294 cin >> y.x[i];
295 }
296 mol->CenterEdge((ofstream *)&cout, &x); // make every coordinate positive
297 mol->Center.AddVector(&y); // translate by boundary
298 helper.CopyVector(&y);
299 helper.Scale(2.);
300 helper.AddVector(&x);
301 mol->SetBoxDimension(&helper); // update Box of atoms by boundary
302 break;
303 case 'd':
304 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
305 for (int i=0;i<NDIM;i++) {
306 cout << Verbose(0) << "Enter axis " << i << " boundary: ";
307 cin >> x.x[i];
308 }
309 // update Box of atoms by boundary
310 mol->SetBoxDimension(&x);
311 // center
312 mol->CenterInBox((ofstream *)&cout);
313 break;
314 }
315};
316
317/** Submenu for aligning the atoms in the molecule.
318 * \param *periode periodentafel
319 * \param *mol molecule with all the atoms
320 */
321static void AlignAtoms(periodentafel *periode, molecule *mol)
322{
323 atom *first, *second, *third;
324 Vector x,n;
325 char choice; // menu choice char
326
327 cout << Verbose(0) << "===========ALIGN ATOMS=========================" << endl;
328 cout << Verbose(0) << " a - state three atoms defining align plane" << endl;
329 cout << Verbose(0) << " b - state alignment vector" << endl;
330 cout << Verbose(0) << " c - state two atoms in alignment direction" << endl;
331 cout << Verbose(0) << " d - align automatically by least square fit" << endl;
332 cout << Verbose(0) << "all else - go back" << endl;
333 cout << Verbose(0) << "===============================================" << endl;
334 cout << Verbose(0) << "INPUT: ";
335 cin >> choice;
336
337 switch (choice) {
338 default:
339 case 'a': // three atoms defining mirror plane
340 first = mol->AskAtom("Enter first atom: ");
341 second = mol->AskAtom("Enter second atom: ");
342 third = mol->AskAtom("Enter third atom: ");
343
344 n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
345 break;
346 case 'b': // normal vector of mirror plane
347 cout << Verbose(0) << "Enter normal vector of mirror plane." << endl;
348 n.AskPosition(mol->cell_size,0);
349 n.Normalize();
350 break;
351 case 'c': // three atoms defining mirror plane
352 first = mol->AskAtom("Enter first atom: ");
353 second = mol->AskAtom("Enter second atom: ");
354
355 n.CopyVector((const Vector *)&first->x);
356 n.SubtractVector((const Vector *)&second->x);
357 n.Normalize();
358 break;
359 case 'd':
360 char shorthand[4];
361 Vector a;
362 struct lsq_params param;
363 do {
364 fprintf(stdout, "Enter the element of atoms to be chosen: ");
365 fscanf(stdin, "%3s", shorthand);
366 } while ((param.type = periode->FindElement(shorthand)) == NULL);
367 cout << Verbose(0) << "Element is " << param.type->name << endl;
368 mol->GetAlignvector(&param);
369 for (int i=NDIM;i--;) {
370 x.x[i] = gsl_vector_get(param.x,i);
371 n.x[i] = gsl_vector_get(param.x,i+NDIM);
372 }
373 gsl_vector_free(param.x);
374 cout << Verbose(0) << "Offset vector: ";
375 x.Output((ofstream *)&cout);
376 cout << Verbose(0) << endl;
377 n.Normalize();
378 break;
379 };
380 cout << Verbose(0) << "Alignment vector: ";
381 n.Output((ofstream *)&cout);
382 cout << Verbose(0) << endl;
383 mol->Align(&n);
384};
385
386/** Submenu for mirroring the atoms in the molecule.
387 * \param *mol molecule with all the atoms
388 */
389static void MirrorAtoms(molecule *mol)
390{
391 atom *first, *second, *third;
392 Vector n;
393 char choice; // menu choice char
394
395 cout << Verbose(0) << "===========MIRROR ATOMS=========================" << endl;
396 cout << Verbose(0) << " a - state three atoms defining mirror plane" << endl;
397 cout << Verbose(0) << " b - state normal vector of mirror plane" << endl;
398 cout << Verbose(0) << " c - state two atoms in normal direction" << endl;
399 cout << Verbose(0) << "all else - go back" << endl;
400 cout << Verbose(0) << "===============================================" << endl;
401 cout << Verbose(0) << "INPUT: ";
402 cin >> choice;
403
404 switch (choice) {
405 default:
406 case 'a': // three atoms defining mirror plane
407 first = mol->AskAtom("Enter first atom: ");
408 second = mol->AskAtom("Enter second atom: ");
409 third = mol->AskAtom("Enter third atom: ");
410
411 n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
412 break;
413 case 'b': // normal vector of mirror plane
414 cout << Verbose(0) << "Enter normal vector of mirror plane." << endl;
415 n.AskPosition(mol->cell_size,0);
416 n.Normalize();
417 break;
418 case 'c': // three atoms defining mirror plane
419 first = mol->AskAtom("Enter first atom: ");
420 second = mol->AskAtom("Enter second atom: ");
421
422 n.CopyVector((const Vector *)&first->x);
423 n.SubtractVector((const Vector *)&second->x);
424 n.Normalize();
425 break;
426 };
427 cout << Verbose(0) << "Normal vector: ";
428 n.Output((ofstream *)&cout);
429 cout << Verbose(0) << endl;
430 mol->Mirror((const Vector *)&n);
431};
432
433/** Submenu for removing the atoms from the molecule.
434 * \param *mol molecule with all the atoms
435 */
436static void RemoveAtoms(molecule *mol)
437{
438 atom *first, *second;
439 int axis;
440 double tmp1, tmp2;
441 char choice; // menu choice char
442
443 cout << Verbose(0) << "===========REMOVE ATOMS=========================" << endl;
444 cout << Verbose(0) << " a - state atom for removal by number" << endl;
445 cout << Verbose(0) << " b - keep only in radius around atom" << endl;
446 cout << Verbose(0) << " c - remove this with one axis greater value" << endl;
447 cout << Verbose(0) << "all else - go back" << endl;
448 cout << Verbose(0) << "===============================================" << endl;
449 cout << Verbose(0) << "INPUT: ";
450 cin >> choice;
451
452 switch (choice) {
453 default:
454 case 'a':
455 if (mol->RemoveAtom(mol->AskAtom("Enter number of atom within molecule: ")))
456 cout << Verbose(1) << "Atom removed." << endl;
457 else
458 cout << Verbose(1) << "Atom not found." << endl;
459 break;
460 case 'b':
461 second = mol->AskAtom("Enter number of atom as reference point: ");
462 cout << Verbose(0) << "Enter radius: ";
463 cin >> tmp1;
464 first = mol->start;
465 second = first->next;
466 while(second != mol->end) {
467 first = second;
468 second = first->next;
469 if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...
470 mol->RemoveAtom(first);
471 }
472 break;
473 case 'c':
474 cout << Verbose(0) << "Which axis is it: ";
475 cin >> axis;
476 cout << Verbose(0) << "Lower boundary: ";
477 cin >> tmp1;
478 cout << Verbose(0) << "Upper boundary: ";
479 cin >> tmp2;
480 first = mol->start;
481 second = first->next;
482 while(second != mol->end) {
483 first = second;
484 second = first->next;
485 if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
486 //cout << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
487 mol->RemoveAtom(first);
488 }
489 }
490 break;
491 };
492 //mol->Output((ofstream *)&cout);
493 choice = 'r';
494};
495
496/** Submenu for measuring out the atoms in the molecule.
497 * \param *periode periodentafel
498 * \param *mol molecule with all the atoms
499 */
500static void MeasureAtoms(periodentafel *periode, molecule *mol, config *configuration)
501{
502 atom *first, *second, *third;
503 Vector x,y;
504 double min[256], tmp1, tmp2, tmp3;
505 int Z;
506 char choice; // menu choice char
507
508 cout << Verbose(0) << "===========MEASURE ATOMS=========================" << endl;
509 cout << Verbose(0) << " a - calculate bond length between one atom and all others" << endl;
510 cout << Verbose(0) << " b - calculate bond length between two atoms" << endl;
511 cout << Verbose(0) << " c - calculate bond angle" << endl;
512 cout << Verbose(0) << " d - calculate principal axis of the system" << endl;
513 cout << Verbose(0) << " e - calculate volume of the convex envelope" << endl;
514 cout << Verbose(0) << " f - calculate temperature from current velocity" << endl;
515 cout << Verbose(0) << " g - output all temperatures per step from velocities" << endl;
516 cout << Verbose(0) << "all else - go back" << endl;
517 cout << Verbose(0) << "===============================================" << endl;
518 cout << Verbose(0) << "INPUT: ";
519 cin >> choice;
520
521 switch(choice) {
522 default:
523 cout << Verbose(1) << "Not a valid choice." << endl;
524 break;
525 case 'a':
526 first = mol->AskAtom("Enter first atom: ");
527 for (int i=MAX_ELEMENTS;i--;)
528 min[i] = 0.;
529
530 second = mol->start;
531 while ((second->next != mol->end)) {
532 second = second->next; // advance
533 Z = second->type->Z;
534 tmp1 = 0.;
535 if (first != second) {
536 x.CopyVector((const Vector *)&first->x);
537 x.SubtractVector((const Vector *)&second->x);
538 tmp1 = x.Norm();
539 }
540 if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
541 //cout << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;
542 }
543 for (int i=MAX_ELEMENTS;i--;)
544 if (min[i] != 0.) cout << 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;
545 break;
546
547 case 'b':
548 first = mol->AskAtom("Enter first atom: ");
549 second = mol->AskAtom("Enter second atom: ");
550 for (int i=NDIM;i--;)
551 min[i] = 0.;
552 x.CopyVector((const Vector *)&first->x);
553 x.SubtractVector((const Vector *)&second->x);
554 tmp1 = x.Norm();
555 cout << Verbose(1) << "Distance vector is ";
556 x.Output((ofstream *)&cout);
557 cout << "." << endl << "Norm of distance is " << tmp1 << "." << endl;
558 break;
559
560 case 'c':
561 cout << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl;
562 first = mol->AskAtom("Enter first atom: ");
563 second = mol->AskAtom("Enter central atom: ");
564 third = mol->AskAtom("Enter last atom: ");
565 tmp1 = tmp2 = tmp3 = 0.;
566 x.CopyVector((const Vector *)&first->x);
567 x.SubtractVector((const Vector *)&second->x);
568 y.CopyVector((const Vector *)&third->x);
569 y.SubtractVector((const Vector *)&second->x);
570 cout << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
571 cout << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
572 break;
573 case 'd':
574 cout << Verbose(0) << "Evaluating prinicipal axis." << endl;
575 cout << Verbose(0) << "Shall we rotate? [0/1]: ";
576 cin >> Z;
577 if ((Z >=0) && (Z <=1))
578 mol->PrincipalAxisSystem((ofstream *)&cout, (bool)Z);
579 else
580 mol->PrincipalAxisSystem((ofstream *)&cout, false);
581 break;
582 case 'e':
583 {
584 cout << Verbose(0) << "Evaluating volume of the convex envelope.";
585 LinkedCell LCList(mol, 10.);
586 class Tesselation *TesselStruct = NULL;
587 FindConvexBorder((ofstream *)&cout, mol, &LCList, NULL);
588 double clustervolume = VolumeOfConvexEnvelope((ofstream *)&cout, TesselStruct, configuration);
589 cout << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl;
590 delete(TesselStruct);
591 }
592 break;
593 case 'f':
594 mol->OutputTemperatureFromTrajectories((ofstream *)&cout, mol->MDSteps-1, mol->MDSteps, (ofstream *)&cout);
595 break;
596 case 'g':
597 {
598 char filename[255];
599 cout << "Please enter filename: " << endl;
600 cin >> filename;
601 cout << Verbose(1) << "Storing temperatures in " << filename << "." << endl;
602 ofstream *output = new ofstream(filename, ios::trunc);
603 if (!mol->OutputTemperatureFromTrajectories((ofstream *)&cout, 0, mol->MDSteps, output))
604 cout << Verbose(2) << "File could not be written." << endl;
605 else
606 cout << Verbose(2) << "File stored." << endl;
607 output->close();
608 delete(output);
609 }
610 break;
611 }
612};
613
614/** Submenu for measuring out the atoms in the molecule.
615 * \param *mol molecule with all the atoms
616 * \param *configuration configuration structure for the to be written config files of all fragments
617 */
618static void FragmentAtoms(molecule *mol, config *configuration)
619{
620 int Order1;
621 clock_t start, end;
622
623 cout << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
624 cout << Verbose(0) << "What's the desired bond order: ";
625 cin >> Order1;
626 if (mol->first->next != mol->last) { // there are bonds
627 start = clock();
628 mol->FragmentMolecule((ofstream *)&cout, Order1, configuration);
629 end = clock();
630 cout << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
631 } else
632 cout << Verbose(0) << "Connection matrix has not yet been generated!" << endl;
633};
634
635/********************************************** Submenu routine **************************************/
636
637/** Submenu for manipulating atoms.
638 * \param *periode periodentafel
639 * \param *molecules list of molecules whose atoms are to be manipulated
640 */
641static void ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
642{
643 atom *first, *second;
644 molecule *mol = NULL;
645 Vector x,y,z,n; // coordinates for absolute point in cell volume
646 double *factor; // unit factor if desired
647 double bond, minBond;
648 char choice; // menu choice char
649 bool valid;
650
651 cout << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl;
652 cout << Verbose(0) << "a - add an atom" << endl;
653 cout << Verbose(0) << "r - remove an atom" << endl;
654 cout << Verbose(0) << "b - scale a bond between atoms" << endl;
655 cout << Verbose(0) << "u - change an atoms element" << endl;
656 cout << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl;
657 cout << Verbose(0) << "all else - go back" << endl;
658 cout << Verbose(0) << "===============================================" << endl;
659 if (molecules->NumberOfActiveMolecules() > 1)
660 cout << Verbose(0) << "WARNING: There is more than one molecule active! Atoms will be added to each." << endl;
661 cout << Verbose(0) << "INPUT: ";
662 cin >> choice;
663
664 switch (choice) {
665 default:
666 cout << Verbose(0) << "Not a valid choice." << endl;
667 break;
668
669 case 'a': // add atom
670 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
671 if ((*ListRunner)->ActiveFlag) {
672 mol = *ListRunner;
673 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
674 AddAtoms(periode, mol);
675 }
676 break;
677
678 case 'b': // scale a bond
679 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
680 if ((*ListRunner)->ActiveFlag) {
681 mol = *ListRunner;
682 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
683 cout << Verbose(0) << "Scaling bond length between two atoms." << endl;
684 first = mol->AskAtom("Enter first (fixed) atom: ");
685 second = mol->AskAtom("Enter second (shifting) atom: ");
686 minBond = 0.;
687 for (int i=NDIM;i--;)
688 minBond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]);
689 minBond = sqrt(minBond);
690 cout << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;
691 cout << Verbose(0) << "Enter new bond length [a.u.]: ";
692 cin >> bond;
693 for (int i=NDIM;i--;) {
694 second->x.x[i] -= (second->x.x[i]-first->x.x[i])/minBond*(minBond-bond);
695 }
696 //cout << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";
697 //second->Output(second->type->No, 1, (ofstream *)&cout);
698 }
699 break;
700
701 case 'c': // unit scaling of the metric
702 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
703 if ((*ListRunner)->ActiveFlag) {
704 mol = *ListRunner;
705 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
706 cout << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl;
707 cout << Verbose(0) << "Enter three factors: ";
708 factor = new double[NDIM];
709 cin >> factor[0];
710 cin >> factor[1];
711 cin >> factor[2];
712 valid = true;
713 mol->Scale(&factor);
714 delete[](factor);
715 }
716 break;
717
718 case 'l': // measure distances or angles
719 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
720 if ((*ListRunner)->ActiveFlag) {
721 mol = *ListRunner;
722 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
723 MeasureAtoms(periode, mol, configuration);
724 }
725 break;
726
727 case 'r': // remove atom
728 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
729 if ((*ListRunner)->ActiveFlag) {
730 mol = *ListRunner;
731 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
732 RemoveAtoms(mol);
733 }
734 break;
735
736 case 'u': // change an atom's element
737 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
738 if ((*ListRunner)->ActiveFlag) {
739 int Z;
740 mol = *ListRunner;
741 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
742 first = NULL;
743 do {
744 cout << Verbose(0) << "Change the element of which atom: ";
745 cin >> Z;
746 } while ((first = mol->FindAtom(Z)) == NULL);
747 cout << Verbose(0) << "New element by atomic number Z: ";
748 cin >> Z;
749 first->type = periode->FindElement(Z);
750 cout << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl;
751 }
752 break;
753 }
754};
755
756/** Submenu for manipulating molecules.
757 * \param *periode periodentafel
758 * \param *molecules list of molecule to manipulate
759 */
760static void ManipulateMolecules(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
761{
762 atom *first = NULL;
763 Vector x,y,z,n; // coordinates for absolute point in cell volume
764 int j, axis, count, faktor;
765 char choice; // menu choice char
766 molecule *mol = NULL;
767 element **Elements;
768 Vector **vectors;
769 MoleculeLeafClass *Subgraphs = NULL;
770
771 cout << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl;
772 cout << Verbose(0) << "c - scale by unit transformation" << endl;
773 cout << Verbose(0) << "d - duplicate molecule/periodic cell" << endl;
774 cout << Verbose(0) << "f - fragment molecule many-body bond order style" << endl;
775 cout << Verbose(0) << "g - center atoms in box" << endl;
776 cout << Verbose(0) << "i - realign molecule" << endl;
777 cout << Verbose(0) << "m - mirror all molecules" << endl;
778 cout << Verbose(0) << "o - create connection matrix" << endl;
779 cout << Verbose(0) << "t - translate molecule by vector" << endl;
780 cout << Verbose(0) << "all else - go back" << endl;
781 cout << Verbose(0) << "===============================================" << endl;
782 if (molecules->NumberOfActiveMolecules() > 1)
783 cout << Verbose(0) << "WARNING: There is more than one molecule active! Atoms will be added to each." << endl;
784 cout << Verbose(0) << "INPUT: ";
785 cin >> choice;
786
787 switch (choice) {
788 default:
789 cout << Verbose(0) << "Not a valid choice." << endl;
790 break;
791
792 case 'd': // duplicate the periodic cell along a given axis, given times
793 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
794 if ((*ListRunner)->ActiveFlag) {
795 mol = *ListRunner;
796 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
797 cout << Verbose(0) << "State the axis [(+-)123]: ";
798 cin >> axis;
799 cout << Verbose(0) << "State the factor: ";
800 cin >> faktor;
801
802 mol->CountAtoms((ofstream *)&cout); // recount atoms
803 if (mol->AtomCount != 0) { // if there is more than none
804 count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand
805 Elements = new element *[count];
806 vectors = new Vector *[count];
807 j = 0;
808 first = mol->start;
809 while (first->next != mol->end) { // make a list of all atoms with coordinates and element
810 first = first->next;
811 Elements[j] = first->type;
812 vectors[j] = &first->x;
813 j++;
814 }
815 if (count != j)
816 cout << Verbose(0) << "ERROR: AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
817 x.Zero();
818 y.Zero();
819 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
820 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times
821 x.AddVector(&y); // per factor one cell width further
822 for (int k=count;k--;) { // go through every atom of the original cell
823 first = new atom(); // create a new body
824 first->x.CopyVector(vectors[k]); // use coordinate of original atom
825 first->x.AddVector(&x); // translate the coordinates
826 first->type = Elements[k]; // insert original element
827 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
828 }
829 }
830 if (mol->first->next != mol->last) // if connect matrix is present already, redo it
831 mol->CreateAdjacencyList((ofstream *)&cout, mol->BondDistance, configuration->GetIsAngstroem());
832 // free memory
833 delete[](Elements);
834 delete[](vectors);
835 // correct cell size
836 if (axis < 0) { // if sign was negative, we have to translate everything
837 x.Zero();
838 x.AddVector(&y);
839 x.Scale(-(faktor-1));
840 mol->Translate(&x);
841 }
842 mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
843 }
844 }
845 break;
846
847 case 'f':
848 FragmentAtoms(mol, configuration);
849 break;
850
851 case 'g': // center the atoms
852 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
853 if ((*ListRunner)->ActiveFlag) {
854 mol = *ListRunner;
855 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
856 CenterAtoms(mol);
857 }
858 break;
859
860 case 'i': // align all atoms
861 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
862 if ((*ListRunner)->ActiveFlag) {
863 mol = *ListRunner;
864 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
865 AlignAtoms(periode, mol);
866 }
867 break;
868
869 case 'm': // mirror atoms along a given axis
870 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
871 if ((*ListRunner)->ActiveFlag) {
872 mol = *ListRunner;
873 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
874 MirrorAtoms(mol);
875 }
876 break;
877
878 case 'o': // create the connection matrix
879 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
880 if ((*ListRunner)->ActiveFlag) {
881 mol = *ListRunner;
882 double bonddistance;
883 clock_t start,end;
884 cout << Verbose(0) << "What's the maximum bond distance: ";
885 cin >> bonddistance;
886 start = clock();
887 mol->CreateAdjacencyList((ofstream *)&cout, bonddistance, configuration->GetIsAngstroem());
888 mol->CreateListOfBondsPerAtom((ofstream *)&cout);
889 end = clock();
890 cout << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
891 }
892 break;
893
894 case 't': // translate all atoms
895 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
896 if ((*ListRunner)->ActiveFlag) {
897 mol = *ListRunner;
898 cout << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
899 cout << Verbose(0) << "Enter translation vector." << endl;
900 x.AskPosition(mol->cell_size,0);
901 mol->Center.AddVector((const Vector *)&x);
902 }
903 break;
904 }
905 // Free all
906 if (Subgraphs != NULL) { // free disconnected subgraph list of DFS analysis was performed
907 while (Subgraphs->next != NULL) {
908 Subgraphs = Subgraphs->next;
909 delete(Subgraphs->previous);
910 }
911 delete(Subgraphs);
912 }
913};
914
915
916/** Submenu for creating new molecules.
917 * \param *periode periodentafel
918 * \param *molecules list of molecules to add to
919 */
920static void EditMolecules(periodentafel *periode, MoleculeListClass *molecules)
921{
922 char choice; // menu choice char
923 Vector center;
924 int nr, count;
925 molecule *mol = NULL;
926
927 cout << Verbose(0) << "==========EDIT MOLECULES=====================" << endl;
928 cout << Verbose(0) << "c - create new molecule" << endl;
929 cout << Verbose(0) << "l - load molecule from xyz file" << endl;
930 cout << Verbose(0) << "n - change molecule's name" << endl;
931 cout << Verbose(0) << "N - give molecules filename" << endl;
932 cout << Verbose(0) << "p - parse atoms in xyz file into molecule" << endl;
933 cout << Verbose(0) << "r - remove a molecule" << endl;
934 cout << Verbose(0) << "all else - go back" << endl;
935 cout << Verbose(0) << "===============================================" << endl;
936 cout << Verbose(0) << "INPUT: ";
937 cin >> choice;
938
939 switch (choice) {
940 default:
941 cout << Verbose(0) << "Not a valid choice." << endl;
942 break;
943 case 'c':
944 mol = new molecule(periode);
945 molecules->insert(mol);
946 break;
947
948 case 'l': // load from XYZ file
949 {
950 char filename[MAXSTRINGSIZE];
951 cout << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl;
952 mol = new molecule(periode);
953 do {
954 cout << Verbose(0) << "Enter file name: ";
955 cin >> filename;
956 } while (!mol->AddXYZFile(filename));
957 mol->SetNameFromFilename(filename);
958 // center at set box dimensions
959 mol->CenterEdge((ofstream *)&cout, &center);
960 mol->cell_size[0] = center.x[0];
961 mol->cell_size[1] = 0;
962 mol->cell_size[2] = center.x[1];
963 mol->cell_size[3] = 0;
964 mol->cell_size[4] = 0;
965 mol->cell_size[5] = center.x[2];
966 molecules->insert(mol);
967 }
968 break;
969
970 case 'n':
971 {
972 char filename[MAXSTRINGSIZE];
973 do {
974 cout << Verbose(0) << "Enter index of molecule: ";
975 cin >> nr;
976 mol = molecules->ReturnIndex(nr);
977 } while (mol == NULL);
978 cout << Verbose(0) << "Enter name: ";
979 cin >> filename;
980 strcpy(mol->name, filename);
981 }
982 break;
983
984 case 'N':
985 {
986 char filename[MAXSTRINGSIZE];
987 do {
988 cout << Verbose(0) << "Enter index of molecule: ";
989 cin >> nr;
990 mol = molecules->ReturnIndex(nr);
991 } while (mol == NULL);
992 cout << Verbose(0) << "Enter name: ";
993 cin >> filename;
994 mol->SetNameFromFilename(filename);
995 }
996 break;
997
998 case 'p': // parse XYZ file
999 {
1000 char filename[MAXSTRINGSIZE];
1001 mol = NULL;
1002 do {
1003 cout << Verbose(0) << "Enter index of molecule: ";
1004 cin >> nr;
1005 mol = molecules->ReturnIndex(nr);
1006 } while (mol == NULL);
1007 cout << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl;
1008 do {
1009 cout << Verbose(0) << "Enter file name: ";
1010 cin >> filename;
1011 } while (!mol->AddXYZFile(filename));
1012 mol->SetNameFromFilename(filename);
1013 }
1014 break;
1015
1016 case 'r':
1017 cout << Verbose(0) << "Enter index of molecule: ";
1018 cin >> nr;
1019 count = 1;
1020 for( MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
1021 if (nr == (*ListRunner)->IndexNr) {
1022 mol = *ListRunner;
1023 molecules->ListOfMolecules.erase(ListRunner);
1024 delete(mol);
1025 }
1026 break;
1027 }
1028};
1029
1030
1031/** Submenu for merging molecules.
1032 * \param *periode periodentafel
1033 * \param *molecules list of molecules to add to
1034 */
1035static void MergeMolecules(periodentafel *periode, MoleculeListClass *molecules)
1036{
1037 char choice; // menu choice char
1038
1039 cout << Verbose(0) << "===========MERGE MOLECULES=====================" << endl;
1040 cout << Verbose(0) << "a - simple add of one molecule to another" << endl;
1041 cout << Verbose(0) << "e - embedding merge of two molecules" << endl;
1042 cout << Verbose(0) << "m - multi-merge of all molecules" << endl;
1043 cout << Verbose(0) << "s - scatter merge of two molecules" << endl;
1044 cout << Verbose(0) << "t - simple merge of two molecules" << endl;
1045 cout << Verbose(0) << "all else - go back" << endl;
1046 cout << Verbose(0) << "===============================================" << endl;
1047 cout << Verbose(0) << "INPUT: ";
1048 cin >> choice;
1049
1050 switch (choice) {
1051 default:
1052 cout << Verbose(0) << "Not a valid choice." << endl;
1053 break;
1054
1055 case 'a':
1056 {
1057 int src, dest;
1058 molecule *srcmol = NULL, *destmol = NULL;
1059 {
1060 do {
1061 cout << Verbose(0) << "Enter index of destination molecule: ";
1062 cin >> dest;
1063 destmol = molecules->ReturnIndex(dest);
1064 } while ((destmol == NULL) && (dest != -1));
1065 do {
1066 cout << Verbose(0) << "Enter index of source molecule to add from: ";
1067 cin >> src;
1068 srcmol = molecules->ReturnIndex(src);
1069 } while ((srcmol == NULL) && (src != -1));
1070 if ((src != -1) && (dest != -1))
1071 molecules->SimpleAdd(srcmol, destmol);
1072 }
1073 }
1074 break;
1075
1076 case 'e':
1077 cout << Verbose(0) << "Not implemented yet." << endl;
1078 break;
1079
1080 case 'm':
1081 {
1082 int nr;
1083 molecule *mol = NULL;
1084 do {
1085 cout << Verbose(0) << "Enter index of molecule to merge into: ";
1086 cin >> nr;
1087 mol = molecules->ReturnIndex(nr);
1088 } while ((mol == NULL) && (nr != -1));
1089 if (nr != -1) {
1090 int N = molecules->ListOfMolecules.size()-1;
1091 int *src = new int(N);
1092 for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
1093 if ((*ListRunner)->IndexNr != nr)
1094 src[N++] = (*ListRunner)->IndexNr;
1095 molecules->SimpleMultiMerge(mol, src, N);
1096 delete[](src);
1097 }
1098 }
1099 break;
1100
1101 case 's':
1102 cout << Verbose(0) << "Not implemented yet." << endl;
1103 break;
1104
1105 case 't':
1106 {
1107 int src, dest;
1108 molecule *srcmol = NULL, *destmol = NULL;
1109 {
1110 do {
1111 cout << Verbose(0) << "Enter index of destination molecule: ";
1112 cin >> dest;
1113 destmol = molecules->ReturnIndex(dest);
1114 } while ((destmol == NULL) && (dest != -1));
1115 do {
1116 cout << Verbose(0) << "Enter index of source molecule to merge into: ";
1117 cin >> src;
1118 srcmol = molecules->ReturnIndex(src);
1119 } while ((srcmol == NULL) && (src != -1));
1120 if ((src != -1) && (dest != -1))
1121 molecules->SimpleMerge(srcmol, destmol);
1122 }
1123 }
1124 break;
1125 }
1126};
1127
1128
1129/********************************************** Test routine **************************************/
1130
1131/** Is called always as option 'T' in the menu.
1132 * \param *molecules list of molecules
1133 */
1134static void testroutine(MoleculeListClass *molecules)
1135{
1136 // the current test routine checks the functionality of the KeySet&Graph concept:
1137 // We want to have a multiindex (the KeySet) describing a unique subgraph
1138 int i, comp, counter=0;
1139
1140 // create a clone
1141 molecule *mol = NULL;
1142 if (molecules->ListOfMolecules.size() != 0) // clone
1143 mol = (molecules->ListOfMolecules.front())->CopyMolecule();
1144 else {
1145 cerr << "I don't have anything to test on ... ";
1146 return;
1147 }
1148 atom *Walker = mol->start;
1149
1150 // generate some KeySets
1151 cout << "Generating KeySets." << endl;
1152 KeySet TestSets[mol->AtomCount+1];
1153 i=1;
1154 while (Walker->next != mol->end) {
1155 Walker = Walker->next;
1156 for (int j=0;j<i;j++) {
1157 TestSets[j].insert(Walker->nr);
1158 }
1159 i++;
1160 }
1161 cout << "Testing insertion of already present item in KeySets." << endl;
1162 KeySetTestPair test;
1163 test = TestSets[mol->AtomCount-1].insert(Walker->nr);
1164 if (test.second) {
1165 cout << Verbose(1) << "Insertion worked?!" << endl;
1166 } else {
1167 cout << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
1168 }
1169 TestSets[mol->AtomCount].insert(mol->end->previous->nr);
1170 TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
1171
1172 // constructing Graph structure
1173 cout << "Generating Subgraph class." << endl;
1174 Graph Subgraphs;
1175
1176 // insert KeySets into Subgraphs
1177 cout << "Inserting KeySets into Subgraph class." << endl;
1178 for (int j=0;j<mol->AtomCount;j++) {
1179 Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
1180 }
1181 cout << "Testing insertion of already present item in Subgraph." << endl;
1182 GraphTestPair test2;
1183 test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
1184 if (test2.second) {
1185 cout << Verbose(1) << "Insertion worked?!" << endl;
1186 } else {
1187 cout << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl;
1188 }
1189
1190 // show graphs
1191 cout << "Showing Subgraph's contents, checking that it's sorted." << endl;
1192 Graph::iterator A = Subgraphs.begin();
1193 while (A != Subgraphs.end()) {
1194 cout << (*A).second.first << ": ";
1195 KeySet::iterator key = (*A).first.begin();
1196 comp = -1;
1197 while (key != (*A).first.end()) {
1198 if ((*key) > comp)
1199 cout << (*key) << " ";
1200 else
1201 cout << (*key) << "! ";
1202 comp = (*key);
1203 key++;
1204 }
1205 cout << endl;
1206 A++;
1207 }
1208 delete(mol);
1209};
1210
1211/** Tries given filename or standard on saving the config file.
1212 * \param *ConfigFileName name of file
1213 * \param *configuration pointer to configuration structure with all the values
1214 * \param *periode pointer to periodentafel structure with all the elements
1215 * \param *molecules list of molecules structure with all the atoms and coordinates
1216 */
1217static void SaveConfig(char *ConfigFileName, config *configuration, periodentafel *periode, MoleculeListClass *molecules)
1218{
1219 char filename[MAXSTRINGSIZE];
1220 ofstream output;
1221 molecule *mol = new molecule(periode);
1222
1223 // translate each to its center and merge all molecules in MoleculeListClass into this molecule
1224 int N = molecules->ListOfMolecules.size();
1225 int *src = new int(N);
1226 N=0;
1227 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
1228 src[N++] = (*ListRunner)->IndexNr;
1229 (*ListRunner)->Translate(&(*ListRunner)->Center);
1230 }
1231 molecules->SimpleMultiAdd(mol, src, N);
1232 delete(src);
1233
1234 // ... and translate back
1235 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
1236 (*ListRunner)->Center.Scale(-1.);
1237 (*ListRunner)->Translate(&(*ListRunner)->Center);
1238 (*ListRunner)->Center.Scale(-1.);
1239 }
1240
1241 cout << Verbose(0) << "Storing configuration ... " << endl;
1242 // get correct valence orbitals
1243 mol->CalculateOrbitals(*configuration);
1244 configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble;
1245 if (ConfigFileName != NULL) { // test the file name
1246 strcpy(filename, ConfigFileName);
1247 output.open(filename, ios::trunc);
1248 } else if (strlen(configuration->configname) != 0) {
1249 strcpy(filename, configuration->configname);
1250 output.open(configuration->configname, ios::trunc);
1251 } else {
1252 strcpy(filename, DEFAULTCONFIG);
1253 output.open(DEFAULTCONFIG, ios::trunc);
1254 }
1255 output.close();
1256 output.clear();
1257 cout << Verbose(0) << "Saving of config file ";
1258 if (configuration->Save(filename, periode, mol))
1259 cout << "successful." << endl;
1260 else
1261 cout << "failed." << endl;
1262
1263 // and save to xyz file
1264 if (ConfigFileName != NULL) {
1265 strcpy(filename, ConfigFileName);
1266 strcat(filename, ".xyz");
1267 output.open(filename, ios::trunc);
1268 }
1269 if (output == NULL) {
1270 strcpy(filename,"main_pcp_linux");
1271 strcat(filename, ".xyz");
1272 output.open(filename, ios::trunc);
1273 }
1274 cout << Verbose(0) << "Saving of XYZ file ";
1275 if (mol->MDSteps <= 1) {
1276 if (mol->OutputXYZ(&output))
1277 cout << "successful." << endl;
1278 else
1279 cout << "failed." << endl;
1280 } else {
1281 if (mol->OutputTrajectoriesXYZ(&output))
1282 cout << "successful." << endl;
1283 else
1284 cout << "failed." << endl;
1285 }
1286 output.close();
1287 output.clear();
1288
1289 // and save as MPQC configuration
1290 if (ConfigFileName != NULL)
1291 strcpy(filename, ConfigFileName);
1292 if (output == NULL)
1293 strcpy(filename,"main_pcp_linux");
1294 cout << Verbose(0) << "Saving as mpqc input ";
1295 if (configuration->SaveMPQC(filename, mol))
1296 cout << "done." << endl;
1297 else
1298 cout << "failed." << endl;
1299
1300 if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
1301 cerr << "WARNING: config is found under different path then stated in config file::defaultpath!" << endl;
1302 }
1303 delete(mol);
1304};
1305
1306/** Parses the command line options.
1307 * \param argc argument count
1308 * \param **argv arguments array
1309 * \param *molecules list of molecules structure
1310 * \param *periode elements structure
1311 * \param configuration config file structure
1312 * \param *ConfigFileName pointer to config file name in **argv
1313 * \param *PathToDatabases pointer to db's path in **argv
1314 * \return exit code (0 - successful, all else - something's wrong)
1315 */
1316static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode, config& configuration, char *&ConfigFileName)
1317{
1318 Vector x,y,z,n; // coordinates for absolute point in cell volume
1319 double *factor; // unit factor if desired
1320 ifstream test;
1321 ofstream output;
1322 string line;
1323 atom *first;
1324 bool SaveFlag = false;
1325 int ExitFlag = 0;
1326 int j;
1327 double volume = 0.;
1328 enum ConfigStatus configPresent = absent;
1329 clock_t start,end;
1330 int argptr;
1331 molecule *mol = NULL;
1332 strncpy(configuration.databasepath, LocalPath, MAXSTRINGSIZE-1);
1333
1334 if (argc > 1) { // config file specified as option
1335 // 1. : Parse options that just set variables or print help
1336 argptr = 1;
1337 do {
1338 if (argv[argptr][0] == '-') {
1339 cout << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n";
1340 argptr++;
1341 switch(argv[argptr-1][1]) {
1342 case 'h':
1343 case 'H':
1344 case '?':
1345 cout << "MoleCuilder suite" << endl << "==================" << endl << endl;
1346 cout << "Usage: " << argv[0] << "[config file] [-{acefpsthH?vfrp}] [further arguments]" << endl;
1347 cout << "or simply " << argv[0] << " without arguments for interactive session." << endl;
1348 cout << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl;
1349 cout << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl;
1350 cout << "\t-b xx xy xz yy yz zz\tCenter atoms in domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl;
1351 cout << "\t-B xx xy xz yy yz zz\tBound atoms by domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl;
1352 cout << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl;
1353 cout << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl;
1354 cout << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl;
1355 cout << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl;
1356 cout << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl;
1357 cout << "\t-f/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;
1358 cout << "\t-h/-H/-?\tGive this help screen." << endl;
1359 cout << "\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;
1360 cout << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl;
1361 cout << "\t-M <basis>\tSetting basis to store to MPQC config files." << endl;
1362 cout << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl;
1363 cout << "\t-N <radius> <file>\tGet non-convex-envelope." << endl;
1364 cout << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl;
1365 cout << "\t-O\tCenter atoms in origin." << endl;
1366 cout << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl;
1367 cout << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl;
1368 cout << "\t-r\t\tConvert file from an old pcp syntax." << endl;
1369 cout << "\t-R\t\tRemove all atoms out of sphere around a given one." << endl;
1370 cout << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl;
1371 cout << "\t-S <file> Store temperatures from the config file in <file>." << endl;
1372 cout << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl;
1373 cout << "\t-T x1 x2 x3\tTranslate periodically all atoms by this vector (x1,x2,x3)." << endl;
1374 cout << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl;
1375 cout << "\t-v/-V\t\tGives version information." << endl;
1376 cout << "Note: config files must not begin with '-' !" << endl;
1377 return (1);
1378 break;
1379 case 'v':
1380 case 'V':
1381 cout << argv[0] << " " << VERSIONSTRING << endl;
1382 cout << "Build your own molecule position set." << endl;
1383 return (1);
1384 break;
1385 case 'e':
1386 if ((argptr >= argc) || (argv[argptr][0] == '-')) {
1387 cerr << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl;
1388 } else {
1389 cout << "Using " << argv[argptr] << " as elements database." << endl;
1390 strncpy (configuration.databasepath, argv[argptr], MAXSTRINGSIZE-1);
1391 argptr+=1;
1392 }
1393 break;
1394 case 'n':
1395 cout << "I won't parse trajectories." << endl;
1396 configuration.FastParsing = true;
1397 break;
1398 default: // no match? Step on
1399 argptr++;
1400 break;
1401 }
1402 } else
1403 argptr++;
1404 } while (argptr < argc);
1405
1406 // 2. Parse the element database
1407 if (periode->LoadPeriodentafel(configuration.databasepath)) {
1408 cout << Verbose(0) << "Element list loaded successfully." << endl;
1409 //periode->Output((ofstream *)&cout);
1410 } else {
1411 cout << Verbose(0) << "Element list loading failed." << endl;
1412 return 1;
1413 }
1414 // 3. Find config file name and parse if possible
1415 if (argv[1][0] != '-') {
1416 // simply create a new molecule, wherein the config file is loaded and the manipulation takes place
1417 mol = new molecule(periode);
1418 mol->ActiveFlag = true;
1419 molecules->insert(mol);
1420
1421 cout << Verbose(0) << "Config file given." << endl;
1422 test.open(argv[1], ios::in);
1423 if (test == NULL) {
1424 //return (1);
1425 output.open(argv[1], ios::out);
1426 if (output == NULL) {
1427 cout << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl;
1428 configPresent = absent;
1429 } else {
1430 cout << "Empty configuration file." << endl;
1431 ConfigFileName = argv[1];
1432 configPresent = empty;
1433 output.close();
1434 }
1435 } else {
1436 test.close();
1437 ConfigFileName = argv[1];
1438 cout << Verbose(1) << "Specified config file found, parsing ... ";
1439 switch (configuration.TestSyntax(ConfigFileName, periode, mol)) {
1440 case 1:
1441 cout << "new syntax." << endl;
1442 configuration.Load(ConfigFileName, periode, mol);
1443 configPresent = present;
1444 break;
1445 case 0:
1446 cout << "old syntax." << endl;
1447 configuration.LoadOld(ConfigFileName, periode, mol);
1448 configPresent = present;
1449 break;
1450 default:
1451 cout << "Unknown syntax or empty, yet present file." << endl;
1452 configPresent = empty;
1453 }
1454 }
1455 } else
1456 configPresent = absent;
1457 // 4. parse again through options, now for those depending on elements db and config presence
1458 argptr = 1;
1459 do {
1460 cout << "Current Command line argument: " << argv[argptr] << "." << endl;
1461 if (argv[argptr][0] == '-') {
1462 argptr++;
1463 if ((configPresent == present) || (configPresent == empty)) {
1464 switch(argv[argptr-1][1]) {
1465 case 'p':
1466 ExitFlag = 1;
1467 if ((argptr >= argc) || (argv[argptr][0] == '-')) {
1468 ExitFlag = 255;
1469 cerr << "Not enough arguments for parsing: -p <xyz file>" << endl;
1470 } else {
1471 SaveFlag = true;
1472 cout << Verbose(1) << "Parsing xyz file for new atoms." << endl;
1473 if (!mol->AddXYZFile(argv[argptr]))
1474 cout << Verbose(2) << "File not found." << endl;
1475 else {
1476 cout << Verbose(2) << "File found and parsed." << endl;
1477 configPresent = present;
1478 }
1479 }
1480 break;
1481 case 'a':
1482 ExitFlag = 1;
1483 if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1]))) {
1484 ExitFlag = 255;
1485 cerr << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl;
1486 } else {
1487 SaveFlag = true;
1488 cout << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), ";
1489 first = new atom;
1490 first->type = periode->FindElement(atoi(argv[argptr]));
1491 if (first->type != NULL)
1492 cout << Verbose(2) << "found element " << first->type->name << endl;
1493 for (int i=NDIM;i--;)
1494 first->x.x[i] = atof(argv[argptr+1+i]);
1495 if (first->type != NULL) {
1496 mol->AddAtom(first); // add to molecule
1497 if ((configPresent == empty) && (mol->AtomCount != 0))
1498 configPresent = present;
1499 } else
1500 cerr << Verbose(1) << "Could not find the specified element." << endl;
1501 argptr+=4;
1502 }
1503 break;
1504 default: // no match? Don't step on (this is done in next switch's default)
1505 break;
1506 }
1507 }
1508 if (configPresent == present) {
1509 switch(argv[argptr-1][1]) {
1510 case 'M':
1511 if ((argptr >= argc) || (argv[argptr][0] == '-')) {
1512 ExitFlag = 255;
1513 cerr << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl;
1514 } else {
1515 configuration.basis = argv[argptr];
1516 cout << Verbose(1) << "Setting MPQC basis to " << configuration.basis << "." << endl;
1517 argptr+=1;
1518 }
1519 break;
1520 case 'D':
1521 ExitFlag = 1;
1522 {
1523 cout << Verbose(1) << "Depth-First-Search Analysis." << endl;
1524 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis
1525 int *MinimumRingSize = new int[mol->AtomCount];
1526 atom ***ListOfLocalAtoms = NULL;
1527 int FragmentCounter = 0;
1528 class StackClass<bond *> *BackEdgeStack = NULL;
1529 class StackClass<bond *> *LocalBackEdgeStack = NULL;
1530 mol->CreateAdjacencyList((ofstream *)&cout, atof(argv[argptr]), configuration.GetIsAngstroem());
1531 mol->CreateListOfBondsPerAtom((ofstream *)&cout);
1532 Subgraphs = mol->DepthFirstSearchAnalysis((ofstream *)&cout, BackEdgeStack);
1533 if (Subgraphs != NULL) {
1534 Subgraphs->next->FillBondStructureFromReference((ofstream *)&cout, mol, (FragmentCounter = 0), ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms
1535 while (Subgraphs->next != NULL) {
1536 Subgraphs = Subgraphs->next;
1537 LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
1538 Subgraphs->Leaf->PickLocalBackEdges((ofstream *)&cout, ListOfLocalAtoms[FragmentCounter++], BackEdgeStack, LocalBackEdgeStack);
1539 Subgraphs->Leaf->CyclicStructureAnalysis((ofstream *)&cout, BackEdgeStack, MinimumRingSize);
1540 delete(LocalBackEdgeStack);
1541 delete(Subgraphs->previous);
1542 }
1543 delete(Subgraphs);
1544 for (int i=0;i<FragmentCounter;i++)
1545 Free(&ListOfLocalAtoms[FragmentCounter]);
1546 Free(&ListOfLocalAtoms);
1547 }
1548 delete(BackEdgeStack);
1549 delete[](MinimumRingSize);
1550 }
1551 //argptr+=1;
1552 break;
1553 case 'E':
1554 ExitFlag = 1;
1555 if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) {
1556 ExitFlag = 255;
1557 cerr << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl;
1558 } else {
1559 SaveFlag = true;
1560 cout << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl;
1561 first = mol->FindAtom(atoi(argv[argptr]));
1562 first->type = periode->FindElement(atoi(argv[argptr+1]));
1563 argptr+=2;
1564 }
1565 break;
1566 case 'F':
1567 ExitFlag = 1;
1568 if (argptr+5 >=argc) {
1569 ExitFlag = 255;
1570 cerr << "Not enough or invalid arguments given for filling box with water: -F <dist_x> <dist_y> <dist_z> <randatom> <randmol> <DoRotate>" << endl;
1571 } else {
1572 SaveFlag = true;
1573 cout << Verbose(1) << "Filling Box with water molecules." << endl;
1574 // construct water molecule
1575 molecule *filler = new molecule(periode);;
1576 molecule *Filling = NULL;
1577 atom *second = NULL, *third = NULL;
1578 first = new atom();
1579 first->type = periode->FindElement(1);
1580 first->x.Init(0.441, -0.143, 0.);
1581 filler->AddAtom(first);
1582 second = new atom();
1583 second->type = periode->FindElement(1);
1584 second->x.Init(-0.464, 1.137, 0.0);
1585 filler->AddAtom(second);
1586 third = new atom();
1587 third->type = periode->FindElement(8);
1588 third->x.Init(-0.464, 0.177, 0.);
1589 filler->AddAtom(third);
1590 filler->AddBond(first, third, 1);
1591 filler->AddBond(second, third, 1);
1592 // call routine
1593 double distance[NDIM];
1594 for (int i=0;i<NDIM;i++)
1595 distance[i] = atof(argv[argptr+i]);
1596 Filling = FillBoxWithMolecule((ofstream *)&cout, molecules, filler, configuration, distance, atof(argv[argptr+3]), atof(argv[argptr+4]), atoi(argv[argptr+5]));
1597 if (Filling != NULL) {
1598 molecules->insert(Filling);
1599 }
1600 delete(filler);
1601 argptr+=6;
1602 }
1603 break;
1604 case 'A':
1605 ExitFlag = 1;
1606 if ((argptr >= argc) || (argv[argptr][0] == '-')) {
1607 ExitFlag =255;
1608 cerr << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl;
1609 } else {
1610 cout << "Parsing bonds from " << argv[argptr] << "." << endl;
1611 ifstream *input = new ifstream(argv[argptr]);
1612 mol->CreateAdjacencyList2((ofstream *)&cout, input);
1613 input->close();
1614 argptr+=1;
1615 }
1616 break;
1617 case 'N':
1618 ExitFlag = 1;
1619 if ((argptr+1 >= argc) || (argv[argptr+1][0] == '-')){
1620 ExitFlag = 255;
1621 cerr << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl;
1622 } else {
1623 class Tesselation T;
1624 string filename(argv[argptr+1]);
1625 filename.append(".csv");
1626 cout << Verbose(0) << "Evaluating non-convex envelope.";
1627 cout << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl;
1628 start = clock();
1629 LinkedCell LCList(mol, atof(argv[argptr])*2.);
1630 FindNonConvexBorder((ofstream *)&cout, mol, &LCList, argv[argptr+1], atof(argv[argptr]));
1631 //FindDistributionOfEllipsoids((ofstream *)&cout, &T, &LCList, N, number, filename.c_str());
1632 end = clock();
1633 cout << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
1634 argptr+=2;
1635 }
1636 break;
1637 case 'S':
1638 ExitFlag = 1;
1639 if ((argptr >= argc) || (argv[argptr][0] == '-')) {
1640 ExitFlag = 255;
1641 cerr << "Not enough or invalid arguments given for storing tempature: -S <temperature file>" << endl;
1642 } else {
1643 cout << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl;
1644 ofstream *output = new ofstream(argv[argptr], ios::trunc);
1645 if (!mol->OutputTemperatureFromTrajectories((ofstream *)&cout, 0, mol->MDSteps, output))
1646 cout << Verbose(2) << "File could not be written." << endl;
1647 else
1648 cout << Verbose(2) << "File stored." << endl;
1649 output->close();
1650 delete(output);
1651 argptr+=1;
1652 }
1653 break;
1654 case 'L':
1655 ExitFlag = 1;
1656 SaveFlag = true;
1657 cout << Verbose(1) << "Linear interpolation between configuration " << argv[argptr] << " and " << argv[argptr+1] << "." << endl;
1658 if (!mol->LinearInterpolationBetweenConfiguration((ofstream *)&cout, atoi(argv[argptr]), atoi(argv[argptr+1]), argv[argptr+2], configuration))
1659 cout << Verbose(2) << "Could not store " << argv[argptr+2] << " files." << endl;
1660 else
1661 cout << Verbose(2) << "Steps created and " << argv[argptr+2] << " files stored." << endl;
1662 argptr+=3;
1663 break;
1664 case 'P':
1665 ExitFlag = 1;
1666 if ((argptr >= argc) || (argv[argptr][0] == '-')) {
1667 ExitFlag = 255;
1668 cerr << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl;
1669 } else {
1670 SaveFlag = true;
1671 cout << Verbose(1) << "Parsing forces file and Verlet integrating." << endl;
1672 if (!mol->VerletForceIntegration((ofstream *)&cout, argv[argptr], configuration))
1673 cout << Verbose(2) << "File not found." << endl;
1674 else
1675 cout << Verbose(2) << "File found and parsed." << endl;
1676 argptr+=1;
1677 }
1678 break;
1679 case 'R':
1680 ExitFlag = 1;
1681 if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {
1682 ExitFlag = 255;
1683 cerr << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl;
1684 } else {
1685 SaveFlag = true;
1686 cout << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl;
1687 double tmp1 = atof(argv[argptr+1]);
1688 atom *third = mol->FindAtom(atoi(argv[argptr]));
1689 atom *first = mol->start;
1690 if ((third != NULL) && (first != mol->end)) {
1691 atom *second = first->next;
1692 while(second != mol->end) {
1693 first = second;
1694 second = first->next;
1695 if (first->x.DistanceSquared((const Vector *)&third->x) > tmp1*tmp1) // distance to first above radius ...
1696 mol->RemoveAtom(first);
1697 }
1698 } else {
1699 cerr << "Removal failed due to missing atoms on molecule or wrong id." << endl;
1700 }
1701 argptr+=2;
1702 }
1703 break;
1704 case 't':
1705 ExitFlag = 1;
1706 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
1707 ExitFlag = 255;
1708 cerr << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl;
1709 } else {
1710 ExitFlag = 1;
1711 SaveFlag = true;
1712 cout << Verbose(1) << "Translating all ions to new origin." << endl;
1713 for (int i=NDIM;i--;)
1714 x.x[i] = atof(argv[argptr+i]);
1715 mol->Translate((const Vector *)&x);
1716 argptr+=3;
1717 }
1718 case 'T':
1719 ExitFlag = 1;
1720 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
1721 ExitFlag = 255;
1722 cerr << "Not enough or invalid arguments given for periodic translation: -T <x> <y> <z>" << endl;
1723 } else {
1724 ExitFlag = 1;
1725 SaveFlag = true;
1726 cout << Verbose(1) << "Translating all ions periodically to new origin." << endl;
1727 for (int i=NDIM;i--;)
1728 x.x[i] = atof(argv[argptr+i]);
1729 mol->TranslatePeriodically((const Vector *)&x);
1730 argptr+=3;
1731 }
1732 break;
1733 case 's':
1734 ExitFlag = 1;
1735 if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) ) {
1736 ExitFlag = 255;
1737 cerr << "Not enough or invalid arguments given for scaling: -s <factor/[factor_x]> [factor_y] [factor_z]" << endl;
1738 } else {
1739 SaveFlag = true;
1740 j = -1;
1741 cout << Verbose(1) << "Scaling all ion positions by factor." << endl;
1742 factor = new double[NDIM];
1743 factor[0] = atof(argv[argptr]);
1744 if ((argptr < argc) && (IsValidNumber(argv[argptr])))
1745 argptr++;
1746 factor[1] = atof(argv[argptr]);
1747 if ((argptr < argc) && (IsValidNumber(argv[argptr])))
1748 argptr++;
1749 factor[2] = atof(argv[argptr]);
1750 mol->Scale(&factor);
1751 for (int i=0;i<NDIM;i++) {
1752 j += i+1;
1753 x.x[i] = atof(argv[NDIM+i]);
1754 mol->cell_size[j]*=factor[i];
1755 }
1756 delete[](factor);
1757 argptr+=1;
1758 }
1759 break;
1760 case 'b':
1761 ExitFlag = 1;
1762 if ((argptr+5 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
1763 ExitFlag = 255;
1764 cerr << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl;
1765 } else {
1766 SaveFlag = true;
1767 j = -1;
1768 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
1769 for (int i=0;i<6;i++) {
1770 mol->cell_size[i] = atof(argv[argptr+i]);
1771 }
1772 // center
1773 mol->CenterInBox((ofstream *)&cout);
1774 argptr+=6;
1775 }
1776 break;
1777 case 'B':
1778 ExitFlag = 1;
1779 if ((argptr+5 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
1780 ExitFlag = 255;
1781 cerr << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl;
1782 } else {
1783 SaveFlag = true;
1784 j = -1;
1785 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
1786 for (int i=0;i<6;i++) {
1787 mol->cell_size[i] = atof(argv[argptr+i]);
1788 }
1789 // center
1790 mol->BoundInBox((ofstream *)&cout);
1791 argptr+=6;
1792 }
1793 break;
1794 case 'c':
1795 ExitFlag = 1;
1796 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
1797 ExitFlag = 255;
1798 cerr << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl;
1799 } else {
1800 SaveFlag = true;
1801 j = -1;
1802 cout << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl;
1803 // make every coordinate positive
1804 mol->CenterEdge((ofstream *)&cout, &x);
1805 // update Box of atoms by boundary
1806 mol->SetBoxDimension(&x);
1807 // translate each coordinate by boundary
1808 j=-1;
1809 for (int i=0;i<NDIM;i++) {
1810 j += i+1;
1811 x.x[i] = atof(argv[argptr+i]);
1812 mol->cell_size[j] += x.x[i]*2.;
1813 }
1814 mol->Translate((const Vector *)&x);
1815 argptr+=3;
1816 }
1817 break;
1818 case 'O':
1819 ExitFlag = 1;
1820 SaveFlag = true;
1821 cout << Verbose(1) << "Centering atoms on edge and setting box dimensions." << endl;
1822 x.Zero();
1823 mol->CenterEdge((ofstream *)&cout, &x);
1824 mol->SetBoxDimension(&x);
1825 argptr+=0;
1826 break;
1827 case 'r':
1828 ExitFlag = 1;
1829 SaveFlag = true;
1830 cout << Verbose(1) << "Converting config file from supposed old to new syntax." << endl;
1831 break;
1832 case 'f':
1833 ExitFlag = 1;
1834 if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {
1835 ExitFlag = 255;
1836 cerr << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl;
1837 } else {
1838 cout << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl;
1839 cout << Verbose(0) << "Creating connection matrix..." << endl;
1840 start = clock();
1841 mol->CreateAdjacencyList((ofstream *)&cout, atof(argv[argptr++]), configuration.GetIsAngstroem());
1842 cout << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
1843 if (mol->first->next != mol->last) {
1844 ExitFlag = mol->FragmentMolecule((ofstream *)&cout, atoi(argv[argptr]), &configuration);
1845 }
1846 end = clock();
1847 cout << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
1848 argptr+=2;
1849 }
1850 break;
1851 case 'm':
1852 ExitFlag = 1;
1853 j = atoi(argv[argptr++]);
1854 if ((j<0) || (j>1)) {
1855 cerr << Verbose(1) << "ERROR: Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl;
1856 j = 0;
1857 }
1858 if (j) {
1859 SaveFlag = true;
1860 cout << Verbose(0) << "Converting to prinicipal axis system." << endl;
1861 } else
1862 cout << Verbose(0) << "Evaluating prinicipal axis." << endl;
1863 mol->PrincipalAxisSystem((ofstream *)&cout, (bool)j);
1864 break;
1865 case 'o':
1866 ExitFlag = 1;
1867 if ((argptr >= argc) || (argv[argptr][0] == '-')){
1868 ExitFlag = 255;
1869 cerr << "Not enough or invalid arguments given for convex envelope: -o <tecplot output file>" << endl;
1870 } else {
1871 cout << Verbose(0) << "Evaluating volume of the convex envelope.";
1872 cout << Verbose(1) << "Storing tecplot data in " << argv[argptr] << "." << endl;
1873 LinkedCell LCList(mol, 10.);
1874 //FindConvexBorder((ofstream *)&cout, mol, &LCList, argv[argptr]);
1875 FindNonConvexBorder((ofstream *)&cout, mol, &LCList, argv[argptr], 10.);
1876
1877 double volumedifference = ConvexizeNonconvexEnvelope((ofstream *)&cout, mol->TesselStruct, mol, argv[argptr]);
1878 double clustervolume = VolumeOfConvexEnvelope((ofstream *)&cout, mol->TesselStruct, &configuration);
1879 cout << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl;
1880 cout << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl;
1881 argptr+=1;
1882 }
1883 break;
1884 case 'U':
1885 ExitFlag = 1;
1886 if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) {
1887 ExitFlag = 255;
1888 cerr << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl;
1889 volume = -1; // for case 'u': don't print error again
1890 } else {
1891 volume = atof(argv[argptr++]);
1892 cout << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl;
1893 }
1894 case 'u':
1895 ExitFlag = 1;
1896 if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) ) {
1897 if (volume != -1)
1898 ExitFlag = 255;
1899 cerr << "Not enough arguments given for suspension: -u <density>" << endl;
1900 } else {
1901 double density;
1902 SaveFlag = true;
1903 cout << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.";
1904 density = atof(argv[argptr++]);
1905 if (density < 1.0) {
1906 cerr << Verbose(0) << "Density must be greater than 1.0g/cm^3 !" << endl;
1907 density = 1.3;
1908 }
1909// for(int i=0;i<NDIM;i++) {
1910// repetition[i] = atoi(argv[argptr++]);
1911// if (repetition[i] < 1)
1912// cerr << Verbose(0) << "ERROR: repetition value must be greater 1!" << endl;
1913// repetition[i] = 1;
1914// }
1915 PrepareClustersinWater((ofstream *)&cout, &configuration, mol, volume, density); // if volume == 0, will calculate from ConvexEnvelope
1916 }
1917 break;
1918 case 'd':
1919 ExitFlag = 1;
1920 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
1921 ExitFlag = 255;
1922 cerr << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl;
1923 } else {
1924 SaveFlag = true;
1925 for (int axis = 1; axis <= NDIM; axis++) {
1926 int faktor = atoi(argv[argptr++]);
1927 int count;
1928 element ** Elements;
1929 Vector ** vectors;
1930 if (faktor < 1) {
1931 cerr << Verbose(0) << "ERROR: Repetition faktor mus be greater than 1!" << endl;
1932 faktor = 1;
1933 }
1934 mol->CountAtoms((ofstream *)&cout); // recount atoms
1935 if (mol->AtomCount != 0) { // if there is more than none
1936 count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand
1937 Elements = new element *[count];
1938 vectors = new Vector *[count];
1939 j = 0;
1940 first = mol->start;
1941 while (first->next != mol->end) { // make a list of all atoms with coordinates and element
1942 first = first->next;
1943 Elements[j] = first->type;
1944 vectors[j] = &first->x;
1945 j++;
1946 }
1947 if (count != j)
1948 cout << Verbose(0) << "ERROR: AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
1949 x.Zero();
1950 y.Zero();
1951 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
1952 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times
1953 x.AddVector(&y); // per factor one cell width further
1954 for (int k=count;k--;) { // go through every atom of the original cell
1955 first = new atom(); // create a new body
1956 first->x.CopyVector(vectors[k]); // use coordinate of original atom
1957 first->x.AddVector(&x); // translate the coordinates
1958 first->type = Elements[k]; // insert original element
1959 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
1960 }
1961 }
1962 // free memory
1963 delete[](Elements);
1964 delete[](vectors);
1965 // correct cell size
1966 if (axis < 0) { // if sign was negative, we have to translate everything
1967 x.Zero();
1968 x.AddVector(&y);
1969 x.Scale(-(faktor-1));
1970 mol->Translate(&x);
1971 }
1972 mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
1973 }
1974 }
1975 }
1976 break;
1977 default: // no match? Step on
1978 if ((argptr < argc) && (argv[argptr][0] != '-')) // if it started with a '-' we've already made a step!
1979 argptr++;
1980 break;
1981 }
1982 }
1983 } else argptr++;
1984 } while (argptr < argc);
1985 if (SaveFlag)
1986 SaveConfig(ConfigFileName, &configuration, periode, molecules);
1987 } else { // no arguments, hence scan the elements db
1988 if (periode->LoadPeriodentafel(configuration.databasepath))
1989 cout << Verbose(0) << "Element list loaded successfully." << endl;
1990 else
1991 cout << Verbose(0) << "Element list loading failed." << endl;
1992 configuration.RetrieveConfigPathAndName("main_pcp_linux");
1993 }
1994 return(ExitFlag);
1995};
1996
1997/********************************************** Main routine **************************************/
1998
1999int main(int argc, char **argv)
2000{
2001 periodentafel *periode = new periodentafel; // and a period table of all elements
2002 MoleculeListClass *molecules = new MoleculeListClass; // list of all molecules
2003 molecule *mol = NULL;
2004 config configuration;
2005 char choice; // menu choice char
2006 Vector x,y,z,n; // coordinates for absolute point in cell volume
2007 ifstream test;
2008 ofstream output;
2009 string line;
2010 char *ConfigFileName = NULL;
2011 int j;
2012
2013 // =========================== PARSE COMMAND LINE OPTIONS ====================================
2014 j = ParseCommandLineOptions(argc, argv, molecules, periode, configuration, ConfigFileName);
2015 switch(j) {
2016 case 255: // something went wrong
2017 delete(molecules); // also free's all molecules contained
2018 delete(periode);
2019 return j;
2020 break;
2021 case 1: // just for -v and -h options
2022 delete(molecules); // also free's all molecules contained
2023 delete(periode);
2024 cout << Verbose(0) << "Remaining non-freed memory: "
2025 << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;
2026 return 0;
2027 break;
2028 default:
2029 break;
2030 }
2031
2032 // General stuff
2033 if (molecules->ListOfMolecules.size() == 0) {
2034 mol = new molecule(periode);
2035 if (mol->cell_size[0] == 0.) {
2036 cout << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl;
2037 for (int i=0;i<6;i++) {
2038 cout << Verbose(1) << "Cell size" << i << ": ";
2039 cin >> mol->cell_size[i];
2040 }
2041 }
2042 molecules->insert(mol);
2043 }
2044
2045 // =========================== START INTERACTIVE SESSION ====================================
2046
2047 // now the main construction loop
2048 cout << Verbose(0) << endl << "Now comes the real construction..." << endl;
2049 do {
2050 cout << Verbose(0) << endl << endl;
2051 cout << Verbose(0) << "============Molecule list=======================" << endl;
2052 molecules->Enumerate((ofstream *)&cout);
2053 cout << Verbose(0) << "============Menu===============================" << endl;
2054 cout << Verbose(0) << "a - set molecule (in)active" << endl;
2055 cout << Verbose(0) << "e - edit molecules (load, parse, save)" << endl;
2056 cout << Verbose(0) << "g - globally manipulate atoms in molecule" << endl;
2057 cout << Verbose(0) << "M - Merge molecules" << endl;
2058 cout << Verbose(0) << "m - manipulate atoms" << endl;
2059 cout << Verbose(0) << "-----------------------------------------------" << endl;
2060 cout << Verbose(0) << "c - edit the current configuration" << endl;
2061 cout << Verbose(0) << "-----------------------------------------------" << endl;
2062 cout << Verbose(0) << "s - save current setup to config file" << endl;
2063 cout << Verbose(0) << "T - call the current test routine" << endl;
2064 cout << Verbose(0) << "q - quit" << endl;
2065 cout << Verbose(0) << "===============================================" << endl;
2066 cout << Verbose(0) << "Input: ";
2067 cin >> choice;
2068
2069 switch (choice) {
2070 case 'a': // (in)activate molecule
2071 {
2072 cout << "Enter index of molecule: ";
2073 cin >> j;
2074 for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
2075 if ((*ListRunner)->IndexNr == j)
2076 (*ListRunner)->ActiveFlag = !(*ListRunner)->ActiveFlag;
2077 }
2078 break;
2079
2080 case 'c': // edit each field of the configuration
2081 configuration.Edit();
2082 break;
2083
2084 case 'e': // create molecule
2085 EditMolecules(periode, molecules);
2086 break;
2087
2088 case 'g': // manipulate molecules
2089 ManipulateMolecules(periode, molecules, &configuration);
2090 break;
2091
2092 case 'M': // merge molecules
2093 MergeMolecules(periode, molecules);
2094 break;
2095
2096 case 'm': // manipulate atoms
2097 ManipulateAtoms(periode, molecules, &configuration);
2098 break;
2099
2100 case 'q': // quit
2101 break;
2102
2103 case 's': // save to config file
2104 SaveConfig(ConfigFileName, &configuration, periode, molecules);
2105 break;
2106
2107 case 'T':
2108 testroutine(molecules);
2109 break;
2110
2111 default:
2112 break;
2113 };
2114 } while (choice != 'q');
2115
2116 // save element data base
2117 if (periode->StorePeriodentafel(configuration.databasepath)) //ElementsFileName
2118 cout << Verbose(0) << "Saving of elements.db successful." << endl;
2119 else
2120 cout << Verbose(0) << "Saving of elements.db failed." << endl;
2121
2122 delete(molecules); // also free's all molecules contained
2123 delete(periode);
2124
2125 cout << Verbose(0) << "Remaining non-freed memory: "
2126 << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;
2127
2128 return (0);
2129}
2130
2131/********************************************** E N D **************************************************/
Note: See TracBrowser for help on using the repository browser.