Ignore:
Timestamp:
May 31, 2010, 5:32:27 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, 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:
e08c46
Parents:
42af9e (diff), a7b761b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Frederik Heber <heber@…> (05/31/10 17:29:30)
git-committer:
Frederik Heber <heber@…> (05/31/10 17:32:27)
Message:

Merge commit 'jupiter/MoleculeStartEndSwitch' into CommandLineActionMapping

Conflicts:

molecuilder/src/Makefile.am
molecuilder/src/builder.cpp
molecuilder/src/config.cpp
molecuilder/src/helpers.hpp
molecuilder/src/molecule.cpp
molecuilder/src/molecule_dynamics.cpp
molecuilder/src/molecule_fragmentation.cpp
molecuilder/src/molecule_geometry.cpp
molecuilder/src/molecule_graph.cpp
molecuilder/src/moleculelist.cpp
molecuilder/src/unittests/AnalysisCorrelationToPointUnitTest.cpp
molecuilder/src/unittests/listofbondsunittest.cpp

Integration of MoleculeStartEndSwitch had the following consequences:

  • no more AtomCount -> getAtomCount()
  • no more start/end -> begin(), end() and iterator
  • no more decent ordering in atomic ids (hence, Simple_configuration/8 and Domain/5, Domain/6 now check by comparing sorted xyz, not confs)

