| [a0bcf1] | 1 | /** \file molecules.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 | // GSL headers
 | 
|---|
 | 12 | #include <gsl/gsl_multimin.h>
 | 
|---|
 | 13 | #include <gsl/gsl_vector.h>
 | 
|---|
 | 14 | #include <gsl/gsl_matrix.h>
 | 
|---|
 | 15 | #include <gsl/gsl_heapsort.h>
 | 
|---|
 | 16 | 
 | 
|---|
 | 17 | // STL headers
 | 
|---|
 | 18 | #include <map>
 | 
|---|
 | 19 | #include <set>
 | 
|---|
 | 20 | #include <deque>
 | 
|---|
 | 21 | 
 | 
|---|
 | 22 | #include "helpers.hpp"
 | 
|---|
| [d50d2a] | 23 | #include "stackclass.hpp"
 | 
|---|
| [a0bcf1] | 24 | 
 | 
|---|
 | 25 | class atom;
 | 
|---|
 | 26 | class bond;
 | 
|---|
 | 27 | class config;
 | 
|---|
 | 28 | class element;
 | 
|---|
 | 29 | class molecule;
 | 
|---|
 | 30 | class MoleculeListClass;
 | 
|---|
 | 31 | class periodentafel;
 | 
|---|
 | 32 | class vector;
 | 
|---|
 | 33 | class Verbose;
 | 
|---|
 | 34 | 
 | 
|---|
 | 35 | /******************************** Some definitions for easier reading **********************************/
 | 
|---|
 | 36 | 
 | 
|---|
 | 37 | #define KeyStack deque<int>
 | 
|---|
 | 38 | #define KeySet set<int>
 | 
|---|
| [a3ff7b2] | 39 | #define NumberValuePair pair<int, double>
 | 
|---|
 | 40 | #define Graph map<KeySet, NumberValuePair, KeyCompare >
 | 
|---|
 | 41 | #define GraphPair pair<KeySet, NumberValuePair >
 | 
|---|
| [a0bcf1] | 42 | #define KeySetTestPair pair<KeySet::iterator, bool>
 | 
|---|
 | 43 | #define GraphTestPair pair<Graph::iterator, bool>
 | 
|---|
 | 44 | 
 | 
|---|
 | 45 | struct KeyCompare
 | 
|---|
 | 46 | {
 | 
|---|
 | 47 |   bool operator() (const KeySet SubgraphA, const KeySet SubgraphB) const;
 | 
|---|
 | 48 | };
 | 
|---|
| [d50d2a] | 49 | 
 | 
|---|
| [a0bcf1] | 50 | //bool operator < (KeySet SubgraphA, KeySet SubgraphB);   //note: this declaration is important, otherwise normal < is used (producing wrong order)
 | 
|---|
 | 51 | inline void InsertFragmentIntoGraph(ofstream *out, struct UniqueFragments *Fragment); // Insert a KeySet into a Graph
 | 
|---|
 | 52 | inline void InsertGraphIntoGraph(ofstream *out, Graph &graph1, Graph &graph2, int *counter);  // Insert all KeySet's in a Graph into another Graph 
 | 
|---|
 | 53 | int CompareDoubles (const void * a, const void * b);
 | 
|---|
 | 54 | 
 | 
|---|
| [d50d2a] | 55 | 
 | 
|---|
| [a0bcf1] | 56 | /************************************* Class definitions ****************************************/
 | 
|---|
 | 57 | 
 | 
|---|
 | 58 | /** Chemical element.
 | 
|---|
 | 59 |  * Class incorporates data for a certain chemical element to be referenced from atom class.
 | 
|---|
 | 60 |  */
 | 
|---|
 | 61 | class element {
 | 
|---|
 | 62 |   public:
 | 
|---|
 | 63 |     double mass;    //!< mass in g/mol
 | 
|---|
 | 64 |     double CovalentRadius;  //!< covalent radius
 | 
|---|
 | 65 |     double VanDerWaalsRadius;  //!< can-der-Waals radius
 | 
|---|
 | 66 |     int Z;          //!< atomic number
 | 
|---|
 | 67 |     char name[64];  //!< atom name, i.e. "Hydrogren"
 | 
|---|
 | 68 |     char symbol[3]; //!< short form of the atom, i.e. "H"
 | 
|---|
 | 69 |     char period[8];    //!< period: n quantum number
 | 
|---|
 | 70 |     char group[8];    //!< group: l quantum number
 | 
|---|
 | 71 |     char block[8];    //!< block: l quantum number
 | 
|---|
 | 72 |     element *previous;  //!< previous item in list
 | 
|---|
 | 73 |     element *next;  //!< next element in list
 | 
|---|
 | 74 |     int *sort;      //!< sorc criteria
 | 
|---|
 | 75 |     int No;         //!< number of element set on periodentafel::Output()
 | 
|---|
 | 76 |     double Valence;             //!< number of valence electrons for this element
 | 
|---|
 | 77 |     int NoValenceOrbitals;  //!< number of valence orbitals, used for determining bond degree in molecule::CreateConnectmatrix()
 | 
|---|
 | 78 |     double HBondDistance[NDIM]; //!< distance in Angstrom of this element to hydrogen  (for single, double and triple bonds)
 | 
|---|
 | 79 |     double HBondAngle[NDIM];     //!< typical angle for one, two, three bonded hydrogen (in degrees)
 | 
|---|
 | 80 | 
 | 
|---|
 | 81 |   element();
 | 
|---|
 | 82 |   ~element();
 | 
|---|
 | 83 | 
 | 
|---|
 | 84 |   //> print element entries to screen
 | 
|---|
 | 85 |   bool Output(ofstream *out) const;
 | 
|---|
 | 86 |   bool Checkout(ofstream *out, const int No, const int NoOfAtoms) const;
 | 
|---|
 | 87 |   
 | 
|---|
 | 88 |   private:
 | 
|---|
 | 89 | };
 | 
