Changeset 458c31
- Timestamp:
- Mar 1, 2011, 10:16:39 AM (14 years ago)
- 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:
- 4b5cf8
- Parents:
- d4a44c
- git-author:
- Frederik Heber <heber@…> (02/21/11 13:02:57)
- git-committer:
- Frederik Heber <heber@…> (03/01/11 10:16:39)
- Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FragmentationAction/SubgraphDissectionAction.cpp
rd4a44c r458c31 74 74 // 0b. remove all bonds and construct a molecule with all atoms 75 75 molecule *mol = World::getInstance().createMolecule(); 76 int BondCount = 0;77 76 { 78 77 vector <atom *> allatoms = World::getInstance().getAllAtoms(); 79 78 for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) { 80 const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds(); 81 BondCount += ListOfBonds.size(); 79 // const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds(); 82 80 // for(BondList::iterator BondRunner = ListOfBonds.begin(); 83 81 // !ListOfBonds.empty(); … … 90 88 91 89 // 1. create the bond structure of the single molecule 92 if ( BondCount== 0) {90 if (mol->getBondCount() == 0) { 93 91 BondGraph *BG = World::getInstance().getBondGraph(); 94 92 if (!BG->CreateAdjacencyForMolecule(mol)) { -
src/molecule.cpp
rd4a44c r458c31 56 56 molecule::molecule(const periodentafel * const teil) : 57 57 Observable("molecule"), 58 elemente(teil), MDSteps(0), BondCount(0), NoNonHydrogen(0), NoNonBonds(0), 59 NoCyclicBonds(0), ActiveFlag(false), IndexNr(-1), 60 AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0) 58 elemente(teil), 59 MDSteps(0), 60 NoNonHydrogen(0), 61 NoNonBonds(0), 62 NoCyclicBonds(0), 63 ActiveFlag(false), 64 IndexNr(-1), 65 AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), 66 BondCount(this,boost::bind(&molecule::doCountBonds,this),"BondCount"), 67 last_atom(0) 61 68 { 62 69 … … 88 95 int molecule::getAtomCount() const{ 89 96 return *AtomCount; 97 } 98 99 int molecule::getBondCount() const{ 100 return *BondCount; 90 101 } 91 102 … … 729 740 ASSERT(FindAtom(atom2->getNr()),"Second atom in bond-creation was not part of molecule"); 730 741 731 Binder = new bond(atom1, atom2, degree, BondCount++);742 Binder = new bond(atom1, atom2, degree, getBondCount()); 732 743 atom1->RegisterBond(WorldTime::getTime(), Binder); 733 744 atom2->RegisterBond(WorldTime::getTime(), Binder); … … 998 1009 return res; 999 1010 }; 1011 1012 /** Counts the number of present bonds. 1013 * \return number of bonds 1014 */ 1015 int molecule::doCountBonds() const 1016 { 1017 unsigned int counter = 0; 1018 for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) { 1019 const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds(); 1020 for(BondList::const_iterator BondRunner = ListOfBonds.begin(); 1021 BondRunner != ListOfBonds.end(); 1022 ++BondRunner) 1023 if ((*BondRunner)->leftatom == *AtomRunner) 1024 counter++; 1025 } 1026 return counter; 1027 } 1028 1000 1029 1001 1030 /** Returns an index map for two father-son-molecules. -
src/molecule.hpp
rd4a44c r458c31 98 98 //bond *last; //!< end of bond list 99 99 int MDSteps; //!< The number of MD steps in Trajectories 100 //int AtomCount; //!< number of atoms, brought up-to-date by CountAtoms()101 int BondCount; //!< number of atoms, brought up-to-date by CountBonds()102 100 mutable int NoNonHydrogen; //!< number of non-hydrogen atoms in molecule 103 101 mutable int NoNonBonds; //!< number of non-hydrogen bonds in molecule 104 102 mutable int NoCyclicBonds; //!< number of cyclic bonds in molecule, by DepthFirstSearchAnalysis() 105 //double BondDistance; //!< typical bond distance used in CreateAdjacencyList() and furtheron106 103 bool ActiveFlag; //!< in a MoleculeListClass used to discern active from inactive molecules 107 104 //Vector Center; //!< Center of molecule in a global box … … 111 108 private: 112 109 Formula formula; 113 Cacheable<int> AtomCount; 110 Cacheable<int> AtomCount; //!< number of atoms, brought up-to-date by doCountAtoms() 111 Cacheable<int> BondCount; //!< number of atoms, brought up-to-date by doCountBonds() 114 112 moleculeId_t id; 115 113 atomSet atoms; //<!list of atoms … … 131 129 int getAtomCount() const; 132 130 int doCountAtoms(); 131 int getBondCount() const; 132 int doCountBonds() const; 133 133 moleculeId_t getId() const; 134 134 void setId(moleculeId_t); … … 169 169 bool RemoveBonds(atom *BondPartner); 170 170 bool hasBondStructure() const; 171 unsigned int CountBonds() const;172 171 173 172 /// Find atoms. -
src/molecule_graph.cpp
rd4a44c r458c31 149 149 delete((*BondRunner)); 150 150 } 151 BondCount = 0;152 151 153 152 // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering) … … 214 213 } 215 214 delete (LC); 216 DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount<< " bonds in the molecule." << endl);215 DoLog(1) && (Log() << Verbose(1) << "I detected " << getBondCount() << " bonds in the molecule." << endl); 217 216 218 217 // correct bond degree by comparing valence and bond degree … … 242 241 } 243 242 return false; 244 }245 246 /** Counts the number of present bonds.247 * \return number of bonds248 */249 unsigned int molecule::CountBonds() const250 {251 unsigned int counter = 0;252 for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {253 const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();254 for(BondList::const_iterator BondRunner = ListOfBonds.begin();255 BondRunner != ListOfBonds.end();256 ++BondRunner)257 if ((*BondRunner)->leftatom == *AtomRunner)258 counter++;259 }260 return counter;261 243 } 262 244 … … 290 272 int No = 0, OldNo = -1; 291 273 292 if ( BondCount!= 0) {274 if (getBondCount() != 0) { 293 275 DoLog(1) && (Log() << Verbose(1) << "Correcting Bond degree of each bond ... " << endl); 294 276 do { … … 301 283 DoLog(0) && (Log() << Verbose(0) << " done." << endl); 302 284 } else { 303 DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount<< ", no bonds between any of the " << getAtomCount() << " atoms." << endl);285 DoLog(1) && (Log() << Verbose(1) << "BondCount is " << getBondCount() << ", no bonds between any of the " << getAtomCount() << " atoms." << endl); 304 286 } 305 287 DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl); … … 561 543 { 562 544 struct DFSAccounting DFS; 563 BackEdgeStack = new std::deque<bond *> ( BondCount);545 BackEdgeStack = new std::deque<bond *> (getBondCount()); 564 546 DFS.BackEdgeStack = BackEdgeStack; 565 547 MoleculeLeafClass *SubGraphs = new MoleculeLeafClass(NULL); -
src/unittests/ListOfBondsUnitTest.cpp
rd4a44c r458c31 227 227 // check if removed from molecule 228 228 CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() ); 229 CPPUNIT_ASSERT_EQUAL( ( unsigned int)1, TestMolecule->CountBonds() );229 CPPUNIT_ASSERT_EQUAL( (int)1, TestMolecule->getBondCount() ); 230 230 }; 231 231
Note:
See TracChangeset
for help on using the changeset viewer.