source: src/molecule.hpp@ 2a0271

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 2a0271 was 560bbe, checked in by Frederik Heber <heber@…>, 13 years ago

AtomicInfo now also (re)stores ParticleInfo::Nr, molecule has own IdPool.

  • molecule now also has an internal IdPool to be able to hand out unique ids, according to uniqueId policy.
  • new functions: molecule::changeAtomNr(), molecule::setAtomName()
  • molecule::erase() and ::insert() release and set the id (and the name).
  • molecule::setAtomName() uses getNr() with id increased by one.
  • AtomicInfo stores and sets ParticleInfo::Nr.
  • atom::changeNr() is similar to changeId() only for the molecule.
  • molecule::AddAtom() does not set the name anymore, is done by ::insert().
  • simplified molecule::doCountAtoms() a lot, no more naming of atoms.
  • SPEEDUP: This speeds up the GUI already a lot.
  • TESTFIX: changed regression test Tesselation/BigNonConvex due to different ordering of node ids (due to above), surface is still the same (checked).
  • Property mode set to 100755
File size: 8.4 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 const periodentafel * const elemente; //!< periodic table with each element
87 int MDSteps; //!< The number of MD steps in Trajectories
88 mutable int NoNonHydrogen; //!< number of non-hydrogen atoms in molecule
89 mutable int NoNonBonds; //!< number of non-hydrogen bonds in molecule
90 mutable int NoCyclicBonds; //!< number of cyclic bonds in molecule, by DepthFirstSearchAnalysis()
91 bool ActiveFlag; //!< in a MoleculeListClass used to discern active from inactive molecules
92 int IndexNr; //!< index of molecule in a MoleculeListClass
93 char name[MAXSTRINGSIZE]; //!< arbitrary name
94
95private:
96 Formula formula;
[458c31]97 Cacheable<int> AtomCount; //!< number of atoms, brought up-to-date by doCountAtoms()
98 Cacheable<int> BondCount; //!< number of atoms, brought up-to-date by doCountBonds()
[e4afb4]99 moleculeId_t id;
100 atomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms
[560bbe]101 IdPool<atomId_t, uniqueId> atomIdPool; //!< pool of internal ids such that way may guarantee uniqueness
102
[e4afb4]103protected:
[ac9b56]104
[e4afb4]105 molecule(const periodentafel * const teil);
106 virtual ~molecule();
[042f82]107
[cbc5fb]108public:
[520c8b]109 //getter and setter
[73a857]110 const std::string getName() const;
[ea7176]111 int getAtomCount() const;
112 int doCountAtoms();
[458c31]113 int getBondCount() const;
114 int doCountBonds() const;
[73a857]115 moleculeId_t getId() const;
[cbc5fb]116 void setId(moleculeId_t);
[520c8b]117 void setName(const std::string);
[73a857]118 const Formula &getFormula() const;
119 unsigned int getElementCount() const;
[389cc8]120 bool hasElement(const element*) const;
121 bool hasElement(atomicNumber_t) const;
122 bool hasElement(const std::string&) const;
123
[a7a087]124 virtual bool changeId(atomId_t newId);
[520c8b]125
[9317be]126 World::AtomComposite getAtomSet() const;
[3738f0]127
[bd58fb]128 iterator begin();
129 const_iterator begin() const;
[e87acf]130 iterator end();
131 const_iterator end() const;
[9879f6]132 bool empty() const;
133 size_t size() const;
[e4afb4]134 const_iterator find(atom * key) const;
135 pair<iterator, bool> insert(atom * const key);
[6cfa36]136 bool containsAtom(atom* key);
[bd58fb]137
[2e4105]138private:
139 friend void atom::removeFromMolecule();
140 /** Erase an atom from the list.
141 * \note This should only be called by atom::removeFromMolecule(),
142 * otherwise it is not assured that the atom knows about it.
143 *
144 * @param loc locator to atom in list
145 * @return iterator to just after removed item (compliant with standard)
146 */
147 const_iterator erase(const_iterator loc);
148 /** Erase an atom from the list.
149 * \note This should only be called by atom::removeFromMolecule(),
150 * otherwise it is not assured that the atom knows about it.
151 *
152 * @param *key key to atom in list
153 * @return iterator to just after removed item (compliant with standard)
154 */
155 const_iterator erase(atom * key);
156
[560bbe]157private:
158 friend bool atom::changeNr(int newId);
159 /**
160 * used when changing an ParticleInfo::Nr.
161 * Note that this number is local with this molecule.
162 * Unless you are calling this method from inside an atom don't fiddle with the third parameter.
163 *
164 * @param oldNr old Nr
165 * @param newNr new Nr to set
166 * @param *target ref to atom
167 * @return indicates wether the change could be done or not.
168 */
169 bool changeAtomNr(int oldNr, int newNr, atom* target=0);
170
171 /** Sets the name of the atom.
172 *
173 * The name is set via its element symbol and its internal ParticleInfo::Nr.
174 *
175 * @param _atom atom whose name to set
176 */
177 void setAtomName(atom *_atom) const;
178
[2e4105]179public:
180
[042f82]181 /// remove atoms from molecule.
182 bool AddAtom(atom *pointer);
183 bool RemoveAtom(atom *pointer);
184 bool UnlinkAtom(atom *pointer);
185 bool CleanupMolecule();
[9df680]186 void removeAtomsinMolecule();
[042f82]187
188 /// Add/remove atoms to/from molecule.
189 atom * AddCopyAtom(atom *pointer);
190 bool AddXYZFile(string filename);
[e138de]191 bool AddHydrogenReplacementAtom(bond *Bond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem);
[cee0b57]192 bond * AddBond(atom *first, atom *second, int degree = 1);
[042f82]193 bool RemoveBond(bond *pointer);
194 bool RemoveBonds(atom *BondPartner);
[e4afb4]195 bool hasBondStructure() const;
[042f82]196
197 /// Find atoms.
198 atom * FindAtom(int Nr) const;
199 atom * AskAtom(string text);
[59fff1]200 bool isInMolecule(const atom * const _atom);
[042f82]201
202 /// Count and change present atoms' coordination.
[e138de]203 bool CenterInBox();
204 bool BoundInBox();
205 void CenterEdge(Vector *max);
206 void CenterOrigin();
207 void CenterPeriodic();
208 void CenterAtVector(Vector *newcenter);
[042f82]209 void Translate(const Vector *x);
210 void TranslatePeriodically(const Vector *trans);
211 void Mirror(const Vector *x);
212 void Align(Vector *n);
[776b64]213 void Scale(const double ** const factor);
[07a47e]214 void DeterminePeriodicCenter(Vector &center, const enum HydrogenSaturation _saturation = DoSaturate);
[4bb63c]215 Vector * DetermineCenterOfGravity() const;
[e138de]216 Vector * DetermineCenterOfAll() const;
[eddea2]217 Vector * DetermineCenterOfBox() const;
[437922]218 void SetNameFromFilename(const char *filename);
[042f82]219 void SetBoxDimension(Vector *dim);
[3c58f8]220 bool ScanForPeriodicCorrection();
[e138de]221 double VolumeOfConvexEnvelope(bool IsAngstroem);
[1f91f4]222 RealSpaceMatrix getInertiaTensor() const;
223 void RotateToPrincipalAxisSystem(Vector &Axis);
[042f82]224
225 bool CheckBounds(const Vector *x) const;
226 void GetAlignvector(struct lsq_params * par) const;
227
228 /// Initialising routines in fragmentation
[e138de]229 void OutputBondsList() const;
[49c059]230
[266237]231 bond * CopyBond(atom *left, atom *right, bond *CopyBond);
232
[e4afb4]233 molecule *CopyMolecule() const;
[c550dd]234 molecule* CopyMoleculeFromSubRegion(const Shape&) const;
[042f82]235
236 /// Fragment molecule by two different approaches:
[e4afb4]237 bool StoreBondsToFile(std::string filename, std::string path = "");
238 bool StoreAdjacencyToFile(std::string filename, std::string path = "");
[9879f6]239 bool CreateFatherLookupTable(atom **&LookupTable, int count = 0);
[b9772a]240
[042f82]241 // Recognize doubly appearing molecules in a list of them
[e138de]242 int * GetFatherSonAtomicMap(molecule *OtherMolecule);
[99752a]243 bool FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList = false);
[c6123b]244 bool FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount);
[042f82]245
246 // Output routines.
[e4afb4]247 bool Output(std::ostream * const output) const;
248 bool OutputTrajectories(ofstream * const output) const;
[e138de]249 void OutputListOfBonds() const;
250 bool OutputXYZ(ofstream * const output) const;
251 bool OutputTrajectoriesXYZ(ofstream * const output);
252 bool Checkout(ofstream * const output) const;
[042f82]253
[c68025]254 // Manipulation routines
255 void flipActiveFlag();
256
[e4afb4]257private:
258 int last_atom; //!< number given to last atom
[14de469]259};
260
[cbc5fb]261molecule *NewMolecule();
262void DeleteMolecule(molecule* mol);
263
[14de469]264
265
266#endif /*MOLECULES_HPP_*/
267
Note: See TracBrowser for help on using the repository browser.