|---|
 | 90 | 
 | 
|---|
 | 91 | /** Periodentafel is a list of all elements sorted by their atomic number.
 | 
|---|
 | 92 |  */
 | 
|---|
 | 93 | class periodentafel {
 | 
|---|
 | 94 |   public:
 | 
|---|
 | 95 |     element *start; //!< start of element list
 | 
|---|
 | 96 |     element *end;   //!< end of element list
 | 
|---|
| [c510a7] | 97 |     char header1[MAXSTRINGSIZE]; //!< store first header line
 | 
|---|
 | 98 |     char header2[MAXSTRINGSIZE]; //!< store second header line
 | 
|---|
| [a0bcf1] | 99 |   
 | 
|---|
 | 100 |   periodentafel();
 | 
|---|
 | 101 |   ~periodentafel(); 
 | 
|---|
 | 102 |   
 | 
|---|
 | 103 |   bool AddElement(element *pointer);
 | 
|---|
 | 104 |   bool RemoveElement(element *pointer);
 | 
|---|
 | 105 |   bool CleanupPeriodtable();
 | 
|---|
 | 106 |   element * FindElement(int Z);
 | 
|---|
 | 107 |   element * FindElement(char *shorthand) const;
 | 
|---|
 | 108 |   element * AskElement(); 
 | 
|---|
 | 109 |   bool Output(ofstream *output) const;
 | 
|---|
 | 110 |   bool Checkout(ofstream *output, const int *checkliste) const;
 | 
|---|
| [c72cbe] | 111 |   bool LoadPeriodentafel(char *filename = NULL);
 | 
|---|
 | 112 |   bool StorePeriodentafel(char *filename = NULL) const;
 | 
|---|
| [a0bcf1] | 113 |   
 | 
|---|
 | 114 |   private:
 | 
|---|
 | 115 | };
 | 
|---|
 | 116 | 
 | 
|---|
 | 117 | // some algebraic matrix stuff
 | 
|---|
 | 118 | #define RDET3(a) ((a)[0]*(a)[4]*(a)[8] + (a)[3]*(a)[7]*(a)[2] + (a)[6]*(a)[1]*(a)[5] - (a)[2]*(a)[4]*(a)[6] - (a)[5]*(a)[7]*(a)[0] - (a)[8]*(a)[1]*(a)[3])  //!< hard-coded determinant of a 3x3 matrix
 | 
|---|
 | 119 | #define RDET2(a0,a1,a2,a3) ((a0)*(a3)-(a1)*(a2))                      //!< hard-coded determinant of a 2x2 matrix
 | 
|---|
 | 120 | 
 | 
|---|
 | 121 | /** Single vector.
 | 
|---|
 | 122 |  * basically, just a x[3] but with helpful functions
 | 
|---|
 | 123 |  */
 | 
