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