| [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 |  *
 | 
|---|
| [14de469] | 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 |  *
 | 
|---|
| [14de469] | 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 |  *
 | 
|---|
| [14de469] | 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 |  *
 | 
|---|
| [14de469] | 31 |  *  Further useful commands are
 | 
|---|
 | 32 |  *  -# make clean uninstall: deletes .o-files and removes executable from the given binary directory\n
 | 
|---|
| [a8bcea6] | 33 |  *  -# make doxygen-doc: Creates these html pages out of the documented source
 | 
|---|
 | 34 |  *
 | 
|---|
| [14de469] | 35 |  * \section run Running
 | 
|---|
| [a8bcea6] | 36 |  *
 | 
|---|
| [14de469] | 37 |  *  The program can be executed by running: ./molecuilder
 | 
|---|
| [a8bcea6] | 38 |  *
 | 
|---|
| [14de469] | 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
 | 
|---|
| [a8bcea6] | 41 |  *  later re-execution.
 | 
|---|
 | 42 |  *
 | 
|---|
| [14de469] | 43 |  * \section ref References
 | 
|---|
| [a8bcea6] | 44 |  *
 | 
|---|
| [14de469] | 45 |  *  For the special configuration file format, see the documentation of pcp.
 | 
|---|
| [a8bcea6] | 46 |  *
 | 
|---|
| [14de469] | 47 |  */
 | 
|---|
 | 48 | 
 | 
|---|
 | 49 | 
 | 
|---|
 | 50 | using namespace std;
 | 
|---|
 | 51 | 
 | 
|---|
 | 52 | #include "helpers.hpp"
 | 
|---|
 | 53 | #include "molecules.hpp"
 | 
|---|
| [110ceb] | 54 | #include "boundary.hpp"
 | 
|---|
| [14de469] | 55 | 
 | 
|---|
 | 56 | /********************************************** Submenu routine **************************************/
 | 
|---|
 | 57 | 
 | 
|---|
 | 58 | /** Submenu for adding atoms to the molecule.
 | 
|---|
 | 59 |  * \param *periode periodentafel
 | 
|---|
 | 60 |  * \param *mol the molecule to add to
 | 
|---|
 | 61 |  */
 | 
|---|
| [7f3b9d] | 62 | static void AddAtoms(periodentafel *periode, molecule *mol)
 | 
|---|
| [14de469] | 63 | {
 | 
|---|
 | 64 |   atom *first, *second, *third, *fourth;
 | 
|---|
| [e9b8bb] | 65 |   Vector **atoms;
 | 
|---|
 | 66 |   Vector x,y,z,n;  // coordinates for absolute point in cell volume
 | 
|---|
| [14de469] | 67 |   double a,b,c;
 | 
|---|
 | 68 |   char choice;  // menu choice char
 | 
|---|
 | 69 |   bool valid;
 | 
|---|
 | 70 | 
 | 
|---|
 | 71 |   cout << Verbose(0) << "===========ADD ATOM============================" << endl;
 | 
|---|
 | 72 |   cout << Verbose(0) << " a - state absolute coordinates of atom" << endl;
 | 
|---|
 | 73 |   cout << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;
 | 
|---|
 | 74 |   cout << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;
 | 
|---|
 | 75 |   cout << Verbose(0) << " d - state two atoms, two angles and a distance" << endl;
 | 
|---|
 | 76 |   cout << Verbose(0) << " e - least square distance position to a set of atoms" << endl;
 | 
|---|
 | 77 |   cout << Verbose(0) << "all else - go back" << endl;
 | 
|---|
 | 78 |   cout << Verbose(0) << "===============================================" << endl;
 | 
|---|
 | 79 |   cout << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;
 | 
|---|
 | 80 |   cout << Verbose(0) << "INPUT: ";
 | 
|---|
 | 81 |   cin >> choice;
 | 
|---|
| [a8bcea6] | 82 | 
 | 
|---|
| [14de469] | 83 |   switch (choice) {
 | 
|---|
 | 84 |       case 'a': // absolute coordinates of atom
 | 
|---|
 | 85 |         cout << Verbose(0) << "Enter absolute coordinates." << endl;
 | 
|---|
 | 86 |         first = new atom;
 | 
|---|
 | 87 |         first->x.AskPosition(mol->cell_size, false);
 | 
|---|
 | 88 |         first->type = periode->AskElement();  // give type
 | 
|---|
 | 89 |         mol->AddAtom(first);  // add to molecule
 | 
|---|
 | 90 |         break;
 | 
|---|
| [a8bcea6] | 91 | 
 | 
|---|
| [14de469] | 92 |       case 'b': // relative coordinates of atom wrt to reference point
 | 
|---|
 | 93 |         first = new atom;
 | 
|---|
 | 94 |         valid = true;
 | 
|---|
 | 95 |         do {
 | 
|---|
 | 96 |           if (!valid) cout << Verbose(0) << "Resulting position out of cell." << endl;
 | 
|---|
 | 97 |           cout << Verbose(0) << "Enter reference coordinates." << endl;
 | 
|---|
 | 98 |           x.AskPosition(mol->cell_size, true);
 | 
|---|
 | 99 |           cout << Verbose(0) << "Enter relative coordinates." << endl;
 | 
|---|
 | 100 |           first->x.AskPosition(mol->cell_size, false);
 | 
|---|
| [e9b8bb] | 101 |           first->x.AddVector((const Vector *)&x);
 | 
|---|
| [14de469] | 102 |           cout << Verbose(0) << "\n";
 | 
|---|
| [e9b8bb] | 103 |         } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
 | 
|---|
| [14de469] | 104 |         first->type = periode->AskElement();  // give type
 | 
|---|
 | 105 |         mol->AddAtom(first);  // add to molecule
 | 
|---|
 | 106 |         break;
 | 
|---|
| [a8bcea6] | 107 | 
 | 
|---|
| [14de469] | 108 |       case 'c': // relative coordinates of atom wrt to already placed atom
 | 
|---|
 | 109 |         first = new atom;
 | 
|---|
 | 110 |         valid = true;
 | 
|---|
 | 111 |         do {
 | 
|---|
 | 112 |           if (!valid) cout << Verbose(0) << "Resulting position out of cell." << endl;
 | 
|---|
| [a8bcea6] | 113 |           second = mol->AskAtom("Enter atom number: ");
 | 
|---|
| [14de469] | 114 |           cout << Verbose(0) << "Enter relative coordinates." << endl;
 | 
|---|
 | 115 |           first->x.AskPosition(mol->cell_size, false);
 | 
|---|
| [7f3b9d] | 116 |           for (int i=NDIM;i--;) {
 | 
|---|
| [14de469] | 117 |             first->x.x[i] += second->x.x[i];
 | 
|---|
 | 118 |           }
 | 
|---|
| [e9b8bb] | 119 |         } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
 | 
|---|
| [14de469] | 120 |         first->type = periode->AskElement();  // give type
 | 
|---|
 | 121 |         mol->AddAtom(first);  // add to molecule
 | 
|---|
 | 122 |         break;
 | 
|---|
| [a8bcea6] | 123 | 
 | 
|---|
| [14de469] | 124 |       case 'd': // two atoms, two angles and a distance
 | 
|---|
 | 125 |         first = new atom;
 | 
|---|
 | 126 |         valid = true;
 | 
|---|
 | 127 |         do {
 | 
|---|
 | 128 |           if (!valid) {
 | 
|---|
 | 129 |             cout << Verbose(0) << "Resulting coordinates out of cell - ";
 | 
|---|
 | 130 |             first->x.Output((ofstream *)&cout);
 | 
|---|
 | 131 |             cout << Verbose(0) << endl;
 | 
|---|
 | 132 |           }
 | 
|---|
 | 133 |           cout << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;
 | 
|---|
 | 134 |           second = mol->AskAtom("Enter central atom: ");
 | 
|---|
 | 135 |           third = mol->AskAtom("Enter second atom (specifying the axis for first angle): ");
 | 
|---|
 | 136 |           fourth = mol->AskAtom("Enter third atom (specifying a plane for second angle): ");
 | 
|---|
 | 137 |           a = ask_value("Enter distance between central (first) and new atom: ");
 | 
|---|
 | 138 |           b = ask_value("Enter angle between new, first and second atom (degrees): ");
 | 
|---|
 | 139 |           b *= M_PI/180.;
 | 
|---|
 | 140 |           bound(&b, 0., 2.*M_PI);
 | 
|---|
 | 141 |           c = ask_value("Enter second angle between new and normal vector of plane defined by first, second and third atom (degrees): ");
 | 
|---|
 | 142 |           c *= M_PI/180.;
 | 
|---|
 | 143 |           bound(&c, -M_PI, M_PI);
 | 
|---|
 | 144 |           cout << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl;
 | 
|---|
 | 145 | /*
 | 
|---|
 | 146 |           second->Output(1,1,(ofstream *)&cout);
 | 
|---|
 | 147 |           third->Output(1,2,(ofstream *)&cout);
 | 
|---|
 | 148 |           fourth->Output(1,3,(ofstream *)&cout);
 | 
|---|
| [d7e30c] | 149 |           n.MakeNormalvector((const vector *)&second->x, (const vector *)&third->x, (const vector *)&fourth->x);
 | 
|---|
 | 150 |           x.Copyvector(&second->x);
 | 
|---|
| [14de469] | 151 |           x.SubtractVector(&third->x);
 | 
|---|
| [d7e30c] | 152 |           x.Copyvector(&fourth->x);
 | 
|---|
| [14de469] | 153 |           x.SubtractVector(&third->x);
 | 
|---|
| [a8bcea6] | 154 | 
 | 
|---|
| [14de469] | 155 |           if (!z.SolveSystem(&x,&y,&n, b, c, a)) {
 | 
|---|
 | 156 |             cout << Verbose(0) << "Failure solving self-dependent linear system!" << endl;
 | 
|---|
 | 157 |             continue;
 | 
|---|
 | 158 |           }
 | 
|---|
 | 159 |           cout << Verbose(0) << "resulting relative coordinates: ";
 | 
|---|
 | 160 |           z.Output((ofstream *)&cout);
 | 
|---|
 | 161 |           cout << Verbose(0) << endl;
 | 
|---|
 | 162 |           */
 | 
|---|
 | 163 |           // calc axis vector
 | 
|---|
 | 164 |           x.CopyVector(&second->x);
 | 
|---|
 | 165 |           x.SubtractVector(&third->x);
 | 
|---|
 | 166 |           x.Normalize();
 | 
|---|
 | 167 |           cout << "x: ",
 | 
|---|
 | 168 |           x.Output((ofstream *)&cout);
 | 
|---|
| [a8bcea6] | 169 |           cout << endl;
 | 
|---|
| [14de469] | 170 |           z.MakeNormalVector(&second->x,&third->x,&fourth->x);
 | 
|---|
 | 171 |           cout << "z: ",
 | 
|---|
 | 172 |           z.Output((ofstream *)&cout);
 | 
|---|
| [a8bcea6] | 173 |           cout << endl;
 | 
|---|
| [14de469] | 174 |           y.MakeNormalVector(&x,&z);
 | 
|---|
 | 175 |           cout << "y: ",
 | 
|---|
 | 176 |           y.Output((ofstream *)&cout);
 | 
|---|
| [a8bcea6] | 177 |           cout << endl;
 | 
|---|
 | 178 | 
 | 
|---|
| [14de469] | 179 |           // rotate vector around first angle
 | 
|---|
 | 180 |           first->x.CopyVector(&x);
 | 
|---|
 | 181 |           first->x.RotateVector(&z,b - M_PI);
 | 
|---|
 | 182 |           cout << "Rotated vector: ",
 | 
|---|
 | 183 |           first->x.Output((ofstream *)&cout);
 | 
|---|
| [a8bcea6] | 184 |           cout << endl;
 | 
|---|
| [14de469] | 185 |           // remove the projection onto the rotation plane of the second angle
 | 
|---|
 | 186 |           n.CopyVector(&y);
 | 
|---|
 | 187 |           n.Scale(first->x.Projection(&y));
 | 
|---|
 | 188 |           cout << "N1: ",
 | 
|---|
 | 189 |           n.Output((ofstream *)&cout);
 | 
|---|
| [a8bcea6] | 190 |           cout << endl;
 | 
|---|
| [14de469] | 191 |           first->x.SubtractVector(&n);
 | 
|---|
 | 192 |           cout << "Subtracted vector: ",
 | 
|---|
 | 193 |           first->x.Output((ofstream *)&cout);
 | 
|---|
| [a8bcea6] | 194 |           cout << endl;
 | 
|---|
| [14de469] | 195 |           n.CopyVector(&z);
 | 
|---|
 | 196 |           n.Scale(first->x.Projection(&z));
 | 
|---|
 | 197 |           cout << "N2: ",
 | 
|---|
 | 198 |           n.Output((ofstream *)&cout);
 | 
|---|
| [a8bcea6] | 199 |           cout << endl;
 | 
|---|
| [14de469] | 200 |           first->x.SubtractVector(&n);
 | 
|---|
 | 201 |           cout << "2nd subtracted vector: ",
 | 
|---|
 | 202 |           first->x.Output((ofstream *)&cout);
 | 
|---|
| [a8bcea6] | 203 |           cout << endl;
 | 
|---|
 | 204 | 
 | 
|---|
| [14de469] | 205 |           // rotate another vector around second angle
 | 
|---|
 | 206 |           n.CopyVector(&y);
 | 
|---|
 | 207 |           n.RotateVector(&x,c - M_PI);
 | 
|---|
 | 208 |           cout << "2nd Rotated vector: ",
 | 
|---|
 | 209 |           n.Output((ofstream *)&cout);
 | 
|---|
| [a8bcea6] | 210 |           cout << endl;
 | 
|---|
 | 211 | 
 | 
|---|
| [14de469] | 212 |           // add the two linear independent vectors
 | 
|---|
 | 213 |           first->x.AddVector(&n);
 | 
|---|
| [a8bcea6] | 214 |           first->x.Normalize();
 | 
|---|
| [14de469] | 215 |           first->x.Scale(a);
 | 
|---|
 | 216 |           first->x.AddVector(&second->x);
 | 
|---|
| [a8bcea6] | 217 | 
 | 
|---|
| [14de469] | 218 |           cout << Verbose(0) << "resulting coordinates: ";
 | 
|---|
 | 219 |           first->x.Output((ofstream *)&cout);
 | 
|---|
 | 220 |           cout << Verbose(0) << endl;
 | 
|---|
| [e9b8bb] | 221 |         } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
 | 
|---|
| [14de469] | 222 |         first->type = periode->AskElement();  // give type
 | 
|---|
 | 223 |         mol->AddAtom(first);  // add to molecule
 | 
|---|
 | 224 |         break;
 | 
|---|
 | 225 | 
 | 
|---|
 | 226 |       case 'e': // least square distance position to a set of atoms
 | 
|---|
 | 227 |         first = new atom;
 | 
|---|
| [e9b8bb] | 228 |         atoms = new (Vector*[128]);
 | 
|---|
| [14de469] | 229 |         valid = true;
 | 
|---|
| [7f3b9d] | 230 |         for(int i=128;i--;)
 | 
|---|
| [14de469] | 231 |           atoms[i] = NULL;
 | 
|---|
 | 232 |         int i=0, j=0;
 | 
|---|
 | 233 |         cout << Verbose(0) << "Now we need at least three molecules.\n";
 | 
|---|
 | 234 |         do {
 | 
|---|
 | 235 |           cout << Verbose(0) << "Enter " << i+1 << "th atom: ";
 | 
|---|
 | 236 |           cin >> j;
 | 
|---|
 | 237 |           if (j != -1) {
 | 
|---|
 | 238 |             second = mol->FindAtom(j);
 | 
|---|
 | 239 |             atoms[i++] = &(second->x);
 | 
|---|
 | 240 |           }
 | 
|---|
 | 241 |         } while ((j != -1) && (i<128));
 | 
|---|
 | 242 |         if (i >= 2) {
 | 
|---|
| [a8bcea6] | 243 |           first->x.LSQdistance(atoms, i);
 | 
|---|
| [14de469] | 244 | 
 | 
|---|
 | 245 |           first->x.Output((ofstream *)&cout);
 | 
|---|
 | 246 |           first->type = periode->AskElement();  // give type
 | 
|---|
 | 247 |           mol->AddAtom(first);  // add to molecule
 | 
|---|
 | 248 |         } else {
 | 
|---|
 | 249 |           delete first;
 | 
|---|
 | 250 |           cout << Verbose(0) << "Please enter at least two vectors!\n";
 | 
|---|
 | 251 |         }
 | 
|---|
 | 252 |         break;
 | 
|---|
 | 253 |   };
 | 
|---|
 | 254 | };
 | 
|---|
 | 255 | 
 | 
|---|
 | 256 | /** Submenu for centering the atoms in the molecule.
 | 
|---|
 | 257 |  * \param *mol the molecule with all the atoms
 | 
|---|
 | 258 |  */
 | 
|---|
| [7f3b9d] | 259 | static void CenterAtoms(molecule *mol)
 | 
|---|
| [14de469] | 260 | {
 | 
|---|
| [cc2ee5] | 261 |   Vector x, y, helper;
 | 
|---|
| [14de469] | 262 |   char choice;  // menu choice char
 | 
|---|
| [a8bcea6] | 263 | 
 | 
|---|
| [14de469] | 264 |   cout << Verbose(0) << "===========CENTER ATOMS=========================" << endl;
 | 
|---|
 | 265 |   cout << Verbose(0) << " a - on origin" << endl;
 | 
|---|
 | 266 |   cout << Verbose(0) << " b - on center of gravity" << endl;
 | 
|---|
 | 267 |   cout << Verbose(0) << " c - within box with additional boundary" << endl;
 | 
|---|
| [ca2b83] | 268 |   cout << Verbose(0) << " d - within given simulation box" << endl;
 | 
|---|
| [14de469] | 269 |   cout << Verbose(0) << "all else - go back" << endl;
 | 
|---|
 | 270 |   cout << Verbose(0) << "===============================================" << endl;
 | 
|---|
 | 271 |   cout << Verbose(0) << "INPUT: ";
 | 
|---|
 | 272 |   cin >> choice;
 | 
|---|
| [a8bcea6] | 273 | 
 | 
|---|
| [14de469] | 274 |   switch (choice) {
 | 
|---|
 | 275 |     default:
 | 
|---|
 | 276 |       cout << Verbose(0) << "Not a valid choice." << endl;
 | 
|---|
 | 277 |       break;
 | 
|---|
 | 278 |     case 'a':
 | 
|---|
 | 279 |       cout << Verbose(0) << "Centering atoms in config file on origin." << endl;
 | 
|---|
 | 280 |       mol->CenterOrigin((ofstream *)&cout, &x);
 | 
|---|
 | 281 |       break;
 | 
|---|
 | 282 |     case 'b':
 | 
|---|
 | 283 |       cout << Verbose(0) << "Centering atoms in config file on center of gravity." << endl;
 | 
|---|
 | 284 |       mol->CenterGravity((ofstream *)&cout, &x);
 | 
|---|
 | 285 |       break;
 | 
|---|
 | 286 |     case 'c':
 | 
|---|
 | 287 |       cout << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;
 | 
|---|
| [7f3b9d] | 288 |       for (int i=0;i<NDIM;i++) {
 | 
|---|
| [14de469] | 289 |         cout << Verbose(0) << "Enter axis " << i << " boundary: ";
 | 
|---|
| [ca2b83] | 290 |         cin >> y.x[i];
 | 
|---|
| [14de469] | 291 |       }
 | 
|---|
 | 292 |       mol->CenterEdge((ofstream *)&cout, &x);  // make every coordinate positive
 | 
|---|
| [ca2b83] | 293 |       mol->Translate(&y); // translate by boundary
 | 
|---|
| [cc2ee5] | 294 |       helper.CopyVector(&y);
 | 
|---|
 | 295 |       helper.Scale(2.);
 | 
|---|
 | 296 |       helper.AddVector(&x);
 | 
|---|
 | 297 |       mol->SetBoxDimension(&helper);  // update Box of atoms by boundary
 | 
|---|
| [ca2b83] | 298 |       break;
 | 
|---|
 | 299 |     case 'd':
 | 
|---|
 | 300 |       cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
 | 
|---|
| [7f3b9d] | 301 |       for (int i=0;i<NDIM;i++) {
 | 
|---|
| [ca2b83] | 302 |         cout << Verbose(0) << "Enter axis " << i << " boundary: ";
 | 
|---|
 | 303 |         cin >> x.x[i];
 | 
|---|
| [14de469] | 304 |       }
 | 
|---|
| [ca2b83] | 305 |       // center
 | 
|---|
 | 306 |       mol->CenterInBox((ofstream *)&cout, &x);
 | 
|---|
 | 307 |       // update Box of atoms by boundary
 | 
|---|
 | 308 |       mol->SetBoxDimension(&x);
 | 
|---|
| [14de469] | 309 |       break;
 | 
|---|
 | 310 |   }
 | 
|---|
 | 311 | };
 | 
|---|
 | 312 | 
 | 
|---|
 | 313 | /** Submenu for aligning the atoms in the molecule.
 | 
|---|
 | 314 |  * \param *periode periodentafel
 | 
|---|
 | 315 |  * \param *mol the molecule with all the atoms
 | 
|---|
 | 316 |  */
 | 
|---|
| [7f3b9d] | 317 | static void AlignAtoms(periodentafel *periode, molecule *mol)
 | 
|---|
| [14de469] | 318 | {
 | 
|---|
 | 319 |   atom *first, *second, *third;
 | 
|---|
| [e9b8bb] | 320 |   Vector x,n;
 | 
|---|
| [14de469] | 321 |   char choice;  // menu choice char
 | 
|---|
 | 322 | 
 | 
|---|
 | 323 |   cout << Verbose(0) << "===========ALIGN ATOMS=========================" << endl;
 | 
|---|
 | 324 |   cout << Verbose(0) << " a - state three atoms defining align plane" << endl;
 | 
|---|
 | 325 |   cout << Verbose(0) << " b - state alignment vector" << endl;
 | 
|---|
 | 326 |   cout << Verbose(0) << " c - state two atoms in alignment direction" << endl;
 | 
|---|
 | 327 |   cout << Verbose(0) << " d - align automatically by least square fit" << endl;
 | 
|---|
 | 328 |   cout << Verbose(0) << "all else - go back" << endl;
 | 
|---|
 | 329 |   cout << Verbose(0) << "===============================================" << endl;
 | 
|---|
 | 330 |   cout << Verbose(0) << "INPUT: ";
 | 
|---|
 | 331 |   cin >> choice;
 | 
|---|
| [a8bcea6] | 332 | 
 | 
|---|
| [14de469] | 333 |   switch (choice) {
 | 
|---|
 | 334 |     default:
 | 
|---|
 | 335 |     case 'a': // three atoms defining mirror plane
 | 
|---|
 | 336 |       first = mol->AskAtom("Enter first atom: ");
 | 
|---|
 | 337 |       second = mol->AskAtom("Enter second atom: ");
 | 
|---|
 | 338 |       third = mol->AskAtom("Enter third atom: ");
 | 
|---|
 | 339 | 
 | 
|---|
| [e9b8bb] | 340 |       n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
 | 
|---|
| [14de469] | 341 |       break;
 | 
|---|
 | 342 |     case 'b': // normal vector of mirror plane
 | 
|---|
 | 343 |       cout << Verbose(0) << "Enter normal vector of mirror plane." << endl;
 | 
|---|
 | 344 |       n.AskPosition(mol->cell_size,0);
 | 
|---|
 | 345 |       n.Normalize();
 | 
|---|
 | 346 |       break;
 | 
|---|
 | 347 |     case 'c': // three atoms defining mirror plane
 | 
|---|
 | 348 |       first = mol->AskAtom("Enter first atom: ");
 | 
|---|
 | 349 |       second = mol->AskAtom("Enter second atom: ");
 | 
|---|
 | 350 | 
 | 
|---|
| [a8bcea6] | 351 |       n.CopyVector((const Vector *)&first->x);
 | 
|---|
 | 352 |       n.SubtractVector((const Vector *)&second->x);
 | 
|---|
| [14de469] | 353 |       n.Normalize();
 | 
|---|
| [a8bcea6] | 354 |       break;
 | 
|---|
| [14de469] | 355 |     case 'd':
 | 
|---|
 | 356 |       char shorthand[4];
 | 
|---|
| [e9b8bb] | 357 |       Vector a;
 | 
|---|
| [14de469] | 358 |       struct lsq_params param;
 | 
|---|
 | 359 |       do {
 | 
|---|
 | 360 |         fprintf(stdout, "Enter the element of atoms to be chosen: ");
 | 
|---|
 | 361 |         fscanf(stdin, "%3s", shorthand);
 | 
|---|
 | 362 |       } while ((param.type = periode->FindElement(shorthand)) == NULL);
 | 
|---|
 | 363 |       cout << Verbose(0) << "Element is " << param.type->name << endl;
 | 
|---|
| [d7e30c] | 364 |       mol->GetAlignvector(¶m);
 | 
|---|
| [7f3b9d] | 365 |       for (int i=NDIM;i--;) {
 | 
|---|
| [14de469] | 366 |         x.x[i] = gsl_vector_get(param.x,i);
 | 
|---|
| [7f3b9d] | 367 |         n.x[i] = gsl_vector_get(param.x,i+NDIM);
 | 
|---|
| [a8bcea6] | 368 |       }
 | 
|---|
| [14de469] | 369 |       gsl_vector_free(param.x);
 | 
|---|
 | 370 |       cout << Verbose(0) << "Offset vector: ";
 | 
|---|
 | 371 |       x.Output((ofstream *)&cout);
 | 
|---|
 | 372 |       cout << Verbose(0) << endl;
 | 
|---|
 | 373 |       n.Normalize();
 | 
|---|
| [a8bcea6] | 374 |       break;
 | 
|---|
| [14de469] | 375 |   };
 | 
|---|
 | 376 |   cout << Verbose(0) << "Alignment vector: ";
 | 
|---|
 | 377 |   n.Output((ofstream *)&cout);
 | 
|---|
 | 378 |   cout << Verbose(0) << endl;
 | 
|---|
 | 379 |   mol->Align(&n);
 | 
|---|
 | 380 | };
 | 
|---|
 | 381 | 
 | 
|---|
 | 382 | /** Submenu for mirroring the atoms in the molecule.
 | 
|---|
 | 383 |  * \param *mol the molecule with all the atoms
 | 
|---|
 | 384 |  */
 | 
|---|
| [7f3b9d] | 385 | static void MirrorAtoms(molecule *mol)
 | 
|---|
| [14de469] | 386 | {
 | 
|---|
 | 387 |   atom *first, *second, *third;
 | 
|---|
| [e9b8bb] | 388 |   Vector n;
 | 
|---|
| [14de469] | 389 |   char choice;  // menu choice char
 | 
|---|
| [a8bcea6] | 390 | 
 | 
|---|
| [14de469] | 391 |   cout << Verbose(0) << "===========MIRROR ATOMS=========================" << endl;
 | 
|---|
 | 392 |   cout << Verbose(0) << " a - state three atoms defining mirror plane" << endl;
 | 
|---|
 | 393 |   cout << Verbose(0) << " b - state normal vector of mirror plane" << endl;
 | 
|---|
 | 394 |   cout << Verbose(0) << " c - state two atoms in normal direction" << endl;
 | 
|---|
 | 395 |   cout << Verbose(0) << "all else - go back" << endl;
 | 
|---|
 | 396 |   cout << Verbose(0) << "===============================================" << endl;
 | 
|---|
 | 397 |   cout << Verbose(0) << "INPUT: ";
 | 
|---|
 | 398 |   cin >> choice;
 | 
|---|
| [a8bcea6] | 399 | 
 | 
|---|
| [14de469] | 400 |   switch (choice) {
 | 
|---|
 | 401 |     default:
 | 
|---|
 | 402 |     case 'a': // three atoms defining mirror plane
 | 
|---|
 | 403 |       first = mol->AskAtom("Enter first atom: ");
 | 
|---|
 | 404 |       second = mol->AskAtom("Enter second atom: ");
 | 
|---|
 | 405 |       third = mol->AskAtom("Enter third atom: ");
 | 
|---|
 | 406 | 
 | 
|---|
| [e9b8bb] | 407 |       n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
 | 
|---|
| [14de469] | 408 |       break;
 | 
|---|
 | 409 |     case 'b': // normal vector of mirror plane
 | 
|---|
 | 410 |       cout << Verbose(0) << "Enter normal vector of mirror plane." << endl;
 | 
|---|
 | 411 |       n.AskPosition(mol->cell_size,0);
 | 
|---|
 | 412 |       n.Normalize();
 | 
|---|
 | 413 |       break;
 | 
|---|
 | 414 |     case 'c': // three atoms defining mirror plane
 | 
|---|
 | 415 |       first = mol->AskAtom("Enter first atom: ");
 | 
|---|
 | 416 |       second = mol->AskAtom("Enter second atom: ");
 | 
|---|
 | 417 | 
 | 
|---|
| [a8bcea6] | 418 |       n.CopyVector((const Vector *)&first->x);
 | 
|---|
 | 419 |       n.SubtractVector((const Vector *)&second->x);
 | 
|---|
| [14de469] | 420 |       n.Normalize();
 | 
|---|
| [a8bcea6] | 421 |       break;
 | 
|---|
| [14de469] | 422 |   };
 | 
|---|
 | 423 |   cout << Verbose(0) << "Normal vector: ";
 | 
|---|
 | 424 |   n.Output((ofstream *)&cout);
 | 
|---|
 | 425 |   cout << Verbose(0) << endl;
 | 
|---|
| [e9b8bb] | 426 |   mol->Mirror((const Vector *)&n);
 | 
|---|
| [14de469] | 427 | };
 | 
|---|
 | 428 | 
 | 
|---|
 | 429 | /** Submenu for removing the atoms from the molecule.
 | 
|---|
 | 430 |  * \param *mol the molecule with all the atoms
 | 
|---|
 | 431 |  */
 | 
|---|
| [7f3b9d] | 432 | static void RemoveAtoms(molecule *mol)
 | 
|---|
| [14de469] | 433 | {
 | 
|---|
 | 434 |   atom *first, *second;
 | 
|---|
 | 435 |   int axis;
 | 
|---|
 | 436 |   double tmp1, tmp2;
 | 
|---|
 | 437 |   char choice;  // menu choice char
 | 
|---|
| [a8bcea6] | 438 | 
 | 
|---|
| [14de469] | 439 |   cout << Verbose(0) << "===========REMOVE ATOMS=========================" << endl;
 | 
|---|
 | 440 |   cout << Verbose(0) << " a - state atom for removal by number" << endl;
 | 
|---|
 | 441 |   cout << Verbose(0) << " b - keep only in radius around atom" << endl;
 | 
|---|
 | 442 |   cout << Verbose(0) << " c - remove this with one axis greater value" << endl;
 | 
|---|
 | 443 |   cout << Verbose(0) << "all else - go back" << endl;
 | 
|---|
 | 444 |   cout << Verbose(0) << "===============================================" << endl;
 | 
|---|
 | 445 |   cout << Verbose(0) << "INPUT: ";
 | 
|---|
 | 446 |   cin >> choice;
 | 
|---|
| [a8bcea6] | 447 | 
 | 
|---|
| [14de469] | 448 |   switch (choice) {
 | 
|---|
 | 449 |     default:
 | 
|---|
 | 450 |     case 'a':
 | 
|---|
 | 451 |       if (mol->RemoveAtom(mol->AskAtom("Enter number of atom within molecule: ")))
 | 
|---|
 | 452 |         cout << Verbose(1) << "Atom removed." << endl;
 | 
|---|
 | 453 |       else
 | 
|---|
 | 454 |         cout << Verbose(1) << "Atom not found." << endl;
 | 
|---|
 | 455 |       break;
 | 
|---|
 | 456 |     case 'b':
 | 
|---|
 | 457 |       second = mol->AskAtom("Enter number of atom as reference point: ");
 | 
|---|
 | 458 |       cout << Verbose(0) << "Enter radius: ";
 | 
|---|
 | 459 |       cin >> tmp1;
 | 
|---|
 | 460 |       first = mol->start;
 | 
|---|
 | 461 |       while(first->next != mol->end) {
 | 
|---|
 | 462 |         first = first->next;
 | 
|---|
| [e9b8bb] | 463 |         if (first->x.Distance((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...
 | 
|---|
| [14de469] | 464 |           mol->RemoveAtom(first);
 | 
|---|
 | 465 |       }
 | 
|---|
 | 466 |       break;
 | 
|---|
 | 467 |     case 'c':
 | 
|---|
 | 468 |       cout << Verbose(0) << "Which axis is it: ";
 | 
|---|
 | 469 |       cin >> axis;
 | 
|---|
 | 470 |       cout << Verbose(0) << "Left inward boundary: ";
 | 
|---|
 | 471 |       cin >> tmp1;
 | 
|---|
 | 472 |       cout << Verbose(0) << "Right inward boundary: ";
 | 
|---|
 | 473 |       cin >> tmp2;
 | 
|---|
 | 474 |       first = mol->start;
 | 
|---|
 | 475 |       while(first->next != mol->end) {
 | 
|---|
 | 476 |         first = first->next;
 | 
|---|
 | 477 |         if ((first->x.x[axis] > tmp2) || (first->x.x[axis] < tmp1)) // out of boundary ...
 | 
|---|
 | 478 |           mol->RemoveAtom(first);
 | 
|---|
 | 479 |       }
 | 
|---|
| [a8bcea6] | 480 |       break;
 | 
|---|
| [14de469] | 481 |   };
 | 
|---|
 | 482 |   //mol->Output((ofstream *)&cout);
 | 
|---|
 | 483 |   choice = 'r';
 | 
|---|
 | 484 | };
 | 
|---|
 | 485 | 
 | 
|---|
 | 486 | /** Submenu for measuring out the atoms in the molecule.
 | 
|---|
 | 487 |  * \param *periode periodentafel
 | 
|---|
 | 488 |  * \param *mol the molecule with all the atoms
 | 
|---|
 | 489 |  */
 | 
|---|
| [d52ea1b] | 490 | static void MeasureAtoms(periodentafel *periode, molecule *mol, config *configuration)
 | 
|---|
| [14de469] | 491 | {
 | 
|---|
 | 492 |   atom *first, *second, *third;
 | 
|---|
| [e9b8bb] | 493 |   Vector x,y;
 | 
|---|
| [14de469] | 494 |   double min[256], tmp1, tmp2, tmp3;
 | 
|---|
 | 495 |   int Z;
 | 
|---|
 | 496 |   char choice;  // menu choice char
 | 
|---|
| [a8bcea6] | 497 | 
 | 
|---|
| [14de469] | 498 |   cout << Verbose(0) << "===========MEASURE ATOMS=========================" << endl;
 | 
|---|
 | 499 |   cout << Verbose(0) << " a - calculate bond length between one atom and all others" << endl;
 | 
|---|
 | 500 |   cout << Verbose(0) << " b - calculate bond length between two atoms" << endl;
 | 
|---|
 | 501 |   cout << Verbose(0) << " c - calculate bond angle" << endl;
 | 
|---|
| [d52ea1b] | 502 |   cout << Verbose(0) << " d - calculate principal axis of the system" << endl;
 | 
|---|
 | 503 |   cout << Verbose(0) << " e - calculate volume of the convex envelope" << endl;
 | 
|---|
| [698b04] | 504 |   cout << Verbose(0) << " f - calculate temperature from current velocity" << endl;
 | 
|---|
 | 505 |   cout << Verbose(0) << " g - output all temperatures per step from velocities" << endl;
 | 
|---|
| [14de469] | 506 |   cout << Verbose(0) << "all else - go back" << endl;
 | 
|---|
 | 507 |   cout << Verbose(0) << "===============================================" << endl;
 | 
|---|
 | 508 |   cout << Verbose(0) << "INPUT: ";
 | 
|---|
 | 509 |   cin >> choice;
 | 
|---|
 | 510 | 
 | 
|---|
 | 511 |   switch(choice) {
 | 
|---|
 | 512 |     default:
 | 
|---|
 | 513 |       cout << Verbose(1) << "Not a valid choice." << endl;
 | 
|---|
 | 514 |       break;
 | 
|---|
 | 515 |     case 'a':
 | 
|---|
 | 516 |       first = mol->AskAtom("Enter first atom: ");
 | 
|---|
| [7f3b9d] | 517 |       for (int i=MAX_ELEMENTS;i--;)
 | 
|---|
| [14de469] | 518 |         min[i] = 0.;
 | 
|---|
| [a8bcea6] | 519 | 
 | 
|---|
 | 520 |       second = mol->start;
 | 
|---|
| [14de469] | 521 |       while ((second->next != mol->end)) {
 | 
|---|
 | 522 |         second = second->next; // advance
 | 
|---|
 | 523 |         Z = second->type->Z;
 | 
|---|
 | 524 |         tmp1 = 0.;
 | 
|---|
 | 525 |         if (first != second) {
 | 
|---|
| [e9b8bb] | 526 |           x.CopyVector((const Vector *)&first->x);
 | 
|---|
 | 527 |           x.SubtractVector((const Vector *)&second->x);
 | 
|---|
| [14de469] | 528 |           tmp1 = x.Norm();
 | 
|---|
 | 529 |         }
 | 
|---|
 | 530 |         if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
 | 
|---|
| [a8bcea6] | 531 |         //cout << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;
 | 
|---|
| [14de469] | 532 |       }
 | 
|---|
| [7f3b9d] | 533 |       for (int i=MAX_ELEMENTS;i--;)
 | 
|---|
| [14de469] | 534 |         if (min[i] != 0.) cout << 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;
 | 
|---|
 | 535 |       break;
 | 
|---|
| [a8bcea6] | 536 | 
 | 
|---|
| [14de469] | 537 |     case 'b':
 | 
|---|
 | 538 |       first = mol->AskAtom("Enter first atom: ");
 | 
|---|
 | 539 |       second = mol->AskAtom("Enter second atom: ");
 | 
|---|
| [7f3b9d] | 540 |       for (int i=NDIM;i--;)
 | 
|---|
| [14de469] | 541 |         min[i] = 0.;
 | 
|---|
| [e9b8bb] | 542 |       x.CopyVector((const Vector *)&first->x);
 | 
|---|
 | 543 |       x.SubtractVector((const Vector *)&second->x);
 | 
|---|
| [14de469] | 544 |       tmp1 = x.Norm();
 | 
|---|
 | 545 |       cout << Verbose(1) << "Distance vector is ";
 | 
|---|
 | 546 |       x.Output((ofstream *)&cout);
 | 
|---|
 | 547 |       cout << "." << endl << "Norm of distance is " << tmp1 << "." << endl;
 | 
|---|
 | 548 |       break;
 | 
|---|
 | 549 | 
 | 
|---|
 | 550 |     case 'c':
 | 
|---|
 | 551 |       cout << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl;
 | 
|---|
 | 552 |       first = mol->AskAtom("Enter first atom: ");
 | 
|---|
 | 553 |       second = mol->AskAtom("Enter central atom: ");
 | 
|---|
 | 554 |       third  = mol->AskAtom("Enter last atom: ");
 | 
|---|
 | 555 |       tmp1 = tmp2 = tmp3 = 0.;
 | 
|---|
| [e9b8bb] | 556 |       x.CopyVector((const Vector *)&first->x);
 | 
|---|
 | 557 |       x.SubtractVector((const Vector *)&second->x);
 | 
|---|
 | 558 |       y.CopyVector((const Vector *)&third->x);
 | 
|---|
 | 559 |       y.SubtractVector((const Vector *)&second->x);
 | 
|---|
| [14de469] | 560 |       cout << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
 | 
|---|
| [a8bcea6] | 561 |       cout << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
 | 
|---|
| [14de469] | 562 |       break;
 | 
|---|
| [d52ea1b] | 563 |     case 'd':
 | 
|---|
 | 564 |         cout << Verbose(0) << "Evaluating prinicipal axis." << endl;
 | 
|---|
 | 565 |         cout << Verbose(0) << "Shall we rotate? [0/1]: ";
 | 
|---|
 | 566 |         cin >> Z;
 | 
|---|
 | 567 |         if ((Z >=0) && (Z <=1))
 | 
|---|
 | 568 |           mol->PrincipalAxisSystem((ofstream *)&cout, (bool)Z);
 | 
|---|
 | 569 |         else
 | 
|---|
 | 570 |           mol->PrincipalAxisSystem((ofstream *)&cout, false);
 | 
|---|
 | 571 |         break;
 | 
|---|
 | 572 |     case 'e':
 | 
|---|
 | 573 |         cout << Verbose(0) << "Evaluating volume of the convex envelope.";
 | 
|---|
| [450d63] | 574 |         VolumeOfConvexEnvelope((ofstream *)&cout, NULL, configuration, NULL, mol);
 | 
|---|
| [d52ea1b] | 575 |         break;
 | 
|---|
| [698b04] | 576 |     case 'f':
 | 
|---|
 | 577 |       mol->OutputTemperatureFromTrajectories((ofstream *)&cout, mol->MDSteps-1, mol->MDSteps, (ofstream *)&cout);
 | 
|---|
 | 578 |       break;
 | 
|---|
 | 579 |     case 'g':
 | 
|---|
 | 580 |       {
 | 
|---|
 | 581 |         char filename[255];
 | 
|---|
 | 582 |         cout << "Please enter filename: " << endl;
 | 
|---|
 | 583 |         cin >> filename;
 | 
|---|
 | 584 |         cout << Verbose(1) << "Storing temperatures in " << filename << "." << endl;
 | 
|---|
 | 585 |         ofstream *output = new ofstream(filename, ios::trunc);
 | 
|---|
 | 586 |         if (!mol->OutputTemperatureFromTrajectories((ofstream *)&cout, 0, mol->MDSteps, output))
 | 
|---|
 | 587 |           cout << Verbose(2) << "File could not be written." << endl;
 | 
|---|
 | 588 |         else
 | 
|---|
 | 589 |           cout << Verbose(2) << "File stored." << endl;
 | 
|---|
 | 590 |         output->close();
 | 
|---|
 | 591 |         delete(output);
 | 
|---|
 | 592 |       }
 | 
|---|
 | 593 |       break;
 | 
|---|
| [14de469] | 594 |   }
 | 
|---|
 | 595 | };
 | 
|---|
 | 596 | 
 | 
|---|
 | 597 | /** Submenu for measuring out the atoms in the molecule.
 | 
|---|
 | 598 |  * \param *mol the molecule with all the atoms
 | 
|---|
 | 599 |  * \param *configuration configuration structure for the to be written config files of all fragments
 | 
|---|
 | 600 |  */
 | 
|---|
| [7f3b9d] | 601 | static void FragmentAtoms(molecule *mol, config *configuration)
 | 
|---|
| [14de469] | 602 | {
 | 
|---|
| [db942e] | 603 |   int Order1;
 | 
|---|
| [14de469] | 604 |   clock_t start, end;
 | 
|---|
| [a8bcea6] | 605 | 
 | 
|---|
| [14de469] | 606 |   cout << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
 | 
|---|
 | 607 |   cout << Verbose(0) << "What's the desired bond order: ";
 | 
|---|
 | 608 |   cin >> Order1;
 | 
|---|
 | 609 |   if (mol->first->next != mol->last) {  // there are bonds
 | 
|---|
 | 610 |     start = clock();
 | 
|---|
| [db942e] | 611 |     mol->FragmentMolecule((ofstream *)&cout, Order1, configuration);
 | 
|---|
| [14de469] | 612 |     end = clock();
 | 
|---|
 | 613 |     cout << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
 | 
|---|
| [a8bcea6] | 614 |   } else
 | 
|---|
| [14de469] | 615 |     cout << Verbose(0) << "Connection matrix has not yet been generated!" << endl;
 | 
|---|
 | 616 | };
 | 
|---|
 | 617 | 
 | 
|---|
 | 618 | /********************************************** Test routine **************************************/
 | 
|---|
 | 619 | 
 | 
|---|
 | 620 | /** Is called always as option 'T' in the menu.
 | 
|---|
 | 621 |  */
 | 
|---|
| [7f3b9d] | 622 | static void testroutine(molecule *mol)
 | 
|---|
| [14de469] | 623 | {
 | 
|---|
 | 624 |   // the current test routine checks the functionality of the KeySet&Graph concept:
 | 
|---|
 | 625 |   // We want to have a multiindex (the KeySet) describing a unique subgraph
 | 
|---|
 | 626 |   atom *Walker = mol->start;
 | 
|---|
 | 627 |   int i, comp, counter=0;
 | 
|---|
| [a8bcea6] | 628 | 
 | 
|---|
| [14de469] | 629 |   // generate some KeySets
 | 
|---|
 | 630 |   cout << "Generating KeySets." << endl;
 | 
|---|
 | 631 |   KeySet TestSets[mol->AtomCount+1];
 | 
|---|
 | 632 |   i=1;
 | 
|---|
 | 633 |   while (Walker->next != mol->end) {
 | 
|---|
 | 634 |     Walker = Walker->next;
 | 
|---|
 | 635 |     for (int j=0;j<i;j++) {
 | 
|---|
 | 636 |       TestSets[j].insert(Walker->nr);
 | 
|---|
 | 637 |     }
 | 
|---|
 | 638 |     i++;
 | 
|---|
 | 639 |   }
 | 
|---|
 | 640 |   cout << "Testing insertion of already present item in KeySets." << endl;
 | 
|---|
 | 641 |   KeySetTestPair test;
 | 
|---|
| [a8bcea6] | 642 |   test = TestSets[mol->AtomCount-1].insert(Walker->nr);
 | 
|---|
| [14de469] | 643 |   if (test.second) {
 | 
|---|
 | 644 |     cout << Verbose(1) << "Insertion worked?!" << endl;
 | 
|---|
 | 645 |   } else {
 | 
|---|
 | 646 |     cout << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
 | 
|---|
 | 647 |   }
 | 
|---|
 | 648 |   TestSets[mol->AtomCount].insert(mol->end->previous->nr);
 | 
|---|
 | 649 |   TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
 | 
|---|
 | 650 | 
 | 
|---|
| [a8bcea6] | 651 |   // constructing Graph structure
 | 
|---|
| [14de469] | 652 |   cout << "Generating Subgraph class." << endl;
 | 
|---|
 | 653 |   Graph Subgraphs;
 | 
|---|
 | 654 | 
 | 
|---|
 | 655 |   // insert KeySets into Subgraphs
 | 
|---|
 | 656 |   cout << "Inserting KeySets into Subgraph class." << endl;
 | 
|---|
 | 657 |   for (int j=0;j<mol->AtomCount;j++) {
 | 
|---|
 | 658 |     Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
 | 
|---|
 | 659 |   }
 | 
|---|
 | 660 |   cout << "Testing insertion of already present item in Subgraph." << endl;
 | 
|---|
 | 661 |   GraphTestPair test2;
 | 
|---|
| [a8bcea6] | 662 |   test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
 | 
|---|
| [14de469] | 663 |   if (test2.second) {
 | 
|---|
 | 664 |     cout << Verbose(1) << "Insertion worked?!" << endl;
 | 
|---|
 | 665 |   } else {
 | 
|---|
 | 666 |     cout << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl;
 | 
|---|
 | 667 |   }
 | 
|---|
| [a8bcea6] | 668 | 
 | 
|---|
| [14de469] | 669 |   // show graphs
 | 
|---|
 | 670 |   cout << "Showing Subgraph's contents, checking that it's sorted." << endl;
 | 
|---|
 | 671 |   Graph::iterator A = Subgraphs.begin();
 | 
|---|
 | 672 |   while (A !=  Subgraphs.end()) {
 | 
|---|
 | 673 |     cout << (*A).second.first << ": ";
 | 
|---|
 | 674 |     KeySet::iterator key = (*A).first.begin();
 | 
|---|
 | 675 |     comp = -1;
 | 
|---|
 | 676 |     while (key != (*A).first.end()) {
 | 
|---|
 | 677 |       if ((*key) > comp)
 | 
|---|
 | 678 |         cout << (*key) << " ";
 | 
|---|
| [a8bcea6] | 679 |       else
 | 
|---|
| [14de469] | 680 |         cout << (*key) << "! ";
 | 
|---|
 | 681 |       comp = (*key);
 | 
|---|
 | 682 |       key++;
 | 
|---|
 | 683 |     }
 | 
|---|
 | 684 |     cout << endl;
 | 
|---|
 | 685 |     A++;
 | 
|---|
 | 686 |   }
 | 
|---|
 | 687 | };
 | 
|---|
 | 688 | 
 | 
|---|
| [dbe929] | 689 | /** Tries given filename or standard on saving the config file.
 | 
|---|
 | 690 |  * \param *ConfigFileName name of file
 | 
|---|
 | 691 |  * \param *configuration pointer to configuration structure with all the values
 | 
|---|
 | 692 |  * \param *periode pointer to periodentafel structure with all the elements
 | 
|---|
 | 693 |  * \param *mol pointer to molecule structure with all the atoms and coordinates
 | 
|---|
 | 694 |  */
 | 
|---|
| [7f3b9d] | 695 | static void SaveConfig(char *ConfigFileName, config *configuration, periodentafel *periode, molecule *mol)
 | 
|---|
| [dbe929] | 696 | {
 | 
|---|
| [c750cc] | 697 |   char filename[MAXSTRINGSIZE];
 | 
|---|
| [dbe929] | 698 |   ofstream output;
 | 
|---|
 | 699 | 
 | 
|---|
| [73f80e] | 700 |   cout << Verbose(0) << "Storing configuration ... " << endl;
 | 
|---|
| [dbe929] | 701 |   // get correct valence orbitals
 | 
|---|
 | 702 |   mol->CalculateOrbitals(*configuration);
 | 
|---|
 | 703 |   configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble;
 | 
|---|
| [9a5bcd] | 704 |   strcpy(filename, ConfigFileName);
 | 
|---|
 | 705 |   if (ConfigFileName != NULL) { // test the file name
 | 
|---|
| [dbe929] | 706 |     output.open(ConfigFileName, ios::trunc);
 | 
|---|
| [4885953] | 707 |   } else if (strlen(configuration->configname) != 0) {
 | 
|---|
| [9a5bcd] | 708 |     strcpy(filename, configuration->configname);
 | 
|---|
| [6590bee] | 709 |     output.open(configuration->configname, ios::trunc);
 | 
|---|
| [4885953] | 710 |     } else {
 | 
|---|
| [9a5bcd] | 711 |       strcpy(filename, DEFAULTCONFIG);
 | 
|---|
| [4885953] | 712 |       output.open(DEFAULTCONFIG, ios::trunc);
 | 
|---|
 | 713 |     }
 | 
|---|
| [9a5bcd] | 714 |   output.close();
 | 
|---|
 | 715 |   output.clear();
 | 
|---|
| [a8aadf6] | 716 |   cout << Verbose(0) << "Saving of config file ";
 | 
|---|
| [9a5bcd] | 717 |   if (configuration->Save(filename, periode, mol))
 | 
|---|
| [a8aadf6] | 718 |     cout << "successful." << endl;
 | 
|---|
| [dbe929] | 719 |   else
 | 
|---|
| [a8aadf6] | 720 |     cout << "failed." << endl;
 | 
|---|
| [a8bcea6] | 721 | 
 | 
|---|
| [dbe929] | 722 |   // and save to xyz file
 | 
|---|
 | 723 |   if (ConfigFileName != NULL) {
 | 
|---|
 | 724 |     strcpy(filename, ConfigFileName);
 | 
|---|
 | 725 |     strcat(filename, ".xyz");
 | 
|---|
 | 726 |     output.open(filename, ios::trunc);
 | 
|---|
 | 727 |   }
 | 
|---|
 | 728 |   if (output == NULL) {
 | 
|---|
 | 729 |     strcpy(filename,"main_pcp_linux");
 | 
|---|
 | 730 |     strcat(filename, ".xyz");
 | 
|---|
 | 731 |     output.open(filename, ios::trunc);
 | 
|---|
| [a8bcea6] | 732 |   }
 | 
|---|
| [a8aadf6] | 733 |   cout << Verbose(0) << "Saving of XYZ file ";
 | 
|---|
| [362b0e] | 734 |   if (mol->MDSteps <= 1) {
 | 
|---|
 | 735 |     if (mol->OutputXYZ(&output))
 | 
|---|
| [a8aadf6] | 736 |       cout << "successful." << endl;
 | 
|---|
| [362b0e] | 737 |     else
 | 
|---|
| [a8aadf6] | 738 |       cout << "failed." << endl;
 | 
|---|
| [362b0e] | 739 |   } else {
 | 
|---|
 | 740 |     if (mol->OutputTrajectoriesXYZ(&output))
 | 
|---|
| [a8aadf6] | 741 |       cout << "successful." << endl;
 | 
|---|
| [362b0e] | 742 |     else
 | 
|---|
| [a8aadf6] | 743 |       cout << "failed." << endl;
 | 
|---|
| [362b0e] | 744 |   }
 | 
|---|
| [dbe929] | 745 |   output.close();
 | 
|---|
 | 746 |   output.clear();
 | 
|---|
| [a8bcea6] | 747 | 
 | 
|---|
| [a8aadf6] | 748 |   // and save as MPQC configuration
 | 
|---|
| [9a5bcd] | 749 |   if (ConfigFileName != NULL)
 | 
|---|
| [a8aadf6] | 750 |     strcpy(filename, ConfigFileName);
 | 
|---|
| [9a5bcd] | 751 |   if (output == NULL)
 | 
|---|
| [a8aadf6] | 752 |     strcpy(filename,"main_pcp_linux");
 | 
|---|
 | 753 |   cout << Verbose(0) << "Saving as mpqc input ";
 | 
|---|
| [9a5bcd] | 754 |   if (configuration->SaveMPQC(filename, mol))
 | 
|---|
| [a8aadf6] | 755 |     cout << "done." << endl;
 | 
|---|
 | 756 |   else
 | 
|---|
 | 757 |     cout << "failed." << endl;
 | 
|---|
| [a8bcea6] | 758 | 
 | 
|---|
| [2910e0] | 759 |   if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
 | 
|---|
 | 760 |     cerr << "WARNING: config is found under different path then stated in config file::defaultpath!" << endl;
 | 
|---|
 | 761 |   }
 | 
|---|
| [dbe929] | 762 | };
 | 
|---|
 | 763 | 
 | 
|---|
| [ca2b83] | 764 | /** Parses the command line options.
 | 
|---|
 | 765 |  * \param argc argument count
 | 
|---|
 | 766 |  * \param **argv arguments array
 | 
|---|
 | 767 |  * \param *mol molecule structure
 | 
|---|
 | 768 |  * \param *periode elements structure
 | 
|---|
 | 769 |  * \param configuration config file structure
 | 
|---|
 | 770 |  * \param *ConfigFileName pointer to config file name in **argv
 | 
|---|
| [d7d29c] | 771 |  * \param *PathToDatabases pointer to db's path in **argv
 | 
|---|
| [ca2b83] | 772 |  * \return exit code (0 - successful, all else - something's wrong)
 | 
|---|
 | 773 |  */
 | 
|---|
| [d7d29c] | 774 | static int ParseCommandLineOptions(int argc, char **argv, molecule *&mol, periodentafel *&periode, config& configuration, char *&ConfigFileName, char *&PathToDatabases)
 | 
|---|
| [14de469] | 775 | {
 | 
|---|
| [e9b8bb] | 776 |   Vector x,y,z,n;  // coordinates for absolute point in cell volume
 | 
|---|
| [ca2b83] | 777 |   double *factor; // unit factor if desired
 | 
|---|
| [14de469] | 778 |   ifstream test;
 | 
|---|
 | 779 |   ofstream output;
 | 
|---|
 | 780 |   string line;
 | 
|---|
| [ca2b83] | 781 |   atom *first;
 | 
|---|
| [362b0e] | 782 |   bool SaveFlag = false;
 | 
|---|
| [dd8cf8] | 783 |   int ExitFlag = 0;
 | 
|---|
| [ca2b83] | 784 |   int j;
 | 
|---|
| [edb650] | 785 |   double volume = 0.;
 | 
|---|
| [dbe929] | 786 |   enum ConfigStatus config_present = absent;
 | 
|---|
| [14de469] | 787 |   clock_t start,end;
 | 
|---|
| [73f80e] | 788 |   int argptr;
 | 
|---|
| [d7d29c] | 789 |   PathToDatabases = LocalPath;
 | 
|---|
| [a8bcea6] | 790 | 
 | 
|---|
| [6590bee] | 791 |   if (argc > 1) { // config file specified as option
 | 
|---|
| [73f80e] | 792 |     // 1. : Parse options that just set variables or print help
 | 
|---|
| [ca2b83] | 793 |     argptr = 1;
 | 
|---|
 | 794 |     do {
 | 
|---|
 | 795 |       if (argv[argptr][0] == '-') {
 | 
|---|
| [73f80e] | 796 |         cout << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n";
 | 
|---|
 | 797 |         argptr++;
 | 
|---|
 | 798 |         switch(argv[argptr-1][1]) {
 | 
|---|
 | 799 |           case 'h':
 | 
|---|
 | 800 |           case 'H':
 | 
|---|
 | 801 |           case '?':
 | 
|---|
 | 802 |             cout << "MoleCuilder suite" << endl << "==================" << endl << endl;
 | 
|---|
| [a8bcea6] | 803 |             cout << "Usage: " << argv[0] << "[config file] [-{acefpsthH?vfrp}] [further arguments]" << endl;
 | 
|---|
| [73f80e] | 804 |             cout << "or simply " << argv[0] << " without arguments for interactive session." << endl;
 | 
|---|
 | 805 |             cout << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl;
 | 
|---|
| [f714979] | 806 |             cout << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl;
 | 
|---|
| [ca2b83] | 807 |             cout << "\t-b x1 x2 x3\tCenter atoms in domain with given edge lengths of (x1,x2,x3)." << endl;
 | 
|---|
| [73f80e] | 808 |             cout << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl;
 | 
|---|
| [362b0e] | 809 |             cout << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl;
 | 
|---|
| [1f066fe] | 810 |             cout << "\t-O\tCenter atoms in origin." << endl;
 | 
|---|
| [318bfd] | 811 |             cout << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl;
 | 
|---|
| [d7d29c] | 812 |             cout << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl;
 | 
|---|
| [4f2335] | 813 |             cout << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl;
 | 
|---|
| [362b0e] | 814 |             cout << "\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;
 | 
|---|
| [73f80e] | 815 |             cout << "\t-h/-H/-?\tGive this help screen." << endl;
 | 
|---|
| [68cb0f] | 816 |             cout << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl;
 | 
|---|
| [233e33] | 817 |             cout << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl;
 | 
|---|
| [f714979] | 818 |             cout << "\t-N\tGet non-convex-envelope." << endl;
 | 
|---|
| [a8bcea6] | 819 |             cout << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl;
 | 
|---|
| [73f80e] | 820 |             cout << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl;
 | 
|---|
| [362b0e] | 821 |             cout << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl;
 | 
|---|
| [73f80e] | 822 |             cout << "\t-r\t\tConvert file from an old pcp syntax." << endl;
 | 
|---|
 | 823 |             cout << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl;
 | 
|---|
| [a8bcea6] | 824 |             cout << "\t-T <file> Store temperatures from the config file in <file>." << endl;
 | 
|---|
| [73f80e] | 825 |             cout << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl;
 | 
|---|
| [a8bcea6] | 826 |             cout << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl;
 | 
|---|
| [73f80e] | 827 |             cout << "\t-v/-V\t\tGives version information." << endl;
 | 
|---|
| [5b15ab] | 828 |             cout << "Note: config files must not begin with '-' !" << endl;
 | 
|---|
| [2910e0] | 829 |             delete(mol);
 | 
|---|
 | 830 |             delete(periode);
 | 
|---|
| [ca2b83] | 831 |             return (1);
 | 
|---|
| [73f80e] | 832 |             break;
 | 
|---|
 | 833 |           case 'v':
 | 
|---|
 | 834 |           case 'V':
 | 
|---|
 | 835 |             cout << argv[0] << " " << VERSIONSTRING << endl;
 | 
|---|
 | 836 |             cout << "Build your own molecule position set." << endl;
 | 
|---|
| [2910e0] | 837 |             delete(mol);
 | 
|---|
 | 838 |             delete(periode);
 | 
|---|
| [ca2b83] | 839 |             return (1);
 | 
|---|
| [73f80e] | 840 |             break;
 | 
|---|
 | 841 |           case 'e':
 | 
|---|
| [a8b9d61] | 842 |             if ((argptr >= argc) || (argv[argptr][0] == '-')) {
 | 
|---|
 | 843 |               cerr << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl;
 | 
|---|
 | 844 |             } else {
 | 
|---|
 | 845 |               cout << "Using " << argv[argptr] << " as elements database." << endl;
 | 
|---|
 | 846 |               PathToDatabases = argv[argptr];
 | 
|---|
 | 847 |               argptr+=1;
 | 
|---|
 | 848 |             }
 | 
|---|
| [73f80e] | 849 |             break;
 | 
|---|
| [233e33] | 850 |           case 'n':
 | 
|---|
 | 851 |             cout << "I won't parse trajectories." << endl;
 | 
|---|
 | 852 |             configuration.FastParsing = true;
 | 
|---|
| [256520] | 853 |             break;
 | 
|---|
| [73f80e] | 854 |           default:   // no match? Step on
 | 
|---|
 | 855 |             argptr++;
 | 
|---|
 | 856 |             break;
 | 
|---|
 | 857 |         }
 | 
|---|
| [ca2b83] | 858 |       } else
 | 
|---|
 | 859 |         argptr++;
 | 
|---|
| [4885953] | 860 |     } while (argptr < argc);
 | 
|---|
| [a8bcea6] | 861 | 
 | 
|---|
| [ca2b83] | 862 |     // 2. Parse the element database
 | 
|---|
| [d7d29c] | 863 |     if (periode->LoadPeriodentafel(PathToDatabases)) {
 | 
|---|
| [73f80e] | 864 |       cout << Verbose(0) << "Element list loaded successfully." << endl;
 | 
|---|
| [b61043] | 865 |       //periode->Output((ofstream *)&cout);
 | 
|---|
| [14d4d4] | 866 |     } else {
 | 
|---|
| [73f80e] | 867 |       cout << Verbose(0) << "Element list loading failed." << endl;
 | 
|---|
| [14d4d4] | 868 |       return 1;
 | 
|---|
 | 869 |     }
 | 
|---|
| [a8bcea6] | 870 | 
 | 
|---|
| [ca2b83] | 871 |     // 3. Find config file name and parse if possible
 | 
|---|
| [4885953] | 872 |     if (argv[1][0] != '-') {
 | 
|---|
| [dbe929] | 873 |       cout << Verbose(0) << "Config file given." << endl;
 | 
|---|
| [4885953] | 874 |       test.open(argv[1], ios::in);
 | 
|---|
| [dbe929] | 875 |       if (test == NULL) {
 | 
|---|
 | 876 |         //return (1);
 | 
|---|
| [4885953] | 877 |         output.open(argv[1], ios::out);
 | 
|---|
| [dbe929] | 878 |         if (output == NULL) {
 | 
|---|
| [4885953] | 879 |           cout << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl;
 | 
|---|
| [dbe929] | 880 |           config_present = absent;
 | 
|---|
 | 881 |         } else {
 | 
|---|
 | 882 |           cout << "Empty configuration file." << endl;
 | 
|---|
| [4885953] | 883 |           ConfigFileName = argv[1];
 | 
|---|
| [dbe929] | 884 |           config_present = empty;
 | 
|---|
 | 885 |           output.close();
 | 
|---|
 | 886 |         }
 | 
|---|
 | 887 |       } else {
 | 
|---|
| [5b15ab] | 888 |         test.close();
 | 
|---|
| [4885953] | 889 |         ConfigFileName = argv[1];
 | 
|---|
| [fedd5f] | 890 |         cout << Verbose(1) << "Specified config file found, parsing ... ";
 | 
|---|
| [5b15ab] | 891 |         switch (configuration.TestSyntax(ConfigFileName, periode, mol)) {
 | 
|---|
| [dbe929] | 892 |           case 1:
 | 
|---|
 | 893 |             cout << "new syntax." << endl;
 | 
|---|
| [5b15ab] | 894 |             configuration.Load(ConfigFileName, periode, mol);
 | 
|---|
| [dbe929] | 895 |             config_present = present;
 | 
|---|
 | 896 |             break;
 | 
|---|
 | 897 |           case 0:
 | 
|---|
 | 898 |             cout << "old syntax." << endl;
 | 
|---|
| [5b15ab] | 899 |             configuration.LoadOld(ConfigFileName, periode, mol);
 | 
|---|
| [dbe929] | 900 |             config_present = present;
 | 
|---|
 | 901 |             break;
 | 
|---|
 | 902 |           default:
 | 
|---|
 | 903 |             cout << "Unknown syntax or empty, yet present file." << endl;
 | 
|---|
 | 904 |             config_present = empty;
 | 
|---|
 | 905 |        }
 | 
|---|
| [14de469] | 906 |       }
 | 
|---|
| [73f80e] | 907 |     } else
 | 
|---|
 | 908 |       config_present = absent;
 | 
|---|
| [a8bcea6] | 909 | 
 | 
|---|
| [73f80e] | 910 |     // 4. parse again through options, now for those depending on elements db and config presence
 | 
|---|
 | 911 |     argptr = 1;
 | 
|---|
 | 912 |     do {
 | 
|---|
| [ca2b83] | 913 |       cout << "Current Command line argument: " << argv[argptr] << "." << endl;
 | 
|---|
| [73f80e] | 914 |       if (argv[argptr][0] == '-') {
 | 
|---|
| [dbe929] | 915 |         argptr++;
 | 
|---|
 | 916 |         if ((config_present == present) || (config_present == empty)) {
 | 
|---|
 | 917 |           switch(argv[argptr-1][1]) {
 | 
|---|
 | 918 |             case 'p':
 | 
|---|
| [dd8cf8] | 919 |               ExitFlag = 1;
 | 
|---|
| [a8b9d61] | 920 |               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
 | 
|---|
| [9a5bcd] | 921 |                 ExitFlag = 255;
 | 
|---|
| [a8b9d61] | 922 |                 cerr << "Not enough arguments for parsing: -p <xyz file>" << endl;
 | 
|---|
 | 923 |               } else {
 | 
|---|
 | 924 |                 SaveFlag = true;
 | 
|---|
 | 925 |                 cout << Verbose(1) << "Parsing xyz file for new atoms." << endl;
 | 
|---|
 | 926 |                 if (!mol->AddXYZFile(argv[argptr]))
 | 
|---|
 | 927 |                   cout << Verbose(2) << "File not found." << endl;
 | 
|---|
 | 928 |                 else {
 | 
|---|
 | 929 |                   cout << Verbose(2) << "File found and parsed." << endl;
 | 
|---|
 | 930 |                   config_present = present;
 | 
|---|
 | 931 |                 }
 | 
|---|
| [d7e30c] | 932 |               }
 | 
|---|
| [14de469] | 933 |               break;
 | 
|---|
| [d1fc7f] | 934 |             case 'a':
 | 
|---|
 | 935 |               ExitFlag = 1;
 | 
|---|
| [a8b9d61] | 936 |               if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1]))) {
 | 
|---|
| [9a5bcd] | 937 |                 ExitFlag = 255;
 | 
|---|
| [a8b9d61] | 938 |                 cerr << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl;
 | 
|---|
 | 939 |               } else {
 | 
|---|
 | 940 |                 SaveFlag = true;
 | 
|---|
 | 941 |                 cout << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), ";
 | 
|---|
 | 942 |                 first = new atom;
 | 
|---|
 | 943 |                 first->type = periode->FindElement(atoi(argv[argptr]));
 | 
|---|
 | 944 |                 if (first->type != NULL)
 | 
|---|
 | 945 |                   cout << Verbose(2) << "found element " << first->type->name << endl;
 | 
|---|
 | 946 |                 for (int i=NDIM;i--;)
 | 
|---|
 | 947 |                   first->x.x[i] = atof(argv[argptr+1+i]);
 | 
|---|
 | 948 |                 if (first->type != NULL) {
 | 
|---|
 | 949 |                   mol->AddAtom(first);  // add to molecule
 | 
|---|
 | 950 |                   if ((config_present == empty) && (mol->AtomCount != 0))
 | 
|---|
 | 951 |                     config_present = present;
 | 
|---|
 | 952 |                 } else
 | 
|---|
| [a8bcea6] | 953 |                   cerr << Verbose(1) << "Could not find the specified element." << endl;
 | 
|---|
| [a8b9d61] | 954 |                 argptr+=4;
 | 
|---|
 | 955 |               }
 | 
|---|
| [d1fc7f] | 956 |               break;
 | 
|---|
| [73f80e] | 957 |             default:   // no match? Don't step on (this is done in next switch's default)
 | 
|---|
| [14de469] | 958 |               break;
 | 
|---|
| [dbe929] | 959 |           }
 | 
|---|
 | 960 |         }
 | 
|---|
| [ca2b83] | 961 |         if (config_present == present) {
 | 
|---|
 | 962 |           switch(argv[argptr-1][1]) {
 | 
|---|
| [a8bcea6] | 963 |             case 'D':
 | 
|---|
| [dd8cf8] | 964 |               ExitFlag = 1;
 | 
|---|
| [362b0e] | 965 |               {
 | 
|---|
 | 966 |                 cout << Verbose(1) << "Depth-First-Search Analysis." << endl;
 | 
|---|
 | 967 |                 MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
 | 
|---|
| [3ccc3e] | 968 |                 int *MinimumRingSize = new int[mol->AtomCount];
 | 
|---|
 | 969 |                 atom ***ListOfLocalAtoms = NULL;
 | 
|---|
 | 970 |                 int FragmentCounter = 0;
 | 
|---|
 | 971 |                 class StackClass<bond *> *BackEdgeStack = NULL;
 | 
|---|
 | 972 |                 class StackClass<bond *> *LocalBackEdgeStack = NULL;
 | 
|---|
| [698b04] | 973 |                 mol->CreateAdjacencyList((ofstream *)&cout, atof(argv[argptr]), configuration.GetIsAngstroem());
 | 
|---|
| [362b0e] | 974 |                 mol->CreateListOfBondsPerAtom((ofstream *)&cout);
 | 
|---|
| [3ccc3e] | 975 |                 Subgraphs = mol->DepthFirstSearchAnalysis((ofstream *)&cout, BackEdgeStack);
 | 
|---|
| [362b0e] | 976 |                 if (Subgraphs != NULL) {
 | 
|---|
| [3ccc3e] | 977 |                   Subgraphs->next->FillBondStructureFromReference((ofstream *)&cout, mol, (FragmentCounter = 0), ListOfLocalAtoms, false);  // we want to keep the created ListOfLocalAtoms
 | 
|---|
| [362b0e] | 978 |                   while (Subgraphs->next != NULL) {
 | 
|---|
 | 979 |                     Subgraphs = Subgraphs->next;
 | 
|---|
| [3ccc3e] | 980 |                     LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
 | 
|---|
 | 981 |                     Subgraphs->Leaf->PickLocalBackEdges((ofstream *)&cout, ListOfLocalAtoms[FragmentCounter++], BackEdgeStack, LocalBackEdgeStack);
 | 
|---|
 | 982 |                     Subgraphs->Leaf->CyclicStructureAnalysis((ofstream *)&cout, BackEdgeStack, MinimumRingSize);
 | 
|---|
 | 983 |                     delete(LocalBackEdgeStack);
 | 
|---|
| [362b0e] | 984 |                     delete(Subgraphs->previous);
 | 
|---|
 | 985 |                   }
 | 
|---|
 | 986 |                   delete(Subgraphs);
 | 
|---|
| [3ccc3e] | 987 |                   for (int i=0;i<FragmentCounter;i++)
 | 
|---|
 | 988 |                     Free((void **)&ListOfLocalAtoms[FragmentCounter], "ParseCommandLineOptions: **ListOfLocalAtoms[]");
 | 
|---|
 | 989 |                   Free((void **)&ListOfLocalAtoms, "ParseCommandLineOptions: ***ListOfLocalAtoms");
 | 
|---|
| [362b0e] | 990 |                 }
 | 
|---|
| [3ccc3e] | 991 |                 delete(BackEdgeStack);
 | 
|---|
 | 992 |                 delete[](MinimumRingSize);
 | 
|---|
| [362b0e] | 993 |               }
 | 
|---|
| [a8b9d61] | 994 |               //argptr+=1;
 | 
|---|
| [698b04] | 995 |               break;
 | 
|---|
| [4f2335] | 996 |             case 'E':
 | 
|---|
 | 997 |               ExitFlag = 1;
 | 
|---|
| [a8b9d61] | 998 |               if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) {
 | 
|---|
| [9a5bcd] | 999 |                 ExitFlag = 255;
 | 
|---|
| [a8b9d61] | 1000 |                 cerr << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl;
 | 
|---|
 | 1001 |               } else {
 | 
|---|
 | 1002 |                 SaveFlag = true;
 | 
|---|
 | 1003 |                 cout << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl;
 | 
|---|
 | 1004 |                 first = mol->FindAtom(atoi(argv[argptr]));
 | 
|---|
 | 1005 |                 first->type = periode->FindElement(atoi(argv[argptr+1]));
 | 
|---|
 | 1006 |                 argptr+=2;
 | 
|---|
 | 1007 |               }
 | 
|---|
| [4f2335] | 1008 |               break;
 | 
|---|
| [cc2ee5] | 1009 |                                                 case 'A':
 | 
|---|
 | 1010 |                                                         ExitFlag = 1;
 | 
|---|
 | 1011 |                                                         if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr][0] == '-')) {
 | 
|---|
 | 1012 |                                                                 ExitFlag =255;
 | 
|---|
 | 1013 |                                                                 cerr << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl;
 | 
|---|
 | 1014 |                                                         } else {
 | 
|---|
 | 1015 |                                                                 cout << "Parsing bonds from " << argv[argptr] << "." << endl;
 | 
|---|
 | 1016 |                                                                 ifstream *input = new ifstream(argv[argptr]);
 | 
|---|
 | 1017 |                                                                 mol->CreateAdjacencyList2((ofstream *)&cout, input);
 | 
|---|
 | 1018 |                                                                 input->close();
 | 
|---|
 | 1019 |                                                         }
 | 
