| [14de469] | 1 | /** \file builder.cpp
 | 
|---|
| [a8bcea6] | 2 |  *
 | 
|---|
| [14de469] | 3 |  * By stating absolute positions or binding angles and distances atomic positions of a molecule can be constructed.
 | 
|---|
 | 4 |  * The output is the complete configuration file for PCP for direct use.
 | 
|---|
 | 5 |  * Features:
 | 
|---|
 | 6 |  * -# Atomic data is retrieved from a file, if not found requested and stored there for later re-use
 | 
|---|
 | 7 |  * -# step-by-step construction of the molecule beginning either at a centre of with a certain atom
 | 
|---|
| [a8bcea6] | 8 |  *
 | 
|---|
| [14de469] | 9 |  */
 | 
|---|
 | 10 | 
 | 
|---|
 | 11 | /*! \mainpage Molecuilder - a molecular set builder
 | 
|---|
| [a8bcea6] | 12 |  *
 | 
|---|
| [14de469] | 13 |  * This introductory shall briefly make aquainted with the program, helping in installing and a first run.
 | 
|---|
| [a8bcea6] | 14 |  *
 | 
|---|
| [14de469] | 15 |  * \section about About the Program
 | 
|---|
| [a8bcea6] | 16 |  *
 | 
|---|
| [042f82] | 17 |  *  Molecuilder is a short program, written in C++, that enables the construction of a coordinate set for the
 | 
|---|
 | 18 |  *  atoms making up an molecule by the successive statement of binding angles and distances and referencing to
 | 
|---|
 | 19 |  *  already constructed atoms.
 | 
|---|
| [a8bcea6] | 20 |  *
 | 
|---|
| [042f82] | 21 |  *  A configuration file may be written that is compatible to the format used by PCP - a parallel Car-Parrinello
 | 
|---|
 | 22 |  *  molecular dynamics implementation.
 | 
|---|
| [a8bcea6] | 23 |  *
 | 
|---|
| [14de469] | 24 |  * \section install Installation
 | 
|---|
| [a8bcea6] | 25 |  *
 | 
|---|
| [042f82] | 26 |  *  Installation should without problems succeed as follows:
 | 
|---|
 | 27 |  *  -# ./configure (or: mkdir build;mkdir run;cd build; ../configure --bindir=../run)
 | 
|---|
 | 28 |  *  -# make
 | 
|---|
 | 29 |  *  -# make install
 | 
|---|
| [a8bcea6] | 30 |  *
 | 
|---|
| [042f82] | 31 |  *  Further useful commands are
 | 
|---|
 | 32 |  *  -# make clean uninstall: deletes .o-files and removes executable from the given binary directory\n
 | 
|---|
 | 33 |  *  -# make doxygen-doc: Creates these html pages out of the documented source
 | 
|---|
| [a8bcea6] | 34 |  *
 | 
|---|
| [14de469] | 35 |  * \section run Running
 | 
|---|
| [a8bcea6] | 36 |  *
 | 
|---|
| [042f82] | 37 |  *  The program can be executed by running: ./molecuilder
 | 
|---|
| [a8bcea6] | 38 |  *
 | 
|---|
| [042f82] | 39 |  *  Note, that it uses a database, called "elements.db", in the executable's directory. If the file is not found,
 | 
|---|
 | 40 |  *  it is created and any given data on elements of the periodic table will be stored therein and re-used on
 | 
|---|
 | 41 |  *  later re-execution.
 | 
|---|
| [a8bcea6] | 42 |  *
 | 
|---|
| [14de469] | 43 |  * \section ref References
 | 
|---|
| [a8bcea6] | 44 |  *
 | 
|---|
| [042f82] | 45 |  *  For the special configuration file format, see the documentation of pcp.
 | 
|---|
| [a8bcea6] | 46 |  *
 | 
|---|
| [14de469] | 47 |  */
 | 
|---|
 | 48 | 
 | 
|---|
 | 49 | 
 | 
|---|
| [12b845] | 50 | #include <boost/bind.hpp>
 | 
|---|
 | 51 | 
 | 
|---|
| [14de469] | 52 | using namespace std;
 | 
|---|
 | 53 | 
 | 
|---|
| [db6bf74] | 54 | #include "analysis_correlation.hpp"
 | 
|---|
| [f66195] | 55 | #include "atom.hpp"
 | 
|---|
 | 56 | #include "bond.hpp"
 | 
|---|
| [b70721] | 57 | #include "bondgraph.hpp"
 | 
|---|
| [6ac7ee] | 58 | #include "boundary.hpp"
 | 
|---|
| [f66195] | 59 | #include "config.hpp"
 | 
|---|
 | 60 | #include "element.hpp"
 | 
|---|
| [6ac7ee] | 61 | #include "ellipsoid.hpp"
 | 
|---|
| [14de469] | 62 | #include "helpers.hpp"
 | 
|---|
| [f66195] | 63 | #include "leastsquaremin.hpp"
 | 
|---|
 | 64 | #include "linkedcell.hpp"
 | 
|---|
| [e138de] | 65 | #include "log.hpp"
 | 
|---|
| [b66c22] | 66 | #include "memoryusageobserverunittest.hpp"
 | 
|---|
| [cee0b57] | 67 | #include "molecule.hpp"
 | 
|---|
| [f66195] | 68 | #include "periodentafel.hpp"
 | 
|---|
| [cc04b7] | 69 | #include "UIElements/UIFactory.hpp"
 | 
|---|
 | 70 | #include "UIElements/MainWindow.hpp"
 | 
|---|
| [12b845] | 71 | #include "Menu/ActionMenuItem.hpp"
 | 
|---|
 | 72 | #include "Actions/ActionRegistry.hpp"
 | 
|---|
 | 73 | #include "Actions/MethodAction.hpp"
 | 
|---|
 | 74 | 
 | 
|---|
| [dbe929] | 75 | 
 | 
|---|
| [ca2b83] | 76 | /** Parses the command line options.
 | 
|---|
 | 77 |  * \param argc argument count
 | 
|---|
 | 78 |  * \param **argv arguments array
 | 
|---|
| [1907a7] | 79 |  * \param *molecules list of molecules structure
 | 
|---|
| [ca2b83] | 80 |  * \param *periode elements structure
 | 
|---|
 | 81 |  * \param configuration config file structure
 | 
|---|
 | 82 |  * \param *ConfigFileName pointer to config file name in **argv
 | 
|---|
| [d7d29c] | 83 |  * \param *PathToDatabases pointer to db's path in **argv
 | 
|---|
| [ca2b83] | 84 |  * \return exit code (0 - successful, all else - something's wrong)
 | 
|---|
 | 85 |  */
 | 
|---|
| [85bc8e] | 86 | static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode,\
 | 
|---|
| [235bed] | 87 |                                    config& configuration, char *&ConfigFileName)
 | 
