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