|---|
 | 1020 |                                                         break;
 | 
|---|
 | 1021 |                                                 case 'N':
 | 
|---|
 | 1022 |                                                         ExitFlag = 1;
 | 
|---|
 | 1023 |                                                         if ((argptr+1 >= argc) || (argv[argptr+1][0] == '-')){
 | 
|---|
 | 1024 |                                                                 ExitFlag = 255;
 | 
|---|
 | 1025 |                                                                 cerr << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl;
 | 
|---|
 | 1026 |                                                         } else {
 | 
|---|
 | 1027 |                                                                 cout << Verbose(0) << "Evaluating npn-convex envelope.";
 | 
|---|
 | 1028 |                                                                 string TempName(argv[argptr+1]);
 | 
|---|
 | 1029 |                                                                 TempName.append(".r3d");
 | 
|---|
 | 1030 |                                                                 ofstream *output = new ofstream(TempName.c_str(), ios::trunc);
 | 
|---|
 | 1031 |                                                                 cout << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl;
 | 
|---|
 | 1032 |                                                                 Find_non_convex_border((ofstream *)&cout, output, mol, argv[argptr+1], atof(argv[argptr]));
 | 
|---|
 | 1033 |                                                                 output->close();
 | 
|---|
 | 1034 |                                                                 delete(output);
 | 
|---|
 | 1035 |                                                                 argptr+=2;
 | 
|---|
 | 1036 |                                                         }
 | 
