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