|---|
 | 124 | class vector {   
 | 
|---|
 | 125 |   public:
 | 
|---|
 | 126 |     double x[NDIM];
 | 
|---|
 | 127 | 
 | 
|---|
 | 128 |   vector();
 | 
|---|
 | 129 |   ~vector();
 | 
|---|
 | 130 | 
 | 
|---|
 | 131 |   double Distance(const vector *y) const;
 | 
|---|
 | 132 |   double PeriodicDistance(const vector *y, const double *cell_size) const;
 | 
|---|
 | 133 |   double ScalarProduct(const vector *y) const;
 | 
|---|
 | 134 |   double Projection(const vector *y) const;
 | 
|---|
 | 135 |   double Norm() const ;
 | 
|---|
 | 136 |   double Angle(vector *y) const;
 | 
|---|
 | 137 | 
 | 
|---|
 | 138 |   void AddVector(const vector *y);
 | 
|---|
 | 139 |   void SubtractVector(const vector *y);
 | 
|---|
 | 140 |   void CopyVector(const vector *y);
 | 
|---|
 | 141 |   void RotateVector(const vector *y, const double alpha);
 | 
|---|
 | 142 |   void Zero(); 
 | 
|---|
 | 143 |   void Normalize();
 | 
|---|
 | 144 |   void Translate(const vector *x);
 | 
|---|
 | 145 |   void Mirror(const vector *x);
 | 
|---|
 | 146 |   void Scale(double **factor);
 | 
|---|
 | 147 |   void Scale(double *factor);
 | 
|---|
 | 148 |   void Scale(double factor);
 | 
|---|
 | 149 |   void MatrixMultiplication(double *M);
 | 
|---|
 | 150 |   void InverseMatrixMultiplication(double *M);
 | 
|---|
 | 151 |   void KeepPeriodic(ofstream *out, double *matrix);
 | 
|---|
 | 152 |   void LinearCombinationOfVectors(const vector *x1, const vector *x2, const vector *x3, double *factors);
 | 
|---|
 | 153 |   
 | 
|---|
 | 154 |   bool GetOneNormalVector(const vector *x1);
 | 
|---|
 | 155 |   bool MakeNormalVector(const vector *y1);
 | 
|---|
 | 156 |   bool MakeNormalVector(const vector *y1, const vector *y2);
 | 
|---|
 | 157 |   bool MakeNormalVector(const vector *x1, const vector *x2, const vector *x3);
 | 
|---|
 | 158 |   bool SolveSystem(vector *x1, vector *x2, vector *y, double alpha, double beta, double c);
 | 
|---|
 | 159 |         bool LSQdistance(vector **vectors, int dim);
 | 
|---|
 | 160 | 
 | 
|---|
 | 161 |   void AskPosition(double *cell_size, bool check);
 | 
|---|
 | 162 |   bool Output(ofstream *out) const;
 | 
|---|
 | 163 | };
 | 
|---|
 | 164 | 
 | 
|---|
 | 165 | ofstream& operator<<(ofstream& ost, vector& m);
 | 
|---|
 | 166 | 
 | 
|---|
 | 167 | /** Parameter structure for least square minimsation.
 | 
|---|
 | 168 |  */
 | 
|---|
 | 169 | struct LSQ_params {
 | 
|---|
 | 170 |   vector **vectors;
 | 
|---|
 | 171 |   int num;
 | 
|---|
 | 172 | };
 | 
|---|
 | 173 | 
 | 
|---|
 | 174 | double LSQ(const gsl_vector * x, void * params);
 | 
|---|
 | 175 | 
 | 
|---|
 | 176 | /** Parameter structure for least square minimsation.
 | 
|---|
 | 177 |  */
 | 
|---|
 | 178 | struct lsq_params {
 | 
|---|
 | 179 |   gsl_vector *x;
 | 
|---|
 | 180 |   const molecule *mol;
 | 
|---|
 | 181 |   element *type;
 | 
|---|
 | 182 | };
 | 
|---|
 | 183 | 
 | 
|---|
 | 184 | 
 | 
|---|
 | 185 | 
 | 
|---|
 | 186 | /** Single atom.
 | 
|---|
 | 187 |  * Class incoporates position, type
 | 
|---|
 | 188 |  */
 | 
|---|
 | 189 | class atom {
 | 
|---|
 | 190 |   public:
 | 
|---|
| [090299] | 191 |     vector x;       //!< coordinate array of atom, giving position within cell
 | 
|---|
 | 192 |     vector v;       //!< velocity array of atom
 | 
|---|
| [a0bcf1] | 193 |     element *type;  //!< pointing to element
 | 
|---|
 | 194 |     atom *previous; //!< previous atom in molecule list
 | 
|---|
 | 195 |     atom *next;     //!< next atom in molecule list
 | 
|---|
 | 196 |     atom *father;   //!< In many-body bond order fragmentations points to originating atom
 | 
|---|
 | 197 |     atom *Ancestor; //!< "Father" in Depth-First-Search
 | 
|---|
 | 198 |     char *Name;                 //!< unique name used during many-body bond-order fragmentation
 | 
|---|
| [090299] | 199 |     int FixedIon;   //!< config variable that states whether forces act on the ion or not
 | 
|---|
| [a0bcf1] | 200 |     int *sort;      //!< sort criteria
 | 
|---|
 | 201 |     int nr;         //!< continuous, unique number
 | 
|---|
 | 202 |     int GraphNr;      //!< unique number, given in DepthFirstSearchAnalysis()
 | 
|---|
 | 203 |     int *ComponentNr;//!< belongs to this nonseparable components, given in DepthFirstSearchAnalysis() (if more than one, then is SeparationVertex)
 | 
|---|
 | 204 |     int LowpointNr; //!< needed in DepthFirstSearchAnalysis() to detect nonseparable components, is the lowest possible number of an atom to reach via tree edges only followed by at most one back edge.
 | 
|---|
 | 205 |     bool SeparationVertex; //!< whether this atom separates off subsets of atoms or not, given in DepthFirstSearchAnalysis()
 | 
|---|
| [c75363] | 206 |     unsigned char AdaptiveOrder;  //!< current present bond order at site (0 means "not set")
 | 
|---|
| [a0bcf1] | 207 |   
 | 
|---|
 | 208 |   atom();
 | 
|---|
 | 209 |   ~atom();
 | 
|---|
 | 210 |   
 | 
|---|
 | 211 |   bool Output(int ElementNo, int AtomNo, ofstream *out) const;
 | 
|---|
 | 212 |   bool OutputXYZLine(ofstream *out) const;
 | 
|---|
 | 213 |   atom *GetTrueFather();
 | 
|---|
 | 214 |   bool Compare(atom &ptr);
 | 
|---|
 | 215 |   
 | 
|---|
 | 216 |   private:
 | 
|---|
 | 217 | };
 | 
