source: molecuilder/src/builder.cpp@ 7d1ad9

Last change on this file since 7d1ad9 was 3d4969, checked in by Frederik Heber <heber@…>, 16 years ago

Fixing ticket #18.

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