source: src/molecule.hpp@ 936a02

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 936a02 was 07a47e, checked in by Frederik Heber <heber@…>, 13 years ago

Replaced enable/disable-hydrogen by internal switch.

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