|---|
 | 218 | 
 | 
|---|
 | 219 | ostream & operator << (ostream &ost, atom &a);
 | 
|---|
 | 220 | 
 | 
|---|
 | 221 | /** Bonds between atoms.
 | 
|---|
 | 222 |  * Class incorporates bonds between atoms in a molecule,
 | 
|---|
 | 223 |  * used to derive tge fragments in many-body bond order
 | 
|---|
 | 224 |  * calculations.
 | 
|---|
 | 225 |  */
 | 
|---|
 | 226 | class bond {
 | 
|---|
 | 227 |   public:
 | 
|---|
 | 228 |         atom *leftatom;         //!< first bond partner
 | 
|---|
 | 229 |         atom *rightatom;        //!< second bond partner
 | 
|---|
 | 230 |     bond *previous; //!< previous atom in molecule list
 | 
|---|
 | 231 |     bond *next;     //!< next atom in molecule list
 | 
|---|
 | 232 |         int HydrogenBond;       //!< Number of hydrogen atoms in the bond
 | 
|---|
 | 233 |         int BondDegree;         //!< single, double, triple, ... bond
 | 
|---|
 | 234 |     int nr;           //!< unique number in a molecule, updated by molecule::CreateAdjacencyList()
 | 
|---|
 | 235 |     bool Cyclic;      //!< flag whether bond is part of a cycle or not, given in DepthFirstSearchAnalysis()
 | 
|---|
 | 236 |     enum EdgeType Type;//!< whether this is a tree or back edge 
 | 
|---|
 | 237 |         
 | 
|---|
 | 238 |   atom * GetOtherAtom(atom *Atom) const;
 | 
|---|
 | 239 |   bond * GetFirstBond();
 | 
|---|
 | 240 |   bond * GetLastBond();
 | 
|---|
 | 241 |   
 | 
|---|
 | 242 |   bool MarkUsed(enum Shading color);
 | 
|---|
 | 243 |   enum Shading IsUsed();
 | 
|---|
 | 244 |   void ResetUsed();
 | 
|---|
 | 245 |   bool Contains(const atom *ptr);
 | 
|---|
 | 246 |   bool Contains(const int nr);
 | 
|---|
 | 247 |   
 | 
|---|
 | 248 |   bond();
 | 
|---|
 | 249 |   bond(atom *left, atom *right);
 | 
|---|
 | 250 |   bond(atom *left, atom *right, int degree);
 | 
|---|
 | 251 |   bond(atom *left, atom *right, int degree, int number);
 | 
|---|
 | 252 |   ~bond();
 | 
|---|
 | 253 |     
 | 
|---|
 | 254 |   private: 
 | 
|---|
 | 255 |     enum Shading Used;        //!< marker in depth-first search, DepthFirstSearchAnalysis()
 | 
|---|
 | 256 | };
 | 
|---|
 | 257 | 
 | 
|---|
 | 258 | ostream & operator << (ostream &ost, bond &b);
 | 
|---|
 | 259 | 
 | 
|---|
 | 260 | class MoleculeLeafClass;
 | 
|---|
 | 261 | 
 | 
|---|
 | 262 | /** The complete molecule.
 | 
|---|
 | 263 |  * Class incorporates number of types
 | 
|---|
 | 264 |  */
 | 
