Changeset 35b698 for src


Ignore:
Timestamp:
Jun 23, 2010, 3:52:50 PM (15 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, Candidate_v1.7.0, 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:
d0fbec
Parents:
dc0d21
git-author:
Frederik Heber <heber@…> (06/23/10 15:20:35)
git-committer:
Frederik Heber <heber@…> (06/23/10 15:52:50)
Message:

BIG CHANGE: config::load and config::save in ParseCommandLineOptions() and main() replaced with FormatParser replacements.

Fragmentation:

  • FIX: MoleculeFillWithMoleculeAction: filler atoms have to be removed before the system can be stored to file.
  • FIX: PcpParser::load() - has to put the molecule also into World's MoleculeListClass (otherwise the name cannot be set right after loading)
  • new Libparser.a
  • all sources from PARSER subdir are compiled into libparser such that only ParserUnitTest is recompiled.

Testfixes:

  • testsuite-fragmentation - changes to due to different -f calling syntax.
  • most of the xyz files had to be replaced due to a single whitespace at the end of each entry: Domain/6, Simple_configuration/2, Simple_configuration/3, Simple_configuration/4, Simple_configuration/5, Simple_configuration/8
  • in many cases were the number orbitals (and thus MaxMinStopStep) wrong: Filling/1, Simple_configuration/4, Simple_configuration/5

Signed-off-by: Frederik Heber <heber@…>

Location:
src
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FragmentationAction/FragmentationAction.cpp

    rdc0d21 r35b698  
    4242  double distance = -1.;
    4343  int order = 0;
     44  std::string path;
    4445  config *configuration = World::getInstance().getConfig();
    4546  int ExitFlag = 0;
    4647
    4748  cout << "pre-dialog"<< endl;
    48   dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));
     49  dialog->queryString(NAME, &path, MapOfActions::getInstance().getDescription(NAME));
     50  dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
    4951  dialog->queryDouble("distance", &distance, MapOfActions::getInstance().getDescription("distance"));
    5052  dialog->queryInt("order", &order, MapOfActions::getInstance().getDescription("order"));
     
    5961    DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
    6062    if (mol->hasBondStructure()) {
    61       ExitFlag = mol->FragmentMolecule(order, configuration);
     63      ExitFlag = mol->FragmentMolecule(order, path);
    6264    }
    6365    World::getInstance().setExitFlag(ExitFlag);
  • src/Actions/MapOfActions.cpp

    rdc0d21 r35b698  
    185185  TypeMap["fastparsing"] = Boolean;
    186186  TypeMap["fill-molecule"] = String;
    187   TypeMap["fragment-mol"] = Molecule;
     187  TypeMap["fragment-mol"] = String;
    188188  TypeMap["input"] = String;
    189189  TypeMap["linear-interpolate"] = String;
  • src/Actions/MoleculeAction/FillWithMoleculeAction.cpp

    rdc0d21 r35b698  
    102102      World::getInstance().getMolecules()->insert(Filling);
    103103    }
     104    for (molecule::iterator iter = filler->begin(); !filler->empty(); iter = filler->begin()) {
     105      atom *Walker = *iter;
     106      filler->erase(iter);
     107      World::getInstance().destroyAtom(Walker);
     108    }
    104109    World::getInstance().destroyMolecule(filler);
    105110
  • src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp

    rdc0d21 r35b698  
    6969    if (IdMapping)
    7070      DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl);
    71     char outputname[MAXSTRINGSIZE];
    72     strcpy(outputname, filename.c_str());
    73     // TODO: LinearInterpolationBetweenConfiguration should use stream, not the filename directly! (better for unit test)
    74     if (!mol->LinearInterpolationBetweenConfiguration(start, end, outputname, *(World::getInstance().getConfig()), IdMapping))
    75       DoLog(2) && (Log() << Verbose(2) << "Could not store " << outputname << " files." << endl);
     71    if (!mol->LinearInterpolationBetweenConfiguration(start, end, filename, *(World::getInstance().getConfig()), IdMapping))
     72      DoLog(2) && (Log() << Verbose(2) << "Could not store " << filename << " files." << endl);
    7673    else
    7774      DoLog(2) && (Log() << Verbose(2) << "Steps created and " << filename << " files stored." << endl);
  • src/Actions/MoleculeAction/SaveAdjacencyAction.cpp

    rdc0d21 r35b698  
    6565    World::getInstance().getConfig()->BG->ConstructBondGraph(mol);
    6666    // TODO: sollte stream nicht filename benutzen, besser fuer unit test
    67     char outputname[MAXSTRINGSIZE];
    68     strcpy(outputname, filename.c_str());
    69     mol->StoreAdjacencyToFile(NULL, outputname);
     67    mol->StoreAdjacencyToFile(filename);
    7068    delete dialog;
    7169    return Action::success;
  • src/Actions/MoleculeAction/SaveBondsAction.cpp

    rdc0d21 r35b698  
    6464    DoLog(0) && (Log() << Verbose(0) << "Storing bonds to path " << filename << "." << endl);
    6565    World::getInstance().getConfig()->BG->ConstructBondGraph(mol);
    66     // TODO: sollte stream, nicht filenamen direkt nutzen, beser fuer unit tests
    67     char outputname[MAXSTRINGSIZE];
    68     strcpy(outputname, filename.c_str());
    69     mol->StoreBondsToFile(NULL, outputname);
     66    // TODO: sollte stream, nicht filenamen direkt nutzen, besser fuer unit tests
     67    mol->StoreBondsToFile(filename);
    7068    delete dialog;
    7169    return Action::success;
  • src/Legacy/oldmenu.cpp

    rdc0d21 r35b698  
    609609{
    610610  int Order1;
     611  std::string path;
    611612  clock_t start, end;
    612613
     
    614615  Log() << Verbose(0) << "What's the desired bond order: ";
    615616  cin >> Order1;
     617  DoLog(0) && (Log() << Verbose(0) << "What's the output path and prefix [e.g. /home/foo/BondFragment]: ");
     618  cin >> path;
    616619  if (mol->hasBondStructure()) {
    617620    start = clock();
    618     mol->FragmentMolecule(Order1, configuration);
     621    mol->FragmentMolecule(Order1, path);
    619622    end = clock();
    620623    Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
  • src/Makefile.am

    rdc0d21 r35b698  
    245245INCLUDES = -I$(top_srcdir)/src/unittests -I$(top_srcdir)/src/Actions -I$(top_srcdir)/src/UIElements
    246246
    247 noinst_LIBRARIES = libmolecuilder.a libgslwrapper.a
     247noinst_LIBRARIES = libmolecuilder.a libgslwrapper.a libparser.a
    248248bin_PROGRAMS = molecuilder joiner analyzer
    249249molecuilderdir = ${bindir}
    250250libmolecuilder_a_SOURCES = ${SOURCE} ${HEADER}
     251libparser_a_SOURCES = ${PARSERSOURCE} ${PARSERHEADER}
    251252libgslwrapper_a_SOURCES = ${LINALGSOURCE} ${LINALGHEADER}
    252253molecuilder_DATA = elements.db valence.db orbitals.db Hbonddistance.db Hbondangle.db
    253254molecuilder_LDFLAGS = $(BOOST_LDFLAGS)
    254255molecuilder_SOURCES = builder.cpp
    255 molecuilder_LDADD =  UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilder.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}
     256molecuilder_LDADD =  UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilder.a libparser.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}
    256257joiner_SOURCES = joiner.cpp datacreator.cpp parser.cpp datacreator.hpp helpers.hpp parser.hpp periodentafel.hpp
    257258joiner_LDADD = libmolecuilder.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
  • src/Parser/PcpParser.cpp

    rdc0d21 r35b698  
    3030
    3131  Paths.databasepath = NULL;
    32   Paths.configpath = NULL;
    3332  Paths.configname = NULL;
    3433  Paths.mainname = NULL;
     
    307306  // 3. parse the molecule in
    308307  molecule *mol = World::getInstance().createMolecule();
     308  MoleculeListClass *molecules = World::getInstance().getMolecules();
     309  molecules->insert(mol);
    309310  LoadMolecule(mol, FileBuffer, World::getInstance().getPeriode(), FastParsing);
    310311  //mol->SetNameFromFilename(filename);
     
    615616  if ((Paths.databasepath != NULL) && (b.Paths.databasepath != NULL))
    616617    ASSERT(strcmp(Paths.databasepath, b.Paths.databasepath), "PcpParser ==: databasepath not");
    617   if ((Paths.configpath != NULL) && (b.Paths.configpath != NULL))
    618     ASSERT(strcmp(Paths.configpath, b.Paths.configpath), "PcpParser ==: configpath not");
    619618  if ((Paths.configname != NULL) && (b.Paths.configname != NULL))
    620619    ASSERT(strcmp(Paths.configname, b.Paths.configname), "PcpParser ==: configname not");
  • src/Parser/PcpParser.hpp

    rdc0d21 r35b698  
    4141  struct StructPaths {
    4242    char *databasepath;
    43     char *configpath;
    4443    char *configname;
    4544    char *mainname;
  • src/World.cpp

    rdc0d21 r35b698  
    112112  molecule *mol = NULL;
    113113  mol = NewMolecule();
     114  cout << "Creating molecule with id " << currMoleculeId << "." << endl;
    114115  assert(!molecules.count(currMoleculeId));
    115116  mol->setId(currMoleculeId++);
  • src/builder.cpp

    rdc0d21 r35b698  
    8080#include "Menu/ActionMenuItem.hpp"
    8181#include "Parser/ChangeTracker.hpp"
     82#include "Parser/FormatParserStorage.hpp"
     83#include "Parser/PcpParser.hpp"
     84#include "Parser/XyzParser.hpp"
    8285#include "Actions/ActionRegistry.hpp"
    8386#include "Actions/ActionHistory.hpp"
     
    654657  int Order1;
    655658  clock_t start, end;
     659  std::string path;
    656660
    657661  DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
    658662  DoLog(0) && (Log() << Verbose(0) << "What's the desired bond order: ");
    659663  cin >> Order1;
     664  DoLog(0) && (Log() << Verbose(0) << "What's the output path and prefix [e.g. /home/foo/BondFragment]: ");
     665  cin >> path;
    660666  if (mol->first->next != mol->last) {  // there are bonds
    661667    start = clock();
    662     mol->FragmentMolecule(Order1, configuration);
     668    mol->FragmentMolecule(Order1, path);
    663669    end = clock();
    664670    DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
     
    13731379  mol->SetNameFromFilename(ConfigFileName);
    13741380
    1375   if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
    1376     DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl);
    1377   }
    1378 
    1379 
    13801381  // first save as PDB data
    13811382  if (ConfigFileName != NULL)
     
    14771478    DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    14781479
    1479   if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
    1480     DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl);
    1481   }
    1482 
    14831480  World::getInstance().destroyMolecule(mol);
    14841481};
     
    15001497 */
    15011498static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode,
    1502                                    config& configuration, char **ConfigFileName, set<int> &ArgcList)
     1499                                   config& configuration, char **ConfigFileName, std::string &BondGraphFileName, set<int> &ArgcList)
    15031500{
    15041501  Vector x,y,z,n;  // coordinates for absolute point in cell volume
     
    15131510  int argptr;
    15141511  molecule *mol = NULL;
    1515   string BondGraphFileName("\n");
    15161512
    15171513  if (argc > 1) { // config file specified as option
     
    16251621      // simply create a new molecule, wherein the config file is loaded and the manipulation takes place
    16261622      DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl);
     1623      std::string filenameprefix(argv[1]);
     1624      strcpy(*ConfigFileName, filenameprefix.substr(0,filenameprefix.find('.')).c_str());
     1625      DoLog(1) && (Log() << Verbose(1) << "Setting config file name prefix to " << *ConfigFileName << "." << endl);
    16271626      test.open(argv[1], ios::in);
    16281627      if (test == NULL) {
    1629         //return (1);
    1630         output.open(argv[1], ios::out);
    1631         if (output == NULL) {
    1632           DoLog(1) && (Log() << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl);
    1633           configPresent = absent;
    1634         } else {
    1635           DoLog(0) && (Log() << Verbose(0) << "Empty configuration file." << endl);
    1636           strcpy(*ConfigFileName, argv[1]);
    1637           configPresent = empty;
    1638           output.close();
    1639         }
     1628        DoLog(1) && (Log() << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl);
     1629        configPresent = empty;
    16401630      } else {
     1631        configPresent = present;
     1632        DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
     1633        FormatParserStorage::getInstance().getPcp().load(&test);
    16411634        test.close();
    1642         strcpy(*ConfigFileName, argv[1]);
    1643         DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
    1644         switch (configuration.TestSyntax(*ConfigFileName, periode)) {
    1645           case 1:
    1646             DoLog(0) && (Log() << Verbose(0) << "new syntax." << endl);
    1647             configuration.Load(*ConfigFileName, BondGraphFileName, periode, molecules);
    1648             configPresent = present;
    1649             break;
    1650           case 0:
    1651             DoLog(0) && (Log() << Verbose(0) << "old syntax." << endl);
    1652             configuration.LoadOld(*ConfigFileName, BondGraphFileName, periode, molecules);
    1653             configPresent = present;
    1654             break;
    1655           default:
    1656             DoLog(0) && (Log() << Verbose(0) << "Unknown syntax or empty, yet present file." << endl);
    1657             configPresent = empty;
    1658        }
    16591635      }
    16601636    } else
     
    16711647       mol = World::getInstance().createMolecule();
    16721648       mol->ActiveFlag = true;
    1673        if (*ConfigFileName != NULL)
    1674          mol->SetNameFromFilename(*ConfigFileName);
    16751649       molecules->insert(mol);
    16761650     }
     1651     if (*ConfigFileName != NULL)
     1652       mol->SetNameFromFilename(*ConfigFileName);
    16771653
    16781654    // 4. parse again through options, now for those depending on elements db and config presence
     
    17331709              break;
    17341710            case 'I':
    1735               DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);
    17361711              ArgcList.insert(argptr-1);
    17371712              argptr+=0;
     
    19771952            case 't':
    19781953              if (ExitFlag == 0) ExitFlag = 1;
    1979               if ((argptr+4 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
     1954              if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    19801955                ExitFlag = 255;
    19811956                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z> --molecule-by-id <molecule_id> --periodic <0/1>" << endl);
     
    20742049            case 'f':
    20752050              if (ExitFlag == 0) ExitFlag = 1;
    2076               if ((argptr+1 >= argc) || (argv[argptr][0] == '-')) {
     2051              if ((argptr+4 >= argc) || (argv[argptr][0] == '-')) {
    20772052                ExitFlag = 255;
    2078                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl);
     2053                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <path/prefix> --molecule-by-id <molecule id> --distance <max_distance> --order <order>" << endl);
     2054                performCriticalExit();
     2055              } else {
     2056                ArgcList.insert(argptr-1);
     2057                ArgcList.insert(argptr);
     2058                ArgcList.insert(argptr+1);
     2059                ArgcList.insert(argptr+2);
     2060                ArgcList.insert(argptr+3);
     2061                ArgcList.insert(argptr+4);
     2062                ArgcList.insert(argptr+5);
     2063                ArgcList.insert(argptr+6);
     2064                argptr+=7;
     2065              }
     2066              break;
     2067            case 'm':
     2068              if (ExitFlag == 0) ExitFlag = 1;
     2069              j = atoi(argv[argptr++]);
     2070              if ((j<0) || (j>1)) {
     2071                DoeLog(1) && (eLog()<< Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl);
     2072                j = 0;
     2073              }
     2074              if (j) {
     2075                SaveFlag = true;
     2076                DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
     2077                mol->PrincipalAxisSystem((bool)j);
     2078              } else
     2079                ArgcList.insert(argptr-1);
     2080                argptr+=0;
     2081              break;
     2082            case 'o':
     2083              if (ExitFlag == 0) ExitFlag = 1;
     2084              if ((argptr+4 >= argc) || (argv[argptr][0] == '-')){
     2085                ExitFlag = 255;
     2086                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <molecule_id> --output-file <output file> --output-file <binned output file>" << endl);
    20792087                performCriticalExit();
    20802088              } else {
     
    20882096              }
    20892097              break;
    2090             case 'm':
    2091               if (ExitFlag == 0) ExitFlag = 1;
    2092               j = atoi(argv[argptr++]);
    2093               if ((j<0) || (j>1)) {
    2094                 DoeLog(1) && (eLog()<< Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl);
    2095                 j = 0;
    2096               }
    2097               if (j) {
    2098                 SaveFlag = true;
    2099                 DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
    2100                 mol->PrincipalAxisSystem((bool)j);
    2101               } else
    2102                 ArgcList.insert(argptr-1);
    2103                 argptr+=0;
    2104               break;
    2105             case 'o':
    2106               if (ExitFlag == 0) ExitFlag = 1;
    2107               if ((argptr+4 >= argc) || (argv[argptr][0] == '-')){
    2108                 ExitFlag = 255;
    2109                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <molecule_id> --output-file <output file> --output-file <binned output file>" << endl);
    2110                 performCriticalExit();
    2111               } else {
    2112                 ArgcList.insert(argptr-1);
    2113                 ArgcList.insert(argptr);
    2114                 ArgcList.insert(argptr+1);
    2115                 ArgcList.insert(argptr+2);
    2116                 ArgcList.insert(argptr+3);
    2117                 ArgcList.insert(argptr+4);
    2118                 argptr+=5;
    2119               }
    2120               break;
    21212098            case 'U':
    21222099              if (ExitFlag == 0) ExitFlag = 1;
     
    21642141      } else argptr++;
    21652142    } while (argptr < argc);
    2166     if (SaveFlag)
    2167       configuration.SaveAll(*ConfigFileName, periode, molecules);
    21682143  } else {  // no arguments, hence scan the elements db
    21692144    if (periode->LoadPeriodentafel(configuration.databasepath))
     
    21712146    else
    21722147      DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
    2173     configuration.RetrieveConfigPathAndName("main_pcp_linux");
    21742148  }
    21752149  return(ExitFlag);
     
    21792153
    21802154void cleanUp(){
     2155  FormatParserStorage::purgeInstance();
    21812156  ChangeTracker::purgeInstance();
    21822157  World::purgeInstance();
     
    22072182    bool ArgumentsCopied = false;
    22082183    char *ConfigFileName = new char[MAXSTRINGSIZE];
     2184    std::string BondGraphFileName("\n");
     2185    FormatParserStorage::getInstance().addMpqc();
     2186    FormatParserStorage::getInstance().addPcp();
     2187    FormatParserStorage::getInstance().addXyz();
    22092188
    22102189    // print version check whether arguments are present at all
     
    22352214      ArgcList.insert(1); // push back config file name
    22362215      // handle arguments by ParseCommandLineOptions()
    2237       ExitFlag = ParseCommandLineOptions(argc,argv,World::getInstance().getMolecules(),World::getInstance().getPeriode(),*World::getInstance().getConfig(), &ConfigFileName, ArgcList);
     2216      ExitFlag = ParseCommandLineOptions(argc,argv,World::getInstance().getMolecules(),World::getInstance().getPeriode(),*World::getInstance().getConfig(), &ConfigFileName, BondGraphFileName, ArgcList);
    22382217      World::getInstance().setExitFlag(ExitFlag);
    22392218      // copy all remaining arguments to a new argv
     
    22482227      cout << endl;
    22492228      ArgumentsCopied = true;
     2229
     2230      // construct bond graph
     2231      if (World::getInstance().getConfig()->BG == NULL) {
     2232        World::getInstance().getConfig()->BG = new BondGraph(World::getInstance().getConfig()->GetIsAngstroem());
     2233        if (World::getInstance().getConfig()->BG->LoadBondLengthTable(BondGraphFileName)) {
     2234          DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
     2235        } else {
     2236          DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
     2237        }
     2238      }
    22502239      // handle remaining arguments by CommandLineParser
    22512240      MapOfActions::getInstance().AddOptionsToParser();
     
    22692258    }
    22702259
    2271     Log() << Verbose(0) << "Saving to " << ConfigFileName << "." << endl;
    2272     World::getInstance().getConfig()->SaveAll(ConfigFileName, World::getInstance().getPeriode(), World::getInstance().getMolecules());
     2260    std::string FilenamePrefix(ConfigFileName);
     2261    FormatParserStorage::getInstance().SetOutputPrefixForAll(FilenamePrefix);
     2262    FormatParserStorage::getInstance().SaveAll();
     2263    ChangeTracker::getInstance().saveStatus();
    22732264
    22742265  // free the new argv
  • src/config.cpp

    rdc0d21 r35b698  
    3131/** Constructor for config file class.
    3232 */
    33 config::config() : BG(NULL), Thermostats(0), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), configpath(NULL),
     33config::config() : BG(NULL), Thermostats(0), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1),
    3434    configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL),
    3535    DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01),
     
    4242  pseudopotpath = new char[MAXSTRINGSIZE];
    4343  databasepath = new char[MAXSTRINGSIZE];
    44   configpath = new char[MAXSTRINGSIZE];
    4544  configname = new char[MAXSTRINGSIZE];
    4645  Thermostats = new ThermoStatContainer();
     
    4847  strcpy(defaultpath,"not specified");
    4948  strcpy(pseudopotpath,"not specified");
    50   configpath[0]='\0';
    5149  configname[0]='\0';
    5250  basis = "3-21G";
     
    6159  delete[](pseudopotpath);
    6260  delete[](databasepath);
    63   delete[](configpath);
    6461  delete[](configname);
    6562  if (Thermostats != NULL)
     
    383380};
    384381
    385 /** Retrieves the path in the given config file name.
    386  * \param filename config file string
    387  */
    388 void config::RetrieveConfigPathAndName(const string filename)
    389 {
    390   char *ptr = NULL;
    391   char *buffer = new char[MAXSTRINGSIZE];
    392   strncpy(buffer, filename.c_str(), MAXSTRINGSIZE);
    393   int last = -1;
    394   for(last=MAXSTRINGSIZE;last--;) {
    395     if (buffer[last] == '/')
    396       break;
    397   }
    398   if (last == -1) { // no path in front, set to local directory.
    399     strcpy(configpath, "./");
    400     ptr = buffer;
    401   } else {
    402     strncpy(configpath, buffer, last+1);
    403     ptr = &buffer[last+1];
    404     if (last < 254)
    405       configpath[last+1]='\0';
    406   }
    407   strcpy(configname, ptr);
    408   DoLog(0) && (Log() << Verbose(0) << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl);
    409   delete[](buffer);
    410 };
    411 
    412382/** Loads a molecule from a ConfigFileBuffer.
    413383 * \param *mol molecule to load
     
    603573  file->close();
    604574  delete(file);
    605   RetrieveConfigPathAndName(filename);
    606575
    607576  // ParseParameterFile
     
    840809    return;
    841810  }
    842   RetrieveConfigPathAndName(filename);
    843811  // ParseParameters
    844812
     
    15251493  molecule *mol = NULL;
    15261494
    1527   if (!strcmp(configpath, GetDefaultPath())) {
    1528     eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
    1529   }
    1530 
    1531 
    15321495  // first save as PDB data
    15331496  if (ConfigFileName != NULL)
     
    15661529    mol->doCountAtoms();
    15671530    mol->CountElements();
    1568     mol->CalculateOrbitals(*this);
     1531    //mol->CalculateOrbitals(*this);
    15691532    delete[](src);
    15701533  } else {
     
    15721535      mol = *(molecules->ListOfMolecules.begin());
    15731536      mol->doCountAtoms();
    1574       mol->CalculateOrbitals(*this);
     1537      //mol->CalculateOrbitals(*this);
    15751538    } else {
    15761539      DoeLog(1) && (eLog() << Verbose(1) << "There are no molecules to save!" << endl);
     
    16341597  else
    16351598    Log() << Verbose(0) << "\t... failed." << endl;
    1636 
    1637   if (!strcmp(configpath, GetDefaultPath())) {
    1638     eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
    1639   }
    16401599
    16411600  // don't destroy molecule as it contains all our atoms
  • src/config.hpp

    rdc0d21 r35b698  
    4747    int ProcPEGamma;
    4848    int ProcPEPsi;
    49     char *configpath;
    5049    char *configname;
    5150    bool FastParsing;
     
    117116  void Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList);
    118117  void LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList);
    119   void RetrieveConfigPathAndName(const string filename);
    120118  bool Save(const char * const filename, const periodentafel * const periode, molecule * const mol) const;
    121119  bool SaveMPQC(const char * const filename, const molecule * const mol) const;
  • src/molecule.cpp

    rdc0d21 r35b698  
    7979void molecule::setName(const std::string _name){
    8080  OBSERVE;
     81  cout << "Set name of molecule " << getId() << " to " << _name << endl;
    8182  strncpy(name,_name.c_str(),MAXSTRINGSIZE);
    8283}
     
    740741  else
    741742    length = strlen(molname) - strlen(endname);
     743  cout << "Set name of molecule " << getId() << " to " << molname << endl;
    742744  strncpy(name, molname, length);
    743745  name[length]='\0';
     
    10041006  for(int i=MAX_ELEMENTS;i--;)
    10051007    ElementCount += (ElementsInMolecule[i] != 0 ? 1 : 0);
    1006 };
    1007 
    1008 
    1009 /** Counts necessary number of valence electrons and returns number and SpinType.
    1010  * \param configuration containing everything
    1011  */
    1012 void molecule::CalculateOrbitals(class config &configuration)
    1013 {
    1014   configuration.MaxPsiDouble = configuration.PsiMaxNoDown = configuration.PsiMaxNoUp = configuration.PsiType = 0;
    1015   for(int i=MAX_ELEMENTS;i--;) {
    1016     if (ElementsInMolecule[i] != 0) {
    1017       //Log() << Verbose(0) << "CalculateOrbitals: " << elemente->FindElement(i)->name << " has a valence of " << (int)elemente->FindElement(i)->Valence << " and there are " << ElementsInMolecule[i] << " of it." << endl;
    1018       configuration.MaxPsiDouble += ElementsInMolecule[i]*((int)elemente->FindElement(i)->Valence);
    1019     }
    1020   }
    1021   configuration.PsiMaxNoDown = configuration.MaxPsiDouble/2 + (configuration.MaxPsiDouble % 2);
    1022   configuration.PsiMaxNoUp = configuration.MaxPsiDouble/2;
    1023   configuration.MaxPsiDouble /= 2;
    1024   configuration.PsiType = (configuration.PsiMaxNoDown == configuration.PsiMaxNoUp) ? 0 : 1;
    1025   if ((configuration.PsiType == 1) && (configuration.ProcPEPsi < 2) && ((configuration.PsiMaxNoDown != 1) || (configuration.PsiMaxNoUp != 0))) {
    1026     configuration.ProcPEGamma /= 2;
    1027     configuration.ProcPEPsi *= 2;
    1028   } else {
    1029     configuration.ProcPEGamma *= configuration.ProcPEPsi;
    1030     configuration.ProcPEPsi = 1;
    1031   }
    1032   cout << configuration.PsiMaxNoDown << ">" << configuration.PsiMaxNoUp << endl;
    1033   if (configuration.PsiMaxNoDown > configuration.PsiMaxNoUp) {
    1034     configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.PsiMaxNoDown;
    1035     cout << configuration.PsiMaxNoDown << " " << configuration.InitMaxMinStopStep << endl;
    1036   } else {
    1037     configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.PsiMaxNoUp;
    1038     cout << configuration.PsiMaxNoUp << " " << configuration.InitMaxMinStopStep << endl;
    1039   }
    10401008};
    10411009
  • src/molecule.hpp

    rdc0d21 r35b698  
    261261  /// Count and change present atoms' coordination.
    262262  void CountElements();
    263   void CalculateOrbitals(class config &configuration);
    264263  bool CenterInBox();
    265264  bool BoundInBox();
     
    288287  double MinimiseConstrainedPotential(atom **&permutation, int startstep, int endstep, bool IsAngstroem);
    289288  void EvaluateConstrainedForces(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force);
    290   bool LinearInterpolationBetweenConfiguration(int startstep, int endstep, const char *prefix, config &configuration, bool MapByIdentity);
     289  bool LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string &prefix, config &configuration, bool MapByIdentity);
    291290       
    292291  bool CheckBounds(const Vector *x) const;
     
    320319
    321320  /// Fragment molecule by two different approaches:
    322   int FragmentMolecule(int Order, config *configuration);
    323   bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path = NULL);
    324   bool StoreBondsToFile(char *path, char *filename);
    325   bool StoreAdjacencyToFile(char *path, char *filename);
    326   bool CheckAdjacencyFileAgainstMolecule(char *path, atom **ListOfAtoms);
    327   bool ParseOrderAtSiteFromFile(char *path);
    328   bool StoreOrderAtSiteFile(char *path);
    329   bool StoreForcesFile(MoleculeListClass *BondFragments, char *path, int *SortIndex);
     321  int FragmentMolecule(int Order, std::string &prefix);
     322  bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, std::string path = "");
     323  bool StoreBondsToFile(std::string &filename, std::string path = "");
     324  bool StoreAdjacencyToFile(std::string &filename, std::string path = "");
     325  bool CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms);
     326  bool ParseOrderAtSiteFromFile(std::string &path);
     327  bool StoreOrderAtSiteFile(std::string &path);
     328  bool StoreForcesFile(MoleculeListClass *BondFragments, std::string &path, int *SortIndex);
    330329  bool CreateMappingLabelsToConfigSequence(int *&SortIndex);
    331330  bool CreateFatherLookupTable(atom **&LookupTable, int count = 0);
     
    376375  ~MoleculeListClass();
    377376
    378   bool AddHydrogenCorrection(char *path);
    379   bool StoreForcesFile(char *path, int *SortIndex);
     377  bool AddHydrogenCorrection(std::string &path);
     378  bool StoreForcesFile(std::string &path, int *SortIndex);
    380379  void insert(molecule *mol);
    381380  void erase(molecule *mol);
    382381  molecule * ReturnIndex(int index);
    383   bool OutputConfigForListOfFragments(config *configuration, int *SortIndex);
     382  bool OutputConfigForListOfFragments(std::string &prefix, int *SortIndex);
    384383  int NumberOfActiveMolecules();
    385384  void Enumerate(ostream *out);
  • src/molecule_dynamics.cpp

    rdc0d21 r35b698  
    473473 * \param startstep stating initial configuration in molecule::Trajectories
    474474 * \param endstep stating final configuration in molecule::Trajectories
     475 * \param &prefix path and prefix
    475476 * \param &config configuration structure
    476477 * \param MapByIdentity if true we just use the identity to map atoms in start config to end config, if not we find mapping by \sa MinimiseConstrainedPotential()
    477478 * \return true - success in writing step files, false - error writing files or only one step in molecule::Trajectories
    478479 */
    479 bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, const char *prefix, config &configuration, bool MapByIdentity)
     480bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string &prefix, config &configuration, bool MapByIdentity)
    480481{
    481482  molecule *mol = NULL;
     
    525526  for (int i=getAtomCount(); i--; )
    526527    SortIndex[i] = i;
    527   status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex);
     528
     529  status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex);
    528530  delete[](SortIndex);
    529531
  • src/molecule_fragmentation.cpp

    rdc0d21 r35b698  
    8282 * -# Scans TEFactors file and sets the TEFactor of each key set in the temporary graph accordingly
    8383 * Finally, the temporary graph is inserted into the given \a FragmentList for return.
    84  * \param *out output stream for debugging
    85  * \param *path path to file
     84 * \param &path path to file
    8685 * \param *FragmentList empty, filled on return
    8786 * \return true - parsing successfully, false - failure on parsing (FragmentList will be NULL)
    8887 */
    89 bool ParseKeySetFile(char *path, Graph *&FragmentList)
     88bool ParseKeySetFile(std::string &path, Graph *&FragmentList)
    9089{
    9190  bool status = true;
     
    9493  GraphTestPair testGraphInsert;
    9594  int NumberOfFragments = 0;
    96   char filename[MAXSTRINGSIZE];
     95  string filename;
    9796
    9897  if (FragmentList == NULL) { // check list pointer
     
    102101  // 1st pass: open file and read
    103102  DoLog(1) && (Log() << Verbose(1) << "Parsing the KeySet file ... " << endl);
    104   sprintf(filename, "%s/%s%s", path, FRAGMENTPREFIX, KEYSETFILE);
    105   InputFile.open(filename);
    106   if (InputFile != NULL) {
     103  filename = path + KEYSETFILE;
     104  InputFile.open(filename.c_str());
     105  if (InputFile.good()) {
    107106    // each line represents a new fragment
    108107    char buffer[MAXSTRINGSIZE];
     
    181180
    182181/** Stores key sets to file.
    183  * \param *out output stream for debugging
    184182 * \param KeySetList Graph with Keysets
    185  * \param *path path to file
     183 * \param &path path to file
    186184 * \return true - file written successfully, false - writing failed
    187185 */
    188 bool StoreKeySetFile(Graph &KeySetList, char *path)
    189 {
    190   ofstream output;
     186bool StoreKeySetFile(Graph &KeySetList, std::string &path)
     187{
    191188  bool status =  true;
    192   string line;
     189  string line = path + KEYSETFILE;
     190  ofstream output(line.c_str());
    193191
    194192  // open KeySet file
    195   line = path;
    196   line.append("/");
    197   line += FRAGMENTPREFIX;
    198   line += KEYSETFILE;
    199   output.open(line.c_str(), ios::out);
    200193  DoLog(1) && (Log() << Verbose(1) << "Saving key sets of the total graph ... ");
    201   if(output != NULL) {
     194  if(output.good()) {
    202195    for(Graph::iterator runner = KeySetList.begin(); runner != KeySetList.end(); runner++) {
    203196      for (KeySet::iterator sprinter = (*runner).first.begin();sprinter != (*runner).first.end(); sprinter++) {
     
    302295
    303296/** Scans the adaptive order file and insert (index, value) into map.
    304  * \param *out output stream for debugging
    305  * \param *path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative)
     297 * \param &path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative)
    306298 * \param &IndexedKeySetList list to find key set for a given index \a No
    307299 * \return adaptive criteria list from file
    308300 */
    309 map<int, pair<double,int> > * ScanAdaptiveFileIntoMap(char *path, map<int,KeySet> &IndexKeySetList)
     301map<int, pair<double,int> > * ScanAdaptiveFileIntoMap(std::string &path, map<int,KeySet> &IndexKeySetList)
    310302{
    311303  map<int, pair<double,int> > *AdaptiveCriteriaList = new map<int, pair<double,int> >;
     
    313305  double Value = 0.;
    314306  char buffer[MAXSTRINGSIZE];
    315   sprintf(buffer, "%s/%s%s.dat", path, FRAGMENTPREFIX, ENERGYPERFRAGMENT);
    316   ifstream InputFile(buffer, ios::in);
     307  string filename = path + ENERGYPERFRAGMENT;
     308  ifstream InputFile(filename.c_str());
     309
     310  if (InputFile.fail()) {
     311    DoeLog(1) && (eLog() << Verbose(1) << "Cannot find file " << filename << "." << endl);
     312    return AdaptiveCriteriaList;
     313  }
    317314
    318315  if (CountLinesinFile(InputFile) > 0) {
     
    419416
    420417/** Checks whether the OrderAtSite is still below \a Order at some site.
    421  * \param *out output stream for debugging
    422418 * \param *AtomMask defines true/false per global Atom::nr to mask in/out each nuclear site, used to activate given number of site to increment order adaptively
    423419 * \param *GlobalKeySetList list of keysets with global ids (valid in "this" molecule) needed for adaptive increase
    424420 * \param Order desired Order if positive, desired exponent in threshold criteria if negative (0 is single-step)
    425421 * \param *MinimumRingSize array of max. possible order to avoid loops
    426  * \param *path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative)
     422 * \param path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative)
    427423 * \return true - needs further fragmentation, false - does not need fragmentation
    428424 */
    429 bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path)
     425bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, std::string path)
    430426{
    431427  bool status = false;
     
    585581 * of vertex indices: Global always means the index in "this" molecule, whereas local refers to the molecule or
    586582 * subgraph in the MoleculeListClass.
    587  * \param *out output stream for debugging
    588583 * \param Order up to how many neighbouring bonds a fragment contains in BondOrderScheme::BottumUp scheme
    589  * \param *configuration configuration for writing config files for each fragment
     584 * \param &prefix path and prefix of the bond order configs to be written
    590585 * \return 1 - continue, 2 - stop (no fragmentation occured)
    591586 */
    592 int molecule::FragmentMolecule(int Order, config *configuration)
     587int molecule::FragmentMolecule(int Order, std::string &prefix)
    593588{
    594589  MoleculeListClass *BondFragments = NULL;
     
    624619
    625620  // === compare it with adjacency file ===
    626   FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(configuration->configpath, ListOfAtoms);
     621  FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(prefix, ListOfAtoms);
    627622  delete[](ListOfAtoms);
    628623
     
    658653
    659654  // ===== 3. if structure still valid, parse key set file and others =====
    660   FragmentationToDo = FragmentationToDo && ParseKeySetFile(configuration->configpath, ParsedFragmentList);
     655  FragmentationToDo = FragmentationToDo && ParseKeySetFile(prefix, ParsedFragmentList);
    661656
    662657  // ===== 4. check globally whether there's something to do actually (first adaptivity check)
    663   FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(configuration->configpath);
     658  FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(prefix);
    664659
    665660  // =================================== Begin of FRAGMENTATION ===============================
     
    672667  AtomMask[getAtomCount()] = false;
    673668  FragmentationToDo = false;  // if CheckOrderAtSite just ones recommends fragmentation, we will save fragments afterwards
    674   while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, configuration->configpath))) {
     669  while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, prefix))) {
    675670    FragmentationToDo = FragmentationToDo || CheckOrder;
    676671    AtomMask[getAtomCount()] = true;   // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite()
     
    727722    KeySet test = (*runner).first;
    728723    DoLog(0) && (Log() << Verbose(0) << "Fragment No." << (*runner).second.first << " with TEFactor " << (*runner).second.second << "." << endl);
    729     BondFragments->insert(StoreFragmentFromKeySet(test, configuration));
     724    BondFragments->insert(StoreFragmentFromKeySet(test, World::getInstance().getConfig()));
    730725    k++;
    731726  }
     
    739734
    740735    DoLog(1) && (Log() << Verbose(1) << "Writing " << BondFragments->ListOfMolecules.size() << " possible bond fragmentation configs" << endl);
    741     if (BondFragments->OutputConfigForListOfFragments(configuration, SortIndex))
     736    if (BondFragments->OutputConfigForListOfFragments(prefix, SortIndex))
    742737      DoLog(1) && (Log() << Verbose(1) << "All configs written." << endl);
    743738    else
     
    745740
    746741    // store force index reference file
    747     BondFragments->StoreForcesFile(configuration->configpath, SortIndex);
     742    BondFragments->StoreForcesFile(prefix, SortIndex);
    748743
    749744    // store keysets file
    750     StoreKeySetFile(TotalGraph, configuration->configpath);
     745    StoreKeySetFile(TotalGraph, prefix);
    751746
    752747    {
    753748      // store Adjacency file
    754       char filename[MAXSTRINGSIZE];
    755       strcpy(filename, FRAGMENTPREFIX);
    756       strcat(filename, ADJACENCYFILE);
    757       StoreAdjacencyToFile(configuration->configpath, filename);
     749      std::string filename = prefix + ADJACENCYFILE;
     750      StoreAdjacencyToFile(filename);
    758751    }
    759752
    760753    // store Hydrogen saturation correction file
    761     BondFragments->AddHydrogenCorrection(configuration->configpath);
     754    BondFragments->AddHydrogenCorrection(prefix);
    762755
    763756    // store adaptive orders into file
    764     StoreOrderAtSiteFile(configuration->configpath);
     757    StoreOrderAtSiteFile(prefix);
    765758
    766759    // restore orbital and Stop values
    767     CalculateOrbitals(*configuration);
     760    //CalculateOrbitals(*configuration);
    768761
    769762    // free memory for bond part
     
    782775/** Stores pairs (Atom::nr, Atom::AdaptiveOrder) into file.
    783776 * Atoms not present in the file get "-1".
    784  * \param *out output stream for debugging
    785  * \param *path path to file ORDERATSITEFILE
     777 * \param &path path to file ORDERATSITEFILE
    786778 * \return true - file writable, false - not writable
    787779 */
    788 bool molecule::StoreOrderAtSiteFile(char *path)
    789 {
    790   stringstream line;
     780bool molecule::StoreOrderAtSiteFile(std::string &path)
     781{
     782  string line;
    791783  ofstream file;
    792784
    793   line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE;
    794   file.open(line.str().c_str());
     785  line = path + ORDERATSITEFILE;
     786  file.open(line.c_str());
    795787  DoLog(1) && (Log() << Verbose(1) << "Writing OrderAtSite " << ORDERATSITEFILE << " ... " << endl);
    796   if (file != NULL) {
     788  if (file.good()) {
    797789    ActOnAllAtoms( &atom::OutputOrder, &file );
    798790    file.close();
     
    800792    return true;
    801793  } else {
    802     DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
     794    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line << "." << endl);
    803795    return false;
    804796  }
     
    807799/** Parses pairs(Atom::nr, Atom::AdaptiveOrder) from file and stores in molecule's Atom's.
    808800 * Atoms not present in the file get "0".
    809  * \param *out output stream for debugging
    810  * \param *path path to file ORDERATSITEFILEe
     801 * \param &path path to file ORDERATSITEFILEe
    811802 * \return true - file found and scanned, false - file not found
    812803 * \sa ParseKeySetFile() and CheckAdjacencyFileAgainstMolecule() as this is meant to be used in conjunction with the two
    813804 */
    814 bool molecule::ParseOrderAtSiteFromFile(char *path)
     805bool molecule::ParseOrderAtSiteFromFile(std::string &path)
    815806{
    816807  unsigned char *OrderArray = new unsigned char[getAtomCount()];
     
    818809  bool status;
    819810  int AtomNr, value;
    820   stringstream line;
     811  string line;
    821812  ifstream file;
    822813
     
    827818
    828819  DoLog(1) && (Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl);
    829   line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE;
    830   file.open(line.str().c_str());
    831   if (file != NULL) {
     820  line = path + ORDERATSITEFILE;
     821  file.open(line.c_str());
     822  if (file.good()) {
    832823    while (!file.eof()) { // parse from file
    833824      AtomNr = -1;
     
    850841    status = true;
    851842  } else {
    852     DoLog(1) && (Log() << Verbose(1) << "\t ... failed to open file " << line.str() << "." << endl);
     843    DoLog(1) && (Log() << Verbose(1) << "\t ... failed to open file " << line << "." << endl);
    853844    status = false;
    854845  }
  • src/molecule_graph.cpp

    rdc0d21 r35b698  
    1212#include "bondgraph.hpp"
    1313#include "config.hpp"
     14#include "defs.hpp"
    1415#include "element.hpp"
    1516#include "helpers.hpp"
     
    10241025/** Storing the bond structure of a molecule to file.
    10251026 * Simply stores Atom::nr and then the Atom::nr of all bond partners per line.
    1026  * \param *path path to file
    1027  * \param *filename name of file
     1027 * \param &filename name of file
     1028 * \param path path to file, defaults to empty
    10281029 * \return true - file written successfully, false - writing failed
    10291030 */
    1030 bool molecule::StoreAdjacencyToFile(char *path, char *filename)
     1031bool molecule::StoreAdjacencyToFile(std::string &filename, std::string path)
    10311032{
    10321033  ofstream AdjacencyFile;
    1033   stringstream line;
     1034  string line;
    10341035  bool status = true;
    10351036
    1036   if (path != NULL)
    1037     line << path << "/" << filename;
     1037  if (path != "")
     1038    line = path + "/" + filename;
    10381039  else
    1039     line << filename;
    1040   AdjacencyFile.open(line.str().c_str(), ios::out);
     1040    line = filename;
     1041  AdjacencyFile.open(line.c_str(), ios::out);
    10411042  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl);
    1042   if (AdjacencyFile != NULL) {
     1043  if (AdjacencyFile.good()) {
    10431044    AdjacencyFile << "m\tn" << endl;
    10441045    ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile);
     
    10461047    DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl);
    10471048  } else {
    1048     DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line.str() << "." << endl);
     1049    DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line << "." << endl);
    10491050    status = false;
    10501051  }
     
    10561057/** Storing the bond structure of a molecule to file.
    10571058 * Simply stores Atom::nr and then the Atom::nr of all bond partners, one per line.
    1058  * \param *path path to file
    1059  * \param *filename name of file
     1059 * \param &filename name of file
     1060 * \param path path to file, defaults to empty
    10601061 * \return true - file written successfully, false - writing failed
    10611062 */
    1062 bool molecule::StoreBondsToFile(char *path, char *filename)
     1063bool molecule::StoreBondsToFile(std::string &filename, std::string path)
    10631064{
    10641065  ofstream BondFile;
    1065   stringstream line;
     1066  string line;
    10661067  bool status = true;
    10671068
    1068   if (path != NULL)
    1069     line << path << "/" << filename;
     1069  if (path != "")
     1070    line = path + "/" + filename;
    10701071  else
    1071     line << filename;
    1072   BondFile.open(line.str().c_str(), ios::out);
     1072    line = filename;
     1073  BondFile.open(line.c_str(), ios::out);
    10731074  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl);
    1074   if (BondFile != NULL) {
     1075  if (BondFile.good()) {
    10751076    BondFile << "m\tn" << endl;
    10761077    ActOnAllAtoms(&atom::OutputBonds, &BondFile);
     
    10781079    DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl);
    10791080  } else {
    1080     DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line.str() << "." << endl);
     1081    DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line << "." << endl);
    10811082    status = false;
    10821083  }
     
    10861087;
    10871088
    1088 bool CheckAdjacencyFileAgainstMolecule_Init(char *path, ifstream &File, int *&CurrentBonds)
    1089 {
    1090   stringstream filename;
    1091   filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;
    1092   File.open(filename.str().c_str(), ios::out);
     1089bool CheckAdjacencyFileAgainstMolecule_Init(std::string &path, ifstream &File, int *&CurrentBonds)
     1090{
     1091  string filename;
     1092  filename = path + ADJACENCYFILE;
     1093  File.open(filename.c_str(), ios::out);
    10931094  DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... " << endl);
    1094   if (File == NULL)
     1095  if (File.fail())
    10951096    return false;
    10961097
     
    11461147 * \return true - structure is equal, false - not equivalence
    11471148 */
    1148 bool molecule::CheckAdjacencyFileAgainstMolecule(char *path, atom **ListOfAtoms)
     1149bool molecule::CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms)
    11491150{
    11501151  ifstream File;
  • src/moleculelist.cpp

    rdc0d21 r35b698  
    380380 * bonded to the same atom, then we add for this pair a correction term constructed from a Morse
    381381 * potential function fit to QM calculations with respecting to the interatomic hydrogen distance.
    382  * \param *out output stream for debugging
    383  * \param *path path to file
    384  */
    385 bool MoleculeListClass::AddHydrogenCorrection(char *path)
     382 * \param &path path to file
     383 */
     384bool MoleculeListClass::AddHydrogenCorrection(std::string &path)
    386385{
    387386  bond *Binder = NULL;
     
    401400  // 0a. find dimension of matrices with constants
    402401  line = path;
    403   line.append("/");
    404   line += FRAGMENTPREFIX;
    405402  line += "1";
    406403  line += FITCONSTANTSUFFIX;
    407404  input.open(line.c_str());
    408   if (input == NULL) {
     405  if (input.fail()) {
    409406    DoLog(1) && (Log() << Verbose(1) << endl << "Unable to open " << line << ", is the directory correct?" << endl);
    410407    return false;
     
    570567
    571568/** Store force indices, i.e. the connection between the nuclear index in the total molecule config and the respective atom in fragment config.
    572  * \param *out output stream for debugging
    573  * \param *path path to file
     569 * \param &path path to file
    574570 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config
    575571 * \return true - file written successfully, false - writing failed
    576572 */
    577 bool MoleculeListClass::StoreForcesFile(char *path,
    578     int *SortIndex)
     573bool MoleculeListClass::StoreForcesFile(std::string &path, int *SortIndex)
    579574{
    580575  bool status = true;
    581   ofstream ForcesFile;
    582   stringstream line;
     576  string filename(path);
     577  filename += FORCESFILE;
     578  ofstream ForcesFile(filename.c_str());
    583579  periodentafel *periode=World::getInstance().getPeriode();
    584580
    585581  // open file for the force factors
    586582  DoLog(1) && (Log() << Verbose(1) << "Saving  force factors ... ");
    587   line << path << "/" << FRAGMENTPREFIX << FORCESFILE;
    588   ForcesFile.open(line.str().c_str(), ios::out);
    589   if (ForcesFile != NULL) {
     583  if (!ForcesFile.fail()) {
    590584    //Log() << Verbose(1) << "Final AtomicForcesList: ";
    591585    //output << prefix << "Forces" << endl;
     
    612606  } else {
    613607    status = false;
    614     DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
     608    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << filename << "." << endl);
    615609  }
    616610  ForcesFile.close();
     
    621615/** Writes a config file for each molecule in the given \a **FragmentList.
    622616 * \param *out output stream for debugging
    623  * \param *configuration standard configuration to attach atoms in fragment molecule to.
     617 * \param &prefix path and prefix to the fragment config files
    624618 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config
    625619 * \return true - success (each file was written), false - something went wrong.
    626620 */
    627 bool MoleculeListClass::OutputConfigForListOfFragments(config *configuration, int *SortIndex)
     621bool MoleculeListClass::OutputConfigForListOfFragments(std::string &prefix, int *SortIndex)
    628622{
    629623  ofstream outputFragment;
    630   char FragmentName[MAXSTRINGSIZE];
     624  std::string FragmentName;
    631625  char PathBackup[MAXSTRINGSIZE];
    632626  bool result = true;
     
    646640  for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
    647641    // save default path as it is changed for each fragment
    648     path = configuration->GetDefaultPath();
     642    path = World::getInstance().getConfig()->GetDefaultPath();
    649643    if (path != NULL)
    650644      strcpy(PathBackup, path);
     
    659653    // output xyz file
    660654    FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), FragmentCounter++);
    661     sprintf(FragmentName, "%s/%s%s.conf.xyz", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
    662     outputFragment.open(FragmentName, ios::out);
     655    FragmentName = prefix + FragmentNumber + ".conf.xyz";
     656    outputFragment.open(FragmentName.c_str(), ios::out);
    663657    DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as XYZ ...");
    664658    if ((intermediateResult = (*ListRunner)->OutputXYZ(&outputFragment)))
     
    683677    for (int k = 0; k < NDIM; k++) {
    684678      j += k + 1;
    685       BoxDimension[k] = 2.5 * (configuration->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);
     679      BoxDimension[k] = 2.5 * (World::getInstance().getConfig()->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);
    686680      cell_size[j] = BoxDimension[k] * 2.;
    687681    }
     
    690684    // also calculate necessary orbitals
    691685    (*ListRunner)->CountElements(); // this is a bugfix, atoms should shoulds actually be added correctly to this fragment
    692     (*ListRunner)->CalculateOrbitals(*configuration);
     686    //(*ListRunner)->CalculateOrbitals(*World::getInstance().getConfig);
    693687
    694688    // change path in config
    695     //strcpy(PathBackup, configuration->configpath);
    696     sprintf(FragmentName, "%s/%s%s/", PathBackup, FRAGMENTPREFIX, FragmentNumber);
    697     configuration->SetDefaultPath(FragmentName);
     689    FragmentName = PathBackup;
     690    FragmentName += "/";
     691    FragmentName += FRAGMENTPREFIX;
     692    FragmentName += FragmentNumber;
     693    FragmentName += "/";
     694    World::getInstance().getConfig()->SetDefaultPath(FragmentName.c_str());
    698695
    699696    // and save as config
    700     sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
     697    FragmentName = prefix + FragmentNumber + ".conf";
    701698    DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as config ...");
    702     if ((intermediateResult = configuration->Save(FragmentName, (*ListRunner)->elemente, (*ListRunner))))
     699    if ((intermediateResult = World::getInstance().getConfig()->Save(FragmentName.c_str(), (*ListRunner)->elemente, (*ListRunner))))
    703700      DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    704701    else
     
    707704
    708705    // restore old config
    709     configuration->SetDefaultPath(PathBackup);
     706    World::getInstance().getConfig()->SetDefaultPath(PathBackup);
    710707
    711708    // and save as mpqc input file
    712     sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
     709    FragmentName = prefix + FragmentNumber + ".conf";
    713710    DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as mpqc input ...");
    714     if ((intermediateResult = configuration->SaveMPQC(FragmentName, (*ListRunner))))
     711    if ((intermediateResult = World::getInstance().getConfig()->SaveMPQC(FragmentName.c_str(), (*ListRunner))))
    715712      DoLog(2) && (Log() << Verbose(2) << " done." << endl);
    716713    else
     
    768765
    769766  // 1. dissect the molecule into connected subgraphs
    770   if (!configuration->BG->ConstructBondGraph(mol)) {
    771     World::getInstance().destroyMolecule(mol);
    772     DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl);
     767  if (configuration->BG != NULL) {
     768    if (!configuration->BG->ConstructBondGraph(mol)) {
     769      World::getInstance().destroyMolecule(mol);
     770      DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl);
     771      return;
     772    }
     773  } else {
     774    DoeLog(1) && (eLog()<< Verbose(1) << "There is no BondGraph class present to create bonds." << endl);
    773775    return;
    774776  }
  • src/unittests/Makefile.am

    rdc0d21 r35b698  
    5252GSLLIBS = ../libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
    5353ALLLIBS = ../libmolecuilder.a ${GSLLIBS}
     54PARSERLIBS = ../libparser.a ${ALLLIBS}
    5455
    5556TESTSOURCES = \
     
    201202
    202203ParserUnitTest_SOURCES = UnitTestMain.cpp ParserUnitTest.cpp ParserUnitTest.hpp
    203 ParserUnitTest_LDADD = ${ALLLIBS}
     204ParserUnitTest_LDADD = ${PARSERLIBS}
    204205
    205206periodentafelTest_SOURCES = UnitTestMain.cpp periodentafelTest.cpp periodentafelTest.hpp
Note: See TracChangeset for help on using the changeset viewer.