| 1 | /*
|
|---|
| 2 | * atom_atominfo.hpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: Oct 19, 2009
|
|---|
| 5 | * Author: heber
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #ifndef ATOM_ATOMINFO_HPP_
|
|---|
| 9 | #define ATOM_ATOMINFO_HPP_
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 | using namespace std;
|
|---|
| 13 |
|
|---|
| 14 | /*********************************************** includes ***********************************/
|
|---|
| 15 |
|
|---|
| 16 | // include config.h
|
|---|
| 17 | #ifdef HAVE_CONFIG_H
|
|---|
| 18 | #include <config.h>
|
|---|
| 19 | #endif
|
|---|
| 20 |
|
|---|
| 21 | #include <vector>
|
|---|
| 22 |
|
|---|
| 23 | #include "LinearAlgebra/Vector.hpp"
|
|---|
| 24 | #include "LinearAlgebra/VectorInterface.hpp"
|
|---|
| 25 |
|
|---|
| 26 | /****************************************** forward declarations *****************************/
|
|---|
| 27 |
|
|---|
| 28 | class AtomInfo;
|
|---|
| 29 | class config;
|
|---|
| 30 | class element;
|
|---|
| 31 | class ForceMatrix;
|
|---|
| 32 | class RealSpaceMatrix;
|
|---|
| 33 |
|
|---|
| 34 | /********************************************** declarations *******************************/
|
|---|
| 35 |
|
|---|
| 36 | class AtomInfo : public VectorInterface {
|
|---|
| 37 |
|
|---|
| 38 | public:
|
|---|
| 39 | AtomInfo();
|
|---|
| 40 | AtomInfo(const AtomInfo &_atom);
|
|---|
| 41 | AtomInfo(const VectorInterface &_v);
|
|---|
| 42 | virtual ~AtomInfo();
|
|---|
| 43 |
|
|---|
| 44 | /** Getter for AtomicElement.
|
|---|
| 45 | *
|
|---|
| 46 | * @return constant reference to AtomicElement
|
|---|
| 47 | */
|
|---|
| 48 | const element *getType() const;
|
|---|
| 49 | /** Setter for AtomicElement.
|
|---|
| 50 | *
|
|---|
| 51 | * @param _type new element by pointer to set
|
|---|
| 52 | */
|
|---|
| 53 | void setType(const element *_type);
|
|---|
| 54 | /** Setter for AtomicElement.
|
|---|
| 55 | *
|
|---|
| 56 | * @param _typenr new element by index to set
|
|---|
| 57 | */
|
|---|
| 58 | void setType(const int _typenr);
|
|---|
| 59 |
|
|---|
| 60 | /** Getter for AtomicVelocity.
|
|---|
| 61 | *
|
|---|
| 62 | * Current time step is used.
|
|---|
| 63 | *
|
|---|
| 64 | * @return constant reference to AtomicVelocity
|
|---|
| 65 | */
|
|---|
| 66 | Vector& getAtomicVelocity();
|
|---|
| 67 | /** Getter for AtomicVelocity.
|
|---|
| 68 | *
|
|---|
| 69 | * @param _step time step to return
|
|---|
| 70 | * @return constant reference to AtomicVelocity
|
|---|
| 71 | */
|
|---|
| 72 | Vector& getAtomicVelocity(const int _step);
|
|---|
| 73 | /** Getter for AtomicVelocity.
|
|---|
| 74 | *
|
|---|
| 75 | * Current time step is used.
|
|---|
| 76 | *
|
|---|
| 77 | * @return constant reference to AtomicVelocity
|
|---|
| 78 | */
|
|---|
| 79 | const Vector& getAtomicVelocity() const;
|
|---|
| 80 | /** Getter for AtomicVelocity.
|
|---|
| 81 | *
|
|---|
| 82 | * @param _step time step to return
|
|---|
| 83 | * @return constant reference to AtomicVelocity
|
|---|
| 84 | */
|
|---|
| 85 | const Vector& getAtomicVelocity(const int _step) const;
|
|---|
| 86 | /** Setter for AtomicVelocity.
|
|---|
| 87 | *
|
|---|
| 88 | * Current time step is used.
|
|---|
| 89 | *
|
|---|
| 90 | * @param _newvelocity new velocity to set
|
|---|
| 91 | */
|
|---|
| 92 | void setAtomicVelocity(const Vector &_newvelocity);
|
|---|
| 93 | /** Setter for AtomicVelocity.
|
|---|
| 94 | *
|
|---|
| 95 | * @param _step time step to set
|
|---|
| 96 | * @param _newvelocity new velocity to set
|
|---|
| 97 | */
|
|---|
| 98 | void setAtomicVelocity(const int _step, const Vector &_newvelocity);
|
|---|
| 99 |
|
|---|
| 100 | /** Getter for AtomicForce.
|
|---|
| 101 | *
|
|---|
| 102 | * Current time step is used.
|
|---|
| 103 | *
|
|---|
| 104 | * @return constant reference to AtomicForce
|
|---|
| 105 | */
|
|---|
| 106 | const Vector& getAtomicForce() const;
|
|---|
| 107 | /** Getter for AtomicForce.
|
|---|
| 108 | *
|
|---|
| 109 | * @param _step time step to return
|
|---|
| 110 | * @return constant reference to AtomicForce
|
|---|
| 111 | */
|
|---|
| 112 | const Vector& getAtomicForce(const int _step) const;
|
|---|
| 113 | /** Setter for AtomicForce.
|
|---|
| 114 | *
|
|---|
| 115 | * Current time step is used.
|
|---|
| 116 | *
|
|---|
| 117 | * @param _newvelocity new force vector to set
|
|---|
| 118 | */
|
|---|
| 119 | void setAtomicForce(const Vector &_newforce);
|
|---|
| 120 | /** Setter for AtomicForce.
|
|---|
| 121 | *
|
|---|
| 122 | * @param _step time step to set
|
|---|
| 123 | * @param _newvelocity new force vector to set
|
|---|
| 124 | */
|
|---|
| 125 | void setAtomicForce(const int _step, const Vector &_newforce);
|
|---|
| 126 |
|
|---|
| 127 | /** Getter for FixedIon.
|
|---|
| 128 | *
|
|---|
| 129 | * @return constant reference to FixedIon
|
|---|
| 130 | */
|
|---|
| 131 | bool getFixedIon() const;
|
|---|
| 132 | /** Setter for FixedIon.
|
|---|
| 133 | *
|
|---|
| 134 | * @param _fixedion new state of FixedIon
|
|---|
| 135 | */
|
|---|
| 136 | void setFixedIon(const bool _fixedion);
|
|---|
| 137 |
|
|---|
| 138 | ///// manipulation of the atomic position
|
|---|
| 139 |
|
|---|
| 140 | // Accessors ussually come in pairs... and sometimes even more than that
|
|---|
| 141 | /** Getter for AtomicPosition.
|
|---|
| 142 | *
|
|---|
| 143 | * Current time step is used.
|
|---|
| 144 | *
|
|---|
| 145 | * @param i component of vector
|
|---|
| 146 | * @return i-th component of atomic position
|
|---|
| 147 | */
|
|---|
| 148 | const double& operator[](size_t i) const;
|
|---|
| 149 | /** Getter for AtomicPosition.
|
|---|
| 150 | *
|
|---|
| 151 | * Current time step is used.
|
|---|
| 152 | *
|
|---|
| 153 | * \sa operator[], this is if instance is a reference.
|
|---|
| 154 | *
|
|---|
| 155 | * @param i component of vector
|
|---|
| 156 | * @return i-th component of atomic position
|
|---|
| 157 | */
|
|---|
| 158 | const double& at(size_t i) const;
|
|---|
| 159 | /** Getter for AtomicPosition.
|
|---|
| 160 | *
|
|---|
| 161 | * \sa operator[], this is if instance is a reference.
|
|---|
| 162 | *
|
|---|
| 163 | * @param i index of component of AtomicPosition
|
|---|
| 164 | * @param _step time step to return
|
|---|
| 165 | * @return atomic position at time step _step
|
|---|
| 166 | */
|
|---|
| 167 | const Vector& atStep(size_t i, int _step) const;
|
|---|
| 168 | /** Setter for AtomicPosition.
|
|---|
| 169 | *
|
|---|
| 170 | * Current time step is used.
|
|---|
| 171 | *
|
|---|
| 172 | * @param i component to set
|
|---|
| 173 | * @param value value to set to
|
|---|
| 174 | */
|
|---|
| 175 | void set(size_t i, const double value);
|
|---|
| 176 | /** Setter for AtomicPosition.
|
|---|
| 177 | *
|
|---|
| 178 | * @param i component to set
|
|---|
| 179 | * @param _step time step to set
|
|---|
| 180 | * @param value value to set to
|
|---|
| 181 | */
|
|---|
| 182 | void setAtStep(size_t i, int _step, const double value);
|
|---|
| 183 | /** Getter for AtomicPosition.
|
|---|
| 184 | *
|
|---|
| 185 | * Current time step is used.
|
|---|
| 186 | *
|
|---|
| 187 | * @return atomic position
|
|---|
| 188 | */
|
|---|
| 189 | const Vector& getPosition() const;
|
|---|
| 190 | /** Getter for AtomicPosition.
|
|---|
| 191 | *
|
|---|
| 192 | * @param _step time step to return
|
|---|
| 193 | * @return atomic position at time step _step
|
|---|
| 194 | */
|
|---|
| 195 | const Vector& getPosition(int _step) const;
|
|---|
| 196 |
|
|---|
| 197 | // Assignment operator
|
|---|
| 198 | /** Setter for AtomicPosition.
|
|---|
| 199 | *
|
|---|
| 200 | * Current time step is used.
|
|---|
| 201 | *
|
|---|
| 202 | * @param _vector new position to set
|
|---|
| 203 | */
|
|---|
| 204 | void setPosition(const Vector& _vector);
|
|---|
| 205 | /** Setter for AtomicPosition.
|
|---|
| 206 | *
|
|---|
| 207 | * @param _step time step to set
|
|---|
| 208 | * @param _vector new position to set for time step _step
|
|---|
| 209 | */
|
|---|
| 210 | void setPosition(int _step, const Vector& _vector);
|
|---|
| 211 | class VectorInterface &operator=(const Vector& _vector);
|
|---|
| 212 |
|
|---|
| 213 | // operators for mathematical operations
|
|---|
| 214 | const VectorInterface& operator+=(const Vector& b);
|
|---|
| 215 | const VectorInterface& operator-=(const Vector& b);
|
|---|
| 216 | Vector const operator+(const Vector& b) const;
|
|---|
| 217 | Vector const operator-(const Vector& b) const;
|
|---|
| 218 |
|
|---|
| 219 | void Zero();
|
|---|
| 220 | void One(const double one);
|
|---|
| 221 | void LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors);
|
|---|
| 222 |
|
|---|
| 223 | double distance(const Vector &point) const;
|
|---|
| 224 | double DistanceSquared(const Vector &y) const;
|
|---|
| 225 | double distance(const VectorInterface &_atom) const;
|
|---|
| 226 | double DistanceSquared(const VectorInterface &_atom) const;
|
|---|
| 227 |
|
|---|
| 228 | void ScaleAll(const double *factor);
|
|---|
| 229 | void ScaleAll(const Vector &factor);
|
|---|
| 230 | void Scale(const double factor);
|
|---|
| 231 |
|
|---|
| 232 | // operations for trajectories
|
|---|
| 233 | void ResizeTrajectory(size_t MaxSteps);
|
|---|
| 234 | size_t getTrajectorySize() const;
|
|---|
| 235 | void CopyStepOnStep(int dest, int src);
|
|---|
| 236 | void VelocityVerletUpdate(int nr, int MDSteps, config *configuration, ForceMatrix *Force, const size_t offset);
|
|---|
| 237 | double getKineticEnergy(unsigned int step) const;
|
|---|
| 238 | Vector getMomentum(unsigned int step) const;
|
|---|
| 239 | double getMass() const;
|
|---|
| 240 |
|
|---|
| 241 | std::ostream & operator << (std::ostream &ost) const;
|
|---|
| 242 |
|
|---|
| 243 | private:
|
|---|
| 244 | std::vector<Vector> AtomicPosition; //!< coordinate vector of atom, giving last position within cell
|
|---|
| 245 | std::vector<Vector> AtomicVelocity; //!< velocity vector of atom, giving last velocity within cell
|
|---|
| 246 | std::vector<Vector> AtomicForce; //!< Force vector of atom, giving last force within cell
|
|---|
| 247 |
|
|---|
| 248 | const element *AtomicElement; //!< pointing to element
|
|---|
| 249 | bool FixedIon;
|
|---|
| 250 | };
|
|---|
| 251 |
|
|---|
| 252 | std::ostream & operator << (std::ostream &ost, const AtomInfo &a);
|
|---|
| 253 |
|
|---|
| 254 | const AtomInfo& operator*=(AtomInfo& a, const double m);
|
|---|
| 255 | AtomInfo const operator*(const AtomInfo& a, const double m);
|
|---|
| 256 | AtomInfo const operator*(const double m, const AtomInfo& a);
|
|---|
| 257 |
|
|---|
| 258 | #endif /* ATOM_ATOMINFO_HPP_ */
|
|---|