|---|
 | 265 | class molecule {
 | 
|---|
 | 266 |   public:
 | 
|---|
 | 267 |     double cell_size[6];//!< cell size
 | 
|---|
 | 268 |     periodentafel *elemente; //!< periodic table with each element
 | 
|---|
 | 269 |     atom *start;        //!< start of atom list
 | 
|---|
 | 270 |     atom *end;          //!< end of atom list
 | 
|---|
 | 271 |     bond *first;        //!< start of bond list
 | 
|---|
 | 272 |     bond *last;         //!< end of bond list
 | 
|---|
 | 273 |     bond ***ListOfBondsPerAtom; //!< pointer list for each atom and each bond it has
 | 
|---|
 | 274 |     int *NumberOfBondsPerAtom;  //!< Number of Bonds each atom has
 | 
|---|
 | 275 |     int AtomCount;                                      //!< number of atoms, brought up-to-date by CountAtoms()
 | 
|---|
 | 276 |     int BondCount;                                      //!< number of atoms, brought up-to-date by CountBonds()
 | 
|---|
 | 277 |     int ElementCount;       //!< how many unique elements are therein
 | 
|---|
 | 278 |     int ElementsInMolecule[MAX_ELEMENTS]; //!< list whether element (sorted by atomic number) is alread present or not
 | 
|---|
 | 279 |     int NoNonHydrogen;  //!< number of non-hydrogen atoms in molecule
 | 
|---|
 | 280 |     int NoNonBonds;     //!< number of non-hydrogen bonds in molecule
 | 
|---|
 | 281 |     int NoCyclicBonds;  //!< number of cyclic bonds in molecule, by DepthFirstSearchAnalysis()
 | 
|---|
 | 282 |     double BondDistance;  //!< typical bond distance used in CreateAdjacencyList() and furtheron
 | 
|---|
 | 283 |   
 | 
|---|
 | 284 |   molecule(periodentafel *teil);
 | 
|---|
 | 285 |   ~molecule();
 | 
|---|
 | 286 |   
 | 
|---|
 | 287 |   /// remove atoms from molecule.
 | 
|---|
 | 288 |   bool AddAtom(atom *pointer);
 | 
|---|
 | 289 |   bool RemoveAtom(atom *pointer);
 | 
|---|
 | 290 |   bool CleanupMolecule();
 | 
|---|
 | 291 | 
 | 
|---|
 | 292 |   /// Add/remove atoms to/from molecule.
 | 
|---|
 | 293 |   atom * AddCopyAtom(atom *pointer);
 | 
|---|
 | 294 |   bool AddXYZFile(string filename);
 | 
|---|
 | 295 |   bool AddHydrogenReplacementAtom(ofstream *out, bond *Bond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bond **BondList, int NumBond, bool IsAngstroem);  
 | 
|---|
 | 296 |   bond * AddBond(atom *first, atom *second, int degree);
 | 
|---|
 | 297 |   bool RemoveBond(bond *pointer);
 | 
|---|
 | 298 |   bool RemoveBonds(atom *BondPartner);
 | 
|---|
 | 299 |     
 | 
|---|
 | 300 |   /// Find atoms.
 | 
|---|
 | 301 |   atom * FindAtom(int Nr) const; 
 | 
|---|
 | 302 |   atom * AskAtom(char *text);
 | 
|---|
 | 303 | 
 | 
|---|
 | 304 |   /// Count and change present atoms' coordination.
 | 
|---|
 | 305 |   void CountAtoms(ofstream *out);
 | 
|---|
 | 306 |   void CountElements();
 | 
|---|
 | 307 |   void CalculateOrbitals(class config &configuration);
 | 
|---|
 | 308 |   void CenterEdge(ofstream *out, vector *max); 
 | 
|---|
 | 309 |   void CenterOrigin(ofstream *out, vector *max); 
 | 
|---|
 | 310 |   void CenterGravity(ofstream *out, vector *max); 
 | 
|---|
 | 311 |   void Translate(const vector *x);
 | 
|---|
 | 312 |   void Mirror(const vector *x);
 | 
|---|
 | 313 |   void Align(vector *n);
 | 
|---|
 | 314 |   void Scale(double **factor);
 | 
|---|
 | 315 |   void DetermineCenterOfGravity(vector &CenterOfGravity);
 | 
|---|
 | 316 |   void SetBoxDimension(vector *dim);
 | 
|---|
 | 317 |   double * ReturnFullMatrixforSymmetric(double *cell_size);
 | 
|---|
 | 318 |   void ScanForPeriodicCorrection(ofstream *out);
 | 
|---|
 | 319 | 
 | 
|---|
 | 320 |   bool CheckBounds(const vector *x) const;
 | 
|---|
 | 321 |   void GetAlignVector(struct lsq_params * par) const;
 | 
|---|
 | 322 | 
 | 
|---|
 | 323 |   /// Initialising routines in fragmentation  
 | 
|---|
 | 324 |   void CreateAdjacencyList(ofstream *out, double bonddistance);
 | 
|---|
 | 325 |   void CreateListOfBondsPerAtom(ofstream *out);
 | 
|---|
 | 326 |   
 | 
|---|
 | 327 |   // Graph analysis
 | 
|---|
 | 328 |   MoleculeLeafClass * DepthFirstSearchAnalysis(ofstream *out, bool ReturnStack, int &MinimumRingSize);
 | 
|---|
| [a01955] | 329 |   void CyclicStructureAnalysis(ofstream *out, class StackClass<bond *> *BackEdgeStack, int &MinimumRingSize);
 | 
|---|
| [a0bcf1] | 330 |   bond * FindNextUnused(atom *vertex);
 | 
|---|
 | 331 |   void SetNextComponentNumber(atom *vertex, int nr);
 | 
|---|
 | 332 |   void InitComponentNumbers();
 | 
|---|
 | 333 |   void OutputComponentNumber(ofstream *out, atom *vertex);
 | 
|---|
 | 334 |   void ResetAllBondsToUnused();
 | 
|---|
 | 335 |   void ResetAllAtomNumbers();
 | 
|---|
 | 336 |   int CountCyclicBonds(ofstream *out);
 | 
|---|
 | 337 |   char * GetColor(enum Shading color);
 | 
|---|
 | 338 | 
 | 
|---|
 | 339 |   molecule *CopyMolecule();
 | 
|---|
 | 340 |   
 | 
|---|
 | 341 |   /// Fragment molecule by two different approaches:
 | 
|---|
| [c75363] | 342 |   void FragmentMolecule(ofstream *out, int Order, config *configuration);
 | 
|---|
| [a3ff7b2] | 343 |   bool CheckOrderAtSite(ofstream *out, bool *AtomMask, Graph *GlobalKeySetList, int Order, char *path = NULL);
 | 
|---|
| [c75363] | 344 |   bool StoreAdjacencyToFile(ofstream *out, char *path);
 | 
|---|
 | 345 |   bool CheckAdjacencyFileAgainstMolecule(ofstream *out, char *path, atom **ListOfAtoms);
 | 
|---|
 | 346 |   bool ParseOrderAtSiteFromFile(ofstream *out, char *path);
 | 
|---|
 | 347 |   bool StoreOrderAtSiteFile(ofstream *out, char *path);
 | 
|---|
| [115bf4] | 348 |   bool ParseKeySetFile(ofstream *out, char *filename, Graph *&FragmentList, bool IsAngstroem);
 | 
|---|
 | 349 |   bool StoreKeySetFile(ofstream *out, Graph &KeySetList, char *path);
 | 
|---|
 | 350 |   bool StoreForcesFile(ofstream *out, MoleculeListClass *BondFragments, char *path, int *SortIndex);
 | 
|---|
| [d88597] | 351 |   bool CreateMappingLabelsToConfigSequence(ofstream *out, int *&SortIndex);
 | 
|---|
| [34d37c] | 352 |   bool ScanBufferIntoKeySet(ofstream *out, char *buffer, KeySet &CurrentSet);
 | 
|---|
| [c75363] | 353 |   void BreadthFirstSearchAdd(ofstream *out, molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem);
 | 
|---|
| [a0bcf1] | 354 |   /// -# BOSSANOVA
 | 
|---|
| [115bf4] | 355 |   void FragmentBOSSANOVA(ofstream *out, Graph *&FragmentList, KeyStack &RootStack);
 | 
|---|
 | 356 |         int PowerSetGenerator(ofstream *out, int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet);
 | 
|---|
| [a0bcf1] | 357 |   bool BuildInducedSubgraph(ofstream *out, const molecule *Father);
 | 
|---|
| [2614f83] | 358 |   molecule * StoreFragmentFromKeySet(ofstream *out, KeySet &Leaflet, bool IsAngstroem);
 | 
|---|
| [a0bcf1] | 359 |   void SPFragmentGenerator(ofstream *out, struct UniqueFragments *FragmentSearch, int RootDistance, bond **BondsSet, int SetDimension, int SubOrder);
 | 
|---|
 | 360 |   int LookForRemovalCandidate(ofstream *&out, KeySet *&Leaf, int *&ShortestPathList);
 | 
|---|
 | 361 |   int GuesstimateFragmentCount(ofstream *out, int order);
 | 
|---|
 | 362 |           
 | 
|---|
 | 363 |   // Recognize doubly appearing molecules in a list of them   
 | 
|---|
 | 364 |   int * IsEqualToWithinThreshold(ofstream *out, molecule *OtherMolecule, double threshold);
 | 
|---|
 | 365 |   int * GetFatherSonAtomicMap(ofstream *out, molecule *OtherMolecule);
 | 
|---|
 | 366 |         
 | 
|---|
 | 367 |   // Output routines.
 | 
|---|
 | 368 |   bool Output(ofstream *out);
 | 
|---|
| [169b24] | 369 |   void OutputListOfBonds(ofstream *out) const;
 | 
|---|
| [a0bcf1] | 370 |   bool OutputXYZ(ofstream *out) const;
 | 
|---|
 | 371 |   bool Checkout(ofstream *out) const;
 | 
|---|
 | 372 | 
 | 
|---|
 | 373 |   private:
 | 
|---|
 | 374 |   int last_atom;      //!< number given to last atom
 | 
|---|
 | 375 | };
 | 
