source: src/Atom/atom_atominfo.hpp@ ca09be

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since ca09be was 8cc22f, checked in by Frederik Heber <heber@…>, 11 years ago

Changed how trajectories are stored, not as vecor but as map.

  • Property mode set to 100644
File size: 9.8 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 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 removeStep(const unsigned int _step)=0;
67
68 /** DEPRECATED: Getter for element indicated by AtomicElement.
69 *
70 * \deprecated This function is deprecated, use getElement() instead.
71 *
72 * @return constant pointer to element for AtomicElement
73 */
74 const element *getType() const;
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
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.
106 *
107 * Current time step is used.
108 *
109 * @return constant reference to AtomicVelocity
110 */
111// Vector& getAtomicVelocity();
112 /** Getter for AtomicVelocity.
113 *
114 * @param _step time step to return
115 * @return constant reference to AtomicVelocity
116 */
117// Vector& getAtomicVelocity(const int _step);
118 /** Getter for AtomicVelocity.
119 *
120 * Current time step is used.
121 *
122 * @return constant reference to AtomicVelocity
123 */
124 const Vector& getAtomicVelocity() const;
125 /** Getter for AtomicVelocity.
126 *
127 * @param _step time step to return
128 * @return constant reference to AtomicVelocity
129 */
130 const Vector& getAtomicVelocityAtStep(const unsigned int _step) const;
131 /** Setter for AtomicVelocity.
132 *
133 * Current time step is used.
134 *
135 * @param _newvelocity new velocity to set
136 */
137 void setAtomicVelocity(const Vector &_newvelocity);
138 /** Setter for AtomicVelocity.
139 *
140 * @param _step time step to set
141 * @param _newvelocity new velocity to set
142 */
143 void setAtomicVelocityAtStep(const unsigned int _step, const Vector &_newvelocity);
144
145 /** Getter for AtomicForce.
146 *
147 * Current time step is used.
148 *
149 * @return constant reference to AtomicForce
150 */
151 const Vector& getAtomicForce() const;
152 /** Getter for AtomicForce.
153 *
154 * @param _step time step to return
155 * @return constant reference to AtomicForce
156 */
157 const Vector& getAtomicForceAtStep(const unsigned int _step) const;
158 /** Setter for AtomicForce.
159 *
160 * Current time step is used.
161 *
162 * @param _newvelocity new force vector to set
163 */
164 void setAtomicForce(const Vector &_newforce);
165 /** Setter for AtomicForce.
166 *
167 * @param _step time step to set
168 * @param _newvelocity new force vector to set
169 */
170 void setAtomicForceAtStep(const unsigned int _step, const Vector &_newforce);
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);
182
183 ///// manipulation of the atomic position
184
185 // Accessors ussually come in pairs... and sometimes even more than that
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 */
193 const double& operator[](size_t i) const;
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 */
203 const double& at(size_t i) const;
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 */
212 const double& atStep(size_t i, unsigned int _step) const;
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 */
220 void set(size_t i, const double value);
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 */
227 void setAtStep(size_t i, unsigned int _step, const double value);
228 /** Getter for AtomicPosition.
229 *
230 * Current time step is used.
231 *
232 * @return atomic position
233 */
234 const Vector& getPosition() const;
235 /** Getter for AtomicPosition.
236 *
237 * @param _step time step to return
238 * @return atomic position at time step _step
239 */
240 const Vector& getPositionAtStep(unsigned int _step) const;
241
242 // Assignment operator
243 /** Setter for AtomicPosition.
244 *
245 * Current time step is used.
246 *
247 * @param _vector new position to set
248 */
249 void setPosition(const Vector& _vector);
250 /** Setter for AtomicPosition.
251 *
252 * @param _step time step to set
253 * @param _vector new position to set for time step _step
254 */
255 void setPositionAtStep(const unsigned int _step, const Vector& _vector);
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
277 // operations for trajectories
278 bool isStepPresent(const unsigned int _step) const;
279 void ResizeTrajectory(size_t MaxSteps);
280 size_t getTrajectorySize() const;
281 void CopyStepOnStep(const unsigned int dest, const unsigned int src);
282 void VelocityVerletUpdateX(int nr, const unsigned int NextStep, double Deltat, bool IsAngstroem);
283 void VelocityVerletUpdateU(int nr, const unsigned int NextStep, double Deltat, bool IsAngstroem);
284 double getKineticEnergy(const unsigned int step) const;
285 Vector getMomentum(const unsigned int step) const;
286 double getMass() const;
287 double getCharge() const {
288 return charge;
289 }
290 void setCharge(const double _charge) {
291 charge = _charge;
292 }
293
294 std::ostream & operator << (std::ostream &ost) const;
295
296protected:
297 /** Function used by this and inheriting classes to extend the trajectory
298 * vectors.
299 */
300 void AppendTrajectoryStep(const unsigned int _step);
301
302 /** Function used by this and inheriting classes to decrease the trajectory
303 * vectors by one.
304 */
305 void removeTrajectoryStep(const unsigned int _step);
306
307 // make these protected only such that deriving atom class still has full
308 // access needed for clone and alike
309
310 //!> typedef for a vector of Vectors with inverse sorting to make lower_bound return present or last past step
311 typedef std::map<unsigned int, Vector, std::greater<unsigned int> > VectorTrajectory_t;
312 VectorTrajectory_t AtomicPosition; //!< coordinate vector of atom, giving last position within cell
313 VectorTrajectory_t AtomicVelocity; //!< velocity vector of atom, giving last velocity within cell
314 VectorTrajectory_t AtomicForce; //!< Force vector of atom, giving last force within cell
315
316private:
317 atomicNumber_t AtomicElement; //!< contains atomic number (i.e. Z of element) or "-1" if unset
318 bool FixedIon; //!< whether this nuclei is influenced by force integration or not
319 double charge; //!< charge of this nuclei
320};
321
322std::ostream & operator << (std::ostream &ost, const AtomInfo &a);
323
324//const AtomInfo& operator*=(AtomInfo& a, const double m);
325//AtomInfo const operator*(const AtomInfo& a, const double m);
326//AtomInfo const operator*(const double m, const AtomInfo& a);
327
328#endif /* ATOM_ATOMINFO_HPP_ */
Note: See TracBrowser for help on using the repository browser.