source: src/Atom/atom_atominfo.hpp@ 6458e7

AutomationFragmentation_failures Candidate_v1.6.1 ChemicalSpaceEvaluator Exclude_Hydrogens_annealWithBondGraph ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_contraction-expansion Gui_displays_atomic_force_velocity PythonUI_with_named_parameters StoppableMakroAction TremoloParser_IncreasedPrecision
Last change on this file since 6458e7 was 8c6b68, checked in by Frederik Heber <frederik.heber@…>, 7 years ago

atom::removeStep() extended to removing interval of steps.

  • AtomInfo::removeTrajectorySteps() and BondedParticle::removeTrajectorySteps() changed and all calls adapted.
  • Property mode set to 100644
File size: 11.0 KB
Line 
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
12using 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
33class AtomInfo;
34class element;
35class ForceMatrix;
36class RealSpaceMatrix;
37
38namespace MoleCuilder {
39 void removeLastStep(const std::vector<atomId_t> &atoms);
40};
41
42/********************************************** declarations *******************************/
43
44class AtomInfo : public VectorInterface, public virtual AtomObservable {
45
46public:
47 AtomInfo();
48 AtomInfo(const AtomInfo &_atom);
49 AtomInfo(const VectorInterface &_v);
50 virtual ~AtomInfo();
51
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 UpdateStep(const unsigned int _step)=0;
59
60 /** Pops all steps in the interval [\a _firststep, \a _laststep] 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 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
68 */
69 virtual void removeSteps(const unsigned int _firststep, const unsigned int _laststep)=0;
70
71 /** DEPRECATED: Getter for element indicated by AtomicElement.
72 *
73 * \deprecated This function is deprecated, use getElement() instead.
74 *
75 * @return constant pointer to element for AtomicElement
76 */
77 const element *getType() const;
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
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
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.
121 *
122 * Current time step is used.
123 *
124 * @return constant reference to AtomicVelocity
125 */
126// Vector& getAtomicVelocity();
127 /** Getter for AtomicVelocity.
128 *
129 * @param _step time step to return
130 * @return constant reference to AtomicVelocity
131 */
132// Vector& getAtomicVelocity(const int _step);
133 /** Getter for AtomicVelocity.
134 *
135 * Current time step is used.
136 *
137 * @return constant reference to AtomicVelocity
138 */
139 const Vector& getAtomicVelocity() const;
140 /** Getter for AtomicVelocity.
141 *
142 * @param _step time step to return
143 * @return constant reference to AtomicVelocity
144 */
145 const Vector& getAtomicVelocityAtStep(const unsigned int _step) const;
146 /** Setter for AtomicVelocity.
147 *
148 * Current time step is used.
149 *
150 * @param _newvelocity new velocity to set
151 */
152 void setAtomicVelocity(const Vector &_newvelocity);
153 /** Setter for AtomicVelocity.
154 *
155 * @param _step time step to set
156 * @param _newvelocity new velocity to set
157 */
158 void setAtomicVelocityAtStep(const unsigned int _step, const Vector &_newvelocity);
159
160 /** Getter for AtomicForce.
161 *
162 * Current time step is used.
163 *
164 * @return constant reference to AtomicForce
165 */
166 const Vector& getAtomicForce() const;
167 /** Getter for AtomicForce.
168 *
169 * @param _step time step to return
170 * @return constant reference to AtomicForce
171 */
172 const Vector& getAtomicForceAtStep(const unsigned int _step) const;
173 /** Setter for AtomicForce.
174 *
175 * Current time step is used.
176 *
177 * @param _newvelocity new force vector to set
178 */
179 void setAtomicForce(const Vector &_newforce);
180 /** Setter for AtomicForce.
181 *
182 * @param _step time step to set
183 * @param _newvelocity new force vector to set
184 */
185 void setAtomicForceAtStep(const unsigned int _step, const Vector &_newforce);
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);
197
198 ///// manipulation of the atomic position
199
200 // Accessors ussually come in pairs... and sometimes even more than that
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 */
208 const double& operator[](size_t i) const;
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 */
218 const double& at(size_t i) const;
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 */
227 const double& atStep(size_t i, unsigned int _step) const;
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 */
235 void set(size_t i, const double value);
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 */
242 void setAtStep(size_t i, unsigned int _step, const double value);
243 /** Getter for AtomicPosition.
244 *
245 * Current time step is used.
246 *
247 * @return atomic position
248 */
249 const Vector& getPosition() const;
250 /** Getter for AtomicPosition.
251 *
252 * @param _step time step to return
253 * @return atomic position at time step _step
254 */
255 const Vector& getPositionAtStep(unsigned int _step) const;
256
257 // Assignment operator
258 /** Setter for AtomicPosition.
259 *
260 * Current time step is used.
261 *
262 * @param _vector new position to set
263 */
264 void setPosition(const Vector& _vector);
265 /** Setter for AtomicPosition.
266 *
267 * @param _step time step to set
268 * @param _vector new position to set for time step _step
269 */
270 void setPositionAtStep(const unsigned int _step, const Vector& _vector);
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
292 // operations for trajectories
293 bool isStepPresent(const unsigned int _step) const;
294 void ResizeTrajectory(size_t MaxSteps);
295 size_t getTrajectorySize() const;
296 void CopyStepOnStep(const unsigned int dest, const unsigned int src);
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);
299 double getKineticEnergy(const unsigned int step) const;
300 Vector getMomentum(const unsigned int step) const;
301 double getMass() const;
302 double getCharge() const {
303 return charge;
304 }
305 void setCharge(const double _charge) {
306 charge = _charge;
307 }
308
309 std::ostream & operator << (std::ostream &ost) const;
310
311protected:
312 /** Function used by this and inheriting classes to extend the trajectory
313 * vectors.
314 */
315 void AppendTrajectoryStep(const unsigned int _step);
316
317 /** Function used by this and inheriting classes to decrease the trajectory
318 * vectors by one.
319 *
320 * \param _firststep first step in interval to be removed
321 * \param _laststep last step in interval to be removed
322 */
323 void removeTrajectorySteps(const unsigned int _firststep, const unsigned int _laststep);
324
325 // make these protected only such that deriving atom class still has full
326 // access needed for clone and alike
327
328 //!> typedef for a vector of Vectors with inverse sorting to make lower_bound return present or last past step
329 typedef std::map<unsigned int, Vector, std::greater<unsigned int> > VectorTrajectory_t;
330 VectorTrajectory_t AtomicPosition; //!< coordinate vector of atom, giving last position within cell
331 VectorTrajectory_t AtomicVelocity; //!< velocity vector of atom, giving last velocity within cell
332 VectorTrajectory_t AtomicForce; //!< Force vector of atom, giving last force within cell
333
334 /** Helper function to avoid an interval of steps in VectorTrajectory_t.
335 *
336 * \param _trajectory trajectory to remove in
337 * \param _firststep first step in interval to be removed
338 * \param _laststep last step in interval to be removed
339 */
340 static void eraseInTrajctory(
341 VectorTrajectory_t &_trajectory,
342 const unsigned int _firststep, const unsigned int _laststep);
343
344private:
345 atomicNumber_t AtomicElement; //!< contains atomic number (i.e. Z of element) or "-1" if unset
346 bool FixedIon; //!< whether this nuclei is influenced by force integration or not
347 double charge; //!< charge of this nuclei
348 std::string particlename; //!< name of associated Particle
349};
350
351std::ostream & operator << (std::ostream &ost, const AtomInfo &a);
352
353//const AtomInfo& operator*=(AtomInfo& a, const double m);
354//AtomInfo const operator*(const AtomInfo& a, const double m);
355//AtomInfo const operator*(const double m, const AtomInfo& a);
356
357#endif /* ATOM_ATOMINFO_HPP_ */
Note: See TracBrowser for help on using the repository browser.