Changeset 375b458 for src/builder.cpp


Ignore:
Timestamp:
Jul 23, 2009, 1:53:01 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
51c910
Parents:
a5b2c3a
Message:

fixed indentation from tabs to two spaces.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/builder.cpp

    ra5b2c3a r375b458  
    1515 * \section about About the Program
    1616 *
    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.
     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.
    2020 *
    21  *      A configuration file may be written that is compatible to the format used by PCP - a parallel Car-Parrinello
    22  *      molecular dynamics implementation.
     21 *  A configuration file may be written that is compatible to the format used by PCP - a parallel Car-Parrinello
     22 *  molecular dynamics implementation.
    2323 *
    2424 * \section install Installation
    2525 *
    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
     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
    3030 *
    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
     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
    3434 *
    3535 * \section run Running
    3636 *
    37  *      The program can be executed by running: ./molecuilder
     37 *  The program can be executed by running: ./molecuilder
    3838 *
    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.
     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.
    4242 *
    4343 * \section ref References
    4444 *
    45  *      For the special configuration file format, see the documentation of pcp.
     45 *  For the special configuration file format, see the documentation of pcp.
    4646 *
    4747 */
     
    6363static void AddAtoms(periodentafel *periode, molecule *mol)
    6464{
    65         atom *first, *second, *third, *fourth;
    66         Vector **atoms;
    67         Vector x,y,z,n; // coordinates for absolute point in cell volume
    68         double a,b,c;
    69         char choice;    // menu choice char
    70         bool valid;
    71 
    72         cout << Verbose(0) << "===========ADD ATOM============================" << endl;
    73         cout << Verbose(0) << " a - state absolute coordinates of atom" << endl;
    74         cout << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;
    75         cout << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;
    76         cout << Verbose(0) << " d - state two atoms, two angles and a distance" << endl;
    77         cout << Verbose(0) << " e - least square distance position to a set of atoms" << endl;
    78         cout << Verbose(0) << "all else - go back" << endl;
    79         cout << Verbose(0) << "===============================================" << endl;
    80         cout << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;
    81         cout << Verbose(0) << "INPUT: ";
    82         cin >> choice;
    83 
    84         switch (choice) {
     65  atom *first, *second, *third, *fourth;
     66  Vector **atoms;
     67  Vector x,y,z,n;  // coordinates for absolute point in cell volume
     68  double a,b,c;
     69  char choice;  // menu choice char
     70  bool valid;
     71
     72  cout << Verbose(0) << "===========ADD ATOM============================" << endl;
     73  cout << Verbose(0) << " a - state absolute coordinates of atom" << endl;
     74  cout << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;
     75  cout << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;
     76  cout << Verbose(0) << " d - state two atoms, two angles and a distance" << endl;
     77  cout << Verbose(0) << " e - least square distance position to a set of atoms" << endl;
     78  cout << Verbose(0) << "all else - go back" << endl;
     79  cout << Verbose(0) << "===============================================" << endl;
     80  cout << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;
     81  cout << Verbose(0) << "INPUT: ";
     82  cin >> choice;
     83
     84  switch (choice) {
    8585    default:
    8686      cout << Verbose(0) << "Not a valid choice." << endl;
    8787      break;
    88                         case 'a': // absolute coordinates of atom
     88      case 'a': // absolute coordinates of atom
    8989        cout << Verbose(0) << "Enter absolute coordinates." << endl;
    9090        first = new atom;
    9191        first->x.AskPosition(mol->cell_size, false);
    92         first->type = periode->AskElement();    // give type
    93         mol->AddAtom(first);    // add to molecule
    94                                 break;
    95 
    96                         case 'b': // relative coordinates of atom wrt to reference point
     92        first->type = periode->AskElement();  // give type
     93        mol->AddAtom(first);  // add to molecule
     94        break;
     95
     96      case 'b': // relative coordinates of atom wrt to reference point
    9797        first = new atom;
    9898        valid = true;
     
    106106          cout << Verbose(0) << "\n";
    107107        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    108         first->type = periode->AskElement();    // give type
    109         mol->AddAtom(first);    // add to molecule
    110                                 break;
    111 
    112                         case 'c': // relative coordinates of atom wrt to already placed atom
     108        first->type = periode->AskElement();  // give type
     109        mol->AddAtom(first);  // add to molecule
     110        break;
     111
     112      case 'c': // relative coordinates of atom wrt to already placed atom
    113113        first = new atom;
    114114        valid = true;
     
    122122          }
    123123        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    124         first->type = periode->AskElement();    // give type
    125         mol->AddAtom(first);    // add to molecule
     124        first->type = periode->AskElement();  // give type
     125        mol->AddAtom(first);  // add to molecule
    126126        break;
    127127
     
    224224          cout << Verbose(0) << endl;
    225225        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    226         first->type = periode->AskElement();    // give type
    227         mol->AddAtom(first);    // add to molecule
    228                                 break;
    229 
    230                         case 'e': // least square distance position to a set of atoms
     226        first->type = periode->AskElement();  // give type
     227        mol->AddAtom(first);  // add to molecule
     228        break;
     229
     230      case 'e': // least square distance position to a set of atoms
    231231        first = new atom;
    232232        atoms = new (Vector*[128]);
     
    248248
    249249          first->x.Output((ofstream *)&cout);
    250           first->type = periode->AskElement();  // give type
    251           mol->AddAtom(first);  // add to molecule
     250          first->type = periode->AskElement();  // give type
     251          mol->AddAtom(first);  // add to molecule
    252252        } else {
    253253          delete first;
    254254          cout << Verbose(0) << "Please enter at least two vectors!\n";
    255255        }
    256                                 break;
    257         };
     256        break;
     257  };
    258258};
    259259
     
    263263static void CenterAtoms(molecule *mol)
    264264{
    265         Vector x, y, helper;
    266         char choice;    // menu choice char
    267 
    268         cout << Verbose(0) << "===========CENTER ATOMS=========================" << endl;
    269         cout << Verbose(0) << " a - on origin" << endl;
    270         cout << Verbose(0) << " b - on center of gravity" << endl;
    271         cout << Verbose(0) << " c - within box with additional boundary" << endl;
    272         cout << Verbose(0) << " d - within given simulation box" << endl;
    273         cout << Verbose(0) << "all else - go back" << endl;
    274         cout << Verbose(0) << "===============================================" << endl;
    275         cout << Verbose(0) << "INPUT: ";
    276         cin >> choice;
    277 
    278         switch (choice) {
    279                 default:
    280                         cout << Verbose(0) << "Not a valid choice." << endl;
    281                         break;
    282                 case 'a':
    283                         cout << Verbose(0) << "Centering atoms in config file on origin." << endl;
    284                         mol->CenterOrigin((ofstream *)&cout, &x);
    285                         break;
    286                 case 'b':
    287                         cout << Verbose(0) << "Centering atoms in config file on center of gravity." << endl;
    288                         mol->CenterGravity((ofstream *)&cout, &x);
    289                         break;
    290                 case 'c':
    291                         cout << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;
    292                         for (int i=0;i<NDIM;i++) {
    293                                 cout << Verbose(0) << "Enter axis " << i << " boundary: ";
    294                                 cin >> y.x[i];
    295                         }
    296                         mol->CenterEdge((ofstream *)&cout, &x); // make every coordinate positive
    297                         mol->Translate(&y); // translate by boundary
    298                         helper.CopyVector(&y);
    299                         helper.Scale(2.);
    300                         helper.AddVector(&x);
    301                         mol->SetBoxDimension(&helper);  // update Box of atoms by boundary
    302                         break;
    303                 case 'd':
    304                         cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
    305                         for (int i=0;i<NDIM;i++) {
    306                                 cout << Verbose(0) << "Enter axis " << i << " boundary: ";
    307                                 cin >> x.x[i];
    308                         }
    309                         // center
    310                         mol->CenterInBox((ofstream *)&cout, &x);
    311                         // update Box of atoms by boundary
    312                         mol->SetBoxDimension(&x);
    313                         break;
    314         }
     265  Vector x, y, helper;
     266  char choice;  // menu choice char
     267
     268  cout << Verbose(0) << "===========CENTER ATOMS=========================" << endl;
     269  cout << Verbose(0) << " a - on origin" << endl;
     270  cout << Verbose(0) << " b - on center of gravity" << endl;
     271  cout << Verbose(0) << " c - within box with additional boundary" << endl;
     272  cout << Verbose(0) << " d - within given simulation box" << endl;
     273  cout << Verbose(0) << "all else - go back" << endl;
     274  cout << Verbose(0) << "===============================================" << endl;
     275  cout << Verbose(0) << "INPUT: ";
     276  cin >> choice;
     277
     278  switch (choice) {
     279    default:
     280      cout << Verbose(0) << "Not a valid choice." << endl;
     281      break;
     282    case 'a':
     283      cout << Verbose(0) << "Centering atoms in config file on origin." << endl;
     284      mol->CenterOrigin((ofstream *)&cout, &x);
     285      break;
     286    case 'b':
     287      cout << Verbose(0) << "Centering atoms in config file on center of gravity." << endl;
     288      mol->CenterGravity((ofstream *)&cout, &x);
     289      break;
     290    case 'c':
     291      cout << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;
     292      for (int i=0;i<NDIM;i++) {
     293        cout << Verbose(0) << "Enter axis " << i << " boundary: ";
     294        cin >> y.x[i];
     295      }
     296      mol->CenterEdge((ofstream *)&cout, &x);  // make every coordinate positive
     297      mol->Translate(&y); // translate by boundary
     298      helper.CopyVector(&y);
     299      helper.Scale(2.);
     300      helper.AddVector(&x);
     301      mol->SetBoxDimension(&helper);  // update Box of atoms by boundary
     302      break;
     303    case 'd':
     304      cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
     305      for (int i=0;i<NDIM;i++) {
     306        cout << Verbose(0) << "Enter axis " << i << " boundary: ";
     307        cin >> x.x[i];
     308      }
     309      // center
     310      mol->CenterInBox((ofstream *)&cout, &x);
     311      // update Box of atoms by boundary
     312      mol->SetBoxDimension(&x);
     313      break;
     314  }
    315315};
    316316
     
    321321static void AlignAtoms(periodentafel *periode, molecule *mol)
    322322{
    323         atom *first, *second, *third;
    324         Vector x,n;
    325         char choice;    // menu choice char
    326 
    327         cout << Verbose(0) << "===========ALIGN ATOMS=========================" << endl;
    328         cout << Verbose(0) << " a - state three atoms defining align plane" << endl;
    329         cout << Verbose(0) << " b - state alignment vector" << endl;
    330         cout << Verbose(0) << " c - state two atoms in alignment direction" << endl;
    331         cout << Verbose(0) << " d - align automatically by least square fit" << endl;
    332         cout << Verbose(0) << "all else - go back" << endl;
    333         cout << Verbose(0) << "===============================================" << endl;
    334         cout << Verbose(0) << "INPUT: ";
    335         cin >> choice;
    336 
    337         switch (choice) {
    338                 default:
    339                 case 'a': // three atoms defining mirror plane
    340                         first = mol->AskAtom("Enter first atom: ");
    341                         second = mol->AskAtom("Enter second atom: ");
    342                         third = mol->AskAtom("Enter third atom: ");
    343 
    344                         n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
    345                         break;
    346                 case 'b': // normal vector of mirror plane
    347                         cout << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    348                         n.AskPosition(mol->cell_size,0);
    349                         n.Normalize();
    350                         break;
    351                 case 'c': // three atoms defining mirror plane
    352                         first = mol->AskAtom("Enter first atom: ");
    353                         second = mol->AskAtom("Enter second atom: ");
    354 
    355                         n.CopyVector((const Vector *)&first->x);
    356                         n.SubtractVector((const Vector *)&second->x);
    357                         n.Normalize();
    358                         break;
    359                 case 'd':
    360                         char shorthand[4];
    361                         Vector a;
    362                         struct lsq_params param;
    363                         do {
    364                                 fprintf(stdout, "Enter the element of atoms to be chosen: ");
    365                                 fscanf(stdin, "%3s", shorthand);
    366                         } while ((param.type = periode->FindElement(shorthand)) == NULL);
    367                         cout << Verbose(0) << "Element is " << param.type->name << endl;
    368                         mol->GetAlignvector(&param);
    369                         for (int i=NDIM;i--;) {
    370                                 x.x[i] = gsl_vector_get(param.x,i);
    371                                 n.x[i] = gsl_vector_get(param.x,i+NDIM);
    372                         }
    373                         gsl_vector_free(param.x);
    374                         cout << Verbose(0) << "Offset vector: ";
    375                         x.Output((ofstream *)&cout);
    376                         cout << Verbose(0) << endl;
    377                         n.Normalize();
    378                         break;
    379         };
    380         cout << Verbose(0) << "Alignment vector: ";
    381         n.Output((ofstream *)&cout);
    382         cout << Verbose(0) << endl;
    383         mol->Align(&n);
     323  atom *first, *second, *third;
     324  Vector x,n;
     325  char choice;  // menu choice char
     326
     327  cout << Verbose(0) << "===========ALIGN ATOMS=========================" << endl;
     328  cout << Verbose(0) << " a - state three atoms defining align plane" << endl;
     329  cout << Verbose(0) << " b - state alignment vector" << endl;
     330  cout << Verbose(0) << " c - state two atoms in alignment direction" << endl;
     331  cout << Verbose(0) << " d - align automatically by least square fit" << endl;
     332  cout << Verbose(0) << "all else - go back" << endl;
     333  cout << Verbose(0) << "===============================================" << endl;
     334  cout << Verbose(0) << "INPUT: ";
     335  cin >> choice;
     336
     337  switch (choice) {
     338    default:
     339    case 'a': // three atoms defining mirror plane
     340      first = mol->AskAtom("Enter first atom: ");
     341      second = mol->AskAtom("Enter second atom: ");
     342      third = mol->AskAtom("Enter third atom: ");
     343
     344      n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
     345      break;
     346    case 'b': // normal vector of mirror plane
     347      cout << Verbose(0) << "Enter normal vector of mirror plane." << endl;
     348      n.AskPosition(mol->cell_size,0);
     349      n.Normalize();
     350      break;
     351    case 'c': // three atoms defining mirror plane
     352      first = mol->AskAtom("Enter first atom: ");
     353      second = mol->AskAtom("Enter second atom: ");
     354
     355      n.CopyVector((const Vector *)&first->x);
     356      n.SubtractVector((const Vector *)&second->x);
     357      n.Normalize();
     358      break;
     359    case 'd':
     360      char shorthand[4];
     361      Vector a;
     362      struct lsq_params param;
     363      do {
     364        fprintf(stdout, "Enter the element of atoms to be chosen: ");
     365        fscanf(stdin, "%3s", shorthand);
     366      } while ((param.type = periode->FindElement(shorthand)) == NULL);
     367      cout << Verbose(0) << "Element is " << param.type->name << endl;
     368      mol->GetAlignvector(&param);
     369      for (int i=NDIM;i--;) {
     370        x.x[i] = gsl_vector_get(param.x,i);
     371        n.x[i] = gsl_vector_get(param.x,i+NDIM);
     372      }
     373      gsl_vector_free(param.x);
     374      cout << Verbose(0) << "Offset vector: ";
     375      x.Output((ofstream *)&cout);
     376      cout << Verbose(0) << endl;
     377      n.Normalize();
     378      break;
     379  };
     380  cout << Verbose(0) << "Alignment vector: ";
     381  n.Output((ofstream *)&cout);
     382  cout << Verbose(0) << endl;
     383  mol->Align(&n);
    384384};
    385385
     
    389389static void MirrorAtoms(molecule *mol)
    390390{
    391         atom *first, *second, *third;
    392         Vector n;
    393         char choice;    // menu choice char
    394 
    395         cout << Verbose(0) << "===========MIRROR ATOMS=========================" << endl;
    396         cout << Verbose(0) << " a - state three atoms defining mirror plane" << endl;
    397         cout << Verbose(0) << " b - state normal vector of mirror plane" << endl;
    398         cout << Verbose(0) << " c - state two atoms in normal direction" << endl;
    399         cout << Verbose(0) << "all else - go back" << endl;
    400         cout << Verbose(0) << "===============================================" << endl;
    401         cout << Verbose(0) << "INPUT: ";
    402         cin >> choice;
    403 
    404         switch (choice) {
    405                 default:
    406                 case 'a': // three atoms defining mirror plane
    407                         first = mol->AskAtom("Enter first atom: ");
    408                         second = mol->AskAtom("Enter second atom: ");
    409                         third = mol->AskAtom("Enter third atom: ");
    410 
    411                         n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
    412                         break;
    413                 case 'b': // normal vector of mirror plane
    414                         cout << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    415                         n.AskPosition(mol->cell_size,0);
    416                         n.Normalize();
    417                         break;
    418                 case 'c': // three atoms defining mirror plane
    419                         first = mol->AskAtom("Enter first atom: ");
    420                         second = mol->AskAtom("Enter second atom: ");
    421 
    422                         n.CopyVector((const Vector *)&first->x);
    423                         n.SubtractVector((const Vector *)&second->x);
    424                         n.Normalize();
    425                         break;
    426         };
    427         cout << Verbose(0) << "Normal vector: ";
    428         n.Output((ofstream *)&cout);
    429         cout << Verbose(0) << endl;
    430         mol->Mirror((const Vector *)&n);
     391  atom *first, *second, *third;
     392  Vector n;
     393  char choice;  // menu choice char
     394
     395  cout << Verbose(0) << "===========MIRROR ATOMS=========================" << endl;
     396  cout << Verbose(0) << " a - state three atoms defining mirror plane" << endl;
     397  cout << Verbose(0) << " b - state normal vector of mirror plane" << endl;
     398  cout << Verbose(0) << " c - state two atoms in normal direction" << endl;
     399  cout << Verbose(0) << "all else - go back" << endl;
     400  cout << Verbose(0) << "===============================================" << endl;
     401  cout << Verbose(0) << "INPUT: ";
     402  cin >> choice;
     403
     404  switch (choice) {
     405    default:
     406    case 'a': // three atoms defining mirror plane
     407      first = mol->AskAtom("Enter first atom: ");
     408      second = mol->AskAtom("Enter second atom: ");
     409      third = mol->AskAtom("Enter third atom: ");
     410
     411      n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
     412      break;
     413    case 'b': // normal vector of mirror plane
     414      cout << Verbose(0) << "Enter normal vector of mirror plane." << endl;
     415      n.AskPosition(mol->cell_size,0);
     416      n.Normalize();
     417      break;
     418    case 'c': // three atoms defining mirror plane
     419      first = mol->AskAtom("Enter first atom: ");
     420      second = mol->AskAtom("Enter second atom: ");
     421
     422      n.CopyVector((const Vector *)&first->x);
     423      n.SubtractVector((const Vector *)&second->x);
     424      n.Normalize();
     425      break;
     426  };
     427  cout << Verbose(0) << "Normal vector: ";
     428  n.Output((ofstream *)&cout);
     429  cout << Verbose(0) << endl;
     430  mol->Mirror((const Vector *)&n);
    431431};
    432432
     
    436436static void RemoveAtoms(molecule *mol)
    437437{
    438         atom *first, *second, *third;
    439         int axis;
    440         double tmp1, tmp2;
    441         char choice;    // menu choice char
    442 
    443         cout << Verbose(0) << "===========REMOVE ATOMS=========================" << endl;
    444         cout << Verbose(0) << " a - state atom for removal by number" << endl;
    445         cout << Verbose(0) << " b - keep only in radius around atom" << endl;
    446         cout << Verbose(0) << " c - remove this with one axis greater value" << endl;
    447         cout << Verbose(0) << "all else - go back" << endl;
    448         cout << Verbose(0) << "===============================================" << endl;
    449         cout << Verbose(0) << "INPUT: ";
    450         cin >> choice;
    451 
    452         switch (choice) {
    453                 default:
    454                 case 'a':
    455                         if (mol->RemoveAtom(mol->AskAtom("Enter number of atom within molecule: ")))
    456                                 cout << Verbose(1) << "Atom removed." << endl;
    457                         else
    458                                 cout << Verbose(1) << "Atom not found." << endl;
    459                         break;
    460                 case 'b':
    461                   third = mol->AskAtom("Enter number of atom as reference point: ");
    462                         cout << Verbose(0) << "Enter radius: ";
    463                         cin >> tmp1;
    464                         first = mol->start;
    465       second = first->next;
    466                         while(second != mol->end) {
    467                                 first = second;
    468         second = first->next;
    469                                 if (first->x.DistanceSquared((const Vector *)&third->x) > tmp1*tmp1) // distance to first above radius ...
    470                                         mol->RemoveAtom(first);
    471                         }
    472                         break;
    473                 case 'c':
    474                         cout << Verbose(0) << "Which axis is it: ";
    475                         cin >> axis;
    476                         cout << Verbose(0) << "Lower boundary: ";
    477                         cin >> tmp1;
    478                         cout << Verbose(0) << "Upper boundary: ";
    479                         cin >> tmp2;
    480                         first = mol->start;
     438  atom *first, *second, *third;
     439  int axis;
     440  double tmp1, tmp2;
     441  char choice;  // menu choice char
     442
     443  cout << Verbose(0) << "===========REMOVE ATOMS=========================" << endl;
     444  cout << Verbose(0) << " a - state atom for removal by number" << endl;
     445  cout << Verbose(0) << " b - keep only in radius around atom" << endl;
     446  cout << Verbose(0) << " c - remove this with one axis greater value" << endl;
     447  cout << Verbose(0) << "all else - go back" << endl;
     448  cout << Verbose(0) << "===============================================" << endl;
     449  cout << Verbose(0) << "INPUT: ";
     450  cin >> choice;
     451
     452  switch (choice) {
     453    default:
     454    case 'a':
     455      if (mol->RemoveAtom(mol->AskAtom("Enter number of atom within molecule: ")))
     456        cout << Verbose(1) << "Atom removed." << endl;
     457      else
     458        cout << Verbose(1) << "Atom not found." << endl;
     459      break;
     460    case 'b':
     461      third = mol->AskAtom("Enter number of atom as reference point: ");
     462      cout << Verbose(0) << "Enter radius: ";
     463      cin >> tmp1;
     464      first = mol->start;
    481465      second = first->next;
    482466      while(second != mol->end) {
    483467        first = second;
    484468        second = first->next;
    485                                 if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
    486                                   //cout << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
    487                                         mol->RemoveAtom(first);
    488                                 }
    489                         }
    490                         break;
    491         };
    492         //mol->Output((ofstream *)&cout);
    493         choice = 'r';
     469        if (first->x.DistanceSquared((const Vector *)&third->x) > tmp1*tmp1) // distance to first above radius ...
     470          mol->RemoveAtom(first);
     471      }
     472      break;
     473    case 'c':
     474      cout << Verbose(0) << "Which axis is it: ";
     475      cin >> axis;
     476      cout << Verbose(0) << "Lower boundary: ";
     477      cin >> tmp1;
     478      cout << Verbose(0) << "Upper boundary: ";
     479      cin >> tmp2;
     480      first = mol->start;
     481      second = first->next;
     482      while(second != mol->end) {
     483        first = second;
     484        second = first->next;
     485        if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
     486          //cout << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
     487          mol->RemoveAtom(first);
     488        }
     489      }
     490      break;
     491  };
     492  //mol->Output((ofstream *)&cout);
     493  choice = 'r';
    494494};
    495495
     
    500500static void MeasureAtoms(periodentafel *periode, molecule *mol, config *configuration)
    501501{
    502         atom *first, *second, *third;
    503         Vector x,y;
    504         double min[256], tmp1, tmp2, tmp3;
    505         int Z;
    506         char choice;    // menu choice char
    507 
    508         cout << Verbose(0) << "===========MEASURE ATOMS=========================" << endl;
    509         cout << Verbose(0) << " a - calculate bond length between one atom and all others" << endl;
    510         cout << Verbose(0) << " b - calculate bond length between two atoms" << endl;
    511         cout << Verbose(0) << " c - calculate bond angle" << endl;
    512         cout << Verbose(0) << " d - calculate principal axis of the system" << endl;
    513         cout << Verbose(0) << " e - calculate volume of the convex envelope" << endl;
    514         cout << Verbose(0) << " f - calculate temperature from current velocity" << endl;
    515         cout << Verbose(0) << " g - output all temperatures per step from velocities" << endl;
    516         cout << Verbose(0) << "all else - go back" << endl;
    517         cout << Verbose(0) << "===============================================" << endl;
    518         cout << Verbose(0) << "INPUT: ";
    519         cin >> choice;
    520 
    521         switch(choice) {
    522                 default:
    523                         cout << Verbose(1) << "Not a valid choice." << endl;
    524                         break;
    525                 case 'a':
    526                         first = mol->AskAtom("Enter first atom: ");
    527                         for (int i=MAX_ELEMENTS;i--;)
    528                                 min[i] = 0.;
    529 
    530                         second = mol->start;
    531                         while ((second->next != mol->end)) {
    532                                 second = second->next; // advance
    533                                 Z = second->type->Z;
    534                                 tmp1 = 0.;
    535                                 if (first != second) {
    536                                         x.CopyVector((const Vector *)&first->x);
    537                                         x.SubtractVector((const Vector *)&second->x);
    538                                         tmp1 = x.Norm();
    539                                 }
    540                                 if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
    541                                 //cout << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;
    542                         }
    543                         for (int i=MAX_ELEMENTS;i--;)
    544                                 if (min[i] != 0.) cout << Verbose(0) << "Minimum Bond length between " << first->type->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl;
    545                         break;
    546 
    547                 case 'b':
    548                         first = mol->AskAtom("Enter first atom: ");
    549                         second = mol->AskAtom("Enter second atom: ");
    550                         for (int i=NDIM;i--;)
    551                                 min[i] = 0.;
    552                         x.CopyVector((const Vector *)&first->x);
    553                         x.SubtractVector((const Vector *)&second->x);
    554                         tmp1 = x.Norm();
    555                         cout << Verbose(1) << "Distance vector is ";
    556                         x.Output((ofstream *)&cout);
    557                         cout << "." << endl << "Norm of distance is " << tmp1 << "." << endl;
    558                         break;
    559 
    560                 case 'c':
    561                         cout << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl;
    562                         first = mol->AskAtom("Enter first atom: ");
    563                         second = mol->AskAtom("Enter central atom: ");
    564                         third   = mol->AskAtom("Enter last atom: ");
    565                         tmp1 = tmp2 = tmp3 = 0.;
    566                         x.CopyVector((const Vector *)&first->x);
    567                         x.SubtractVector((const Vector *)&second->x);
    568                         y.CopyVector((const Vector *)&third->x);
    569                         y.SubtractVector((const Vector *)&second->x);
    570                         cout << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
    571                         cout << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
    572                         break;
    573                 case 'd':
    574                         cout << Verbose(0) << "Evaluating prinicipal axis." << endl;
    575                         cout << Verbose(0) << "Shall we rotate? [0/1]: ";
    576                         cin >> Z;
    577                         if ((Z >=0) && (Z <=1))
    578                                 mol->PrincipalAxisSystem((ofstream *)&cout, (bool)Z);
    579                         else
    580                                 mol->PrincipalAxisSystem((ofstream *)&cout, false);
    581                         break;
    582                 case 'e':
    583                         cout << Verbose(0) << "Evaluating volume of the convex envelope.";
    584                         VolumeOfConvexEnvelope((ofstream *)&cout, NULL, configuration, NULL, mol);
    585                         break;
    586                 case 'f':
    587                         mol->OutputTemperatureFromTrajectories((ofstream *)&cout, mol->MDSteps-1, mol->MDSteps, (ofstream *)&cout);
    588                         break;
    589                 case 'g':
    590                         {
    591                                 char filename[255];
    592                                 cout << "Please enter filename: " << endl;
    593                                 cin >> filename;
    594                                 cout << Verbose(1) << "Storing temperatures in " << filename << "." << endl;
    595                                 ofstream *output = new ofstream(filename, ios::trunc);
    596                                 if (!mol->OutputTemperatureFromTrajectories((ofstream *)&cout, 0, mol->MDSteps, output))
    597                                         cout << Verbose(2) << "File could not be written." << endl;
    598                                 else
    599                                         cout << Verbose(2) << "File stored." << endl;
    600                                 output->close();
    601                                 delete(output);
    602                         }
    603                         break;
    604         }
     502  atom *first, *second, *third;
     503  Vector x,y;
     504  double min[256], tmp1, tmp2, tmp3;
     505  int Z;
     506  char choice;  // menu choice char
     507
     508  cout << Verbose(0) << "===========MEASURE ATOMS=========================" << endl;
     509  cout << Verbose(0) << " a - calculate bond length between one atom and all others" << endl;
     510  cout << Verbose(0) << " b - calculate bond length between two atoms" << endl;
     511  cout << Verbose(0) << " c - calculate bond angle" << endl;
     512  cout << Verbose(0) << " d - calculate principal axis of the system" << endl;
     513  cout << Verbose(0) << " e - calculate volume of the convex envelope" << endl;
     514  cout << Verbose(0) << " f - calculate temperature from current velocity" << endl;
     515  cout << Verbose(0) << " g - output all temperatures per step from velocities" << endl;
     516  cout << Verbose(0) << "all else - go back" << endl;
     517  cout << Verbose(0) << "===============================================" << endl;
     518  cout << Verbose(0) << "INPUT: ";
     519  cin >> choice;
     520
     521  switch(choice) {
     522    default:
     523      cout << Verbose(1) << "Not a valid choice." << endl;
     524      break;
     525    case 'a':
     526      first = mol->AskAtom("Enter first atom: ");
     527      for (int i=MAX_ELEMENTS;i--;)
     528        min[i] = 0.;
     529
     530      second = mol->start;
     531      while ((second->next != mol->end)) {
     532        second = second->next; // advance
     533        Z = second->type->Z;
     534        tmp1 = 0.;
     535        if (first != second) {
     536          x.CopyVector((const Vector *)&first->x);
     537          x.SubtractVector((const Vector *)&second->x);
     538          tmp1 = x.Norm();
     539        }
     540        if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
     541        //cout << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;
     542      }
     543      for (int i=MAX_ELEMENTS;i--;)
     544        if (min[i] != 0.) cout << Verbose(0) << "Minimum Bond length between " << first->type->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl;
     545      break;
     546
     547    case 'b':
     548      first = mol->AskAtom("Enter first atom: ");
     549      second = mol->AskAtom("Enter second atom: ");
     550      for (int i=NDIM;i--;)
     551        min[i] = 0.;
     552      x.CopyVector((const Vector *)&first->x);
     553      x.SubtractVector((const Vector *)&second->x);
     554      tmp1 = x.Norm();
     555      cout << Verbose(1) << "Distance vector is ";
     556      x.Output((ofstream *)&cout);
     557      cout << "." << endl << "Norm of distance is " << tmp1 << "." << endl;
     558      break;
     559
     560    case 'c':
     561      cout << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl;
     562      first = mol->AskAtom("Enter first atom: ");
     563      second = mol->AskAtom("Enter central atom: ");
     564      third  = mol->AskAtom("Enter last atom: ");
     565      tmp1 = tmp2 = tmp3 = 0.;
     566      x.CopyVector((const Vector *)&first->x);
     567      x.SubtractVector((const Vector *)&second->x);
     568      y.CopyVector((const Vector *)&third->x);
     569      y.SubtractVector((const Vector *)&second->x);
     570      cout << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
     571      cout << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
     572      break;
     573    case 'd':
     574      cout << Verbose(0) << "Evaluating prinicipal axis." << endl;
     575      cout << Verbose(0) << "Shall we rotate? [0/1]: ";
     576      cin >> Z;
     577      if ((Z >=0) && (Z <=1))
     578        mol->PrincipalAxisSystem((ofstream *)&cout, (bool)Z);
     579      else
     580        mol->PrincipalAxisSystem((ofstream *)&cout, false);
     581      break;
     582    case 'e':
     583      cout << Verbose(0) << "Evaluating volume of the convex envelope.";
     584      VolumeOfConvexEnvelope((ofstream *)&cout, NULL, configuration, NULL, mol);
     585      break;
     586    case 'f':
     587      mol->OutputTemperatureFromTrajectories((ofstream *)&cout, mol->MDSteps-1, mol->MDSteps, (ofstream *)&cout);
     588      break;
     589    case 'g':
     590      {
     591        char filename[255];
     592        cout << "Please enter filename: " << endl;
     593        cin >> filename;
     594        cout << Verbose(1) << "Storing temperatures in " << filename << "." << endl;
     595        ofstream *output = new ofstream(filename, ios::trunc);
     596        if (!mol->OutputTemperatureFromTrajectories((ofstream *)&cout, 0, mol->MDSteps, output))
     597          cout << Verbose(2) << "File could not be written." << endl;
     598        else
     599          cout << Verbose(2) << "File stored." << endl;
     600        output->close();
     601        delete(output);
     602      }
     603      break;
     604  }
    605605};
    606606
     
    611611static void FragmentAtoms(molecule *mol, config *configuration)
    612612{
    613         int Order1;
    614         clock_t start, end;
    615 
    616         cout << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
    617         cout << Verbose(0) << "What's the desired bond order: ";
    618         cin >> Order1;
    619         if (mol->first->next != mol->last) {    // there are bonds
    620                 start = clock();
    621                 mol->FragmentMolecule((ofstream *)&cout, Order1, configuration);
    622                 end = clock();
    623                 cout << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
    624         } else
    625                 cout << Verbose(0) << "Connection matrix has not yet been generated!" << endl;
     613  int Order1;
     614  clock_t start, end;
     615
     616  cout << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
     617  cout << Verbose(0) << "What's the desired bond order: ";
     618  cin >> Order1;
     619  if (mol->first->next != mol->last) {  // there are bonds
     620    start = clock();
     621    mol->FragmentMolecule((ofstream *)&cout, Order1, configuration);
     622    end = clock();
     623    cout << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
     624  } else
     625    cout << Verbose(0) << "Connection matrix has not yet been generated!" << endl;
    626626};
    627627
     
    10531053static void testroutine(MoleculeListClass *molecules)
    10541054{
    1055         // the current test routine checks the functionality of the KeySet&Graph concept:
    1056         // We want to have a multiindex (the KeySet) describing a unique subgraph
     1055  // the current test routine checks the functionality of the KeySet&Graph concept:
     1056  // We want to have a multiindex (the KeySet) describing a unique subgraph
    10571057  int i, comp, counter=0;
    10581058
     
    10671067  atom *Walker = mol->start;
    10681068
    1069         // generate some KeySets
    1070         cout << "Generating KeySets." << endl;
    1071         KeySet TestSets[mol->AtomCount+1];
    1072         i=1;
    1073         while (Walker->next != mol->end) {
    1074                 Walker = Walker->next;
    1075                 for (int j=0;j<i;j++) {
    1076                         TestSets[j].insert(Walker->nr);
    1077                 }
    1078                 i++;
    1079         }
    1080         cout << "Testing insertion of already present item in KeySets." << endl;
    1081         KeySetTestPair test;
    1082         test = TestSets[mol->AtomCount-1].insert(Walker->nr);
    1083         if (test.second) {
    1084                 cout << Verbose(1) << "Insertion worked?!" << endl;
    1085         } else {
    1086                 cout << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
    1087         }
    1088         TestSets[mol->AtomCount].insert(mol->end->previous->nr);
    1089         TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
    1090 
    1091         // constructing Graph structure
    1092         cout << "Generating Subgraph class." << endl;
    1093         Graph Subgraphs;
    1094 
    1095         // insert KeySets into Subgraphs
    1096         cout << "Inserting KeySets into Subgraph class." << endl;
    1097         for (int j=0;j<mol->AtomCount;j++) {
    1098                 Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
    1099         }
    1100         cout << "Testing insertion of already present item in Subgraph." << endl;
    1101         GraphTestPair test2;
    1102         test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
    1103         if (test2.second) {
    1104                 cout << Verbose(1) << "Insertion worked?!" << endl;
    1105         } else {
    1106                 cout << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl;
    1107         }
    1108 
    1109         // show graphs
    1110         cout << "Showing Subgraph's contents, checking that it's sorted." << endl;
    1111         Graph::iterator A = Subgraphs.begin();
    1112         while (A !=     Subgraphs.end()) {
    1113                 cout << (*A).second.first << ": ";
    1114                 KeySet::iterator key = (*A).first.begin();
    1115                 comp = -1;
    1116                 while (key != (*A).first.end()) {
    1117                         if ((*key) > comp)
    1118                                 cout << (*key) << " ";
    1119                         else
    1120                                 cout << (*key) << "! ";
    1121                         comp = (*key);
    1122                         key++;
    1123                 }
    1124                 cout << endl;
    1125                 A++;
    1126         }
    1127         delete(mol);
     1069  // generate some KeySets
     1070  cout << "Generating KeySets." << endl;
     1071  KeySet TestSets[mol->AtomCount+1];
     1072  i=1;
     1073  while (Walker->next != mol->end) {
     1074    Walker = Walker->next;
     1075    for (int j=0;j<i;j++) {
     1076      TestSets[j].insert(Walker->nr);
     1077    }
     1078    i++;
     1079  }
     1080  cout << "Testing insertion of already present item in KeySets." << endl;
     1081  KeySetTestPair test;
     1082  test = TestSets[mol->AtomCount-1].insert(Walker->nr);
     1083  if (test.second) {
     1084    cout << Verbose(1) << "Insertion worked?!" << endl;
     1085  } else {
     1086    cout << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
     1087  }
     1088  TestSets[mol->AtomCount].insert(mol->end->previous->nr);
     1089  TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
     1090
     1091  // constructing Graph structure
     1092  cout << "Generating Subgraph class." << endl;
     1093  Graph Subgraphs;
     1094
     1095  // insert KeySets into Subgraphs
     1096  cout << "Inserting KeySets into Subgraph class." << endl;
     1097  for (int j=0;j<mol->AtomCount;j++) {
     1098    Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
     1099  }
     1100  cout << "Testing insertion of already present item in Subgraph." << endl;
     1101  GraphTestPair test2;
     1102  test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
     1103  if (test2.second) {
     1104    cout << Verbose(1) << "Insertion worked?!" << endl;
     1105  } else {
     1106    cout << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl;
     1107  }
     1108
     1109  // show graphs
     1110  cout << "Showing Subgraph's contents, checking that it's sorted." << endl;
     1111  Graph::iterator A = Subgraphs.begin();
     1112  while (A !=  Subgraphs.end()) {
     1113    cout << (*A).second.first << ": ";
     1114    KeySet::iterator key = (*A).first.begin();
     1115    comp = -1;
     1116    while (key != (*A).first.end()) {
     1117      if ((*key) > comp)
     1118        cout << (*key) << " ";
     1119      else
     1120        cout << (*key) << "! ";
     1121      comp = (*key);
     1122      key++;
     1123    }
     1124    cout << endl;
     1125    A++;
     1126  }
     1127  delete(mol);
    11281128};
    11291129
     
    11361136static void SaveConfig(char *ConfigFileName, config *configuration, periodentafel *periode, MoleculeListClass *molecules)
    11371137{
    1138         char filename[MAXSTRINGSIZE];
    1139         ofstream output;
    1140         molecule *mol = new molecule(periode);
    1141 
    1142         // merge all molecules in MoleculeListClass into this molecule
    1143         int N = molecules->ListOfMolecules.size();
    1144         int *src = new int(N);
    1145         N=0;
    1146         for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    1147           src[N++] = (*ListRunner)->IndexNr;
    1148         molecules->SimpleMultiAdd(mol, src, N);
    1149 
    1150         cout << Verbose(0) << "Storing configuration ... " << endl;
    1151         // get correct valence orbitals
    1152         mol->CalculateOrbitals(*configuration);
    1153         configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble;
    1154         strcpy(filename, ConfigFileName);
    1155         if (ConfigFileName != NULL) { // test the file name
    1156                 output.open(ConfigFileName, ios::trunc);
    1157         } else if (strlen(configuration->configname) != 0) {
    1158                 strcpy(filename, configuration->configname);
    1159                 output.open(configuration->configname, ios::trunc);
    1160                 } else {
    1161                         strcpy(filename, DEFAULTCONFIG);
    1162                         output.open(DEFAULTCONFIG, ios::trunc);
    1163                 }
    1164         output.close();
    1165         output.clear();
    1166         cout << Verbose(0) << "Saving of config file ";
    1167         if (configuration->Save(filename, periode, mol))
    1168                 cout << "successful." << endl;
    1169         else
    1170                 cout << "failed." << endl;
    1171 
    1172         // and save to xyz file
    1173         if (ConfigFileName != NULL) {
    1174                 strcpy(filename, ConfigFileName);
    1175                 strcat(filename, ".xyz");
    1176                 output.open(filename, ios::trunc);
    1177         }
    1178         if (output == NULL) {
    1179                 strcpy(filename,"main_pcp_linux");
    1180                 strcat(filename, ".xyz");
    1181                 output.open(filename, ios::trunc);
    1182         }
    1183         cout << Verbose(0) << "Saving of XYZ file ";
    1184         if (mol->MDSteps <= 1) {
    1185                 if (mol->OutputXYZ(&output))
    1186                         cout << "successful." << endl;
    1187                 else
    1188                         cout << "failed." << endl;
    1189         } else {
    1190                 if (mol->OutputTrajectoriesXYZ(&output))
    1191                         cout << "successful." << endl;
    1192                 else
    1193                         cout << "failed." << endl;
    1194         }
    1195         output.close();
    1196         output.clear();
    1197 
    1198         // and save as MPQC configuration
    1199         if (ConfigFileName != NULL)
    1200                 strcpy(filename, ConfigFileName);
    1201         if (output == NULL)
    1202                 strcpy(filename,"main_pcp_linux");
    1203         cout << Verbose(0) << "Saving as mpqc input ";
    1204         if (configuration->SaveMPQC(filename, mol))
    1205                 cout << "done." << endl;
    1206         else
    1207                 cout << "failed." << endl;
    1208 
    1209         if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
    1210                 cerr << "WARNING: config is found under different path then stated in config file::defaultpath!" << endl;
    1211         }
    1212         delete(mol);
     1138  char filename[MAXSTRINGSIZE];
     1139  ofstream output;
     1140  molecule *mol = new molecule(periode);
     1141
     1142  // merge all molecules in MoleculeListClass into this molecule
     1143  int N = molecules->ListOfMolecules.size();
     1144  int *src = new int(N);
     1145  N=0;
     1146  for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     1147    src[N++] = (*ListRunner)->IndexNr;
     1148  molecules->SimpleMultiAdd(mol, src, N);
     1149
     1150  cout << Verbose(0) << "Storing configuration ... " << endl;
     1151  // get correct valence orbitals
     1152  mol->CalculateOrbitals(*configuration);
     1153  configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble;
     1154  strcpy(filename, ConfigFileName);
     1155  if (ConfigFileName != NULL) { // test the file name
     1156    output.open(ConfigFileName, ios::trunc);
     1157  } else if (strlen(configuration->configname) != 0) {
     1158    strcpy(filename, configuration->configname);
     1159    output.open(configuration->configname, ios::trunc);
     1160    } else {
     1161      strcpy(filename, DEFAULTCONFIG);
     1162      output.open(DEFAULTCONFIG, ios::trunc);
     1163    }
     1164  output.close();
     1165  output.clear();
     1166  cout << Verbose(0) << "Saving of config file ";
     1167  if (configuration->Save(filename, periode, mol))
     1168    cout << "successful." << endl;
     1169  else
     1170    cout << "failed." << endl;
     1171
     1172  // and save to xyz file
     1173  if (ConfigFileName != NULL) {
     1174    strcpy(filename, ConfigFileName);
     1175    strcat(filename, ".xyz");
     1176    output.open(filename, ios::trunc);
     1177  }
     1178  if (output == NULL) {
     1179    strcpy(filename,"main_pcp_linux");
     1180    strcat(filename, ".xyz");
     1181    output.open(filename, ios::trunc);
     1182  }
     1183  cout << Verbose(0) << "Saving of XYZ file ";
     1184  if (mol->MDSteps <= 1) {
     1185    if (mol->OutputXYZ(&output))
     1186      cout << "successful." << endl;
     1187    else
     1188      cout << "failed." << endl;
     1189  } else {
     1190    if (mol->OutputTrajectoriesXYZ(&output))
     1191      cout << "successful." << endl;
     1192    else
     1193      cout << "failed." << endl;
     1194  }
     1195  output.close();
     1196  output.clear();
     1197
     1198  // and save as MPQC configuration
     1199  if (ConfigFileName != NULL)
     1200    strcpy(filename, ConfigFileName);
     1201  if (output == NULL)
     1202    strcpy(filename,"main_pcp_linux");
     1203  cout << Verbose(0) << "Saving as mpqc input ";
     1204  if (configuration->SaveMPQC(filename, mol))
     1205    cout << "done." << endl;
     1206  else
     1207    cout << "failed." << endl;
     1208
     1209  if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
     1210    cerr << "WARNING: config is found under different path then stated in config file::defaultpath!" << endl;
     1211  }
     1212  delete(mol);
    12131213};
    12141214
     
    12251225static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode, config& configuration, char *&ConfigFileName, char *&PathToDatabases)
    12261226{
    1227         Vector x,y,z,n; // coordinates for absolute point in cell volume
    1228         double *factor; // unit factor if desired
    1229         ifstream test;
    1230         ofstream output;
    1231         string line;
    1232         atom *first;
    1233         bool SaveFlag = false;
    1234         int ExitFlag = 0;
    1235         int j;
    1236         double volume = 0.;
    1237         enum ConfigStatus config_present = absent;
    1238         clock_t start,end;
    1239         int argptr;
    1240         PathToDatabases = LocalPath;
    1241 
    1242         // simply create a new molecule, wherein the config file is loaded and the manipulation takes place
    1243         molecule *mol = new molecule(periode);
    1244         molecules->insert(mol);
    1245 
    1246         if (argc > 1) { // config file specified as option
    1247                 // 1. : Parse options that just set variables or print help
    1248                 argptr = 1;
    1249                 do {
    1250                         if (argv[argptr][0] == '-') {
    1251                                 cout << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n";
    1252                                 argptr++;
    1253                                 switch(argv[argptr-1][1]) {
    1254                                         case 'h':
    1255                                         case 'H':
    1256                                         case '?':
    1257                                                 cout << "MoleCuilder suite" << endl << "==================" << endl << endl;
    1258                                                 cout << "Usage: " << argv[0] << "[config file] [-{acefpsthH?vfrp}] [further arguments]" << endl;
    1259                                                 cout << "or simply " << argv[0] << " without arguments for interactive session." << endl;
    1260                                                 cout << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl;
    1261                                                 cout << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl;
    1262                                                 cout << "\t-b x1 x2 x3\tCenter atoms in domain with given edge lengths of (x1,x2,x3)." << endl;
    1263                                                 cout << "\t-B <basis>\tSetting basis to store to MPQC config files." << endl;
    1264                                                 cout << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl;
    1265                                                 cout << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl;
    1266                                                 cout << "\t-O\tCenter atoms in origin." << endl;
    1267                                                 cout << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl;
    1268                                                 cout << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl;
    1269                                                 cout << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl;
    1270                                                 cout << "\t-f/F <dist> <order>\tFragments the molecule in BOSSANOVA manner (with/out rings compressed) and stores config files in same dir as config (return code 0 - fragmented, 2 - no fragmentation necessary)." << endl;
    1271                                                 cout << "\t-h/-H/-?\tGive this help screen." << endl;
    1272                                                 cout << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl;
    1273                                                 cout << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl;
    1274                                                 cout << "\t-N <radius> <file>\tGet non-convex-envelope." << endl;
    1275                                                 cout << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl;
    1276                                                 cout << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl;
    1277                                                 cout << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl;
    1278                                                 cout << "\t-r\t\tConvert file from an old pcp syntax." << endl;
    1279                                                 cout << "\t-R\t\tRemove all atoms out of sphere around a given one." << endl;
    1280                                                 cout << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl;
    1281                                                 cout << "\t-T <file> Store temperatures from the config file in <file>." << endl;
    1282                                                 cout << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl;
    1283                                                 cout << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl;
    1284                                                 cout << "\t-v/-V\t\tGives version information." << endl;
    1285                                                 cout << "Note: config files must not begin with '-' !" << endl;
    1286                                                 delete(mol);
    1287                                                 delete(periode);
    1288                                                 return (1);
    1289                                                 break;
    1290                                         case 'v':
    1291                                         case 'V':
    1292                                                 cout << argv[0] << " " << VERSIONSTRING << endl;
    1293                                                 cout << "Build your own molecule position set." << endl;
    1294                                                 delete(mol);
    1295                                                 delete(periode);
    1296                                                 return (1);
    1297                                                 break;
    1298                                         case 'e':
    1299                                                 if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1300                                                         cerr << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl;
    1301                                                 } else {
    1302                                                         cout << "Using " << argv[argptr] << " as elements database." << endl;
    1303                                                         PathToDatabases = argv[argptr];
    1304                                                         argptr+=1;
    1305                                                 }
    1306                                                 break;
    1307                                         case 'n':
    1308                                                 cout << "I won't parse trajectories." << endl;
    1309                                                 configuration.FastParsing = true;
    1310                                                 break;
    1311                                         default:        // no match? Step on
    1312                                                 argptr++;
    1313                                                 break;
    1314                                 }
    1315                         } else
    1316                                 argptr++;
    1317                 } while (argptr < argc);
    1318 
    1319                 // 2. Parse the element database
    1320                 if (periode->LoadPeriodentafel(PathToDatabases)) {
    1321                         cout << Verbose(0) << "Element list loaded successfully." << endl;
    1322                         //periode->Output((ofstream *)&cout);
    1323                 } else {
    1324                         cout << Verbose(0) << "Element list loading failed." << endl;
    1325                         return 1;
    1326                 }
    1327                 // 3. Find config file name and parse if possible
    1328                 if (argv[1][0] != '-') {
    1329                         cout << Verbose(0) << "Config file given." << endl;
    1330                         test.open(argv[1], ios::in);
    1331                         if (test == NULL) {
    1332                                 //return (1);
    1333                                 output.open(argv[1], ios::out);
    1334                                 if (output == NULL) {
    1335                                         cout << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl;
    1336                                         config_present = absent;
    1337                                 } else {
    1338                                         cout << "Empty configuration file." << endl;
    1339                                         ConfigFileName = argv[1];
    1340                                         config_present = empty;
    1341                                         output.close();
    1342                                 }
    1343                         } else {
    1344                                 test.close();
    1345                                 ConfigFileName = argv[1];
    1346                                 cout << Verbose(1) << "Specified config file found, parsing ... ";
    1347                                 switch (configuration.TestSyntax(ConfigFileName, periode, mol)) {
    1348                                         case 1:
    1349                                                 cout << "new syntax." << endl;
    1350                                                 configuration.Load(ConfigFileName, periode, mol);
    1351                                                 config_present = present;
    1352                                                 break;
    1353                                         case 0:
    1354                                                 cout << "old syntax." << endl;
    1355                                                 configuration.LoadOld(ConfigFileName, periode, mol);
    1356                                                 config_present = present;
    1357                                                 break;
    1358                                         default:
    1359                                                 cout << "Unknown syntax or empty, yet present file." << endl;
    1360                                                 config_present = empty;
    1361                         }
    1362                         }
    1363                 } else
    1364                         config_present = absent;
    1365                 // 4. parse again through options, now for those depending on elements db and config presence
    1366                 argptr = 1;
    1367                 do {
    1368                         cout << "Current Command line argument: " << argv[argptr] << "." << endl;
    1369                         if (argv[argptr][0] == '-') {
    1370                                 argptr++;
    1371                                 if ((config_present == present) || (config_present == empty)) {
    1372                                         switch(argv[argptr-1][1]) {
    1373                                                 case 'p':
    1374                                                         ExitFlag = 1;
    1375                                                         if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1376                                                                 ExitFlag = 255;
    1377                                                                 cerr << "Not enough arguments for parsing: -p <xyz file>" << endl;
    1378                                                         } else {
    1379                                                                 SaveFlag = true;
    1380                                                                 cout << Verbose(1) << "Parsing xyz file for new atoms." << endl;
    1381                                                                 if (!mol->AddXYZFile(argv[argptr]))
    1382                                                                         cout << Verbose(2) << "File not found." << endl;
    1383                                                                 else {
    1384                                                                         cout << Verbose(2) << "File found and parsed." << endl;
    1385                                                                         config_present = present;
    1386                                                                 }
    1387                                                         }
    1388                                                         break;
    1389                                                 case 'a':
    1390                                                         ExitFlag = 1;
    1391                                                         if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1]))) {
    1392                                                                 ExitFlag = 255;
    1393                                                                 cerr << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl;
    1394                                                         } else {
    1395                                                                 SaveFlag = true;
    1396                                                                 cout << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), ";
    1397                                                                 first = new atom;
    1398                                                                 first->type = periode->FindElement(atoi(argv[argptr]));
    1399                                                                 if (first->type != NULL)
    1400                                                                         cout << Verbose(2) << "found element " << first->type->name << endl;
    1401                                                                 for (int i=NDIM;i--;)
    1402                                                                         first->x.x[i] = atof(argv[argptr+1+i]);
    1403                                                                 if (first->type != NULL) {
    1404                                                                         mol->AddAtom(first);    // add to molecule
    1405                                                                         if ((config_present == empty) && (mol->AtomCount != 0))
    1406                                                                                 config_present = present;
    1407                                                                 } else
    1408                                                                         cerr << Verbose(1) << "Could not find the specified element." << endl;
    1409                                                                 argptr+=4;
    1410                                                         }
    1411                                                         break;
    1412                                                 default:        // no match? Don't step on (this is done in next switch's default)
    1413                                                         break;
    1414                                         }
    1415                                 }
    1416                                 if (config_present == present) {
    1417                                         switch(argv[argptr-1][1]) {
    1418                                                 case 'B':
    1419                                                         if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1420                                                                 ExitFlag = 255;
    1421                                                                 cerr << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl;
    1422                                                         } else {
    1423                                                                 configuration.basis = argv[argptr];
    1424                                                                 cout << Verbose(1) << "Setting MPQC basis to " << configuration.basis << "." << endl;
    1425                                                                 argptr+=1;
    1426                                                         }
    1427                                                         break;
    1428                                                 case 'D':
    1429                                                         ExitFlag = 1;
    1430                                                         {
    1431                                                                 cout << Verbose(1) << "Depth-First-Search Analysis." << endl;
    1432                                                                 MoleculeLeafClass *Subgraphs = NULL;                    // list of subgraphs from DFS analysis
    1433                                                                 int *MinimumRingSize = new int[mol->AtomCount];
    1434                                                                 atom ***ListOfLocalAtoms = NULL;
    1435                                                                 int FragmentCounter = 0;
    1436                                                                 class StackClass<bond *> *BackEdgeStack = NULL;
    1437                                                                 class StackClass<bond *> *LocalBackEdgeStack = NULL;
    1438                                                                 mol->CreateAdjacencyList((ofstream *)&cout, atof(argv[argptr]), configuration.GetIsAngstroem());
    1439                                                                 mol->CreateListOfBondsPerAtom((ofstream *)&cout);
    1440                                                                 Subgraphs = mol->DepthFirstSearchAnalysis((ofstream *)&cout, BackEdgeStack);
    1441                                                                 if (Subgraphs != NULL) {
    1442                                                                         Subgraphs->next->FillBondStructureFromReference((ofstream *)&cout, mol, (FragmentCounter = 0), ListOfLocalAtoms, false);        // we want to keep the created ListOfLocalAtoms
    1443                                                                         while (Subgraphs->next != NULL) {
    1444                                                                                 Subgraphs = Subgraphs->next;
    1445                                                                                 LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
    1446                                                                                 Subgraphs->Leaf->PickLocalBackEdges((ofstream *)&cout, ListOfLocalAtoms[FragmentCounter++], BackEdgeStack, LocalBackEdgeStack);
    1447                                                                                 Subgraphs->Leaf->CyclicStructureAnalysis((ofstream *)&cout, BackEdgeStack, MinimumRingSize);
    1448                                                                                 delete(LocalBackEdgeStack);
    1449                                                                                 delete(Subgraphs->previous);
    1450                                                                         }
    1451                                                                         delete(Subgraphs);
    1452                                                                         for (int i=0;i<FragmentCounter;i++)
    1453                                                                                 Free((void **)&ListOfLocalAtoms[FragmentCounter], "ParseCommandLineOptions: **ListOfLocalAtoms[]");
    1454                                                                         Free((void **)&ListOfLocalAtoms, "ParseCommandLineOptions: ***ListOfLocalAtoms");
    1455                                                                 }
    1456                                                                 delete(BackEdgeStack);
    1457                                                                 delete[](MinimumRingSize);
    1458                                                         }
    1459                                                         //argptr+=1;
    1460                                                         break;
    1461                                                 case 'E':
    1462                                                         ExitFlag = 1;
    1463                                                         if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) {
    1464                                                                 ExitFlag = 255;
    1465                                                                 cerr << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl;
    1466                                                         } else {
    1467                                                                 SaveFlag = true;
    1468                                                                 cout << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl;
    1469                                                                 first = mol->FindAtom(atoi(argv[argptr]));
    1470                                                                 first->type = periode->FindElement(atoi(argv[argptr+1]));
    1471                                                                 argptr+=2;
    1472                                                         }
    1473                                                         break;
    1474                                                 case 'A':
    1475                                                         ExitFlag = 1;
    1476                                                         if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1477                                                                 ExitFlag =255;
    1478                                                                 cerr << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl;
    1479                                                         } else {
    1480                                                                 cout << "Parsing bonds from " << argv[argptr] << "." << endl;
    1481                                                                 ifstream *input = new ifstream(argv[argptr]);
    1482                                                                 mol->CreateAdjacencyList2((ofstream *)&cout, input);
    1483                                                                 input->close();
    1484                                                                 argptr+=1;
    1485                                                         }
    1486                                                         break;
    1487                                                 case 'N':
    1488                                                         ExitFlag = 1;
    1489                                                         if ((argptr+1 >= argc) || (argv[argptr+1][0] == '-')){
    1490                                                                 ExitFlag = 255;
    1491                                                                 cerr << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl;
    1492                                                         } else {
    1493                                                                 class Tesselation T;
    1494                                                                 int N = 15;
    1495                                                                 int number = 100;
    1496                                                                 string filename(argv[argptr+1]);
    1497                                                                 filename.append(".csv");
    1498                                                                 cout << Verbose(0) << "Evaluating non-convex envelope.";
    1499                                                                 cout << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl;
    1500                                                                 LinkedCell LCList(mol, atof(argv[argptr]));             // \NOTE not twice the radius??
    1501                                                                 Find_non_convex_border((ofstream *)&cout, mol, &T, &LCList, argv[argptr+1], atof(argv[argptr]));
    1502                                                                 //FindDistributionOfEllipsoids((ofstream *)&cout, &T, &LCList, N, number, filename.c_str());
    1503                                                                 argptr+=2;
    1504                                                         }
    1505                                                         break;
    1506                                                 case 'T':
    1507                                                         ExitFlag = 1;
    1508                                                         if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1509                                                                 ExitFlag = 255;
    1510                                                                 cerr << "Not enough or invalid arguments given for storing tempature: -T <temperature file>" << endl;
    1511                                                         } else {
    1512                                                                 cout << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl;
    1513                                                                 ofstream *output = new ofstream(argv[argptr], ios::trunc);
    1514                                                                 if (!mol->OutputTemperatureFromTrajectories((ofstream *)&cout, 0, mol->MDSteps, output))
    1515                                                                         cout << Verbose(2) << "File could not be written." << endl;
    1516                                                                 else
    1517                                                                         cout << Verbose(2) << "File stored." << endl;
    1518                                                                 output->close();
    1519                                                                 delete(output);
    1520                                                                 argptr+=1;
    1521                                                         }
    1522                                                         break;
    1523                                                 case 'P':
    1524                                                         ExitFlag = 1;
    1525                                                         if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1526                                                                 ExitFlag = 255;
    1527                                                                 cerr << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl;
    1528                                                         } else {
    1529                                                                 SaveFlag = true;
    1530                                                                 cout << Verbose(1) << "Parsing forces file and Verlet integrating." << endl;
    1531                                                                 if (!mol->VerletForceIntegration(argv[argptr], configuration.Deltat, configuration.GetIsAngstroem()))
    1532                                                                         cout << Verbose(2) << "File not found." << endl;
    1533                                                                 else
    1534                                                                         cout << Verbose(2) << "File found and parsed." << endl;
    1535                                                                 argptr+=1;
    1536                                                         }
    1537                                                         break;
     1227  Vector x,y,z,n;  // coordinates for absolute point in cell volume
     1228  double *factor; // unit factor if desired
     1229  ifstream test;
     1230  ofstream output;
     1231  string line;
     1232  atom *first;
     1233  bool SaveFlag = false;
     1234  int ExitFlag = 0;
     1235  int j;
     1236  double volume = 0.;
     1237  enum ConfigStatus config_present = absent;
     1238  clock_t start,end;
     1239  int argptr;
     1240  PathToDatabases = LocalPath;
     1241
     1242  // simply create a new molecule, wherein the config file is loaded and the manipulation takes place
     1243  molecule *mol = new molecule(periode);
     1244  molecules->insert(mol);
     1245
     1246  if (argc > 1) { // config file specified as option
     1247    // 1. : Parse options that just set variables or print help
     1248    argptr = 1;
     1249    do {
     1250      if (argv[argptr][0] == '-') {
     1251        cout << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n";
     1252        argptr++;
     1253        switch(argv[argptr-1][1]) {
     1254          case 'h':
     1255          case 'H':
     1256          case '?':
     1257            cout << "MoleCuilder suite" << endl << "==================" << endl << endl;
     1258            cout << "Usage: " << argv[0] << "[config file] [-{acefpsthH?vfrp}] [further arguments]" << endl;
     1259            cout << "or simply " << argv[0] << " without arguments for interactive session." << endl;
     1260            cout << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl;
     1261            cout << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl;
     1262            cout << "\t-b x1 x2 x3\tCenter atoms in domain with given edge lengths of (x1,x2,x3)." << endl;
     1263            cout << "\t-B <basis>\tSetting basis to store to MPQC config files." << endl;
     1264            cout << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl;
     1265            cout << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl;
     1266            cout << "\t-O\tCenter atoms in origin." << endl;
     1267            cout << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl;
     1268            cout << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl;
     1269            cout << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl;
     1270            cout << "\t-f/F <dist> <order>\tFragments the molecule in BOSSANOVA manner (with/out rings compressed) and stores config files in same dir as config (return code 0 - fragmented, 2 - no fragmentation necessary)." << endl;
     1271            cout << "\t-h/-H/-?\tGive this help screen." << endl;
     1272            cout << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl;
     1273            cout << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl;
     1274            cout << "\t-N <radius> <file>\tGet non-convex-envelope." << endl;
     1275            cout << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl;
     1276            cout << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl;
     1277            cout << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl;
     1278            cout << "\t-r\t\tConvert file from an old pcp syntax." << endl;
     1279            cout << "\t-R\t\tRemove all atoms out of sphere around a given one." << endl;
     1280            cout << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl;
     1281            cout << "\t-T <file> Store temperatures from the config file in <file>." << endl;
     1282            cout << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl;
     1283            cout << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl;
     1284            cout << "\t-v/-V\t\tGives version information." << endl;
     1285            cout << "Note: config files must not begin with '-' !" << endl;
     1286            delete(mol);
     1287            delete(periode);
     1288            return (1);
     1289            break;
     1290          case 'v':
     1291          case 'V':
     1292            cout << argv[0] << " " << VERSIONSTRING << endl;
     1293            cout << "Build your own molecule position set." << endl;
     1294            delete(mol);
     1295            delete(periode);
     1296            return (1);
     1297            break;
     1298          case 'e':
     1299            if ((argptr >= argc) || (argv[argptr][0] == '-')) {
     1300              cerr << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl;
     1301            } else {
     1302              cout << "Using " << argv[argptr] << " as elements database." << endl;
     1303              PathToDatabases = argv[argptr];
     1304              argptr+=1;
     1305            }
     1306            break;
     1307          case 'n':
     1308            cout << "I won't parse trajectories." << endl;
     1309            configuration.FastParsing = true;
     1310            break;
     1311          default:  // no match? Step on
     1312            argptr++;
     1313            break;
     1314        }
     1315      } else
     1316        argptr++;
     1317    } while (argptr < argc);
     1318
     1319    // 2. Parse the element database
     1320    if (periode->LoadPeriodentafel(PathToDatabases)) {
     1321      cout << Verbose(0) << "Element list loaded successfully." << endl;
     1322      //periode->Output((ofstream *)&cout);
     1323    } else {
     1324      cout << Verbose(0) << "Element list loading failed." << endl;
     1325      return 1;
     1326    }
     1327    // 3. Find config file name and parse if possible
     1328    if (argv[1][0] != '-') {
     1329      cout << Verbose(0) << "Config file given." << endl;
     1330      test.open(argv[1], ios::in);
     1331      if (test == NULL) {
     1332        //return (1);
     1333        output.open(argv[1], ios::out);
     1334        if (output == NULL) {
     1335          cout << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl;
     1336          config_present = absent;
     1337        } else {
     1338          cout << "Empty configuration file." << endl;
     1339          ConfigFileName = argv[1];
     1340          config_present = empty;
     1341          output.close();
     1342        }
     1343      } else {
     1344        test.close();
     1345        ConfigFileName = argv[1];
     1346        cout << Verbose(1) << "Specified config file found, parsing ... ";
     1347        switch (configuration.TestSyntax(ConfigFileName, periode, mol)) {
     1348          case 1:
     1349            cout << "new syntax." << endl;
     1350            configuration.Load(ConfigFileName, periode, mol);
     1351            config_present = present;
     1352            break;
     1353          case 0:
     1354            cout << "old syntax." << endl;
     1355            configuration.LoadOld(ConfigFileName, periode, mol);
     1356            config_present = present;
     1357            break;
     1358          default:
     1359            cout << "Unknown syntax or empty, yet present file." << endl;
     1360            config_present = empty;
     1361      }
     1362      }
     1363    } else
     1364      config_present = absent;
     1365    // 4. parse again through options, now for those depending on elements db and config presence
     1366    argptr = 1;
     1367    do {
     1368      cout << "Current Command line argument: " << argv[argptr] << "." << endl;
     1369      if (argv[argptr][0] == '-') {
     1370        argptr++;
     1371        if ((config_present == present) || (config_present == empty)) {
     1372          switch(argv[argptr-1][1]) {
     1373            case 'p':
     1374              ExitFlag = 1;
     1375              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
     1376                ExitFlag = 255;
     1377                cerr << "Not enough arguments for parsing: -p <xyz file>" << endl;
     1378              } else {
     1379                SaveFlag = true;
     1380                cout << Verbose(1) << "Parsing xyz file for new atoms." << endl;
     1381                if (!mol->AddXYZFile(argv[argptr]))
     1382                  cout << Verbose(2) << "File not found." << endl;
     1383                else {
     1384                  cout << Verbose(2) << "File found and parsed." << endl;
     1385                  config_present = present;
     1386                }
     1387              }
     1388              break;
     1389            case 'a':
     1390              ExitFlag = 1;
     1391              if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1]))) {
     1392                ExitFlag = 255;
     1393                cerr << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl;
     1394              } else {
     1395                SaveFlag = true;
     1396                cout << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), ";
     1397                first = new atom;
     1398                first->type = periode->FindElement(atoi(argv[argptr]));
     1399                if (first->type != NULL)
     1400                  cout << Verbose(2) << "found element " << first->type->name << endl;
     1401                for (int i=NDIM;i--;)
     1402                  first->x.x[i] = atof(argv[argptr+1+i]);
     1403                if (first->type != NULL) {
     1404                  mol->AddAtom(first);  // add to molecule
     1405                  if ((config_present == empty) && (mol->AtomCount != 0))
     1406                    config_present = present;
     1407                } else
     1408                  cerr << Verbose(1) << "Could not find the specified element." << endl;
     1409                argptr+=4;
     1410              }
     1411              break;
     1412            default:  // no match? Don't step on (this is done in next switch's default)
     1413              break;
     1414          }
     1415        }
     1416        if (config_present == present) {
     1417          switch(argv[argptr-1][1]) {
     1418            case 'B':
     1419              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
     1420                ExitFlag = 255;
     1421                cerr << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl;
     1422              } else {
     1423                configuration.basis = argv[argptr];
     1424                cout << Verbose(1) << "Setting MPQC basis to " << configuration.basis << "." << endl;
     1425                argptr+=1;
     1426              }
     1427              break;
     1428            case 'D':
     1429              ExitFlag = 1;
     1430              {
     1431                cout << Verbose(1) << "Depth-First-Search Analysis." << endl;
     1432                MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
     1433                int *MinimumRingSize = new int[mol->AtomCount];
     1434                atom ***ListOfLocalAtoms = NULL;
     1435                int FragmentCounter = 0;
     1436                class StackClass<bond *> *BackEdgeStack = NULL;
     1437                class StackClass<bond *> *LocalBackEdgeStack = NULL;
     1438                mol->CreateAdjacencyList((ofstream *)&cout, atof(argv[argptr]), configuration.GetIsAngstroem());
     1439                mol->CreateListOfBondsPerAtom((ofstream *)&cout);
     1440                Subgraphs = mol->DepthFirstSearchAnalysis((ofstream *)&cout, BackEdgeStack);
     1441                if (Subgraphs != NULL) {
     1442                  Subgraphs->next->FillBondStructureFromReference((ofstream *)&cout, mol, (FragmentCounter = 0), ListOfLocalAtoms, false);  // we want to keep the created ListOfLocalAtoms
     1443                  while (Subgraphs->next != NULL) {
     1444                    Subgraphs = Subgraphs->next;
     1445                    LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
     1446                    Subgraphs->Leaf->PickLocalBackEdges((ofstream *)&cout, ListOfLocalAtoms[FragmentCounter++], BackEdgeStack, LocalBackEdgeStack);
     1447                    Subgraphs->Leaf->CyclicStructureAnalysis((ofstream *)&cout, BackEdgeStack, MinimumRingSize);
     1448                    delete(LocalBackEdgeStack);
     1449                    delete(Subgraphs->previous);
     1450                  }
     1451                  delete(Subgraphs);
     1452                  for (int i=0;i<FragmentCounter;i++)
     1453                    Free((void **)&ListOfLocalAtoms[FragmentCounter], "ParseCommandLineOptions: **ListOfLocalAtoms[]");
     1454                  Free((void **)&ListOfLocalAtoms, "ParseCommandLineOptions: ***ListOfLocalAtoms");
     1455                }
     1456                delete(BackEdgeStack);
     1457                delete[](MinimumRingSize);
     1458              }
     1459              //argptr+=1;
     1460              break;
     1461            case 'E':
     1462              ExitFlag = 1;
     1463              if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) {
     1464                ExitFlag = 255;
     1465                cerr << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl;
     1466              } else {
     1467                SaveFlag = true;
     1468                cout << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl;
     1469                first = mol->FindAtom(atoi(argv[argptr]));
     1470                first->type = periode->FindElement(atoi(argv[argptr+1]));
     1471                argptr+=2;
     1472              }
     1473              break;
     1474            case 'A':
     1475              ExitFlag = 1;
     1476              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
     1477                ExitFlag =255;
     1478                cerr << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl;
     1479              } else {
     1480                cout << "Parsing bonds from " << argv[argptr] << "." << endl;
     1481                ifstream *input = new ifstream(argv[argptr]);
     1482                mol->CreateAdjacencyList2((ofstream *)&cout, input);
     1483                input->close();
     1484                argptr+=1;
     1485              }
     1486              break;
     1487            case 'N':
     1488              ExitFlag = 1;
     1489              if ((argptr+1 >= argc) || (argv[argptr+1][0] == '-')){
     1490                ExitFlag = 255;
     1491                cerr << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl;
     1492              } else {
     1493                class Tesselation T;
     1494                int N = 15;
     1495                int number = 100;
     1496                string filename(argv[argptr+1]);
     1497                filename.append(".csv");
     1498                cout << Verbose(0) << "Evaluating non-convex envelope.";
     1499                cout << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl;
     1500                LinkedCell LCList(mol, atof(argv[argptr]));    // \NOTE not twice the radius??
     1501                Find_non_convex_border((ofstream *)&cout, mol, &T, &LCList, argv[argptr+1], atof(argv[argptr]));
     1502                //FindDistributionOfEllipsoids((ofstream *)&cout, &T, &LCList, N, number, filename.c_str());
     1503                argptr+=2;
     1504              }
     1505              break;
     1506            case 'T':
     1507              ExitFlag = 1;
     1508              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
     1509                ExitFlag = 255;
     1510                cerr << "Not enough or invalid arguments given for storing tempature: -T <temperature file>" << endl;
     1511              } else {
     1512                cout << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl;
     1513                ofstream *output = new ofstream(argv[argptr], ios::trunc);
     1514                if (!mol->OutputTemperatureFromTrajectories((ofstream *)&cout, 0, mol->MDSteps, output))
     1515                  cout << Verbose(2) << "File could not be written." << endl;
     1516                else
     1517                  cout << Verbose(2) << "File stored." << endl;
     1518                output->close();
     1519                delete(output);
     1520                argptr+=1;
     1521              }
     1522              break;
     1523            case 'P':
     1524              ExitFlag = 1;
     1525              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
     1526                ExitFlag = 255;
     1527                cerr << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl;
     1528              } else {
     1529                SaveFlag = true;
     1530                cout << Verbose(1) << "Parsing forces file and Verlet integrating." << endl;
     1531                if (!mol->VerletForceIntegration(argv[argptr], configuration.Deltat, configuration.GetIsAngstroem()))
     1532                  cout << Verbose(2) << "File not found." << endl;
     1533                else
     1534                  cout << Verbose(2) << "File found and parsed." << endl;
     1535                argptr+=1;
     1536              }
     1537              break;
    15381538            case 'R':
    15391539              ExitFlag = 1;
     
    15611561              }
    15621562              break;
    1563                                                 case 't':
    1564                                                         ExitFlag = 1;
    1565                                                         if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    1566                                                                 ExitFlag = 255;
    1567                                                                 cerr << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl;
    1568                                                         } else {
    1569                                                                 ExitFlag = 1;
    1570                                                                 SaveFlag = true;
    1571                                                                 cout << Verbose(1) << "Translating all ions to new origin." << endl;
    1572                                                                 for (int i=NDIM;i--;)
    1573                                                                         x.x[i] = atof(argv[argptr+i]);
    1574                                                                 mol->Translate((const Vector *)&x);
    1575                                                                 argptr+=3;
    1576                                                         }
    1577                                                         break;
    1578                                                 case 's':
    1579                                                         ExitFlag = 1;
    1580                                                         if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) ) {
    1581                                                                 ExitFlag = 255;
    1582                                                                 cerr << "Not enough or invalid arguments given for scaling: -s <factor/[factor_x]> [factor_y] [factor_z]" << endl;
    1583                                                         } else {
    1584                                                                 SaveFlag = true;
    1585                                                                 j = -1;
    1586                                                                 cout << Verbose(1) << "Scaling all ion positions by factor." << endl;
    1587                                                                 factor = new double[NDIM];
    1588                                                                 factor[0] = atof(argv[argptr]);
    1589                                                                 if ((argptr < argc) && (IsValidNumber(argv[argptr])))
    1590                                                                         argptr++;
    1591                                                                 factor[1] = atof(argv[argptr]);
    1592                                                                 if ((argptr < argc) && (IsValidNumber(argv[argptr])))
    1593                                                                         argptr++;
    1594                                                                 factor[2] = atof(argv[argptr]);
    1595                                                                 mol->Scale(&factor);
    1596                                                                 for (int i=0;i<NDIM;i++) {
    1597                                                                         j += i+1;
    1598                                                                         x.x[i] = atof(argv[NDIM+i]);
    1599                                                                         mol->cell_size[j]*=factor[i];
    1600                                                                 }
    1601                                                                 delete[](factor);
    1602                                                                 argptr+=1;
    1603                                                         }
    1604                                                         break;
    1605                                                 case 'b':
    1606                                                         ExitFlag = 1;
    1607                                                         if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    1608                                                                 ExitFlag = 255;
    1609                                                                 cerr << "Not enough or invalid arguments given for centering in box: -b <length_x> <length_y> <length_z>" << endl;
    1610                                                         } else {
    1611                                                                 SaveFlag = true;
    1612                                                                 j = -1;
    1613                                                                 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
    1614                                                                 j=-1;
    1615                                                                 for (int i=0;i<NDIM;i++) {
    1616                                                                         j += i+1;
    1617                                                                         x.x[i] = atof(argv[argptr++]);
    1618                                                                         mol->cell_size[j] += x.x[i]*2.;
    1619                                                                 }
    1620                                                                 // center
    1621                                                                 mol->CenterInBox((ofstream *)&cout, &x);
    1622                                                                 // update Box of atoms by boundary
    1623                                                                 mol->SetBoxDimension(&x);
    1624                                                         }
    1625                                                         break;
    1626                                                 case 'c':
    1627                                                         ExitFlag = 1;
    1628                                                         if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    1629                                                                 ExitFlag = 255;
    1630                                                                 cerr << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl;
    1631                                                         } else {
    1632                                                                 SaveFlag = true;
    1633                                                                 j = -1;
    1634                                                                 cout << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl;
    1635                                                                 // make every coordinate positive
    1636                                                                 mol->CenterEdge((ofstream *)&cout, &x);
    1637                                                                 // update Box of atoms by boundary
    1638                                                                 mol->SetBoxDimension(&x);
    1639                                                                 // translate each coordinate by boundary
    1640                                                                 j=-1;
    1641                                                                 for (int i=0;i<NDIM;i++) {
    1642                                                                         j += i+1;
    1643                                                                         x.x[i] = atof(argv[argptr++]);
    1644                                                                         mol->cell_size[j] += x.x[i]*2.;
    1645                                                                 }
    1646                                                                 mol->Translate((const Vector *)&x);
    1647                                                         }
    1648                                                         break;
    1649                                                 case 'O':
    1650                                                         ExitFlag = 1;
    1651                                                         SaveFlag = true;
    1652                                                         cout << Verbose(1) << "Centering atoms in origin." << endl;
    1653                                                         mol->CenterOrigin((ofstream *)&cout, &x);
    1654                                                         mol->SetBoxDimension(&x);
    1655                                                         break;
    1656                                                 case 'r':
    1657                                                         ExitFlag = 1;
    1658                                                         SaveFlag = true;
    1659                                                         cout << Verbose(1) << "Converting config file from supposed old to new syntax." << endl;
    1660                                                         break;
    1661                                                 case 'F':
    1662                                                 case 'f':
    1663                                                         ExitFlag = 1;
    1664                                                         if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {
    1665                                                                 ExitFlag = 255;
    1666                                                                 cerr << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl;
    1667                                                         } else {
    1668                                                                 cout << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl;
    1669                                                                 cout << Verbose(0) << "Creating connection matrix..." << endl;
    1670                                                                 start = clock();
    1671                                                                 mol->CreateAdjacencyList((ofstream *)&cout, atof(argv[argptr++]), configuration.GetIsAngstroem());
    1672                                                                 cout << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
    1673                                                                 if (mol->first->next != mol->last) {
    1674                                                                         ExitFlag = mol->FragmentMolecule((ofstream *)&cout, atoi(argv[argptr]), &configuration);
    1675                                                                 }
    1676                                                                 end = clock();
    1677                                                                 cout << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
    1678                                                                 argptr+=2;
    1679                                                         }
    1680                                                         break;
    1681                                                 case 'm':
    1682                                                         ExitFlag = 1;
    1683                                                         j = atoi(argv[argptr++]);
    1684                                                         if ((j<0) || (j>1)) {
    1685                                                                 cerr << Verbose(1) << "ERROR: Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl;
    1686                                                                 j = 0;
    1687                                                         }
    1688                                                         if (j) {
    1689                                                                 SaveFlag = true;
    1690                                                                 cout << Verbose(0) << "Converting to prinicipal axis system." << endl;
    1691                                                         } else
    1692                                                                 cout << Verbose(0) << "Evaluating prinicipal axis." << endl;
    1693                                                         mol->PrincipalAxisSystem((ofstream *)&cout, (bool)j);
    1694                                                         break;
    1695                                                 case 'o':
    1696                                                         ExitFlag = 1;
    1697                                                         if ((argptr >= argc) || (argv[argptr][0] == '-')){
    1698                                                                 ExitFlag = 255;
    1699                                                                 cerr << "Not enough or invalid arguments given for convex envelope: -o <tecplot output file>" << endl;
    1700                                                         } else {
    1701                                                                 cout << Verbose(0) << "Evaluating volume of the convex envelope.";
    1702                                                                 cout << Verbose(1) << "Storing tecplot data in " << argv[argptr] << "." << endl;
    1703                                                                 VolumeOfConvexEnvelope((ofstream *)&cout, argv[argptr], &configuration, NULL, mol);
    1704                                                                 argptr+=1;
    1705                                                         }
    1706                                                         break;
    1707                                                 case 'U':
    1708                                                         ExitFlag = 1;
    1709                                                         if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) {
    1710                                                                 ExitFlag = 255;
    1711                                                                 cerr << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl;
    1712                                                                 volume = -1; // for case 'u': don't print error again
    1713                                                         } else {
    1714                                                                 volume = atof(argv[argptr++]);
    1715                                                                 cout << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl;
    1716                                                         }
    1717                                                 case 'u':
    1718                                                         ExitFlag = 1;
    1719                                                         if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) ) {
    1720                                                                 if (volume != -1)
    1721                                                                         ExitFlag = 255;
    1722                                                                         cerr << "Not enough arguments given for suspension: -u <density>" << endl;
    1723                                                         } else {
    1724                                                                 double density;
    1725                                                                 SaveFlag = true;
    1726                                                                 cout << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.";
    1727                                                                 density = atof(argv[argptr++]);
    1728                                                                 if (density < 1.0) {
    1729                                                                         cerr << Verbose(0) << "Density must be greater than 1.0g/cm^3 !" << endl;
    1730                                                                         density = 1.3;
    1731                                                                 }
    1732 //                                                              for(int i=0;i<NDIM;i++) {
    1733 //                                                                      repetition[i] = atoi(argv[argptr++]);
    1734 //                                                                      if (repetition[i] < 1)
    1735 //                                                                              cerr << Verbose(0) << "ERROR: repetition value must be greater 1!" << endl;
    1736 //                                                                      repetition[i] = 1;
    1737 //                                                              }
    1738                                                                 PrepareClustersinWater((ofstream *)&cout, &configuration, mol, volume, density);        // if volume == 0, will calculate from ConvexEnvelope
    1739                                                         }
    1740                                                         break;
    1741                                                 case 'd':
    1742                                                         ExitFlag = 1;
    1743                                                         if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    1744                                                                 ExitFlag = 255;
    1745                                                                 cerr << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl;
    1746                                                         } else {
    1747                                                                 SaveFlag = true;
    1748                                                                 for (int axis = 1; axis <= NDIM; axis++) {
    1749                                                                         int faktor = atoi(argv[argptr++]);
    1750                                                                         int count;
    1751                                                                         element ** Elements;
    1752                                                                         Vector ** vectors;
    1753                                                                         if (faktor < 1) {
    1754                                                                                 cerr << Verbose(0) << "ERROR: Repetition faktor mus be greater than 1!" << endl;
    1755                                                                                 faktor = 1;
    1756                                                                         }
    1757                                                                         mol->CountAtoms((ofstream *)&cout);     // recount atoms
    1758                                                                         if (mol->AtomCount != 0) {      // if there is more than none
    1759                                                                                 count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand
    1760                                                                                 Elements = new element *[count];
    1761                                                                                 vectors = new Vector *[count];
    1762                                                                                 j = 0;
    1763                                                                                 first = mol->start;
    1764                                                                                 while (first->next != mol->end) {       // make a list of all atoms with coordinates and element
    1765                                                                                         first = first->next;
    1766                                                                                         Elements[j] = first->type;
    1767                                                                                         vectors[j] = &first->x;
    1768                                                                                         j++;
    1769                                                                                 }
    1770                                                                                 if (count != j)
    1771                                                                                         cout << Verbose(0) << "ERROR: AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
    1772                                                                                 x.Zero();
    1773                                                                                 y.Zero();
    1774                                                                                 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
    1775                                                                                 for (int i=1;i<faktor;i++) {    // then add this list with respective translation factor times
    1776                                                                                         x.AddVector(&y); // per factor one cell width further
    1777                                                                                         for (int k=count;k--;) { // go through every atom of the original cell
    1778                                                                                                 first = new atom(); // create a new body
    1779                                                                                                 first->x.CopyVector(vectors[k]);        // use coordinate of original atom
    1780                                                                                                 first->x.AddVector(&x);                 // translate the coordinates
    1781                                                                                                 first->type = Elements[k];      // insert original element
    1782                                                                                                 mol->AddAtom(first);                            // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
    1783                                                                                         }
    1784                                                                                 }
    1785                                                                                 // free memory
    1786                                                                                 delete[](Elements);
    1787                                                                                 delete[](vectors);
    1788                                                                                 // correct cell size
    1789                                                                                 if (axis < 0) { // if sign was negative, we have to translate everything
    1790                                                                                         x.Zero();
    1791                                                                                         x.AddVector(&y);
    1792                                                                                         x.Scale(-(faktor-1));
    1793                                                                                         mol->Translate(&x);
    1794                                                                                 }
    1795                                                                                 mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
    1796                                                                         }
    1797                                                                 }
    1798                                                         }
    1799                                                         break;
    1800                                                 default:        // no match? Step on
    1801                                                         if ((argptr < argc) && (argv[argptr][0] != '-')) // if it started with a '-' we've already made a step!
    1802                                                                 argptr++;
    1803                                                         break;
    1804                                         }
    1805                                 }
    1806                         } else argptr++;
    1807                 } while (argptr < argc);
    1808                 if (SaveFlag)
    1809                         SaveConfig(ConfigFileName, &configuration, periode, molecules);
    1810                 if ((ExitFlag >= 1)) {
    1811                         delete(mol);
    1812                         delete(periode);
    1813                         return (ExitFlag);
    1814                 }
    1815         } else {        // no arguments, hence scan the elements db
    1816                 if (periode->LoadPeriodentafel(PathToDatabases))
    1817                         cout << Verbose(0) << "Element list loaded successfully." << endl;
    1818                 else
    1819                         cout << Verbose(0) << "Element list loading failed." << endl;
    1820                 configuration.RetrieveConfigPathAndName("main_pcp_linux");
    1821         }
    1822         return(0);
     1563            case 't':
     1564              ExitFlag = 1;
     1565              if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
     1566                ExitFlag = 255;
     1567                cerr << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl;
     1568              } else {
     1569                ExitFlag = 1;
     1570                SaveFlag = true;
     1571                cout << Verbose(1) << "Translating all ions to new origin." << endl;
     1572                for (int i=NDIM;i--;)
     1573                  x.x[i] = atof(argv[argptr+i]);
     1574                mol->Translate((const Vector *)&x);
     1575                argptr+=3;
     1576              }
     1577              break;
     1578            case 's':
     1579              ExitFlag = 1;
     1580              if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) ) {
     1581                ExitFlag = 255;
     1582                cerr << "Not enough or invalid arguments given for scaling: -s <factor/[factor_x]> [factor_y] [factor_z]" << endl;
     1583              } else {
     1584                SaveFlag = true;
     1585                j = -1;
     1586                cout << Verbose(1) << "Scaling all ion positions by factor." << endl;
     1587                factor = new double[NDIM];
     1588                factor[0] = atof(argv[argptr]);
     1589                if ((argptr < argc) && (IsValidNumber(argv[argptr])))
     1590                  argptr++;
     1591                factor[1] = atof(argv[argptr]);
     1592                if ((argptr < argc) && (IsValidNumber(argv[argptr])))
     1593                  argptr++;
     1594                factor[2] = atof(argv[argptr]);
     1595                mol->Scale(&factor);
     1596                for (int i=0;i<NDIM;i++) {
     1597                  j += i+1;
     1598                  x.x[i] = atof(argv[NDIM+i]);
     1599                  mol->cell_size[j]*=factor[i];
     1600                }
     1601                delete[](factor);
     1602                argptr+=1;
     1603              }
     1604              break;
     1605            case 'b':
     1606              ExitFlag = 1;
     1607              if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
     1608                ExitFlag = 255;
     1609                cerr << "Not enough or invalid arguments given for centering in box: -b <length_x> <length_y> <length_z>" << endl;
     1610              } else {
     1611                SaveFlag = true;
     1612                j = -1;
     1613                cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
     1614                j=-1;
     1615                for (int i=0;i<NDIM;i++) {
     1616                  j += i+1;
     1617                  x.x[i] = atof(argv[argptr++]);
     1618                  mol->cell_size[j] += x.x[i]*2.;
     1619                }
     1620                // center
     1621                mol->CenterInBox((ofstream *)&cout, &x);
     1622                // update Box of atoms by boundary
     1623                mol->SetBoxDimension(&x);
     1624              }
     1625              break;
     1626            case 'c':
     1627              ExitFlag = 1;
     1628              if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
     1629                ExitFlag = 255;
     1630                cerr << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl;
     1631              } else {
     1632                SaveFlag = true;
     1633                j = -1;
     1634                cout << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl;
     1635                // make every coordinate positive
     1636                mol->CenterEdge((ofstream *)&cout, &x);
     1637                // update Box of atoms by boundary
     1638                mol->SetBoxDimension(&x);
     1639                // translate each coordinate by boundary
     1640                j=-1;
     1641                for (int i=0;i<NDIM;i++) {
     1642                  j += i+1;
     1643                  x.x[i] = atof(argv[argptr++]);
     1644                  mol->cell_size[j] += x.x[i]*2.;
     1645                }
     1646                mol->Translate((const Vector *)&x);
     1647              }
     1648              break;
     1649            case 'O':
     1650              ExitFlag = 1;
     1651              SaveFlag = true;
     1652              cout << Verbose(1) << "Centering atoms in origin." << endl;
     1653              mol->CenterOrigin((ofstream *)&cout, &x);
     1654              mol->SetBoxDimension(&x);
     1655              break;
     1656            case 'r':
     1657              ExitFlag = 1;
     1658              SaveFlag = true;
     1659              cout << Verbose(1) << "Converting config file from supposed old to new syntax." << endl;
     1660              break;
     1661            case 'F':
     1662            case 'f':
     1663              ExitFlag = 1;
     1664              if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {
     1665                ExitFlag = 255;
     1666                cerr << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl;
     1667              } else {
     1668                cout << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl;
     1669                cout << Verbose(0) << "Creating connection matrix..." << endl;
     1670                start = clock();
     1671                mol->CreateAdjacencyList((ofstream *)&cout, atof(argv[argptr++]), configuration.GetIsAngstroem());
     1672                cout << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
     1673                if (mol->first->next != mol->last) {
     1674                  ExitFlag = mol->FragmentMolecule((ofstream *)&cout, atoi(argv[argptr]), &configuration);
     1675                }
     1676                end = clock();
     1677                cout << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
     1678                argptr+=2;
     1679              }
     1680              break;
     1681            case 'm':
     1682              ExitFlag = 1;
     1683              j = atoi(argv[argptr++]);
     1684              if ((j<0) || (j>1)) {
     1685                cerr << Verbose(1) << "ERROR: Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl;
     1686                j = 0;
     1687              }
     1688              if (j) {
     1689                SaveFlag = true;
     1690                cout << Verbose(0) << "Converting to prinicipal axis system." << endl;
     1691              } else
     1692                cout << Verbose(0) << "Evaluating prinicipal axis." << endl;
     1693              mol->PrincipalAxisSystem((ofstream *)&cout, (bool)j);
     1694              break;
     1695            case 'o':
     1696              ExitFlag = 1;
     1697              if ((argptr >= argc) || (argv[argptr][0] == '-')){
     1698                ExitFlag = 255;
     1699                cerr << "Not enough or invalid arguments given for convex envelope: -o <tecplot output file>" << endl;
     1700              } else {
     1701                cout << Verbose(0) << "Evaluating volume of the convex envelope.";
     1702                cout << Verbose(1) << "Storing tecplot data in " << argv[argptr] << "." << endl;
     1703                VolumeOfConvexEnvelope((ofstream *)&cout, argv[argptr], &configuration, NULL, mol);
     1704                argptr+=1;
     1705              }
     1706              break;
     1707            case 'U':
     1708              ExitFlag = 1;
     1709              if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) {
     1710                ExitFlag = 255;
     1711                cerr << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl;
     1712                volume = -1; // for case 'u': don't print error again
     1713              } else {
     1714                volume = atof(argv[argptr++]);
     1715                cout << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl;
     1716              }
     1717            case 'u':
     1718              ExitFlag = 1;
     1719              if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) ) {
     1720                if (volume != -1)
     1721                  ExitFlag = 255;
     1722                  cerr << "Not enough arguments given for suspension: -u <density>" << endl;
     1723              } else {
     1724                double density;
     1725                SaveFlag = true;
     1726                cout << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.";
     1727                density = atof(argv[argptr++]);
     1728                if (density < 1.0) {
     1729                  cerr << Verbose(0) << "Density must be greater than 1.0g/cm^3 !" << endl;
     1730                  density = 1.3;
     1731                }
     1732//                for(int i=0;i<NDIM;i++) {
     1733//                  repetition[i] = atoi(argv[argptr++]);
     1734//                  if (repetition[i] < 1)
     1735//                    cerr << Verbose(0) << "ERROR: repetition value must be greater 1!" << endl;
     1736//                  repetition[i] = 1;
     1737//                }
     1738                PrepareClustersinWater((ofstream *)&cout, &configuration, mol, volume, density);  // if volume == 0, will calculate from ConvexEnvelope
     1739              }
     1740              break;
     1741            case 'd':
     1742              ExitFlag = 1;
     1743              if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
     1744                ExitFlag = 255;
     1745                cerr << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl;
     1746              } else {
     1747                SaveFlag = true;
     1748                for (int axis = 1; axis <= NDIM; axis++) {
     1749                  int faktor = atoi(argv[argptr++]);
     1750                  int count;
     1751                  element ** Elements;
     1752                  Vector ** vectors;
     1753                  if (faktor < 1) {
     1754                    cerr << Verbose(0) << "ERROR: Repetition faktor mus be greater than 1!" << endl;
     1755                    faktor = 1;
     1756                  }
     1757                  mol->CountAtoms((ofstream *)&cout);  // recount atoms
     1758                  if (mol->AtomCount != 0) {  // if there is more than none
     1759                    count = mol->AtomCount;  // is changed becausing of adding, thus has to be stored away beforehand
     1760                    Elements = new element *[count];
     1761                    vectors = new Vector *[count];
     1762                    j = 0;
     1763                    first = mol->start;
     1764                    while (first->next != mol->end) {  // make a list of all atoms with coordinates and element
     1765                      first = first->next;
     1766                      Elements[j] = first->type;
     1767                      vectors[j] = &first->x;
     1768                      j++;
     1769                    }
     1770                    if (count != j)
     1771                      cout << Verbose(0) << "ERROR: AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
     1772                    x.Zero();
     1773                    y.Zero();
     1774                    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
     1775                    for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
     1776                      x.AddVector(&y); // per factor one cell width further
     1777                      for (int k=count;k--;) { // go through every atom of the original cell
     1778                        first = new atom(); // create a new body
     1779                        first->x.CopyVector(vectors[k]);  // use coordinate of original atom
     1780                        first->x.AddVector(&x);      // translate the coordinates
     1781                        first->type = Elements[k];  // insert original element
     1782                        mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
     1783                      }
     1784                    }
     1785                    // free memory
     1786                    delete[](Elements);
     1787                    delete[](vectors);
     1788                    // correct cell size
     1789                    if (axis < 0) { // if sign was negative, we have to translate everything
     1790                      x.Zero();
     1791                      x.AddVector(&y);
     1792                      x.Scale(-(faktor-1));
     1793                      mol->Translate(&x);
     1794                    }
     1795                    mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
     1796                  }
     1797                }
     1798              }
     1799              break;
     1800            default:  // no match? Step on
     1801              if ((argptr < argc) && (argv[argptr][0] != '-')) // if it started with a '-' we've already made a step!
     1802                argptr++;
     1803              break;
     1804          }
     1805        }
     1806      } else argptr++;
     1807    } while (argptr < argc);
     1808    if (SaveFlag)
     1809      SaveConfig(ConfigFileName, &configuration, periode, molecules);
     1810    if ((ExitFlag >= 1)) {
     1811      delete(mol);
     1812      delete(periode);
     1813      return (ExitFlag);
     1814    }
     1815  } else {  // no arguments, hence scan the elements db
     1816    if (periode->LoadPeriodentafel(PathToDatabases))
     1817      cout << Verbose(0) << "Element list loaded successfully." << endl;
     1818    else
     1819      cout << Verbose(0) << "Element list loading failed." << endl;
     1820    configuration.RetrieveConfigPathAndName("main_pcp_linux");
     1821  }
     1822  return(0);
    18231823};
    18241824
     
    18271827int main(int argc, char **argv)
    18281828{
    1829         periodentafel *periode = new periodentafel; // and a period table of all elements
    1830         MoleculeListClass *molecules = new MoleculeListClass;  // list of all molecules
    1831         molecule *mol = NULL;
    1832         config configuration;
    1833         double tmp1;
    1834         atom *first, *second;
    1835         char choice;    // menu choice char
    1836         Vector x,y,z,n; // coordinates for absolute point in cell volume
    1837         bool valid; // flag if input was valid or not
    1838         ifstream test;
    1839         ofstream output;
    1840         string line;
    1841         char *ConfigFileName = NULL;
    1842         char *ElementsFileName = NULL;
    1843         int Z;
    1844         int j, axis, count, faktor;
    1845 
    1846         // =========================== PARSE COMMAND LINE OPTIONS ====================================
    1847         j = ParseCommandLineOptions(argc, argv, molecules, periode, configuration, ConfigFileName, ElementsFileName);
    1848         if (j == 1) return 0; // just for -v and -h options
    1849         if (j) return j;        // something went wrong
    1850 
    1851         // General stuff
    1852         if (molecules->ListOfMolecules.size() == 0) {
     1829  periodentafel *periode = new periodentafel; // and a period table of all elements
     1830  MoleculeListClass *molecules = new MoleculeListClass;  // list of all molecules
     1831  molecule *mol = NULL;
     1832  config configuration;
     1833  double tmp1;
     1834  atom *first, *second;
     1835  char choice;  // menu choice char
     1836  Vector x,y,z,n;  // coordinates for absolute point in cell volume
     1837  bool valid; // flag if input was valid or not
     1838  ifstream test;
     1839  ofstream output;
     1840  string line;
     1841  char *ConfigFileName = NULL;
     1842  char *ElementsFileName = NULL;
     1843  int Z;
     1844  int j, axis, count, faktor;
     1845
     1846  // =========================== PARSE COMMAND LINE OPTIONS ====================================
     1847  j = ParseCommandLineOptions(argc, argv, molecules, periode, configuration, ConfigFileName, ElementsFileName);
     1848  if (j == 1) return 0; // just for -v and -h options
     1849  if (j) return j;  // something went wrong
     1850
     1851  // General stuff
     1852  if (molecules->ListOfMolecules.size() == 0) {
    18531853    mol = new molecule(periode);
    18541854    if (mol->cell_size[0] == 0.) {
     
    18601860    }
    18611861    molecules->insert(mol);
    1862         }
    1863 
    1864         // =========================== START INTERACTIVE SESSION ====================================
    1865 
    1866         // now the main construction loop
    1867         cout << Verbose(0) << endl << "Now comes the real construction..." << endl;
    1868         do {
    1869                 cout << Verbose(0) << endl << endl;
    1870                 cout << Verbose(0) << "============Molecule list=======================" << endl;
    1871                 molecules->Enumerate((ofstream *)&cout);
    1872                 cout << Verbose(0) << "============Menu===============================" << endl;
     1862  }
     1863
     1864  // =========================== START INTERACTIVE SESSION ====================================
     1865
     1866  // now the main construction loop
     1867  cout << Verbose(0) << endl << "Now comes the real construction..." << endl;
     1868  do {
     1869    cout << Verbose(0) << endl << endl;
     1870    cout << Verbose(0) << "============Molecule list=======================" << endl;
     1871    molecules->Enumerate((ofstream *)&cout);
     1872    cout << Verbose(0) << "============Menu===============================" << endl;
    18731873    cout << Verbose(0) << "a - set molecule (in)active" << endl;
    18741874    cout << Verbose(0) << "e - edit new molecules" << endl;
     
    18861886    cin >> choice;
    18871887
    1888                 switch (choice) {
    1889                         case 'a':  // (in)activate molecule
     1888    switch (choice) {
     1889      case 'a':  // (in)activate molecule
    18901890        {
    18911891          cout << "Enter index of molecule: ";
     
    18971897            (*ListRunner)->ActiveFlag = !(*ListRunner)->ActiveFlag;
    18981898        }
    1899                           break;
    1900 
    1901                         case 'c': // edit each field of the configuration
    1902                         configuration.Edit();
    1903                         break;
     1899        break;
     1900
     1901      case 'c': // edit each field of the configuration
     1902      configuration.Edit();
     1903      break;
    19041904
    19051905      case 'e': // create molecule
     
    19191919        break;
    19201920
    1921                         case 'q': // quit
    1922                                 break;
    1923 
    1924                         case 's': // save to config file
    1925                                 SaveConfig(ConfigFileName, &configuration, periode, molecules);
    1926                                 break;
    1927 
    1928                         case 'T':
    1929                                 testroutine(molecules);
    1930                                 break;
    1931 
    1932                         default:
    1933                           break;
    1934                 };
    1935         } while (choice != 'q');
    1936 
    1937         // save element data base
    1938         if (periode->StorePeriodentafel(ElementsFileName)) //ElementsFileName
    1939                 cout << Verbose(0) << "Saving of elements.db successful." << endl;
    1940         else
    1941                 cout << Verbose(0) << "Saving of elements.db failed." << endl;
    1942 
    1943         delete(molecules);
    1944         delete(periode);
    1945         return (0);
     1921      case 'q': // quit
     1922        break;
     1923
     1924      case 's': // save to config file
     1925        SaveConfig(ConfigFileName, &configuration, periode, molecules);
     1926        break;
     1927
     1928      case 'T':
     1929        testroutine(molecules);
     1930        break;
     1931
     1932      default:
     1933        break;
     1934    };
     1935  } while (choice != 'q');
     1936
     1937  // save element data base
     1938  if (periode->StorePeriodentafel(ElementsFileName)) //ElementsFileName
     1939    cout << Verbose(0) << "Saving of elements.db successful." << endl;
     1940  else
     1941    cout << Verbose(0) << "Saving of elements.db failed." << endl;
     1942
     1943  delete(molecules);
     1944  delete(periode);
     1945  return (0);
    19461946}
    19471947
Note: See TracChangeset for help on using the changeset viewer.