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