|---|
 | 376 | 
 | 
|---|
 | 377 | /** A list of \a molecule classes.
 | 
|---|
 | 378 |  */
 | 
|---|
 | 379 | class MoleculeListClass {
 | 
|---|
 | 380 |   public:
 | 
|---|
 | 381 |     molecule **ListOfMolecules;   //!< pointer list of fragment molecules to check for equality
 | 
|---|
 | 382 |     int NumberOfMolecules;        //!< Number of entries in \a **FragmentList and of to be returned one.
 | 
|---|
 | 383 |     int NumberOfTopAtoms;         //!< Number of atoms in the molecule from which all fragments originate
 | 
|---|
 | 384 |     
 | 
|---|
 | 385 |   MoleculeListClass();
 | 
|---|
 | 386 |   MoleculeListClass(int Num, int NumAtoms);
 | 
|---|
 | 387 |   ~MoleculeListClass();
 | 
|---|
 | 388 | 
 | 
|---|
 | 389 |   /// Output configs.
 | 
|---|
| [115bf4] | 390 |   bool StoreForcesFile(ofstream *out, char *path, int *SortIndex);
 | 
|---|
| [c75363] | 391 |   bool OutputConfigForListOfFragments(ofstream *out, config *configuration, int *SortIndex);
 | 
|---|
| [a0bcf1] | 392 |   void Output(ofstream *out);
 | 
|---|
 | 393 |   
 | 
|---|
 | 394 |   private:
 | 
|---|
 | 395 | };
 | 
