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