Changeset 29f7c1 for src/molecule.cpp
- 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)
- File:
-
- 1 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
Note:
See TracChangeset
for help on using the changeset viewer.