|---|
 | 1037 |                                                         break;
 | 
|---|
| [4f2335] | 1038 |             case 'T':
 | 
|---|
| [698b04] | 1039 |               ExitFlag = 1;
 | 
|---|
| [a8b9d61] | 1040 |               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
 | 
|---|
| [9a5bcd] | 1041 |                 ExitFlag = 255;
 | 
|---|
| [a8b9d61] | 1042 |                 cerr << "Not enough or invalid arguments given for storing tempature: -T <temperature file>" << endl;
 | 
|---|
 | 1043 |               } else {
 | 
|---|
| [698b04] | 1044 |                 cout << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl;
 | 
|---|
 | 1045 |                 ofstream *output = new ofstream(argv[argptr], ios::trunc);
 | 
|---|
 | 1046 |                 if (!mol->OutputTemperatureFromTrajectories((ofstream *)&cout, 0, mol->MDSteps, output))
 | 
|---|
 | 1047 |                   cout << Verbose(2) << "File could not be written." << endl;
 | 
|---|
 | 1048 |                 else
 | 
|---|
 | 1049 |                   cout << Verbose(2) << "File stored." << endl;
 | 
|---|
 | 1050 |                 output->close();
 | 
|---|
 | 1051 |                 delete(output);
 | 
|---|
| [a8b9d61] | 1052 |                 argptr+=1;
 | 
|---|
| [698b04] | 1053 |               }
 | 
