- Timestamp:
- Feb 17, 2012, 3:24:18 PM (13 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:
- cdaae6
- Parents:
- ac5c36
- git-author:
- Frederik Heber <heber@…> (01/06/12 16:49:11)
- git-committer:
- Frederik Heber <heber@…> (02/17/12 15:24:18)
- Location:
- src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Atom/AtomicInfo.cpp
rac5c36 r560bbe 35 35 FatherId(0), 36 36 MolId(0), 37 Id(0) 37 Id(0), 38 Nr(0) 38 39 {} 39 40 AtomicInfo::AtomicInfo(const atom &_atom) : … … 43 44 FatherId(_atom.father->getId()), 44 45 MolId(_atom.getMolecule()->getId()), 45 Id(_atom.getId()) 46 Id(_atom.getId()), 47 Nr(_atom.getNr()) 46 48 {} 47 49 … … 72 74 if (_mol != NULL) 73 75 _atom.setMolecule(_mol); // this is ok, mol is const within AtomicInfo, but not outside (atoms need to register) 76 _atom.changeNr(Nr); 74 77 75 78 return status; … … 90 93 Velocity = AI.Velocity; 91 94 Id = AI.Id; 95 Nr = AI.Nr; 92 96 return *this; 93 97 } -
src/Atom/AtomicInfo.hpp
rac5c36 r560bbe 41 41 moleculeId_t MolId; 42 42 atomId_t Id; 43 int Nr; 43 44 }; 44 45 -
src/Atom/atom.cpp
rac5c36 r560bbe 322 322 } 323 323 324 bool atom::changeNr(const int newNr) 325 { 326 if ((mol) && (mol->changeAtomNr(getNr(),newNr,this))) { 327 return true; 328 } else{ 329 return false; 330 } 331 } 332 324 333 int atom::getNr() const{ 325 334 return ParticleInfo::getNr(); -
src/Atom/atom.hpp
rac5c36 r560bbe 211 211 */ 212 212 void removeFromMolecule(); 213 214 /** Changes the molecule internal ParticleInfo::Nr of this atom. 215 * 216 * @param newNr new ParticleInfo::Nr to set 217 * @return true - change successful, false - changed not successful, id remains the old one 218 */ 219 bool changeNr(int newNr); 213 220 214 221 /** Getter for ParticleInfo::Nr of the atom. -
src/documentation/constructs/molecules.dox
rac5c36 r560bbe 29 29 * as well. 30 30 * 31 * \section molecules-atoms Atoms 32 * 33 * Atoms are added to the molecule via molecule::AddAtom() and removed via 34 * molecule::RemoveAtom(). Therein, the atom receives a unique ParticleInfo::Nr 35 * that is useful only within the molecule and is displayed in the atoms name, 36 * i.e. atom names only vary within the molecule. 37 * 38 * The molecule only stores the atoms global id and uses a boost::transform_iterator 39 * to map the ids to the true refs obtained from the World. 40 * 31 41 * \section molecules-formula Formula 32 42 * -
src/molecule.cpp
rac5c36 r560bbe 25 25 #include <gsl/gsl_inline.h> 26 26 #include <gsl/gsl_heapsort.h> 27 28 #include "molecule.hpp" 27 29 28 30 #include "Atom/atom.hpp" … … 32 34 #include "CodePatterns/Log.hpp" 33 35 #include "config.hpp" 36 #include "Descriptors/AtomIdDescriptor.hpp" 34 37 #include "Element/element.hpp" 35 38 #include "Element/periodentafel.hpp" … … 41 44 #include "LinearAlgebra/Vector.hpp" 42 45 #include "LinkedCell/linkedcell.hpp" 43 #include " molecule.hpp"46 #include "IdPool_impl.hpp" 44 47 #include "Tesselation/tesselation.hpp" 45 48 #include "World.hpp" … … 63 66 AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), 64 67 BondCount(this,boost::bind(&molecule::doCountBonds,this),"BondCount"), 68 atomIdPool(0, 20, 100), 65 69 last_atom(0) 66 70 { … … 103 107 cout << "Set name of molecule " << getId() << " to " << _name << endl; 104 108 strncpy(name,_name.c_str(),MAXSTRINGSIZE); 109 } 110 111 bool molecule::changeAtomNr(int oldNr, int newNr, atom* target){ 112 OBSERVE; 113 if(atomIdPool.reserveId(newNr)){ 114 if (oldNr != -1) // -1 is reserved and indicates no number 115 atomIdPool.releaseId(oldNr); 116 ASSERT (target, 117 "molecule::changeAtomNr() - given target is NULL, cannot set Nr or name."); 118 target->setNr(newNr); 119 setAtomName(target); 120 return true; 121 } else{ 122 return false; 123 } 105 124 } 106 125 … … 197 216 ++iter; 198 217 atomIds.erase( key->getId() ); 218 atomIdPool.releaseId(key->getNr()); 219 key->setNr(-1); 199 220 formula-=key->getType(); 200 221 key->removeFromMolecule(); … … 213 234 pair<atomIdSet::iterator,bool> res = atomIds.insert(key->getId()); 214 235 if (res.second) { // push atom if went well 236 key->setNr(atomIdPool.getNextId()); 237 setAtomName(key); 215 238 formula+=key->getType(); 216 239 return pair<iterator,bool>(iterator(res.first, FromIdToAtom()),res.second); … … 219 242 } 220 243 } 244 245 void molecule::setAtomName(atom *_atom) const 246 { 247 std::stringstream sstr; 248 sstr << _atom->getType()->getSymbol() << _atom->getNr()+1; 249 _atom->setName(sstr.str()); 250 } 251 221 252 222 253 bool molecule::containsAtom(atom* key){ … … 247 278 OBSERVE; 248 279 if (pointer != NULL) { 249 if (pointer->getType() != NULL) { 250 if (pointer->getType()->getAtomicNumber() != 1) 251 NoNonHydrogen++; 252 if(pointer->getName() == "Unknown"){ 253 stringstream sstr; 254 sstr << pointer->getType()->getSymbol() << pointer->getNr()+1; 255 pointer->setName(sstr.str()); 256 } 257 } 280 if (pointer->getType()->getAtomicNumber() != 1) 281 NoNonHydrogen++; 258 282 insert(pointer); 259 283 pointer->setMolecule(this); … … 1029 1053 { 1030 1054 int res = size(); 1031 int i = 0;1032 1055 NoNonHydrogen = 0; 1033 for (molecule::iterator iter = begin(); iter != end(); ++iter) {1034 (*iter)->setNr(i); // update number in molecule (for easier referencing in FragmentMolecule lateron)1056 // go through atoms and look for new ones 1057 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) 1035 1058 if ((*iter)->getType()->getAtomicNumber() != 1) // count non-hydrogen atoms whilst at it 1036 1059 NoNonHydrogen++; 1037 stringstream sstr;1038 sstr << (*iter)->getType()->getSymbol() << (*iter)->getNr()+1;1039 (*iter)->setName(sstr.str());1040 LOG(3, "Naming atom nr. " << (*iter)->getNr() << " " << (*iter)->getName() << ".");1041 i++;1042 }1043 1060 return res; 1044 1061 }; … … 1106 1123 ActiveFlag = !ActiveFlag; 1107 1124 } 1125 1126 // construct idpool 1127 CONSTRUCT_IDPOOL(atomId_t, continuousId) -
src/molecule.hpp
rac5c36 r560bbe 33 33 #include "Formula.hpp" 34 34 #include "Helpers/defs.hpp" 35 #include "IdPool_policy.hpp" 36 #include "IdPool.hpp" 35 37 #include "types.hpp" 36 38 … … 97 99 moleculeId_t id; 98 100 atomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms 101 IdPool<atomId_t, uniqueId> atomIdPool; //!< pool of internal ids such that way may guarantee uniqueness 102 99 103 protected: 100 104 … … 150 154 */ 151 155 const_iterator erase(atom * key); 156 157 private: 158 friend bool atom::changeNr(int newId); 159 /** 160 * used when changing an ParticleInfo::Nr. 161 * Note that this number is local with this molecule. 162 * Unless you are calling this method from inside an atom don't fiddle with the third parameter. 163 * 164 * @param oldNr old Nr 165 * @param newNr new Nr to set 166 * @param *target ref to atom 167 * @return indicates wether the change could be done or not. 168 */ 169 bool changeAtomNr(int oldNr, int newNr, atom* target=0); 170 171 /** Sets the name of the atom. 172 * 173 * The name is set via its element symbol and its internal ParticleInfo::Nr. 174 * 175 * @param _atom atom whose name to set 176 */ 177 void setAtomName(atom *_atom) const; 152 178 153 179 public:
Note:
See TracChangeset
for help on using the changeset viewer.