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