There is still a huge problem with bonds. One test runs into an endless loop.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_fragmentation.cpp

    r42af9e r1024cb  
    3939  int FragmentCount;
    4040  // get maximum bond degree
    41   atom *Walker = start;
    42   while (Walker->next != end) {
    43     Walker = Walker->next;
    44     c = (Walker->ListOfBonds.size() > c) ? Walker->ListOfBonds.size() : c;
     41  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     42    c = ((*iter)->ListOfBonds.size() > c) ? (*iter)->ListOfBonds.size() : c;
    4543  }
    4644  FragmentCount = NoNonHydrogen*(1 << (c*order));
     
    353351map<double, pair<int,int> >  * ReMapAdaptiveCriteriaListToValue(map<int, pair<double,int> > *AdaptiveCriteriaList, molecule *mol)
    354352{
    355   atom *Walker = mol->start;
     353  atom *Walker = NULL;
    356354  map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ;
    357355  DoLog(1) && (Log() << Verbose(1) << "Root candidate list is: " << endl);
     
    385383bool MarkUpdateCandidates(bool *AtomMask, map<double, pair<int,int> > &FinalRootCandidates, int Order, molecule *mol)
    386384{
    387   atom *Walker = mol->start;
     385  atom *Walker = NULL;
    388386  int No = -1;
    389387  bool status = false;
     
    429427bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path)
    430428{
    431   atom *Walker = start;
    432429  bool status = false;
    433430
    434431  // initialize mask list
    435   for(int i=AtomCount;i--;)
     432  for(int i=getAtomCount();i--;)
    436433    AtomMask[i] = false;
    437434
    438435  if (Order < 0) { // adaptive increase of BondOrder per site
    439     if (AtomMask[AtomCount] == true)  // break after one step
     436    if (AtomMask[getAtomCount()] == true)  // break after one step
    440437      return false;
    441438
     
    451448    if (AdaptiveCriteriaList->empty()) {
    452449      DoeLog(2) && (eLog()<< Verbose(2) << "Unable to parse file, incrementing all." << endl);
    453       while (Walker->next != end) {
    454         Walker = Walker->next;
     450      for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    455451    #ifdef ADDHYDROGEN
    456         if (Walker->type->Z != 1) // skip hydrogen
     452        if ((*iter)->type->Z != 1) // skip hydrogen
    457453    #endif
    458454        {
    459           AtomMask[Walker->nr] = true;  // include all (non-hydrogen) atoms
     455          AtomMask[(*iter)->nr] = true;  // include all (non-hydrogen) atoms
    460456          status = true;
    461457        }
     
    472468    delete[](FinalRootCandidates);
    473469  } else { // global increase of Bond Order
    474     while (Walker->next != end) {
    475       Walker = Walker->next;
     470    for(molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    476471  #ifdef ADDHYDROGEN
    477       if (Walker->type->Z != 1) // skip hydrogen
     472      if ((*iter)->type->Z != 1) // skip hydrogen
    478473  #endif
    479474      {
    480         AtomMask[Walker->nr] = true;  // include all (non-hydrogen) atoms
    481         if ((Order != 0) && (Walker->AdaptiveOrder < Order)) // && (Walker->AdaptiveOrder < MinimumRingSize[Walker->nr]))
     475        AtomMask[(*iter)->nr] = true;  // include all (non-hydrogen) atoms
     476        if ((Order != 0) && ((*iter)->AdaptiveOrder < Order)) // && ((*iter)->AdaptiveOrder < MinimumRingSize[(*iter)->nr]))
    482477          status = true;
    483478      }
    484479    }
    485     if ((Order == 0) && (AtomMask[AtomCount] == false))  // single stepping, just check
     480    if ((!Order) && (!AtomMask[getAtomCount()]))  // single stepping, just check
    486481      status = true;
    487482
     
    494489  }
    495490
    496   PrintAtomMask(AtomMask, AtomCount); // for debugging
     491  PrintAtomMask(AtomMask, getAtomCount()); // for debugging
    497492
    498493  return status;
     
    510505    return false;
    511506  }
    512   SortIndex = new int[AtomCount];
    513   for(int i=AtomCount;i--;)
     507  SortIndex = new int[getAtomCount()];
     508  for(int i=getAtomCount();i--;)
    514509    SortIndex[i] = -1;
    515510
     
    518513
    519514  return true;
     515};
     516
     517
     518
     519/** Creates a lookup table for true father's Atom::Nr -> atom ptr.
     520 * \param *start begin of list (STL iterator, i.e. first item)
     521 * \paran *end end of list (STL iterator, i.e. one past last item)
     522 * \param **Lookuptable pointer to return allocated lookup table (should be NULL on start)
     523 * \param count optional predetermined size for table (otherwise we set the count to highest true father id)
     524 * \return true - success, false - failure
     525 */
     526bool molecule::CreateFatherLookupTable(atom **&LookupTable, int count)
     527{
     528  bool status = true;
     529  int AtomNo;
     530
     531  if (LookupTable != NULL) {
     532    Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl;
     533    return false;
     534  }
     535
     536  // count them
     537  if (count == 0) {
     538    for (molecule::iterator iter = begin(); iter != end(); ++iter) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron
     539      count = (count < (*iter)->GetTrueFather()->nr) ? (*iter)->GetTrueFather()->nr : count;
     540    }
     541  }
     542  if (count <= 0) {
     543    Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl;
     544    return false;
     545  }
     546
     547  // allocate and fill
     548  LookupTable = new atom *[count];
     549  if (LookupTable == NULL) {
     550    eLog() << Verbose(0) << "LookupTable memory allocation failed!" << endl;
     551    performCriticalExit();
     552    status = false;
     553  } else {
     554    for (int i=0;i<count;i++)
     555      LookupTable[i] = NULL;
     556    for (molecule::iterator iter = begin(); iter != end(); ++iter) {
     557      AtomNo = (*iter)->GetTrueFather()->nr;
     558      if ((AtomNo >= 0) && (AtomNo < count)) {
     559        //*out << "Setting LookupTable[" << AtomNo << "] to " << *(*iter) << endl;
     560        LookupTable[AtomNo] = (*iter);
     561      } else {
     562        Log() << Verbose(0) << "Walker " << *(*iter) << " exceeded range of nuclear ids [0, " << count << ")." << endl;
     563        status = false;
     564        break;
     565      }
     566    }
     567  }
     568
     569  return status;
    520570};
    521571
     
    541591{
    542592  MoleculeListClass *BondFragments = NULL;
    543   int *MinimumRingSize = new int[AtomCount];
     593  int *MinimumRingSize = new int[getAtomCount()];
    544594  int FragmentCounter;
    545595  MoleculeLeafClass *MolecularWalker = NULL;
     
    569619
    570620  // create lookup table for Atom::nr
    571   FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(start, end, ListOfAtoms, AtomCount);
     621  FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(ListOfAtoms, getAtomCount());
    572622
    573623  // === compare it with adjacency file ===
     
    579629
    580630  // analysis of the cycles (print rings, get minimum cycle length) for each subgraph
    581   for(int i=AtomCount;i--;)
    582     MinimumRingSize[i] = AtomCount;
     631  for(int i=getAtomCount();i--;)
     632    MinimumRingSize[i] = getAtomCount();
    583633  MolecularWalker = Subgraphs;
    584634  FragmentCounter = 0;
     
    586636    MolecularWalker = MolecularWalker->next;
    587637    // fill the bond structure of the individually stored subgraphs
    588   MolecularWalker->FillBondStructureFromReference(this, FragmentCounter, ListOfLocalAtoms, false);  // we want to keep the created ListOfLocalAtoms
     638    MolecularWalker->FillBondStructureFromReference(this, FragmentCounter, ListOfLocalAtoms, false);  // we want to keep the created ListOfLocalAtoms
    589639    DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    590640    LocalBackEdgeStack = new StackClass<bond *> (MolecularWalker->Leaf->BondCount);
    591641//    // check the list of local atoms for debugging
    592642//    Log() << Verbose(0) << "ListOfLocalAtoms for this subgraph is:" << endl;
    593 //    for (int i=0;i<AtomCount;i++)
     643//    for (int i=0;i<getAtomCount();i++)
    594644//      if (ListOfLocalAtoms[FragmentCounter][i] == NULL)
    595645//        Log() << Verbose(0) << "\tNULL";
     
    617667  // ===== 6b. prepare and go into the adaptive (Order<0), single-step (Order==0) or incremental (Order>0) cycle
    618668  KeyStack *RootStack = new KeyStack[Subgraphs->next->Count()];
    619   AtomMask = new bool[AtomCount+1];
    620   AtomMask[AtomCount] = false;
     669  AtomMask = new bool[getAtomCount()+1];
     670  AtomMask[getAtomCount()] = false;
    621671  FragmentationToDo = false;  // if CheckOrderAtSite just ones recommends fragmentation, we will save fragments afterwards
    622672  while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, configuration->configpath))) {
    623673    FragmentationToDo = FragmentationToDo || CheckOrder;
    624     AtomMask[AtomCount] = true;   // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite()
     674    AtomMask[getAtomCount()] = true;   // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite()
    625675    // ===== 6b. fill RootStack for each subgraph (second adaptivity check) =====
    626676    Subgraphs->next->FillRootStackForSubgraphs(RootStack, AtomMask, (FragmentCounter = 0));
     
    762812bool molecule::ParseOrderAtSiteFromFile(char *path)
    763813{
    764   unsigned char *OrderArray = new unsigned char[AtomCount];
    765   bool *MaxArray = new bool[AtomCount];
     814  unsigned char *OrderArray = new unsigned char[getAtomCount()];
     815  bool *MaxArray = new bool[getAtomCount()];
    766816  bool status;
    767817  int AtomNr, value;
     
    769819  ifstream file;
    770820
    771   for(int i=0;i<AtomCount;i++) {
     821  for(int i=0;i<getAtomCount();i++) {
    772822    OrderArray[i] = 0;
    773823    MaxArray[i] = false;
     
    871921  atom *OtherFather = NULL;
    872922  atom *FatherOfRunner = NULL;
    873   Leaf->CountAtoms();
    874 
    875   atom *Runner = Leaf->start;
    876   while (Runner->next != Leaf->end) {
    877     Runner = Runner->next;
     923
     924#ifdef ADDHYDROGEN
     925  molecule::const_iterator runner;
     926#endif
     927  // we increment the iter just before skipping the hydrogen
     928  for (molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end();) {
    878929    LonelyFlag = true;
    879     FatherOfRunner = Runner->father;
     930    FatherOfRunner = (*iter)->father;
     931    ASSERT(FatherOfRunner,"Atom without father found");
    880932    if (SonList[FatherOfRunner->nr] != NULL)  {  // check if this, our father, is present in list
    881933      // create all bonds
     
    888940//            Log() << Verbose(3) << "Adding Bond: ";
    889941//            Log() << Verbose(0) <<
    890             Leaf->AddBond(Runner, SonList[OtherFather->nr], (*BondRunner)->BondDegree);
     942            Leaf->AddBond((*iter), SonList[OtherFather->nr], (*BondRunner)->BondDegree);
    891943//            Log() << Verbose(0) << "." << endl;
    892             //NumBonds[Runner->nr]++;
     944            //NumBonds[(*iter)->nr]++;
    893945          } else {
    894946//            Log() << Verbose(3) << "Not adding bond, labels in wrong order." << endl;
     
    898950//          Log() << Verbose(0) << ", who has no son in this fragment molecule." << endl;
    899951#ifdef ADDHYDROGEN
    900           //Log() << Verbose(3) << "Adding Hydrogen to " << Runner->Name << " and a bond in between." << endl;
    901           if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), Runner, FatherOfRunner, OtherFather, IsAngstroem))
     952          //Log() << Verbose(3) << "Adding Hydrogen to " << (*iter)->Name << " and a bond in between." << endl;
     953          if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), (*iter), FatherOfRunner, OtherFather, IsAngstroem))
    902954            exit(1);
    903955#endif
    904           //NumBonds[Runner->nr] += Binder->BondDegree;
     956          //NumBonds[(*iter)->nr] += Binder->BondDegree;
    905957        }
    906958      }
    907959    } else {
    908       DoeLog(1) && (eLog()<< Verbose(1) << "Son " << Runner->getName() << " has father " << FatherOfRunner->getName() << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl);
    909     }
    910     if ((LonelyFlag) && (Leaf->AtomCount > 1)) {
    911       DoLog(0) && (Log() << Verbose(0) << *Runner << "has got bonds only to hydrogens!" << endl);
    912     }
     960    DoeLog(1) && (eLog()<< Verbose(1) << "Son " << (*iter)->getName() << " has father " << FatherOfRunner->getName() << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl);
     961    }
     962    if ((LonelyFlag) && (Leaf->getAtomCount() > 1)) {
     963      DoLog(0) && (Log() << Verbose(0) << **iter << "has got bonds only to hydrogens!" << endl);
     964    }
     965    ++iter;
    913966#ifdef ADDHYDROGEN
    914     while ((Runner->next != Leaf->end) && (Runner->next->type->Z == 1)) // skip added hydrogen
    915       Runner = Runner->next;
     967    while ((iter != Leaf->end()) && ((*iter)->type->Z == 1)){ // skip added hydrogen
     968      iter++;
     969    }
    916970#endif
    917971  }
     
    928982molecule * molecule::StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem)
    929983{
    930   atom **SonList = new atom*[AtomCount];
     984  atom **SonList = new atom*[getAtomCount()];
    931985  molecule *Leaf = World::getInstance().createMolecule();
    932986
    933   for(int i=0;i<AtomCount;i++)
     987  for(int i=0;i<getAtomCount();i++)
    934988    SonList[i] = NULL;
    935989
     
    15611615  FragmentSearch.FragmentSet = new KeySet;
    15621616  FragmentSearch.Root = FindAtom(RootKeyNr);
    1563   FragmentSearch.ShortestPathList = new int[AtomCount];
    1564   for (int i=AtomCount;i--;) {
     1617  FragmentSearch.ShortestPathList = new int[getAtomCount()];
     1618  for (int i=getAtomCount();i--;) {
    15651619    FragmentSearch.ShortestPathList[i] = -1;
    15661620  }
    15671621
    15681622  // Construct the complete KeySet which we need for topmost level only (but for all Roots)
    1569   atom *Walker = start;
    15701623  KeySet CompleteMolecule;
    1571   while (Walker->next != end) {
    1572     Walker = Walker->next;
    1573     CompleteMolecule.insert(Walker->GetTrueFather()->nr);
     1624  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     1625    CompleteMolecule.insert((*iter)->GetTrueFather()->nr);
    15741626  }
    15751627
     
    15821634    RootKeyNr = RootStack.front();
    15831635    RootStack.pop_front();
    1584     Walker = FindAtom(RootKeyNr);
     1636    atom *Walker = FindAtom(RootKeyNr);
    15851637    // check cyclic lengths
    15861638    //if ((MinimumRingSize[Walker->GetTrueFather()->nr] != -1) && (Walker->GetTrueFather()->AdaptiveOrder+1 > MinimumRingSize[Walker->GetTrueFather()->nr])) {
     
    16711723  Vector Translationvector;
    16721724  //class StackClass<atom *> *CompStack = NULL;
    1673   class StackClass<atom *> *AtomStack = new StackClass<atom *>(AtomCount);
     1725  class StackClass<atom *> *AtomStack = new StackClass<atom *>(getAtomCount());
    16741726  bool flag = true;
    16751727
    16761728  DoLog(2) && (Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl);
    16771729
    1678   ColorList = new enum Shading[AtomCount];
    1679   for (int i=0;i<AtomCount;i++)
     1730  ColorList = new enum Shading[getAtomCount()];
     1731  for (int i=0;i<getAtomCount();i++)
    16801732    ColorList[i] = (enum Shading)0;
    16811733  while (flag) {
    16821734    // remove bonds that are beyond bonddistance
    1683     for(int i=NDIM;i--;)
    1684       Translationvector[i] = 0.;
     1735    Translationvector.Zero();
    16851736    // scan all bonds
    16861737    Binder = first;
     
    17111762      Log() << Verbose(0) << Translationvector <<  endl;
    17121763      // apply to all atoms of first component via BFS
    1713       for (int i=AtomCount;i--;)
     1764      for (int i=getAtomCount();i--;)
    17141765        ColorList[i] = white;
    17151766      AtomStack->Push(Binder->leftatom);
     
    17351786    //delete(CompStack);
    17361787  }
    1737 
    17381788  // free allocated space from ReturnFullMatrixforSymmetric()
    17391789  delete(AtomStack);
Note: See TracChangeset for help on using the changeset viewer.