| [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 |    */
 | 
|---|
| [8cc22f] | 58 |   virtual void UpdateStep(const unsigned int _step)=0;
 | 
|---|
| [e2373df] | 59 | 
 | 
|---|
| [8c6b68] | 60 |   /** Pops all steps in the interval [\a _firststep, \a _laststep] in all trajectory vectors.
 | 
|---|
| [7e51e1] | 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
 | 
|---|
| [8c6b68] | 64 |    * the real functions, \sa removeTrajectorySteps(), by all necessary subclasses.
 | 
|---|
 | 65 |    *
 | 
|---|
 | 66 |    * \param _firststep first step in interval to be removed
 | 
|---|
 | 67 |    * \param _laststep last step in interval to be removed
 | 
|---|
| [7e51e1] | 68 |    */
 | 
|---|
| [8c6b68] | 69 |   virtual void removeSteps(const unsigned int _firststep, const unsigned int _laststep)=0;
 | 
|---|
| [7e51e1] | 70 | 
 | 
|---|
| [08a0f52] | 71 |   /** DEPRECATED: Getter for element indicated by AtomicElement.
 | 
|---|
 | 72 |    *
 | 
|---|
 | 73 |    * \deprecated This function is deprecated, use getElement() instead.
 | 
|---|
| [bce72c] | 74 |    *
 | 
|---|
| [08a0f52] | 75 |    * @return constant pointer to element for AtomicElement
 | 
|---|
| [bce72c] | 76 |    */
 | 
|---|
| [d74077] | 77 |   const element *getType() const;
 | 
|---|
| [08a0f52] | 78 | 
 | 
|---|
 | 79 |   /** Getter for element indicated by AtomicElement.
 | 
|---|
 | 80 |    *
 | 
|---|
 | 81 |    * \note Looking up the element requires looking the World instance and is
 | 
|---|
 | 82 |    * thus significantly slower than instead just returning the internally
 | 
|---|
 | 83 |    * stored atomicNumber_t. So, if possible use getElementNo() instead and
 | 
|---|
 | 84 |    * check soundly whether you truely need access to all of element's member
 | 
|---|
 | 85 |    * variables.
 | 
|---|
 | 86 |    *
 | 
|---|
 | 87 |    * @return const reference to element indicated by AtomicElement
 | 
|---|
 | 88 |    */
 | 
|---|
 | 89 |   const element & getElement() const;
 | 
|---|
 | 90 | 
 | 
|---|
 | 91 |   /** Getter for AtomicElement.
 | 
|---|
 | 92 |    *
 | 
|---|
 | 93 |    * @return AtomicElement
 | 
|---|
 | 94 |    */
 | 
|---|
 | 95 |   atomicNumber_t getElementNo() const;
 | 
|---|
 | 96 | 
 | 
|---|
| [843590] | 97 |   /** Getter for the name of Particle this atom is associated with.
 | 
|---|
 | 98 |    *
 | 
|---|
 | 99 |    * \return name of Particle to use in lookup in ParticleRegistry
 | 
|---|
 | 100 |    */
 | 
|---|
 | 101 |   const std::string &getParticleName() const;
 | 
|---|
 | 102 | 
 | 
|---|
 | 103 |   /** Setter for the Particle name this atom is associated with.
 | 
|---|
 | 104 |    *
 | 
|---|
 | 105 |    * \param _name new name of atom's Particle
 | 
|---|
 | 106 |    */
 | 
|---|
 | 107 |   void setParticleName(const std::string & _name);
 | 
|---|
 | 108 | 
 | 
|---|
| [bce72c] | 109 |   /** Setter for AtomicElement.
 | 
|---|
 | 110 |    *
 | 
|---|
 | 111 |    * @param _type new element by pointer to set
 | 
|---|
 | 112 |    */
 | 
|---|
 | 113 |   void setType(const element *_type);
 | 
|---|
 | 114 |   /** Setter for AtomicElement.
 | 
|---|
 | 115 |    *
 | 
|---|
 | 116 |    * @param _typenr new element by index to set
 | 
|---|
 | 117 |    */
 | 
|---|
 | 118 |   void setType(const int _typenr);
 | 
|---|
 | 119 | 
 | 
|---|
 | 120 |   /** Getter for AtomicVelocity.
 | 
|---|
| [6625c3] | 121 |    *
 | 
|---|
 | 122 |    * Current time step is used.
 | 
|---|
| [bce72c] | 123 |    *
 | 
|---|
 | 124 |    * @return constant reference to AtomicVelocity
 | 
|---|
 | 125 |    */
 | 
|---|
| [056e70] | 126 | //  Vector& getAtomicVelocity();
 | 
|---|
| [bce72c] | 127 |   /** Getter for AtomicVelocity.
 | 
|---|
| [6625c3] | 128 |    *
 | 
|---|
 | 129 |    * @param _step time step to return
 | 
|---|
 | 130 |    * @return constant reference to AtomicVelocity
 | 
|---|
 | 131 |    */
 | 
|---|
| [056e70] | 132 | //  Vector& getAtomicVelocity(const int _step);
 | 
|---|
| [6625c3] | 133 |   /** Getter for AtomicVelocity.
 | 
|---|
 | 134 |    *
 | 
|---|
 | 135 |    * Current time step is used.
 | 
|---|
| [bce72c] | 136 |    *
 | 
|---|
 | 137 |    * @return constant reference to AtomicVelocity
 | 
|---|
 | 138 |    */
 | 
|---|
 | 139 |   const Vector& getAtomicVelocity() const;
 | 
|---|
| [6625c3] | 140 |   /** Getter for AtomicVelocity.
 | 
|---|
 | 141 |    *
 | 
|---|
 | 142 |    * @param _step time step to return
 | 
|---|
 | 143 |    * @return constant reference to AtomicVelocity
 | 
|---|
 | 144 |    */
 | 
|---|
| [6b020f] | 145 |   const Vector& getAtomicVelocityAtStep(const unsigned int _step) const;
 | 
|---|
| [bce72c] | 146 |   /** Setter for AtomicVelocity.
 | 
|---|
| [6625c3] | 147 |    *
 | 
|---|
 | 148 |    * Current time step is used.
 | 
|---|
| [bce72c] | 149 |    *
 | 
|---|
 | 150 |    * @param _newvelocity new velocity to set
 | 
|---|
 | 151 |    */
 | 
|---|
 | 152 |   void setAtomicVelocity(const Vector &_newvelocity);
 | 
|---|
| [6625c3] | 153 |   /** Setter for AtomicVelocity.
 | 
|---|
 | 154 |    *
 | 
|---|
 | 155 |    * @param _step time step to set
 | 
|---|
 | 156 |    * @param _newvelocity new velocity to set
 | 
|---|
 | 157 |    */
 | 
|---|
| [6b020f] | 158 |   void setAtomicVelocityAtStep(const unsigned int _step, const Vector &_newvelocity);
 | 
|---|
| [bce72c] | 159 | 
 | 
|---|
 | 160 |   /** Getter for AtomicForce.
 | 
|---|
| [6625c3] | 161 |    *
 | 
|---|
 | 162 |    * Current time step is used.
 | 
|---|
| [bce72c] | 163 |    *
 | 
|---|
 | 164 |    * @return constant reference to AtomicForce
 | 
|---|
 | 165 |    */
 | 
|---|
 | 166 |   const Vector& getAtomicForce() const;
 | 
|---|
| [6625c3] | 167 |   /** Getter for AtomicForce.
 | 
|---|
 | 168 |    *
 | 
|---|
 | 169 |    * @param _step time step to return
 | 
|---|
 | 170 |    * @return constant reference to AtomicForce
 | 
|---|
 | 171 |    */
 | 
|---|
| [6b020f] | 172 |   const Vector& getAtomicForceAtStep(const unsigned int _step) const;
 | 
|---|
| [bce72c] | 173 |   /** Setter for AtomicForce.
 | 
|---|
| [6625c3] | 174 |    *
 | 
|---|
 | 175 |    * Current time step is used.
 | 
|---|
| [bce72c] | 176 |    *
 | 
|---|
 | 177 |    * @param _newvelocity new force vector to set
 | 
|---|
 | 178 |    */
 | 
|---|
 | 179 |   void setAtomicForce(const Vector &_newforce);
 | 
|---|
| [6625c3] | 180 |   /** Setter for AtomicForce.
 | 
|---|
 | 181 |    *
 | 
|---|
 | 182 |    * @param _step time step to set
 | 
|---|
 | 183 |    * @param _newvelocity new force vector to set
 | 
|---|
 | 184 |    */
 | 
|---|
| [6b020f] | 185 |   void setAtomicForceAtStep(const unsigned int _step, const Vector &_newforce);
 | 
|---|
| [6625c3] | 186 | 
 | 
|---|
 | 187 |   /** Getter for FixedIon.
 | 
|---|
 | 188 |    *
 | 
|---|
 | 189 |    * @return constant reference to FixedIon
 | 
|---|
 | 190 |    */
 | 
|---|
 | 191 |   bool getFixedIon() const;
 | 
|---|
 | 192 |   /** Setter for FixedIon.
 | 
|---|
 | 193 |    *
 | 
|---|
 | 194 |    * @param _fixedion new state of FixedIon
 | 
|---|
 | 195 |    */
 | 
|---|
 | 196 |   void setFixedIon(const bool _fixedion);
 | 
|---|
| [d74077] | 197 | 
 | 
|---|
 | 198 |   ///// manipulation of the atomic position
 | 
|---|
 | 199 | 
 | 
|---|
 | 200 |   // Accessors ussually come in pairs... and sometimes even more than that
 | 
|---|
| [6625c3] | 201 |   /** Getter for AtomicPosition.
 | 
|---|
 | 202 |    *
 | 
|---|
 | 203 |    * Current time step is used.
 | 
|---|
 | 204 |    *
 | 
|---|
 | 205 |    * @param i component of vector
 | 
|---|
 | 206 |    * @return i-th component of atomic position
 | 
|---|
 | 207 |    */
 | 
|---|
| [d74077] | 208 |   const double& operator[](size_t i) const;
 | 
|---|
| [6625c3] | 209 |   /** Getter for AtomicPosition.
 | 
|---|
 | 210 |    *
 | 
|---|
 | 211 |    * Current time step is used.
 | 
|---|
 | 212 |    *
 | 
|---|
 | 213 |    * \sa operator[], this is if instance is a reference.
 | 
|---|
 | 214 |    *
 | 
|---|
 | 215 |    * @param i component of vector
 | 
|---|
 | 216 |    * @return i-th component of atomic position
 | 
|---|
 | 217 |    */
 | 
|---|
| [d74077] | 218 |   const double& at(size_t i) const;
 | 
|---|
| [6625c3] | 219 |   /** Getter for AtomicPosition.
 | 
|---|
 | 220 |    *
 | 
|---|
 | 221 |    * \sa operator[], this is if instance is a reference.
 | 
|---|
 | 222 |    *
 | 
|---|
 | 223 |    * @param i index of component of AtomicPosition
 | 
|---|
 | 224 |    * @param _step time step to return
 | 
|---|
 | 225 |    * @return atomic position at time step _step
 | 
|---|
 | 226 |    */
 | 
|---|
| [6b020f] | 227 |   const double& atStep(size_t i, unsigned int _step) const;
 | 
|---|
| [6625c3] | 228 |   /** Setter for AtomicPosition.
 | 
|---|
 | 229 |    *
 | 
|---|
 | 230 |    * Current time step is used.
 | 
|---|
 | 231 |    *
 | 
|---|
 | 232 |    * @param i component to set
 | 
|---|
 | 233 |    * @param value value to set to
 | 
|---|
 | 234 |    */
 | 
|---|
| [d74077] | 235 |   void set(size_t i, const double value);
 | 
|---|
| [6625c3] | 236 |   /** Setter for AtomicPosition.
 | 
|---|
 | 237 |    *
 | 
|---|
 | 238 |    * @param i component to set
 | 
|---|
 | 239 |    * @param _step time step to set
 | 
|---|
 | 240 |    * @param value value to set to
 | 
|---|
 | 241 |    */
 | 
|---|
| [6b020f] | 242 |   void setAtStep(size_t i, unsigned int _step, const double value);
 | 
|---|
| [6625c3] | 243 |   /** Getter for AtomicPosition.
 | 
|---|
 | 244 |    *
 | 
|---|
 | 245 |    * Current time step is used.
 | 
|---|
 | 246 |    *
 | 
|---|
 | 247 |    * @return atomic position
 | 
|---|
 | 248 |    */
 | 
|---|
| [d74077] | 249 |   const Vector& getPosition() const;
 | 
|---|
| [6625c3] | 250 |   /** Getter for AtomicPosition.
 | 
|---|
 | 251 |    *
 | 
|---|
 | 252 |    * @param _step time step to return
 | 
|---|
 | 253 |    * @return atomic position at time step _step
 | 
|---|
 | 254 |    */
 | 
|---|
| [6b020f] | 255 |   const Vector& getPositionAtStep(unsigned int _step) const;
 | 
|---|
| [d74077] | 256 | 
 | 
|---|
 | 257 |   // Assignment operator
 | 
|---|
| [6625c3] | 258 |   /** Setter for AtomicPosition.
 | 
|---|
 | 259 |    *
 | 
|---|
 | 260 |    * Current time step is used.
 | 
|---|
 | 261 |    *
 | 
|---|
 | 262 |    * @param _vector new position to set
 | 
|---|
 | 263 |    */
 | 
|---|
| [d74077] | 264 |   void setPosition(const Vector& _vector);
 | 
|---|
| [6625c3] | 265 |   /** Setter for AtomicPosition.
 | 
|---|
 | 266 |    *
 | 
|---|
 | 267 |    * @param _step time step to set
 | 
|---|
 | 268 |    * @param _vector new position to set for time step _step
 | 
|---|
 | 269 |    */
 | 
|---|
| [6b020f] | 270 |   void setPositionAtStep(const unsigned int _step, const Vector& _vector);
 | 
|---|
| [d74077] | 271 |   class VectorInterface &operator=(const Vector& _vector);
 | 
|---|
 | 272 | 
 | 
|---|
 | 273 |   // operators for mathematical operations
 | 
|---|
 | 274 |   const VectorInterface& operator+=(const Vector& b);
 | 
|---|
 | 275 |   const VectorInterface& operator-=(const Vector& b);
 | 
|---|
 | 276 |   Vector const operator+(const Vector& b) const;
 | 
|---|
 | 277 |   Vector const operator-(const Vector& b) const;
 | 
|---|
 | 278 | 
 | 
|---|
 | 279 |   void Zero();
 | 
|---|
 | 280 |   void One(const double one);
 | 
|---|
 | 281 |   void LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors);
 | 
