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