| [bcf653] | 1 | /* | 
|---|
|  | 2 | * Project: MoleCuilder | 
|---|
|  | 3 | * Description: creates and alters molecular systems | 
|---|
|  | 4 | * Copyright (C)  2010 University of Bonn. All rights reserved. | 
|---|
|  | 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
| [14de469] | 8 | /** \file atom.cpp | 
|---|
| [1907a7] | 9 | * | 
|---|
| [14de469] | 10 | * Function implementations for the class atom. | 
|---|
| [1907a7] | 11 | * | 
|---|
| [14de469] | 12 | */ | 
|---|
|  | 13 |  | 
|---|
| [bf3817] | 14 | // include config.h | 
|---|
|  | 15 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 16 | #include <config.h> | 
|---|
|  | 17 | #endif | 
|---|
|  | 18 |  | 
|---|
| [ad011c] | 19 | #include "CodePatterns/MemDebug.hpp" | 
|---|
| [112b09] | 20 |  | 
|---|
| [357fba] | 21 | #include "atom.hpp" | 
|---|
| [e41951] | 22 | #include "bond.hpp" | 
|---|
| [e2373df] | 23 | #include "CodePatterns/Log.hpp" | 
|---|
| [4a7776a] | 24 | #include "config.hpp" | 
|---|
| [f66195] | 25 | #include "element.hpp" | 
|---|
| [ccd9f5] | 26 | #include "parser.hpp" | 
|---|
| [57f243] | 27 | #include "LinearAlgebra/Vector.hpp" | 
|---|
| [d346b6] | 28 | #include "World.hpp" | 
|---|
| [6cfa36] | 29 | #include "molecule.hpp" | 
|---|
| [c550dd] | 30 | #include "Shapes/Shape.hpp" | 
|---|
| [a0064e] | 31 |  | 
|---|
| [36166d] | 32 | #include <iomanip> | 
|---|
| [0ba410] | 33 | #include <iostream> | 
|---|
| [36166d] | 34 |  | 
|---|
| [14de469] | 35 | /************************************* Functions for class atom *************************************/ | 
|---|
|  | 36 |  | 
|---|
| [70ff32] | 37 |  | 
|---|
| [14de469] | 38 | /** Constructor of class atom. | 
|---|
|  | 39 | */ | 
|---|
| [46d958] | 40 | atom::atom() : | 
|---|
| [97b825] | 41 | father(this), | 
|---|
|  | 42 | sort(&nr), | 
|---|
|  | 43 | mol(0) | 
|---|
| [d74077] | 44 | {}; | 
|---|
| [14de469] | 45 |  | 
|---|
| [2319ed] | 46 | /** Constructor of class atom. | 
|---|
|  | 47 | */ | 
|---|
| [46d958] | 48 | atom::atom(atom *pointer) : | 
|---|
| [97b825] | 49 | ParticleInfo(pointer), | 
|---|
|  | 50 | father(pointer), | 
|---|
| [9df680] | 51 | sort(&nr), | 
|---|
|  | 52 | mol(0) | 
|---|
| [2319ed] | 53 | { | 
|---|
| [443547] | 54 | setType(pointer->getType());  // copy element of atom | 
|---|
|  | 55 | AtomicPosition = pointer->AtomicPosition; // copy trajectory of coordination | 
|---|
|  | 56 | AtomicVelocity = pointer->AtomicVelocity; // copy trajectory of velocity | 
|---|
|  | 57 | AtomicForce = pointer->AtomicForce; | 
|---|
| [6625c3] | 58 | setFixedIon(pointer->getFixedIon()); | 
|---|
| [b453f9] | 59 | }; | 
|---|
| [2319ed] | 60 |  | 
|---|
| [46d958] | 61 | atom *atom::clone(){ | 
|---|
| [68f03d] | 62 | atom *res = new atom(this); | 
|---|
| [23b547] | 63 | World::getInstance().registerAtom(res); | 
|---|
| [46d958] | 64 | return res; | 
|---|
|  | 65 | } | 
|---|
|  | 66 |  | 
|---|
| [2319ed] | 67 |  | 
|---|
| [14de469] | 68 | /** Destructor of class atom. | 
|---|
|  | 69 | */ | 
|---|
| [1907a7] | 70 | atom::~atom() | 
|---|
| [14de469] | 71 | { | 
|---|
| [6cfa36] | 72 | removeFromMolecule(); | 
|---|
| [14de469] | 73 | }; | 
|---|
| [e2373df] | 74 |  | 
|---|
|  | 75 |  | 
|---|
|  | 76 | void atom::UpdateSteps() | 
|---|
|  | 77 | { | 
|---|
|  | 78 | LOG(4,"atom::UpdateSteps() called."); | 
|---|
|  | 79 | // append to position, velocity and force vector | 
|---|
|  | 80 | AtomInfo::AppendTrajectoryStep(); | 
|---|
| [1e6249] | 81 | // append to ListOfBonds vector | 
|---|
|  | 82 | BondedParticleInfo::AppendTrajectoryStep(); | 
|---|
| [e2373df] | 83 | } | 
|---|
|  | 84 |  | 
|---|
| [14de469] | 85 | /** Climbs up the father list until NULL, last is returned. | 
|---|
|  | 86 | * \return true father, i.e. whose father points to itself, NULL if it could not be found or has none (added hydrogen) | 
|---|
|  | 87 | */ | 
|---|
|  | 88 | atom *atom::GetTrueFather() | 
|---|
|  | 89 | { | 
|---|
| [215df0] | 90 | if(father == this){ // top most father is the one that points on itself | 
|---|
|  | 91 | return this; | 
|---|
|  | 92 | } | 
|---|
|  | 93 | else if(!father) { | 
|---|
|  | 94 | return 0; | 
|---|
|  | 95 | } | 
|---|
|  | 96 | else { | 
|---|
|  | 97 | return father->GetTrueFather(); | 
|---|
|  | 98 | } | 
|---|
| [14de469] | 99 | }; | 
|---|
|  | 100 |  | 
|---|
| [e65246] | 101 | /** Sets father to itself or its father in case of copying a molecule. | 
|---|
|  | 102 | */ | 
|---|
|  | 103 | void atom::CorrectFather() | 
|---|
|  | 104 | { | 
|---|
|  | 105 | if (father->father == father)   // same atom in copy's father points to itself | 
|---|
|  | 106 | father = this;  // set father to itself (copy of a whole molecule) | 
|---|
|  | 107 | else | 
|---|
|  | 108 | father = father->father;  // set father to original's father | 
|---|
|  | 109 |  | 
|---|
|  | 110 | }; | 
|---|
|  | 111 |  | 
|---|
|  | 112 | /** Check whether father is equal to given atom. | 
|---|
|  | 113 | * \param *ptr atom to compare father to | 
|---|
|  | 114 | * \param **res return value (only set if atom::father is equal to \a *ptr) | 
|---|
|  | 115 | */ | 
|---|
| [b453f9] | 116 | void atom::EqualsFather ( const atom *ptr, const atom **res ) const | 
|---|
| [e65246] | 117 | { | 
|---|
|  | 118 | if ( ptr == father ) | 
|---|
|  | 119 | *res = this; | 
|---|
|  | 120 | }; | 
|---|
|  | 121 |  | 
|---|
| [00abfc] | 122 | bool atom::isFather(const atom *ptr){ | 
|---|
|  | 123 | return ptr==father; | 
|---|
|  | 124 | } | 
|---|
|  | 125 |  | 
|---|
| [e9f8f9] | 126 | /** Checks whether atom is within the given box. | 
|---|
|  | 127 | * \param offset offset to box origin | 
|---|
|  | 128 | * \param *parallelepiped box matrix | 
|---|
|  | 129 | * \return true - is inside, false - is not | 
|---|
|  | 130 | */ | 
|---|
| [c550dd] | 131 | bool atom::IsInShape(const Shape& shape) const | 
|---|
| [e9f8f9] | 132 | { | 
|---|
| [d74077] | 133 | return shape.isInside(getPosition()); | 
|---|
| [e9f8f9] | 134 | }; | 
|---|
|  | 135 |  | 
|---|
| [b453f9] | 136 | /** Output of a single atom with given numbering. | 
|---|
| [14de469] | 137 | * \param ElementNo cardinal number of the element | 
|---|
|  | 138 | * \param AtomNo cardinal number among these atoms of the same element | 
|---|
|  | 139 | * \param *out stream to output to | 
|---|
| [1907a7] | 140 | * \param *comment commentary after '#' sign | 
|---|
| [e41951] | 141 | * \return true - \a *out present, false - \a *out is NULL | 
|---|
| [14de469] | 142 | */ | 
|---|
| [e138de] | 143 | bool atom::OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment) const | 
|---|
| [14de469] | 144 | { | 
|---|
|  | 145 | if (out != NULL) { | 
|---|
|  | 146 | *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t"  << fixed << setprecision(9) << showpoint; | 
|---|
| [d74077] | 147 | *out << at(0) << "\t" << at(1) << "\t" << at(2); | 
|---|
| [6625c3] | 148 | *out << "\t" << (int)(getFixedIon()); | 
|---|
| [bce72c] | 149 | if (getAtomicVelocity().Norm() > MYEPSILON) | 
|---|
|  | 150 | *out << "\t" << scientific << setprecision(6) << getAtomicVelocity()[0] << "\t" << getAtomicVelocity()[1] << "\t" << getAtomicVelocity()[2] << "\t"; | 
|---|
| [437922] | 151 | if (comment != NULL) | 
|---|
|  | 152 | *out << " # " << comment << endl; | 
|---|
| [e9f8f9] | 153 | else | 
|---|
|  | 154 | *out << " # molecule nr " << nr << endl; | 
|---|
|  | 155 | return true; | 
|---|
|  | 156 | } else | 
|---|
|  | 157 | return false; | 
|---|
|  | 158 | }; | 
|---|
| [b453f9] | 159 |  | 
|---|
|  | 160 | /** Output of a single atom with numbering from array according to atom::type. | 
|---|
|  | 161 | * \param *ElementNo cardinal number of the element | 
|---|
|  | 162 | * \param *AtomNo cardinal number among these atoms of the same element | 
|---|
|  | 163 | * \param *out stream to output to | 
|---|
|  | 164 | * \param *comment commentary after '#' sign | 
|---|
|  | 165 | * \return true - \a *out present, false - \a *out is NULL | 
|---|
|  | 166 | */ | 
|---|
| [0ba410] | 167 | bool atom::OutputArrayIndexed(ostream * const out,const enumeration<const element*> &elementLookup, int *AtomNo, const char *comment) const | 
|---|
| [e9f8f9] | 168 | { | 
|---|
| [83f176] | 169 | AtomNo[getType()->getAtomicNumber()]++;  // increment number | 
|---|
| [e9f8f9] | 170 | if (out != NULL) { | 
|---|
| [8f4df1] | 171 | const element *elemental = getType(); | 
|---|
|  | 172 | ASSERT(elementLookup.there.find(elemental)!=elementLookup.there.end(),"Type of this atom was not in the formula upon enumeration"); | 
|---|
| [83f176] | 173 | *out << "Ion_Type" << elementLookup.there.find(elemental)->second << "_" << AtomNo[elemental->getAtomicNumber()] << "\t"  << fixed << setprecision(9) << showpoint; | 
|---|
| [d74077] | 174 | *out << at(0) << "\t" << at(1) << "\t" << at(2); | 
|---|
| [6625c3] | 175 | *out << "\t" << getFixedIon(); | 
|---|
| [bce72c] | 176 | if (getAtomicVelocity().Norm() > MYEPSILON) | 
|---|
|  | 177 | *out << "\t" << scientific << setprecision(6) << getAtomicVelocity()[0] << "\t" << getAtomicVelocity()[1] << "\t" << getAtomicVelocity()[2] << "\t"; | 
|---|
| [e9f8f9] | 178 | if (comment != NULL) | 
|---|
|  | 179 | *out << " # " << comment << endl; | 
|---|
| [437922] | 180 | else | 
|---|
|  | 181 | *out << " # molecule nr " << nr << endl; | 
|---|
| [14de469] | 182 | return true; | 
|---|
|  | 183 | } else | 
|---|
|  | 184 | return false; | 
|---|
|  | 185 | }; | 
|---|
|  | 186 |  | 
|---|
| [6625c3] | 187 | /** Output of a single atom as one line in xyz file. | 
|---|
| [14de469] | 188 | * \param *out stream to output to | 
|---|
| [e41951] | 189 | * \return true - \a *out present, false - \a *out is NULL | 
|---|
| [14de469] | 190 | */ | 
|---|
|  | 191 | bool atom::OutputXYZLine(ofstream *out) const | 
|---|
|  | 192 | { | 
|---|
|  | 193 | if (out != NULL) { | 
|---|
| [b5c53d] | 194 | *out << getType()->getSymbol() << "\t" << at(0) << "\t" << at(1) << "\t" << at(2) << "\t" << endl; | 
|---|
| [14de469] | 195 | return true; | 
|---|
|  | 196 | } else | 
|---|
|  | 197 | return false; | 
|---|
|  | 198 | }; | 
|---|
|  | 199 |  | 
|---|
| [6625c3] | 200 | /** Output of a single atom as one line in xyz file. | 
|---|
| [fcd7b6] | 201 | * \param *out stream to output to | 
|---|
| [e41951] | 202 | * \param *ElementNo array with ion type number in the config file this atom's element shall have | 
|---|
|  | 203 | * \param *AtomNo array with atom number in the config file this atom shall have, is increase by one automatically | 
|---|
|  | 204 | * \param step Trajectory time step to output | 
|---|
|  | 205 | * \return true - \a *out present, false - \a *out is NULL | 
|---|
| [fcd7b6] | 206 | */ | 
|---|
| [882a8a] | 207 | bool atom::OutputTrajectory(ofstream * const out, const enumeration<const element*> &elementLookup, int *AtomNo, const int step) const | 
|---|
| [fcd7b6] | 208 | { | 
|---|
| [83f176] | 209 | AtomNo[getType()->getAtomicNumber()]++; | 
|---|
| [882a8a] | 210 | if (out != NULL) { | 
|---|
|  | 211 | const element *elemental = getType(); | 
|---|
|  | 212 | ASSERT(elementLookup.there.find(elemental)!=elementLookup.there.end(),"Type of this atom was not in the formula upon enumeration"); | 
|---|
|  | 213 | *out << "Ion_Type" << elementLookup.there.find(elemental)->second << "_" << AtomNo[getType()->getAtomicNumber()] << "\t"  << fixed << setprecision(9) << showpoint; | 
|---|
| [056e70] | 214 | *out << getPositionAtStep(step)[0] << "\t" << getPositionAtStep(step)[1] << "\t" << getPositionAtStep(step)[2]; | 
|---|
| [6625c3] | 215 | *out << "\t" << (int)(getFixedIon()); | 
|---|
| [056e70] | 216 | if (getAtomicVelocityAtStep(step).Norm() > MYEPSILON) | 
|---|
|  | 217 | *out << "\t" << scientific << setprecision(6) << getAtomicVelocityAtStep(step)[0] << "\t" << getAtomicVelocityAtStep(step)[1] << "\t" << getAtomicVelocityAtStep(step)[2] << "\t"; | 
|---|
|  | 218 | if (getAtomicForceAtStep(step).Norm() > MYEPSILON) | 
|---|
|  | 219 | *out << "\t" << scientific << setprecision(6) << getAtomicForceAtStep(step)[0] << "\t" << getAtomicForceAtStep(step)[1] << "\t" << getAtomicForceAtStep(step)[2] << "\t"; | 
|---|
| [fcd7b6] | 220 | *out << "\t# Number in molecule " << nr << endl; | 
|---|
|  | 221 | return true; | 
|---|
|  | 222 | } else | 
|---|
|  | 223 | return false; | 
|---|
|  | 224 | }; | 
|---|
|  | 225 |  | 
|---|
| [681a8a] | 226 | /** Output of a single atom as one lin in xyz file. | 
|---|
|  | 227 | * \param *out stream to output to | 
|---|
| [e41951] | 228 | * \param step Trajectory time step to output | 
|---|
|  | 229 | * \return true - \a *out present, false - \a *out is NULL | 
|---|
| [681a8a] | 230 | */ | 
|---|
| [e138de] | 231 | bool atom::OutputTrajectoryXYZ(ofstream * const out, const int step) const | 
|---|
| [681a8a] | 232 | { | 
|---|
|  | 233 | if (out != NULL) { | 
|---|
| [b5c53d] | 234 | *out << getType()->getSymbol() << "\t"; | 
|---|
| [056e70] | 235 | *out << getPositionAtStep(step)[0] << "\t"; | 
|---|
|  | 236 | *out << getPositionAtStep(step)[1] << "\t"; | 
|---|
|  | 237 | *out << getPositionAtStep(step)[2] << endl; | 
|---|
| [681a8a] | 238 | return true; | 
|---|
|  | 239 | } else | 
|---|
|  | 240 | return false; | 
|---|
|  | 241 | }; | 
|---|
|  | 242 |  | 
|---|
| [4455f4] | 243 | /** Outputs the MPQC configuration line for this atom. | 
|---|
|  | 244 | * \param *out output stream | 
|---|
|  | 245 | * \param *center center of molecule subtracted from position | 
|---|
|  | 246 | * \param *AtomNo pointer to atom counter that is increased by one | 
|---|
|  | 247 | */ | 
|---|
| [0dc86e2] | 248 | void atom::OutputMPQCLine(ostream * const out, const Vector *center) const | 
|---|
| [4455f4] | 249 | { | 
|---|
| [d74077] | 250 | Vector recentered(getPosition()); | 
|---|
|  | 251 | recentered -= *center; | 
|---|
| [b5c53d] | 252 | *out << "\t\t" << getType()->getSymbol() << " [ " << recentered[0] << "\t" << recentered[1] << "\t" << recentered[2] << " ]" << endl; | 
|---|
| [4455f4] | 253 | }; | 
|---|
|  | 254 |  | 
|---|
|  | 255 | /** Compares the indices of \a this atom with a given \a ptr. | 
|---|
|  | 256 | * \param ptr atom to compare index against | 
|---|
|  | 257 | * \return true - this one's is smaller, false - not | 
|---|
|  | 258 | */ | 
|---|
| [b453f9] | 259 | bool atom::Compare(const atom &ptr) const | 
|---|
| [4455f4] | 260 | { | 
|---|
|  | 261 | if (nr < ptr.nr) | 
|---|
|  | 262 | return true; | 
|---|
|  | 263 | else | 
|---|
|  | 264 | return false; | 
|---|
|  | 265 | }; | 
|---|
|  | 266 |  | 
|---|
|  | 267 | /** Returns squared distance to a given vector. | 
|---|
|  | 268 | * \param origin vector to calculate distance to | 
|---|
|  | 269 | * \return distance squared | 
|---|
|  | 270 | */ | 
|---|
| [b453f9] | 271 | double atom::DistanceSquaredToVector(const Vector &origin) const | 
|---|
| [4455f4] | 272 | { | 
|---|
| [d74077] | 273 | return DistanceSquared(origin); | 
|---|
| [4455f4] | 274 | }; | 
|---|
|  | 275 |  | 
|---|
|  | 276 | /** Returns distance to a given vector. | 
|---|
|  | 277 | * \param origin vector to calculate distance to | 
|---|
|  | 278 | * \return distance | 
|---|
|  | 279 | */ | 
|---|
| [b453f9] | 280 | double atom::DistanceToVector(const Vector &origin) const | 
|---|
| [4455f4] | 281 | { | 
|---|
| [d74077] | 282 | return distance(origin); | 
|---|
| [4455f4] | 283 | }; | 
|---|
|  | 284 |  | 
|---|
|  | 285 | /** Initialises the component number array. | 
|---|
|  | 286 | * Size is set to atom::ListOfBonds.size()+1 (last is th encode end by -1) | 
|---|
|  | 287 | */ | 
|---|
|  | 288 | void atom::InitComponentNr() | 
|---|
|  | 289 | { | 
|---|
|  | 290 | if (ComponentNr != NULL) | 
|---|
| [920c70] | 291 | delete[](ComponentNr); | 
|---|
| [9d83b6] | 292 | const BondList& ListOfBonds = getListOfBonds(); | 
|---|
| [920c70] | 293 | ComponentNr = new int[ListOfBonds.size()+1]; | 
|---|
| [4455f4] | 294 | for (int i=ListOfBonds.size()+1;i--;) | 
|---|
|  | 295 | ComponentNr[i] = -1; | 
|---|
| [14b65e] | 296 | }; | 
|---|
|  | 297 |  | 
|---|
|  | 298 | void atom::resetGraphNr(){ | 
|---|
|  | 299 | GraphNr=-1; | 
|---|
|  | 300 | } | 
|---|
| [4455f4] | 301 |  | 
|---|
| [d74077] | 302 | std::ostream & atom::operator << (std::ostream &ost) const | 
|---|
|  | 303 | { | 
|---|
|  | 304 | ParticleInfo::operator<<(ost); | 
|---|
|  | 305 | ost << "," << getPosition(); | 
|---|
|  | 306 | return ost; | 
|---|
|  | 307 | } | 
|---|
|  | 308 |  | 
|---|
|  | 309 | std::ostream & operator << (std::ostream &ost, const atom &a) | 
|---|
|  | 310 | { | 
|---|
|  | 311 | a.ParticleInfo::operator<<(ost); | 
|---|
|  | 312 | ost << "," << a.getPosition(); | 
|---|
|  | 313 | return ost; | 
|---|
|  | 314 | } | 
|---|
| [4455f4] | 315 |  | 
|---|
|  | 316 | bool operator < (atom &a, atom &b) | 
|---|
|  | 317 | { | 
|---|
|  | 318 | return a.Compare(b); | 
|---|
|  | 319 | }; | 
|---|
|  | 320 |  | 
|---|
| [46d958] | 321 | World *atom::getWorld(){ | 
|---|
|  | 322 | return world; | 
|---|
|  | 323 | } | 
|---|
|  | 324 |  | 
|---|
|  | 325 | void atom::setWorld(World* _world){ | 
|---|
|  | 326 | world = _world; | 
|---|
|  | 327 | } | 
|---|
|  | 328 |  | 
|---|
| [88d586] | 329 | bool atom::changeId(atomId_t newId){ | 
|---|
|  | 330 | // first we move ourselves in the world | 
|---|
|  | 331 | // the world lets us know if that succeeded | 
|---|
|  | 332 | if(world->changeAtomId(id,newId,this)){ | 
|---|
|  | 333 | id = newId; | 
|---|
|  | 334 | return true; | 
|---|
|  | 335 | } | 
|---|
|  | 336 | else{ | 
|---|
|  | 337 | return false; | 
|---|
|  | 338 | } | 
|---|
|  | 339 | } | 
|---|
|  | 340 |  | 
|---|
|  | 341 | void atom::setId(atomId_t _id) { | 
|---|
| [46d958] | 342 | id=_id; | 
|---|
|  | 343 | } | 
|---|
|  | 344 |  | 
|---|
| [ad2b411] | 345 | atomId_t atom::getId() const { | 
|---|
| [46d958] | 346 | return id; | 
|---|
|  | 347 | } | 
|---|
|  | 348 |  | 
|---|
| [fa7989] | 349 | /** Makes the atom be contained in the new molecule \a *_mol. | 
|---|
|  | 350 | * Uses atom::removeFromMolecule() to delist from old molecule. | 
|---|
|  | 351 | * \param *_mol pointer to new molecule | 
|---|
|  | 352 | */ | 
|---|
| [6cfa36] | 353 | void atom::setMolecule(molecule *_mol){ | 
|---|
|  | 354 | // take this atom from the old molecule | 
|---|
|  | 355 | removeFromMolecule(); | 
|---|
|  | 356 | mol = _mol; | 
|---|
|  | 357 | if(!mol->containsAtom(this)){ | 
|---|
| [dddbfe] | 358 | mol->insert(this); | 
|---|
| [6cfa36] | 359 | } | 
|---|
|  | 360 | } | 
|---|
|  | 361 |  | 
|---|
| [fa7989] | 362 | /** Returns pointer to the molecule which atom belongs to. | 
|---|
|  | 363 | * \return containing molecule | 
|---|
|  | 364 | */ | 
|---|
| [e41c48] | 365 | molecule* atom::getMolecule() const { | 
|---|
| [c084cc] | 366 | return mol; | 
|---|
|  | 367 | } | 
|---|
|  | 368 |  | 
|---|
| [fa7989] | 369 | /** Erases the atom in atom::mol's list of atoms and sets it to zero. | 
|---|
|  | 370 | */ | 
|---|
| [6cfa36] | 371 | void atom::removeFromMolecule(){ | 
|---|
|  | 372 | if(mol){ | 
|---|
|  | 373 | if(mol->containsAtom(this)){ | 
|---|
|  | 374 | mol->erase(this); | 
|---|
|  | 375 | } | 
|---|
|  | 376 | mol=0; | 
|---|
|  | 377 | } | 
|---|
| [1f8337] | 378 | } | 
|---|
|  | 379 |  | 
|---|
| [e8a21f] | 380 | int atom::getNr() const{ | 
|---|
|  | 381 | return nr; | 
|---|
|  | 382 | } | 
|---|
| [6cfa36] | 383 |  | 
|---|
| [88d586] | 384 | atom* NewAtom(atomId_t _id){ | 
|---|
|  | 385 | atom * res =new atom(); | 
|---|
|  | 386 | res->setId(_id); | 
|---|
|  | 387 | return res; | 
|---|
| [46d958] | 388 | } | 
|---|
|  | 389 |  | 
|---|
| [88d586] | 390 | void DeleteAtom(atom* atom){ | 
|---|
| [46d958] | 391 | delete atom; | 
|---|
| [e5f64de] | 392 | } | 
|---|
|  | 393 |  | 
|---|
|  | 394 | bool compareAtomElements(atom* atom1,atom* atom2){ | 
|---|
|  | 395 | return atom1->getType()->getNumber() < atom2->getType()->getNumber(); | 
|---|
| [46d958] | 396 | } | 
|---|