/* * atom_atominfo.hpp * * Created on: Oct 19, 2009 * Author: heber */ #ifndef ATOM_ATOMINFO_HPP_ #define ATOM_ATOMINFO_HPP_ using namespace std; /*********************************************** includes ***********************************/ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include "atom_observable.hpp" #include "types.hpp" #include "LinearAlgebra/Vector.hpp" #include "LinearAlgebra/VectorInterface.hpp" /****************************************** forward declarations *****************************/ class AtomInfo; class element; class ForceMatrix; class RealSpaceMatrix; namespace MoleCuilder { void removeLastStep(const std::vector &atoms); }; /********************************************** declarations *******************************/ class AtomInfo : public VectorInterface, public virtual AtomObservable { public: AtomInfo(); AtomInfo(const AtomInfo &_atom); AtomInfo(const VectorInterface &_v); virtual ~AtomInfo(); /** Pushes back another step in all trajectory vectors. * * This allows to extend all trajectories contained in different classes * consistently. This is implemented by the topmost class which calls the * real functions, \sa AppendTrajectoryStep(), by all necessary subclasses. */ virtual void UpdateStep(const unsigned int _step)=0; /** Pops the last step in all trajectory vectors. * * This allows to decrease all trajectories contained in different classes * by one consistently. This is implemented by the topmost class which calls * the real functions, \sa removeTrajectoryStep(), by all necessary subclasses. */ virtual void removeStep(const unsigned int _step)=0; /** DEPRECATED: Getter for element indicated by AtomicElement. * * \deprecated This function is deprecated, use getElement() instead. * * @return constant pointer to element for AtomicElement */ const element *getType() const; /** Getter for element indicated by AtomicElement. * * \note Looking up the element requires looking the World instance and is * thus significantly slower than instead just returning the internally * stored atomicNumber_t. So, if possible use getElementNo() instead and * check soundly whether you truely need access to all of element's member * variables. * * @return const reference to element indicated by AtomicElement */ const element & getElement() const; /** Getter for AtomicElement. * * @return AtomicElement */ atomicNumber_t getElementNo() const; /** Getter for the name of Particle this atom is associated with. * * \return name of Particle to use in lookup in ParticleRegistry */ const std::string &getParticleName() const; /** Setter for the Particle name this atom is associated with. * * \param _name new name of atom's Particle */ void setParticleName(const std::string & _name); /** Setter for AtomicElement. * * @param _type new element by pointer to set */ void setType(const element *_type); /** Setter for AtomicElement. * * @param _typenr new element by index to set */ void setType(const int _typenr); /** Getter for AtomicVelocity. * * Current time step is used. * * @return constant reference to AtomicVelocity */ // Vector& getAtomicVelocity(); /** Getter for AtomicVelocity. * * @param _step time step to return * @return constant reference to AtomicVelocity */ // Vector& getAtomicVelocity(const int _step); /** Getter for AtomicVelocity. * * Current time step is used. * * @return constant reference to AtomicVelocity */ const Vector& getAtomicVelocity() const; /** Getter for AtomicVelocity. * * @param _step time step to return * @return constant reference to AtomicVelocity */ const Vector& getAtomicVelocityAtStep(const unsigned int _step) const; /** Setter for AtomicVelocity. * * Current time step is used. * * @param _newvelocity new velocity to set */ void setAtomicVelocity(const Vector &_newvelocity); /** Setter for AtomicVelocity. * * @param _step time step to set * @param _newvelocity new velocity to set */ void setAtomicVelocityAtStep(const unsigned int _step, const Vector &_newvelocity); /** Getter for AtomicForce. * * Current time step is used. * * @return constant reference to AtomicForce */ const Vector& getAtomicForce() const; /** Getter for AtomicForce. * * @param _step time step to return * @return constant reference to AtomicForce */ const Vector& getAtomicForceAtStep(const unsigned int _step) const; /** Setter for AtomicForce. * * Current time step is used. * * @param _newvelocity new force vector to set */ void setAtomicForce(const Vector &_newforce); /** Setter for AtomicForce. * * @param _step time step to set * @param _newvelocity new force vector to set */ void setAtomicForceAtStep(const unsigned int _step, const Vector &_newforce); /** Getter for FixedIon. * * @return constant reference to FixedIon */ bool getFixedIon() const; /** Setter for FixedIon. * * @param _fixedion new state of FixedIon */ void setFixedIon(const bool _fixedion); ///// manipulation of the atomic position // Accessors ussually come in pairs... and sometimes even more than that /** Getter for AtomicPosition. * * Current time step is used. * * @param i component of vector * @return i-th component of atomic position */ const double& operator[](size_t i) const; /** Getter for AtomicPosition. * * Current time step is used. * * \sa operator[], this is if instance is a reference. * * @param i component of vector * @return i-th component of atomic position */ const double& at(size_t i) const; /** Getter for AtomicPosition. * * \sa operator[], this is if instance is a reference. * * @param i index of component of AtomicPosition * @param _step time step to return * @return atomic position at time step _step */ const double& atStep(size_t i, unsigned int _step) const; /** Setter for AtomicPosition. * * Current time step is used. * * @param i component to set * @param value value to set to */ void set(size_t i, const double value); /** Setter for AtomicPosition. * * @param i component to set * @param _step time step to set * @param value value to set to */ void setAtStep(size_t i, unsigned int _step, const double value); /** Getter for AtomicPosition. * * Current time step is used. * * @return atomic position */ const Vector& getPosition() const; /** Getter for AtomicPosition. * * @param _step time step to return * @return atomic position at time step _step */ const Vector& getPositionAtStep(unsigned int _step) const; // Assignment operator /** Setter for AtomicPosition. * * Current time step is used. * * @param _vector new position to set */ void setPosition(const Vector& _vector); /** Setter for AtomicPosition. * * @param _step time step to set * @param _vector new position to set for time step _step */ void setPositionAtStep(const unsigned int _step, const Vector& _vector); class VectorInterface &operator=(const Vector& _vector); // operators for mathematical operations const VectorInterface& operator+=(const Vector& b); const VectorInterface& operator-=(const Vector& b); Vector const operator+(const Vector& b) const; Vector const operator-(const Vector& b) const; void Zero(); void One(const double one); void LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors); double distance(const Vector &point) const; double DistanceSquared(const Vector &y) const; double distance(const VectorInterface &_atom) const; double DistanceSquared(const VectorInterface &_atom) const; void ScaleAll(const double *factor); void ScaleAll(const Vector &factor); void Scale(const double factor); // operations for trajectories bool isStepPresent(const unsigned int _step) const; void ResizeTrajectory(size_t MaxSteps); size_t getTrajectorySize() const; void CopyStepOnStep(const unsigned int dest, const unsigned int src); void VelocityVerletUpdateX(int nr, const unsigned int NextStep, double Deltat, bool IsAngstroem); void VelocityVerletUpdateU(int nr, const unsigned int NextStep, double Deltat, bool IsAngstroem); double getKineticEnergy(const unsigned int step) const; Vector getMomentum(const unsigned int step) const; double getMass() const; double getCharge() const { return charge; } void setCharge(const double _charge) { charge = _charge; } std::ostream & operator << (std::ostream &ost) const; protected: /** Function used by this and inheriting classes to extend the trajectory * vectors. */ void AppendTrajectoryStep(const unsigned int _step); /** Function used by this and inheriting classes to decrease the trajectory * vectors by one. */ void removeTrajectoryStep(const unsigned int _step); // make these protected only such that deriving atom class still has full // access needed for clone and alike //!> typedef for a vector of Vectors with inverse sorting to make lower_bound return present or last past step typedef std::map > VectorTrajectory_t; VectorTrajectory_t AtomicPosition; //!< coordinate vector of atom, giving last position within cell VectorTrajectory_t AtomicVelocity; //!< velocity vector of atom, giving last velocity within cell VectorTrajectory_t AtomicForce; //!< Force vector of atom, giving last force within cell private: atomicNumber_t AtomicElement; //!< contains atomic number (i.e. Z of element) or "-1" if unset bool FixedIon; //!< whether this nuclei is influenced by force integration or not double charge; //!< charge of this nuclei std::string particlename; //!< name of associated Particle }; std::ostream & operator << (std::ostream &ost, const AtomInfo &a); //const AtomInfo& operator*=(AtomInfo& a, const double m); //AtomInfo const operator*(const AtomInfo& a, const double m); //AtomInfo const operator*(const double m, const AtomInfo& a); #endif /* ATOM_ATOMINFO_HPP_ */