|---|
| [362b0e] | 1054 |               break;
 | 
|---|
| [d7e30c] | 1055 |             case 'P':
 | 
|---|
| [dd8cf8] | 1056 |               ExitFlag = 1;
 | 
|---|
| [a8b9d61] | 1057 |               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
 | 
|---|
| [9a5bcd] | 1058 |                 ExitFlag = 255;
 | 
|---|
| [a8b9d61] | 1059 |                 cerr << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl;
 | 
|---|
 | 1060 |               } else {
 | 
|---|
 | 1061 |                 SaveFlag = true;
 | 
|---|
 | 1062 |                 cout << Verbose(1) << "Parsing forces file and Verlet integrating." << endl;
 | 
|---|
 | 1063 |                 if (!mol->VerletForceIntegration(argv[argptr], configuration.Deltat, configuration.GetIsAngstroem()))
 | 
|---|
 | 1064 |                   cout << Verbose(2) << "File not found." << endl;
 | 
|---|
 | 1065 |                 else
 | 
|---|
 | 1066 |                   cout << Verbose(2) << "File found and parsed." << endl;
 | 
|---|
 | 1067 |                 argptr+=1;
 | 
|---|
 | 1068 |               }
 | 
|---|
| [d7e30c] | 1069 |               break;
 | 
