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