source: src/molecule.hpp@ 50e4e5

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 50e4e5 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
RevLine 
[cee0b57]1/** \file molecule.hpp
[14de469]2 *
[69eb71]3 * Class definitions of atom and molecule, element and periodentafel
[14de469]4 */
5
6#ifndef MOLECULES_HPP_
7#define MOLECULES_HPP_
8
[f66195]9/*********************************************** includes ***********************************/
10
[962d8d]11#ifdef HAVE_CONFIG_H
12#include <config.h>
13#endif
14
[edb93c]15//// STL headers
[14de469]16#include <map>
17#include <set>
[a564be]18#include <stack>
[14de469]19#include <deque>
[d7e30c]20#include <list>
[5e0d1f]21#include <vector>
[14de469]22
[520c8b]23#include <string>
24
[68d781]25#include "types.hpp"
[ad011c]26#include "CodePatterns/Observer.hpp"
27#include "CodePatterns/ObservedIterator.hpp"
28#include "CodePatterns/Cacheable.hpp"
[07a47e]29#include "Fragmentation/HydrogenSaturation_enum.hpp"
[255829]30#include "Helpers/defs.hpp"
[389cc8]31#include "Formula.hpp"
[14d541]32#include "AtomSet.hpp"
[14de469]33
[97ebf8]34#include "Descriptors/MoleculeDescriptor_impl.hpp"
35
[f66195]36/****************************************** forward declarations *****************************/
37
38class atom;
39class bond;
[b70721]40class BondedParticle;
41class BondGraph;
[49c059]42class DepthFirstSearchAnalysis;
[f66195]43class element;
44class ForceMatrix;
[dadc74]45class Graph;
[f66195]46class LinkedCell;
[14de469]47class molecule;
[2319ed]48class MoleculeLeafClass;
[14de469]49class MoleculeListClass;
[f66195]50class periodentafel;
[1f91f4]51class RealSpaceMatrix;
[f66195]52class Vector;
[c550dd]53class Shape;
[14de469]54
55/******************************** Some definitions for easier reading **********************************/
56
57/************************************* Class definitions ****************************************/
58
59/** The complete molecule.
60 * Class incorporates number of types
61 */
[34c43a]62class molecule : public Observable
[e4afb4]63{
[cbc5fb]64 friend molecule *NewMolecule();
65 friend void DeleteMolecule(molecule *);
[bd58fb]66
[e4afb4]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;
[458c31]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()
[e4afb4]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, \
[d3347e]99 * since it will not lock
[e4afb4]100 */
101 typedef atomSet::iterator internal_iterator;
[ac9b56]102
[e4afb4]103 molecule(const periodentafel * const teil);
104 virtual ~molecule();
[042f82]105
[cbc5fb]106public:
[520c8b]107 //getter and setter
[73a857]108 const std::string getName() const;
[ea7176]109 int getAtomCount() const;
110 int doCountAtoms();
[458c31]111 int getBondCount() const;
112 int doCountBonds() const;
[73a857]113 moleculeId_t getId() const;
[cbc5fb]114 void setId(moleculeId_t);
[520c8b]115 void setName(const std::string);
[73a857]116 const Formula &getFormula() const;
117 unsigned int getElementCount() const;
[389cc8]118 bool hasElement(const element*) const;
119 bool hasElement(atomicNumber_t) const;
120 bool hasElement(const std::string&) const;
121
[a7a087]122 virtual bool changeId(atomId_t newId);
[520c8b]123
[9317be]124 World::AtomComposite getAtomSet() const;
[3738f0]125
[bd58fb]126 iterator begin();
127 const_iterator begin() const;
[e87acf]128 iterator end();
129 const_iterator end() const;
[9879f6]130 bool empty() const;
131 size_t size() const;
[e4afb4]132 const_iterator find(atom * key) const;
133 pair<iterator, bool> insert(atom * const key);
[6cfa36]134 bool containsAtom(atom* key);
[bd58fb]135
[2e4105]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
[042f82]157 /// remove atoms from molecule.
158 bool AddAtom(atom *pointer);
159 bool RemoveAtom(atom *pointer);
160 bool UnlinkAtom(atom *pointer);
161 bool CleanupMolecule();
[9df680]162 void removeAtomsinMolecule();
[042f82]163
164 /// Add/remove atoms to/from molecule.
165 atom * AddCopyAtom(atom *pointer);
166 bool AddXYZFile(string filename);
[e138de]167 bool AddHydrogenReplacementAtom(bond *Bond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem);
[cee0b57]168 bond * AddBond(atom *first, atom *second, int degree = 1);
[042f82]169 bool RemoveBond(bond *pointer);
170 bool RemoveBonds(atom *BondPartner);
[e4afb4]171 bool hasBondStructure() const;
[042f82]172
173 /// Find atoms.
174 atom * FindAtom(int Nr) const;
175 atom * AskAtom(string text);
176
177 /// Count and change present atoms' coordination.
[e138de]178 bool CenterInBox();
179 bool BoundInBox();
180 void CenterEdge(Vector *max);
181 void CenterOrigin();
182 void CenterPeriodic();
183 void CenterAtVector(Vector *newcenter);
[042f82]184 void Translate(const Vector *x);
185 void TranslatePeriodically(const Vector *trans);
186 void Mirror(const Vector *x);
187 void Align(Vector *n);
[776b64]188 void Scale(const double ** const factor);
[07a47e]189 void DeterminePeriodicCenter(Vector &center, const enum HydrogenSaturation _saturation = DoSaturate);
[4bb63c]190 Vector * DetermineCenterOfGravity() const;
[e138de]191 Vector * DetermineCenterOfAll() const;
[eddea2]192 Vector * DetermineCenterOfBox() const;
[437922]193 void SetNameFromFilename(const char *filename);
[042f82]194 void SetBoxDimension(Vector *dim);
[3c58f8]195 bool ScanForPeriodicCorrection();
[e138de]196 double VolumeOfConvexEnvelope(bool IsAngstroem);
[1f91f4]197 RealSpaceMatrix getInertiaTensor() const;
198 void RotateToPrincipalAxisSystem(Vector &Axis);
[042f82]199
200 bool CheckBounds(const Vector *x) const;
201 void GetAlignvector(struct lsq_params * par) const;
202
203 /// Initialising routines in fragmentation
[e138de]204 void OutputBondsList() const;
[49c059]205
[266237]206 bond * CopyBond(atom *left, atom *right, bond *CopyBond);
207
[e4afb4]208 molecule *CopyMolecule() const;
[c550dd]209 molecule* CopyMoleculeFromSubRegion(const Shape&) const;
[042f82]210
211 /// Fragment molecule by two different approaches:
[e4afb4]212 bool StoreBondsToFile(std::string filename, std::string path = "");
213 bool StoreAdjacencyToFile(std::string filename, std::string path = "");
[9879f6]214 bool CreateFatherLookupTable(atom **&LookupTable, int count = 0);
[b9772a]215
[042f82]216 // Recognize doubly appearing molecules in a list of them
[e138de]217 int * GetFatherSonAtomicMap(molecule *OtherMolecule);
[99752a]218 bool FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList = false);
[c6123b]219 bool FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount);
[042f82]220
221 // Output routines.
[e4afb4]222 bool Output(std::ostream * const output) const;
223 bool OutputTrajectories(ofstream * const output) const;
[e138de]224 void OutputListOfBonds() const;
225 bool OutputXYZ(ofstream * const output) const;
226 bool OutputTrajectoriesXYZ(ofstream * const output);
227 bool Checkout(ofstream * const output) const;
[042f82]228
[c68025]229 // Manipulation routines
230 void flipActiveFlag();
231
[e4afb4]232private:
233 int last_atom; //!< number given to last atom
[14de469]234};
235
[cbc5fb]236molecule *NewMolecule();
237void DeleteMolecule(molecule* mol);
238
[14de469]239
240
241#endif /*MOLECULES_HPP_*/
242
Note: See TracBrowser for help on using the repository browser.