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