|---|
 | 282 | 
 | 
|---|
 | 283 |   double distance(const Vector &point) const;
 | 
|---|
 | 284 |   double DistanceSquared(const Vector &y) const;
 | 
|---|
 | 285 |   double distance(const VectorInterface &_atom) const;
 | 
|---|
 | 286 |   double DistanceSquared(const VectorInterface &_atom) const;
 | 
|---|
 | 287 | 
 | 
|---|
 | 288 |   void ScaleAll(const double *factor);
 | 
|---|
 | 289 |   void ScaleAll(const Vector &factor);
 | 
|---|
 | 290 |   void Scale(const double factor);
 | 
|---|
 | 291 | 
 | 
|---|
| [6625c3] | 292 |   // operations for trajectories
 | 
|---|
| [8cc22f] | 293 |   bool isStepPresent(const unsigned int _step) const;
 | 
|---|
| [6625c3] | 294 |   void ResizeTrajectory(size_t MaxSteps);
 | 
|---|
 | 295 |   size_t getTrajectorySize() const;
 | 
|---|
| [6b020f] | 296 |   void CopyStepOnStep(const unsigned int dest, const unsigned int src);
 | 
|---|
| [bcb593] | 297 |   void VelocityVerletUpdateX(int nr, const unsigned int NextStep, double Deltat, bool IsAngstroem);
 | 
