source: src/atom.hpp@ 47d041

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 47d041 was 360c8b, checked in by Frederik Heber <heber@…>, 13 years ago

Merge branch 'Adding_Psi3Parser' into stable

Conflicts:

src/Parser/FormatParser.hpp
src/Parser/unittests/ParserTremoloUnitTest.cpp

Issues:

  • Element and periodentafel have been moved to folder src/Element.
  • Property mode set to 100644
File size: 8.4 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"
27#include "atom_particleinfo.hpp"
[d127c8]28#include "Tesselation/TesselPoint.hpp"
[ead4e6]29#include "types.hpp"
[f66195]30
[ad011c]31#include "CodePatterns/enumeration.hpp"
[a0064e]32
[f66195]33/****************************************** forward declarations *****************************/
[357fba]34
[0d9546]35class AtomicInfo;
[f66195]36class Vector;
[46d958]37class World;
[6cfa36]38class molecule;
[c550dd]39class Shape;
[f66195]40
41/********************************************** declarations *******************************/
[e41951]42
[357fba]43/** Single atom.
44 * Class incorporates position, type
45 */
[6625c3]46class atom : public GraphNode, public BondedParticle, public TesselPoint {
[88d586]47 friend atom* NewAtom(atomId_t);
[46d958]48 friend void DeleteAtom(atom*);
[1363de]49public:
[357fba]50 atom *father; //!< In many-body bond order fragmentations points to originating atom
51 int *sort; //!< sort criteria
52
[1363de]53 /** Clones this atom.
54 *
55 * Does not clone the bonds!
56 *
57 * @return reference to atom
58 */
[46d958]59 virtual atom *clone();
[357fba]60
[e2373df]61 /** Pushes back another step in all trajectory vectors.
62 *
63 * This allows to extend all trajectories contained in different classes
64 * consistently. This is implemented by the topmost class which calls the
65 * real functions, \sa AppendTrajectoryStep(), by all necessary subclasses.
66 */
67 virtual void UpdateSteps();
68
[1363de]69 /** Output of a single atom with given numbering.
70 * \param ElementNo cardinal number of the element
71 * \param AtomNo cardinal number among these atoms of the same element
72 * \param *out stream to output to
73 * \param *comment commentary after '#' sign
74 * \return true - \a *out present, false - \a *out is NULL
75 */
[e138de]76 bool OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment = NULL) const;
[1363de]77
78 /** Output of a single atom with numbering from array according to atom::type.
79 * \param *ElementNo cardinal number of the element
80 * \param *AtomNo cardinal number among these atoms of the same element
81 * \param *out stream to output to
82 * \param *comment commentary after '#' sign
83 * \return true - \a *out present, false - \a *out is NULL
84 */
[0ba410]85 bool OutputArrayIndexed(ostream * const out,const enumeration<const element*>&, int *AtomNo, const char *comment = NULL) const;
[1363de]86
87 /** Output of a single atom as one line in xyz file.
88 * \param *out stream to output to
89 * \return true - \a *out present, false - \a *out is NULL
90 */
[357fba]91 bool OutputXYZLine(ofstream *out) const;
[1363de]92
93 /** Output of a single atom as one line in xyz file.
94 * \param *out stream to output to
95 * \param *ElementNo array with ion type number in the config file this atom's element shall have
96 * \param *AtomNo array with atom number in the config file this atom shall have, is increase by one automatically
97 * \param step Trajectory time step to output
98 * \return true - \a *out present, false - \a *out is NULL
99 */
[882a8a]100 bool OutputTrajectory(ofstream * const out, const enumeration<const element*>&, int *AtomNo, const int step) const;
[1363de]101
102 /** Output of a single atom as one lin in xyz file.
103 * \param *out stream to output to
104 * \param step Trajectory time step to output
105 * \return true - \a *out present, false - \a *out is NULL
106 */
[e138de]107 bool OutputTrajectoryXYZ(ofstream * const out, const int step) const;
[1363de]108
109 /** Outputs the MPQC configuration line for this atom.
110 * \param *out output stream
111 * \param *center center of molecule subtracted from position
112 * \param *AtomNo pointer to atom counter that is increased by one
113 */
[0dc86e2]114 void OutputMPQCLine(ostream * const out, const Vector *center) const;
[266237]115
[9011c1]116 /** Outputs the Psi3 configuration line for this atom.
117 * \param *out output stream
118 * \param *center center of molecule subtracted from position
119 * \param *AtomNo pointer to atom counter that is increased by one
120 */
121 void OutputPsi3Line(ostream * const out, const Vector *center) const;
122
[1363de]123 /** Initialises the component number array.
124 * Size is set to atom::ListOfBonds.size()+1 (last is th encode end by -1)
125 */
[4455f4]126 void InitComponentNr();
[1363de]127
128 /** Resets GraphNr to -1.
129 *
130 */
[14b65e]131 void resetGraphNr();
[681a8a]132
[1363de]133 /** Check whether father is equal to given atom.
134 * \param *ptr atom to compare father to
135 * \param **res return value (only set if atom::father is equal to \a *ptr)
136 */
[b453f9]137 void EqualsFather ( const atom *ptr, const atom **res ) const;
[1363de]138
139 /** States whether the given \a *ptr is our father.
140 *
141 * @param ptr atom to compare atom::Father with
142 * @return true - \a *ptr is father, false - not
143 */
[00abfc]144 bool isFather(const atom *ptr);
[1363de]145
146 /** If we are copy of copy, we are linked to be just a copy.
147 *
148 */
[e65246]149 void CorrectFather();
[1363de]150
151 /** Climbs up the father list until NULL, last is returned.
152 * \return true father, i.e. whose father points to itself, NULL if it could not be found or has none (added hydrogen)
153 */
[357fba]154 atom *GetTrueFather();
[1363de]155
156 /** Compares the indices of \a this atom with a given \a ptr.
157 * \param ptr atom to compare index against
158 * \return true - this one's is smaller, false - not
159 */
[b453f9]160 bool Compare(const atom &ptr) const;
[357fba]161
[1363de]162 /** Returns distance to a given vector.
163 * \param origin vector to calculate distance to
164 * \return distance
165 */
[b453f9]166 double DistanceToVector(const Vector &origin) const;
[1363de]167
168 /** Returns squared distance to a given vector.
169 * \param origin vector to calculate distance to
170 * \return distance squared
171 */
[b453f9]172 double DistanceSquaredToVector(const Vector &origin) const;
[1363de]173 /** Checks whether atom is within the given box.
174 * \param offset offset to box origin
175 * \param *parallelepiped box matrix
176 * \return true - is inside, false - is not
177 */
[c550dd]178 bool IsInShape(const Shape&) const;
[4a7776a]179
[46d958]180 // getter and setter
181
182 /**
183 * returns the World that contains this atom.
184 * Use this if you need to get the world without locking
185 * the singleton for example.
186 *
187 */
188 World *getWorld();
189 void setWorld(World*);
190
[ad2b411]191 virtual atomId_t getId() const;
[88d586]192 virtual bool changeId(atomId_t newId);
193
194 /**
195 * this function sets the Id without notifying the world. Only use it, if the world has already
196 * gotten an ID for this Atom.
197 */
198 virtual void setId(atomId_t);
199
[1363de]200 /** Returns pointer to the molecule which atom belongs to.
201 * \return containing molecule
202 */
[e41c48]203 molecule* getMolecule() const;
[1363de]204
205 /** Erases the atom in atom::mol's list of atoms and sets it to zero.
206 */
[6cfa36]207 void removeFromMolecule();
208
[1363de]209 /** Getter for ParticleInfo::Nr of the atom.
210 *
211 * @return index
212 */
[e8a21f]213 int getNr() const;
[1f8337]214
[d74077]215 // Output operator
216 std::ostream & operator << (std::ostream &ost) const;
217
[46d958]218 protected:
[6cfa36]219
[46d958]220 /**
221 * Protected constructor to ensure construction of atoms through the world.
222 * see World::createAtom()
223 */
224 atom();
225
226 /**
227 * Protected copy-constructor to ensure construction of atoms by cloning.
228 * see atom::clone()
229 */
230 atom(class atom *pointer);
231
232 /**
233 * Protected destructor to ensure destruction of atoms through the world.
234 * see World::destroyAtom()
235 */
236 virtual ~atom();
[0d9546]237 private:
238 friend class molecule;
239 friend class AtomicInfo;
240 /** Makes the atom be contained in the new molecule \a *_mol.
241 * Uses atom::removeFromMolecule() to delist from old molecule.
242 * \param *_mol pointer to new molecule
243 */
244 void setMolecule(molecule*);
245
246 /** Makes the atom be contained in the no molecule.
247 * Use atom::removeFromMolecule() to delist from old molecule,
248 * this assume that the molecule already knows about it.
249 */
250 void unsetMolecule();
251
252
[357fba]253 private:
[6cfa36]254 molecule *mol; // !< the molecule this atom belongs to
[46d958]255 World* world;
[88d586]256 atomId_t id;
[357fba]257};
258
[d74077]259/**
260 * Global output operator for class atom.
261 */
262std::ostream & operator << (std::ostream &ost, const atom &_atom);
263
[46d958]264/**
265 * internal method used by the world. Do not use if you don't know what you are doing.
266 * You might get burned...
267 * Use World::createAtom() instead.
268 */
[88d586]269atom* NewAtom(atomId_t _id);
[46d958]270
271/**
272* internal method used by the world. Do not use if you don't know what you are doing.
273 * You might get burned...
274 * Use World::destroyAtom() instead.
275 */
276void DeleteAtom(atom*);
277
[e5f64de]278/**
279 * Simple function to compare atoms by their elements to allow sorting of atoms by this criteria
280 */
281bool compareAtomElements(atom* atom1,atom* atom2);
282
[46d958]283
[357fba]284#endif /* ATOM_HPP_ */
Note: See TracBrowser for help on using the repository browser.