|---|
| [14de469] | 88 | {
 | 
|---|
| [042f82] | 89 |   Vector x,y,z,n;  // coordinates for absolute point in cell volume
 | 
|---|
 | 90 |   double *factor; // unit factor if desired
 | 
|---|
 | 91 |   ifstream test;
 | 
|---|
 | 92 |   ofstream output;
 | 
|---|
 | 93 |   string line;
 | 
|---|
 | 94 |   atom *first;
 | 
|---|
 | 95 |   bool SaveFlag = false;
 | 
|---|
 | 96 |   int ExitFlag = 0;
 | 
|---|
 | 97 |   int j;
 | 
|---|
 | 98 |   double volume = 0.;
 | 
|---|
| [f1cccd] | 99 |   enum ConfigStatus configPresent = absent;
 | 
|---|
| [042f82] | 100 |   clock_t start,end;
 | 
|---|
 | 101 |   int argptr;
 | 
|---|
| [b6d8a9] | 102 |   molecule *mol = NULL;
 | 
|---|
| [b21a64] | 103 |   string BondGraphFileName("");
 | 
|---|
| [717e0c] | 104 |   int verbosity = 0;
 | 
|---|
| [989bf6] | 105 |   strncpy(configuration.databasepath, LocalPath, MAXSTRINGSIZE-1);
 | 
|---|
| [6ac7ee] | 106 | 
 | 
|---|
| [042f82] | 107 |   if (argc > 1) { // config file specified as option
 | 
|---|
 | 108 |     // 1. : Parse options that just set variables or print help
 | 
|---|
 | 109 |     argptr = 1;
 | 
|---|
 | 110 |     do {
 | 
|---|
 | 111 |       if (argv[argptr][0] == '-') {
 | 
|---|
| [e138de] | 112 |         Log() << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n";
 | 
|---|
| [042f82] | 113 |         argptr++;
 | 
|---|
 | 114 |         switch(argv[argptr-1][1]) {
 | 
|---|
 | 115 |           case 'h':
 | 
|---|
 | 116 |           case 'H':
 | 
|---|
 | 117 |           case '?':
 | 
|---|
| [e138de] | 118 |             Log() << Verbose(0) << "MoleCuilder suite" << endl << "==================" << endl << endl;
 | 
|---|
 | 119 |             Log() << Verbose(0) << "Usage: " << argv[0] << "[config file] [-{acefpsthH?vfrp}] [further arguments]" << endl;
 | 
|---|
 | 120 |             Log() << Verbose(0) << "or simply " << argv[0] << " without arguments for interactive session." << endl;
 | 
|---|
 | 121 |             Log() << Verbose(0) << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl;
 | 
|---|
 | 122 |             Log() << Verbose(0) << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl;
 | 
|---|
 | 123 |             Log() << Verbose(0) << "\t-b xx xy xz yy yz zz\tCenter atoms in domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl;
 | 
|---|
 | 124 |             Log() << Verbose(0) << "\t-B xx xy xz yy yz zz\tBound atoms by domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl;
 | 
|---|
 | 125 |             Log() << Verbose(0) << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl;
 | 
|---|
 | 126 |             Log() << Verbose(0) << "\t-C\tPair Correlation analysis." << endl;
 | 
|---|
 | 127 |             Log() << Verbose(0) << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl;
 | 
|---|
 | 128 |             Log() << Verbose(0) << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl;
 | 
|---|
 | 129 |             Log() << Verbose(0) << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl;
 | 
|---|
 | 130 |             Log() << Verbose(0) << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl;
 | 
|---|
 | 131 |             Log() << Verbose(0) << "\t-f/F <dist> <order>\tFragments the molecule in BOSSANOVA manner (with/out rings compressed) and stores config files in same dir as config (return code 0 - fragmented, 2 - no fragmentation necessary)." << endl;
 | 
|---|
 | 132 |             Log() << Verbose(0) << "\t-g <file>\tParses a bond length table from the given file." << endl;
 | 
|---|
 | 133 |             Log() << Verbose(0) << "\t-h/-H/-?\tGive this help screen." << endl;
 | 
|---|
 | 134 |             Log() << Verbose(0) << "\t-L <step0> <step1> <prefix>\tStore a linear interpolation between two configurations <step0> and <step1> into single config files with prefix <prefix> and as Trajectories into the current config file." << endl;
 | 
|---|
 | 135 |             Log() << Verbose(0) << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl;
 | 
|---|
 | 136 |             Log() << Verbose(0) << "\t-M <basis>\tSetting basis to store to MPQC config files." << endl;
 | 
|---|
 | 137 |             Log() << Verbose(0) << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl;
 | 
|---|
 | 138 |             Log() << Verbose(0) << "\t-N <radius> <file>\tGet non-convex-envelope." << endl;
 | 
|---|
 | 139 |             Log() << Verbose(0) << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl;
 | 
|---|
 | 140 |             Log() << Verbose(0) << "\t-O\tCenter atoms in origin." << endl;
 | 
|---|
 | 141 |             Log() << Verbose(0) << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl;
 | 
|---|
 | 142 |             Log() << Verbose(0) << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl;
 | 
|---|
 | 143 |             Log() << Verbose(0) << "\t-r <id>\t\tRemove an atom with given id." << endl;
 | 
|---|
 | 144 |             Log() << Verbose(0) << "\t-R <id> <radius>\t\tRemove all atoms out of sphere around a given one." << endl;
 | 
|---|
 | 145 |             Log() << Verbose(0) << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl;
 | 
|---|
 | 146 |             Log() << Verbose(0) << "\t-S <file> Store temperatures from the config file in <file>." << endl;
 | 
|---|
 | 147 |             Log() << Verbose(0) << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl;
 | 
|---|
 | 148 |             Log() << Verbose(0) << "\t-T x1 x2 x3\tTranslate periodically all atoms by this vector (x1,x2,x3)." << endl;
 | 
|---|
 | 149 |             Log() << Verbose(0) << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl;
 | 
|---|
| [717e0c] | 150 |             Log() << Verbose(0) << "\t-v\t\tsets verbosity (more is more)." << endl;
 | 
|---|
 | 151 |             Log() << Verbose(0) << "\t-V\t\tGives version information." << endl;
 | 
|---|
| [e138de] | 152 |             Log() << Verbose(0) << "Note: config files must not begin with '-' !" << endl;
 | 
|---|
| [042f82] | 153 |             return (1);
 | 
|---|
 | 154 |             break;
 | 
|---|
 | 155 |           case 'v':
 | 
|---|
| [717e0c] | 156 |             while (argv[argptr-1][verbosity+1] == 'v') {
 | 
|---|
 | 157 |               verbosity++;
 | 
|---|
 | 158 |             }
 | 
|---|
 | 159 |             setVerbosity(verbosity);
 | 
|---|
 | 160 |             Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl;
 | 
|---|
 | 161 |             break;
 | 
|---|
| [042f82] | 162 |           case 'V':
 | 
|---|
| [e138de] | 163 |             Log() << Verbose(0) << argv[0] << " " << VERSIONSTRING << endl;
 | 
|---|
 | 164 |             Log() << Verbose(0) << "Build your own molecule position set." << endl;
 | 
|---|
| [042f82] | 165 |             return (1);
 | 
|---|
 | 166 |             break;
 | 
|---|
 | 167 |           case 'e':
 | 
|---|
 | 168 |             if ((argptr >= argc) || (argv[argptr][0] == '-')) {
 | 
|---|
| [e138de] | 169 |               eLog() << Verbose(0) << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl;
 | 
|---|
| [e359a8] | 170 |               performCriticalExit();
 | 
|---|
| [042f82] | 171 |             } else {
 | 
|---|
| [e138de] | 172 |               Log() << Verbose(0) << "Using " << argv[argptr] << " as elements database." << endl;
 | 
|---|
| [042f82] | 173 |               strncpy (configuration.databasepath, argv[argptr], MAXSTRINGSIZE-1);
 | 
|---|
 | 174 |               argptr+=1;
 | 
|---|
 | 175 |             }
 | 
|---|
 | 176 |             break;
 | 
|---|
| [b21a64] | 177 |           case 'g':
 | 
|---|
 | 178 |             if ((argptr >= argc) || (argv[argptr][0] == '-')) {
 | 
|---|
| [e138de] | 179 |               eLog() << Verbose(0) << "Not enough or invalid arguments for specifying bond length table: -g <table file>" << endl;
 | 
|---|
| [e359a8] | 180 |               performCriticalExit();
 | 
|---|
| [b21a64] | 181 |             } else {
 | 
|---|
 | 182 |               BondGraphFileName = argv[argptr];
 | 
|---|
| [e138de] | 183 |               Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl;
 | 
|---|
| [b21a64] | 184 |               argptr+=1;
 | 
|---|
 | 185 |             }
 | 
|---|
 | 186 |             break;
 | 
|---|
| [042f82] | 187 |           case 'n':
 | 
|---|
| [e138de] | 188 |             Log() << Verbose(0) << "I won't parse trajectories." << endl;
 | 
|---|
| [042f82] | 189 |             configuration.FastParsing = true;
 | 
|---|
 | 190 |             break;
 | 
|---|
 | 191 |           default:   // no match? Step on
 | 
|---|
 | 192 |             argptr++;
 | 
|---|
 | 193 |             break;
 | 
|---|
 | 194 |         }
 | 
|---|
 | 195 |       } else
 | 
|---|
 | 196 |         argptr++;
 | 
|---|
 | 197 |     } while (argptr < argc);
 | 
|---|
 | 198 | 
 | 
|---|
| [b21a64] | 199 |     // 3a. Parse the element database
 | 
|---|
| [042f82] | 200 |     if (periode->LoadPeriodentafel(configuration.databasepath)) {
 | 
|---|
| [e138de] | 201 |       Log() << Verbose(0) << "Element list loaded successfully." << endl;
 | 
|---|
 | 202 |       //periode->Output();
 | 
|---|
| [042f82] | 203 |     } else {
 | 
|---|
| [e138de] | 204 |       Log() << Verbose(0) << "Element list loading failed." << endl;
 | 
|---|
| [042f82] | 205 |       return 1;
 | 
|---|
 | 206 |     }
 | 
|---|
| [34e0013] | 207 |     // 3b. Find config file name and parse if possible, also BondGraphFileName
 | 
|---|
| [042f82] | 208 |     if (argv[1][0] != '-') {
 | 
|---|
| [b6d8a9] | 209 |       // simply create a new molecule, wherein the config file is loaded and the manipulation takes place
 | 
|---|
| [e138de] | 210 |       Log() << Verbose(0) << "Config file given." << endl;
 | 
|---|
| [042f82] | 211 |       test.open(argv[1], ios::in);
 | 
|---|
 | 212 |       if (test == NULL) {
 | 
|---|
 | 213 |         //return (1);
 | 
|---|
 | 214 |         output.open(argv[1], ios::out);
 | 
|---|
 | 215 |         if (output == NULL) {
 | 
|---|
| [e138de] | 216 |           Log() << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl;
 | 
|---|
| [f1cccd] | 217 |           configPresent = absent;
 | 
|---|
| [042f82] | 218 |         } else {
 | 
|---|
| [e138de] | 219 |           Log() << Verbose(0) << "Empty configuration file." << endl;
 | 
|---|
| [042f82] | 220 |           ConfigFileName = argv[1];
 | 
|---|
| [f1cccd] | 221 |           configPresent = empty;
 | 
|---|
| [042f82] | 222 |           output.close();
 | 
|---|
 | 223 |         }
 | 
|---|
 | 224 |       } else {
 | 
|---|
 | 225 |         test.close();
 | 
|---|
 | 226 |         ConfigFileName = argv[1];
 | 
|---|
| [e138de] | 227 |         Log() << Verbose(1) << "Specified config file found, parsing ... ";
 | 
|---|
| [fa649a] | 228 |         switch (configuration.TestSyntax(ConfigFileName, periode)) {
 | 
|---|
| [042f82] | 229 |           case 1:
 | 
|---|
| [e138de] | 230 |             Log() << Verbose(0) << "new syntax." << endl;
 | 
|---|
| [fa649a] | 231 |             configuration.Load(ConfigFileName, BondGraphFileName, periode, molecules);
 | 
|---|
| [f1cccd] | 232 |             configPresent = present;
 | 
|---|
| [042f82] | 233 |             break;
 | 
|---|
 | 234 |           case 0:
 | 
|---|
| [e138de] | 235 |             Log() << Verbose(0) << "old syntax." << endl;
 | 
|---|
| [fa649a] | 236 |             configuration.LoadOld(ConfigFileName, BondGraphFileName, periode, molecules);
 | 
|---|
| [f1cccd] | 237 |             configPresent = present;
 | 
|---|
| [042f82] | 238 |             break;
 | 
|---|
 | 239 |           default:
 | 
|---|
| [e138de] | 240 |             Log() << Verbose(0) << "Unknown syntax or empty, yet present file." << endl;
 | 
|---|
| [f1cccd] | 241 |             configPresent = empty;
 | 
|---|
| [042f82] | 242 |        }
 | 
|---|
 | 243 |       }
 | 
|---|
 | 244 |     } else
 | 
|---|
| [f1cccd] | 245 |       configPresent = absent;
 | 
|---|
| [fa649a] | 246 |      // set mol to first active molecule
 | 
|---|
 | 247 |      if (molecules->ListOfMolecules.size() != 0) {
 | 
|---|
 | 248 |        for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
 | 
|---|
 | 249 |          if ((*ListRunner)->ActiveFlag) {
 | 
|---|
 | 250 |            mol = *ListRunner;
 | 
|---|
 | 251 |            break;
 | 
|---|
 | 252 |          }
 | 
|---|
 | 253 |      }
 | 
|---|
 | 254 |      if (mol == NULL) {
 | 
|---|
 | 255 |        mol = new molecule(periode);
 | 
|---|
 | 256 |        mol->ActiveFlag = true;
 | 
|---|
 | 257 |        molecules->insert(mol);
 | 
|---|
 | 258 |      }
 | 
|---|
 | 259 | 
 | 
|---|
| [042f82] | 260 |     // 4. parse again through options, now for those depending on elements db and config presence
 | 
|---|
 | 261 |     argptr = 1;
 | 
|---|
 | 262 |     do {
 | 
|---|
| [e138de] | 263 |       Log() << Verbose(0) << "Current Command line argument: " << argv[argptr] << "." << endl;
 | 
|---|
| [042f82] | 264 |       if (argv[argptr][0] == '-') {
 | 
|---|
 | 265 |         argptr++;
 | 
|---|
| [f1cccd] | 266 |         if ((configPresent == present) || (configPresent == empty)) {
 | 
|---|
| [042f82] | 267 |           switch(argv[argptr-1][1]) {
 | 
|---|
 | 268 |             case 'p':
 | 
|---|
| [ebcade] | 269 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [042f82] | 270 |               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
 | 
|---|
 | 271 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 272 |                 eLog() << Verbose(0) << "Not enough arguments for parsing: -p <xyz file>" << endl;
 | 
|---|
| [e359a8] | 273 |                 performCriticalExit();
 | 
|---|
| [042f82] | 274 |               } else {
 | 
|---|
 | 275 |                 SaveFlag = true;
 | 
|---|
| [e138de] | 276 |                 Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl;
 | 
|---|
| [042f82] | 277 |                 if (!mol->AddXYZFile(argv[argptr]))
 | 
|---|
| [e138de] | 278 |                   Log() << Verbose(2) << "File not found." << endl;
 | 
|---|
| [042f82] | 279 |                 else {
 | 
|---|
| [e138de] | 280 |                   Log() << Verbose(2) << "File found and parsed." << endl;
 | 
|---|
| [f1cccd] | 281 |                   configPresent = present;
 | 
|---|
| [042f82] | 282 |                 }
 | 
|---|
 | 283 |               }
 | 
|---|
 | 284 |               break;
 | 
|---|
 | 285 |             case 'a':
 | 
|---|
| [ebcade] | 286 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [09048c] | 287 |               if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3]))) {
 | 
|---|
| [042f82] | 288 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 289 |                 eLog() << Verbose(0) << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl;
 | 
|---|
| [e359a8] | 290 |                 performCriticalExit();
 | 
|---|
| [042f82] | 291 |               } else {
 | 
|---|
 | 292 |                 SaveFlag = true;
 | 
|---|
| [e138de] | 293 |                 Log() << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), ";
 | 
|---|
| [042f82] | 294 |                 first = new atom;
 | 
|---|
 | 295 |                 first->type = periode->FindElement(atoi(argv[argptr]));
 | 
|---|
 | 296 |                 if (first->type != NULL)
 | 
|---|
| [e138de] | 297 |                   Log() << Verbose(2) << "found element " << first->type->name << endl;
 | 
|---|
| [042f82] | 298 |                 for (int i=NDIM;i--;)
 | 
|---|
 | 299 |                   first->x.x[i] = atof(argv[argptr+1+i]);
 | 
|---|
 | 300 |                 if (first->type != NULL) {
 | 
|---|
 | 301 |                   mol->AddAtom(first);  // add to molecule
 | 
|---|
| [f1cccd] | 302 |                   if ((configPresent == empty) && (mol->AtomCount != 0))
 | 
|---|
 | 303 |                     configPresent = present;
 | 
|---|
| [042f82] | 304 |                 } else
 | 
|---|
| [e138de] | 305 |                   eLog() << Verbose(1) << "Could not find the specified element." << endl;
 | 
|---|
| [042f82] | 306 |                 argptr+=4;
 | 
|---|
 | 307 |               }
 | 
