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