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