| [6b919f8] | 1 | /* | 
|---|
|  | 2 | * atom_atominfo.cpp | 
|---|
|  | 3 | * | 
|---|
|  | 4 | *  Created on: Oct 19, 2009 | 
|---|
|  | 5 | *      Author: heber | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
| [112b09] | 8 | #include "Helpers/MemDebug.hpp" | 
|---|
|  | 9 |  | 
|---|
| [f16a4b] | 10 | #include "periodentafel.hpp" | 
|---|
|  | 11 | #include "World.hpp" | 
|---|
| [d74077] | 12 | #include "element.hpp" | 
|---|
| [6b919f8] | 13 | #include "atom_atominfo.hpp" | 
|---|
|  | 14 |  | 
|---|
|  | 15 | /** Constructor of class AtomInfo. | 
|---|
|  | 16 | */ | 
|---|
| [97b825] | 17 | AtomInfo::AtomInfo() : | 
|---|
|  | 18 | AtomicElement(NULL) | 
|---|
|  | 19 | {}; | 
|---|
| [d74077] | 20 |  | 
|---|
|  | 21 | /** Copy constructor of class AtomInfo. | 
|---|
|  | 22 | */ | 
|---|
| [97b825] | 23 | AtomInfo::AtomInfo(const AtomInfo &_atom) : | 
|---|
|  | 24 | AtomicPosition(_atom.AtomicPosition), | 
|---|
|  | 25 | AtomicElement(_atom.AtomicElement) | 
|---|
|  | 26 | {}; | 
|---|
| [d74077] | 27 |  | 
|---|
| [97b825] | 28 | AtomInfo::AtomInfo(const VectorInterface &_v) : | 
|---|
|  | 29 | AtomicPosition(_v.getPosition()), | 
|---|
|  | 30 | AtomicElement(NULL) | 
|---|
| [d74077] | 31 | {}; | 
|---|
| [6b919f8] | 32 |  | 
|---|
|  | 33 | /** Destructor of class AtomInfo. | 
|---|
|  | 34 | */ | 
|---|
|  | 35 | AtomInfo::~AtomInfo() | 
|---|
|  | 36 | { | 
|---|
|  | 37 | }; | 
|---|
|  | 38 |  | 
|---|
| [d74077] | 39 | const element *AtomInfo::getType() const | 
|---|
|  | 40 | { | 
|---|
|  | 41 | return AtomicElement; | 
|---|
|  | 42 | } | 
|---|
|  | 43 |  | 
|---|
|  | 44 | const double& AtomInfo::operator[](size_t i) const | 
|---|
|  | 45 | { | 
|---|
|  | 46 | return AtomicPosition[i]; | 
|---|
|  | 47 | } | 
|---|
|  | 48 |  | 
|---|
|  | 49 | const double& AtomInfo::at(size_t i) const | 
|---|
|  | 50 | { | 
|---|
|  | 51 | return AtomicPosition.at(i); | 
|---|
|  | 52 | } | 
|---|
|  | 53 |  | 
|---|
|  | 54 | void AtomInfo::set(size_t i, const double value) | 
|---|
|  | 55 | { | 
|---|
|  | 56 | AtomicPosition.at(i) = value; | 
|---|
|  | 57 | } | 
|---|
|  | 58 |  | 
|---|
|  | 59 | const Vector& AtomInfo::getPosition() const | 
|---|
|  | 60 | { | 
|---|
|  | 61 | return AtomicPosition; | 
|---|
| [f16a4b] | 62 | } | 
|---|
|  | 63 |  | 
|---|
| [ead4e6] | 64 | void AtomInfo::setType(const element* _type) { | 
|---|
| [d74077] | 65 | AtomicElement = _type; | 
|---|
| [f16a4b] | 66 | } | 
|---|
|  | 67 |  | 
|---|
| [d74077] | 68 | void AtomInfo::setType(const int Z) { | 
|---|
| [ead4e6] | 69 | const element *elem = World::getInstance().getPeriode()->FindElement(Z); | 
|---|
| [f16a4b] | 70 | setType(elem); | 
|---|
|  | 71 | } | 
|---|
| [d74077] | 72 |  | 
|---|
|  | 73 | void AtomInfo::setPosition(const Vector& _vector) | 
|---|
|  | 74 | { | 
|---|
|  | 75 | AtomicPosition = _vector; | 
|---|
|  | 76 | //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl; | 
|---|
|  | 77 | } | 
|---|
|  | 78 |  | 
|---|
|  | 79 | const VectorInterface& AtomInfo::operator+=(const Vector& b) | 
|---|
|  | 80 | { | 
|---|
|  | 81 | AtomicPosition += b; | 
|---|
|  | 82 | return *this; | 
|---|
|  | 83 | } | 
|---|
|  | 84 |  | 
|---|
|  | 85 | const VectorInterface& AtomInfo::operator-=(const Vector& b) | 
|---|
|  | 86 | { | 
|---|
|  | 87 | AtomicPosition -= b; | 
|---|
|  | 88 | return *this; | 
|---|
|  | 89 | } | 
|---|
|  | 90 |  | 
|---|
|  | 91 | Vector const AtomInfo::operator+(const Vector& b) const | 
|---|
|  | 92 | { | 
|---|
|  | 93 | Vector a(AtomicPosition); | 
|---|
|  | 94 | a += b; | 
|---|
|  | 95 | return a; | 
|---|
|  | 96 | } | 
|---|
|  | 97 |  | 
|---|
|  | 98 | Vector const AtomInfo::operator-(const Vector& b) const | 
|---|
|  | 99 | { | 
|---|
|  | 100 | Vector a(AtomicPosition); | 
|---|
|  | 101 | a -= b; | 
|---|
|  | 102 | return a; | 
|---|
|  | 103 | } | 
|---|
|  | 104 |  | 
|---|
|  | 105 | double AtomInfo::distance(const Vector &point) const | 
|---|
|  | 106 | { | 
|---|
|  | 107 | return AtomicPosition.distance(point); | 
|---|
|  | 108 | } | 
|---|
|  | 109 |  | 
|---|
|  | 110 | double AtomInfo::DistanceSquared(const Vector &y) const | 
|---|
|  | 111 | { | 
|---|
|  | 112 | return AtomicPosition.DistanceSquared(y); | 
|---|
|  | 113 | } | 
|---|
|  | 114 |  | 
|---|
|  | 115 | double AtomInfo::distance(const VectorInterface &_atom) const | 
|---|
|  | 116 | { | 
|---|
|  | 117 | return _atom.distance(AtomicPosition); | 
|---|
|  | 118 | } | 
|---|
|  | 119 |  | 
|---|
|  | 120 | double AtomInfo::DistanceSquared(const VectorInterface &_atom) const | 
|---|
|  | 121 | { | 
|---|
|  | 122 | return _atom.DistanceSquared(AtomicPosition); | 
|---|
|  | 123 | } | 
|---|
|  | 124 |  | 
|---|
|  | 125 | VectorInterface &AtomInfo::operator=(const Vector& _vector) | 
|---|
|  | 126 | { | 
|---|
|  | 127 | AtomicPosition = _vector; | 
|---|
|  | 128 | return *this; | 
|---|
|  | 129 | } | 
|---|
|  | 130 |  | 
|---|
|  | 131 | void AtomInfo::ScaleAll(const double *factor) | 
|---|
|  | 132 | { | 
|---|
|  | 133 | AtomicPosition.ScaleAll(factor); | 
|---|
|  | 134 | } | 
|---|
|  | 135 |  | 
|---|
|  | 136 | void AtomInfo::ScaleAll(const Vector &factor) | 
|---|
|  | 137 | { | 
|---|
|  | 138 | AtomicPosition.ScaleAll(factor); | 
|---|
|  | 139 | } | 
|---|
|  | 140 |  | 
|---|
|  | 141 | void AtomInfo::Scale(const double factor) | 
|---|
|  | 142 | { | 
|---|
|  | 143 | AtomicPosition.Scale(factor); | 
|---|
|  | 144 | } | 
|---|
|  | 145 |  | 
|---|
|  | 146 | void AtomInfo::Zero() | 
|---|
|  | 147 | { | 
|---|
|  | 148 | AtomicPosition.Zero(); | 
|---|
|  | 149 | } | 
|---|
|  | 150 |  | 
|---|
|  | 151 | void AtomInfo::One(const double one) | 
|---|
|  | 152 | { | 
|---|
|  | 153 | AtomicPosition.One(one); | 
|---|
|  | 154 | } | 
|---|
|  | 155 |  | 
|---|
|  | 156 | void AtomInfo::LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors) | 
|---|
|  | 157 | { | 
|---|
|  | 158 | AtomicPosition.LinearCombinationOfVectors(x1,x2,x3,factors); | 
|---|
|  | 159 | } | 
|---|
|  | 160 |  | 
|---|
|  | 161 | const AtomInfo& operator*=(AtomInfo& a, const double m) | 
|---|
|  | 162 | { | 
|---|
|  | 163 | a.Scale(m); | 
|---|
|  | 164 | return a; | 
|---|
|  | 165 | } | 
|---|
|  | 166 |  | 
|---|
|  | 167 | AtomInfo const operator*(const AtomInfo& a, const double m) | 
|---|
|  | 168 | { | 
|---|
|  | 169 | AtomInfo copy(a); | 
|---|
|  | 170 | copy *= m; | 
|---|
|  | 171 | return copy; | 
|---|
|  | 172 | } | 
|---|
|  | 173 |  | 
|---|
|  | 174 | AtomInfo const operator*(const double m, const AtomInfo& a) | 
|---|
|  | 175 | { | 
|---|
|  | 176 | AtomInfo copy(a); | 
|---|
|  | 177 | copy *= m; | 
|---|
|  | 178 | return copy; | 
|---|
|  | 179 | } | 
|---|
|  | 180 |  | 
|---|
|  | 181 | std::ostream & AtomInfo::operator << (std::ostream &ost) const | 
|---|
|  | 182 | { | 
|---|
|  | 183 | return (ost << getPosition()); | 
|---|
|  | 184 | } | 
|---|
|  | 185 |  | 
|---|
|  | 186 | std::ostream & operator << (std::ostream &ost, const AtomInfo &a) | 
|---|
|  | 187 | { | 
|---|
|  | 188 | ost << a; | 
|---|
|  | 189 | return ost; | 
|---|
|  | 190 | } | 
|---|
|  | 191 |  | 
|---|