Changeset 29f7c1
- Timestamp:
- Feb 11, 2016, 8:07:50 AM (9 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:
- 951aa6
- Parents:
- c0f2fc
- git-author:
- Frederik Heber <heber@…> (12/29/15 19:49:43)
- git-committer:
- Frederik Heber <heber@…> (02/11/16 08:07:50)
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule.cpp
rc0f2fc r29f7c1 92 92 ActiveFlag(false), 93 93 IndexNr(-1), 94 NoNonHydrogen( this,boost::bind(&molecule::doCountNoNonHydrogen,this),"NoNonHydrogen"),95 BondCount( this,boost::bind(&molecule::doCountBonds,this),"BondCount"),94 NoNonHydrogen(0), 95 BondCount(0), 96 96 atomIdPool(1, 20, 100), 97 97 BoundingBoxSweepingAxis(std::vector<AtomDistanceMap_t>(NDIM)), … … 153 153 int molecule::getAtomCount() const{ 154 154 return atomIds.size(); 155 }156 157 size_t molecule::getNoNonHydrogen() const{158 return *NoNonHydrogen;159 }160 161 int molecule::getBondCount() const{162 return *BondCount;163 155 } 164 156 … … 293 285 } 294 286 NOTIFY(FormulaChanged); 295 formula-=_atom->getType();296 287 _atom->removeFromMolecule(); 297 288 return iter; … … 330 321 setAtomName(key); 331 322 NOTIFY(FormulaChanged); 332 formula+=key->getType();333 323 return res; 334 324 } else { … … 1172 1162 OBSERVE; 1173 1163 NOTIFY(FormulaChanged); 1174 resetFormula(); 1164 const ElementPerAtom_t::iterator iter = ElementPerAtom.find(_lastchangedatomid); 1165 ASSERT( iter != ElementPerAtom.end(), 1166 "molecule::recieveNotification() - atom " 1167 +toString(_atom->getId()+" is not contained in ElementsPerAtom.")); 1168 formula -= iter->second; 1169 if (iter->second == (atomicNumber_t)1) // was a hydrogen ? 1170 --NoNonHydrogen; 1171 iter->second = _atom->getElementNo(); 1172 formula += iter->second; 1173 if (iter->second == (atomicNumber_t)1) // is a hydrogen ? 1174 ++NoNonHydrogen; 1175 1175 break; 1176 } 1177 case AtomObservable::BondsAdded: 1178 case AtomObservable::BondsRemoved: 1179 { 1180 // emit others about one of our atoms moved 1181 _lastchangedatomid = _atom->getId(); 1182 const BondCountsPerAtom_t::iterator iter = BondCountsPerAtom.find(_lastchangedatomid); 1183 ASSERT( iter != BondCountsPerAtom.end(), 1184 "molecule::recieveNotification() - atom " 1185 +toString(_atom->getId()+" is not contained in BondCountsPerAtom.")); 1186 BondCount -= iter->second; 1187 iter->second = _atom->getListOfBonds().size(); 1188 BondCount += iter->second; 1189 break; 1176 1190 } 1177 1191 default: … … 1216 1230 _atom->signOn(this, AtomObservable::PositionChanged); 1217 1231 _atom->signOn(this, AtomObservable::ElementChanged); 1232 _atom->signOn(this, AtomObservable::BondsAdded); 1233 _atom->signOn(this, AtomObservable::BondsRemoved); 1218 1234 insert(_atom); 1235 { 1236 const size_t atom_bondcount = _atom->getListOfBonds().size(); 1237 #ifndef NDEBUG 1238 const std::pair<BondCountsPerAtom_t::iterator, bool> inserter = 1239 #endif 1240 BondCountsPerAtom.insert( std::make_pair(_atom->getId(), atom_bondcount) ); 1241 ASSERT( inserter.second, 1242 "molecule::associateAtomWithMolecule() - atom " 1243 +toString(_atom->getId()+" already in BondCountsPerAtom.")); 1244 BondCount += atom_bondcount; 1245 } 1246 { 1247 const int atom_elementno = _atom->getElementNo(); 1248 #ifndef NDEBUG 1249 const std::pair<ElementPerAtom_t::iterator, bool> inserter = 1250 #endif 1251 ElementPerAtom.insert( std::make_pair(_atom->getId(), atom_elementno) ); 1252 ASSERT( inserter.second, 1253 "molecule::associateAtomWithMolecule() - atom " 1254 +toString(_atom->getId()+" already in ElementPerAtom.")); 1255 formula += atom_elementno; 1256 } 1219 1257 } 1220 1258 … … 1223 1261 _atom->signOff(this, AtomObservable::PositionChanged); 1224 1262 _atom->signOff(this, AtomObservable::ElementChanged); 1263 _atom->signOff(this, AtomObservable::BondsAdded); 1264 _atom->signOff(this, AtomObservable::BondsRemoved); 1225 1265 erase(_atom); 1266 { 1267 const BondCountsPerAtom_t::iterator iter = BondCountsPerAtom.find(_atom->getId()); 1268 ASSERT( iter != BondCountsPerAtom.end(), 1269 "molecule::disassociateAtomWithMolecule() - atom " 1270 +toString(_atom->getId()+" is not contained in BondCountsPerAtom.")); 1271 BondCount -= iter->second; 1272 BondCountsPerAtom.erase(iter); 1273 } 1274 { 1275 const ElementPerAtom_t::iterator iter = ElementPerAtom.find(_atom->getId()); 1276 ASSERT( iter != ElementPerAtom.end(), 1277 "molecule::disassociateAtomWithMolecule() - atom " 1278 +toString(_atom->getId()+" is not contained in ElementPerAtom.")); 1279 formula -= iter->second; 1280 ElementPerAtom.erase(iter); 1281 } 1226 1282 } 1227 1283 -
src/molecule.hpp
rc0f2fc r29f7c1 94 94 private: 95 95 Formula formula; 96 Cacheable<size_t>NoNonHydrogen; //!< number of non-hydrogen atoms in molecule97 Cacheable<int>BondCount; //!< number of atoms, brought up-to-date by doCountBonds()96 size_t NoNonHydrogen; //!< number of non-hydrogen atoms in molecule 97 int BondCount; //!< number of atoms, brought up-to-date by doCountBonds() 98 98 moleculeId_t id; 99 99 AtomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms … … 136 136 int getAtomCount() const; 137 137 size_t doCountNoNonHydrogen() const; 138 size_t getNoNonHydrogen() const;139 int getBondCount() const;140 138 int doCountBonds() const; 139 size_t getNoNonHydrogen() const{ 140 return NoNonHydrogen; 141 } 142 143 int getBondCount() const{ 144 return BondCount; 145 } 141 146 moleculeId_t getId() const; 142 147 void setId(moleculeId_t); … … 357 362 > AtomDistanceMap_t; 358 363 std::vector<AtomDistanceMap_t> BoundingBoxSweepingAxis; 364 365 //!> typedef for a map with current bond counts per atom 366 typedef std::map<atomId_t, size_t> BondCountsPerAtom_t; 367 368 //!> current bond counts per atom to update the BondCount 369 BondCountsPerAtom_t BondCountsPerAtom; 370 371 //!> typedef for a map with current element per atom 372 typedef std::map<atomId_t, atomicNumber_t> ElementPerAtom_t; 373 374 //!> current element per atom to update the BondCount 375 ElementPerAtom_t ElementPerAtom; 359 376 360 377 //!> make setMolecule friend to access associateAtomWithMolecule()
Note:
See TracChangeset
for help on using the changeset viewer.