Changeset ae38fb


Ignore:
Timestamp:
Nov 3, 2009, 2:34:02 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:
3c349b
Parents:
2aeefd
git-author:
Frederik Heber <heber@…> (11/03/09 14:27:15)
git-committer:
Frederik Heber <heber@…> (11/03/09 14:34:02)
Message:

Fixing not created adjacency list, partially fixing subgraph dissection in config::Load()

  • CreateAdjacencyList() was called with zero bonddistance.
  • this was due to max_distance not being initialised in the constructor to 0 and subsequently not set if Bond Length Table was not found.
  • new function SetMaxDistanceToMaxOfCovalentRadii() which sets the max_distance to twice the max of covalent radii of all elements.
  • config::Load() - atoms in copied molecule (by DepthFirstSearchAnalysis()) are made their own father (and originals are removed).
Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/bondgraph.cpp

    r2aeefd rae38fb  
    1313#include "molecule.hpp"
    1414#include "parser.hpp"
     15#include "periodentafel.hpp"
    1516#include "vector.hpp"
    1617
     
    1819 * This classes contains typical bond lengths and thus may be used to construct a bond graph for a given molecule.
    1920 */
    20 BondGraph::BondGraph(bool IsA) : BondLengthMatrix(NULL), IsAngstroem(IsA)
     21BondGraph::BondGraph(bool IsA) : BondLengthMatrix(NULL), max_distance(0), IsAngstroem(IsA)
    2122{
    2223};
     
    104105};
    105106
     107/** Determines the maximum of all element::CovalentRadius.
     108 * \param *out output stream for debugging
     109 * \param *periode periodentafel with all elements.
     110 */
     111double BondGraph::SetMaxDistanceToMaxOfCovalentRadii(ofstream * const out, const periodentafel * const periode)
     112{
     113  max_distance = 0.;
     114
     115  element * Runner = periode->start;
     116  while (Runner->next != periode->end) {
     117    Runner = Runner->next;
     118    if (Runner->CovalentRadius > max_distance)
     119      max_distance = Runner->CovalentRadius;
     120  }
     121  max_distance *= 2.;
     122
     123  return max_distance;
     124};
     125
    106126/** Returns bond criterion for given pair based on covalent radius.
    107127 * \param *Walker first BondedParticle
  • src/bondgraph.hpp

    r2aeefd rae38fb  
    2323
    2424class molecule;
     25class periodentafel;
    2526class MatrixContainer;
    2627
     
    3738  bool ConstructBondGraph(ofstream * const out, molecule * const mol);
    3839  double GetBondLength(int firstelement, int secondelement);
     40  double SetMaxDistanceToMaxOfCovalentRadii(ofstream * const out, const periodentafel * const periode);
    3941
    4042  void BondLengthMatrixMinMaxDistance(BondedParticle * const Walker, BondedParticle * const OtherWalker, double &MinDistance, double &MaxDistance, bool IsAngstroem);
  • src/builder.cpp

    r2aeefd rae38fb  
    12501250  // translate each to its center and merge all molecules in MoleculeListClass into this molecule
    12511251  int N = molecules->ListOfMolecules.size();
    1252   int *src = new int(N);
     1252  int *src = new int[N];
    12531253  N=0;
    12541254  for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
     
    12571257  }
    12581258  molecules->SimpleMultiAdd(mol, src, N);
    1259   delete(src);
     1259  delete[](src);
    12601260
    12611261  // ... and translate back
  • src/config.cpp

    r2aeefd rae38fb  
    10511051  } else {
    10521052    cout << Verbose(0) << "Bond length table loading failed." << endl;
     1053    BG->SetMaxDistanceToMaxOfCovalentRadii((ofstream *)&cout, periode);
    10531054  }
    10541055
    10551056  // 3. parse the molecule in
    10561057  LoadMolecule(mol, FileBuffer, periode, FastParsing);
    1057   mol->ActiveFlag = true;
    1058   MolList->insert(mol);
     1058  //mol->ActiveFlag = true;
     1059  //MolList->insert(mol);
    10591060
    10601061  // 4. dissect the molecule into connected subgraphs
    10611062  BG->ConstructBondGraph((ofstream *)&cout, mol);
     1063
     1064  // 5. scan for connected subgraphs
     1065  MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
     1066  class StackClass<bond *> *BackEdgeStack = NULL;
     1067  Subgraphs = mol->DepthFirstSearchAnalysis((ofstream *)&cout, BackEdgeStack);
     1068  delete(BackEdgeStack);
     1069
     1070  // 6. dissect
     1071  atom ***ListOfLocalAtoms = NULL;
     1072  int FragmentCounter = 0;
     1073  MoleculeLeafClass *MolecularWalker = Subgraphs;
     1074  atom *Walker = NULL;
     1075  while (MolecularWalker->next != NULL) {
     1076    MolecularWalker = MolecularWalker->next;
     1077    // fill the bond structure of the individually stored subgraphs (goes through whole chained list by itself)
     1078    MolecularWalker->FillBondStructureFromReference((ofstream *)&cout, mol, FragmentCounter, ListOfLocalAtoms, false);  // we don't want to keep the created ListOfLocalAtoms
     1079    FragmentCounter++;
     1080    MolecularWalker->Leaf->ActiveFlag = true;
     1081    Walker = MolecularWalker->Leaf->start;
     1082    while (Walker->next != MolecularWalker->Leaf->end) {
     1083      Walker = Walker->next;
     1084      Walker->father = Walker;
     1085    }
     1086    MolList->insert(MolecularWalker->Leaf);
     1087    MolecularWalker->Leaf = NULL; // don't remove molecule when deleting MolecularWalker
     1088    delete(MolecularWalker->previous);
     1089  }
     1090  delete(MolecularWalker);
     1091  for (int i=0;i<FragmentCounter;i++)
     1092    Free(&ListOfLocalAtoms[i]);
     1093  Free(&ListOfLocalAtoms);
     1094  cout << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl;
     1095
     1096  // 6. free parsed in molecule
     1097  delete(mol);
    10621098
    10631099  delete(FileBuffer);
  • src/molecule_graph.cpp

    r2aeefd rae38fb  
    114114  *out << Verbose(0) << "Begin of CreateAdjacencyList." << endl;
    115115  // remove every bond from the list
    116   if ((first->next != last) && (last->previous != first)) { // there are bonds present
    117     cleanup(first, last);
     116  bond *Binder = NULL;
     117  while (last->previous != first) {
     118    Binder = last->previous;
     119    Binder->leftatom->UnregisterBond(Binder);
     120    Binder->rightatom->UnregisterBond(Binder);
     121    removewithoutcheck(Binder);
    118122  }
    119123
    120124  // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering)
    121125  CountAtoms(out);
    122   *out << Verbose(1) << "AtomCount " << AtomCount << "." << endl;
     126  *out << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl;
    123127
    124128  if ((AtomCount > 1) && (bonddistance > 1.)) {
     129    *out << Verbose(2) << "Creating Linked Cell structure ... " << endl;
    125130    LC = new LinkedCell(this, bonddistance);
    126131
    127132    // create a list to map Tesselpoint::nr to atom *
     133    *out << Verbose(2) << "Creating TesselPoint to atom map ... " << endl;
    128134    AtomMap = Calloc<atom *> (AtomCount, "molecule::CreateAdjacencyList - **AtomCount");
    129135    Walker = start;
     
    134140
    135141    // 3a. go through every cell
     142    *out << Verbose(2) << "Celling ... " << endl;
    136143    for (LC->n[0] = 0; LC->n[0] < LC->N[0]; LC->n[0]++)
    137144      for (LC->n[1] = 0; LC->n[1] < LC->N[1]; LC->n[1]++)
     
    175182
    176183    // correct bond degree by comparing valence and bond degree
     184    *out << Verbose(2) << "Correcting bond degree ... " << endl;
    177185    CorrectBondDegree(out);
    178186
  • src/moleculelist.cpp

    r2aeefd rae38fb  
    1212#include "helpers.hpp"
    1313#include "linkedcell.hpp"
     14#include "lists.hpp"
    1415#include "molecule.hpp"
    1516#include "memoryallocator.hpp"
     
    829830
    830831  if (status) {
    831     *out << Verbose(1) << "Creating adjacency list for subgraph " << this
    832         << "." << endl;
     832    *out << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl;
     833    // remove every bond from the list
     834    bond *Binder = NULL;
     835    while (Leaf->last->previous != Leaf->first) {
     836      Binder = Leaf->last->previous;
     837      Binder->leftatom->UnregisterBond(Binder);
     838      Binder->rightatom->UnregisterBond(Binder);
     839      removewithoutcheck(Binder);
     840    }
     841
    833842    Walker = Leaf->start;
    834843    while (Walker->next != Leaf->end) {
     
    847856      }
    848857    }
    849 //    FragmentCounter++;
    850 //    if (next != NULL)
    851 //      status = next->FillBondStructureFromReference(out, reference, FragmentCounter, ListOfLocalAtoms);
    852 //    FragmentCounter--;
    853858  }
    854859
     
    916921  bool status = true;
    917922
    918   int Counter = Count();
    919923  if (ListOfLocalAtoms == NULL) { // allocated initial pointer
    920924    // allocate and set each field to NULL
     925    const int Counter = Count();
    921926    ListOfLocalAtoms = Calloc<atom**>(Counter, "MoleculeLeafClass::FillListOfLocalAtoms - ***ListOfLocalAtoms");
    922     if (ListOfLocalAtoms != NULL) {
    923       FreeList = FreeList && true;
    924     } else
     927    if (ListOfLocalAtoms == NULL) {
     928      FreeList = FreeList && false;
    925929      status = false;
     930    }
    926931  }
    927932
Note: See TracChangeset for help on using the changeset viewer.