|---|
| [ca2b83] | 1070 |             case 't':
 | 
|---|
| [dd8cf8] | 1071 |               ExitFlag = 1;
 | 
|---|
| [a8b9d61] | 1072 |               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
 | 
|---|
| [9a5bcd] | 1073 |                 ExitFlag = 255;
 | 
|---|
| [a8b9d61] | 1074 |                 cerr << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl;
 | 
|---|
 | 1075 |               } else {
 | 
|---|
 | 1076 |                 ExitFlag = 1;
 | 
|---|
 | 1077 |                 SaveFlag = true;
 | 
|---|
 | 1078 |                 cout << Verbose(1) << "Translating all ions to new origin." << endl;
 | 
|---|
 | 1079 |                 for (int i=NDIM;i--;)
 | 
|---|
 | 1080 |                   x.x[i] = atof(argv[argptr+i]);
 | 
|---|
 | 1081 |                 mol->Translate((const Vector *)&x);
 | 
|---|
 | 1082 |                 argptr+=3;
 | 
|---|
 | 1083 |               }
 | 
|---|
| [ca2b83] | 1084 |               break;
 | 
|---|
 | 1085 |             case 's':
 | 
|---|
| [dd8cf8] | 1086 |               ExitFlag = 1;
 | 
|---|
| [a8b9d61] | 1087 |               if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) ) {
 | 
|---|
| [9a5bcd] | 1088 |                 ExitFlag = 255;
 | 
|---|
| [a8b9d61] | 1089 |                 cerr << "Not enough or invalid arguments given for scaling: -s <factor/[factor_x]> [factor_y] [factor_z]" << endl;
 | 
|---|
 | 1090 |               } else {
 | 
|---|
 | 1091 |                 SaveFlag = true;
 | 
|---|
 | 1092 |                 j = -1;
 | 
|---|
 | 1093 |                 cout << Verbose(1) << "Scaling all ion positions by factor." << endl;
 | 
|---|
 | 1094 |                 factor = new double[NDIM];
 | 
|---|
 | 1095 |                 factor[0] = atof(argv[argptr]);
 | 
|---|
 | 1096 |                 if ((argptr < argc) && (IsValidNumber(argv[argptr])))
 | 
|---|
 | 1097 |                   argptr++;
 | 
|---|
 | 1098 |                 factor[1] = atof(argv[argptr]);
 | 
|---|
 | 1099 |                 if ((argptr < argc) && (IsValidNumber(argv[argptr])))
 | 
|---|
 | 1100 |                   argptr++;
 | 
|---|
 | 1101 |                 factor[2] = atof(argv[argptr]);
 | 
|---|
 | 1102 |                 mol->Scale(&factor);
 | 
|---|
 | 1103 |                 for (int i=0;i<NDIM;i++) {
 | 
|---|
 | 1104 |                   j += i+1;
 | 
|---|
 | 1105 |                   x.x[i] = atof(argv[NDIM+i]);
 | 
|---|
 | 1106 |                   mol->cell_size[j]*=factor[i];
 | 
|---|
 | 1107 |                 }
 | 
|---|
 | 1108 |                 delete[](factor);
 | 
|---|
 | 1109 |                 argptr+=1;
 | 
|---|
| [ca2b83] | 1110 |               }
 | 
