source: src/molecule.hpp@ 52575c

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 52575c was 5b6a4b7, checked in by Michael Ankele <ankele@…>, 12 years ago

molecule: RotateToPrincipalAxisSystem only needs a const Vector for axis

  • Property mode set to 100755
File size: 8.9 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 "Shapes/Shape.hpp"
36#include "types.hpp"
37
38/****************************************** forward declarations *****************************/
39
40class atom;
41class bond;
42class BondedParticle;
43class BondGraph;
44class DepthFirstSearchAnalysis;
45class element;
46class ForceMatrix;
47class Graph;
48class LinkedCell_deprecated;
49class molecule;
50class MoleculeLeafClass;
51class MoleculeListClass;
52class MoleculeUnittest;
53class RealSpaceMatrix;
54class Vector;
55
56/************************************* Class definitions ****************************************/
57
58/** The complete molecule.
59 * Class incorporates number of types
60 */
61class molecule : public Observable
62{
63 //!> grant unit test access
64 friend class MoleculeUnittest;
65 //!> function may access cstor
66 friend molecule *NewMolecule();
67 //!> function may access dstor
68 friend void DeleteMolecule(molecule *);
69
70public:
71 typedef AtomIdSet::atomIdSet atomIdSet;
72 typedef AtomIdSet::iterator iterator;
73 typedef AtomIdSet::const_iterator const_iterator;
74
75 int MDSteps; //!< The number of MD steps in Trajectories
76 mutable int NoNonBonds; //!< number of non-hydrogen bonds in molecule
77 mutable int NoCyclicBonds; //!< number of cyclic bonds in molecule, by DepthFirstSearchAnalysis()
78 bool ActiveFlag; //!< in a MoleculeListClass used to discern active from inactive molecules
79 int IndexNr; //!< index of molecule in a MoleculeListClass
80 char name[MAXSTRINGSIZE]; //!< arbitrary name
81
82private:
83 Formula formula;
84 Cacheable<size_t> NoNonHydrogen; //!< number of non-hydrogen atoms in molecule
85 Cacheable<int> BondCount; //!< number of atoms, brought up-to-date by doCountBonds()
86 moleculeId_t id;
87 AtomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms
88 IdPool<atomId_t, uniqueId> atomIdPool; //!< pool of internal ids such that way may guarantee uniqueness
89
90protected:
91
92 molecule();
93 virtual ~molecule();
94
95public:
96
97 /******* Notifications *******/
98
99 //!> enumeration of present notification types: only insertion/removal of atoms or molecules
100 enum NotificationType {
101 AtomInserted,
102 AtomRemoved,
103 AtomNrChanged,
104 MoleculeNameChanged,
105 NotificationType_MAX
106 };
107
108public:
109 //getter and setter
110 const std::string getName() const;
111 int getAtomCount() const;
112 size_t doCountNoNonHydrogen() const;
113 size_t getNoNonHydrogen() const;
114 int getBondCount() const;
115 int doCountBonds() const;
116 moleculeId_t getId() const;
117 void setId(moleculeId_t);
118 void setName(const std::string);
119 const Formula &getFormula() const;
120 unsigned int getElementCount() const;
121 bool hasElement(const element*) const;
122 bool hasElement(atomicNumber_t) const;
123 bool hasElement(const std::string&) const;
124
125 virtual bool changeId(atomId_t newId);
126
127 World::AtomComposite getAtomSet() const;
128
129 // simply pass on all functions to AtomIdSet
130 iterator begin() {
131 return atomIds.begin();
132 }
133 const_iterator begin() const
134 {
135 return atomIds.begin();
136 }
137 iterator end()
138 {
139 return atomIds.end();
140 }
141 const_iterator end() const
142 {
143 return atomIds.end();
144 }
145 bool empty() const
146 {
147 return atomIds.empty();
148 }
149 size_t size() const
150 {
151 return atomIds.size();
152 }
153 const_iterator find(atom * key) const
154 {
155 return atomIds.find(key);
156 }
157
158 /** Returns the set of atomic ids contained in this molecule.
159 *
160 * @return set of atomic ids
161 */
162 const atomIdSet & getAtomIds() const {
163 return atomIds.getAtomIds();
164 }
165
166 std::pair<iterator, bool> insert(atom * const key);
167
168 /** Predicate whether given \a key is contained in this molecule.
169 *
170 * @param key atom to check
171 * @return true - is contained, false - else
172 */
173 bool containsAtom(const atom* key) const
174 {
175 return atomIds.contains(key);
176 }
177
178 /** Predicate whether given \a id is contained in this molecule.
179 *
180 * @param id atomic id to check
181 * @return true - is contained, false - else
182 */
183 bool containsAtom(const atomId_t id) const
184 {
185 return atomIds.contains(id);
186 }
187
188private:
189 friend void atom::removeFromMolecule();
190 /** Erase an atom from the list.
191 * \note This should only be called by atom::removeFromMolecule(),
192 * otherwise it is not assured that the atom knows about it.
193 *
194 * @param loc locator to atom in list
195 * @return iterator to just after removed item (compliant with standard)
196 */
197 const_iterator erase(const_iterator loc);
198
199 /** Erase an atom from the list.
200 * \note This should only be called by atom::removeFromMolecule(),
201 * otherwise it is not assured that the atom knows about it.
202 *
203 * @param *key key to atom in list
204 * @return iterator to just after removed item (compliant with standard)
205 */
206 const_iterator erase(atom * key);
207
208private:
209 friend bool atom::changeNr(int newId);
210 /**
211 * used when changing an ParticleInfo::Nr.
212 * Note that this number is local with this molecule.
213 * Unless you are calling this method from inside an atom don't fiddle with the third parameter.
214 *
215 * @param oldNr old Nr
216 * @param newNr new Nr to set
217 * @param *target ref to atom
218 * @return indicates wether the change could be done or not.
219 */
220 bool changeAtomNr(int oldNr, int newNr, atom* target=0);
221
222 /** Sets the name of the atom.
223 *
224 * The name is set via its element symbol and its internal ParticleInfo::Nr.
225 *
226 * @param _atom atom whose name to set
227 */
228 void setAtomName(atom *_atom) const;
229
230public:
231
232 /** Function to create a bounding spherical shape for the currently associated atoms.
233 *
234 */
235 Shape getBoundingShape() const;
236
237 /// remove atoms from molecule.
238 bool AddAtom(atom *pointer);
239 bool RemoveAtom(atom *pointer);
240 bool UnlinkAtom(atom *pointer);
241 bool CleanupMolecule();
242 void removeAtomsinMolecule();
243
244 /// Add/remove atoms to/from molecule.
245 atom * AddCopyAtom(atom *pointer);
246 bool AddHydrogenReplacementAtom(bond *Bond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem);
247 bond * AddBond(atom *first, atom *second, int degree = 1);
248 bool RemoveBond(bond *pointer);
249 bool RemoveBonds(atom *BondPartner);
250 bool hasBondStructure() const;
251
252 /// Find atoms.
253 atom * FindAtom(int Nr) const;
254 atom * AskAtom(std::string text);
255 bool isInMolecule(const atom * const _atom);
256
257 /// Count and change present atoms' coordination.
258 bool CenterInBox();
259 bool BoundInBox();
260 void CenterEdge(Vector *max);
261 void CenterOrigin();
262 void CenterPeriodic();
263 void CenterAtVector(Vector *newcenter);
264 void Translate(const Vector *x);
265 void TranslatePeriodically(const Vector *trans);
266 void Mirror(const Vector *x);
267 void Align(Vector *n);
268 void Scale(const double ** const factor);
269 void DeterminePeriodicCenter(Vector &center, const enum HydrogenSaturation _saturation = DoSaturate);
270 Vector * DetermineCenterOfGravity() const;
271 Vector * DetermineCenterOfAll() const;
272 Vector * DetermineCenterOfBox() const;
273 void SetNameFromFilename(const char *filename);
274 void SetBoxDimension(Vector *dim);
275 bool ScanForPeriodicCorrection();
276 double VolumeOfConvexEnvelope(bool IsAngstroem);
277 RealSpaceMatrix getInertiaTensor() const;
278 void RotateToPrincipalAxisSystem(const Vector &Axis);
279
280 bool CheckBounds(const Vector *x) const;
281 void GetAlignvector(struct lsq_params * par) const;
282
283 /// Initialising routines in fragmentation
284 void OutputBondsList() const;
285
286 bond * CopyBond(atom *left, atom *right, bond *CopyBond);
287
288 molecule *CopyMolecule(const Vector &offset = zeroVec) const;
289 molecule* CopyMoleculeFromSubRegion(const Shape&) const;
290
291 /// Fragment molecule by two different approaches:
292 bool StoreBondsToFile(std::string filename, std::string path = "");
293 bool StoreAdjacencyToFile(std::string filename, std::string path = "");
294 bool CreateFatherLookupTable(atom **&LookupTable, int count = 0);
295
296 // Recognize doubly appearing molecules in a list of them
297 int * GetFatherSonAtomicMap(molecule *OtherMolecule);
298 bool FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList = false);
299 bool FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount);
300
301 // Output routines.
302 bool Output(std::ostream * const output) const;
303 void OutputListOfBonds() const;
304
305 // Manipulation routines
306 void flipActiveFlag();
307
308private:
309 int last_atom; //!< number given to last atom
310};
311
312molecule *NewMolecule();
313void DeleteMolecule(molecule* mol);
314
315
316
317#endif /*MOLECULES_HPP_*/
318
Note: See TracBrowser for help on using the repository browser.