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