|---|
 | 1111 |               break;
 | 
|---|
 | 1112 |             case 'b':
 | 
|---|
| [dd8cf8] | 1113 |               ExitFlag = 1;
 | 
|---|
| [a8b9d61] | 1114 |               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
 | 
|---|
| [9a5bcd] | 1115 |                 ExitFlag = 255;
 | 
|---|
| [a8b9d61] | 1116 |                 cerr << "Not enough or invalid arguments given for centering in box: -b <length_x> <length_y> <length_z>" << endl;
 | 
|---|
 | 1117 |               } else {
 | 
|---|
 | 1118 |                 SaveFlag = true;
 | 
|---|
 | 1119 |                 j = -1;
 | 
|---|
 | 1120 |                 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
 | 
|---|
 | 1121 |                 j=-1;
 | 
|---|
 | 1122 |                 for (int i=0;i<NDIM;i++) {
 | 
|---|
 | 1123 |                   j += i+1;
 | 
|---|
 | 1124 |                   x.x[i] = atof(argv[argptr++]);
 | 
|---|
 | 1125 |                   mol->cell_size[j] += x.x[i]*2.;
 | 
|---|
 | 1126 |                 }
 | 
|---|
 | 1127 |                 // center
 | 
|---|
 | 1128 |                 mol->CenterInBox((ofstream *)&cout, &x);
 | 
|---|
 | 1129 |                 // update Box of atoms by boundary
 | 
|---|
 | 1130 |                 mol->SetBoxDimension(&x);
 | 
|---|
| [ca2b83] | 1131 |               }
 | 
|---|
 | 1132 |               break;
 | 
|---|
 | 1133 |             case 'c':
 | 
|---|
| [dd8cf8] | 1134 |               ExitFlag = 1;
 | 
|---|
| [a8b9d61] | 1135 |               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
 | 
|---|
| [9a5bcd] | 1136 |                 ExitFlag = 255;
 | 
|---|
| [a8b9d61] | 1137 |                 cerr << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl;
 | 
|---|
 | 1138 |               } else {
 | 
|---|
 | 1139 |                 SaveFlag = true;
 | 
|---|
 | 1140 |                 j = -1;
 | 
|---|
 | 1141 |                 cout << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl;
 | 
|---|
 | 1142 |                 // make every coordinate positive
 | 
|---|
 | 1143 |                 mol->CenterEdge((ofstream *)&cout, &x);
 | 
|---|
 | 1144 |                 // update Box of atoms by boundary
 | 
|---|
 | 1145 |                 mol->SetBoxDimension(&x);
 | 
|---|
 | 1146 |                 // translate each coordinate by boundary
 | 
|---|
 | 1147 |                 j=-1;
 | 
|---|
 | 1148 |                 for (int i=0;i<NDIM;i++) {
 | 
|---|
 | 1149 |                   j += i+1;
 | 
|---|
 | 1150 |                   x.x[i] = atof(argv[argptr++]);
 | 
|---|
 | 1151 |                   mol->cell_size[j] += x.x[i]*2.;
 | 
|---|
 | 1152 |                 }
 | 
|---|
 | 1153 |                 mol->Translate((const Vector *)&x);
 | 
|---|
| [ca2b83] | 1154 |               }
 | 
|---|
 | 1155 |               break;
 | 
|---|
| [1f066fe] | 1156 |             case 'O':
 | 
|---|
| [dd8cf8] | 1157 |               ExitFlag = 1;
 | 
|---|
| [362b0e] | 1158 |               SaveFlag = true;
 | 
|---|
| [1f066fe] | 1159 |               cout << Verbose(1) << "Centering atoms in origin." << endl;
 | 
|---|
 | 1160 |               mol->CenterOrigin((ofstream *)&cout, &x);
 | 
|---|
 | 1161 |               mol->SetBoxDimension(&x);
 | 
|---|
 | 1162 |               break;
 | 
|---|
| [ca2b83] | 1163 |             case 'r':
 | 
|---|
| [dd8cf8] | 1164 |               ExitFlag = 1;
 | 
|---|
| [362b0e] | 1165 |               SaveFlag = true;
 | 
|---|
| [ca2b83] | 1166 |               cout << Verbose(1) << "Converting config file from supposed old to new syntax." << endl;
 | 
|---|
 | 1167 |               break;
 | 
|---|
| [d7e30c] | 1168 |             case 'F':
 | 
|---|
| [ca2b83] | 1169 |             case 'f':
 | 
|---|
| [dd8cf8] | 1170 |               ExitFlag = 1;
 | 
|---|
| [a8b9d61] | 1171 |               if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {
 | 
|---|
| [9a5bcd] | 1172 |                 ExitFlag = 255;
 | 
|---|
| [a8b9d61] | 1173 |                 cerr << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl;
 | 
|---|
 | 1174 |               } else {
 | 
|---|
 | 1175 |                 cout << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl;
 | 
|---|
| [ca2b83] | 1176 |                 cout << Verbose(0) << "Creating connection matrix..." << endl;
 | 
|---|
 | 1177 |                 start = clock();
 | 
|---|
| [a251a3] | 1178 |                 mol->CreateAdjacencyList((ofstream *)&cout, atof(argv[argptr++]), configuration.GetIsAngstroem());
 | 
|---|
| [ca2b83] | 1179 |                 cout << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
 | 
|---|
 | 1180 |                 if (mol->first->next != mol->last) {
 | 
|---|
| [362b0e] | 1181 |                   ExitFlag = mol->FragmentMolecule((ofstream *)&cout, atoi(argv[argptr]), &configuration);
 | 
|---|
| [dbe929] | 1182 |                 }
 | 
|---|
| [ca2b83] | 1183 |                 end = clock();
 | 
|---|
 | 1184 |                 cout << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
 | 
|---|
| [a8b9d61] | 1185 |                 argptr+=2;
 | 
|---|
| [ca2b83] | 1186 |               }
 | 
|---|
 | 1187 |               break;
 | 
|---|
| [d52ea1b] | 1188 |             case 'm':
 | 
|---|
| [dd8cf8] | 1189 |               ExitFlag = 1;
 | 
|---|
| [110ceb] | 1190 |               j = atoi(argv[argptr++]);
 | 
|---|
 | 1191 |               if ((j<0) || (j>1)) {
 | 
|---|
 | 1192 |                 cerr << Verbose(1) << "ERROR: Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl;
 | 
|---|
 | 1193 |                 j = 0;
 | 
|---|
 | 1194 |               }
 | 
|---|
| [362b0e] | 1195 |               if (j) {
 | 
|---|
 | 1196 |                 SaveFlag = true;
 | 
|---|
| [110ceb] | 1197 |                 cout << Verbose(0) << "Converting to prinicipal axis system." << endl;
 | 
|---|
| [362b0e] | 1198 |               } else
 | 
|---|
| [110ceb] | 1199 |                 cout << Verbose(0) << "Evaluating prinicipal axis." << endl;
 | 
|---|
 | 1200 |               mol->PrincipalAxisSystem((ofstream *)&cout, (bool)j);
 | 
|---|
 | 1201 |               break;
 | 
|---|
 | 1202 |             case 'o':
 | 
|---|
| [dd8cf8] | 1203 |               ExitFlag = 1;
 | 
|---|
| [a8bcea6] | 1204 |               if ((argptr >= argc) || (argv[argptr][0] == '-')){
 | 
|---|
| [450d63] | 1205 |                 ExitFlag = 255;
 | 
|---|
 | 1206 |                 cerr << "Not enough or invalid arguments given for convex envelope: -o <tecplot output file>" << endl;
 | 
|---|
 | 1207 |               } else {
 | 
|---|
 | 1208 |                 cout << Verbose(0) << "Evaluating volume of the convex envelope.";
 | 
|---|
 | 1209 |                 ofstream *output = new ofstream(argv[argptr], ios::trunc);
 | 
|---|
| [a8bcea6] | 1210 |                 //$$$
 | 
|---|
 | 1211 |                 cout << Verbose(1) << "Storing tecplot data in " << argv[argptr] << "." << endl;
 | 
|---|
| [450d63] | 1212 |                 VolumeOfConvexEnvelope((ofstream *)&cout, output, &configuration, NULL, mol);
 | 
|---|
 | 1213 |                 output->close();
 | 
|---|
 | 1214 |                 delete(output);
 | 
|---|
 | 1215 |                 argptr+=1;
 | 
|---|
 | 1216 |               }
 | 
|---|
| [d52ea1b] | 1217 |               break;
 | 
|---|
| [edb650] | 1218 |             case 'U':
 | 