|---|
 | 308 |               break;
 | 
|---|
 | 309 |             default:   // no match? Don't step on (this is done in next switch's default)
 | 
|---|
 | 310 |               break;
 | 
|---|
 | 311 |           }
 | 
|---|
 | 312 |         }
 | 
|---|
| [f1cccd] | 313 |         if (configPresent == present) {
 | 
|---|
| [042f82] | 314 |           switch(argv[argptr-1][1]) {
 | 
|---|
| [f3278b] | 315 |             case 'M':
 | 
|---|
| [042f82] | 316 |               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
 | 
|---|
 | 317 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 318 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl;
 | 
|---|
| [e359a8] | 319 |                 performCriticalExit();
 | 
|---|
| [042f82] | 320 |               } else {
 | 
|---|
 | 321 |                 configuration.basis = argv[argptr];
 | 
|---|
| [e138de] | 322 |                 Log() << Verbose(1) << "Setting MPQC basis to " << configuration.basis << "." << endl;
 | 
|---|
| [042f82] | 323 |                 argptr+=1;
 | 
|---|
 | 324 |               }
 | 
|---|
 | 325 |               break;
 | 
|---|
 | 326 |             case 'D':
 | 
|---|
| [ebcade] | 327 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [042f82] | 328 |               {
 | 
|---|
| [e138de] | 329 |                 Log() << Verbose(1) << "Depth-First-Search Analysis." << endl;
 | 
|---|
| [042f82] | 330 |                 MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
 | 
|---|
 | 331 |                 int *MinimumRingSize = new int[mol->AtomCount];
 | 
|---|
 | 332 |                 atom ***ListOfLocalAtoms = NULL;
 | 
|---|
 | 333 |                 class StackClass<bond *> *BackEdgeStack = NULL;
 | 
|---|
 | 334 |                 class StackClass<bond *> *LocalBackEdgeStack = NULL;
 | 
|---|
| [e138de] | 335 |                 mol->CreateAdjacencyList(atof(argv[argptr]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
 | 
|---|
 | 336 |                 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
 | 
|---|
| [042f82] | 337 |                 if (Subgraphs != NULL) {
 | 
|---|
| [7218f8] | 338 |                   int FragmentCounter = 0;
 | 
|---|
| [042f82] | 339 |                   while (Subgraphs->next != NULL) {
 | 
|---|
 | 340 |                     Subgraphs = Subgraphs->next;
 | 
|---|
| [e138de] | 341 |                     Subgraphs->FillBondStructureFromReference(mol, FragmentCounter, ListOfLocalAtoms, false);  // we want to keep the created ListOfLocalAtoms
 | 
|---|
| [042f82] | 342 |                     LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
 | 
|---|
| [e138de] | 343 |                     Subgraphs->Leaf->PickLocalBackEdges(ListOfLocalAtoms[FragmentCounter], BackEdgeStack, LocalBackEdgeStack);
 | 
|---|
 | 344 |                     Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
 | 
|---|
| [042f82] | 345 |                     delete(LocalBackEdgeStack);
 | 
|---|
 | 346 |                     delete(Subgraphs->previous);
 | 
|---|
| [7218f8] | 347 |                     FragmentCounter++;
 | 
|---|
| [042f82] | 348 |                   }
 | 
|---|
 | 349 |                   delete(Subgraphs);
 | 
|---|
 | 350 |                   for (int i=0;i<FragmentCounter;i++)
 | 
|---|
| [7218f8] | 351 |                     Free(&ListOfLocalAtoms[i]);
 | 
|---|
| [b66c22] | 352 |                   Free(&ListOfLocalAtoms);
 | 
|---|
| [042f82] | 353 |                 }
 | 
|---|
 | 354 |                 delete(BackEdgeStack);
 | 
|---|
 | 355 |                 delete[](MinimumRingSize);
 | 
|---|
 | 356 |               }
 | 
|---|
 | 357 |               //argptr+=1;
 | 
|---|
 | 358 |               break;
 | 
|---|
| [db6bf74] | 359 |             case 'C':
 | 
|---|
 | 360 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [f4e1f5] | 361 |               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr][0] == '-') || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-')) {
 | 
|---|
| [db6bf74] | 362 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 363 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C <Z> <output> <bin output>" << endl;
 | 
|---|
| [e359a8] | 364 |                 performCriticalExit();
 | 
|---|
| [db6bf74] | 365 |               } else {
 | 
|---|
 | 366 |                 SaveFlag = false;
 | 
|---|
| [09048c] | 367 |                 ofstream output(argv[argptr+1]);
 | 
|---|
 | 368 |                 ofstream binoutput(argv[argptr+2]);
 | 
|---|
| [db6bf74] | 369 |                 const double radius = 5.;
 | 
|---|
| [09048c] | 370 | 
 | 
|---|
 | 371 |                 // get the boundary
 | 
|---|
| [f4e1f5] | 372 |                 class molecule *Boundary = NULL;
 | 
|---|
| [776b64] | 373 |                 class Tesselation *TesselStruct = NULL;
 | 
|---|
 | 374 |                 const LinkedCell *LCList = NULL;
 | 
|---|
| [f4e1f5] | 375 |                 // find biggest molecule
 | 
|---|
| [a5551b] | 376 |                 int counter  = 0;
 | 
|---|
| [f4e1f5] | 377 |                 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
 | 
|---|
 | 378 |                   if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) {
 | 
|---|
 | 379 |                     Boundary = *BigFinder;
 | 
|---|
 | 380 |                   }
 | 
