| 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 | using namespace std; | 
|---|
| 10 |  | 
|---|
| 11 | /*********************************************** includes ***********************************/ | 
|---|
| 12 |  | 
|---|
| 13 | // GSL headers | 
|---|
| 14 | #include <gsl/gsl_eigen.h> | 
|---|
| 15 | #include <gsl/gsl_heapsort.h> | 
|---|
| 16 | #include <gsl/gsl_linalg.h> | 
|---|
| 17 | #include <gsl/gsl_matrix.h> | 
|---|
| 18 | #include <gsl/gsl_multimin.h> | 
|---|
| 19 | #include <gsl/gsl_vector.h> | 
|---|
| 20 | #include <gsl/gsl_randist.h> | 
|---|
| 21 |  | 
|---|
| 22 | //// STL headers | 
|---|
| 23 | #include <map> | 
|---|
| 24 | #include <set> | 
|---|
| 25 | #include <deque> | 
|---|
| 26 | #include <list> | 
|---|
| 27 | #include <vector> | 
|---|
| 28 |  | 
|---|
| 29 | #include <string> | 
|---|
| 30 |  | 
|---|
| 31 | #include "graph.hpp" | 
|---|
| 32 | #include "stackclass.hpp" | 
|---|
| 33 | #include "tesselation.hpp" | 
|---|
| 34 | #include "Patterns/Observer.hpp" | 
|---|
| 35 | #include "Patterns/Cacheable.hpp" | 
|---|
| 36 |  | 
|---|
| 37 | /****************************************** forward declarations *****************************/ | 
|---|
| 38 |  | 
|---|
| 39 | class atom; | 
|---|
| 40 | class bond; | 
|---|
| 41 | class BondedParticle; | 
|---|
| 42 | class BondGraph; | 
|---|
| 43 | class element; | 
|---|
| 44 | class ForceMatrix; | 
|---|
| 45 | class LinkedCell; | 
|---|
| 46 | class molecule; | 
|---|
| 47 | class MoleculeLeafClass; | 
|---|
| 48 | class MoleculeListClass; | 
|---|
| 49 | class periodentafel; | 
|---|
| 50 | class Vector; | 
|---|
| 51 |  | 
|---|
| 52 | /******************************** Some definitions for easier reading **********************************/ | 
|---|
| 53 |  | 
|---|
| 54 | #define MoleculeList list <molecule *> | 
|---|
| 55 | #define MoleculeListTest pair <MoleculeList::iterator, bool> | 
|---|
| 56 |  | 
|---|
| 57 | #define DistancePair pair < double, atom* > | 
|---|
| 58 | #define DistanceMap multimap < double, atom* > | 
|---|
| 59 | #define DistanceTestPair pair < DistanceMap::iterator, bool> | 
|---|
| 60 |  | 
|---|
| 61 |  | 
|---|
| 62 | /************************************* Class definitions ****************************************/ | 
|---|
| 63 |  | 
|---|
| 64 | /** Structure to contain parameters needed for evaluation of constraint potential. | 
|---|
| 65 | */ | 
|---|
| 66 | struct EvaluatePotential | 
|---|
| 67 | { | 
|---|
| 68 | int startstep;              //!< start configuration (MDStep in atom::trajectory) | 
|---|
| 69 | int endstep;                //!< end configuration (MDStep in atom::trajectory) | 
|---|
| 70 | atom **PermutationMap;      //!< gives target ptr for each atom, array of size molecule::AtomCount (this is "x" in \f$ V^{con}(x) \f$ ) | 
|---|
| 71 | DistanceMap **DistanceList; //!< distance list of each atom to each atom | 
|---|
| 72 | DistanceMap::iterator *StepList; //!< iterator to ascend through NearestNeighbours \a **DistanceList | 
|---|
| 73 | int *DoubleList;            //!< count of which sources want to move to this target, basically the injective measure (>1 -> not injective) | 
|---|
| 74 | DistanceMap::iterator *DistanceIterators; //!< marks which was the last picked target as injective candidate with smallest distance | 
|---|
| 75 | bool IsAngstroem;           //!< whether coordinates are in angstroem (true) or bohrradius (false) | 
|---|
| 76 | double *PenaltyConstants;   //!<  penalty constant in front of each term | 
|---|
| 77 | }; | 
|---|
| 78 |  | 
|---|
| 79 | #define MaxThermostats 6      //!< maximum number of thermostat entries in Ions#ThermostatNames and Ions#ThermostatImplemented | 
|---|
| 80 | enum thermostats { None, Woodcock, Gaussian, Langevin, Berendsen, NoseHoover };   //!< Thermostat names for output | 
|---|
| 81 |  | 
|---|
| 82 |  | 
|---|
| 83 | /** The complete molecule. | 
|---|
| 84 | * Class incorporates number of types | 
|---|
| 85 | */ | 
|---|
| 86 | class molecule : public PointCloud , public Observable { | 
|---|
| 87 | public: | 
|---|
| 88 | double cell_size[6];//!< cell size | 
|---|
| 89 | const periodentafel * const elemente; //!< periodic table with each element | 
|---|
| 90 | atom *start;        //!< start of atom list | 
|---|
| 91 | atom *end;          //!< end of atom list | 
|---|
| 92 | bond *first;        //!< start of bond list | 
|---|
| 93 | bond *last;         //!< end of bond list | 
|---|
| 94 | int MDSteps;        //!< The number of MD steps in Trajectories | 
|---|
| 95 | int AtomCount;          //!< number of atoms, brought up-to-date by CountAtoms() | 
|---|
| 96 | int BondCount;          //!< number of atoms, brought up-to-date by CountBonds() | 
|---|
| 97 | int ElementCount;       //!< how many unique elements are therein | 
|---|
| 98 | int ElementsInMolecule[MAX_ELEMENTS]; //!< list whether element (sorted by atomic number) is alread present or not | 
|---|
| 99 | mutable int NoNonHydrogen;  //!< number of non-hydrogen atoms in molecule | 
|---|
| 100 | mutable int NoNonBonds;     //!< number of non-hydrogen bonds in molecule | 
|---|
| 101 | mutable int NoCyclicBonds;  //!< number of cyclic bonds in molecule, by DepthFirstSearchAnalysis() | 
|---|
| 102 | double BondDistance;  //!< typical bond distance used in CreateAdjacencyList() and furtheron | 
|---|
| 103 | bool ActiveFlag;    //!< in a MoleculeListClass used to discern active from inactive molecules | 
|---|
| 104 | Vector Center;      //!< Center of molecule in a global box | 
|---|
| 105 | int IndexNr;        //!< index of molecule in a MoleculeListClass | 
|---|
| 106 | char name[MAXSTRINGSIZE];         //!< arbitrary name | 
|---|
| 107 |  | 
|---|
| 108 | private: | 
|---|
| 109 | Cacheable<string> formula; | 
|---|
| 110 |  | 
|---|
| 111 | public: | 
|---|
| 112 | molecule(const periodentafel * const teil); | 
|---|
| 113 | virtual ~molecule(); | 
|---|
| 114 |  | 
|---|
| 115 | //getter and setter | 
|---|
| 116 | const std::string getName(); | 
|---|
| 117 | void setName(const std::string); | 
|---|
| 118 | const std::string getFormula(); | 
|---|
| 119 | std::string calcFormula(); | 
|---|
| 120 |  | 
|---|
| 121 | // re-definition of virtual functions from PointCloud | 
|---|
| 122 | const char * const GetName() const; | 
|---|
| 123 | Vector *GetCenter() const ; | 
|---|
| 124 | TesselPoint *GetPoint() const ; | 
|---|
| 125 | TesselPoint *GetTerminalPoint() const ; | 
|---|
| 126 | int GetMaxId() const; | 
|---|
| 127 | void GoToNext() const ; | 
|---|
| 128 | void GoToPrevious() const ; | 
|---|
| 129 | void GoToFirst() const ; | 
|---|
| 130 | void GoToLast() const ; | 
|---|
| 131 | bool IsEmpty() const ; | 
|---|
| 132 | bool IsEnd() const ; | 
|---|
| 133 |  | 
|---|
| 134 | // templates for allowing global manipulation of all vectors | 
|---|
| 135 | template <typename res> void ActOnAllVectors( res (Vector::*f)() ) const; | 
|---|
| 136 | template <typename res> void ActOnAllVectors( res (Vector::*f)() const) const; | 
|---|
| 137 | template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T), T t ) const; | 
|---|
| 138 | template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T) const, T t ) const; | 
|---|
| 139 | template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const; | 
|---|
| 140 | template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const; | 
|---|
| 141 | template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const; | 
|---|
| 142 | template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const; | 
|---|
| 143 |  | 
|---|
| 144 | // templates for allowing global manipulation of molecule with each atom as single argument | 
|---|
| 145 | template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) ) const; | 
|---|
| 146 | template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) const) const; | 
|---|
| 147 |  | 
|---|
| 148 | // templates for allowing global copying of molecule with each atom as single argument | 
|---|
| 149 | template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const; | 
|---|
| 150 | template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const; | 
|---|
| 151 |  | 
|---|
| 152 | // templates for allowing global manipulation of all atoms | 
|---|
| 153 | template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() ) const; | 
|---|
| 154 | template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() const) const; | 
|---|
| 155 | template <typename res, typename typ, typename T> void ActOnAllAtoms( res (typ::*f)(T), T t ) const; | 
|---|
| 156 | template <typename res, typename typ, typename T> void ActOnAllAtoms( res (typ::*f)(T) const, T t ) const; | 
|---|
| 157 | template <typename res, typename typ, typename T, typename U> void ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const; | 
|---|
| 158 | template <typename res, typename typ, typename T, typename U> void ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const; | 
|---|
| 159 | template <typename res, typename typ, typename T, typename U, typename V> void ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const; | 
|---|
| 160 | template <typename res, typename typ, typename T, typename U, typename V> void ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const; | 
|---|
| 161 | template <typename res, typename typ, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const; | 
|---|
| 162 | template <typename res, typename typ, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const; | 
|---|
| 163 |  | 
|---|
| 164 | // templates for allowing conditional global copying of molecule with each atom as single argument | 
|---|
| 165 | template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const; | 
|---|
| 166 | template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const; | 
|---|
| 167 | template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const; | 
|---|
| 168 | template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () const ) const; | 
|---|
| 169 | template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const; | 
|---|
| 170 | template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const; | 
|---|
| 171 | template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T), T t ) const; | 
|---|
| 172 | template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T) const, T t ) const; | 
|---|
| 173 | template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const; | 
|---|
| 174 | template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const; | 
|---|
| 175 | template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const; | 
|---|
| 176 | template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const; | 
|---|
| 177 | template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const; | 
|---|
| 178 | template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const; | 
|---|
| 179 | template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const; | 
|---|
| 180 | template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const; | 
|---|
| 181 |  | 
|---|
| 182 | // templates for allowing global manipulation of an array with one entry per atom | 
|---|
| 183 | void SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::* index) const; | 
|---|
| 184 | template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *)) const; | 
|---|
| 185 | template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *), T t) const; | 
|---|
| 186 | template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *), T *t) const; | 
|---|
| 187 | template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *)) const; | 
|---|
| 188 | template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *), T t) const; | 
|---|
| 189 | template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *), T *t) const; | 
|---|
| 190 | template <typename T, typename typ> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value) const; | 
|---|
| 191 | template <typename T, typename typ> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value) const; | 
|---|
| 192 | template <typename T, typename typ> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const; | 
|---|
| 193 | template <typename T, typename typ> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const; | 
|---|
| 194 |  | 
|---|
| 195 | // templates for allowing global manipulation of each atom by entries in an array | 
|---|
| 196 | template <typename T, typename typ, typename typ2> void SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const; | 
|---|
| 197 | template <typename T, typename typ> void SetAtomValueToValue ( T value, T typ::*ptr ) const; | 
|---|
| 198 |  | 
|---|
| 199 | template <typename res, typename typ> res SumPerAtom(res (typ::*f)() ) const; | 
|---|
| 200 | template <typename res, typename typ> res SumPerAtom(res (typ::*f)() const ) const; | 
|---|
| 201 | template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) , T t ) const; | 
|---|
| 202 | template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) const, T t ) const; | 
|---|
| 203 |  | 
|---|
| 204 | /// remove atoms from molecule. | 
|---|
| 205 | bool AddAtom(atom *pointer); | 
|---|
| 206 | bool RemoveAtom(atom *pointer); | 
|---|
| 207 | bool UnlinkAtom(atom *pointer); | 
|---|
| 208 | bool CleanupMolecule(); | 
|---|
| 209 |  | 
|---|
| 210 | /// Add/remove atoms to/from molecule. | 
|---|
| 211 | atom * AddCopyAtom(atom *pointer); | 
|---|
| 212 | bool AddXYZFile(string filename); | 
|---|
| 213 | bool AddHydrogenReplacementAtom(bond *Bond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem); | 
|---|
| 214 | bond * AddBond(atom *first, atom *second, int degree = 1); | 
|---|
| 215 | bool RemoveBond(bond *pointer); | 
|---|
| 216 | bool RemoveBonds(atom *BondPartner); | 
|---|
| 217 |  | 
|---|
| 218 | /// Find atoms. | 
|---|
| 219 | atom * FindAtom(int Nr) const; | 
|---|
| 220 | atom * AskAtom(string text); | 
|---|
| 221 |  | 
|---|
| 222 | /// Count and change present atoms' coordination. | 
|---|
| 223 | void CountAtoms(); | 
|---|
| 224 | void CountElements(); | 
|---|
| 225 | void CalculateOrbitals(class config &configuration); | 
|---|
| 226 | bool CenterInBox(); | 
|---|
| 227 | bool BoundInBox(); | 
|---|
| 228 | void CenterEdge(Vector *max); | 
|---|
| 229 | void CenterOrigin(); | 
|---|
| 230 | void CenterPeriodic(); | 
|---|
| 231 | void CenterAtVector(Vector *newcenter); | 
|---|
| 232 | void Translate(const Vector *x); | 
|---|
| 233 | void TranslatePeriodically(const Vector *trans); | 
|---|
| 234 | void Mirror(const Vector *x); | 
|---|
| 235 | void Align(Vector *n); | 
|---|
| 236 | void Scale(const double ** const factor); | 
|---|
| 237 | void DeterminePeriodicCenter(Vector ¢er); | 
|---|
| 238 | Vector * DetermineCenterOfGravity(); | 
|---|
| 239 | Vector * DetermineCenterOfAll() const; | 
|---|
| 240 | void SetNameFromFilename(const char *filename); | 
|---|
| 241 | void SetBoxDimension(Vector *dim); | 
|---|
| 242 | void ScanForPeriodicCorrection(); | 
|---|
| 243 | bool VerletForceIntegration(char *file, config &configuration); | 
|---|
| 244 | void Thermostats(config &configuration, double ActualTemp, int Thermostat); | 
|---|
| 245 | void PrincipalAxisSystem(bool DoRotate); | 
|---|
| 246 | double VolumeOfConvexEnvelope(bool IsAngstroem); | 
|---|
| 247 |  | 
|---|
| 248 | double ConstrainedPotential(struct EvaluatePotential &Params); | 
|---|
| 249 | double MinimiseConstrainedPotential(atom **&permutation, int startstep, int endstep, bool IsAngstroem); | 
|---|
| 250 | void EvaluateConstrainedForces(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force); | 
|---|
| 251 | bool LinearInterpolationBetweenConfiguration(int startstep, int endstep, const char *prefix, config &configuration, bool MapByIdentity); | 
|---|
| 252 |  | 
|---|
| 253 | bool CheckBounds(const Vector *x) const; | 
|---|
| 254 | void GetAlignvector(struct lsq_params * par) const; | 
|---|
| 255 |  | 
|---|
| 256 | /// Initialising routines in fragmentation | 
|---|
| 257 | void CreateAdjacencyListFromDbondFile(ifstream *output); | 
|---|
| 258 | void CreateAdjacencyList(double bonddistance, bool IsAngstroem, void (BondGraph::*f)(BondedParticle * const , BondedParticle * const , double &, double &, bool), BondGraph *BG = NULL); | 
|---|
| 259 | int CorrectBondDegree() const; | 
|---|
| 260 | void OutputBondsList() const; | 
|---|
| 261 | void CyclicBondAnalysis() const; | 
|---|
| 262 | void OutputGraphInfoPerAtom() const; | 
|---|
| 263 | void OutputGraphInfoPerBond() const; | 
|---|
| 264 |  | 
|---|
| 265 |  | 
|---|
| 266 | // Graph analysis | 
|---|
| 267 | MoleculeLeafClass * DepthFirstSearchAnalysis(class StackClass<bond *> *&BackEdgeStack) const; | 
|---|
| 268 | void CyclicStructureAnalysis(class StackClass<bond *> *BackEdgeStack, int *&MinimumRingSize) const; | 
|---|
| 269 | bool PickLocalBackEdges(atom **ListOfLocalAtoms, class StackClass<bond *> *&ReferenceStack, class StackClass<bond *> *&LocalStack) const; | 
|---|
| 270 | bond * FindNextUnused(atom *vertex) const; | 
|---|
| 271 | void SetNextComponentNumber(atom *vertex, int nr) const; | 
|---|
| 272 | void ResetAllBondsToUnused() const; | 
|---|
| 273 | int CountCyclicBonds(); | 
|---|
| 274 | bool CheckForConnectedSubgraph(KeySet *Fragment); | 
|---|
| 275 | string GetColor(enum Shading color) const; | 
|---|
| 276 | bond * CopyBond(atom *left, atom *right, bond *CopyBond); | 
|---|
| 277 |  | 
|---|
| 278 |  | 
|---|
| 279 | molecule *CopyMolecule(); | 
|---|
| 280 | molecule* CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const; | 
|---|
| 281 |  | 
|---|
| 282 | /// Fragment molecule by two different approaches: | 
|---|
| 283 | int FragmentMolecule(int Order, config *configuration); | 
|---|
| 284 | bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path = NULL); | 
|---|
| 285 | bool StoreBondsToFile(char *path); | 
|---|
| 286 | bool StoreAdjacencyToFile(char *path); | 
|---|
| 287 | bool CheckAdjacencyFileAgainstMolecule(char *path, atom **ListOfAtoms); | 
|---|
| 288 | bool ParseOrderAtSiteFromFile(char *path); | 
|---|
| 289 | bool StoreOrderAtSiteFile(char *path); | 
|---|
| 290 | bool StoreForcesFile(MoleculeListClass *BondFragments, char *path, int *SortIndex); | 
|---|
| 291 | bool CreateMappingLabelsToConfigSequence(int *&SortIndex); | 
|---|
| 292 | void BreadthFirstSearchAdd(molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem); | 
|---|
| 293 | /// -# BOSSANOVA | 
|---|
| 294 | void FragmentBOSSANOVA(Graph *&FragmentList, KeyStack &RootStack, int *MinimumRingSize); | 
|---|
| 295 | int PowerSetGenerator(int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet); | 
|---|
| 296 | bool BuildInducedSubgraph(const molecule *Father); | 
|---|
| 297 | molecule * StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem); | 
|---|
| 298 | void SPFragmentGenerator(struct UniqueFragments *FragmentSearch, int RootDistance, bond **BondsSet, int SetDimension, int SubOrder); | 
|---|
| 299 | int LookForRemovalCandidate(KeySet *&Leaf, int *&ShortestPathList); | 
|---|
| 300 | int GuesstimateFragmentCount(int order); | 
|---|
| 301 |  | 
|---|
| 302 | // Recognize doubly appearing molecules in a list of them | 
|---|
| 303 | int * IsEqualToWithinThreshold(molecule *OtherMolecule, double threshold); | 
|---|
| 304 | int * GetFatherSonAtomicMap(molecule *OtherMolecule); | 
|---|
| 305 |  | 
|---|
| 306 | // Output routines. | 
|---|
| 307 | bool Output(ofstream * const output); | 
|---|
| 308 | bool OutputTrajectories(ofstream * const output); | 
|---|
| 309 | void OutputListOfBonds() const; | 
|---|
| 310 | bool OutputXYZ(ofstream * const output) const; | 
|---|
| 311 | bool OutputTrajectoriesXYZ(ofstream * const output); | 
|---|
| 312 | bool Checkout(ofstream * const output) const; | 
|---|
| 313 | bool OutputTemperatureFromTrajectories(ofstream * const output, int startstep, int endstep); | 
|---|
| 314 |  | 
|---|
| 315 | // Manipulation routines | 
|---|
| 316 | void flipActiveFlag(); | 
|---|
| 317 |  | 
|---|
| 318 | private: | 
|---|
| 319 | int last_atom;      //!< number given to last atom | 
|---|
| 320 | mutable atom *InternalPointer;  //!< internal pointer for PointCloud | 
|---|
| 321 | }; | 
|---|
| 322 |  | 
|---|
| 323 | #include "molecule_template.hpp" | 
|---|
| 324 |  | 
|---|
| 325 | /** A list of \a molecule classes. | 
|---|
| 326 | */ | 
|---|
| 327 | class MoleculeListClass : public Observable { | 
|---|
| 328 | public: | 
|---|
| 329 | MoleculeList ListOfMolecules; //!< List of the contained molecules | 
|---|
| 330 | int MaxIndex; | 
|---|
| 331 |  | 
|---|
| 332 | MoleculeListClass(); | 
|---|
| 333 | ~MoleculeListClass(); | 
|---|
| 334 |  | 
|---|
| 335 | bool AddHydrogenCorrection(char *path); | 
|---|
| 336 | bool StoreForcesFile(char *path, int *SortIndex); | 
|---|
| 337 | void insert(molecule *mol); | 
|---|
| 338 | molecule * ReturnIndex(int index); | 
|---|
| 339 | bool OutputConfigForListOfFragments(config *configuration, int *SortIndex); | 
|---|
| 340 | int NumberOfActiveMolecules(); | 
|---|
| 341 | void Enumerate(ofstream *out); | 
|---|
| 342 | void Output(ofstream *out); | 
|---|
| 343 | void DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration); | 
|---|
| 344 | int CountAllAtoms() const; | 
|---|
| 345 |  | 
|---|
| 346 | // Methods moved here from the menus | 
|---|
| 347 | // TODO: more refactoring needed on these methods | 
|---|
| 348 | void flipChosen(); | 
|---|
| 349 | void createNewMolecule(periodentafel *periode); | 
|---|
| 350 | void loadFromXYZ(periodentafel *periode); | 
|---|
| 351 | void setMoleculeFilename(); | 
|---|
| 352 | void parseXYZIntoMolecule(); | 
|---|
| 353 | void eraseMolecule(); | 
|---|
| 354 |  | 
|---|
| 355 |  | 
|---|
| 356 | // merging of molecules | 
|---|
| 357 | bool SimpleMerge(molecule *mol, molecule *srcmol); | 
|---|
| 358 | bool SimpleAdd(molecule *mol, molecule *srcmol); | 
|---|
| 359 | bool SimpleMultiMerge(molecule *mol, int *src, int N); | 
|---|
| 360 | bool SimpleMultiAdd(molecule *mol, int *src, int N); | 
|---|
| 361 | bool ScatterMerge(molecule *mol, int *src, int N); | 
|---|
| 362 | bool EmbedMerge(molecule *mol, molecule *srcmol); | 
|---|
| 363 |  | 
|---|
| 364 | private: | 
|---|
| 365 | }; | 
|---|
| 366 |  | 
|---|
| 367 |  | 
|---|
| 368 | /** A leaf for a tree of \a molecule class | 
|---|
| 369 | * Wraps molecules in a tree structure | 
|---|
| 370 | */ | 
|---|
| 371 | class MoleculeLeafClass { | 
|---|
| 372 | public: | 
|---|
| 373 | molecule *Leaf;                   //!< molecule of this leaf | 
|---|
| 374 | //MoleculeLeafClass *UpLeaf;        //!< Leaf one level up | 
|---|
| 375 | //MoleculeLeafClass *DownLeaf;      //!< First leaf one level down | 
|---|
| 376 | MoleculeLeafClass *previous;  //!< Previous leaf on this level | 
|---|
| 377 | MoleculeLeafClass *next;      //!< Next leaf on this level | 
|---|
| 378 |  | 
|---|
| 379 | //MoleculeLeafClass(MoleculeLeafClass *Up, MoleculeLeafClass *Previous); | 
|---|
| 380 | MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf); | 
|---|
| 381 | ~MoleculeLeafClass(); | 
|---|
| 382 |  | 
|---|
| 383 | bool AddLeaf(molecule *ptr, MoleculeLeafClass *Previous); | 
|---|
| 384 | bool FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList = false); | 
|---|
| 385 | bool FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter); | 
|---|
| 386 | bool AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList = false); | 
|---|
| 387 | bool FillListOfLocalAtoms(atom ***&ListOfLocalAtoms, const int FragmentCounter, const int GlobalAtomCount, bool &FreeList); | 
|---|
| 388 | void TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph); | 
|---|
| 389 | int Count() const; | 
|---|
| 390 | }; | 
|---|
| 391 |  | 
|---|
| 392 |  | 
|---|
| 393 | #endif /*MOLECULES_HPP_*/ | 
|---|
| 394 |  | 
|---|