|---|
| [dd8cf8] | 1219 |               ExitFlag = 1;
 | 
|---|
| [a8b9d61] | 1220 |               if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) {
 | 
|---|
| [9a5bcd] | 1221 |                 ExitFlag = 255;
 | 
|---|
| [a8b9d61] | 1222 |                 cerr << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl;
 | 
|---|
 | 1223 |                 volume = -1; // for case 'u': don't print error again
 | 
|---|
 | 1224 |               } else {
 | 
|---|
 | 1225 |                 volume = atof(argv[argptr++]);
 | 
|---|
 | 1226 |                 cout << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl;
 | 
|---|
 | 1227 |               }
 | 
|---|
| [318bfd] | 1228 |             case 'u':
 | 
|---|
| [dd8cf8] | 1229 |               ExitFlag = 1;
 | 
|---|
| [a8b9d61] | 1230 |               if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) ) {
 | 
|---|
 | 1231 |                 if (volume != -1)
 | 
|---|
| [9a5bcd] | 1232 |                   ExitFlag = 255;
 | 
|---|
| [a8b9d61] | 1233 |                   cerr << "Not enough arguments given for suspension: -u <density>" << endl;
 | 
|---|
 | 1234 |               } else {
 | 
|---|
| [edb650] | 1235 |                 double density;
 | 
|---|
| [362b0e] | 1236 |                 SaveFlag = true;
 | 
|---|
| [318bfd] | 1237 |                 cout << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.";
 | 
|---|
| [edb650] | 1238 |                 density = atof(argv[argptr++]);
 | 
|---|
 | 1239 |                 if (density < 1.0) {
 | 
|---|
| [318bfd] | 1240 |                   cerr << Verbose(0) << "Density must be greater than 1.0g/cm^3 !" << endl;
 | 
|---|
| [edb650] | 1241 |                   density = 1.3;
 | 
|---|
| [318bfd] | 1242 |                 }
 | 
|---|
 | 1243 | //                for(int i=0;i<NDIM;i++) {
 | 
|---|
 | 1244 | //                  repetition[i] = atoi(argv[argptr++]);
 | 
|---|
 | 1245 | //                  if (repetition[i] < 1)
 | 
|---|
 | 1246 | //                    cerr << Verbose(0) << "ERROR: repetition value must be greater 1!" << endl;
 | 
|---|
 | 1247 | //                  repetition[i] = 1;
 | 
|---|
 | 1248 | //                }
 | 
|---|
| [a8b9d61] | 1249 |                 PrepareClustersinWater((ofstream *)&cout, &configuration, mol, volume, density);  // if volume == 0, will calculate from ConvexEnvelope
 | 
|---|
| [318bfd] | 1250 |               }
 | 
|---|
 | 1251 |               break;
 | 
|---|
 | 1252 |             case 'd':
 | 
|---|
| [dd8cf8] | 1253 |               ExitFlag = 1;
 | 
|---|
| [a8b9d61] | 1254 |               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
 | 
|---|
| [9a5bcd] | 1255 |                 ExitFlag = 255;
 | 
|---|
| [a8b9d61] | 1256 |                 cerr << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl;
 | 
|---|
 | 1257 |               } else {
 | 
|---|
 | 1258 |                 SaveFlag = true;
 | 
|---|
 | 1259 |                 for (int axis = 1; axis <= NDIM; axis++) {
 | 
|---|
 | 1260 |                   int faktor = atoi(argv[argptr++]);
 | 
|---|
 | 1261 |                   int count;
 | 
|---|
 | 1262 |                   element ** Elements;
 | 
|---|
 | 1263 |                   Vector ** vectors;
 | 
|---|
 | 1264 |                   if (faktor < 1) {
 | 
|---|
 | 1265 |                     cerr << Verbose(0) << "ERROR: Repetition faktor mus be greater than 1!" << endl;
 | 
|---|
 | 1266 |                     faktor = 1;
 | 
|---|
| [318bfd] | 1267 |                   }
 | 
|---|
| [a8b9d61] | 1268 |                   mol->CountAtoms((ofstream *)&cout);  // recount atoms
 | 
|---|
 | 1269 |                   if (mol->AtomCount != 0) {  // if there is more than none
 | 
|---|
 | 1270 |                     count = mol->AtomCount;   // is changed becausing of adding, thus has to be stored away beforehand
 | 
|---|
 | 1271 |                     Elements = new element *[count];
 | 
|---|
 | 1272 |                     vectors = new Vector *[count];
 | 
|---|
 | 1273 |                     j = 0;
 | 
|---|
 | 1274 |                     first = mol->start;
 | 
|---|
 | 1275 |                     while (first->next != mol->end) {  // make a list of all atoms with coordinates and element
 | 
|---|
 | 1276 |                       first = first->next;
 | 
|---|
 | 1277 |                       Elements[j] = first->type;
 | 
|---|
 | 1278 |                       vectors[j] = &first->x;
 | 
|---|
 | 1279 |                       j++;
 | 
|---|
| [318bfd] | 1280 |                     }
 | 
|---|
| [a8b9d61] | 1281 |                     if (count != j)
 | 
|---|
 | 1282 |                       cout << Verbose(0) << "ERROR: AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
 | 
|---|
| [318bfd] | 1283 |                     x.Zero();
 | 
|---|
| [a8b9d61] | 1284 |                     y.Zero();
 | 
|---|
 | 1285 |                     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
 | 
|---|
 | 1286 |                     for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
 | 
|---|
 | 1287 |                       x.AddVector(&y); // per factor one cell width further
 | 
|---|
 | 1288 |                       for (int k=count;k--;) { // go through every atom of the original cell
 | 
|---|
 | 1289 |                         first = new atom(); // create a new body
 | 
|---|
 | 1290 |                         first->x.CopyVector(vectors[k]);  // use coordinate of original atom
 | 
|---|
 | 1291 |                         first->x.AddVector(&x);      // translate the coordinates
 | 
|---|
 | 1292 |                         first->type = Elements[k];  // insert original element
 | 
|---|
 | 1293 |                         mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
 | 
|---|
 | 1294 |                       }
 | 
|---|
 | 1295 |                     }
 | 
|---|
 | 1296 |                     // free memory
 | 
|---|
 | 1297 |                     delete[](Elements);
 | 
|---|
 | 1298 |                     delete[](vectors);
 | 
|---|
 | 1299 |                     // correct cell size
 | 
|---|
 | 1300 |                     if (axis < 0) { // if sign was negative, we have to translate everything
 | 
|---|
 | 1301 |                       x.Zero();
 | 
|---|
 | 1302 |                       x.AddVector(&y);
 | 
|---|
 | 1303 |                       x.Scale(-(faktor-1));
 | 
|---|
 | 1304 |                       mol->Translate(&x);
 | 
|---|
 | 1305 |                     }
 | 
|---|
| [a8bcea6] | 1306 |                     mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
 | 
|---|
| [318bfd] | 1307 |                   }
 | 
|---|
 | 1308 |                 }
 | 
|---|
 | 1309 |               }
 | 
|---|
 | 1310 |               break;
 | 
|---|
| [ca2b83] | 1311 |             default:   // no match? Step on
 | 
|---|
| [4f2335] | 1312 |               if ((argptr < argc) && (argv[argptr][0] != '-')) // if it started with a '-' we've already made a step!
 | 
|---|
| [110ceb] | 1313 |                 argptr++;
 | 
|---|
| [ca2b83] | 1314 |               break;
 | 
|---|
| [14de469] | 1315 |           }
 | 
|---|
 | 1316 |         }
 | 
|---|
| [ca2b83] | 1317 |       } else argptr++;
 | 
|---|
 | 1318 |     } while (argptr < argc);
 | 
|---|
| [362b0e] | 1319 |     if (SaveFlag)
 | 
|---|
| [dbe929] | 1320 |       SaveConfig(ConfigFileName, &configuration, periode, mol);
 | 
|---|
| [362b0e] | 1321 |     if ((ExitFlag >= 1)) {
 | 
|---|
| [5b15ab] | 1322 |       delete(mol);
 | 
|---|
 | 1323 |       delete(periode);
 | 
|---|
| [362b0e] | 1324 |       return (ExitFlag);
 | 
|---|
| [5b15ab] | 1325 |     }
 | 
|---|
| [6590bee] | 1326 |   } else {  // no arguments, hence scan the elements db
 | 
|---|
| [d7d29c] | 1327 |     if (periode->LoadPeriodentafel(PathToDatabases))
 | 
|---|
| [6590bee] | 1328 |       cout << Verbose(0) << "Element list loaded successfully." << endl;
 | 
|---|
 | 1329 |     else
 | 
|---|
 | 1330 |       cout << Verbose(0) << "Element list loading failed." << endl;
 | 
|---|
 | 1331 |     configuration.RetrieveConfigPathAndName("main_pcp_linux");
 | 
|---|
| [14de469] | 1332 |   }
 | 
|---|
| [ca2b83] | 1333 |   return(0);
 | 
|---|
 | 1334 | };
 | 
|---|
 | 1335 | 
 | 
|---|
 | 1336 | /********************************************** Main routine **************************************/
 | 
|---|
| [14de469] | 1337 | 
 | 
|---|
| [ca2b83] | 1338 | int main(int argc, char **argv)
 | 
