/** \file molecule.hpp * * Class definitions of atom and molecule, element and periodentafel */ #ifndef MOLECULES_HPP_ #define MOLECULES_HPP_ /*********************************************** includes ***********************************/ #ifdef HAVE_CONFIG_H #include #endif //// STL headers #include #include #include #include #include #include #include #include "types.hpp" #include "CodePatterns/Observer.hpp" #include "CodePatterns/ObservedIterator.hpp" #include "CodePatterns/Cacheable.hpp" #include "Fragmentation/HydrogenSaturation_enum.hpp" #include "Helpers/defs.hpp" #include "Formula.hpp" #include "AtomSet.hpp" #include "Descriptors/MoleculeDescriptor_impl.hpp" /****************************************** forward declarations *****************************/ class atom; class bond; class BondedParticle; class BondGraph; class DepthFirstSearchAnalysis; class element; class ForceMatrix; class Graph; class LinkedCell; class molecule; class MoleculeLeafClass; class MoleculeListClass; class periodentafel; class RealSpaceMatrix; class Vector; class Shape; /******************************** Some definitions for easier reading **********************************/ /************************************* Class definitions ****************************************/ /** The complete molecule. * Class incorporates number of types */ class molecule : public Observable { friend molecule *NewMolecule(); friend void DeleteMolecule(molecule *); public: typedef ATOMSET(std::list) atomSet; typedef std::set atomIdSet; typedef ObservedIterator iterator; typedef atomSet::const_iterator const_iterator; const periodentafel * const elemente; //!< periodic table with each element // old deprecated atom handling //atom *start; //!< start of atom list //atom *end; //!< end of atom list //bond *first; //!< start of bond list //bond *last; //!< end of bond list int MDSteps; //!< The number of MD steps in Trajectories mutable int NoNonHydrogen; //!< number of non-hydrogen atoms in molecule mutable int NoNonBonds; //!< number of non-hydrogen bonds in molecule mutable int NoCyclicBonds; //!< number of cyclic bonds in molecule, by DepthFirstSearchAnalysis() bool ActiveFlag; //!< in a MoleculeListClass used to discern active from inactive molecules //Vector Center; //!< Center of molecule in a global box int IndexNr; //!< index of molecule in a MoleculeListClass char name[MAXSTRINGSIZE]; //!< arbitrary name private: Formula formula; Cacheable AtomCount; //!< number of atoms, brought up-to-date by doCountAtoms() Cacheable BondCount; //!< number of atoms, brought up-to-date by doCountBonds() moleculeId_t id; atomSet atoms; // insert(atom * const key); bool containsAtom(atom* key); private: friend void atom::removeFromMolecule(); /** Erase an atom from the list. * \note This should only be called by atom::removeFromMolecule(), * otherwise it is not assured that the atom knows about it. * * @param loc locator to atom in list * @return iterator to just after removed item (compliant with standard) */ const_iterator erase(const_iterator loc); /** Erase an atom from the list. * \note This should only be called by atom::removeFromMolecule(), * otherwise it is not assured that the atom knows about it. * * @param *key key to atom in list * @return iterator to just after removed item (compliant with standard) */ const_iterator erase(atom * key); public: /// remove atoms from molecule. bool AddAtom(atom *pointer); bool RemoveAtom(atom *pointer); bool UnlinkAtom(atom *pointer); bool CleanupMolecule(); void removeAtomsinMolecule(); /// Add/remove atoms to/from molecule. atom * AddCopyAtom(atom *pointer); bool AddXYZFile(string filename); bool AddHydrogenReplacementAtom(bond *Bond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem); bond * AddBond(atom *first, atom *second, int degree = 1); bool RemoveBond(bond *pointer); bool RemoveBonds(atom *BondPartner); bool hasBondStructure() const; /// Find atoms. atom * FindAtom(int Nr) const; atom * AskAtom(string text); /// Count and change present atoms' coordination. bool CenterInBox(); bool BoundInBox(); void CenterEdge(Vector *max); void CenterOrigin(); void CenterPeriodic(); void CenterAtVector(Vector *newcenter); void Translate(const Vector *x); void TranslatePeriodically(const Vector *trans); void Mirror(const Vector *x); void Align(Vector *n); void Scale(const double ** const factor); void DeterminePeriodicCenter(Vector ¢er, const enum HydrogenSaturation _saturation = DoSaturate); Vector * DetermineCenterOfGravity() const; Vector * DetermineCenterOfAll() const; Vector * DetermineCenterOfBox() const; void SetNameFromFilename(const char *filename); void SetBoxDimension(Vector *dim); bool ScanForPeriodicCorrection(); double VolumeOfConvexEnvelope(bool IsAngstroem); RealSpaceMatrix getInertiaTensor() const; void RotateToPrincipalAxisSystem(Vector &Axis); bool CheckBounds(const Vector *x) const; void GetAlignvector(struct lsq_params * par) const; /// Initialising routines in fragmentation void OutputBondsList() const; bond * CopyBond(atom *left, atom *right, bond *CopyBond); molecule *CopyMolecule() const; molecule* CopyMoleculeFromSubRegion(const Shape&) const; /// Fragment molecule by two different approaches: bool StoreBondsToFile(std::string filename, std::string path = ""); bool StoreAdjacencyToFile(std::string filename, std::string path = ""); bool CreateFatherLookupTable(atom **&LookupTable, int count = 0); // Recognize doubly appearing molecules in a list of them int * GetFatherSonAtomicMap(molecule *OtherMolecule); bool FillBondStructureFromReference(const molecule * const reference, atom **&ListOfLocalAtoms, bool FreeList = false); bool FillListOfLocalAtoms(atom **&ListOfLocalAtoms, const int GlobalAtomCount); // Output routines. bool Output(std::ostream * const output) const; bool OutputTrajectories(ofstream * const output) const; void OutputListOfBonds() const; bool OutputXYZ(ofstream * const output) const; bool OutputTrajectoriesXYZ(ofstream * const output); bool Checkout(ofstream * const output) const; // Manipulation routines void flipActiveFlag(); private: int last_atom; //!< number given to last atom }; molecule *NewMolecule(); void DeleteMolecule(molecule* mol); #endif /*MOLECULES_HPP_*/