|---|
| [a5551b] | 381 |                   counter++;
 | 
|---|
 | 382 |                 }
 | 
|---|
 | 383 |                 bool *Actives = Malloc<bool>(counter, "ParseCommandLineOptions() - case C -- *Actives");
 | 
|---|
 | 384 |                 counter = 0;
 | 
|---|
 | 385 |                 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
 | 
|---|
 | 386 |                   Actives[counter] = (*BigFinder)->ActiveFlag;
 | 
|---|
 | 387 |                   (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
 | 
|---|
| [f4e1f5] | 388 |                 }
 | 
|---|
| [776b64] | 389 |                 LCList = new LinkedCell(Boundary, 2.*radius);
 | 
|---|
| [f4e1f5] | 390 |                 element *elemental = periode->FindElement((const int) atoi(argv[argptr]));
 | 
|---|
| [e138de] | 391 |                 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
 | 
|---|
| [7ea9e6] | 392 |                 int ranges[NDIM] = {1,1,1};
 | 
|---|
| [e138de] | 393 |                 CorrelationToSurfaceMap *surfacemap = PeriodicCorrelationToSurface( molecules, elemental, TesselStruct, LCList, ranges );
 | 
|---|
 | 394 |                 BinPairMap *binmap = BinData( surfacemap, 0.5, 0., 0. );
 | 
|---|
| [db6bf74] | 395 |                 OutputCorrelation ( &binoutput, binmap );
 | 
|---|
 | 396 |                 output.close();
 | 
|---|
 | 397 |                 binoutput.close();
 | 
|---|
| [a5551b] | 398 |                 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++)
 | 
|---|
 | 399 |                   (*BigFinder)->ActiveFlag = Actives[counter];
 | 
|---|
 | 400 |                 Free(&Actives);
 | 
|---|
| [776b64] | 401 |                 delete(LCList);
 | 
|---|
 | 402 |                 delete(TesselStruct);
 | 
|---|
| [09048c] | 403 |                 argptr+=3;
 | 
|---|
| [db6bf74] | 404 |               }
 | 
|---|
 | 405 |               break;
 | 
|---|
| [042f82] | 406 |             case 'E':
 | 
|---|
| [ebcade] | 407 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [042f82] | 408 |               if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) {
 | 
|---|
 | 409 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 410 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl;
 | 
|---|
| [e359a8] | 411 |                 performCriticalExit();
 | 
|---|
| [042f82] | 412 |               } else {
 | 
|---|
 | 413 |                 SaveFlag = true;
 | 
|---|
| [e138de] | 414 |                 Log() << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl;
 | 
|---|
| [042f82] | 415 |                 first = mol->FindAtom(atoi(argv[argptr]));
 | 
|---|
 | 416 |                 first->type = periode->FindElement(atoi(argv[argptr+1]));
 | 
|---|
 | 417 |                 argptr+=2;
 | 
|---|
 | 418 |               }
 | 
|---|
 | 419 |               break;
 | 
|---|
| [9f97c5] | 420 |             case 'F':
 | 
|---|
| [ebcade] | 421 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [9f97c5] | 422 |               if (argptr+5 >=argc) {
 | 
|---|
 | 423 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 424 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for filling box with water: -F <dist_x> <dist_y> <dist_z> <randatom> <randmol> <DoRotate>" << endl;
 | 
|---|
| [e359a8] | 425 |                 performCriticalExit();
 | 
|---|
| [9f97c5] | 426 |               } else {
 | 
|---|
 | 427 |                 SaveFlag = true;
 | 
|---|
| [e138de] | 428 |                 Log() << Verbose(1) << "Filling Box with water molecules." << endl;
 | 
|---|
| [9f97c5] | 429 |                 // construct water molecule
 | 
|---|
 | 430 |                 molecule *filler = new molecule(periode);;
 | 
|---|
 | 431 |                 molecule *Filling = NULL;
 | 
|---|
 | 432 |                 atom *second = NULL, *third = NULL;
 | 
|---|
 | 433 |                 first = new atom();
 | 
|---|
 | 434 |                 first->type = periode->FindElement(1);
 | 
|---|
 | 435 |                 first->x.Init(0.441, -0.143, 0.);
 | 
|---|
 | 436 |                 filler->AddAtom(first);
 | 
|---|
 | 437 |                 second = new atom();
 | 
|---|
 | 438 |                 second->type = periode->FindElement(1);
 | 
|---|
 | 439 |                 second->x.Init(-0.464, 1.137, 0.0);
 | 
|---|
 | 440 |                 filler->AddAtom(second);
 | 
|---|
 | 441 |                 third = new atom();
 | 
|---|
 | 442 |                 third->type = periode->FindElement(8);
 | 
|---|
 | 443 |                 third->x.Init(-0.464, 0.177, 0.);
 | 
|---|
 | 444 |                 filler->AddAtom(third);
 | 
|---|
 | 445 |                 filler->AddBond(first, third, 1);
 | 
|---|
 | 446 |                 filler->AddBond(second, third, 1);
 | 
|---|
 | 447 |                 // call routine
 | 
|---|
 | 448 |                 double distance[NDIM];
 | 
|---|
 | 449 |                 for (int i=0;i<NDIM;i++)
 | 
|---|
 | 450 |                   distance[i] = atof(argv[argptr+i]);
 | 
|---|
| [e138de] | 451 |                 Filling = FillBoxWithMolecule(molecules, filler, configuration, distance, atof(argv[argptr+3]), atof(argv[argptr+4]), atoi(argv[argptr+5]));
 | 
|---|
| [9f97c5] | 452 |                 if (Filling != NULL) {
 | 
|---|
 | 453 |                   molecules->insert(Filling);
 | 
|---|
 | 454 |                 }
 | 
|---|
 | 455 |                 delete(filler);
 | 
|---|
 | 456 |                 argptr+=6;
 | 
|---|
 | 457 |               }
 | 
|---|
 | 458 |               break;
 | 
|---|
| [042f82] | 459 |             case 'A':
 | 
|---|
| [ebcade] | 460 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [042f82] | 461 |               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
 | 
|---|
 | 462 |                 ExitFlag =255;
 | 
|---|
| [e138de] | 463 |                 eLog() << Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl;
 | 
|---|
| [e359a8] | 464 |                 performCriticalExit();
 | 
|---|
| [042f82] | 465 |               } else {
 | 
|---|
| [e138de] | 466 |                 Log() << Verbose(0) << "Parsing bonds from " << argv[argptr] << "." << endl;
 | 
|---|
| [042f82] | 467 |                 ifstream *input = new ifstream(argv[argptr]);
 | 
|---|
| [e138de] | 468 |                 mol->CreateAdjacencyListFromDbondFile(input);
 | 
|---|
| [042f82] | 469 |                 input->close();
 | 
|---|
 | 470 |                 argptr+=1;
 | 
|---|
 | 471 |               }
 | 
|---|
 | 472 |               break;
 | 
|---|
 | 473 |             case 'N':
 | 
|---|
| [ebcade] | 474 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [042f82] | 475 |               if ((argptr+1 >= argc) || (argv[argptr+1][0] == '-')){
 | 
|---|
 | 476 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 477 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl;
 | 
|---|
| [e359a8] | 478 |                 performCriticalExit();
 | 
|---|
| [042f82] | 479 |               } else {
 | 
|---|
| [776b64] | 480 |                 class Tesselation *T = NULL;
 | 
|---|
 | 481 |                 const LinkedCell *LCList = NULL;
 | 
|---|
| [9a0dc8] | 482 |                 molecule * Boundary = NULL;
 | 
|---|
 | 483 |                 //string filename(argv[argptr+1]);
 | 
|---|
 | 484 |                 //filename.append(".csv");
 | 
|---|
 | 485 |                 Log() << Verbose(0) << "Evaluating non-convex envelope of biggest molecule.";
 | 
|---|
| [e138de] | 486 |                 Log() << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl;
 | 
|---|
| [9a0dc8] | 487 |                 // find biggest molecule
 | 
|---|
 | 488 |                 int counter  = 0;
 | 
|---|
 | 489 |                 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
 | 
|---|
 | 490 |                   (*BigFinder)->CountAtoms();
 | 
|---|
 | 491 |                   if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) {
 | 
|---|
 | 492 |                     Boundary = *BigFinder;
 | 
|---|
 | 493 |                   }
 | 
