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