|---|
 | 298 |   void VelocityVerletUpdateU(int nr, const unsigned int NextStep, double Deltat, bool IsAngstroem);
 | 
|---|
| [6b020f] | 299 |   double getKineticEnergy(const unsigned int step) const;
 | 
|---|
 | 300 |   Vector getMomentum(const unsigned int step) const;
 | 
|---|
| [d40189] | 301 |   Vector getAcceleration(const unsigned int _step) const;
 | 
|---|
| [6625c3] | 302 |   double getMass() const;
 | 
|---|
| [2034f3] | 303 |   double getCharge() const {
 | 
|---|
 | 304 |     return charge;
 | 
|---|
 | 305 |   }
 | 
|---|
 | 306 |   void setCharge(const double _charge) {
 | 
|---|
 | 307 |     charge = _charge;
 | 
|---|
 | 308 |   }
 | 
|---|
| [6625c3] | 309 | 
 | 
|---|
| [d74077] | 310 |   std::ostream & operator << (std::ostream &ost) const;
 | 
|---|
| [f16a4b] | 311 | 
 | 
|---|
| [443547] | 312 | protected:
 | 
|---|
| [e2373df] | 313 |   /** Function used by this and inheriting classes to extend the trajectory
 | 
|---|
 | 314 |    * vectors.
 | 
|---|
 | 315 |    */
 | 