|---|
 | 494 |                   counter++;
 | 
|---|
 | 495 |                 }
 | 
|---|
 | 496 |                 Log() << Verbose(1) << "Biggest molecule has " << Boundary->AtomCount << " atoms." << endl;
 | 
|---|
| [f7f7a4] | 497 |                 start = clock();
 | 
|---|
| [9a0dc8] | 498 |                 LCList = new LinkedCell(Boundary, atof(argv[argptr])*2.);
 | 
|---|
 | 499 |                 FindNonConvexBorder(Boundary, T, LCList, atof(argv[argptr]), argv[argptr+1]);
 | 
|---|
| [e138de] | 500 |                 //FindDistributionOfEllipsoids(T, &LCList, N, number, filename.c_str());
 | 
|---|
| [f7f7a4] | 501 |                 end = clock();
 | 
|---|
| [e138de] | 502 |                 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
 | 
|---|
| [776b64] | 503 |                 delete(LCList);
 | 
|---|
| [042f82] | 504 |                 argptr+=2;
 | 
|---|
 | 505 |               }
 | 
|---|
 | 506 |               break;
 | 
|---|
 | 507 |             case 'S':
 | 
|---|
| [ebcade] | 508 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [042f82] | 509 |               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
 | 
|---|
 | 510 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 511 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file>" << endl;
 | 
|---|
| [e359a8] | 512 |                 performCriticalExit();
 | 
|---|
| [042f82] | 513 |               } else {
 | 
|---|
| [e138de] | 514 |                 Log() << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl;
 | 
|---|
| [042f82] | 515 |                 ofstream *output = new ofstream(argv[argptr], ios::trunc);
 | 
|---|
| [e138de] | 516 |                 if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))
 | 
|---|
 | 517 |                   Log() << Verbose(2) << "File could not be written." << endl;
 | 
|---|
| [042f82] | 518 |                 else
 | 
|---|
| [e138de] | 519 |                   Log() << Verbose(2) << "File stored." << endl;
 | 
|---|
| [042f82] | 520 |                 output->close();
 | 
|---|
 | 521 |                 delete(output);
 | 
|---|
 | 522 |                 argptr+=1;
 | 
|---|
 | 523 |               }
 | 
|---|
 | 524 |               break;
 | 
|---|
| [85bac0] | 525 |             case 'L':
 | 
|---|
| [ebcade] | 526 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [f7f7a4] | 527 |               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
 | 
|---|
 | 528 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 529 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for storing tempature: -L <step0> <step1> <prefix> <identity mapping?>" << endl;
 | 
|---|
| [e359a8] | 530 |                 performCriticalExit();
 | 
|---|
| [f7f7a4] | 531 |               } else {
 | 
|---|
 | 532 |                 SaveFlag = true;
 | 
|---|
| [e138de] | 533 |                 Log() << Verbose(1) << "Linear interpolation between configuration " << argv[argptr] << " and " << argv[argptr+1] << "." << endl;
 | 
|---|
| [f7f7a4] | 534 |                 if (atoi(argv[argptr+3]) == 1)
 | 
|---|
| [e138de] | 535 |                   Log() << Verbose(1) << "Using Identity for the permutation map." << endl;
 | 
|---|
 | 536 |                 if (!mol->LinearInterpolationBetweenConfiguration(atoi(argv[argptr]), atoi(argv[argptr+1]), argv[argptr+2], configuration, atoi(argv[argptr+3])) == 1 ? true : false)
 | 
|---|
 | 537 |                   Log() << Verbose(2) << "Could not store " << argv[argptr+2] << " files." << endl;
 | 
|---|
| [f7f7a4] | 538 |                 else
 | 
|---|
| [e138de] | 539 |                   Log() << Verbose(2) << "Steps created and " << argv[argptr+2] << " files stored." << endl;
 | 
|---|
| [f7f7a4] | 540 |                 argptr+=4;
 | 
|---|
 | 541 |               }
 | 
|---|
| [85bac0] | 542 |               break;
 | 
|---|
| [042f82] | 543 |             case 'P':
 | 
|---|
| [ebcade] | 544 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [042f82] | 545 |               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
 | 
|---|
 | 546 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 547 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl;
 | 
|---|
| [e359a8] | 548 |                 performCriticalExit();
 | 
|---|
| [042f82] | 549 |               } else {
 | 
|---|
 | 550 |                 SaveFlag = true;
 | 
|---|
| [e138de] | 551 |                 Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl;
 | 
|---|
 | 552 |                 if (!mol->VerletForceIntegration(argv[argptr], configuration))
 | 
|---|
 | 553 |                   Log() << Verbose(2) << "File not found." << endl;
 | 
|---|
| [042f82] | 554 |                 else
 | 
|---|
| [e138de] | 555 |                   Log() << Verbose(2) << "File found and parsed." << endl;
 | 
|---|
| [042f82] | 556 |                 argptr+=1;
 | 
|---|
 | 557 |               }
 | 
|---|
 | 558 |               break;
 | 
|---|
| [a5b2c3a] | 559 |             case 'R':
 | 
|---|
| [ebcade] | 560 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
 | 561 |               if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])))  {
 | 
|---|
| [a5b2c3a] | 562 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 563 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl;
 | 
|---|
| [e359a8] | 564 |                 performCriticalExit();
 | 
|---|
| [a5b2c3a] | 565 |               } else {
 | 
|---|
 | 566 |                 SaveFlag = true;
 | 
|---|
| [e138de] | 567 |                 Log() << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl;
 | 
|---|
| [a5b2c3a] | 568 |                 double tmp1 = atof(argv[argptr+1]);
 | 
|---|
 | 569 |                 atom *third = mol->FindAtom(atoi(argv[argptr]));
 | 
|---|
 | 570 |                 atom *first = mol->start;
 | 
|---|
 | 571 |                 if ((third != NULL) && (first != mol->end)) {
 | 
|---|
 | 572 |                   atom *second = first->next;
 | 
|---|
 | 573 |                   while(second != mol->end) {
 | 
|---|
 | 574 |                     first = second;
 | 
|---|
 | 575 |                     second = first->next;
 | 
|---|
 | 576 |                     if (first->x.DistanceSquared((const Vector *)&third->x) > tmp1*tmp1) // distance to first above radius ...
 | 
|---|
 | 577 |                       mol->RemoveAtom(first);
 | 
|---|
 | 578 |                   }
 | 
|---|
 | 579 |                 } else {
 | 
|---|
| [717e0c] | 580 |                   eLog() << Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl;
 | 
|---|
| [a5b2c3a] | 581 |                 }
 | 
|---|
 | 582 |                 argptr+=2;
 | 
|---|
 | 583 |               }
 | 
|---|
 | 584 |               break;
 | 
|---|
| [042f82] | 585 |             case 't':
 | 
|---|
| [ebcade] | 586 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [09048c] | 587 |               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
 | 
|---|
| [042f82] | 588 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 589 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl;
 | 
|---|
| [e359a8] | 590 |                 performCriticalExit();
 | 
|---|
| [042f82] | 591 |               } else {
 | 
|---|
| [ebcade] | 592 |                 if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [042f82] | 593 |                 SaveFlag = true;
 | 
|---|
| [e138de] | 594 |                 Log() << Verbose(1) << "Translating all ions by given vector." << endl;
 | 
|---|
| [042f82] | 595 |                 for (int i=NDIM;i--;)
 | 
|---|
 | 596 |                   x.x[i] = atof(argv[argptr+i]);
 | 
|---|
 | 597 |                 mol->Translate((const Vector *)&x);
 | 
|---|
 | 598 |                 argptr+=3;
 | 
|---|
 | 599 |               }
 | 
|---|
| [f7f7a4] | 600 |               break;
 | 
|---|
| [21c017] | 601 |             case 'T':
 | 
|---|
| [ebcade] | 602 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [09048c] | 603 |               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
 | 
|---|
| [21c017] | 604 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 605 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for periodic translation: -T <x> <y> <z>" << endl;
 | 
|---|
| [e359a8] | 606 |                 performCriticalExit();
 | 
|---|
| [21c017] | 607 |               } else {
 | 
|---|
| [ebcade] | 608 |                 if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [21c017] | 609 |                 SaveFlag = true;
 | 
|---|
| [e138de] | 610 |                 Log() << Verbose(1) << "Translating all ions periodically by given vector." << endl;
 | 
|---|
| [21c017] | 611 |                 for (int i=NDIM;i--;)
 | 
|---|
 | 612 |                   x.x[i] = atof(argv[argptr+i]);
 | 
|---|
 | 613 |                 mol->TranslatePeriodically((const Vector *)&x);
 | 
|---|
 | 614 |                 argptr+=3;
 | 
|---|
 | 615 |               }
 | 
|---|
 | 616 |               break;
 | 
