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