|---|
 | 1339 | {
 | 
|---|
 | 1340 |   periodentafel *periode = new periodentafel; // and a period table of all elements
 | 
|---|
 | 1341 |   molecule *mol = new molecule(periode);    // first we need an empty molecule
 | 
|---|
 | 1342 |   config configuration;
 | 
|---|
 | 1343 |   double tmp1;
 | 
|---|
 | 1344 |   double bond, min_bond;
 | 
|---|
 | 1345 |   atom *first, *second;
 | 
|---|
 | 1346 |   char choice;  // menu choice char
 | 
|---|
| [e9b8bb] | 1347 |   Vector x,y,z,n;  // coordinates for absolute point in cell volume
 | 
|---|
| [ca2b83] | 1348 |         double *factor; // unit factor if desired
 | 
|---|
 | 1349 |   bool valid; // flag if input was valid or not
 | 
|---|
 | 1350 |   ifstream test;
 | 
|---|
 | 1351 |   ofstream output;
 | 
|---|
 | 1352 |   string line;
 | 
|---|
 | 1353 |   char filename[MAXSTRINGSIZE];
 | 
|---|
 | 1354 |   char *ConfigFileName = NULL;
 | 
|---|
 | 1355 |   char *ElementsFileName = NULL;
 | 
|---|
 | 1356 |   int Z;
 | 
|---|
 | 1357 |   int j, axis, count, faktor;
 | 
|---|
 | 1358 |   clock_t start,end;
 | 
|---|
| [3ccc3e] | 1359 | //  int *MinimumRingSize = NULL;
 | 
|---|
 | 1360 |   MoleculeLeafClass *Subgraphs = NULL;
 | 
|---|
 | 1361 | //  class StackClass<bond *> *BackEdgeStack = NULL;
 | 
|---|
| [ca2b83] | 1362 |   element **Elements;
 | 
|---|
| [e9b8bb] | 1363 |   Vector **vectors;
 | 
|---|
| [ca2b83] | 1364 | 
 | 
|---|
 | 1365 |   // =========================== PARSE COMMAND LINE OPTIONS ====================================
 | 
|---|
 | 1366 |   j = ParseCommandLineOptions(argc, argv, mol, periode, configuration, ConfigFileName, ElementsFileName);
 | 
|---|
| [d7d29c] | 1367 |   if (j == 1) return 0; // just for -v and -h options
 | 
|---|
| [ca2b83] | 1368 |   if (j) return j;  // something went wrong
 | 
|---|
| [a8bcea6] | 1369 | 
 | 
|---|
| [14de469] | 1370 |   // General stuff
 | 
|---|
 | 1371 |   if (mol->cell_size[0] == 0.) {
 | 
|---|
 | 1372 |     cout << Verbose(0) << "enter lower triadiagonal form of basis matrix" << endl << endl;
 | 
|---|
 | 1373 |     for (int i=0;i<6;i++) {
 | 
|---|
 | 1374 |       cout << Verbose(1) << "Cell size" << i << ": ";
 | 
|---|
 | 1375 |       cin >> mol->cell_size[i];
 | 
|---|
 | 1376 |     }
 | 
|---|
 | 1377 |   }
 | 
|---|
 | 1378 | 
 | 
|---|
| [73f80e] | 1379 |   // =========================== START INTERACTIVE SESSION ====================================
 | 
|---|
 | 1380 | 
 | 
|---|
| [14de469] | 1381 |   // now the main construction loop
 | 
|---|
 | 1382 |   cout << Verbose(0) << endl << "Now comes the real construction..." << endl;
 | 
|---|
| [a8bcea6] | 1383 |   do {
 | 
|---|
| [14de469] | 1384 |     cout << Verbose(0) << endl << endl;
 | 
|---|
 | 1385 |     cout << Verbose(0) << "============Element list=======================" << endl;
 | 
|---|
 | 1386 |     mol->Checkout((ofstream *)&cout);
 | 
|---|
 | 1387 |     cout << Verbose(0) << "============Atom list==========================" << endl;
 | 
|---|
 | 1388 |     mol->Output((ofstream *)&cout);
 | 
|---|
 | 1389 |     cout << Verbose(0) << "============Menu===============================" << endl;
 | 
|---|
 | 1390 |     cout << Verbose(0) << "a - add an atom" << endl;
 | 
|---|
 | 1391 |     cout << Verbose(0) << "r - remove an atom" << endl;
 | 
|---|
 | 1392 |     cout << Verbose(0) << "b - scale a bond between atoms" << endl;
 | 
|---|
 | 1393 |     cout << Verbose(0) << "u - change an atoms element" << endl;
 | 
|---|
 | 1394 |     cout << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl;
 | 
|---|
 | 1395 |     cout << Verbose(0) << "-----------------------------------------------" << endl;
 | 
|---|
 | 1396 |     cout << Verbose(0) << "p - Parse xyz file" << endl;
 | 
|---|
 | 1397 |     cout << Verbose(0) << "e - edit the current configuration" << endl;
 | 
|---|
 | 1398 |     cout << Verbose(0) << "o - create connection matrix" << endl;
 | 
|---|
 | 1399 |     cout << Verbose(0) << "f - fragment molecule many-body bond order style" << endl;
 | 
|---|
 | 1400 |     cout << Verbose(0) << "-----------------------------------------------" << endl;
 | 
|---|
 | 1401 |     cout << Verbose(0) << "d - duplicate molecule/periodic cell" << endl;
 | 
|---|
| [a8bcea6] | 1402 |     cout << Verbose(0) << "i - realign molecule" << endl;
 | 
|---|
 | 1403 |     cout << Verbose(0) << "m - mirror all molecules" << endl;
 | 
|---|
| [14de469] | 1404 |     cout << Verbose(0) << "t - translate molecule by vector" << endl;
 | 
|---|
 | 1405 |     cout << Verbose(0) << "c - scale by unit transformation" << endl;
 | 
|---|
 | 1406 |     cout << Verbose(0) << "g - center atoms in box" << endl;
 | 
|---|
 | 1407 |     cout << Verbose(0) << "-----------------------------------------------" << endl;
 | 
|---|
 | 1408 |     cout << Verbose(0) << "s - save current setup to config file" << endl;
 | 
|---|
 | 1409 |     cout << Verbose(0) << "T - call the current test routine" << endl;
 | 
|---|
 | 1410 |     cout << Verbose(0) << "q - quit" << endl;
 | 
|---|
 | 1411 |     cout << Verbose(0) << "===============================================" << endl;
 | 
|---|
 | 1412 |     cout << Verbose(0) << "Input: ";
 | 
|---|
 | 1413 |     cin >> choice;
 | 
|---|
| [a8bcea6] | 1414 | 
 | 
|---|
| [14de469] | 1415 |     switch (choice) {
 | 
|---|
 | 1416 |       default:
 | 
|---|
 | 1417 |       case 'a': // add atom
 | 
|---|
 | 1418 |         AddAtoms(periode, mol);
 | 
|---|
| [a8bcea6] | 1419 |         choice = 'a';
 | 
|---|
| [14de469] | 1420 |         break;
 | 
|---|
| [a8bcea6] | 1421 | 
 | 
|---|
| [ca2b83] | 1422 |       case 'b': // scale a bond
 | 
|---|
 | 1423 |         cout << Verbose(0) << "Scaling bond length between two atoms." << endl;
 | 
|---|
 | 1424 |         first = mol->AskAtom("Enter first (fixed) atom: ");
 | 
|---|
 | 1425 |         second = mol->AskAtom("Enter second (shifting) atom: ");
 | 
|---|
 | 1426 |         min_bond = 0.;
 | 
|---|
| [7f3b9d] | 1427 |         for (int i=NDIM;i--;)
 | 
|---|
| [ca2b83] | 1428 |           min_bond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]);
 | 
|---|
 | 1429 |         min_bond = sqrt(min_bond);
 | 
|---|
 | 1430 |         cout << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << min_bond << " a.u." << endl;
 | 
|---|
 | 1431 |         cout << Verbose(0) << "Enter new bond length [a.u.]: ";
 | 
|---|
 | 1432 |         cin >> bond;
 | 
|---|
| [7f3b9d] | 1433 |         for (int i=NDIM;i--;) {
 | 
|---|
| [ca2b83] | 1434 |           second->x.x[i] -= (second->x.x[i]-first->x.x[i])/min_bond*(min_bond-bond);
 | 
|---|
 | 1435 |         }
 | 
|---|
 | 1436 |         //cout << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";
 | 
|---|
| [a8bcea6] | 1437 |         //second->Output(second->type->No, 1, (ofstream *)&cout);
 | 
|---|
| [ca2b83] | 1438 |         break;
 | 
|---|
 | 1439 | 
 | 
|---|
| [a8bcea6] | 1440 |       case 'c': // unit scaling of the metric
 | 
|---|
| [ca2b83] | 1441 |        cout << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl;
 | 
|---|
 | 1442 |        cout << Verbose(0) << "Enter three factors: ";
 | 
|---|
 | 1443 |        factor = new double[NDIM];
 | 
|---|
 | 1444 |        cin >> factor[0];
 | 
|---|
 | 1445 |        cin >> factor[1];
 | 
|---|
 | 1446 |        cin >> factor[2];
 | 
|---|
 | 1447 |        valid = true;
 | 
|---|
 | 1448 |        mol->Scale(&factor);
 | 
|---|
 | 1449 |        delete[](factor);
 | 
|---|
 | 1450 |        break;
 | 
|---|
| [a8bcea6] | 1451 | 
 | 
|---|
| [14de469] | 1452 |       case 'd': // duplicate the periodic cell along a given axis, given times
 | 
|---|
 | 1453 |         cout << Verbose(0) << "State the axis [(+-)123]: ";
 | 
|---|
 | 1454 |         cin >> axis;
 | 
|---|
 | 1455 |         cout << Verbose(0) << "State the factor: ";
 | 
|---|
 | 1456 |         cin >> faktor;
 | 
|---|
| [a8bcea6] | 1457 | 
 | 
|---|
| [14de469] | 1458 |         mol->CountAtoms((ofstream *)&cout);  // recount atoms
 | 
|---|
 | 1459 |         if (mol->AtomCount != 0) {  // if there is more than none
 | 
|---|
 | 1460 |           count = mol->AtomCount;   // is changed becausing of adding, thus has to be stored away beforehand
 | 
|---|
| [ca2b83] | 1461 |           Elements = new element *[count];
 | 
|---|
| [e9b8bb] | 1462 |           vectors = new Vector *[count];
 | 
|---|
| [14de469] | 1463 |           j = 0;
 | 
|---|
 | 1464 |           first = mol->start;
 | 
|---|
 | 1465 |           while (first->next != mol->end) {  // make a list of all atoms with coordinates and element
 | 
|---|
 | 1466 |             first = first->next;
 | 
|---|
 | 1467 |             Elements[j] = first->type;
 | 
|---|
| [d7e30c] | 1468 |             vectors[j] = &first->x;
 | 
|---|
| [14de469] | 1469 |             j++;
 | 
|---|
 | 1470 |           }
 | 
|---|
 | 1471 |           if (count != j)
 | 
|---|
 | 1472 |             cout << Verbose(0) << "ERROR: AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
 | 
|---|
 | 1473 |           x.Zero();
 | 
|---|
 | 1474 |           y.Zero();
 | 
|---|
 | 1475 |           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
 | 
|---|
 | 1476 |           for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
 | 
|---|
 | 1477 |             x.AddVector(&y); // per factor one cell width further
 | 
|---|
| [7f3b9d] | 1478 |             for (int k=count;k--;) { // go through every atom of the original cell
 | 
|---|
| [14de469] | 1479 |               first = new atom(); // create a new body
 | 
|---|
| [d7e30c] | 1480 |               first->x.CopyVector(vectors[k]);  // use coordinate of original atom
 | 
|---|
| [14de469] | 1481 |               first->x.AddVector(&x);      // translate the coordinates
 | 
|---|
 | 1482 |               first->type = Elements[k];  // insert original element
 | 
|---|
 | 1483 |               mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
 | 
|---|
 | 1484 |             }
 | 
|---|
 | 1485 |           }
 | 
|---|
 | 1486 |           if (mol->first->next != mol->last) // if connect matrix is present already, redo it
 | 
|---|
| [a251a3] | 1487 |             mol->CreateAdjacencyList((ofstream *)&cout, mol->BondDistance, configuration.GetIsAngstroem());
 | 
|---|
| [14de469] | 1488 |           // free memory
 | 
|---|
| [ca2b83] | 1489 |           delete[](Elements);
 | 
|---|
| [d7e30c] | 1490 |           delete[](vectors);
 | 
|---|
| [14de469] | 1491 |           // correct cell size
 | 
|---|
 | 1492 |           if (axis < 0) { // if sign was negative, we have to translate everything
 | 
|---|
 | 1493 |             x.Zero();
 | 
|---|
 | 1494 |             x.AddVector(&y);
 | 
|---|
 | 1495 |             x.Scale(-(faktor-1));
 | 
|---|
 | 1496 |             mol->Translate(&x);
 | 
|---|
 | 1497 |           }
 | 
|---|
| [a8bcea6] | 1498 |           mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
 | 
|---|
| [14de469] | 1499 |         }
 | 
|---|
 | 1500 |         break;
 | 
|---|
| [a8bcea6] | 1501 | 
 | 
|---|
| [ca2b83] | 1502 |       case 'e': // edit each field of the configuration
 | 
|---|
 | 1503 |        configuration.Edit(mol);
 | 
|---|
 | 1504 |        break;
 | 
|---|
| [a8bcea6] | 1505 | 
 | 
|---|
| [ca2b83] | 1506 |       case 'f':
 | 
|---|
 | 1507 |         FragmentAtoms(mol, &configuration);
 | 
|---|
 | 1508 |         break;
 | 
|---|
| [a8bcea6] | 1509 | 
 | 
|---|
| [14de469] | 1510 |       case 'g': // center the atoms
 | 
|---|
 | 1511 |         CenterAtoms(mol);
 | 
|---|
 | 1512 |         break;
 | 
|---|
| [a8bcea6] | 1513 | 
 | 
|---|
 | 1514 |       case 'i': // align all atoms
 | 
|---|
| [14de469] | 1515 |         AlignAtoms(periode, mol);
 | 
|---|
 | 1516 |         break;
 | 
|---|
 | 1517 | 
 | 
|---|
 | 1518 |       case 'l': // measure distances or angles
 | 
|---|
| [d52ea1b] | 1519 |         MeasureAtoms(periode, mol, &configuration);
 | 
|---|
| [14de469] | 1520 |         break;
 | 
|---|
 | 1521 | 
 | 
|---|
| [ca2b83] | 1522 |       case 'm': // mirror atoms along a given axis
 | 
|---|
 | 1523 |         MirrorAtoms(mol);
 | 
|---|
| [14de469] | 1524 |         break;
 | 
|---|
| [a8bcea6] | 1525 | 
 | 
|---|
| [14de469] | 1526 |       case 'o': // create the connection matrix
 | 
|---|
| [3ccc3e] | 1527 |         {
 | 
|---|
 | 1528 |           cout << Verbose(0) << "What's the maximum bond distance: ";
 | 
|---|
 | 1529 |           cin >> tmp1;
 | 
|---|
 | 1530 |           start = clock();
 | 
|---|
 | 1531 |           mol->CreateAdjacencyList((ofstream *)&cout, tmp1, configuration.GetIsAngstroem());
 | 
|---|
 | 1532 |           mol->CreateListOfBondsPerAtom((ofstream *)&cout);
 | 
|---|
 | 1533 | //          Subgraphs = mol->DepthFirstSearchAnalysis((ofstream *)&cout, BackEdgeStack);
 | 
|---|
 | 1534 | //          while (Subgraphs->next != NULL) {
 | 
|---|
 | 1535 | //            Subgraphs = Subgraphs->next;
 | 
|---|
 | 1536 | //            Subgraphs->Leaf->CyclicStructureAnalysis((ofstream *)&cout, BackEdgeStack, MinimumRingSize);
 | 
|---|
 | 1537 | //            delete(Subgraphs->previous);
 | 
|---|
 | 1538 | //          }
 | 
|---|
 | 1539 | //          delete(Subgraphs);    // we don't need the list here, so free everything
 | 
|---|
 | 1540 | //          delete[](MinimumRingSize);
 | 
|---|
 | 1541 | //          Subgraphs = NULL;
 | 
|---|
 | 1542 |           end = clock();
 | 
|---|
 | 1543 |           cout << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
 | 
|---|
| [14de469] | 1544 |         }
 | 
|---|
 | 1545 |         break;
 | 
|---|
| [a8bcea6] | 1546 | 
 | 
|---|
| [ca2b83] | 1547 |       case 'p': // parse and XYZ file
 | 
|---|
 | 1548 |         cout << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl;
 | 
|---|
 | 1549 |         do {
 | 
|---|
 | 1550 |           cout << Verbose(0) << "Enter file name: ";
 | 
|---|
 | 1551 |           cin >> filename;
 | 
|---|
 | 1552 |         } while (!mol->AddXYZFile(filename));
 | 
|---|
 | 1553 |         break;
 | 
|---|
 | 1554 | 
 | 
|---|
| [a8bcea6] | 1555 |       case 'q': // quit
 | 
|---|
| [ca2b83] | 1556 |         break;
 | 
|---|
| [a8bcea6] | 1557 | 
 | 
|---|
| [ca2b83] | 1558 |       case 'r': // remove atom
 | 
|---|
| [a8bcea6] | 1559 |         RemoveAtoms(mol);
 | 
|---|
| [ca2b83] | 1560 |         break;
 | 
|---|
| [a8bcea6] | 1561 | 
 | 
|---|
| [ca2b83] | 1562 |       case 's': // save to config file
 | 
|---|
 | 1563 |         SaveConfig(ConfigFileName, &configuration, periode, mol);
 | 
|---|
 | 1564 |         break;
 | 
|---|
 | 1565 | 
 | 
|---|
 | 1566 |       case 't': // translate all atoms
 | 
|---|
| [a8bcea6] | 1567 |        cout << Verbose(0) << "Enter translation vector." << endl;
 | 
|---|
| [ca2b83] | 1568 |        x.AskPosition(mol->cell_size,0);
 | 
|---|
| [e9b8bb] | 1569 |        mol->Translate((const Vector *)&x);
 | 
|---|
| [ca2b83] | 1570 |        break;
 | 
|---|
| [a8bcea6] | 1571 | 
 | 
|---|
| [ca2b83] | 1572 |       case 'T':
 | 
|---|
 | 1573 |         testroutine(mol);
 | 
|---|
 | 1574 |         break;
 | 
|---|
| [a8bcea6] | 1575 | 
 | 
|---|
| [14de469] | 1576 |       case 'u': // change an atom's element
 | 
|---|
 | 1577 |         first = NULL;
 | 
|---|
 | 1578 |         do {
 | 
|---|
 | 1579 |           cout << Verbose(0) << "Change the element of which atom: ";
 | 
|---|
 | 1580 |           cin >> Z;
 | 
|---|
 | 1581 |         } while ((first = mol->FindAtom(Z)) == NULL);
 | 
|---|
| [a8bcea6] | 1582 |         cout << Verbose(0) << "New element by atomic number Z: ";
 | 
|---|
| [14de469] | 1583 |         cin >> Z;
 | 
|---|
 | 1584 |         first->type = periode->FindElement(Z);
 | 
|---|
| [a8bcea6] | 1585 |         cout << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl;
 | 
|---|
| [14de469] | 1586 |         break;
 | 
|---|
 | 1587 |     };
 | 
|---|
 | 1588 |   } while (choice != 'q');
 | 
|---|
| [a8bcea6] | 1589 | 
 | 
|---|
| [14de469] | 1590 |   // save element data base
 | 
|---|
| [110ceb] | 1591 |   if (periode->StorePeriodentafel(ElementsFileName)) //ElementsFileName
 | 
|---|
| [14de469] | 1592 |     cout << Verbose(0) << "Saving of elements.db successful." << endl;
 | 
|---|
 | 1593 |   else
 | 
|---|
 | 1594 |     cout << Verbose(0) << "Saving of elements.db failed." << endl;
 | 
|---|
 | 1595 | 
 | 
|---|
 | 1596 |   // Free all
 | 
|---|
 | 1597 |   if (Subgraphs != NULL) {  // free disconnected subgraph list of DFS analysis was performed
 | 
|---|
 | 1598 |     while (Subgraphs->next != NULL) {
 | 
|---|
 | 1599 |       Subgraphs = Subgraphs->next;
 | 
|---|
 | 1600 |       delete(Subgraphs->previous);
 | 
|---|
 | 1601 |     }
 | 
|---|
 | 1602 |     delete(Subgraphs);
 | 
|---|
 | 1603 |   }
 | 
|---|
 | 1604 |   delete(mol);
 | 
|---|
 | 1605 |   delete(periode);
 | 
|---|
 | 1606 |   return (0);
 | 
|---|
 | 1607 | }
 | 
|---|
 | 1608 | 
 | 
|---|
 | 1609 | /********************************************** E N D **************************************************/
 | 
|---|