source: src/molecule.hpp@ 5e6534

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 5e6534 was 4d2b33, checked in by Frederik Heber <heber@…>, 13 years ago

FIX: molecule does not need a periodentafel.

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