Changeset 97dff0 for src/Fragmentation
- Timestamp:
- Aug 20, 2014, 1:04:08 PM (11 years ago)
- Children:
- 11cc05
- Parents:
- 972412
- git-author:
- Frederik Heber <heber@…> (05/29/14 11:29:27)
- git-committer:
- Frederik Heber <heber@…> (08/20/14 13:04:08)
- Location:
- src/Fragmentation/Exporters
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Exporters/SaturatedFragment.cpp
r972412 r97dff0 54 54 #include "Descriptors/AtomIdDescriptor.hpp" 55 55 #include "Fragmentation/Exporters/HydrogenPool.hpp" 56 #include "Fragmentation/Exporters/SphericalPointDistribution.hpp" 56 57 #include "Fragmentation/HydrogenSaturation_enum.hpp" 57 58 #include "Graph/BondGraph.hpp" … … 165 166 atomiter != CutBonds.end(); ++atomiter) { 166 167 atom * const Walker = atomiter->first; 167 // go through each bond and replace 168 for (BondList::const_iterator bonditer = atomiter->second.begin(); 169 bonditer != atomiter->second.end(); ++bonditer) { 170 atom * const OtherWalker = (*bonditer)->GetOtherAtom(Walker); 171 if (!AddHydrogenReplacementAtom( 172 (*bonditer), 173 Walker, 174 OtherWalker, 175 World::getInstance().getConfig()->IsAngstroem == 1)) 176 exit(1); 177 } 178 } 179 } 168 if (!saturateAtom(Walker, atomiter->second)) 169 exit(1); 170 } 171 } 172 173 bool SaturatedFragment::saturateAtom( 174 atom * const _atom, 175 const BondList &_cutbonds) 176 { 177 // OLD WAY: use AddHydrogenReplacementAtom() on each cut bond 178 // // go through each bond and replace 179 // for (BondList::const_iterator bonditer = _cutbonds.begin(); 180 // bonditer != _cutbonds.end(); ++bonditer) { 181 // atom * const OtherWalker = (*bonditer)->GetOtherAtom(_atom); 182 // if (!AddHydrogenReplacementAtom( 183 // (*bonditer), 184 // _atom, 185 // OtherWalker, 186 // World::getInstance().getConfig()->IsAngstroem == 1)) 187 // return false; 188 // } 189 190 // gather the nodes of the shape defined by the current set of bonded atoms 191 SphericalPointDistribution::Polygon_t Polygon; 192 for (BondList::const_iterator bonditer = _cutbonds.begin(); 193 bonditer != _cutbonds.end(); ++bonditer) { 194 Vector DistanceVector; 195 if ((*bonditer)->leftatom == _atom) 196 DistanceVector = (*bonditer)->rightatom->getPosition() - (*bonditer)->leftatom->getPosition(); 197 else 198 DistanceVector = (*bonditer)->leftatom->getPosition() - (*bonditer)->rightatom->getPosition(); 199 // always use unit distances 200 DistanceVector.Normalize(); 201 Polygon.push_back( DistanceVector ); 202 } 203 204 // get the new number of bonds (where all cut bonds are replaced by as 205 // many hydrogens as is their degree) 206 // unsigned int NumberOfPoints = _atom->getElement().NoValenceOrbitals; 207 unsigned int NumberOfPoints = 208 _atom->getListOfBonds().size() - _cutbonds.size(); 209 const BondList& ListOfBonds = _atom->getListOfBonds(); 210 for (BondList::const_iterator BondRunner = ListOfBonds.begin(); 211 BondRunner != ListOfBonds.end(); 212 ++BondRunner) { 213 NumberOfPoints += (*BondRunner)->getDegree(); 214 // ALTERNATIVE starting from valence: 215 // // if not one of the cut bonds, reduce by its bond degree -1 (for the one bond itself) 216 // if (_cutbonds.count(*BondRunner)) 217 // NumberOfPoints -= (*BondRunner)->getDegree() - 1; 218 } 219 220 // get perfect node distribution for the given remaining atoms with respect 221 // to valence of the atoms (for a saturated fragment, resembles number of bonds) 222 SphericalPointDistribution polygonizer; 223 SphericalPointDistribution::Polygon_t NewPolygon; 224 switch (NumberOfPoints) 225 { 226 case 0: 227 NewPolygon = polygonizer.get<0>(); 228 break; 229 case 1: 230 NewPolygon = polygonizer.get<1>(); 231 break; 232 case 2: 233 NewPolygon = polygonizer.get<2>(); 234 break; 235 case 3: 236 NewPolygon = polygonizer.get<3>(); 237 break; 238 case 4: 239 NewPolygon = polygonizer.get<4>(); 240 break; 241 case 5: 242 NewPolygon = polygonizer.get<5>(); 243 break; 244 case 6: 245 NewPolygon = polygonizer.get<6>(); 246 break; 247 case 7: 248 NewPolygon = polygonizer.get<7>(); 249 break; 250 case 8: 251 NewPolygon = polygonizer.get<8>(); 252 break; 253 case 9: 254 NewPolygon = polygonizer.get<9>(); 255 break; 256 case 10: 257 NewPolygon = polygonizer.get<10>(); 258 break; 259 case 11: 260 NewPolygon = polygonizer.get<11>(); 261 break; 262 case 12: 263 NewPolygon = polygonizer.get<12>(); 264 break; 265 case 14: 266 NewPolygon = polygonizer.get<14>(); 267 break; 268 default: 269 ASSERT(0, "SaturatedFragment::saturateAtom() - cannot deal with the case " 270 +toString(NumberOfPoints)+"."); 271 } 272 273 // then we need to match the old with the new 274 SphericalPointDistribution::Polygon_t RemainingPoints = 275 SphericalPointDistribution::matchSphericalPointDistributions(Polygon, NewPolygon); 276 277 // and place hydrogen atoms at each vacant spot in the distance given by the table 278 for(SphericalPointDistribution::Polygon_t::const_iterator iter = RemainingPoints.begin(); 279 iter != RemainingPoints.end(); ++iter) { 280 // find nearest atom as father to this point 281 atom * const _father = _atom; 282 setHydrogenReplacement( 283 _atom, 284 *iter, 285 1., 286 _father); 287 } 288 289 return true; 290 } 291 180 292 181 293 bool SaturatedFragment::OutputConfig( … … 234 346 SaturationHydrogens.insert(_atom->getId()); 235 347 return _atom; 348 } 349 350 void SaturatedFragment::setHydrogenReplacement( 351 const atom * const _OwnerAtom, 352 const Vector &_position, 353 const double _distance, 354 atom * const _father) 355 { 356 atom * const _atom = hydrogens.leaseHydrogen(); // new atom 357 _atom->setPosition( _OwnerAtom->getPosition() + _distance * _position ); 358 // always set as fixed ion (not moving during molecular dynamics simulation) 359 _atom->setFixedIon(true); 360 // if we replace hydrogen, we mark it as our father, otherwise we are just an added hydrogen with no father 361 _atom->father = _father; 362 SaturationHydrogens.insert(_atom->getId()); 236 363 } 237 364 -
src/Fragmentation/Exporters/SaturatedFragment.hpp
r972412 r97dff0 25 25 class atom; 26 26 class HydrogenPool; 27 class Vector; 27 28 28 29 /** The SaturatedFragment class acts as a wrapper to a KeySet by adding a list … … 110 111 atom * const getHydrogenReplacement(atom * const replacement); 111 112 113 /** Sets a saturation hydrogen at the given position in place of \a _father. 114 * 115 * \param _OwnerAtom atom "owning" the hydrogen (i.e. the one getting saturated) 116 * \param _position new position relative to \a _OwnerAtom 117 * \param _distance scale factor to the distance (default 1.) 118 * \param _father bond partner of \a _OwnerAtom that is replaced 119 */ 120 void setHydrogenReplacement( 121 const atom * const _OwnerAtom, 122 const Vector &_position, 123 const double _distance, 124 atom * const _father); 125 112 126 /** Leases and adds a Hydrogen atom in replacement for the given atom \a *partner in bond with a *origin. 113 127 * Here, we have to distinguish between single, double or triple bonds as stated by \a BondDegree, that each demand
Note:
See TracChangeset
for help on using the changeset viewer.