| [6b919f8] | 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 |  | 
|---|
| [54b42e] | 21 | #include <vector> | 
|---|
|  | 22 |  | 
|---|
| [7188b1] | 23 | #include "atom_observable.hpp" | 
|---|
|  | 24 |  | 
|---|
| [57f243] | 25 | #include "LinearAlgebra/Vector.hpp" | 
|---|
| [8f4df1] | 26 | #include "LinearAlgebra/VectorInterface.hpp" | 
|---|
| [6b919f8] | 27 |  | 
|---|
|  | 28 | /****************************************** forward declarations *****************************/ | 
|---|
|  | 29 |  | 
|---|
| [d74077] | 30 | class AtomInfo; | 
|---|
| [6b919f8] | 31 | class element; | 
|---|
| [6625c3] | 32 | class ForceMatrix; | 
|---|
| [cca9ef] | 33 | class RealSpaceMatrix; | 
|---|
| [6b919f8] | 34 |  | 
|---|
|  | 35 | /********************************************** declarations *******************************/ | 
|---|
|  | 36 |  | 
|---|
| [7188b1] | 37 | class AtomInfo : public VectorInterface, public virtual AtomObservable  { | 
|---|
| [d74077] | 38 |  | 
|---|
| [6b919f8] | 39 | public: | 
|---|
|  | 40 | AtomInfo(); | 
|---|
| [d74077] | 41 | AtomInfo(const AtomInfo &_atom); | 
|---|
|  | 42 | AtomInfo(const VectorInterface &_v); | 
|---|
|  | 43 | virtual ~AtomInfo(); | 
|---|
| [6b919f8] | 44 |  | 
|---|
| [e2373df] | 45 | /** Pushes back another step in all trajectory vectors. | 
|---|
|  | 46 | * | 
|---|
|  | 47 | * This allows to extend all trajectories contained in different classes | 
|---|
|  | 48 | * consistently. This is implemented by the topmost class which calls the | 
|---|
|  | 49 | * real functions, \sa AppendTrajectoryStep(), by all necessary subclasses. | 
|---|
|  | 50 | */ | 
|---|
|  | 51 | virtual void UpdateSteps()=0; | 
|---|
|  | 52 |  | 
|---|
| [bce72c] | 53 | /** Getter for AtomicElement. | 
|---|
|  | 54 | * | 
|---|
|  | 55 | * @return constant reference to AtomicElement | 
|---|
|  | 56 | */ | 
|---|
| [d74077] | 57 | const element *getType() const; | 
|---|
| [bce72c] | 58 | /** Setter for AtomicElement. | 
|---|
|  | 59 | * | 
|---|
|  | 60 | * @param _type new element by pointer to set | 
|---|
|  | 61 | */ | 
|---|
|  | 62 | void setType(const element *_type); | 
|---|
|  | 63 | /** Setter for AtomicElement. | 
|---|
|  | 64 | * | 
|---|
|  | 65 | * @param _typenr new element by index to set | 
|---|
|  | 66 | */ | 
|---|
|  | 67 | void setType(const int _typenr); | 
|---|
|  | 68 |  | 
|---|
|  | 69 | /** Getter for AtomicVelocity. | 
|---|
| [6625c3] | 70 | * | 
|---|
|  | 71 | * Current time step is used. | 
|---|
| [bce72c] | 72 | * | 
|---|
|  | 73 | * @return constant reference to AtomicVelocity | 
|---|
|  | 74 | */ | 
|---|
| [056e70] | 75 | //  Vector& getAtomicVelocity(); | 
|---|
| [bce72c] | 76 | /** Getter for AtomicVelocity. | 
|---|
| [6625c3] | 77 | * | 
|---|
|  | 78 | * @param _step time step to return | 
|---|
|  | 79 | * @return constant reference to AtomicVelocity | 
|---|
|  | 80 | */ | 
|---|
| [056e70] | 81 | //  Vector& getAtomicVelocity(const int _step); | 
|---|
| [6625c3] | 82 | /** Getter for AtomicVelocity. | 
|---|
|  | 83 | * | 
|---|
|  | 84 | * Current time step is used. | 
|---|
| [bce72c] | 85 | * | 
|---|
|  | 86 | * @return constant reference to AtomicVelocity | 
|---|
|  | 87 | */ | 
|---|
|  | 88 | const Vector& getAtomicVelocity() const; | 
|---|
| [6625c3] | 89 | /** Getter for AtomicVelocity. | 
|---|
|  | 90 | * | 
|---|
|  | 91 | * @param _step time step to return | 
|---|
|  | 92 | * @return constant reference to AtomicVelocity | 
|---|
|  | 93 | */ | 
|---|
| [6b020f] | 94 | const Vector& getAtomicVelocityAtStep(const unsigned int _step) const; | 
|---|
| [bce72c] | 95 | /** Setter for AtomicVelocity. | 
|---|
| [6625c3] | 96 | * | 
|---|
|  | 97 | * Current time step is used. | 
|---|
| [bce72c] | 98 | * | 
|---|
|  | 99 | * @param _newvelocity new velocity to set | 
|---|
|  | 100 | */ | 
|---|
|  | 101 | void setAtomicVelocity(const Vector &_newvelocity); | 
|---|
| [6625c3] | 102 | /** Setter for AtomicVelocity. | 
|---|
|  | 103 | * | 
|---|
|  | 104 | * @param _step time step to set | 
|---|
|  | 105 | * @param _newvelocity new velocity to set | 
|---|
|  | 106 | */ | 
|---|
| [6b020f] | 107 | void setAtomicVelocityAtStep(const unsigned int _step, const Vector &_newvelocity); | 
|---|
| [bce72c] | 108 |  | 
|---|
|  | 109 | /** Getter for AtomicForce. | 
|---|
| [6625c3] | 110 | * | 
|---|
|  | 111 | * Current time step is used. | 
|---|
| [bce72c] | 112 | * | 
|---|
|  | 113 | * @return constant reference to AtomicForce | 
|---|
|  | 114 | */ | 
|---|
|  | 115 | const Vector& getAtomicForce() const; | 
|---|
| [6625c3] | 116 | /** Getter for AtomicForce. | 
|---|
|  | 117 | * | 
|---|
|  | 118 | * @param _step time step to return | 
|---|
|  | 119 | * @return constant reference to AtomicForce | 
|---|
|  | 120 | */ | 
|---|
| [6b020f] | 121 | const Vector& getAtomicForceAtStep(const unsigned int _step) const; | 
|---|
| [bce72c] | 122 | /** Setter for AtomicForce. | 
|---|
| [6625c3] | 123 | * | 
|---|
|  | 124 | * Current time step is used. | 
|---|
| [bce72c] | 125 | * | 
|---|
|  | 126 | * @param _newvelocity new force vector to set | 
|---|
|  | 127 | */ | 
|---|
|  | 128 | void setAtomicForce(const Vector &_newforce); | 
|---|
| [6625c3] | 129 | /** Setter for AtomicForce. | 
|---|
|  | 130 | * | 
|---|
|  | 131 | * @param _step time step to set | 
|---|
|  | 132 | * @param _newvelocity new force vector to set | 
|---|
|  | 133 | */ | 
|---|
| [6b020f] | 134 | void setAtomicForceAtStep(const unsigned int _step, const Vector &_newforce); | 
|---|
| [6625c3] | 135 |  | 
|---|
|  | 136 | /** Getter for FixedIon. | 
|---|
|  | 137 | * | 
|---|
|  | 138 | * @return constant reference to FixedIon | 
|---|
|  | 139 | */ | 
|---|
|  | 140 | bool getFixedIon() const; | 
|---|
|  | 141 | /** Setter for FixedIon. | 
|---|
|  | 142 | * | 
|---|
|  | 143 | * @param _fixedion new state of FixedIon | 
|---|
|  | 144 | */ | 
|---|
|  | 145 | void setFixedIon(const bool _fixedion); | 
|---|
| [d74077] | 146 |  | 
|---|
|  | 147 | ///// manipulation of the atomic position | 
|---|
|  | 148 |  | 
|---|
|  | 149 | // Accessors ussually come in pairs... and sometimes even more than that | 
|---|
| [6625c3] | 150 | /** Getter for AtomicPosition. | 
|---|
|  | 151 | * | 
|---|
|  | 152 | * Current time step is used. | 
|---|
|  | 153 | * | 
|---|
|  | 154 | * @param i component of vector | 
|---|
|  | 155 | * @return i-th component of atomic position | 
|---|
|  | 156 | */ | 
|---|
| [d74077] | 157 | const double& operator[](size_t i) const; | 
|---|
| [6625c3] | 158 | /** Getter for AtomicPosition. | 
|---|
|  | 159 | * | 
|---|
|  | 160 | * Current time step is used. | 
|---|
|  | 161 | * | 
|---|
|  | 162 | * \sa operator[], this is if instance is a reference. | 
|---|
|  | 163 | * | 
|---|
|  | 164 | * @param i component of vector | 
|---|
|  | 165 | * @return i-th component of atomic position | 
|---|
|  | 166 | */ | 
|---|
| [d74077] | 167 | const double& at(size_t i) const; | 
|---|
| [6625c3] | 168 | /** Getter for AtomicPosition. | 
|---|
|  | 169 | * | 
|---|
|  | 170 | * \sa operator[], this is if instance is a reference. | 
|---|
|  | 171 | * | 
|---|
|  | 172 | * @param i index of component of AtomicPosition | 
|---|
|  | 173 | * @param _step time step to return | 
|---|
|  | 174 | * @return atomic position at time step _step | 
|---|
|  | 175 | */ | 
|---|
| [6b020f] | 176 | const double& atStep(size_t i, unsigned int _step) const; | 
|---|
| [6625c3] | 177 | /** Setter for AtomicPosition. | 
|---|
|  | 178 | * | 
|---|
|  | 179 | * Current time step is used. | 
|---|
|  | 180 | * | 
|---|
|  | 181 | * @param i component to set | 
|---|
|  | 182 | * @param value value to set to | 
|---|
|  | 183 | */ | 
|---|
| [d74077] | 184 | void set(size_t i, const double value); | 
|---|
| [6625c3] | 185 | /** Setter for AtomicPosition. | 
|---|
|  | 186 | * | 
|---|
|  | 187 | * @param i component to set | 
|---|
|  | 188 | * @param _step time step to set | 
|---|
|  | 189 | * @param value value to set to | 
|---|
|  | 190 | */ | 
|---|
| [6b020f] | 191 | void setAtStep(size_t i, unsigned int _step, const double value); | 
|---|
| [6625c3] | 192 | /** Getter for AtomicPosition. | 
|---|
|  | 193 | * | 
|---|
|  | 194 | * Current time step is used. | 
|---|
|  | 195 | * | 
|---|
|  | 196 | * @return atomic position | 
|---|
|  | 197 | */ | 
|---|
| [d74077] | 198 | const Vector& getPosition() const; | 
|---|
| [6625c3] | 199 | /** Getter for AtomicPosition. | 
|---|
|  | 200 | * | 
|---|
|  | 201 | * @param _step time step to return | 
|---|
|  | 202 | * @return atomic position at time step _step | 
|---|
|  | 203 | */ | 
|---|
| [6b020f] | 204 | const Vector& getPositionAtStep(unsigned int _step) const; | 
|---|
| [d74077] | 205 |  | 
|---|
|  | 206 | // Assignment operator | 
|---|
| [6625c3] | 207 | /** Setter for AtomicPosition. | 
|---|
|  | 208 | * | 
|---|
|  | 209 | * Current time step is used. | 
|---|
|  | 210 | * | 
|---|
|  | 211 | * @param _vector new position to set | 
|---|
|  | 212 | */ | 
|---|
| [d74077] | 213 | void setPosition(const Vector& _vector); | 
|---|
| [6625c3] | 214 | /** Setter for AtomicPosition. | 
|---|
|  | 215 | * | 
|---|
|  | 216 | * @param _step time step to set | 
|---|
|  | 217 | * @param _vector new position to set for time step _step | 
|---|
|  | 218 | */ | 
|---|
| [6b020f] | 219 | void setPositionAtStep(const unsigned int _step, const Vector& _vector); | 
|---|
| [d74077] | 220 | class VectorInterface &operator=(const Vector& _vector); | 
|---|
|  | 221 |  | 
|---|
|  | 222 | // operators for mathematical operations | 
|---|
|  | 223 | const VectorInterface& operator+=(const Vector& b); | 
|---|
|  | 224 | const VectorInterface& operator-=(const Vector& b); | 
|---|
|  | 225 | Vector const operator+(const Vector& b) const; | 
|---|
|  | 226 | Vector const operator-(const Vector& b) const; | 
|---|
|  | 227 |  | 
|---|
|  | 228 | void Zero(); | 
|---|
|  | 229 | void One(const double one); | 
|---|
|  | 230 | void LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors); | 
|---|
|  | 231 |  | 
|---|
|  | 232 | double distance(const Vector &point) const; | 
|---|
|  | 233 | double DistanceSquared(const Vector &y) const; | 
|---|
|  | 234 | double distance(const VectorInterface &_atom) const; | 
|---|
|  | 235 | double DistanceSquared(const VectorInterface &_atom) const; | 
|---|
|  | 236 |  | 
|---|
|  | 237 | void ScaleAll(const double *factor); | 
|---|
|  | 238 | void ScaleAll(const Vector &factor); | 
|---|
|  | 239 | void Scale(const double factor); | 
|---|
|  | 240 |  | 
|---|
| [6625c3] | 241 | // operations for trajectories | 
|---|
|  | 242 | void ResizeTrajectory(size_t MaxSteps); | 
|---|
|  | 243 | size_t getTrajectorySize() const; | 
|---|
| [6b020f] | 244 | void CopyStepOnStep(const unsigned int dest, const unsigned int src); | 
|---|
| [435065] | 245 | void VelocityVerletUpdate(int nr, const unsigned int NextStep, double Deltat, bool IsAngstroem, ForceMatrix *Force, const size_t offset); | 
|---|
| [6b020f] | 246 | double getKineticEnergy(const unsigned int step) const; | 
|---|
|  | 247 | Vector getMomentum(const unsigned int step) const; | 
|---|
| [6625c3] | 248 | double getMass() const; | 
|---|
|  | 249 |  | 
|---|
| [d74077] | 250 | std::ostream & operator << (std::ostream &ost) const; | 
|---|
| [f16a4b] | 251 |  | 
|---|
| [443547] | 252 | protected: | 
|---|
| [e2373df] | 253 | /** Function used by this and inheriting classes to extend the trajectory | 
|---|
|  | 254 | * vectors. | 
|---|
|  | 255 | */ | 
|---|
|  | 256 | void AppendTrajectoryStep(); | 
|---|
|  | 257 |  | 
|---|
| [443547] | 258 | // make these protected only such that deriving atom class still has full | 
|---|
|  | 259 | // access needed for clone and alike | 
|---|
| [54b42e] | 260 | std::vector<Vector> AtomicPosition;       //!< coordinate vector of atom, giving last position within cell | 
|---|
|  | 261 | std::vector<Vector> AtomicVelocity;       //!< velocity vector of atom, giving last velocity within cell | 
|---|
|  | 262 | std::vector<Vector> AtomicForce;       //!< Force vector of atom, giving last force within cell | 
|---|
| [bce72c] | 263 |  | 
|---|
| [443547] | 264 | private: | 
|---|
| [d74077] | 265 | const element *AtomicElement;  //!< pointing to element | 
|---|
| [6625c3] | 266 | bool FixedIon; | 
|---|
| [6b919f8] | 267 | }; | 
|---|
|  | 268 |  | 
|---|
| [d74077] | 269 | std::ostream & operator << (std::ostream &ost, const AtomInfo &a); | 
|---|
|  | 270 |  | 
|---|
| [fb0b62] | 271 | //const AtomInfo& operator*=(AtomInfo& a, const double m); | 
|---|
|  | 272 | //AtomInfo const operator*(const AtomInfo& a, const double m); | 
|---|
|  | 273 | //AtomInfo const operator*(const double m, const AtomInfo& a); | 
|---|
| [d74077] | 274 |  | 
|---|
| [6b919f8] | 275 | #endif /* ATOM_ATOMINFO_HPP_ */ | 
|---|