source: src/molecule.hpp@ 8e1f901

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 8e1f901 was 8e1f901, checked in by Frederik Heber <heber@…>, 13 years ago

molecule uses AtomIdSet now, rename getAtoms -> getAtomIds().

  • Property mode set to 100755
File size: 8.0 KB
Line 
1/** \file molecule.hpp
2 *
3 * Class definitions of atom and molecule, element and periodentafel
4 */
5
6#ifndef MOLECULES_HPP_
7#define MOLECULES_HPP_
8
9/*********************************************** includes ***********************************/
10
11#ifdef HAVE_CONFIG_H
12#include <config.h>
13#endif
14
15//// STL headers
16#include <map>
17#include <set>
18#include <stack>
19#include <deque>
20#include <list>
21#include <vector>
22
23#include <string>
24
25#include "AtomIdSet.hpp"
26#include "Atom/AtomSet.hpp"
27#include "CodePatterns/Cacheable.hpp"
28#include "CodePatterns/Observer/Observable.hpp"
29#include "Descriptors/AtomIdDescriptor.hpp"
30#include "Fragmentation/HydrogenSaturation_enum.hpp"
31#include "Formula.hpp"
32#include "Helpers/defs.hpp"
33#include "IdPool_policy.hpp"
34#include "IdPool.hpp"
35#include "types.hpp"
36
37/****************************************** forward declarations *****************************/
38
39class atom;
40class bond;
41class BondedParticle;
42class BondGraph;
43class DepthFirstSearchAnalysis;
44class element;
45class ForceMatrix;
46class Graph;
47class LinkedCell_deprecated;
48class molecule;
49class MoleculeLeafClass;
50class MoleculeListClass;
51class periodentafel;
52class RealSpaceMatrix;
53class Vector;
54class Shape;
55
56/************************************* Class definitions ****************************************/
57
58/** The complete molecule.
59 * Class incorporates number of types
60 */
61class molecule : public Observable
62{
63 friend molecule *NewMolecule();
64 friend void DeleteMolecule(molecule *);
65
66public:
67 typedef AtomIdSet::atomIdSet atomIdSet;
68 typedef AtomIdSet::iterator iterator;
69 typedef AtomIdSet::const_iterator const_iterator;
70
71 int MDSteps; //!< The number of MD steps in Trajectories
72 mutable int NoNonHydrogen; //!< number of non-hydrogen atoms in molecule
73 mutable int NoNonBonds; //!< number of non-hydrogen bonds in molecule
74 mutable int NoCyclicBonds; //!< number of cyclic bonds in molecule, by DepthFirstSearchAnalysis()
75 bool ActiveFlag; //!< in a MoleculeListClass used to discern active from inactive molecules
76 int IndexNr; //!< index of molecule in a MoleculeListClass
77 char name[MAXSTRINGSIZE]; //!< arbitrary name
78
79private:
80 Formula formula;
81 Cacheable<int> AtomCount; //!< number of atoms, brought up-to-date by doCountAtoms()
82 Cacheable<int> BondCount; //!< number of atoms, brought up-to-date by doCountBonds()
83 moleculeId_t id;
84 AtomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms
85 IdPool<atomId_t, uniqueId> atomIdPool; //!< pool of internal ids such that way may guarantee uniqueness
86
87protected:
88
89 molecule();
90 virtual ~molecule();
91
92public:
93 //getter and setter
94 const std::string getName() const;
95 int getAtomCount() const;
96 int doCountAtoms();
97 int getBondCount() const;
98 int doCountBonds() const;
99 moleculeId_t getId() const;
100 void setId(moleculeId_t);
101 void setName(const std::string);
102 const Formula &getFormula() const;
103 unsigned int getElementCount() const;
104 bool hasElement(const element*) const;
105 bool hasElement(atomicNumber_t) const;
106 bool hasElement(const std::string&) const;
107
108 virtual bool changeId(atomId_t newId);
109
110 World::AtomComposite getAtomSet() const;
111
112 // simply pass on all functions to AtomIdSet
113 iterator begin() {
114 return atomIds.begin();
115 }
116 const_iterator begin() const
117 {
118 return atomIds.begin();
119 }
120 iterator end()
121 {
122 return atomIds.end();
123 }
124 const_iterator end() const
125 {
126 return atomIds.end();
127 }
128 bool empty() const
129 {
130 return atomIds.empty();
131 }
132 size_t size() const
133 {
134 return atomIds.size();
135 }
136 const_iterator find(atom * key) const
137 {
138 return atomIds.find(key);
139 }
140 const atomIdSet & getAtomIds() const {
141 return atomIds.getAtomIds();
142 }
143
144 std::pair<iterator, bool> insert(atom * const key);
145
146 bool containsAtom(atom* key);
147
148private:
149 friend void atom::removeFromMolecule();
150 /** Erase an atom from the list.
151 * \note This should only be called by atom::removeFromMolecule(),
152 * otherwise it is not assured that the atom knows about it.
153 *
154 * @param loc locator to atom in list
155 * @return iterator to just after removed item (compliant with standard)
156 */
157 const_iterator erase(const_iterator loc);
158
159 /** Erase an atom from the list.
160 * \note This should only be called by atom::removeFromMolecule(),
161 * otherwise it is not assured that the atom knows about it.
162 *
163 * @param *key key to atom in list
164 * @return iterator to just after removed item (compliant with standard)
165 */
166 const_iterator erase(atom * key);
167
168private:
169 friend bool atom::changeNr(int newId);
170 /**
171 * used when changing an ParticleInfo::Nr.
172 * Note that this number is local with this molecule.
173 * Unless you are calling this method from inside an atom don't fiddle with the third parameter.
174 *
175 * @param oldNr old Nr
176 * @param newNr new Nr to set
177 * @param *target ref to atom
178 * @return indicates wether the change could be done or not.
179 */
180 bool changeAtomNr(int oldNr, int newNr, atom* target=0);
181
182 /** Sets the name of the atom.
183 *
184 * The name is set via its element symbol and its internal ParticleInfo::Nr.
185 *
186 * @param _atom atom whose name to set
187 */
188 void setAtomName(atom *_atom) const;
189
190public:
191
192 /// remove atoms from molecule.
193 bool AddAtom(atom *pointer);
194 bool RemoveAtom(atom *pointer);
195 bool UnlinkAtom(atom *pointer);
196 bool CleanupMolecule();
197 void removeAtomsinMolecule();
198
199 /// Add/remove atoms to/from molecule.
200 atom * AddCopyAtom(atom *pointer);
201 bool AddHydrogenReplacementAtom(bond *Bond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem);
202 bond * AddBond(atom *first, atom *second, int degree = 1);
203 bool RemoveBond(bond *pointer);
204 bool RemoveBonds(atom *BondPartner);
205 bool hasBondStructure() const;
206
207 /// Find atoms.
208 atom * FindAtom(int Nr) const;
209 atom * AskAtom(std::string text);
210 bool isInMolecule(const atom * const _atom);
211
212 /// Count and change present atoms' coordination.
213 bool CenterInBox();
214 bool BoundInBox();
215 void CenterEdge(Vector *max);
216 void CenterOrigin();
217 void CenterPeriodic();
218 void CenterAtVector(Vector *newcenter);
219 void Translate(const Vector *x);
220 void TranslatePeriodically(const Vector *trans);
221 void Mirror(const Vector *x);
222 void Align(Vector *n);
223 void Scale(const double ** const factor);
224 void DeterminePeriodicCenter(Vector &center, const enum HydrogenSaturation _saturation = DoSaturate);
225 Vector * DetermineCenterOfGravity() const;
226 Vector * DetermineCenterOfAll() const;
227 Vector * DetermineCenterOfBox() const;
228 void SetNameFromFilename(const char *filename);
229 void SetBoxDimension(Vector *dim);
230 bool ScanForPeriodicCorrection();
231 double VolumeOfConvexEnvelope(bool IsAngstroem);
232 RealSpaceMatrix getInertiaTensor() const;
233 void RotateToPrincipalAxisSystem(Vector &Axis);
234
235 bool CheckBounds(const Vector *x) const;
236 void GetAlignvector(struct lsq_params * par) const;
237
238 /// Initialising routines in fragmentation
239 void OutputBondsList() const;
240
241 bond * CopyBond(atom *left, atom *right, bond *CopyBond);
242
243 molecule *CopyMolecule() const;
244 molecule* CopyMoleculeFromSubRegion(const Shape&) const;
245
246 /// Fragment molecule by two different approaches:
247 bool StoreBondsToFile(std::string filename, std::string path = "");
248 bool StoreAdjacencyToFile(std::string filename, std::string path = "");
249 bool CreateFatherLookupTable(atom **&LookupTable, int count = 0);
250
251 // Recognize doubly appearing molecules in a list of them
252 int * GetFatherSonAtomicMap(molecule *OtherMolecule);
253 bool FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList = false);
254 bool FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount);
255
256 // Output routines.
257 bool Output(std::ostream * const output) const;
258 bool OutputTrajectories(ofstream * const output) const;
259 void OutputListOfBonds() const;
260 bool OutputXYZ(ofstream * const output) const;
261 bool OutputTrajectoriesXYZ(ofstream * const output);
262 bool Checkout(ofstream * const output) const;
263
264 // Manipulation routines
265 void flipActiveFlag();
266
267private:
268 int last_atom; //!< number given to last atom
269};
270
271molecule *NewMolecule();
272void DeleteMolecule(molecule* mol);
273
274
275
276#endif /*MOLECULES_HPP_*/
277
Note: See TracBrowser for help on using the repository browser.