[bcf653] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
[0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
[94d5ac6] | 5 | *
|
---|
| 6 | *
|
---|
| 7 | * This file is part of MoleCuilder.
|
---|
| 8 | *
|
---|
| 9 | * MoleCuilder is free software: you can redistribute it and/or modify
|
---|
| 10 | * it under the terms of the GNU General Public License as published by
|
---|
| 11 | * the Free Software Foundation, either version 2 of the License, or
|
---|
| 12 | * (at your option) any later version.
|
---|
| 13 | *
|
---|
| 14 | * MoleCuilder is distributed in the hope that it will be useful,
|
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 17 | * GNU General Public License for more details.
|
---|
| 18 | *
|
---|
| 19 | * You should have received a copy of the GNU General Public License
|
---|
| 20 | * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
|
---|
[bcf653] | 21 | */
|
---|
| 22 |
|
---|
[6b919f8] | 23 | /*
|
---|
| 24 | * atom_bondedparticle.cpp
|
---|
| 25 | *
|
---|
| 26 | * Created on: Oct 19, 2009
|
---|
| 27 | * Author: heber
|
---|
| 28 | */
|
---|
| 29 |
|
---|
[bf3817] | 30 | // include config.h
|
---|
| 31 | #ifdef HAVE_CONFIG_H
|
---|
| 32 | #include <config.h>
|
---|
| 33 | #endif
|
---|
| 34 |
|
---|
[ad011c] | 35 | #include "CodePatterns/MemDebug.hpp"
|
---|
[112b09] | 36 |
|
---|
[f63e41] | 37 | #include <algorithm>
|
---|
| 38 | #include <boost/bind.hpp>
|
---|
| 39 |
|
---|
[6b919f8] | 40 | #include "atom.hpp"
|
---|
| 41 | #include "atom_bondedparticle.hpp"
|
---|
[129204] | 42 | #include "Bond/bond.hpp"
|
---|
[d557374] | 43 | #include "CodePatterns/Assert.hpp"
|
---|
[ad011c] | 44 | #include "CodePatterns/Log.hpp"
|
---|
| 45 | #include "CodePatterns/Verbose.hpp"
|
---|
[3bdb6d] | 46 | #include "Element/element.hpp"
|
---|
[db7e6d] | 47 | #include "WorldTime.hpp"
|
---|
[6b919f8] | 48 |
|
---|
| 49 | /** Constructor of class BondedParticle.
|
---|
| 50 | */
|
---|
[70ff32] | 51 | BondedParticle::BondedParticle()
|
---|
| 52 | {
|
---|
[9d83b6] | 53 | ListOfBonds.push_back(BondList());
|
---|
[70ff32] | 54 | };
|
---|
[6b919f8] | 55 |
|
---|
| 56 | /** Destructor of class BondedParticle.
|
---|
| 57 | */
|
---|
| 58 | BondedParticle::~BondedParticle()
|
---|
| 59 | {
|
---|
[5e2f80] | 60 | removeAllBonds();
|
---|
[6b919f8] | 61 | };
|
---|
| 62 |
|
---|
| 63 | /** Outputs the current atom::AdaptiveOrder and atom::MaxOrder to \a *file.
|
---|
| 64 | * \param *file output stream
|
---|
| 65 | */
|
---|
[b453f9] | 66 | void BondedParticle::OutputOrder(ofstream *file) const
|
---|
[6b919f8] | 67 | {
|
---|
[735b1c] | 68 | *file << getNr() << "\t" << (int)AdaptiveOrder << "\t" << (int)MaxOrder << endl;
|
---|
[d760bb] | 69 | //LOG(2, "Storing: " << getNr() << "\t" << (int)AdaptiveOrder << "\t" << MaxOrder << ".");
|
---|
[6b919f8] | 70 | };
|
---|
| 71 |
|
---|
| 72 | /** Prints all bonds of this atom with total degree.
|
---|
| 73 | */
|
---|
[4b5cf8] | 74 | void BondedParticle::OutputBondOfAtom(std::ostream &ost) const
|
---|
[6b919f8] | 75 | {
|
---|
[9d83b6] | 76 | const BondList& ListOfBonds = getListOfBonds();
|
---|
[4b5cf8] | 77 | ost << "Atom " << getName() << "/" << getNr() << " with " << ListOfBonds.size() << " bonds: ";
|
---|
[e138de] | 78 | int TotalDegree = 0;
|
---|
| 79 | for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); ++Runner) {
|
---|
[4b5cf8] | 80 | ost << **Runner << "\t";
|
---|
[e138de] | 81 | TotalDegree += (*Runner)->BondDegree;
|
---|
| 82 | }
|
---|
[4b5cf8] | 83 | ost << " -- TotalDegree: " << TotalDegree;
|
---|
[6b919f8] | 84 | };
|
---|
| 85 |
|
---|
[5309ba] | 86 | /** Output of atom::Nr along each bond partner per line.
|
---|
| 87 | * Only bonds are printed where atom::Nr is smaller than the one of the bond partner.
|
---|
[1f1b23] | 88 | * \param *AdjacencyFile output stream
|
---|
| 89 | */
|
---|
| 90 | void BondedParticle::OutputBonds(ofstream * const BondFile) const
|
---|
| 91 | {
|
---|
[9d83b6] | 92 | const BondList& ListOfBonds = getListOfBonds();
|
---|
[1f1b23] | 93 | for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner))
|
---|
[735b1c] | 94 | if (getNr() < (*Runner)->GetOtherAtom(this)->getNr())
|
---|
[52ed5b] | 95 | *BondFile << getNr() << "\t" << (*Runner)->GetOtherAtom(this)->getNr() << "\n";
|
---|
[1f1b23] | 96 | };
|
---|
| 97 |
|
---|
[b8d4a3] | 98 | /**
|
---|
[db7e6d] | 99 | * Adds a bond between this bonded particle and another. Returns present instance if this
|
---|
[b8d4a3] | 100 | * bond already exists.
|
---|
| 101 | *
|
---|
[073a9e4] | 102 | * @param _step time step to access
|
---|
[db7e6d] | 103 | * @param bonding partner
|
---|
[05a885] | 104 | * @return const pointer to created bond or to already present bonds
|
---|
[b8d4a3] | 105 | */
|
---|
[88c8ec] | 106 | bond::ptr const BondedParticle::addBond(const unsigned int _step, BondedParticle* Partner)
|
---|
[db7e6d] | 107 | {
|
---|
| 108 | const BondList &bondlist = getListOfBondsAtStep(_step);
|
---|
| 109 | for (BondList::const_iterator runner = bondlist.begin();
|
---|
| 110 | runner != bondlist.end();
|
---|
| 111 | runner++) {
|
---|
| 112 | if ((*runner)->Contains(Partner))
|
---|
| 113 | return *runner;
|
---|
[b8d4a3] | 114 | }
|
---|
| 115 |
|
---|
[7d82a5] | 116 | bond::ptr newBond(new bond((atom*) this, (atom*) Partner, 1));
|
---|
[073a9e4] | 117 | RegisterBond(_step, newBond);
|
---|
| 118 | Partner->RegisterBond(_step, newBond);
|
---|
[db7e6d] | 119 |
|
---|
| 120 | return newBond;
|
---|
| 121 | }
|
---|
| 122 |
|
---|
[7d82a5] | 123 | /** Helper function to find the time step to a given bond in \a Binder.
|
---|
[f63e41] | 124 | *
|
---|
[7d82a5] | 125 | * \param Binder bond to look for
|
---|
| 126 | * \return ListOfBonds::size() - not found, else - step containing \a Binder
|
---|
[f63e41] | 127 | */
|
---|
[7d82a5] | 128 | unsigned int BondedParticle::findBondsStep(bond::ptr const Binder) const
|
---|
| 129 | {
|
---|
| 130 |
|
---|
| 131 | size_t _step = 0;
|
---|
| 132 | for (;_step < ListOfBonds.size();++_step) {
|
---|
| 133 | const BondList& ListOfBonds = getListOfBondsAtStep(_step);
|
---|
| 134 | if (std::find(ListOfBonds.begin(), ListOfBonds.end(), Binder) != ListOfBonds.end())
|
---|
| 135 | break;
|
---|
| 136 | }
|
---|
| 137 | return _step;
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | /** Helper function to find the iterator to a bond at a given time \a step to
|
---|
| 141 | * a given bond partner in \a Partner.
|
---|
| 142 | *
|
---|
| 143 | * \param _step time step to look at
|
---|
| 144 | * \param Partner bond partner to look for
|
---|
| 145 | * \return ListOfBonds::end() - not found, else - iterator pointing \a Binder
|
---|
| 146 | */
|
---|
| 147 | BondList::const_iterator BondedParticle::findBondPartnerAtStep(
|
---|
| 148 | const unsigned int _step,
|
---|
| 149 | BondedParticle * const Partner) const
|
---|
[f63e41] | 150 | {
|
---|
| 151 | const BondList& ListOfBonds = getListOfBondsAtStep(_step);
|
---|
| 152 | BondList::const_iterator iter = std::find_if(ListOfBonds.begin(), ListOfBonds.end(),
|
---|
| 153 | boost::bind(
|
---|
| 154 | static_cast<bool (bond::*)(const ParticleInfo * const) const>(&bond::Contains),
|
---|
| 155 | _1,
|
---|
| 156 | boost::cref(Partner)));
|
---|
[7d82a5] | 157 | return iter;
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | /** Removes a bond of this atom to a given \a Partner.
|
---|
| 161 | *
|
---|
| 162 | * @param _step time step
|
---|
| 163 | * @param Partner bond partner
|
---|
| 164 | */
|
---|
| 165 | void BondedParticle::removeBond(const unsigned int _step, BondedParticle * const Partner)
|
---|
| 166 | {
|
---|
| 167 | BondList::const_iterator iter = findBondPartnerAtStep(_step, Partner);
|
---|
| 168 | if (iter != getListOfBondsAtStep(_step).end()) {
|
---|
| 169 | // iter becomes invalid upon first unregister,
|
---|
| 170 | // hence store the bond someplace else first
|
---|
| 171 | bond::ptr const Binder = *iter;
|
---|
| 172 | UnregisterBond(_step, Binder);
|
---|
| 173 | Partner->UnregisterBond(_step, Binder);
|
---|
[f63e41] | 174 | } else
|
---|
| 175 | ELOG(1, "BondedParticle::removeBond() - I cannot find the bond in between "
|
---|
| 176 | +toString(getName())+" and "+toString(Partner->getName())+".");
|
---|
| 177 | }
|
---|
| 178 |
|
---|
[db7e6d] | 179 | /** Removes a bond for this atom.
|
---|
| 180 | *
|
---|
| 181 | * @param Binder bond to remove
|
---|
| 182 | */
|
---|
[7d82a5] | 183 | void BondedParticle::removeBond(bond::ptr &binder)
|
---|
[db7e6d] | 184 | {
|
---|
[7d82a5] | 185 | if (binder != NULL) {
|
---|
| 186 | atom * const Other = binder->GetOtherAtom(this);
|
---|
| 187 | ASSERT( Other != NULL,
|
---|
| 188 | "BondedParticle::removeBonds() - cannot find bond partner for "
|
---|
| 189 | +toString(*binder)+".");
|
---|
| 190 | // find bond at step
|
---|
| 191 | unsigned int step = findBondsStep(binder);
|
---|
| 192 | if (step != ListOfBonds.size()) {
|
---|
| 193 | UnregisterBond(step, binder);
|
---|
| 194 | Other->UnregisterBond(step, binder);
|
---|
| 195 | binder.reset();
|
---|
| 196 | }
|
---|
| 197 | }
|
---|
[b8d4a3] | 198 | }
|
---|
| 199 |
|
---|
[cc9119] | 200 | /** Removes all bonds in all timesteps and their instances, too.
|
---|
[5e2f80] | 201 | *
|
---|
| 202 | */
|
---|
| 203 | void BondedParticle::removeAllBonds()
|
---|
| 204 | {
|
---|
| 205 | for (size_t index = 0; index < ListOfBonds.size(); ++index)
|
---|
[cc9119] | 206 | removeAllBonds(index);
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 | /** Removes all bonds for a given \a _step and their instances, too.
|
---|
| 210 | *
|
---|
| 211 | * @param _step time step to access
|
---|
| 212 | */
|
---|
| 213 | void BondedParticle::removeAllBonds(const unsigned int _step)
|
---|
| 214 | {
|
---|
[7d82a5] | 215 | //LOG(3,"INFO: Clearing all bonds of " << *this << ": " << ListOfBonds[_step]);
|
---|
| 216 | for (BondList::iterator iter = (ListOfBonds[_step]).begin();
|
---|
| 217 | !(ListOfBonds[_step]).empty();
|
---|
| 218 | iter = (ListOfBonds[_step]).begin()) {
|
---|
| 219 | //LOG(3,"INFO: Clearing bond (" << *iter << ") " << *(*iter) << " of list " << &ListOfBonds);
|
---|
| 220 | atom * const Other = (*iter)->GetOtherAtom(this);
|
---|
| 221 | ASSERT( Other != NULL,
|
---|
| 222 | "BondedParticle::removeAllBonds() - cannot find bond partner for "
|
---|
| 223 | +toString(**iter)+".");
|
---|
| 224 | Other->UnregisterBond(_step, *iter);
|
---|
| 225 | UnregisterBond(_step, *iter);
|
---|
[5e2f80] | 226 | }
|
---|
| 227 | }
|
---|
| 228 |
|
---|
[6b919f8] | 229 | /** Puts a given bond into atom::ListOfBonds.
|
---|
[073a9e4] | 230 | * @param _step time step to access
|
---|
[6b919f8] | 231 | * \param *Binder bond to insert
|
---|
| 232 | */
|
---|
[88c8ec] | 233 | bool BondedParticle::RegisterBond(const unsigned int _step, bond::ptr const Binder)
|
---|
[6b919f8] | 234 | {
|
---|
| 235 | bool status = false;
|
---|
| 236 | if (Binder != NULL) {
|
---|
[7d82a5] | 237 | OBSERVE;
|
---|
[6b919f8] | 238 | if (Binder->Contains(this)) {
|
---|
[d557374] | 239 | //LOG(3,"INFO: Registering bond "<< *Binder << " with atom " << *this << " at step " << _step);
|
---|
[5e2f80] | 240 | if (ListOfBonds.size() <= _step)
|
---|
| 241 | ListOfBonds.resize(_step+1);
|
---|
| 242 | ListOfBonds[_step].push_back(Binder);
|
---|
[74ec1f] | 243 | if (WorldTime::getTime() == _step)
|
---|
[2ad1ec] | 244 | NOTIFY(AtomObservable::BondsAdded);
|
---|
[6b919f8] | 245 | status = true;
|
---|
| 246 | } else {
|
---|
[47d041] | 247 | ELOG(1, *Binder << " does not contain " << *this << ".");
|
---|
[6b919f8] | 248 | }
|
---|
| 249 | } else {
|
---|
[47d041] | 250 | ELOG(1, "Binder is " << Binder << ".");
|
---|
[6b919f8] | 251 | }
|
---|
| 252 | return status;
|
---|
| 253 | };
|
---|
| 254 |
|
---|
| 255 | /** Removes a given bond from atom::ListOfBonds.
|
---|
[7d82a5] | 256 | *
|
---|
| 257 | * \warning This only removes this atom not its bond partner, i.e.
|
---|
| 258 | * both atoms need to call this function to fully empty a bond.
|
---|
| 259 | *
|
---|
[9d83b6] | 260 | * @param _step time step to access
|
---|
[6b919f8] | 261 | * \param *Binder bond to remove
|
---|
| 262 | */
|
---|
[7d82a5] | 263 | bool BondedParticle::UnregisterBond(const unsigned int _step, bond::ptr const Binder)
|
---|
[6b919f8] | 264 | {
|
---|
| 265 | bool status = false;
|
---|
[7d82a5] | 266 | if (Binder != NULL) {
|
---|
| 267 | if (Binder->Contains(this)) {
|
---|
| 268 | OBSERVE;
|
---|
| 269 | //LOG(0,"INFO: Unregistering bond "<< *Binder << " from list " << &ListOfBonds << " of atom " << *this << " at step " << step);
|
---|
| 270 | #ifndef NDEBUG
|
---|
| 271 | BondList::const_iterator iter =
|
---|
| 272 | std::find(ListOfBonds[_step].begin(), ListOfBonds[_step].end(), Binder);
|
---|
| 273 | ASSERT( iter != ListOfBonds[_step].end(),
|
---|
| 274 | "BondedParticle::UnregisterBond() - "+toString(*Binder)+" not contained at "
|
---|
| 275 | +toString(_step));
|
---|
| 276 | #endif
|
---|
| 277 | Binder->removeAtom(this);
|
---|
| 278 | ListOfBonds[_step].remove(Binder);
|
---|
| 279 | if (WorldTime::getTime() == _step)
|
---|
| 280 | NOTIFY(AtomObservable::BondsRemoved);
|
---|
| 281 | status = true;
|
---|
| 282 | } else {
|
---|
| 283 | ELOG(1, *Binder << " does not contain " << *this << ".");
|
---|
| 284 | }
|
---|
[6b919f8] | 285 | } else {
|
---|
[7d82a5] | 286 | ELOG(1, "Binder is " << Binder << ".");
|
---|
[6b919f8] | 287 | }
|
---|
| 288 | return status;
|
---|
| 289 | };
|
---|
| 290 |
|
---|
[583081] | 291 | /** Removes all bonds of given \a _step with freeing memory.
|
---|
| 292 | *
|
---|
| 293 | * @param _step time step whose bonds to free
|
---|
| 294 | */
|
---|
| 295 | void BondedParticle::ClearBondsAtStep(const unsigned int _step)
|
---|
| 296 | {
|
---|
[7d82a5] | 297 | removeAllBonds(_step);
|
---|
[583081] | 298 | }
|
---|
| 299 |
|
---|
[93c6e9] | 300 | /** Searches for the time step where the given bond \a *Binder is a bond of this particle.
|
---|
| 301 | *
|
---|
| 302 | * @param Binder bond to check
|
---|
| 303 | * @return >=0 - first time step where bond appears, -1 - bond not present in lists
|
---|
| 304 | */
|
---|
[88c8ec] | 305 | int BondedParticle::ContainsBondAtStep(bond::ptr Binder) const
|
---|
[93c6e9] | 306 | {
|
---|
| 307 | int step = -1;
|
---|
| 308 | int tempstep = 0;
|
---|
| 309 | for(std::vector<BondList>::const_iterator iter = ListOfBonds.begin();
|
---|
| 310 | iter != ListOfBonds.end();
|
---|
| 311 | ++iter,++tempstep) {
|
---|
| 312 | for (BondList::const_iterator bonditer = iter->begin();
|
---|
| 313 | bonditer != iter->end();
|
---|
| 314 | ++bonditer) {
|
---|
| 315 | if ((*bonditer) == Binder) {
|
---|
| 316 | step = tempstep;
|
---|
| 317 | break;
|
---|
| 318 | }
|
---|
| 319 | }
|
---|
| 320 | if (step != -1)
|
---|
| 321 | break;
|
---|
| 322 | }
|
---|
| 323 |
|
---|
| 324 | return step;
|
---|
| 325 | }
|
---|
| 326 |
|
---|
[6b919f8] | 327 | /** Corrects the bond degree by one at most if necessary.
|
---|
[93c6e9] | 328 | * \return number of corrections done
|
---|
[6b919f8] | 329 | */
|
---|
[e138de] | 330 | int BondedParticle::CorrectBondDegree()
|
---|
[6b919f8] | 331 | {
|
---|
[db7e6d] | 332 | OBSERVE;
|
---|
[74ec1f] | 333 | NOTIFY(AtomObservable::BondDegreeChanged);
|
---|
[6b919f8] | 334 | int NoBonds = 0;
|
---|
| 335 | int OtherNoBonds = 0;
|
---|
| 336 | int FalseBondDegree = 0;
|
---|
| 337 | atom *OtherWalker = NULL;
|
---|
[7d82a5] | 338 | bond::ptr CandidateBond;
|
---|
[6b919f8] | 339 |
|
---|
| 340 | NoBonds = CountBonds();
|
---|
[47d041] | 341 | //LOG(3, "Walker " << *this << ": " << (int)this->type->NoValenceOrbitals << " > " << NoBonds << "?");
|
---|
[83f176] | 342 | if ((int)(getType()->getNoValenceOrbitals()) > NoBonds) { // we have a mismatch, check all bonding partners for mismatch
|
---|
[9d83b6] | 343 | const BondList& ListOfBonds = getListOfBonds();
|
---|
[6b919f8] | 344 | for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner)) {
|
---|
| 345 | OtherWalker = (*Runner)->GetOtherAtom(this);
|
---|
| 346 | OtherNoBonds = OtherWalker->CountBonds();
|
---|
[47d041] | 347 | //LOG(3, "OtherWalker " << *OtherWalker << ": " << (int)OtherWalker->type->NoValenceOrbitals << " > " << OtherNoBonds << "?");
|
---|
[83f176] | 348 | if ((int)(OtherWalker->getType()->getNoValenceOrbitals()) > OtherNoBonds) { // check if possible candidate
|
---|
[9d83b6] | 349 | const BondList& OtherListOfBonds = OtherWalker->getListOfBonds();
|
---|
| 350 | if ((CandidateBond == NULL) || (ListOfBonds.size() > OtherListOfBonds.size())) { // pick the one with fewer number of bonds first
|
---|
[6b919f8] | 351 | CandidateBond = (*Runner);
|
---|
[47d041] | 352 | //LOG(3, "New candidate is " << *CandidateBond << ".");
|
---|
[6b919f8] | 353 | }
|
---|
| 354 | }
|
---|
| 355 | }
|
---|
| 356 | if ((CandidateBond != NULL)) {
|
---|
| 357 | CandidateBond->BondDegree++;
|
---|
[47d041] | 358 | //LOG(2, "Increased bond degree for bond " << *CandidateBond << ".");
|
---|
[6b919f8] | 359 | } else {
|
---|
[47d041] | 360 | ELOG(2, "Could not find correct degree for atom " << *this << ".");
|
---|
[6b919f8] | 361 | FalseBondDegree++;
|
---|
| 362 | }
|
---|
| 363 | }
|
---|
| 364 | return FalseBondDegree;
|
---|
| 365 | };
|
---|
| 366 |
|
---|
[5e2f80] | 367 | /** Sets the weight of all connected bonds to one.
|
---|
| 368 | */
|
---|
| 369 | void BondedParticle::resetBondDegree()
|
---|
| 370 | {
|
---|
| 371 | OBSERVE;
|
---|
[74ec1f] | 372 | NOTIFY(BondedParticle::BondDegreeChanged);
|
---|
[5e2f80] | 373 | for (std::vector<BondList>::iterator Runner = ListOfBonds.begin();
|
---|
| 374 | Runner != ListOfBonds.end();
|
---|
| 375 | ++Runner)
|
---|
| 376 | for (BondList::iterator BondRunner = (*Runner).begin();
|
---|
| 377 | BondRunner != (*Runner).end();
|
---|
| 378 | ++BondRunner)
|
---|
| 379 | (*BondRunner)->BondDegree = 1;
|
---|
| 380 | };
|
---|
| 381 |
|
---|
[c0d9eb] | 382 | /** Counts the number of bonds weighted by bond::BondDegree.
|
---|
| 383 | * @param _step time step to access
|
---|
| 384 | * \param bonds times bond::BondDegree
|
---|
| 385 | */
|
---|
| 386 | int BondedParticle::CountBonds() const
|
---|
| 387 | {
|
---|
| 388 | int NoBonds = 0;
|
---|
[9d83b6] | 389 | const BondList& ListOfBonds = getListOfBonds();
|
---|
[c0d9eb] | 390 | for (BondList::const_iterator Runner = ListOfBonds.begin();
|
---|
| 391 | Runner != ListOfBonds.end();
|
---|
| 392 | (++Runner))
|
---|
| 393 | NoBonds += (*Runner)->BondDegree;
|
---|
| 394 | return NoBonds;
|
---|
| 395 | };
|
---|
| 396 |
|
---|
[b70721] | 397 | /** Checks whether there is a bond between \a this atom and the given \a *BondPartner.
|
---|
[073a9e4] | 398 | * @param _step time step to access
|
---|
[b70721] | 399 | * \param *BondPartner atom to check for
|
---|
| 400 | * \return true - bond exists, false - bond does not exist
|
---|
| 401 | */
|
---|
[073a9e4] | 402 | bool BondedParticle::IsBondedTo(const unsigned int _step, BondedParticle * const BondPartner) const
|
---|
[b70721] | 403 | {
|
---|
| 404 | bool status = false;
|
---|
| 405 |
|
---|
[073a9e4] | 406 | const BondList& ListOfBonds = getListOfBondsAtStep(_step);
|
---|
| 407 | for (BondList::const_iterator runner = ListOfBonds.begin();
|
---|
| 408 | runner != ListOfBonds.end();
|
---|
| 409 | runner++) {
|
---|
[b70721] | 410 | status = status || ((*runner)->Contains(BondPartner));
|
---|
| 411 | }
|
---|
| 412 | return status;
|
---|
| 413 | };
|
---|
| 414 |
|
---|
[d74077] | 415 | std::ostream & BondedParticle::operator << (std::ostream &ost) const
|
---|
| 416 | {
|
---|
| 417 | ParticleInfo::operator<<(ost);
|
---|
| 418 | ost << "," << getPosition();
|
---|
| 419 | return ost;
|
---|
| 420 | }
|
---|
| 421 |
|
---|
| 422 | std::ostream & operator << (std::ostream &ost, const BondedParticle &a)
|
---|
| 423 | {
|
---|
| 424 | a.ParticleInfo::operator<<(ost);
|
---|
| 425 | ost << "," << a.getPosition();
|
---|
| 426 | return ost;
|
---|
| 427 | }
|
---|
| 428 |
|
---|