Changeset 461e93


Ignore:
Timestamp:
May 8, 2008, 4:18:07 PM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
a3ff7b2
Parents:
d88597
Message:

molecule::CheckOrderAtSite() returns bool and used as threshold criterium to break while in molecule::FragmentMolecule()

As we are now near the end of the switch to adaptive increase of the bond order, the first step was to increment the OrderAtSite on all sites equally. This is now implemented. CheckOrderAtSite() checks whether the order is still below the desired value at one site and if so continues. In this while-loop we fill the RootStack and call BOSSANOVA. The sequence of AssignKeySets.. and FillRootStack... was flipped for this.

Location:
molecuilder/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/molecules.cpp

    rd88597 r461e93  
    21392139 * \param &FragmentationToDo return boolean
    21402140 * \param Order desired Order
    2141  */
    2142 void molecule::CheckOrderAtSite(ofstream *out, bool &FragmentationToDo, int Order)
    2143 {
    2144   atom *Walker = NULL;
    2145  
    2146   if (FragmentationToDo) { // check whether OrderAtSite is above Order everywhere
    2147     FragmentationToDo = false;
    2148     Walker = start;
    2149     while (Walker->next != end) {
    2150       Walker = Walker->next;
     2141 * \return true - needs further fragmentation, false - does not need fragmentation
     2142 */
     2143bool molecule::CheckOrderAtSite(ofstream *out, int Order)
     2144{
     2145  atom *Walker = NULL;
     2146  bool status = false;
     2147 
     2148  Walker = start;
     2149  while (Walker->next != end) {
     2150    Walker = Walker->next;
    21512151#ifdef ADDHYDROGEN
    2152       if (Walker->type->Z != 1) // skip hydrogen
     2152    if (Walker->type->Z != 1) // skip hydrogen
    21532153#endif
    2154         if (Walker->AdaptiveOrder < Order)
    2155           FragmentationToDo = true;
    2156     }
    2157     if (!FragmentationToDo)
    2158       *out << Verbose(1) << "Order at every site is already equal or above desired order " << Order << "." << endl;
    2159   } else
    2160     *out << Verbose(1) << "Parsing order at site file failed" << endl;
     2154      if (Walker->AdaptiveOrder < Order)
     2155        status = true;
     2156  }
     2157  if (!status)
     2158    *out << Verbose(1) << "Order at every site is already equal or above desired order " << Order << "." << endl;
     2159 
     2160  return status;
    21612161};
    21622162
     
    22342234#endif
    22352235
    2236   // ++++++++++++++++++++++++++++ INITIAL STUFF: Bond structure analysis, ... ++++++++++++++++++++++++++++++++++++++++++
     2236  // ++++++++++++++++++++++++++++ INITIAL STUFF: Bond structure analysis, file parsing, ... ++++++++++++++++++++++++++++++++++++++++++
    22372237 
    22382238  // ===== 1. Check whether bond structure is same as stored in files ====
     
    22582258  // ===== 4. check globally whether there's something to do actually (first adaptivity check)
    22592259  FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(out, configuration->configpath);
    2260   CheckOrderAtSite(out, FragmentationToDo, Order);
    22612260 
    22622261  // =================================== Begin of FRAGMENTATION ===============================
     
    22652264    *out << Verbose(0) << "Bond order " << Order << " greater than or equal to Minimum Ring size of " << MinimumRingSize << " found is not allowed." << endl;
    22662265  } else {
    2267     // ===== 6a. fill RootStack for each subgraph (second adaptivity check) =====
    2268     // NOTE: (keep this extern of following while loop, as lateron we may here look for which site to add to which subgraph)
    2269     // fill the root stack
     2266    // ===== 6a. assign each keyset to its respective subgraph =====
     2267    Subgraphs->next->AssignKeySetsToFragment(out, this, ParsedFragmentList, ListOfLocalAtoms, FragmentList, (FragmentCounter = 0), false);
     2268    delete(ParsedFragmentList);
     2269
    22702270    KeyStack *RootStack = new KeyStack[Subgraphs->next->Count()];
    2271     Subgraphs->next->FillRootStackForSubgraphs(out, RootStack, Order, (FragmentCounter = 0));
    2272 
    2273    // ===== 6b. assign each keyset to its respective subgraph =====
    2274     Subgraphs->next->AssignKeySetsToFragment(out, this, ParsedFragmentList, ListOfLocalAtoms, FragmentList, (FragmentCounter = 0), false);
    2275 
    2276    // ===== 7. fill the bond fragment list =====
    2277     FragmentCounter = 0;
    2278     MolecularWalker = Subgraphs;
    2279     while (MolecularWalker->next != NULL) {
    2280       MolecularWalker = MolecularWalker->next;
    2281       *out << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl;
    2282       // output ListOfBondsPerAtom for debugging
    2283       MolecularWalker->Leaf->OutputListOfBonds(out);
    2284       if (MolecularWalker->Leaf->first->next != MolecularWalker->Leaf->last) {
    2285      
    2286         // call BOSSANOVA method
    2287         *out << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl;
    2288         MolecularWalker->Leaf->FragmentBOSSANOVA(out, FragmentList[FragmentCounter], RootStack[FragmentCounter]);
    2289       } else {
    2290         cerr << "Subgraph " << MolecularWalker << " has no atoms!" << endl;
    2291       }
    2292       FragmentCounter++;  // next fragment list
    2293     }
     2271    while (CheckOrderAtSite(out, Order)) {
     2272      // ===== 6b. fill RootStack for each subgraph (second adaptivity check) =====
     2273      Subgraphs->next->FillRootStackForSubgraphs(out, RootStack, Order, (FragmentCounter = 0));
     2274
     2275      // ===== 7. fill the bond fragment list =====
     2276      FragmentCounter = 0;
     2277      MolecularWalker = Subgraphs;
     2278      while (MolecularWalker->next != NULL) {
     2279        MolecularWalker = MolecularWalker->next;
     2280        *out << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl;
     2281        // output ListOfBondsPerAtom for debugging
     2282        MolecularWalker->Leaf->OutputListOfBonds(out);
     2283        if (MolecularWalker->Leaf->first->next != MolecularWalker->Leaf->last) {
     2284       
     2285          // call BOSSANOVA method
     2286          *out << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl;
     2287          MolecularWalker->Leaf->FragmentBOSSANOVA(out, FragmentList[FragmentCounter], RootStack[FragmentCounter]);
     2288        } else {
     2289          cerr << "Subgraph " << MolecularWalker << " has no atoms!" << endl;
     2290        }
     2291        FragmentCounter++;  // next fragment list
     2292      }
     2293    }
     2294    delete[](RootStack);
    22942295  }
    22952296 
     
    23052306 
    23062307  // free subgraph memory again
    2307   delete(ParsedFragmentList);
    23082308  FragmentCounter = 0;
    23092309  if (Subgraphs != NULL) {
  • molecuilder/src/molecules.hpp

    rd88597 r461e93  
    340340  /// Fragment molecule by two different approaches:
    341341  void FragmentMolecule(ofstream *out, int Order, config *configuration);
    342   void CheckOrderAtSite(ofstream *out, bool &FragmentationToDo, int Order);
     342  bool CheckOrderAtSite(ofstream *out, int Order);
    343343  bool StoreAdjacencyToFile(ofstream *out, char *path);
    344344  bool CheckAdjacencyFileAgainstMolecule(ofstream *out, char *path, atom **ListOfAtoms);
Note: See TracChangeset for help on using the changeset viewer.