|---|
| [042f82] | 617 |             case 's':
 | 
|---|
| [ebcade] | 618 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [09048c] | 619 |               if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
 | 
|---|
| [042f82] | 620 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 621 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl;
 | 
|---|
| [e359a8] | 622 |                 performCriticalExit();
 | 
|---|
| [042f82] | 623 |               } else {
 | 
|---|
 | 624 |                 SaveFlag = true;
 | 
|---|
 | 625 |                 j = -1;
 | 
|---|
| [e138de] | 626 |                 Log() << Verbose(1) << "Scaling all ion positions by factor." << endl;
 | 
|---|
| [042f82] | 627 |                 factor = new double[NDIM];
 | 
|---|
 | 628 |                 factor[0] = atof(argv[argptr]);
 | 
|---|
| [09048c] | 629 |                 factor[1] = atof(argv[argptr+1]);
 | 
|---|
 | 630 |                 factor[2] = atof(argv[argptr+2]);
 | 
|---|
| [776b64] | 631 |                 mol->Scale((const double ** const)&factor);
 | 
|---|
| [042f82] | 632 |                 for (int i=0;i<NDIM;i++) {
 | 
|---|
 | 633 |                   j += i+1;
 | 
|---|
 | 634 |                   x.x[i] = atof(argv[NDIM+i]);
 | 
|---|
 | 635 |                   mol->cell_size[j]*=factor[i];
 | 
|---|
 | 636 |                 }
 | 
|---|
 | 637 |                 delete[](factor);
 | 
|---|
| [09048c] | 638 |                 argptr+=3;
 | 
|---|
| [042f82] | 639 |               }
 | 
|---|
 | 640 |               break;
 | 
|---|
 | 641 |             case 'b':
 | 
|---|
| [ebcade] | 642 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
 | 643 |               if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
 | 
|---|
| [042f82] | 644 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 645 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl;
 | 
|---|
| [e359a8] | 646 |                 performCriticalExit();
 | 
|---|
| [042f82] | 647 |               } else {
 | 
|---|
 | 648 |                 SaveFlag = true;
 | 
|---|
| [a8b9d61] | 649 |                 j = -1;
 | 
|---|
| [e138de] | 650 |                 Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
 | 
|---|
| [042f82] | 651 |                 for (int i=0;i<6;i++) {
 | 
|---|
 | 652 |                   mol->cell_size[i] = atof(argv[argptr+i]);
 | 
|---|
 | 653 |                 }
 | 
|---|
 | 654 |                 // center
 | 
|---|
| [e138de] | 655 |                 mol->CenterInBox();
 | 
|---|
| [21c017] | 656 |                 argptr+=6;
 | 
|---|
| [042f82] | 657 |               }
 | 
|---|
 | 658 |               break;
 | 
|---|
| [f3278b] | 659 |             case 'B':
 | 
|---|
| [ebcade] | 660 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
 | 661 |               if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
 | 
|---|
| [f3278b] | 662 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 663 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl;
 | 
|---|
| [e359a8] | 664 |                 performCriticalExit();
 | 
|---|
| [f3278b] | 665 |               } else {
 | 
|---|
 | 666 |                 SaveFlag = true;
 | 
|---|
 | 667 |                 j = -1;
 | 
|---|
| [e138de] | 668 |                 Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
 | 
|---|
| [f3278b] | 669 |                 for (int i=0;i<6;i++) {
 | 
|---|
 | 670 |                   mol->cell_size[i] = atof(argv[argptr+i]);
 | 
|---|
 | 671 |                 }
 | 
|---|
 | 672 |                 // center
 | 
|---|
| [e138de] | 673 |                 mol->BoundInBox();
 | 
|---|
| [f3278b] | 674 |                 argptr+=6;
 | 
|---|
 | 675 |               }
 | 
|---|
 | 676 |               break;
 | 
|---|
| [042f82] | 677 |             case 'c':
 | 
|---|
| [ebcade] | 678 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
 | 679 |               if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
 | 
|---|
| [042f82] | 680 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 681 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl;
 | 
|---|
| [e359a8] | 682 |                 performCriticalExit();
 | 
|---|
| [042f82] | 683 |               } else {
 | 
|---|
 | 684 |                 SaveFlag = true;
 | 
|---|
 | 685 |                 j = -1;
 | 
|---|
| [e138de] | 686 |                 Log() << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl;
 | 
|---|
| [042f82] | 687 |                 // make every coordinate positive
 | 
|---|
| [e138de] | 688 |                 mol->CenterEdge(&x);
 | 
|---|
| [042f82] | 689 |                 // update Box of atoms by boundary
 | 
|---|
 | 690 |                 mol->SetBoxDimension(&x);
 | 
|---|
 | 691 |                 // translate each coordinate by boundary
 | 
|---|
 | 692 |                 j=-1;
 | 
|---|
 | 693 |                 for (int i=0;i<NDIM;i++) {
 | 
|---|
 | 694 |                   j += i+1;
 | 
|---|
| [36ec71] | 695 |                   x.x[i] = atof(argv[argptr+i]);
 | 
|---|
| [042f82] | 696 |                   mol->cell_size[j] += x.x[i]*2.;
 | 
|---|
 | 697 |                 }
 | 
|---|
 | 698 |                 mol->Translate((const Vector *)&x);
 | 
|---|
| [21c017] | 699 |                 argptr+=3;
 | 
|---|
| [042f82] | 700 |               }
 | 
|---|
 | 701 |               break;
 | 
|---|
 | 702 |             case 'O':
 | 
|---|
| [ebcade] | 703 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [042f82] | 704 |               SaveFlag = true;
 | 
|---|
| [e138de] | 705 |               Log() << Verbose(1) << "Centering atoms on edge and setting box dimensions." << endl;
 | 
|---|
| [36ec71] | 706 |               x.Zero();
 | 
|---|
| [e138de] | 707 |               mol->CenterEdge(&x);
 | 
|---|
| [042f82] | 708 |               mol->SetBoxDimension(&x);
 | 
|---|
| [21c017] | 709 |               argptr+=0;
 | 
|---|
| [042f82] | 710 |               break;
 | 
|---|
 | 711 |             case 'r':
 | 
|---|
| [ebcade] | 712 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
 | 713 |               if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])))  {
 | 
|---|
 | 714 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 715 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for removing atoms: -r <id>" << endl;
 | 
|---|
| [e359a8] | 716 |                 performCriticalExit();
 | 
|---|
| [ebcade] | 717 |               } else {
 | 
|---|
 | 718 |                 SaveFlag = true;
 | 
|---|
| [e138de] | 719 |                 Log() << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl;
 | 
|---|
| [ebcade] | 720 |                 atom *first = mol->FindAtom(atoi(argv[argptr]));
 | 
|---|
 | 721 |                 mol->RemoveAtom(first);
 | 
|---|
 | 722 |                 argptr+=1;
 | 
|---|
 | 723 |               }
 | 
|---|
| [042f82] | 724 |               break;
 | 
|---|
 | 725 |             case 'f':
 | 