|---|
 | 396 | 
 | 
|---|
 | 397 | 
 | 
|---|
 | 398 | /** A leaf for a tree of \a molecule class
 | 
|---|
 | 399 |  * Wraps molecules in a tree structure
 | 
|---|
 | 400 |  */
 | 
|---|
 | 401 | class MoleculeLeafClass {
 | 
|---|
 | 402 |   public:
 | 
|---|
 | 403 |     molecule *Leaf;                   //!< molecule of this leaf 
 | 
|---|
 | 404 |     //MoleculeLeafClass *UpLeaf;        //!< Leaf one level up
 | 
|---|
 | 405 |     //MoleculeLeafClass *DownLeaf;      //!< First leaf one level down
 | 
|---|
 | 406 |     MoleculeLeafClass *previous;  //!< Previous leaf on this level
 | 
|---|
 | 407 |     MoleculeLeafClass *next;      //!< Next leaf on this level
 | 
|---|
 | 408 | 
 | 
|---|
 | 409 |   //MoleculeLeafClass(MoleculeLeafClass *Up, MoleculeLeafClass *Previous);
 | 
|---|
 | 410 |   MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf);
 | 
|---|
 | 411 |   ~MoleculeLeafClass();
 | 
|---|
 | 412 | 
 | 
|---|
 | 413 |   bool AddLeaf(molecule *ptr, MoleculeLeafClass *Previous);
 | 
|---|
| [9c3496] | 414 |   bool FillBondStructureFromReference(ofstream *out, molecule *reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList = false);
 | 
|---|
| [a3ff7b2] | 415 |   bool FillRootStackForSubgraphs(ofstream *out, KeyStack *&RootStack, bool *AtomMask, int Order, int &FragmentCounter);
 | 
|---|
| [169b24] | 416 |   bool AssignKeySetsToFragment(ofstream *out, molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList = false);
 | 
|---|
 | 417 |   bool FillListOfLocalAtoms(ofstream *out, atom ***&ListOfLocalAtoms, int &FragmentCounter, int GlobalAtomCount, bool &FreeList);
 | 
|---|
| [2b79c3] | 418 |   void TranslateIndicesToGlobalIDs(ofstream *out, Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph);
 | 
|---|
| [169b24] | 419 |   int Count() const;
 | 
|---|
| [a0bcf1] | 420 | };
 | 
|---|
 | 421 | 
 | 
|---|
 | 422 | /** The config file.
 | 
|---|
 | 423 |  * The class contains all parameters that control a dft run also functions to load and save.
 | 
|---|
 | 424 |  */
 | 