|---|
| [8cc22f] | 316 |   void AppendTrajectoryStep(const unsigned int _step);
 | 
|---|
| [e2373df] | 317 | 
 | 
|---|
| [7e51e1] | 318 |   /** Function used by this and inheriting classes to decrease the trajectory
 | 
|---|
 | 319 |    * vectors by one.
 | 
|---|
| [8c6b68] | 320 |    *
 | 
|---|
 | 321 |    * \param _firststep first step in interval to be removed
 | 
|---|
 | 322 |    * \param _laststep last step in interval to be removed
 | 
|---|
| [7e51e1] | 323 |    */
 | 
|---|
| [8c6b68] | 324 |   void removeTrajectorySteps(const unsigned int _firststep, const unsigned int _laststep);
 | 
|---|
| [7e51e1] | 325 | 
 | 
|---|
| [443547] | 326 |   // make these protected only such that deriving atom class still has full
 | 
|---|
 | 327 |   // access needed for clone and alike
 | 
|---|
| [8cc22f] | 328 | 
 | 
|---|
 | 329 |   //!> typedef for a vector of Vectors with inverse sorting to make lower_bound return present or last past step
 | 
|---|
 | 330 |   typedef std::map<unsigned int, Vector, std::greater<unsigned int> > VectorTrajectory_t;
 | 