|---|
| [ebcade] | 726 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
 | 727 |               if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {
 | 
|---|
| [042f82] | 728 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 729 |                 eLog() << Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl;
 | 
|---|
| [e359a8] | 730 |                 performCriticalExit();
 | 
|---|
| [042f82] | 731 |               } else {
 | 
|---|
| [e138de] | 732 |                 Log() << Verbose(0) << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl;
 | 
|---|
 | 733 |                 Log() << Verbose(0) << "Creating connection matrix..." << endl;
 | 
|---|
| [042f82] | 734 |                 start = clock();
 | 
|---|
| [e138de] | 735 |                 mol->CreateAdjacencyList(atof(argv[argptr++]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
 | 
|---|
 | 736 |                 Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
 | 
|---|
| [042f82] | 737 |                 if (mol->first->next != mol->last) {
 | 
|---|
| [e138de] | 738 |                   ExitFlag = mol->FragmentMolecule(atoi(argv[argptr]), &configuration);
 | 
|---|
| [042f82] | 739 |                 }
 | 
|---|
 | 740 |                 end = clock();
 | 
|---|
| [e138de] | 741 |                 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
 | 
|---|
| [042f82] | 742 |                 argptr+=2;
 | 
|---|
 | 743 |               }
 | 
|---|
 | 744 |               break;
 | 
|---|
 | 745 |             case 'm':
 | 
|---|
| [ebcade] | 746 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [042f82] | 747 |               j = atoi(argv[argptr++]);
 | 
|---|
 | 748 |               if ((j<0) || (j>1)) {
 | 
|---|
| [717e0c] | 749 |                 eLog() << Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl;
 | 
|---|
| [042f82] | 750 |                 j = 0;
 | 
|---|
 | 751 |               }
 | 
|---|
 | 752 |               if (j) {
 | 
|---|
 | 753 |                 SaveFlag = true;
 | 
|---|
| [e138de] | 754 |                 Log() << Verbose(0) << "Converting to prinicipal axis system." << endl;
 | 
|---|
| [042f82] | 755 |               } else
 | 
|---|
| [e138de] | 756 |                 Log() << Verbose(0) << "Evaluating prinicipal axis." << endl;
 | 
|---|
 | 757 |               mol->PrincipalAxisSystem((bool)j);
 | 
|---|
| [042f82] | 758 |               break;
 | 
|---|
 | 759 |             case 'o':
 | 
|---|
| [ebcade] | 760 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
| [f7f7a4] | 761 |               if ((argptr+1 >= argc) || (argv[argptr][0] == '-')){
 | 
|---|
| [042f82] | 762 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 763 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <convex output file> <non-convex output file>" << endl;
 | 
|---|
| [e359a8] | 764 |                 performCriticalExit();
 | 
|---|
| [042f82] | 765 |               } else {
 | 
|---|
| [776b64] | 766 |                 class Tesselation *TesselStruct = NULL;
 | 
|---|
 | 767 |                 const LinkedCell *LCList = NULL;
 | 
|---|
| [e138de] | 768 |                 Log() << Verbose(0) << "Evaluating volume of the convex envelope.";
 | 
|---|
 | 769 |                 Log() << Verbose(1) << "Storing tecplot convex data in " << argv[argptr] << "." << endl;
 | 
|---|
 | 770 |                 Log() << Verbose(1) << "Storing tecplot non-convex data in " << argv[argptr+1] << "." << endl;
 | 
|---|
| [776b64] | 771 |                 LCList = new LinkedCell(mol, 10.);
 | 
|---|
| [e138de] | 772 |                 //FindConvexBorder(mol, LCList, argv[argptr]);
 | 
|---|
 | 773 |                 FindNonConvexBorder(mol, TesselStruct, LCList, 5., argv[argptr+1]);
 | 
|---|
 | 774 | //                RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]);
 | 
|---|
 | 775 |                 double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, argv[argptr]);
 | 
|---|
 | 776 |                 double clustervolume = VolumeOfConvexEnvelope(TesselStruct, &configuration);
 | 
|---|
 | 777 |                 Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl;
 | 
|---|
 | 778 |                 Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl;
 | 
|---|
| [776b64] | 779 |                 delete(TesselStruct);
 | 
|---|
 | 780 |                 delete(LCList);
 | 
|---|
| [f7f7a4] | 781 |                 argptr+=2;
 | 
|---|
| [042f82] | 782 |               }
 | 
|---|
 | 783 |               break;
 | 
|---|
 | 784 |             case 'U':
 | 
|---|
| [ebcade] | 785 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
 | 786 |               if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) {
 | 
|---|
| [042f82] | 787 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 788 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl;
 | 
|---|
| [e359a8] | 789 |                 performCriticalExit();
 | 
|---|
| [042f82] | 790 |               } else {
 | 
|---|
 | 791 |                 volume = atof(argv[argptr++]);
 | 
|---|
| [e138de] | 792 |                 Log() << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl;
 | 
|---|
| [042f82] | 793 |               }
 | 
|---|
 | 794 |             case 'u':
 | 
|---|
| [ebcade] | 795 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
 | 796 |               if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) ) {
 | 
|---|
| [042f82] | 797 |                 if (volume != -1)
 | 
|---|
 | 798 |                   ExitFlag = 255;
 | 
|---|
| [e138de] | 799 |                   eLog() << Verbose(0) << "Not enough arguments given for suspension: -u <density>" << endl;
 | 
|---|
| [e359a8] | 800 |                   performCriticalExit();
 | 
|---|
| [042f82] | 801 |               } else {
 | 
|---|
 | 802 |                 double density;
 | 
|---|
 | 803 |                 SaveFlag = true;
 | 
|---|
| [e138de] | 804 |                 Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.";
 | 
|---|
| [042f82] | 805 |                 density = atof(argv[argptr++]);
 | 
|---|
 | 806 |                 if (density < 1.0) {
 | 
|---|
| [e359a8] | 807 |                   eLog() << Verbose(1) << "Density must be greater than 1.0g/cm^3 !" << endl;
 | 
|---|
| [042f82] | 808 |                   density = 1.3;
 | 
|---|
 | 809 |                 }
 | 
|---|
 | 810 | //                for(int i=0;i<NDIM;i++) {
 | 
|---|
 | 811 | //                  repetition[i] = atoi(argv[argptr++]);
 | 
|---|
 | 812 | //                  if (repetition[i] < 1)
 | 
|---|
| [717e0c] | 813 | //                    eLog() << Verbose(1) << "repetition value must be greater 1!" << endl;
 | 
|---|
| [042f82] | 814 | //                  repetition[i] = 1;
 | 
|---|
 | 815 | //                }
 | 
|---|
| [e138de] | 816 |                 PrepareClustersinWater(&configuration, mol, volume, density);  // if volume == 0, will calculate from ConvexEnvelope
 | 
|---|
| [042f82] | 817 |               }
 | 
|---|
 | 818 |               break;
 | 
|---|
 | 819 |             case 'd':
 | 
|---|
| [ebcade] | 820 |               if (ExitFlag == 0) ExitFlag = 1;
 | 
|---|
 | 821 |               if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
 | 
|---|
| [042f82] | 822 |                 ExitFlag = 255;
 | 
|---|
| [e138de] | 823 |                 eLog() << Verbose(0) << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl;
 | 
|---|
| [e359a8] | 824 |                 performCriticalExit();
 | 
|---|
| [042f82] | 825 |               } else {
 | 
|---|
 | 826 |                 SaveFlag = true;
 | 
|---|
 | 827 |                 for (int axis = 1; axis <= NDIM; axis++) {
 | 
|---|
 | 828 |                   int faktor = atoi(argv[argptr++]);
 | 
|---|
 | 829 |                   int count;
 | 
|---|
 | 830 |                   element ** Elements;
 | 
|---|
 | 831 |                   Vector ** vectors;
 | 
|---|
 | 832 |                   if (faktor < 1) {
 | 
|---|
| [717e0c] | 833 |                     eLog() << Verbose(1) << "Repetition factor mus be greater than 1!" << endl;
 | 
|---|
| [042f82] | 834 |                     faktor = 1;
 | 
|---|
 | 835 |                   }
 | 
|---|
| [e138de] | 836 |                   mol->CountAtoms();  // recount atoms
 | 
|---|
| [042f82] | 837 |                   if (mol->AtomCount != 0) {  // if there is more than none
 | 
|---|
 | 838 |                     count = mol->AtomCount;   // is changed becausing of adding, thus has to be stored away beforehand
 | 
|---|
 | 839 |                     Elements = new element *[count];
 | 
|---|
 | 840 |                     vectors = new Vector *[count];
 | 
|---|
 | 841 |                     j = 0;
 | 
|---|
 | 842 |                     first = mol->start;
 | 
|---|
 | 843 |                     while (first->next != mol->end) {  // make a list of all atoms with coordinates and element
 | 
|---|
 | 844 |                       first = first->next;
 | 
|---|
 | 845 |                       Elements[j] = first->type;
 | 
|---|
 | 846 |                       vectors[j] = &first->x;
 | 
|---|
 | 847 |                       j++;
 | 
|---|
 | 848 |                     }
 | 
|---|
 | 849 |                     if (count != j)
 | 
|---|
| [717e0c] | 850 |                       eLog() << Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
 | 
|---|
| [042f82] | 851 |                     x.Zero();
 | 
|---|
 | 852 |                     y.Zero();
 | 
|---|
 | 853 |                     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
 | 
|---|
 | 854 |                     for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
 | 
|---|
 | 855 |                       x.AddVector(&y); // per factor one cell width further
 | 
|---|
 | 856 |                       for (int k=count;k--;) { // go through every atom of the original cell
 | 
|---|
 | 857 |                         first = new atom(); // create a new body
 | 
|---|
 | 858 |                         first->x.CopyVector(vectors[k]);  // use coordinate of original atom
 | 
|---|
 | 859 |                         first->x.AddVector(&x);      // translate the coordinates
 | 
|---|
 | 860 |                         first->type = Elements[k];  // insert original element
 | 
|---|
 | 861 |                         mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
 | 
|---|
 | 862 |                       }
 | 
|---|
 | 863 |                     }
 | 
|---|
 | 864 |                     // free memory
 | 
|---|
 | 865 |                     delete[](Elements);
 | 
|---|
 | 866 |                     delete[](vectors);
 | 
|---|
 | 867 |                     // correct cell size
 | 
|---|
 | 868 |                     if (axis < 0) { // if sign was negative, we have to translate everything
 | 
|---|
 | 869 |                       x.Zero();
 | 
|---|
 | 870 |                       x.AddVector(&y);
 | 
|---|
 | 871 |                       x.Scale(-(faktor-1));
 | 
|---|
 | 872 |                       mol->Translate(&x);
 | 
|---|
 | 873 |                     }
 | 
|---|
 | 874 |                     mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
 | 
|---|
 | 875 |                   }
 | 
|---|
 | 876 |                 }
 | 
|---|
 | 877 |               }
 | 
|---|
 | 878 |               break;
 | 
|---|
 | 879 |             default:   // no match? Step on
 | 
|---|
 | 880 |               if ((argptr < argc) && (argv[argptr][0] != '-')) // if it started with a '-' we've already made a step!
 | 
|---|
 | 881 |                 argptr++;
 | 
|---|
 | 882 |               break;
 | 
|---|
 | 883 |           }
 | 
|---|
 | 884 |         }
 | 
|---|
 | 885 |       } else argptr++;
 | 
|---|
 | 886 |     } while (argptr < argc);
 | 
|---|
 | 887 |     if (SaveFlag)
 | 
|---|
| [235bed] | 888 |       configuration.SaveAll(ConfigFileName, periode, molecules);
 | 
