source: src/molecule.hpp@ 12c4cb

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 12c4cb 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
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
[30c753]23#include <boost/iterator/transform_iterator.hpp>
24
[520c8b]25#include <string>
26
[6f0841]27#include "Atom/AtomSet.hpp"
[ad011c]28#include "CodePatterns/Cacheable.hpp"
[02ce36]29#include "CodePatterns/Observer/Observable.hpp"
30#include "CodePatterns/Observer/ObservedIterator.hpp"
[30c753]31#include "Descriptors/AtomIdDescriptor.hpp"
[07a47e]32#include "Fragmentation/HydrogenSaturation_enum.hpp"
[389cc8]33#include "Formula.hpp"
[30c753]34#include "Helpers/defs.hpp"
[560bbe]35#include "IdPool_policy.hpp"
36#include "IdPool.hpp"
[30c753]37#include "types.hpp"
[14de469]38
[30c753]39// TODO: Was is the include of MoleculeDescriptor_impl.hpp doing in molecule.hpp
[97ebf8]40#include "Descriptors/MoleculeDescriptor_impl.hpp"
41
[f66195]42/****************************************** forward declarations *****************************/
43
44class atom;
45class bond;
[b70721]46class BondedParticle;
47class BondGraph;
[49c059]48class DepthFirstSearchAnalysis;
[f66195]49class element;
50class ForceMatrix;
[dadc74]51class Graph;
[6bd7e0]52class LinkedCell_deprecated;
[14de469]53class molecule;
[2319ed]54class MoleculeLeafClass;
[14de469]55class MoleculeListClass;
[f66195]56class periodentafel;
[1f91f4]57class RealSpaceMatrix;
[f66195]58class Vector;
[c550dd]59class Shape;
[14de469]60
61/******************************** Some definitions for easier reading **********************************/
62
[30c753]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
[14de469]71/************************************* Class definitions ****************************************/
72
73/** The complete molecule.
74 * Class incorporates number of types
75 */
[34c43a]76class molecule : public Observable
[e4afb4]77{
[cbc5fb]78 friend molecule *NewMolecule();
79 friend void DeleteMolecule(molecule *);
[bd58fb]80
[e4afb4]81public:
82 typedef std::set<atomId_t> atomIdSet;
[30c753]83 typedef boost::transform_iterator<FromIdToAtom, atomIdSet::iterator, atom *, atomId_t> iterator;
[59fff1]84 typedef boost::transform_iterator<FromIdToAtom, atomIdSet::const_iterator, const atom *, atomId_t const &> const_iterator;
[e4afb4]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;
[458c31]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()
[e4afb4]98 moleculeId_t id;
99 atomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms
[560bbe]100 IdPool<atomId_t, uniqueId> atomIdPool; //!< pool of internal ids such that way may guarantee uniqueness
101
[e4afb4]102protected:
[ac9b56]103
[4d2b33]104 molecule();
[e4afb4]105 virtual ~molecule();
[042f82]106
[cbc5fb]107public:
[520c8b]108 //getter and setter
[73a857]109 const std::string getName() const;
[ea7176]110 int getAtomCount() const;
111 int doCountAtoms();
[458c31]112 int getBondCount() const;
113 int doCountBonds() const;
[73a857]114 moleculeId_t getId() const;
[cbc5fb]115 void setId(moleculeId_t);
[520c8b]116 void setName(const std::string);
[73a857]117 const Formula &getFormula() const;
118 unsigned int getElementCount() const;
[389cc8]119 bool hasElement(const element*) const;
120 bool hasElement(atomicNumber_t) const;
121 bool hasElement(const std::string&) const;
122
[a7a087]123 virtual bool changeId(atomId_t newId);
[520c8b]124
[9317be]125 World::AtomComposite getAtomSet() const;
[3738f0]126
[bd58fb]127 iterator begin();
128 const_iterator begin() const;
[e87acf]129 iterator end();
130 const_iterator end() const;
[9879f6]131 bool empty() const;
132 size_t size() const;
[e4afb4]133 const_iterator find(atom * key) const;
134 pair<iterator, bool> insert(atom * const key);
[6cfa36]135 bool containsAtom(atom* key);
[bd58fb]136
[2e4105]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
[560bbe]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
[2e4105]178public:
179
[042f82]180 /// remove atoms from molecule.
181 bool AddAtom(atom *pointer);
182 bool RemoveAtom(atom *pointer);
183 bool UnlinkAtom(atom *pointer);
184 bool CleanupMolecule();
[9df680]185 void removeAtomsinMolecule();
[042f82]186
187 /// Add/remove atoms to/from molecule.
188 atom * AddCopyAtom(atom *pointer);
[e138de]189 bool AddHydrogenReplacementAtom(bond *Bond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem);
[cee0b57]190 bond * AddBond(atom *first, atom *second, int degree = 1);
[042f82]191 bool RemoveBond(bond *pointer);
192 bool RemoveBonds(atom *BondPartner);
[e4afb4]193 bool hasBondStructure() const;
[042f82]194
195 /// Find atoms.
196 atom * FindAtom(int Nr) const;
[955b91]197 atom * AskAtom(std::string text);
[59fff1]198 bool isInMolecule(const atom * const _atom);
[042f82]199
200 /// Count and change present atoms' coordination.
[e138de]201 bool CenterInBox();
202 bool BoundInBox();
203 void CenterEdge(Vector *max);
204 void CenterOrigin();
205 void CenterPeriodic();
206 void CenterAtVector(Vector *newcenter);
[042f82]207 void Translate(const Vector *x);
208 void TranslatePeriodically(const Vector *trans);
209 void Mirror(const Vector *x);
210 void Align(Vector *n);
[776b64]211 void Scale(const double ** const factor);
[07a47e]212 void DeterminePeriodicCenter(Vector &center, const enum HydrogenSaturation _saturation = DoSaturate);
[4bb63c]213 Vector * DetermineCenterOfGravity() const;
[e138de]214 Vector * DetermineCenterOfAll() const;
[eddea2]215 Vector * DetermineCenterOfBox() const;
[437922]216 void SetNameFromFilename(const char *filename);
[042f82]217 void SetBoxDimension(Vector *dim);
[3c58f8]218 bool ScanForPeriodicCorrection();
[e138de]219 double VolumeOfConvexEnvelope(bool IsAngstroem);
[1f91f4]220 RealSpaceMatrix getInertiaTensor() const;
221 void RotateToPrincipalAxisSystem(Vector &Axis);
[042f82]222
223 bool CheckBounds(const Vector *x) const;
224 void GetAlignvector(struct lsq_params * par) const;
225
226 /// Initialising routines in fragmentation
[e138de]227 void OutputBondsList() const;
[49c059]228
[266237]229 bond * CopyBond(atom *left, atom *right, bond *CopyBond);
230
[e4afb4]231 molecule *CopyMolecule() const;
[c550dd]232 molecule* CopyMoleculeFromSubRegion(const Shape&) const;
[042f82]233
234 /// Fragment molecule by two different approaches:
[e4afb4]235 bool StoreBondsToFile(std::string filename, std::string path = "");
236 bool StoreAdjacencyToFile(std::string filename, std::string path = "");
[9879f6]237 bool CreateFatherLookupTable(atom **&LookupTable, int count = 0);
[b9772a]238
[042f82]239 // Recognize doubly appearing molecules in a list of them
[e138de]240 int * GetFatherSonAtomicMap(molecule *OtherMolecule);
[99752a]241 bool FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList = false);
[c6123b]242 bool FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount);
[042f82]243
244 // Output routines.
[e4afb4]245 bool Output(std::ostream * const output) const;
246 bool OutputTrajectories(ofstream * const output) const;
[e138de]247 void OutputListOfBonds() const;
248 bool OutputXYZ(ofstream * const output) const;
249 bool OutputTrajectoriesXYZ(ofstream * const output);
250 bool Checkout(ofstream * const output) const;
[042f82]251
[c68025]252 // Manipulation routines
253 void flipActiveFlag();
254
[e4afb4]255private:
256 int last_atom; //!< number given to last atom
[14de469]257};
258
[cbc5fb]259molecule *NewMolecule();
260void DeleteMolecule(molecule* mol);
261
[14de469]262
263
264#endif /*MOLECULES_HPP_*/
265
Note: See TracBrowser for help on using the repository browser.