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, 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@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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  }
Note: See TracChangeset for help on using the changeset viewer.