[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 | // system specific headers
|
---|
| 23 | #include <time.h>
|
---|
| 24 |
|
---|
| 25 |
|
---|
| 26 | #include "helpers.hpp"
|
---|
| 27 |
|
---|
| 28 | class atom;
|
---|
| 29 | class AtomStackClass;
|
---|
| 30 | class bond;
|
---|
| 31 | class config;
|
---|
| 32 | class element;
|
---|
| 33 | class molecule;
|
---|
| 34 | class MoleculeListClass;
|
---|
| 35 | class periodentafel;
|
---|
| 36 | class vector;
|
---|
| 37 | class Verbose;
|
---|
| 38 |
|
---|
| 39 | /******************************** Some definitions for easier reading **********************************/
|
---|
| 40 |
|
---|
| 41 | #define KeyStack deque<int>
|
---|
| 42 | #define KeySet set<int>
|
---|
| 43 | #define Graph map<KeySet, pair<int, double>, KeyCompare >
|
---|
| 44 | #define GraphPair pair<KeySet, pair<int, double> >
|
---|
| 45 | #define KeySetTestPair pair<KeySet::iterator, bool>
|
---|
| 46 | #define GraphTestPair pair<Graph::iterator, bool>
|
---|
| 47 |
|
---|
| 48 | struct KeyCompare
|
---|
| 49 | {
|
---|
| 50 | bool operator() (const KeySet SubgraphA, const KeySet SubgraphB) const;
|
---|
| 51 | };
|
---|
| 52 | //bool operator < (KeySet SubgraphA, KeySet SubgraphB); //note: this declaration is important, otherwise normal < is used (producing wrong order)
|
---|
| 53 | inline void InsertFragmentIntoGraph(ofstream *out, struct UniqueFragments *Fragment); // Insert a KeySet into a Graph
|
---|
| 54 | inline void InsertGraphIntoGraph(ofstream *out, Graph &graph1, Graph &graph2, int *counter); // Insert all KeySet's in a Graph into another Graph
|
---|
| 55 |
|
---|
| 56 | /******************************** Some templates for list management ***********************************/
|
---|
| 57 |
|
---|
| 58 | /** Adds linking of an item to a list.
|
---|
| 59 | * \param *walker
|
---|
| 60 | * \return true - adding succeeded, false - error in list
|
---|
| 61 | */
|
---|
| 62 | template <typename X> void link(X *walker, X *end)
|
---|
| 63 | {
|
---|
| 64 | X *vorher = end->previous;
|
---|
| 65 | if (vorher != NULL)
|
---|
| 66 | vorher->next = walker;
|
---|
| 67 | end->previous = walker;
|
---|
| 68 | walker->previous = vorher;
|
---|
| 69 | walker->next = end;
|
---|
| 70 | };
|
---|
| 71 |
|
---|
| 72 | /** Removes linking of an item in a list.
|
---|
| 73 | * \param *walker
|
---|
| 74 | * \return true - removing succeeded, false - given item not found in list
|
---|
| 75 | */
|
---|
| 76 | template <typename X> void unlink(X *walker)
|
---|
| 77 | {
|
---|
| 78 | if (walker->next != NULL)
|
---|
| 79 | walker->next->previous = walker->previous;
|
---|
| 80 | if (walker->previous != NULL)
|
---|
| 81 | walker->previous->next = walker->next;
|
---|
| 82 | };
|
---|
| 83 |
|
---|
| 84 | /** Adds new item before an item \a *end in a list.
|
---|
| 85 | * \param *pointer item to be added
|
---|
| 86 | * \param *end end of list
|
---|
| 87 | * \return true - addition succeeded, false - unable to add item to list
|
---|
| 88 | */
|
---|
| 89 | template <typename X> bool add(X *pointer, X *end)
|
---|
| 90 | {
|
---|
| 91 | if (end != NULL) {
|
---|
| 92 | link(pointer, end);
|
---|
| 93 | } else {
|
---|
| 94 | pointer->previous = NULL;
|
---|
| 95 | pointer->next = NULL;
|
---|
| 96 | }
|
---|
| 97 | return true;
|
---|
| 98 | };
|
---|
| 99 |
|
---|
| 100 | /** Finds item in list
|
---|
| 101 | * \param *suche search criteria
|
---|
| 102 | * \param *start begin of list
|
---|
| 103 | * \param *end end of list
|
---|
| 104 | * \return X - if found, NULL - if not found
|
---|
| 105 | */
|
---|
| 106 | template <typename X, typename Y> X * find(Y *suche, X *start, X *end)
|
---|
| 107 | {
|
---|
| 108 | X *walker = start;
|
---|
| 109 | while (walker->next != end) { // go through list
|
---|
| 110 | walker = walker->next; // step onward beforehand
|
---|
| 111 | if (*walker->sort == *suche) return (walker);
|
---|
| 112 | }
|
---|
| 113 | return NULL;
|
---|
| 114 | };
|
---|
| 115 |
|
---|
| 116 | /** Removes an item from the list without check.
|
---|
| 117 | * \param *walker item to be removed
|
---|
| 118 | * \return true - removing succeeded, false - given item not found in list
|
---|
| 119 | */
|
---|
| 120 | template <typename X> void removewithoutcheck(X *walker)
|
---|
| 121 | {
|
---|
| 122 | if (walker != NULL) {
|
---|
| 123 | unlink(walker);
|
---|
| 124 | delete(walker);
|
---|
| 125 | walker = NULL;
|
---|
| 126 | }
|
---|
| 127 | };
|
---|
| 128 |
|
---|
| 129 | /** Removes an item from the list, checks if exists.
|
---|
| 130 | * Checks beforehand if atom is really within molecule list.
|
---|
| 131 | * \param *pointer item to be removed
|
---|
| 132 | * \param *start begin of list
|
---|
| 133 | * \param *end end of list
|
---|
| 134 | * \return true - removing succeeded, false - given item not found in list
|
---|
| 135 | */
|
---|
| 136 | template <typename X> bool remove(X *pointer, X *start, X *end)
|
---|
| 137 | {
|
---|
| 138 | X *walker = find (pointer->sort, start, end);
|
---|
| 139 | /* while (walker->next != pointer) { // search through list
|
---|
| 140 | walker = walker->next;
|
---|
| 141 | if (walker == end) return false; // item not found in list
|
---|
| 142 | }*/
|
---|
| 143 | // atom found, now unlink
|
---|
| 144 | if (walker != NULL)
|
---|
| 145 | removewithoutcheck(walker);
|
---|
| 146 | else
|
---|
| 147 | return false;
|
---|
| 148 | return true;
|
---|
| 149 | };
|
---|
| 150 |
|
---|
| 151 | /** Cleans the whole list.
|
---|
| 152 | * \param *start begin of list
|
---|
| 153 | * \param *end end of list
|
---|
| 154 | * \return true - list was cleaned successfully, false - error in list structure
|
---|
| 155 | */
|
---|
| 156 | template <typename X> bool cleanup(X *start, X *end)
|
---|
| 157 | {
|
---|
| 158 | X *pointer = start->next;
|
---|
| 159 | X *walker;
|
---|
| 160 | while (pointer != end) { // go through list
|
---|
| 161 | walker = pointer; // mark current
|
---|
| 162 | pointer = pointer->next; // step onward beforehand
|
---|
| 163 | // remove walker
|
---|
| 164 | unlink(walker);
|
---|
| 165 | delete(walker);
|
---|
| 166 | walker = NULL;
|
---|
| 167 | }
|
---|
| 168 | return true;
|
---|
| 169 | };
|
---|
| 170 |
|
---|
| 171 | /** Returns the first marker in a chain list.
|
---|
| 172 | * \param *me one arbitrary item in chain list
|
---|
| 173 | * \return poiner to first marker
|
---|
| 174 | */
|
---|
| 175 | template <typename X> X *GetFirst(X *me)
|
---|
| 176 | {
|
---|
| 177 | X *Binder = me;
|
---|
| 178 | while(Binder->previous != NULL)
|
---|
| 179 | Binder = Binder->previous;
|
---|
| 180 | return Binder;
|
---|
| 181 | };
|
---|
| 182 |
|
---|
| 183 | /** Returns the last marker in a chain list.
|
---|
| 184 | * \param *me one arbitrary item in chain list
|
---|
| 185 | * \return poiner to last marker
|
---|
| 186 | */
|
---|
| 187 | template <typename X> X *GetLast(X *me)
|
---|
| 188 | {
|
---|
| 189 | X *Binder = me;
|
---|
| 190 | while(Binder->next != NULL)
|
---|
| 191 | Binder = Binder->next;
|
---|
| 192 | return Binder;
|
---|
| 193 | };
|
---|
| 194 |
|
---|
| 195 | /** Frees a two-dimensional array.
|
---|
| 196 | * \param *ptr pointer to array
|
---|
| 197 | * \param dim first dim of array
|
---|
| 198 | */
|
---|
| 199 | template <typename X> void Free2DArray(X **ptr, int dim)
|
---|
| 200 | {
|
---|
| 201 | int i;
|
---|
| 202 | if (ptr != NULL) {
|
---|
| 203 | for(i=0;i<dim;i++)
|
---|
| 204 | if (ptr[i] != NULL)
|
---|
| 205 | free(ptr[i]);
|
---|
| 206 | free(ptr);
|
---|
| 207 | }
|
---|
| 208 | };
|
---|
| 209 |
|
---|
| 210 | int CompareDoubles (const void * a, const void * b);
|
---|
| 211 |
|
---|
| 212 | /************************************* Class definitions ****************************************/
|
---|
| 213 |
|
---|
| 214 | /** Chemical element.
|
---|
| 215 | * Class incorporates data for a certain chemical element to be referenced from atom class.
|
---|
| 216 | */
|
---|
| 217 | class element {
|
---|
| 218 | public:
|
---|
| 219 | double mass; //!< mass in g/mol
|
---|
| 220 | double CovalentRadius; //!< covalent radius
|
---|
| 221 | double VanDerWaalsRadius; //!< can-der-Waals radius
|
---|
| 222 | int Z; //!< atomic number
|
---|
| 223 | char name[64]; //!< atom name, i.e. "Hydrogren"
|
---|
| 224 | char symbol[3]; //!< short form of the atom, i.e. "H"
|
---|
| 225 | char period[8]; //!< period: n quantum number
|
---|
| 226 | char group[8]; //!< group: l quantum number
|
---|
| 227 | char block[8]; //!< block: l quantum number
|
---|
| 228 | element *previous; //!< previous item in list
|
---|
| 229 | element *next; //!< next element in list
|
---|
| 230 | int *sort; //!< sorc criteria
|
---|
| 231 | int No; //!< number of element set on periodentafel::Output()
|
---|
| 232 | double Valence; //!< number of valence electrons for this element
|
---|
| 233 | int NoValenceOrbitals; //!< number of valence orbitals, used for determining bond degree in molecule::CreateConnectmatrix()
|
---|
| 234 | double HBondDistance[NDIM]; //!< distance in Angstrom of this element to hydrogen (for single, double and triple bonds)
|
---|
| 235 | double HBondAngle[NDIM]; //!< typical angle for one, two, three bonded hydrogen (in degrees)
|
---|
| 236 |
|
---|
| 237 | element();
|
---|
| 238 | ~element();
|
---|
| 239 |
|
---|
| 240 | //> print element entries to screen
|
---|
| 241 | bool Output(ofstream *out) const;
|
---|
| 242 | bool Checkout(ofstream *out, const int No, const int NoOfAtoms) const;
|
---|
| 243 |
|
---|
| 244 | private:
|
---|
| 245 | };
|
---|
| 246 |
|
---|
| 247 | /** Periodentafel is a list of all elements sorted by their atomic number.
|
---|
| 248 | */
|
---|
| 249 | class periodentafel {
|
---|
| 250 | public:
|
---|
| 251 | element *start; //!< start of element list
|
---|
| 252 | element *end; //!< end of element list
|
---|
| 253 | char header1[255]; //!< store first header line
|
---|
| 254 | char header2[255]; //!< store second header line
|
---|
| 255 |
|
---|
| 256 | periodentafel();
|
---|
| 257 | ~periodentafel();
|
---|
| 258 |
|
---|
| 259 | bool AddElement(element *pointer);
|
---|
| 260 | bool RemoveElement(element *pointer);
|
---|
| 261 | bool CleanupPeriodtable();
|
---|
| 262 | element * FindElement(int Z);
|
---|
| 263 | element * FindElement(char *shorthand) const;
|
---|
| 264 | element * AskElement();
|
---|
| 265 | bool Output(ofstream *output) const;
|
---|
| 266 | bool Checkout(ofstream *output, const int *checkliste) const;
|
---|
| 267 | bool LoadPeriodentafel();
|
---|
| 268 | bool StorePeriodentafel() const;
|
---|
| 269 |
|
---|
| 270 | private:
|
---|
| 271 | };
|
---|
| 272 |
|
---|
| 273 | // some algebraic matrix stuff
|
---|
| 274 | #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
|
---|
| 275 | #define RDET2(a0,a1,a2,a3) ((a0)*(a3)-(a1)*(a2)) //!< hard-coded determinant of a 2x2 matrix
|
---|
| 276 |
|
---|
| 277 | /** Single vector.
|
---|
| 278 | * basically, just a x[3] but with helpful functions
|
---|
| 279 | */
|
---|
| 280 | class vector {
|
---|
| 281 | public:
|
---|
| 282 | double x[NDIM];
|
---|
| 283 |
|
---|
| 284 | vector();
|
---|
| 285 | ~vector();
|
---|
| 286 |
|
---|
| 287 | double Distance(const vector *y) const;
|
---|
| 288 | double PeriodicDistance(const vector *y, const double *cell_size) const;
|
---|
| 289 | double ScalarProduct(const vector *y) const;
|
---|
| 290 | double Projection(const vector *y) const;
|
---|
| 291 | double Norm() const ;
|
---|
| 292 | double Angle(vector *y) const;
|
---|
| 293 |
|
---|
| 294 | void AddVector(const vector *y);
|
---|
| 295 | void SubtractVector(const vector *y);
|
---|
| 296 | void CopyVector(const vector *y);
|
---|
| 297 | void RotateVector(const vector *y, const double alpha);
|
---|
| 298 | void Zero();
|
---|
| 299 | void Normalize();
|
---|
| 300 | void Translate(const vector *x);
|
---|
| 301 | void Mirror(const vector *x);
|
---|
| 302 | void Scale(double **factor);
|
---|
| 303 | void Scale(double *factor);
|
---|
| 304 | void Scale(double factor);
|
---|
| 305 | void MatrixMultiplication(double *M);
|
---|
| 306 | void InverseMatrixMultiplication(double *M);
|
---|
| 307 | void KeepPeriodic(ofstream *out, double *matrix);
|
---|
| 308 | void LinearCombinationOfVectors(const vector *x1, const vector *x2, const vector *x3, double *factors);
|
---|
| 309 |
|
---|
| 310 | bool GetOneNormalVector(const vector *x1);
|
---|
| 311 | bool MakeNormalVector(const vector *y1);
|
---|
| 312 | bool MakeNormalVector(const vector *y1, const vector *y2);
|
---|
| 313 | bool MakeNormalVector(const vector *x1, const vector *x2, const vector *x3);
|
---|
| 314 | bool SolveSystem(vector *x1, vector *x2, vector *y, double alpha, double beta, double c);
|
---|
| 315 | bool LSQdistance(vector **vectors, int dim);
|
---|
| 316 |
|
---|
| 317 | void AskPosition(double *cell_size, bool check);
|
---|
| 318 | bool Output(ofstream *out) const;
|
---|
| 319 | };
|
---|
| 320 |
|
---|
| 321 | ofstream& operator<<(ofstream& ost, vector& m);
|
---|
| 322 |
|
---|
| 323 | /** Parameter structure for least square minimsation.
|
---|
| 324 | */
|
---|
| 325 | struct LSQ_params {
|
---|
| 326 | vector **vectors;
|
---|
| 327 | int num;
|
---|
| 328 | };
|
---|
| 329 |
|
---|
| 330 | double LSQ(const gsl_vector * x, void * params);
|
---|
| 331 |
|
---|
| 332 | /** Parameter structure for least square minimsation.
|
---|
| 333 | */
|
---|
| 334 | struct lsq_params {
|
---|
| 335 | gsl_vector *x;
|
---|
| 336 | const molecule *mol;
|
---|
| 337 | element *type;
|
---|
| 338 | };
|
---|
| 339 |
|
---|
| 340 |
|
---|
| 341 |
|
---|
| 342 | /** Single atom.
|
---|
| 343 | * Class incoporates position, type
|
---|
| 344 | */
|
---|
| 345 | class atom {
|
---|
| 346 | public:
|
---|
| 347 | vector x; //!< coordinate array of atom, giving position within cell
|
---|
| 348 | element *type; //!< pointing to element
|
---|
| 349 | atom *previous; //!< previous atom in molecule list
|
---|
| 350 | atom *next; //!< next atom in molecule list
|
---|
| 351 | atom *father; //!< In many-body bond order fragmentations points to originating atom
|
---|
| 352 | atom *Ancestor; //!< "Father" in Depth-First-Search
|
---|
| 353 | char *Name; //!< unique name used during many-body bond-order fragmentation
|
---|
| 354 | int *sort; //!< sort criteria
|
---|
| 355 | int nr; //!< continuous, unique number
|
---|
| 356 | int GraphNr; //!< unique number, given in DepthFirstSearchAnalysis()
|
---|
| 357 | int *ComponentNr;//!< belongs to this nonseparable components, given in DepthFirstSearchAnalysis() (if more than one, then is SeparationVertex)
|
---|
| 358 | 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.
|
---|
| 359 | bool SeparationVertex; //!< whether this atom separates off subsets of atoms or not, given in DepthFirstSearchAnalysis()
|
---|
| 360 |
|
---|
| 361 | atom();
|
---|
| 362 | ~atom();
|
---|
| 363 |
|
---|
| 364 | bool Output(int ElementNo, int AtomNo, ofstream *out) const;
|
---|
| 365 | bool OutputXYZLine(ofstream *out) const;
|
---|
| 366 | atom *GetTrueFather();
|
---|
| 367 | bool Compare(atom &ptr);
|
---|
| 368 |
|
---|
| 369 | private:
|
---|
| 370 | };
|
---|
| 371 |
|
---|
| 372 | ostream & operator << (ostream &ost, atom &a);
|
---|
| 373 |
|
---|
| 374 | /* Stack of Atoms.
|
---|
| 375 | * Is used during DepthFirstSearchAnalysis() to detect nonseparable components.
|
---|
| 376 | */
|
---|
| 377 | class AtomStackClass {
|
---|
| 378 | public:
|
---|
| 379 | AtomStackClass(int dimension);
|
---|
| 380 | ~AtomStackClass();
|
---|
| 381 |
|
---|
| 382 | bool Push(atom *object);
|
---|
| 383 | atom *PopFirst();
|
---|
| 384 | atom *PopLast();
|
---|
| 385 | bool AtomStackClass::RemoveItem(atom *ptr);
|
---|
| 386 | void ClearStack();
|
---|
| 387 | bool IsEmpty();
|
---|
| 388 | bool IsFull();
|
---|
| 389 | int ItemCount();
|
---|
| 390 | void Output(ofstream *out) const;
|
---|
| 391 | void TestImplementation(ofstream *out, atom *test);
|
---|
| 392 |
|
---|
| 393 | private:
|
---|
| 394 | atom **StackList; //!< the list containing the atom pointers
|
---|
| 395 | int EntryCount; //!< number of entries in the stack
|
---|
| 396 | int CurrentLastEntry; //!< Current last entry (newest item on stack)
|
---|
| 397 | int CurrentFirstEntry; //!< Current first entry (oldest item on stack)
|
---|
| 398 | int NextFreeField; //!< Current index of next free field
|
---|
| 399 | };
|
---|
| 400 |
|
---|
| 401 |
|
---|
| 402 | /** Bonds between atoms.
|
---|
| 403 | * Class incorporates bonds between atoms in a molecule,
|
---|
| 404 | * used to derive tge fragments in many-body bond order
|
---|
| 405 | * calculations.
|
---|
| 406 | */
|
---|
| 407 | class bond {
|
---|
| 408 | public:
|
---|
| 409 | atom *leftatom; //!< first bond partner
|
---|
| 410 | atom *rightatom; //!< second bond partner
|
---|
| 411 | bond *previous; //!< previous atom in molecule list
|
---|
| 412 | bond *next; //!< next atom in molecule list
|
---|
| 413 | int HydrogenBond; //!< Number of hydrogen atoms in the bond
|
---|
| 414 | int BondDegree; //!< single, double, triple, ... bond
|
---|
| 415 | int nr; //!< unique number in a molecule, updated by molecule::CreateAdjacencyList()
|
---|
| 416 | bool Cyclic; //!< flag whether bond is part of a cycle or not, given in DepthFirstSearchAnalysis()
|
---|
| 417 | enum EdgeType Type;//!< whether this is a tree or back edge
|
---|
| 418 |
|
---|
| 419 | atom * GetOtherAtom(atom *Atom) const;
|
---|
| 420 | bond * GetFirstBond();
|
---|
| 421 | bond * GetLastBond();
|
---|
| 422 |
|
---|
| 423 | bool MarkUsed(enum Shading color);
|
---|
| 424 | enum Shading IsUsed();
|
---|
| 425 | void ResetUsed();
|
---|
| 426 | bool Contains(const atom *ptr);
|
---|
| 427 | bool Contains(const int nr);
|
---|
| 428 |
|
---|
| 429 | bond();
|
---|
| 430 | bond(atom *left, atom *right);
|
---|
| 431 | bond(atom *left, atom *right, int degree);
|
---|
| 432 | bond(atom *left, atom *right, int degree, int number);
|
---|
| 433 | ~bond();
|
---|
| 434 |
|
---|
| 435 | private:
|
---|
| 436 | enum Shading Used; //!< marker in depth-first search, DepthFirstSearchAnalysis()
|
---|
| 437 | };
|
---|
| 438 |
|
---|
| 439 | ostream & operator << (ostream &ost, bond &b);
|
---|
| 440 |
|
---|
| 441 | class MoleculeLeafClass;
|
---|
| 442 |
|
---|
| 443 | /** The complete molecule.
|
---|
| 444 | * Class incorporates number of types
|
---|
| 445 | */
|
---|
| 446 | class molecule {
|
---|
| 447 | public:
|
---|
| 448 | double cell_size[6];//!< cell size
|
---|
| 449 | periodentafel *elemente; //!< periodic table with each element
|
---|
| 450 | atom *start; //!< start of atom list
|
---|
| 451 | atom *end; //!< end of atom list
|
---|
| 452 | bond *first; //!< start of bond list
|
---|
| 453 | bond *last; //!< end of bond list
|
---|
| 454 | bond ***ListOfBondsPerAtom; //!< pointer list for each atom and each bond it has
|
---|
| 455 | int *NumberOfBondsPerAtom; //!< Number of Bonds each atom has
|
---|
| 456 | int AtomCount; //!< number of atoms, brought up-to-date by CountAtoms()
|
---|
| 457 | int BondCount; //!< number of atoms, brought up-to-date by CountBonds()
|
---|
| 458 | int ElementCount; //!< how many unique elements are therein
|
---|
| 459 | int ElementsInMolecule[MAX_ELEMENTS]; //!< list whether element (sorted by atomic number) is alread present or not
|
---|
| 460 | int NoNonHydrogen; //!< number of non-hydrogen atoms in molecule
|
---|
| 461 | int NoNonBonds; //!< number of non-hydrogen bonds in molecule
|
---|
| 462 | int NoCyclicBonds; //!< number of cyclic bonds in molecule, by DepthFirstSearchAnalysis()
|
---|
| 463 | double BondDistance; //!< typical bond distance used in CreateAdjacencyList() and furtheron
|
---|
| 464 |
|
---|
| 465 | molecule(periodentafel *teil);
|
---|
| 466 | ~molecule();
|
---|
| 467 |
|
---|
| 468 | /// remove atoms from molecule.
|
---|
| 469 | bool AddAtom(atom *pointer);
|
---|
| 470 | bool RemoveAtom(atom *pointer);
|
---|
| 471 | bool CleanupMolecule();
|
---|
| 472 |
|
---|
| 473 | /// Add/remove atoms to/from molecule.
|
---|
| 474 | atom * AddCopyAtom(atom *pointer);
|
---|
| 475 | bool AddXYZFile(string filename);
|
---|
| 476 | bool AddHydrogenReplacementAtom(ofstream *out, bond *Bond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bond **BondList, int NumBond, bool IsAngstroem);
|
---|
| 477 | bond * AddBond(atom *first, atom *second, int degree);
|
---|
| 478 | bool RemoveBond(bond *pointer);
|
---|
| 479 | bool RemoveBonds(atom *BondPartner);
|
---|
| 480 |
|
---|
| 481 | /// Find atoms.
|
---|
| 482 | atom * FindAtom(int Nr) const;
|
---|
| 483 | atom * AskAtom(char *text);
|
---|
| 484 |
|
---|
| 485 | /// Count and change present atoms' coordination.
|
---|
| 486 | void CountAtoms(ofstream *out);
|
---|
| 487 | void CountElements();
|
---|
| 488 | void CalculateOrbitals(class config &configuration);
|
---|
| 489 | void CenterEdge(ofstream *out, vector *max);
|
---|
| 490 | void CenterOrigin(ofstream *out, vector *max);
|
---|
| 491 | void CenterGravity(ofstream *out, vector *max);
|
---|
| 492 | void Translate(const vector *x);
|
---|
| 493 | void Mirror(const vector *x);
|
---|
| 494 | void Align(vector *n);
|
---|
| 495 | void Scale(double **factor);
|
---|
| 496 | void DetermineCenterOfGravity(vector &CenterOfGravity);
|
---|
| 497 | void SetBoxDimension(vector *dim);
|
---|
| 498 | double * ReturnFullMatrixforSymmetric(double *cell_size);
|
---|
| 499 | void ScanForPeriodicCorrection(ofstream *out);
|
---|
| 500 |
|
---|
| 501 | bool CheckBounds(const vector *x) const;
|
---|
| 502 | void GetAlignVector(struct lsq_params * par) const;
|
---|
| 503 |
|
---|
| 504 | /// Initialising routines in fragmentation
|
---|
| 505 | void CreateAdjacencyList(ofstream *out, double bonddistance);
|
---|
| 506 | void CreateListOfBondsPerAtom(ofstream *out);
|
---|
| 507 |
|
---|
| 508 | // Graph analysis
|
---|
| 509 | MoleculeLeafClass * DepthFirstSearchAnalysis(ofstream *out, bool ReturnStack, int &MinimumRingSize);
|
---|
| 510 | void CyclicStructureAnalysis(ofstream *out, int &MinimumRingSize);
|
---|
| 511 | bond * FindNextUnused(atom *vertex);
|
---|
| 512 | void SetNextComponentNumber(atom *vertex, int nr);
|
---|
| 513 | void InitComponentNumbers();
|
---|
| 514 | void OutputComponentNumber(ofstream *out, atom *vertex);
|
---|
| 515 | void ResetAllBondsToUnused();
|
---|
| 516 | void ResetAllAtomNumbers();
|
---|
| 517 | int CountCyclicBonds(ofstream *out);
|
---|
| 518 | char * GetColor(enum Shading color);
|
---|
| 519 |
|
---|
| 520 | molecule *CopyMolecule();
|
---|
| 521 |
|
---|
| 522 | /// Fragment molecule by two different approaches:
|
---|
| 523 | void FragmentMolecule(ofstream *out, int BottomUpOrder, int TopDownOrder, enum BondOrderScheme Scheme, config *configuration, enum CutCyclicBond CutCyclic);
|
---|
| 524 | MoleculeListClass * GetAtomicFragments(ofstream *out, int NumberOfTopAtoms, bool IsAngstroem, double factor, enum CutCyclicBond CutCyclic);
|
---|
| 525 | void BreadthFirstSearchAdd(ofstream *out, molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem, enum CutCyclicBond CutCyclic);
|
---|
| 526 | /// -# BottomUp
|
---|
| 527 | MoleculeListClass * FragmentBottomUp(ofstream *out, int BondOrder, config *configuration, enum CutCyclicBond CutCyclic);
|
---|
| 528 | MoleculeListClass * GetEachBondFragmentOfOrder(ofstream *out, int BondOrder, bool IsAngstroem, enum CutCyclicBond CutCyclic);
|
---|
| 529 | /// -# TopDown
|
---|
| 530 | void FragmentMoleculeByBond(ofstream *out, bond *Bond, molecule **LeftFragment, molecule **RightFragment, bool IsAngstroem, enum CutCyclicBond CutCyclic);
|
---|
| 531 | /// -# BOSSANOVA
|
---|
| 532 | MoleculeListClass * FragmentBOSSANOVA(ofstream *out, int ANOVAOrder, config *configuration);
|
---|
| 533 | int CreateListOfUniqueFragmentsOfOrder(ofstream *out, int Order, Graph *ListOfGraph, KeySet Fragment, double TEFactor, config *configuration);
|
---|
| 534 | bool BuildInducedSubgraph(ofstream *out, const molecule *Father);
|
---|
| 535 | molecule * StoreFragmentFromKeyset(ofstream *&out, KeySet &Leaflet, config *&configuration);
|
---|
| 536 | void SPFragmentGenerator(ofstream *out, struct UniqueFragments *FragmentSearch, int RootDistance, bond **BondsSet, int SetDimension, int SubOrder);
|
---|
| 537 | int LookForRemovalCandidate(ofstream *&out, KeySet *&Leaf, int *&ShortestPathList);
|
---|
| 538 | int GuesstimateFragmentCount(ofstream *out, int order);
|
---|
| 539 |
|
---|
| 540 | // Recognize doubly appearing molecules in a list of them
|
---|
| 541 | int * IsEqualToWithinThreshold(ofstream *out, molecule *OtherMolecule, double threshold);
|
---|
| 542 | int * GetFatherSonAtomicMap(ofstream *out, molecule *OtherMolecule);
|
---|
| 543 |
|
---|
| 544 | // Output routines.
|
---|
| 545 | bool Output(ofstream *out);
|
---|
| 546 | bool OutputXYZ(ofstream *out) const;
|
---|
| 547 | bool Checkout(ofstream *out) const;
|
---|
| 548 |
|
---|
| 549 | private:
|
---|
| 550 | int last_atom; //!< number given to last atom
|
---|
| 551 | };
|
---|
| 552 |
|
---|
| 553 | /** A list of \a molecule classes.
|
---|
| 554 | */
|
---|
| 555 | class MoleculeListClass {
|
---|
| 556 | public:
|
---|
| 557 | molecule **ListOfMolecules; //!< pointer list of fragment molecules to check for equality
|
---|
| 558 | int NumberOfMolecules; //!< Number of entries in \a **FragmentList and of to be returned one.
|
---|
| 559 | int NumberOfTopAtoms; //!< Number of atoms in the molecule from which all fragments originate
|
---|
| 560 | double *TEList; //!< List of factors when summing over total energies of all fragment
|
---|
| 561 |
|
---|
| 562 | MoleculeListClass();
|
---|
| 563 | MoleculeListClass(int Num, int NumAtoms);
|
---|
| 564 | ~MoleculeListClass();
|
---|
| 565 |
|
---|
| 566 | MoleculeListClass * FragmentTopDown(ofstream *out, int BondDegree, double bonddistance, config *configuration, enum CutCyclicBond Saturation);
|
---|
| 567 |
|
---|
| 568 | /// Reduced list to unique molecules.
|
---|
| 569 | int * GetMappingToUniqueFragments(ofstream *out, double threshold, double *cell_size, double celldistance);
|
---|
| 570 | int ReduceFragmentToUniqueOnes(ofstream *out, int *Map);
|
---|
| 571 | void ReduceToUniqueList(ofstream *out, double *cell_size, double celldistance);
|
---|
| 572 |
|
---|
| 573 | /// Output configs.
|
---|
| 574 | bool OutputConfigForListOfFragments(char *prefix, config *configuration, int *SortIndex);
|
---|
| 575 | void Output(ofstream *out);
|
---|
| 576 |
|
---|
| 577 | private:
|
---|
| 578 | };
|
---|
| 579 |
|
---|
| 580 |
|
---|
| 581 | /** A leaf for a tree of \a molecule class
|
---|
| 582 | * Wraps molecules in a tree structure
|
---|
| 583 | */
|
---|
| 584 | class MoleculeLeafClass {
|
---|
| 585 | public:
|
---|
| 586 | molecule *Leaf; //!< molecule of this leaf
|
---|
| 587 | //MoleculeLeafClass *UpLeaf; //!< Leaf one level up
|
---|
| 588 | //MoleculeLeafClass *DownLeaf; //!< First leaf one level down
|
---|
| 589 | MoleculeLeafClass *previous; //!< Previous leaf on this level
|
---|
| 590 | MoleculeLeafClass *next; //!< Next leaf on this level
|
---|
| 591 |
|
---|
| 592 | //MoleculeLeafClass(MoleculeLeafClass *Up, MoleculeLeafClass *Previous);
|
---|
| 593 | MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf);
|
---|
| 594 | ~MoleculeLeafClass();
|
---|
| 595 |
|
---|
| 596 | bool AddLeaf(molecule *ptr, MoleculeLeafClass *Previous);
|
---|
| 597 | };
|
---|
| 598 |
|
---|
| 599 | /** The config file.
|
---|
| 600 | * The class contains all parameters that control a dft run also functions to load and save.
|
---|
| 601 | */
|
---|
| 602 | class config {
|
---|
| 603 | public:
|
---|
| 604 | int PsiType;
|
---|
| 605 | int MaxPsiDouble;
|
---|
| 606 | int PsiMaxNoUp;
|
---|
| 607 | int PsiMaxNoDown;
|
---|
| 608 | int MaxMinStopStep;
|
---|
| 609 | int InitMaxMinStopStep;
|
---|
| 610 | int ProcPEGamma;
|
---|
| 611 | int ProcPEPsi;
|
---|
| 612 |
|
---|
| 613 | private:
|
---|
| 614 | char *mainname;
|
---|
| 615 | char *defaultpath;
|
---|
| 616 | char *pseudopotpath;
|
---|
| 617 |
|
---|
| 618 | int DoOutVis;
|
---|
| 619 | int DoOutMes;
|
---|
| 620 | int DoOutNICS;
|
---|
| 621 | int DoOutOrbitals;
|
---|
| 622 | int DoOutCurrent;
|
---|
| 623 | int DoFullCurrent;
|
---|
| 624 | int DoPerturbation;
|
---|
| 625 | int CommonWannier;
|
---|
| 626 | double SawtoothStart;
|
---|
| 627 | int VectorPlane;
|
---|
| 628 | double VectorCut;
|
---|
| 629 | int UseAddGramSch;
|
---|
| 630 | int Seed;
|
---|
| 631 |
|
---|
| 632 | int MaxOuterStep;
|
---|
| 633 | double Deltat;
|
---|
| 634 | int OutVisStep;
|
---|
| 635 | int OutSrcStep;
|
---|
| 636 | double TargetTemp;
|
---|
| 637 | int ScaleTempStep;
|
---|
| 638 | int MaxPsiStep;
|
---|
| 639 | double EpsWannier;
|
---|
| 640 |
|
---|
| 641 | int MaxMinStep;
|
---|
| 642 | double RelEpsTotalEnergy;
|
---|
| 643 | double RelEpsKineticEnergy;
|
---|
| 644 | int MaxMinGapStopStep;
|
---|
| 645 | int MaxInitMinStep;
|
---|
| 646 | double InitRelEpsTotalEnergy;
|
---|
| 647 | double InitRelEpsKineticEnergy;
|
---|
| 648 | int InitMaxMinGapStopStep;
|
---|
| 649 |
|
---|
| 650 | //double BoxLength[NDIM*NDIM];
|
---|
| 651 |
|
---|
| 652 | double ECut;
|
---|
| 653 | int MaxLevel;
|
---|
| 654 | int RiemannTensor;
|
---|
| 655 | int LevRFactor;
|
---|
| 656 | int RiemannLevel;
|
---|
| 657 | int Lev0Factor;
|
---|
| 658 | int RTActualUse;
|
---|
| 659 | int AddPsis;
|
---|
| 660 |
|
---|
| 661 | double RCut;
|
---|
| 662 | int StructOpt;
|
---|
| 663 | int IsAngstroem;
|
---|
| 664 | int RelativeCoord;
|
---|
| 665 | int MaxTypes;
|
---|
| 666 |
|
---|
| 667 |
|
---|
| 668 | 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);
|
---|
| 669 |
|
---|
| 670 | public:
|
---|
| 671 | config();
|
---|
| 672 | ~config();
|
---|
| 673 |
|
---|
| 674 | int TestSyntax(ifstream *file, periodentafel *periode, molecule *mol);
|
---|
| 675 | void Load(ifstream *file, periodentafel *periode, molecule *mol);
|
---|
| 676 | void LoadOld(ifstream *file, periodentafel *periode, molecule *mol);
|
---|
| 677 | bool Save(ofstream *file, periodentafel *periode, molecule *mol) const;
|
---|
| 678 | void Edit(molecule *mol);
|
---|
| 679 | bool GetIsAngstroem() const;
|
---|
| 680 | char *GetDefaultPath() const;
|
---|
| 681 | void config::SetDefaultPath(const char *path);
|
---|
| 682 | };
|
---|
| 683 |
|
---|
| 684 | #endif /*MOLECULES_HPP_*/
|
---|
| 685 |
|
---|