|---|
 | 425 | class config {
 | 
|---|
 | 426 |   public:
 | 
|---|
 | 427 |     int PsiType;
 | 
|---|
 | 428 |     int MaxPsiDouble;
 | 
|---|
 | 429 |     int PsiMaxNoUp;
 | 
|---|
 | 430 |     int PsiMaxNoDown;
 | 
|---|
 | 431 |     int MaxMinStopStep;
 | 
|---|
 | 432 |     int InitMaxMinStopStep;
 | 
|---|
 | 433 |     int ProcPEGamma;
 | 
|---|
 | 434 |     int ProcPEPsi;
 | 
|---|
| [f5306f] | 435 |     char *configpath;
 | 
|---|
| [7b1cea] | 436 |     char *configname;
 | 
|---|
| [a0bcf1] | 437 |     
 | 
|---|
 | 438 |     private:
 | 
|---|
 | 439 |     char *mainname;
 | 
|---|
 | 440 |     char *defaultpath;
 | 
|---|
 | 441 |     char *pseudopotpath;
 | 
|---|
 | 442 |     
 | 
|---|
 | 443 |     int DoOutVis;
 | 
|---|
 | 444 |     int DoOutMes;
 | 
|---|
 | 445 |     int DoOutNICS;
 | 
|---|
 | 446 |     int DoOutOrbitals;
 | 
|---|
 | 447 |     int DoOutCurrent;
 | 
|---|
 | 448 |     int DoFullCurrent;
 | 
|---|
 | 449 |     int DoPerturbation;
 | 
|---|
 | 450 |     int CommonWannier;
 | 
|---|
 | 451 |     double SawtoothStart;
 | 
|---|
 | 452 |     int VectorPlane;
 | 
|---|
 | 453 |     double VectorCut;
 | 
|---|
 | 454 |     int UseAddGramSch;
 | 
|---|
 | 455 |     int Seed;
 | 
|---|
 | 456 |     
 | 
|---|
 | 457 |     int MaxOuterStep;
 | 
|---|
 | 458 |     double Deltat;
 | 
|---|
 | 459 |     int OutVisStep;
 | 
|---|
 | 460 |     int OutSrcStep;
 | 
|---|
 | 461 |     double TargetTemp;
 | 
|---|
 | 462 |     int ScaleTempStep;
 | 
|---|
 | 463 |     int MaxPsiStep;
 | 
|---|
 | 464 |     double EpsWannier;
 | 
|---|
 | 465 |     
 | 
|---|
 | 466 |     int MaxMinStep;
 | 
|---|
 | 467 |     double RelEpsTotalEnergy;
 | 
|---|
 | 468 |     double RelEpsKineticEnergy;
 | 
|---|
 | 469 |     int MaxMinGapStopStep;
 | 
|---|
 | 470 |     int MaxInitMinStep;
 | 
|---|
 | 471 |     double InitRelEpsTotalEnergy;
 | 
|---|
 | 472 |     double InitRelEpsKineticEnergy;
 | 
|---|
 | 473 |     int InitMaxMinGapStopStep;
 | 
|---|
 | 474 |     
 | 
|---|
 | 475 |     //double BoxLength[NDIM*NDIM];
 | 
|---|
 | 476 |     
 | 
|---|
 | 477 |     double ECut;
 | 
|---|
 | 478 |     int MaxLevel;
 | 
|---|
 | 479 |     int RiemannTensor;
 | 
|---|
 | 480 |     int LevRFactor;
 | 
|---|
 | 481 |     int RiemannLevel;
 | 
|---|
 | 482 |     int Lev0Factor;
 | 
|---|
 | 483 |     int RTActualUse;
 | 
|---|
 | 484 |     int AddPsis;
 | 
|---|
 | 485 |     
 | 
|---|
 | 486 |     double RCut;
 | 
|---|
 | 487 |     int StructOpt;
 | 
|---|
 | 488 |     int IsAngstroem;
 | 
|---|
 | 489 |     int RelativeCoord;
 | 
|---|
 | 490 |     int MaxTypes;
 | 
|---|
 | 491 | 
 | 
|---|
 | 492 |   
 | 
|---|
 | 493 |   int ParseForParameter(int verbose, ifstream *file, const char *name, int sequential, int const xth, int const yth, int type, void *value, int repetition, int critical);
 | 
|---|
 | 494 |   
 | 
|---|
 | 495 |   public:
 | 
|---|
 | 496 |   config();
 | 
|---|
 | 497 |   ~config();
 | 
|---|
 | 498 | 
 | 
|---|
| [f5306f] | 499 |   int TestSyntax(char *filename, periodentafel *periode, molecule *mol);
 | 
|---|
 | 500 |   void Load(char *filename, periodentafel *periode, molecule *mol);
 | 
|---|
 | 501 |   void LoadOld(char *filename, periodentafel *periode, molecule *mol);
 | 
|---|
| [7b1cea] | 502 |   void RetrieveConfigPathAndName(char *filename);
 | 
|---|
| [a0bcf1] | 503 |   bool Save(ofstream *file, periodentafel *periode, molecule *mol) const;
 | 
|---|
 | 504 |   void Edit(molecule *mol);
 | 
|---|
 | 505 |   bool GetIsAngstroem() const;
 | 
|---|
 | 506 |   char *GetDefaultPath() const;
 | 
|---|
 | 507 |   void config::SetDefaultPath(const char *path);
 | 
|---|
 | 508 | };
 | 
|---|
 | 509 | 
 | 
|---|
 | 510 | #endif /*MOLECULES_HPP_*/
 | 
|---|
 | 511 | 
 | 
|---|