source: src/atom_atominfo.hpp@ 5c5472

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 5c5472 was 7188b1, checked in by Frederik Heber <heber@…>, 13 years ago

Introduced atom_observables and GLWorldView observes World, GLMoleculeObject_atom observes its atom.

Observer changes:

  • new Channels pattern required from CodePatterns 1.1.5 and that Observable signing on and off is now with const instance possible.
  • class atom is now observable, encapsulated in class AtomObservable:
    • enums have notification types
    • we use NotificationChannels of Observable to emit these distinct types.
  • atominfo, particleinfo, bondedparticleinfo all have OBSERVE and NOTIFY(..) in their setter functions (thx encapsulation).
  • class GLMoleculeObject_atom signs on to atom to changes to position, element, and index.
  • World equally has notifications for atom (new,remove) and molecules (new, remove).
  • GLWorldView now observes World for these changes.

Other changes:

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