|---|
 | 331 |   VectorTrajectory_t AtomicPosition;       //!< coordinate vector of atom, giving last position within cell
 | 
|---|
 | 332 |   VectorTrajectory_t AtomicVelocity;       //!< velocity vector of atom, giving last velocity within cell
 | 
|---|
 | 333 |   VectorTrajectory_t AtomicForce;       //!< Force vector of atom, giving last force within cell
 | 
|---|
| [bce72c] | 334 | 
 | 
|---|
| [8c6b68] | 335 |   /** Helper function to avoid an interval of steps in VectorTrajectory_t.
 | 
|---|
 | 336 |    *
 | 
|---|
 | 337 |    * \param  _trajectory trajectory to remove in
 | 
|---|
 | 338 |    * \param _firststep first step in interval to be removed
 | 
|---|
 | 339 |    * \param _laststep last step in interval to be removed
 | 
|---|
 | 340 |    */
 | 
|---|
 | 341 |   static void eraseInTrajctory(
 | 
|---|
 | 342 |       VectorTrajectory_t &_trajectory,
 | 
|---|
 | 343 |       const unsigned int _firststep, const unsigned int _laststep);
 | 
|---|
 | 344 | 
 | 
|---|
| [443547] | 345 | private:
 | 
|---|
| [35a25a] | 346 |   atomicNumber_t AtomicElement;          //!< contains atomic number (i.e. Z of element) or "-1" if unset
 | 
|---|
| [2034f3] | 347 |   bool FixedIon;    //!< whether this nuclei is influenced by force integration or not
 | 
|---|
 | 348 |   double charge;    //!< charge of this nuclei
 | 
|---|
| [843590] | 349 |   std::string particlename; //!< name of associated Particle
 | 
|---|
| [6b919f8] | 350 | };
 | 
|---|
 | 351 | 
 | 
|---|
| [d74077] | 352 | std::ostream & operator << (std::ostream &ost, const AtomInfo &a);
 | 
|---|
 | 353 | 
 | 
|---|
| [fb0b62] | 354 | //const AtomInfo& operator*=(AtomInfo& a, const double m);
 | 
|---|
 | 355 | //AtomInfo const operator*(const AtomInfo& a, const double m);
 | 
|---|
 | 356 | //AtomInfo const operator*(const double m, const AtomInfo& a);
 | 
|---|
| [d74077] | 357 | 
 | 
|---|
| [6b919f8] | 358 | #endif /* ATOM_ATOMINFO_HPP_ */
 | 
|---|