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