Ignore:
Timestamp:
May 31, 2010, 5:32:27 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:
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_graph.cpp

    r42af9e r1024cb  
    2020#include "World.hpp"
    2121#include "Helpers/fast_functions.hpp"
     22#include "Helpers/Assert.hpp"
     23
    2224
    2325struct BFSAccounting
     
    8082      flip(atom1, atom2);
    8183    Walker = FindAtom(atom1);
     84    ASSERT(Walker,"Could not find an atom with the ID given in dbond file");
    8285    OtherWalker = FindAtom(atom2);
     86    ASSERT(OtherWalker,"Could not find an atom with the ID given in dbond file");
    8387    AddBond(Walker, OtherWalker); //Add the bond between the two atoms with respective indices.
    8488  }
     
    109113  atom *Walker = NULL;
    110114  atom *OtherWalker = NULL;
    111   atom **AtomMap = NULL;
    112115  int n[NDIM];
    113116  double MinDistance, MaxDistance;
     
    134137
    135138  // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering)
    136   CountAtoms();
    137   DoLog(1) && (Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl);
    138 
    139   if ((AtomCount > 1) && (bonddistance > 1.)) {
     139  DoLog(1) && (Log() << Verbose(1) << "AtomCount " << getAtomCount() << " and bonddistance is " << bonddistance << "." << endl);
     140
     141  if ((getAtomCount() > 1) && (bonddistance > 1.)) {
    140142    DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl);
    141143    LC = new LinkedCell(this, bonddistance);
     
    143145    // create a list to map Tesselpoint::nr to atom *
    144146    DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl);
    145     AtomMap = new atom *[AtomCount];
    146     for (int i=0;i<AtomCount;i++)
    147       AtomMap[i] = NULL;
    148     Walker = start;
    149     while (Walker->next != end) {
    150       Walker = Walker->next;
    151       AtomMap[Walker->nr] = Walker;
     147
     148    // set numbers for atoms that can later be used
     149    int i=0;
     150    for(internal_iterator iter = atoms.begin();iter!= atoms.end(); ++iter){
     151      (*iter)->nr = i++;
    152152    }
    153153
     
    161161          if (List != NULL) {
    162162            for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    163               Walker = AtomMap[(*Runner)->nr];
    164 //              Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
     163              Walker = dynamic_cast<atom*>(*Runner);
     164              ASSERT(Walker,"Tesselpoint that was not an atom retrieved from LinkedNode");
     165              //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
    165166              // 3c. check for possible bond between each atom in this and every one in the 27 cells
    166167              for (n[0] = -1; n[0] <= 1; n[0]++)
     
    172173                      for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
    173174                        if ((*OtherRunner)->nr > Walker->nr) {
    174                           OtherWalker = AtomMap[(*OtherRunner)->nr];
    175 //                          Log() << Verbose(0) << "Current other Atom is " << *OtherWalker << "." << endl;
    176                           const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x, cell_size);
    177 //                          Log() << Verbose(1) << "Checking distance " << distance << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
     175                          OtherWalker = dynamic_cast<atom*>(*OtherRunner);
     176                          ASSERT(OtherWalker,"TesselPoint that was not an atom retrieved from LinkedNode");
     177                          //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
    178178                          (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
     179                          const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x,cell_size);
    179180                          const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance);
    180181//                          Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl;
     
    196197          }
    197198        }
    198     delete[](AtomMap);
    199199    delete (LC);
    200200    DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl);
     
    207207    ActOnAllAtoms( &atom::OutputBondOfAtom );
    208208  } else
    209     DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl);
     209    DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << getAtomCount() << ", thus no bonds, no connections!." << endl);
    210210  DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl);
    211211  if (free_BG)
     
    249249    DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    250250  } else {
    251     DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl);
     251    DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << getAtomCount() << " atoms." << endl);
    252252  }
    253253  DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl);
     
    469469void DepthFirstSearchAnalysis_Init(struct DFSAccounting &DFS, const molecule * const mol)
    470470{
    471   DFS.AtomStack = new StackClass<atom *> (mol->AtomCount);
     471  DFS.AtomStack = new StackClass<atom *> (mol->getAtomCount());
    472472  DFS.CurrentGraphNr = 0;
    473473  DFS.ComponentNumber = 0;
     
    510510  bond *Binder = NULL;
    511511
    512   if (AtomCount == 0)
     512  if (getAtomCount() == 0)
    513513    return SubGraphs;
    514514  DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl);
    515515  DepthFirstSearchAnalysis_Init(DFS, this);
    516516
    517   DFS.Root = start->next;
    518   while (DFS.Root != end) { // if there any atoms at all
     517  for (molecule::const_iterator iter = begin(); iter != end();) {
     518    DFS.Root = *iter;
    519519    // (1) mark all edges unused, empty stack, set atom->GraphNr = -1 for all
    520520    DFS.AtomStack->ClearStack();
     
    556556
    557557    // step on to next root
    558     while ((DFS.Root != end) && (DFS.Root->GraphNr != -1)) {
    559       //Log() << Verbose(1) << "Current next subgraph root candidate is " << Root->Name << "." << endl;
    560       if (DFS.Root->GraphNr != -1) // if already discovered, step on
    561         DFS.Root = DFS.Root->next;
     558    while ((iter != end()) && ((*iter)->GraphNr != -1)) {
     559      //Log() << Verbose(1) << "Current next subgraph root candidate is " << (*iter)->Name << "." << endl;
     560      if ((*iter)->GraphNr != -1) // if already discovered, step on
     561        iter++;
    562562    }
    563563  }
     
    864864  if (MinRingSize != -1) { // if rings are present
    865865    // go over all atoms
    866     Root = mol->start;
    867     while (Root->next != mol->end) {
    868       Root = Root->next;
    869 
    870       if (MinimumRingSize[Root->GetTrueFather()->nr] == mol->AtomCount) { // check whether MinimumRingSize is set, if not BFS to next where it is
     866    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     867      Root = *iter;
     868
     869      if (MinimumRingSize[Root->GetTrueFather()->nr] == mol->getAtomCount()) { // check whether MinimumRingSize is set, if not BFS to next where it is
    871870        Walker = Root;
    872871
    873872        //Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl;
    874         CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol->AtomCount);
     873        CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol->getAtomCount());
    875874
    876875      }
     
    902901  int MinRingSize = -1;
    903902
    904   InitializeBFSAccounting(BFS, AtomCount);
     903  InitializeBFSAccounting(BFS, getAtomCount());
    905904
    906905  //Log() << Verbose(1) << "Back edge list - ";
     
    11451144    CurrentBondsOfAtom = -1; // we count one too far due to line end
    11461145    // parse into structure
    1147     if ((AtomNr >= 0) && (AtomNr < AtomCount)) {
     1146    if ((AtomNr >= 0) && (AtomNr < getAtomCount())) {
    11481147      Walker = ListOfAtoms[AtomNr];
    11491148      while (!line.eof())
     
    13241323    AddedAtomList[Root->nr] = Mol->AddCopyAtom(Root);
    13251324
    1326   BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, AtomCount, AddedAtomList);
     1325  BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, getAtomCount(), AddedAtomList);
    13271326
    13281327  // and go on ... Queue always contains all lightgray vertices
     
    13821381  // fill parent list with sons
    13831382  DoLog(3) && (Log() << Verbose(3) << "Filling Parent List." << endl);
    1384   atom *Walker = mol->start;
    1385   while (Walker->next != mol->end) {
    1386     Walker = Walker->next;
    1387     ParentList[Walker->father->nr] = Walker;
     1383  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1384    ParentList[(*iter)->father->nr] = (*iter);
    13881385    // Outputting List for debugging
    1389     DoLog(4) && (Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl);
    1390   }
    1391 
    1392 }
    1393 ;
     1386    DoLog(4) && (Log() << Verbose(4) << "Son[" << (*iter)->father->nr << "] of " << (*iter)->father << " is " << ParentList[(*iter)->father->nr] << "." << endl);
     1387  }
     1388};
    13941389
    13951390void BuildInducedSubgraph_Finalize(atom **&ParentList)
     
    14021397{
    14031398  bool status = true;
    1404   atom *Walker = NULL;
    14051399  atom *OtherAtom = NULL;
    14061400  // check each entry of parent list and if ok (one-to-and-onto matching) create bonds
    14071401  DoLog(3) && (Log() << Verbose(3) << "Creating bonds." << endl);
    1408   Walker = Father->start;
    1409   while (Walker->next != Father->end) {
    1410     Walker = Walker->next;
    1411     if (ParentList[Walker->nr] != NULL) {
    1412       if (ParentList[Walker->nr]->father != Walker) {
     1402  for (molecule::const_iterator iter = Father->begin(); iter != Father->end(); ++iter) {
     1403    if (ParentList[(*iter)->nr] != NULL) {
     1404      if (ParentList[(*iter)->nr]->father != (*iter)) {
    14131405        status = false;
    14141406      } else {
    1415         for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    1416           OtherAtom = (*Runner)->GetOtherAtom(Walker);
     1407        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     1408          OtherAtom = (*Runner)->GetOtherAtom((*iter));
    14171409          if (ParentList[OtherAtom->nr] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond
    1418             DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[Walker->nr]->getName() << " and " << ParentList[OtherAtom->nr]->getName() << "." << endl);
    1419             mol->AddBond(ParentList[Walker->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);
     1410            DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[(*iter)->nr]->getName() << " and " << ParentList[OtherAtom->nr]->getName() << "." << endl);
     1411            mol->AddBond(ParentList[(*iter)->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);
    14201412          }
    14211413        }
     
    14401432  bool status = true;
    14411433  atom **ParentList = NULL;
    1442 
    14431434  DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl);
    1444   BuildInducedSubgraph_Init(ParentList, Father->AtomCount);
     1435  BuildInducedSubgraph_Init(ParentList, Father->getAtomCount());
    14451436  BuildInducedSubgraph_FillParentList(this, Father, ParentList);
    14461437  status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList);
Note: See TracChangeset for help on using the changeset viewer.