source: src/molecule.hpp@ 75363b

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 75363b was 42127c, checked in by Frederik Heber <heber@…>, 14 years ago

Extracted definition of MoleculeListClass and put into own header module.

  • Property mode set to 100755
File size: 7.5 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 "types.hpp"
26#include "CodePatterns/Observer.hpp"
27#include "CodePatterns/ObservedIterator.hpp"
28#include "CodePatterns/Cacheable.hpp"
29#include "Helpers/defs.hpp"
30#include "Formula.hpp"
31#include "AtomSet.hpp"
32
33#include "Descriptors/MoleculeDescriptor_impl.hpp"
34
35/****************************************** forward declarations *****************************/
36
37class atom;
38class bond;
39class BondedParticle;
40class BondGraph;
41class DepthFirstSearchAnalysis;
42class element;
43class ForceMatrix;
44class Graph;
45class LinkedCell;
46class molecule;
47class MoleculeLeafClass;
48class MoleculeListClass;
49class periodentafel;
50class RealSpaceMatrix;
51class Vector;
52class Shape;
53
54/******************************** Some definitions for easier reading **********************************/
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 ATOMSET(std::list) atomSet;
68 typedef std::set<atomId_t> atomIdSet;
69 typedef ObservedIterator<atomSet> iterator;
70 typedef atomSet::const_iterator const_iterator;
71
72 const periodentafel * const elemente; //!< periodic table with each element
73 // old deprecated atom handling
74 //atom *start; //!< start of atom list
75 //atom *end; //!< end of atom list
76 //bond *first; //!< start of bond list
77 //bond *last; //!< end of bond list
78 int MDSteps; //!< The number of MD steps in Trajectories
79 mutable int NoNonHydrogen; //!< number of non-hydrogen atoms in molecule
80 mutable int NoNonBonds; //!< number of non-hydrogen bonds in molecule
81 mutable int NoCyclicBonds; //!< number of cyclic bonds in molecule, by DepthFirstSearchAnalysis()
82 bool ActiveFlag; //!< in a MoleculeListClass used to discern active from inactive molecules
83 //Vector Center; //!< Center of molecule in a global box
84 int IndexNr; //!< index of molecule in a MoleculeListClass
85 char name[MAXSTRINGSIZE]; //!< arbitrary name
86
87private:
88 Formula formula;
89 Cacheable<int> AtomCount; //!< number of atoms, brought up-to-date by doCountAtoms()
90 Cacheable<int> BondCount; //!< number of atoms, brought up-to-date by doCountBonds()
91 moleculeId_t id;
92 atomSet atoms; //<!list of atoms
93 atomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms
94protected:
95 //void CountAtoms();
96 /**
97 * this iterator type should be used for internal variables, \
98 * since it will not lock
99 */
100 typedef atomSet::iterator internal_iterator;
101
102 molecule(const periodentafel * const teil);
103 virtual ~molecule();
104
105public:
106 //getter and setter
107 const std::string getName() const;
108 int getAtomCount() const;
109 int doCountAtoms();
110 int getBondCount() const;
111 int doCountBonds() const;
112 moleculeId_t getId() const;
113 void setId(moleculeId_t);
114 void setName(const std::string);
115 const Formula &getFormula() const;
116 unsigned int getElementCount() const;
117 bool hasElement(const element*) const;
118 bool hasElement(atomicNumber_t) const;
119 bool hasElement(const std::string&) const;
120
121 virtual bool changeId(atomId_t newId);
122
123 World::AtomComposite getAtomSet() const;
124
125 iterator begin();
126 const_iterator begin() const;
127 iterator end();
128 const_iterator end() const;
129 bool empty() const;
130 size_t size() const;
131 const_iterator find(atom * key) const;
132 pair<iterator, bool> insert(atom * const key);
133 bool containsAtom(atom* key);
134
135private:
136 friend void atom::removeFromMolecule();
137 /** Erase an atom from the list.
138 * \note This should only be called by atom::removeFromMolecule(),
139 * otherwise it is not assured that the atom knows about it.
140 *
141 * @param loc locator to atom in list
142 * @return iterator to just after removed item (compliant with standard)
143 */
144 const_iterator erase(const_iterator loc);
145 /** Erase an atom from the list.
146 * \note This should only be called by atom::removeFromMolecule(),
147 * otherwise it is not assured that the atom knows about it.
148 *
149 * @param *key key to atom in list
150 * @return iterator to just after removed item (compliant with standard)
151 */
152 const_iterator erase(atom * key);
153
154public:
155
156 /// remove atoms from molecule.
157 bool AddAtom(atom *pointer);
158 bool RemoveAtom(atom *pointer);
159 bool UnlinkAtom(atom *pointer);
160 bool CleanupMolecule();
161 void removeAtomsinMolecule();
162
163 /// Add/remove atoms to/from molecule.
164 atom * AddCopyAtom(atom *pointer);
165 bool AddXYZFile(string filename);
166 bool AddHydrogenReplacementAtom(bond *Bond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem);
167 bond * AddBond(atom *first, atom *second, int degree = 1);
168 bool RemoveBond(bond *pointer);
169 bool RemoveBonds(atom *BondPartner);
170 bool hasBondStructure() const;
171
172 /// Find atoms.
173 atom * FindAtom(int Nr) const;
174 atom * AskAtom(string text);
175
176 /// Count and change present atoms' coordination.
177 bool CenterInBox();
178 bool BoundInBox();
179 void CenterEdge(Vector *max);
180 void CenterOrigin();
181 void CenterPeriodic();
182 void CenterAtVector(Vector *newcenter);
183 void Translate(const Vector *x);
184 void TranslatePeriodically(const Vector *trans);
185 void Mirror(const Vector *x);
186 void Align(Vector *n);
187 void Scale(const double ** const factor);
188 void DeterminePeriodicCenter(Vector &center);
189 Vector * DetermineCenterOfGravity() const;
190 Vector * DetermineCenterOfAll() const;
191 Vector * DetermineCenterOfBox() const;
192 void SetNameFromFilename(const char *filename);
193 void SetBoxDimension(Vector *dim);
194 bool ScanForPeriodicCorrection();
195 double VolumeOfConvexEnvelope(bool IsAngstroem);
196 RealSpaceMatrix getInertiaTensor() const;
197 void RotateToPrincipalAxisSystem(Vector &Axis);
198
199 bool CheckBounds(const Vector *x) const;
200 void GetAlignvector(struct lsq_params * par) const;
201
202 /// Initialising routines in fragmentation
203 void OutputBondsList() const;
204
205 bond * CopyBond(atom *left, atom *right, bond *CopyBond);
206
207 molecule *CopyMolecule() const;
208 molecule* CopyMoleculeFromSubRegion(const Shape&) const;
209
210 /// Fragment molecule by two different approaches:
211 bool StoreBondsToFile(std::string filename, std::string path = "");
212 bool StoreAdjacencyToFile(std::string filename, std::string path = "");
213 bool CreateFatherLookupTable(atom **&LookupTable, int count = 0);
214
215 // Recognize doubly appearing molecules in a list of them
216 int * GetFatherSonAtomicMap(molecule *OtherMolecule);
217 bool FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList = false);
218 bool FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount);
219
220 // Output routines.
221 bool Output(std::ostream * const output) const;
222 bool OutputTrajectories(ofstream * const output) const;
223 void OutputListOfBonds() const;
224 bool OutputXYZ(ofstream * const output) const;
225 bool OutputTrajectoriesXYZ(ofstream * const output);
226 bool Checkout(ofstream * const output) const;
227
228 // Manipulation routines
229 void flipActiveFlag();
230
231private:
232 int last_atom; //!< number given to last atom
233};
234
235molecule *NewMolecule();
236void DeleteMolecule(molecule* mol);
237
238
239
240#endif /*MOLECULES_HPP_*/
241
Note: See TracBrowser for help on using the repository browser.