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