source: src/Atom/atom.hpp@ c4abf2

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator 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_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since c4abf2 was c0f2fc, checked in by Frederik Heber <heber@…>, 9 years ago

atom now uses associate... and disassociatedAtomWithMolecule().

  • this is used to gather all functions that need to be called when a new atom joins a molecule such as signing on to certain channels or updating certain internal values of the molecule.
  • Property mode set to 100644
File size: 8.3 KB
RevLine 
[357fba]1/*
2 * atom.hpp
3 *
4 * Created on: Aug 3, 2009
5 * Author: heber
6 */
7
8#ifndef ATOM_HPP_
9#define ATOM_HPP_
10
11using namespace std;
12
[f66195]13/*********************************************** includes ***********************************/
14
[cd4ccc]15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
[986ed3]20#include <iosfwd>
[266237]21#include <list>
[fcd7b6]22#include <vector>
[cd4ccc]23
[6b919f8]24#include "atom_atominfo.hpp"
25#include "atom_bondedparticle.hpp"
26#include "atom_graphnode.hpp"
[d05088]27#include "atom_observable.hpp"
[6b919f8]28#include "atom_particleinfo.hpp"
[6f0841]29#include "Atom/TesselPoint.hpp"
[ead4e6]30#include "types.hpp"
[f66195]31
[d05088]32#include "CodePatterns/Observer/Observer.hpp"
[ad011c]33#include "CodePatterns/enumeration.hpp"
[a0064e]34
[f66195]35/****************************************** forward declarations *****************************/
[357fba]36
[0d9546]37class AtomicInfo;
[f66195]38class Vector;
[46d958]39class World;
[6cfa36]40class molecule;
[c550dd]41class Shape;
[f66195]42
43/********************************************** declarations *******************************/
[e41951]44
[357fba]45/** Single atom.
46 * Class incorporates position, type
47 */
[d05088]48class atom :
49 public GraphNode,
50 public BondedParticle,
51 public TesselPoint
52{
[88d586]53 friend atom* NewAtom(atomId_t);
[46d958]54 friend void DeleteAtom(atom*);
[910a5d]55
56 atom *father; //!< In many-body bond order fragmentations points to originating atom
57 int *sort; //!< sort criteria
58
[1363de]59public:
[357fba]60
[1363de]61 /** Clones this atom.
62 *
63 * Does not clone the bonds!
64 *
65 * @return reference to atom
66 */
[46d958]67 virtual atom *clone();
[357fba]68
[e2373df]69 /** Pushes back another step in all trajectory vectors.
70 *
71 * This allows to extend all trajectories contained in different classes
72 * consistently. This is implemented by the topmost class which calls the
73 * real functions, \sa AppendTrajectoryStep(), by all necessary subclasses.
74 */
[8cc22f]75 virtual void UpdateStep(const unsigned int _step);
[e2373df]76
[7e51e1]77 /** Pops the last step in all trajectory vectors.
78 *
79 * This allows to decrease all trajectories contained in different classes
80 * by one consistently. This is implemented by the topmost class which calls
81 * the real functions, \sa removeTrajectoryStep(), by all necessary subclasses.
82 */
[8cc22f]83 virtual void removeStep(const unsigned int _step);
[7e51e1]84
[1363de]85 /** Output of a single atom with given numbering.
86 * \param ElementNo cardinal number of the element
87 * \param AtomNo cardinal number among these atoms of the same element
88 * \param *out stream to output to
89 * \param *comment commentary after '#' sign
90 * \return true - \a *out present, false - \a *out is NULL
91 */
[e138de]92 bool OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment = NULL) const;
[1363de]93
94 /** Output of a single atom with numbering from array according to atom::type.
95 * \param *ElementNo cardinal number of the element
96 * \param *AtomNo cardinal number among these atoms of the same element
97 * \param *out stream to output to
98 * \param *comment commentary after '#' sign
99 * \return true - \a *out present, false - \a *out is NULL
100 */
[0ba410]101 bool OutputArrayIndexed(ostream * const out,const enumeration<const element*>&, int *AtomNo, const char *comment = NULL) const;
[1363de]102
103 /** Initialises the component number array.
104 * Size is set to atom::ListOfBonds.size()+1 (last is th encode end by -1)
105 */
[4455f4]106 void InitComponentNr();
[1363de]107
108 /** Resets GraphNr to -1.
109 *
110 */
[14b65e]111 void resetGraphNr();
[681a8a]112
[1363de]113 /** Check whether father is equal to given atom.
114 * \param *ptr atom to compare father to
115 * \param **res return value (only set if atom::father is equal to \a *ptr)
116 */
[b453f9]117 void EqualsFather ( const atom *ptr, const atom **res ) const;
[1363de]118
119 /** States whether the given \a *ptr is our father.
120 *
121 * @param ptr atom to compare atom::Father with
122 * @return true - \a *ptr is father, false - not
123 */
[00abfc]124 bool isFather(const atom *ptr);
[1363de]125
126 /** If we are copy of copy, we are linked to be just a copy.
127 *
128 */
[e65246]129 void CorrectFather();
[1363de]130
131 /** Climbs up the father list until NULL, last is returned.
132 * \return true father, i.e. whose father points to itself, NULL if it could not be found or has none (added hydrogen)
133 */
[357fba]134 atom *GetTrueFather();
[1363de]135
[59fff1]136 /** Const version of \sa GetTrueFather().
137 * \return true father, i.e. whose father points to itself, NULL if it could not be found or has none (added hydrogen)
138 */
139 const atom *GetTrueFather() const;
140
[910a5d]141 /** Const getter for the atoms father.
142 *
143 * \return father of this atom
144 */
145 atom * const getFather() const
146 { return father; }
147
148 /** Sets the father for this atom.
149 *
150 * \param _father ptr to father atom
151 */
152 void setFather(atom * const _father);
153
[1363de]154 /** Compares the indices of \a this atom with a given \a ptr.
155 * \param ptr atom to compare index against
156 * \return true - this one's is smaller, false - not
157 */
[b453f9]158 bool Compare(const atom &ptr) const;
[357fba]159
[1363de]160 /** Returns distance to a given vector.
161 * \param origin vector to calculate distance to
162 * \return distance
163 */
[b453f9]164 double DistanceToVector(const Vector &origin) const;
[1363de]165
166 /** Returns squared distance to a given vector.
167 * \param origin vector to calculate distance to
168 * \return distance squared
169 */
[b453f9]170 double DistanceSquaredToVector(const Vector &origin) const;
[4a7776a]171
[46d958]172 // getter and setter
173
174 /**
175 * returns the World that contains this atom.
176 * Use this if you need to get the world without locking
177 * the singleton for example.
178 *
179 */
180 World *getWorld();
181 void setWorld(World*);
182
[ad2b411]183 virtual atomId_t getId() const;
[88d586]184 virtual bool changeId(atomId_t newId);
185
186 /**
187 * this function sets the Id without notifying the world. Only use it, if the world has already
188 * gotten an ID for this Atom.
189 */
190 virtual void setId(atomId_t);
191
[1363de]192 /** Returns pointer to the molecule which atom belongs to.
193 * \return containing molecule
194 */
[270bdf]195 const molecule* getMolecule() const;
[1363de]196
197 /** Erases the atom in atom::mol's list of atoms and sets it to zero.
198 */
[6cfa36]199 void removeFromMolecule();
200
[560bbe]201 /** Changes the molecule internal ParticleInfo::Nr of this atom.
202 *
203 * @param newNr new ParticleInfo::Nr to set
204 * @return true - change successful, false - changed not successful, id remains the old one
205 */
206 bool changeNr(int newNr);
207
[1363de]208 /** Getter for ParticleInfo::Nr of the atom.
209 *
210 * @return index
211 */
[e8a21f]212 int getNr() const;
[1f8337]213
[d74077]214 // Output operator
215 std::ostream & operator << (std::ostream &ost) const;
216
[46d958]217 protected:
[6cfa36]218
[46d958]219 /**
220 * Protected constructor to ensure construction of atoms through the world.
221 * see World::createAtom()
222 */
223 atom();
224
225 /**
226 * Protected copy-constructor to ensure construction of atoms by cloning.
227 * see atom::clone()
228 */
229 atom(class atom *pointer);
230
231 /**
232 * Protected destructor to ensure destruction of atoms through the world.
233 * see World::destroyAtom()
234 */
235 virtual ~atom();
[0d9546]236 private:
237 friend class molecule;
238 friend class AtomicInfo;
239 /** Makes the atom be contained in the new molecule \a *_mol.
240 * Uses atom::removeFromMolecule() to delist from old molecule.
241 * \param *_mol pointer to new molecule
242 */
243 void setMolecule(molecule*);
244
[b71881]245 //!> grant World (only) access to selection state changers
246 friend class World;
247
248 /** Sets the internal selection state to true.
249 *
250 */
251 void select();
252
253 /** Unsets the internal selection state to true.
254 *
255 */
256 void unselect();
257
[d05088]258// virtual void update(Observable *publisher);
259// virtual void recieveNotification(Observable *publisher, Notification_ptr notification);
260 virtual void subjectKilled(Observable *publisher);
[0d9546]261
[b71881]262 public:
263
264 /** Getter to internal selection status.
265 *
266 * \return true - atom is selected, false - else
267 */
268 bool getSelected() const { return selected; }
269
[357fba]270 private:
[6cfa36]271 molecule *mol; // !< the molecule this atom belongs to
[46d958]272 World* world;
[88d586]273 atomId_t id;
[b71881]274 //!> internal state whether atom is selected or not
275 bool selected;
[357fba]276};
277
[d74077]278/**
279 * Global output operator for class atom.
280 */
281std::ostream & operator << (std::ostream &ost, const atom &_atom);
282
[46d958]283/**
284 * internal method used by the world. Do not use if you don't know what you are doing.
285 * You might get burned...
286 * Use World::createAtom() instead.
287 */
[88d586]288atom* NewAtom(atomId_t _id);
[46d958]289
290/**
291* internal method used by the world. Do not use if you don't know what you are doing.
292 * You might get burned...
293 * Use World::destroyAtom() instead.
294 */
295void DeleteAtom(atom*);
296
[e5f64de]297/**
298 * Simple function to compare atoms by their elements to allow sorting of atoms by this criteria
299 */
300bool compareAtomElements(atom* atom1,atom* atom2);
301
[46d958]302
[357fba]303#endif /* ATOM_HPP_ */
Note: See TracBrowser for help on using the repository browser.