| 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 | double AtomInfo::getMass() const{
|
|---|
| 86 | return getType()->getMass();
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | void AtomInfo::setPosition(const Vector& _vector)
|
|---|
| 90 | {
|
|---|
| 91 | AtomicPosition = _vector;
|
|---|
| 92 | //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl;
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | const VectorInterface& AtomInfo::operator+=(const Vector& b)
|
|---|
| 96 | {
|
|---|
| 97 | AtomicPosition += b;
|
|---|
| 98 | return *this;
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | const VectorInterface& AtomInfo::operator-=(const Vector& b)
|
|---|
| 102 | {
|
|---|
| 103 | AtomicPosition -= b;
|
|---|
| 104 | return *this;
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 | Vector const AtomInfo::operator+(const Vector& b) const
|
|---|
| 108 | {
|
|---|
| 109 | Vector a(AtomicPosition);
|
|---|
| 110 | a += b;
|
|---|
| 111 | return a;
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | Vector const AtomInfo::operator-(const Vector& b) const
|
|---|
| 115 | {
|
|---|
| 116 | Vector a(AtomicPosition);
|
|---|
| 117 | a -= b;
|
|---|
| 118 | return a;
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | double AtomInfo::distance(const Vector &point) const
|
|---|
| 122 | {
|
|---|
| 123 | return AtomicPosition.distance(point);
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | double AtomInfo::DistanceSquared(const Vector &y) const
|
|---|
| 127 | {
|
|---|
| 128 | return AtomicPosition.DistanceSquared(y);
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | double AtomInfo::distance(const VectorInterface &_atom) const
|
|---|
| 132 | {
|
|---|
| 133 | return _atom.distance(AtomicPosition);
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | double AtomInfo::DistanceSquared(const VectorInterface &_atom) const
|
|---|
| 137 | {
|
|---|
| 138 | return _atom.DistanceSquared(AtomicPosition);
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 | VectorInterface &AtomInfo::operator=(const Vector& _vector)
|
|---|
| 142 | {
|
|---|
| 143 | AtomicPosition = _vector;
|
|---|
| 144 | return *this;
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | void AtomInfo::ScaleAll(const double *factor)
|
|---|
| 148 | {
|
|---|
| 149 | AtomicPosition.ScaleAll(factor);
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | void AtomInfo::ScaleAll(const Vector &factor)
|
|---|
| 153 | {
|
|---|
| 154 | AtomicPosition.ScaleAll(factor);
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | void AtomInfo::Scale(const double factor)
|
|---|
| 158 | {
|
|---|
| 159 | AtomicPosition.Scale(factor);
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | void AtomInfo::Zero()
|
|---|
| 163 | {
|
|---|
| 164 | AtomicPosition.Zero();
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | void AtomInfo::One(const double one)
|
|---|
| 168 | {
|
|---|
| 169 | AtomicPosition.One(one);
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | void AtomInfo::LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors)
|
|---|
| 173 | {
|
|---|
| 174 | AtomicPosition.LinearCombinationOfVectors(x1,x2,x3,factors);
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | const AtomInfo& operator*=(AtomInfo& a, const double m)
|
|---|
| 178 | {
|
|---|
| 179 | a.Scale(m);
|
|---|
| 180 | return a;
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | AtomInfo const operator*(const AtomInfo& a, const double m)
|
|---|
| 184 | {
|
|---|
| 185 | AtomInfo copy(a);
|
|---|
| 186 | copy *= m;
|
|---|
| 187 | return copy;
|
|---|
| 188 | }
|
|---|
| 189 |
|
|---|
| 190 | AtomInfo const operator*(const double m, const AtomInfo& a)
|
|---|
| 191 | {
|
|---|
| 192 | AtomInfo copy(a);
|
|---|
| 193 | copy *= m;
|
|---|
| 194 | return copy;
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | std::ostream & AtomInfo::operator << (std::ostream &ost) const
|
|---|
| 198 | {
|
|---|
| 199 | return (ost << getPosition());
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 202 | std::ostream & operator << (std::ostream &ost, const AtomInfo &a)
|
|---|
| 203 | {
|
|---|
| 204 | ost << a;
|
|---|
| 205 | return ost;
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|