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