|---|
| [042f82] | 889 |   } else {  // no arguments, hence scan the elements db
 | 
|---|
 | 890 |     if (periode->LoadPeriodentafel(configuration.databasepath))
 | 
|---|
| [e138de] | 891 |       Log() << Verbose(0) << "Element list loaded successfully." << endl;
 | 
|---|
| [042f82] | 892 |     else
 | 
|---|
| [e138de] | 893 |       Log() << Verbose(0) << "Element list loading failed." << endl;
 | 
|---|
| [042f82] | 894 |     configuration.RetrieveConfigPathAndName("main_pcp_linux");
 | 
|---|
 | 895 |   }
 | 
|---|
 | 896 |   return(ExitFlag);
 | 
|---|
| [ca2b83] | 897 | };
 | 
|---|
 | 898 | 
 | 
|---|
| [12b845] | 899 | /***************************************** Functions used to build all menus **********************/
 | 
|---|
 | 900 | 
 | 
|---|
 | 901 | void populateEditMoleculesMenu(Menu* editMoleculesMenu,MoleculeListClass *molecules, config *configuration, periodentafel *periode){
 | 
|---|
 | 902 |   // build the EditMoleculesMenu
 | 
|---|
 | 903 |   Action *createMoleculeAction = new MethodAction("createMoleculeAction",boost::bind(&MoleculeListClass::createNewMolecule,molecules,periode));
 | 
|---|
 | 904 |   new ActionMenuItem('c',"create new molecule",editMoleculesMenu,createMoleculeAction);
 | 
|---|
 | 905 | 
 | 
|---|
 | 906 |   Action *loadMoleculeAction = new MethodAction("loadMoleculeAction",boost::bind(&MoleculeListClass::loadFromXYZ,molecules,periode));
 | 
|---|
 | 907 |   new ActionMenuItem('l',"load molecule from xyz file",editMoleculesMenu,loadMoleculeAction);
 | 
|---|
 | 908 | 
 | 
|---|
 | 909 |   Action *changeFilenameAction = new MethodAction("changeFilenameAction",boost::bind(&MoleculeListClass::changeName,molecules));
 | 
|---|
 | 910 |   new ActionMenuItem('n',"change molecule's name",editMoleculesMenu,changeFilenameAction);
 | 
|---|
 | 911 | 
 | 
|---|
 | 912 |   Action *giveFilenameAction = new MethodAction("giveFilenameAction",boost::bind(&MoleculeListClass::setMoleculeFilename,molecules));
 | 
|---|
 | 913 |   new ActionMenuItem('N',"give molecules filename",editMoleculesMenu,giveFilenameAction);
 | 
|---|
 | 914 | 
 | 
|---|
 | 915 |   Action *parseAtomsAction = new MethodAction("parseAtomsAction",boost::bind(&MoleculeListClass::parseXYZIntoMolecule,molecules));
 | 
|---|
 | 916 |   new ActionMenuItem('p',"parse atoms in xyz file into molecule",editMoleculesMenu,parseAtomsAction);
 | 
|---|
 | 917 | 
 | 
|---|
 | 918 |   Action *eraseMoleculeAction = new MethodAction("eraseMoleculeAction",boost::bind(&MoleculeListClass::eraseMolecule,molecules));
 | 
|---|
 | 919 |   new ActionMenuItem('r',"remove a molecule",editMoleculesMenu,eraseMoleculeAction);
 | 
|---|
 | 920 | }
 | 
|---|
 | 921 | 
 | 
|---|
 | 922 | 
 | 
|---|
| [ca2b83] | 923 | /********************************************** Main routine **************************************/
 | 
|---|
| [14de469] | 924 | 
 | 
|---|
| [ca2b83] | 925 | int main(int argc, char **argv)
 | 
|---|
 | 926 | {
 | 
|---|
| [85bc8e] | 927 |   periodentafel *periode = new periodentafel;
 | 
|---|
 | 928 |     MoleculeListClass *molecules = new MoleculeListClass;
 | 
|---|
 | 929 |     molecule *mol = NULL;
 | 
|---|
 | 930 |     config *configuration = new config;
 | 
|---|
 | 931 |     Vector x, y, z, n;
 | 
|---|
 | 932 |     ifstream test;
 | 
|---|
 | 933 |     ofstream output;
 | 
|---|
 | 934 |     string line;
 | 
|---|
 | 935 |     char *ConfigFileName = NULL;
 | 
|---|
 | 936 |     int j;
 | 
|---|
 | 937 |     setVerbosity(0);
 | 
|---|
 | 938 |     /* structure of ParseCommandLineOptions will be refactored later */
 | 
|---|
| [235bed] | 939 |     j = ParseCommandLineOptions(argc, argv, molecules, periode, *configuration, ConfigFileName);
 | 
|---|
| [85bc8e] | 940 |     switch (j){
 | 
|---|
 | 941 |         case 255:
 | 
|---|
 | 942 |         case 2:
 | 
|---|
 | 943 |         case 1:
 | 
|---|
 | 944 |             delete (molecules);
 | 
|---|
 | 945 |             delete (periode);
 | 
|---|
 | 946 |             delete (configuration);
 | 
|---|
 | 947 |             Log() << Verbose(0) << "Maximum of allocated memory: " << MemoryUsageObserver::getInstance()->getMaximumUsedMemory() << endl;
 | 
|---|
 | 948 |             Log() << Verbose(0) << "Remaining non-freed memory: " << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;
 | 
|---|
 | 949 |             MemoryUsageObserver::getInstance()->purgeInstance();
 | 
|---|
 | 950 |             logger::purgeInstance();
 | 
|---|
 | 951 |             errorLogger::purgeInstance();
 | 
|---|
 | 952 |             return (j == 1 ? 0 : j);
 | 
|---|
 | 953 |         default:
 | 
|---|
 | 954 |             break;
 | 
|---|
| [1907a7] | 955 |     }
 | 
|---|
| [85bc8e] | 956 |     if(molecules->ListOfMolecules.size() == 0){
 | 
|---|
 | 957 |         mol = new molecule(periode);
 | 
|---|
 | 958 |         if(mol->cell_size[0] == 0.){
 | 
|---|
 | 959 |             Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl;
 | 
|---|
 | 960 |             for(int i = 0;i < 6;i++){
 | 
|---|
 | 961 |                 Log() << Verbose(1) << "Cell size" << i << ": ";
 | 
|---|
 | 962 |                 cin >> mol->cell_size[i];
 | 
|---|
 | 963 |             }
 | 
|---|
| [1907a7] | 964 |         }
 | 
|---|
 | 965 | 
 | 
|---|
| [85bc8e] | 966 |         mol->ActiveFlag = true;
 | 
|---|
 | 967 |         molecules->insert(mol);
 | 
|---|
 | 968 |     }
 | 
|---|
| [6ac7ee] | 969 | 
 | 
|---|
| [12b845] | 970 |     {
 | 
|---|
 | 971 |       menuPopulaters populaters;
 | 
|---|
 | 972 |       populaters.MakeEditMoleculesMenu = populateEditMoleculesMenu;
 | 
|---|
| [6ac7ee] | 973 | 
 | 
|---|
| [12b845] | 974 |       UIFactory::makeUserInterface(UIFactory::Text);
 | 
|---|
 | 975 |       MainWindow *mainWindow = UIFactory::get()->makeMainWindow(populaters,molecules, configuration, periode, ConfigFileName);
 | 
|---|
 | 976 |       mainWindow->display();
 | 
|---|
 | 977 |       delete mainWindow;
 | 
|---|
 | 978 |     }
 | 
|---|
| [6ac7ee] | 979 | 
 | 
|---|
| [85bc8e] | 980 |     if(periode->StorePeriodentafel(configuration->databasepath))
 | 
|---|
 | 981 |         Log() << Verbose(0) << "Saving of elements.db successful." << endl;
 | 
|---|
| [042f82] | 982 | 
 | 
|---|
| [85bc8e] | 983 |     else
 | 
|---|
 | 984 |         Log() << Verbose(0) << "Saving of elements.db failed." << endl;
 | 
|---|
| [042f82] | 985 | 
 | 
|---|
| [85bc8e] | 986 |     delete (molecules);
 | 
|---|
 | 987 |     delete(periode);
 | 
|---|
| [db6bf74] | 988 |   delete(configuration);
 | 
|---|
| [b66c22] | 989 | 
 | 
|---|
| [12b845] | 990 | 
 | 
|---|
| [cc04b7] | 991 | 
 | 
|---|
| [e138de] | 992 |   Log() << Verbose(0) <<  "Maximum of allocated memory: "
 | 
|---|
| [b66c22] | 993 |     << MemoryUsageObserver::getInstance()->getMaximumUsedMemory() << endl;
 | 
|---|
| [e138de] | 994 |   Log() << Verbose(0) <<  "Remaining non-freed memory: "
 | 
|---|
| [b66c22] | 995 |     << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;
 | 
|---|
| [db6bf74] | 996 |   MemoryUsageObserver::purgeInstance();
 | 
|---|
| [1614174] | 997 |   logger::purgeInstance();
 | 
|---|
 | 998 |   errorLogger::purgeInstance();
 | 
|---|
| [cc04b7] | 999 |   UIFactory::purgeInstance();
 | 
|---|
| [12b845] | 1000 |   ActionRegistry::purgeRegistry();
 | 
|---|
| [042f82] | 1001 |   return (0);
 | 
|---|
| [14de469] | 1002 | }
 | 
|---|
 | 1003 | 
 | 
|---|
 | 1004 | /********************************************** E N D **************************************************/
 | 
|---|