| [14de469] | 1 | /** \file molecules.hpp
 | 
|---|
 | 2 |  *
 | 
|---|
| [69eb71] | 3 |  * Class definitions of atom and molecule, element and periodentafel
 | 
|---|
| [14de469] | 4 |  */
 | 
|---|
 | 5 | 
 | 
|---|
 | 6 | #ifndef MOLECULES_HPP_
 | 
|---|
 | 7 | #define MOLECULES_HPP_
 | 
|---|
 | 8 | 
 | 
|---|
 | 9 | using namespace std;
 | 
|---|
 | 10 | 
 | 
|---|
 | 11 | // GSL headers
 | 
|---|
| [d52ea1b] | 12 | #include <gsl/gsl_eigen.h>
 | 
|---|
| [14de469] | 13 | #include <gsl/gsl_heapsort.h>
 | 
|---|
| [6e9353] | 14 | #include <gsl/gsl_linalg.h>
 | 
|---|
 | 15 | #include <gsl/gsl_matrix.h>
 | 
|---|
 | 16 | #include <gsl/gsl_multimin.h>
 | 
|---|
 | 17 | #include <gsl/gsl_vector.h>
 | 
|---|
| [62f793] | 18 | #include <gsl/gsl_randist.h>
 | 
|---|
| [14de469] | 19 | 
 | 
|---|
 | 20 | // STL headers
 | 
|---|
 | 21 | #include <map>
 | 
|---|
 | 22 | #include <set>
 | 
|---|
 | 23 | #include <deque>
 | 
|---|
| [d7e30c] | 24 | #include <list>
 | 
|---|
| [5e0d1f] | 25 | #include <vector>
 | 
|---|
| [14de469] | 26 | 
 | 
|---|
 | 27 | #include "helpers.hpp"
 | 
|---|
| [362b0e] | 28 | #include "parser.hpp"
 | 
|---|
| [68cb0f] | 29 | #include "periodentafel.hpp"
 | 
|---|
| [6d35e4] | 30 | #include "stackclass.hpp"
 | 
|---|
| [342f33f] | 31 | #include "vector.hpp"
 | 
|---|
| [14de469] | 32 | 
 | 
|---|
 | 33 | class atom;
 | 
|---|
 | 34 | class bond;
 | 
|---|
 | 35 | class config;
 | 
|---|
 | 36 | class molecule;
 | 
|---|
 | 37 | class MoleculeListClass;
 | 
|---|
 | 38 | class Verbose;
 | 
|---|
 | 39 | 
 | 
|---|
 | 40 | /******************************** Some definitions for easier reading **********************************/
 | 
|---|
 | 41 | 
 | 
|---|
 | 42 | #define KeyStack deque<int>
 | 
|---|
 | 43 | #define KeySet set<int>
 | 
|---|
| [5de3c9] | 44 | #define NumberValuePair pair<int, double>
 | 
|---|
| [49de64] | 45 | #define Graph map <KeySet, NumberValuePair, KeyCompare >
 | 
|---|
 | 46 | #define GraphPair pair <KeySet, NumberValuePair >
 | 
|---|
| [14de469] | 47 | #define KeySetTestPair pair<KeySet::iterator, bool>
 | 
|---|
 | 48 | #define GraphTestPair pair<Graph::iterator, bool>
 | 
|---|
 | 49 | 
 | 
|---|
| [ed060e] | 50 | #define DistancePair pair < double, atom* >
 | 
|---|
 | 51 | #define DistanceMap multimap < double, atom* >
 | 
|---|
 | 52 | #define DistanceTestPair pair < DistanceMap::iterator, bool>
 | 
|---|
 | 53 | 
 | 
|---|
 | 54 | #define Boundaries map <double, DistancePair >
 | 
|---|
 | 55 | #define BoundariesPair pair<double, DistancePair >
 | 
|---|
 | 56 | #define BoundariesTestPair pair< Boundaries::iterator, bool>
 | 
|---|
 | 57 | 
 | 
|---|
| [69eb71] | 58 | #define PointMap map < int, class BoundaryPointSet * >
 | 
|---|
 | 59 | #define PointPair pair < int, class BoundaryPointSet * >
 | 
|---|
 | 60 | #define PointTestPair pair < PointMap::iterator, bool >
 | 
|---|
| [3d919e] | 61 | #define CandidateList list <class CandidateForTesselation *>
 | 
|---|
| [ed060e] | 62 | 
 | 
|---|
| [3d919e] | 63 | #define LineMap multimap < int, class BoundaryLineSet * >
 | 
|---|
| [69eb71] | 64 | #define LinePair pair < int, class BoundaryLineSet * >
 | 
|---|
| [6ac7ee] | 65 | #define LineTestPair pair < LineMap::iterator, bool >
 | 
|---|
| [ed060e] | 66 | 
 | 
|---|
| [69eb71] | 67 | #define TriangleMap map < int, class BoundaryTriangleSet * >
 | 
|---|
 | 68 | #define TrianglePair pair < int, class BoundaryTriangleSet * >
 | 
|---|
 | 69 | #define TriangleTestPair pair < TrianglePair::iterator, bool >
 | 
|---|
| [ed060e] | 70 | 
 | 
|---|
 | 71 | #define DistanceMultiMap multimap <double, pair < PointMap::iterator, PointMap::iterator> >
 | 
|---|
 | 72 | #define DistanceMultiMapPair pair <double, pair < PointMap::iterator, PointMap::iterator> >
 | 
|---|
 | 73 | 
 | 
|---|
| [1907a7] | 74 | #define MoleculeList list <molecule *>
 | 
|---|
 | 75 | #define MoleculeListTest pair <MoleculeList::iterator, bool>
 | 
|---|
 | 76 | 
 | 
|---|
| [3d919e] | 77 | #define LinkedAtoms list <atom *>
 | 
|---|
 | 78 | 
 | 
|---|
| [ed060e] | 79 | /******************************** Some small functions and/or structures **********************************/
 | 
|---|
 | 80 | 
 | 
|---|
| [14de469] | 81 | struct KeyCompare
 | 
|---|
 | 82 | {
 | 
|---|
| [042f82] | 83 |   bool operator() (const KeySet SubgraphA, const KeySet SubgraphB) const;
 | 
|---|
| [14de469] | 84 | };
 | 
|---|
| [6d35e4] | 85 | 
 | 
|---|
| [d7e30c] | 86 | struct Trajectory
 | 
|---|
 | 87 | {
 | 
|---|
| [042f82] | 88 |   vector<Vector> R;  //!< position vector
 | 
|---|
 | 89 |   vector<Vector> U;  //!< velocity vector
 | 
|---|
 | 90 |   vector<Vector> F;  //!< last force vector
 | 
|---|
 | 91 |   atom *ptr;         //!< pointer to atom whose trajectory we contain
 | 
|---|
| [d7e30c] | 92 | };
 | 
|---|
 | 93 | 
 | 
|---|
| [042f82] | 94 | //bool operator < (KeySet SubgraphA, KeySet SubgraphB);   //note: this declaration is important, otherwise normal < is used (producing wrong order)
 | 
|---|
| [14de469] | 95 | inline void InsertFragmentIntoGraph(ofstream *out, struct UniqueFragments *Fragment); // Insert a KeySet into a Graph
 | 
|---|
| [042f82] | 96 | inline void InsertGraphIntoGraph(ofstream *out, Graph &graph1, Graph &graph2, int *counter);  // Insert all KeySet's in a Graph into another Graph
 | 
|---|
| [14de469] | 97 | int CompareDoubles (const void * a, const void * b);
 | 
|---|
 | 98 | 
 | 
|---|
| [6d35e4] | 99 | 
 | 
|---|
| [14de469] | 100 | /************************************* Class definitions ****************************************/
 | 
|---|
 | 101 | 
 | 
|---|
 | 102 | 
 | 
|---|
 | 103 | // some algebraic matrix stuff
 | 
|---|
| [042f82] | 104 | #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
 | 
|---|
 | 105 | #define RDET2(a0,a1,a2,a3) ((a0)*(a3)-(a1)*(a2))                      //!< hard-coded determinant of a 2x2 matrix
 | 
|---|
| [14de469] | 106 | 
 | 
|---|
 | 107 | 
 | 
|---|
 | 108 | /** Parameter structure for least square minimsation.
 | 
|---|
 | 109 |  */
 | 
|---|
 | 110 | struct LSQ_params {
 | 
|---|
| [042f82] | 111 |   Vector **vectors;
 | 
|---|
 | 112 |   int num;
 | 
|---|
| [14de469] | 113 | };
 | 
|---|
 | 114 | 
 | 
|---|
 | 115 | double LSQ(const gsl_vector * x, void * params);
 | 
|---|
 | 116 | 
 | 
|---|
 | 117 | /** Parameter structure for least square minimsation.
 | 
|---|
 | 118 |  */
 | 
|---|
 | 119 | struct lsq_params {
 | 
|---|
| [042f82] | 120 |   gsl_vector *x;
 | 
|---|
 | 121 |   const molecule *mol;
 | 
|---|
 | 122 |   element *type;
 | 
|---|
| [14de469] | 123 | };
 | 
|---|
 | 124 | 
 | 
|---|
 | 125 | /** Single atom.
 | 
|---|
 | 126 |  * Class incoporates position, type
 | 
|---|
 | 127 |  */
 | 
|---|
 | 128 | class atom {
 | 
|---|
| [042f82] | 129 |   public:
 | 
|---|
 | 130 |     Vector x;       //!< coordinate array of atom, giving position within cell
 | 
|---|
 | 131 |     Vector v;       //!< velocity array of atom
 | 
|---|
 | 132 |     element *type;  //!< pointing to element
 | 
|---|
 | 133 |     atom *previous; //!< previous atom in molecule list
 | 
|---|
 | 134 |     atom *next;     //!< next atom in molecule list
 | 
|---|
 | 135 |     atom *father;   //!< In many-body bond order fragmentations points to originating atom
 | 
|---|
 | 136 |     atom *Ancestor; //!< "Father" in Depth-First-Search
 | 
|---|
 | 137 |     char *Name;      //!< unique name used during many-body bond-order fragmentation
 | 
|---|
 | 138 |     int FixedIon;   //!< config variable that states whether forces act on the ion or not
 | 
|---|
 | 139 |     int *sort;      //!< sort criteria
 | 
|---|
 | 140 |     int nr;         //!< continuous, unique number
 | 
|---|
 | 141 |     int GraphNr;      //!< unique number, given in DepthFirstSearchAnalysis()
 | 
|---|
 | 142 |     int *ComponentNr;//!< belongs to this nonseparable components, given in DepthFirstSearchAnalysis() (if more than one, then is SeparationVertex)
 | 
|---|
 | 143 |     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.
 | 
|---|
 | 144 |     bool SeparationVertex; //!< whether this atom separates off subsets of atoms or not, determined in DepthFirstSearchAnalysis()
 | 
|---|
 | 145 |     bool IsCyclic;        //!< whether atom belong to as cycle or not, determined in DepthFirstSearchAnalysis()
 | 
|---|
 | 146 |     unsigned char AdaptiveOrder;  //!< current present bond order at site (0 means "not set")
 | 
|---|
 | 147 |     bool MaxOrder;  //!< whether this atom as a root in fragmentation still creates more fragments on higher orders or not
 | 
|---|
 | 148 | 
 | 
|---|
 | 149 |   atom();
 | 
|---|
 | 150 |   ~atom();
 | 
|---|
 | 151 | 
 | 
|---|
 | 152 |   bool Output(int ElementNo, int AtomNo, ofstream *out, const char *comment = NULL) const;
 | 
|---|
 | 153 |   bool OutputXYZLine(ofstream *out) const;
 | 
|---|
 | 154 |   atom *GetTrueFather();
 | 
|---|
 | 155 |   bool Compare(atom &ptr);
 | 
|---|
 | 156 | 
 | 
|---|
 | 157 |   private:
 | 
|---|
| [14de469] | 158 | };
 | 
|---|
 | 159 | 
 | 
|---|
| [ba4432] | 160 | ostream & operator << (ostream &ost, const atom &a);
 | 
|---|
| [14de469] | 161 | 
 | 
|---|
 | 162 | /** Bonds between atoms.
 | 
|---|
 | 163 |  * Class incorporates bonds between atoms in a molecule,
 | 
|---|
 | 164 |  * used to derive tge fragments in many-body bond order
 | 
|---|
 | 165 |  * calculations.
 | 
|---|
 | 166 |  */
 | 
|---|
 | 167 | class bond {
 | 
|---|
| [042f82] | 168 |   public:
 | 
|---|
 | 169 |     atom *leftatom;    //!< first bond partner
 | 
|---|
 | 170 |     atom *rightatom;  //!< second bond partner
 | 
|---|
 | 171 |     bond *previous; //!< previous atom in molecule list
 | 
|---|
 | 172 |     bond *next;     //!< next atom in molecule list
 | 
|---|
 | 173 |     int HydrogenBond;  //!< Number of hydrogen atoms in the bond
 | 
|---|
 | 174 |     int BondDegree;    //!< single, double, triple, ... bond
 | 
|---|
 | 175 |     int nr;           //!< unique number in a molecule, updated by molecule::CreateAdjacencyList()
 | 
|---|
 | 176 |     bool Cyclic;      //!< flag whether bond is part of a cycle or not, given in DepthFirstSearchAnalysis()
 | 
|---|
 | 177 |     enum EdgeType Type;//!< whether this is a tree or back edge
 | 
|---|
 | 178 | 
 | 
|---|
 | 179 |   atom * GetOtherAtom(atom *Atom) const;
 | 
|---|
 | 180 |   bond * GetFirstBond();
 | 
|---|
 | 181 |   bond * GetLastBond();
 | 
|---|
 | 182 | 
 | 
|---|
 | 183 |   bool MarkUsed(enum Shading color);
 | 
|---|
 | 184 |   enum Shading IsUsed();
 | 
|---|
 | 185 |   void ResetUsed();
 | 
|---|
 | 186 |   bool Contains(const atom *ptr);
 | 
|---|
 | 187 |   bool Contains(const int nr);
 | 
|---|
 | 188 | 
 | 
|---|
 | 189 |   bond();
 | 
|---|
 | 190 |   bond(atom *left, atom *right);
 | 
|---|
 | 191 |   bond(atom *left, atom *right, int degree);
 | 
|---|
 | 192 |   bond(atom *left, atom *right, int degree, int number);
 | 
|---|
 | 193 |   ~bond();
 | 
|---|
 | 194 | 
 | 
|---|
 | 195 |   private:
 | 
|---|
 | 196 |     enum Shading Used;        //!< marker in depth-first search, DepthFirstSearchAnalysis()
 | 
|---|
| [14de469] | 197 | };
 | 
|---|
 | 198 | 
 | 
|---|
| [62f793] | 199 | 
 | 
|---|
| [ba4432] | 200 | ostream & operator << (ostream &ost, const bond &b);
 | 
|---|
| [14de469] | 201 | 
 | 
|---|
 | 202 | class MoleculeLeafClass;
 | 
|---|
 | 203 | 
 | 
|---|
| [62f793] | 204 | 
 | 
|---|
 | 205 | #define MaxThermostats 6      //!< maximum number of thermostat entries in Ions#ThermostatNames and Ions#ThermostatImplemented 
 | 
|---|
 | 206 | enum thermostats { None, Woodcock, Gaussian, Langevin, Berendsen, NoseHoover };   //!< Thermostat names for output
 | 
|---|
 | 207 | 
 | 
|---|
 | 208 | 
 | 
|---|
| [14de469] | 209 | /** The complete molecule.
 | 
|---|
 | 210 |  * Class incorporates number of types
 | 
|---|
 | 211 |  */
 | 
|---|
 | 212 | class molecule {
 | 
|---|
| [042f82] | 213 |   public:
 | 
|---|
 | 214 |     double cell_size[6];//!< cell size
 | 
|---|
 | 215 |     periodentafel *elemente; //!< periodic table with each element
 | 
|---|
 | 216 |     atom *start;        //!< start of atom list
 | 
|---|
 | 217 |     atom *end;          //!< end of atom list
 | 
|---|
 | 218 |     bond *first;        //!< start of bond list
 | 
|---|
 | 219 |     bond *last;         //!< end of bond list
 | 
|---|
 | 220 |     bond ***ListOfBondsPerAtom; //!< pointer list for each atom and each bond it has
 | 
|---|
 | 221 |     map<atom *, struct Trajectory> Trajectories; //!< contains old trajectory points
 | 
|---|
 | 222 |     int MDSteps;        //!< The number of MD steps in Trajectories
 | 
|---|
 | 223 |     int *NumberOfBondsPerAtom;  //!< Number of Bonds each atom has
 | 
|---|
 | 224 |     int AtomCount;          //!< number of atoms, brought up-to-date by CountAtoms()
 | 
|---|
 | 225 |     int BondCount;          //!< number of atoms, brought up-to-date by CountBonds()
 | 
|---|
 | 226 |     int ElementCount;       //!< how many unique elements are therein
 | 
|---|
 | 227 |     int ElementsInMolecule[MAX_ELEMENTS]; //!< list whether element (sorted by atomic number) is alread present or not
 | 
|---|
 | 228 |     int NoNonHydrogen;  //!< number of non-hydrogen atoms in molecule
 | 
|---|
 | 229 |     int NoNonBonds;     //!< number of non-hydrogen bonds in molecule
 | 
|---|
 | 230 |     int NoCyclicBonds;  //!< number of cyclic bonds in molecule, by DepthFirstSearchAnalysis()
 | 
|---|
 | 231 |     double BondDistance;  //!< typical bond distance used in CreateAdjacencyList() and furtheron
 | 
|---|
 | 232 |     bool ActiveFlag;    //!< in a MoleculeListClass used to discern active from inactive molecules
 | 
|---|
 | 233 |     Vector Center;      //!< Center of molecule in a global box
 | 
|---|
 | 234 |     char name[MAXSTRINGSIZE];         //!< arbitrary name
 | 
|---|
 | 235 |     int IndexNr;        //!< index of molecule in a MoleculeListClass
 | 
|---|
 | 236 | 
 | 
|---|
 | 237 |   molecule(periodentafel *teil);
 | 
|---|
 | 238 |   ~molecule();
 | 
|---|
 | 239 | 
 | 
|---|
 | 240 |   /// remove atoms from molecule.
 | 
|---|
 | 241 |   bool AddAtom(atom *pointer);
 | 
|---|
 | 242 |   bool RemoveAtom(atom *pointer);
 | 
|---|
 | 243 |   bool UnlinkAtom(atom *pointer);
 | 
|---|
 | 244 |   bool CleanupMolecule();
 | 
|---|
 | 245 | 
 | 
|---|
 | 246 |   /// Add/remove atoms to/from molecule.
 | 
|---|
 | 247 |   atom * AddCopyAtom(atom *pointer);
 | 
|---|
 | 248 |   bool AddXYZFile(string filename);
 | 
|---|
 | 249 |   bool AddHydrogenReplacementAtom(ofstream *out, bond *Bond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bond **BondList, int NumBond, bool IsAngstroem);
 | 
|---|
 | 250 |   bond * AddBond(atom *first, atom *second, int degree);
 | 
|---|
 | 251 |   bool RemoveBond(bond *pointer);
 | 
|---|
 | 252 |   bool RemoveBonds(atom *BondPartner);
 | 
|---|
 | 253 | 
 | 
|---|
 | 254 |   /// Find atoms.
 | 
|---|
 | 255 |   atom * FindAtom(int Nr) const;
 | 
|---|
 | 256 |   atom * AskAtom(string text);
 | 
|---|
 | 257 | 
 | 
|---|
 | 258 |   /// Count and change present atoms' coordination.
 | 
|---|
 | 259 |   void CountAtoms(ofstream *out);
 | 
|---|
 | 260 |   void CountElements();
 | 
|---|
 | 261 |   void CalculateOrbitals(class config &configuration);
 | 
|---|
 | 262 |   bool CenterInBox(ofstream *out);
 | 
|---|
 | 263 |   void CenterEdge(ofstream *out, Vector *max);
 | 
|---|
| [437922] | 264 |   void CenterOrigin(ofstream *out);
 | 
|---|
 | 265 |   void CenterPeriodic(ofstream *out);
 | 
|---|
 | 266 |   void CenterAtVector(ofstream *out, Vector *newcenter);
 | 
|---|
| [042f82] | 267 |   void Translate(const Vector *x);
 | 
|---|
 | 268 |   void TranslatePeriodically(const Vector *trans);
 | 
|---|
 | 269 |   void Mirror(const Vector *x);
 | 
|---|
 | 270 |   void Align(Vector *n);
 | 
|---|
 | 271 |   void Scale(double **factor);
 | 
|---|
| [437922] | 272 |   void DeterminePeriodicCenter(Vector ¢er);
 | 
|---|
| [042f82] | 273 |   Vector * DetermineCenterOfGravity(ofstream *out);
 | 
|---|
 | 274 |   Vector * DetermineCenterOfAll(ofstream *out);
 | 
|---|
| [437922] | 275 |   void SetNameFromFilename(const char *filename);
 | 
|---|
| [042f82] | 276 |   void SetBoxDimension(Vector *dim);
 | 
|---|
 | 277 |   double * ReturnFullMatrixforSymmetric(double *cell_size);
 | 
|---|
 | 278 |   void ScanForPeriodicCorrection(ofstream *out);
 | 
|---|
| [631dcb] | 279 |   bool VerletForceIntegration(ofstream *out, char *file, config &configuration);
 | 
|---|
| [62f793] | 280 |   void Thermostats(config &configuration, double ActualTemp, int Thermostat);
 | 
|---|
| [042f82] | 281 |   void PrincipalAxisSystem(ofstream *out, bool DoRotate);
 | 
|---|
 | 282 |   double VolumeOfConvexEnvelope(ofstream *out, bool IsAngstroem);
 | 
|---|
 | 283 |   Vector* FindEmbeddingHole(ofstream *out, molecule *srcmol);
 | 
|---|
 | 284 | 
 | 
|---|
 | 285 | 
 | 
|---|
| [62f793] | 286 |   double ConstrainedPotential(ofstream *out, atom **permutation, int start, int end, double *constants, bool IsAngstroem);
 | 
|---|
| [631dcb] | 287 |   double MinimiseConstrainedPotential(ofstream *out, atom **&permutation, int startstep, int endstep, bool IsAngstroem);
 | 
|---|
 | 288 |   void EvaluateConstrainedForces(ofstream *out, int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force);
 | 
|---|
 | 289 |   bool LinearInterpolationBetweenConfiguration(ofstream *out, int startstep, int endstep, const char *prefix, config &configuration); 
 | 
|---|
| [d52ea1b] | 290 |         
 | 
|---|
| [042f82] | 291 |   bool CheckBounds(const Vector *x) const;
 | 
|---|
 | 292 |   void GetAlignvector(struct lsq_params * par) const;
 | 
|---|
 | 293 | 
 | 
|---|
 | 294 |   /// Initialising routines in fragmentation
 | 
|---|
 | 295 |   void CreateAdjacencyList2(ofstream *out, ifstream *output);
 | 
|---|
 | 296 |   void CreateAdjacencyList(ofstream *out, double bonddistance, bool IsAngstroem);
 | 
|---|
 | 297 |   void CreateListOfBondsPerAtom(ofstream *out);
 | 
|---|
 | 298 | 
 | 
|---|
 | 299 |   // Graph analysis
 | 
|---|
 | 300 |   MoleculeLeafClass * DepthFirstSearchAnalysis(ofstream *out, class StackClass<bond *> *&BackEdgeStack);
 | 
|---|
 | 301 |   void CyclicStructureAnalysis(ofstream *out, class StackClass<bond *> *BackEdgeStack, int *&MinimumRingSize);
 | 
|---|
 | 302 |   bool PickLocalBackEdges(ofstream *out, atom **ListOfLocalAtoms, class StackClass<bond *> *&ReferenceStack, class StackClass<bond *> *&LocalStack);
 | 
|---|
 | 303 |   bond * FindNextUnused(atom *vertex);
 | 
|---|
 | 304 |   void SetNextComponentNumber(atom *vertex, int nr);
 | 
|---|
 | 305 |   void InitComponentNumbers();
 | 
|---|
 | 306 |   void OutputComponentNumber(ofstream *out, atom *vertex);
 | 
|---|
 | 307 |   void ResetAllBondsToUnused();
 | 
|---|
 | 308 |   void ResetAllAtomNumbers();
 | 
|---|
 | 309 |   int CountCyclicBonds(ofstream *out);
 | 
|---|
 | 310 |   bool CheckForConnectedSubgraph(ofstream *out, KeySet *Fragment);
 | 
|---|
 | 311 |   string GetColor(enum Shading color);
 | 
|---|
 | 312 | 
 | 
|---|
 | 313 |   molecule *CopyMolecule();
 | 
|---|
 | 314 | 
 | 
|---|
 | 315 |   /// Fragment molecule by two different approaches:
 | 
|---|
 | 316 |   int FragmentMolecule(ofstream *out, int Order, config *configuration);
 | 
|---|
 | 317 |   bool CheckOrderAtSite(ofstream *out, bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path = NULL);
 | 
|---|
 | 318 |   bool StoreAdjacencyToFile(ofstream *out, char *path);
 | 
|---|
 | 319 |   bool CheckAdjacencyFileAgainstMolecule(ofstream *out, char *path, atom **ListOfAtoms);
 | 
|---|
 | 320 |   bool ParseOrderAtSiteFromFile(ofstream *out, char *path);
 | 
|---|
 | 321 |   bool StoreOrderAtSiteFile(ofstream *out, char *path);
 | 
|---|
 | 322 |   bool ParseKeySetFile(ofstream *out, char *filename, Graph *&FragmentList);
 | 
|---|
 | 323 |   bool StoreKeySetFile(ofstream *out, Graph &KeySetList, char *path);
 | 
|---|
 | 324 |   bool StoreForcesFile(ofstream *out, MoleculeListClass *BondFragments, char *path, int *SortIndex);
 | 
|---|
 | 325 |   bool CreateMappingLabelsToConfigSequence(ofstream *out, int *&SortIndex);
 | 
|---|
 | 326 |   bool ScanBufferIntoKeySet(ofstream *out, char *buffer, KeySet &CurrentSet);
 | 
|---|
 | 327 |   void BreadthFirstSearchAdd(ofstream *out, molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem);
 | 
|---|
 | 328 |   /// -# BOSSANOVA
 | 
|---|
 | 329 |   void FragmentBOSSANOVA(ofstream *out, Graph *&FragmentList, KeyStack &RootStack, int *MinimumRingSize);
 | 
|---|
 | 330 |   int PowerSetGenerator(ofstream *out, int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet);
 | 
|---|
 | 331 |   bool BuildInducedSubgraph(ofstream *out, const molecule *Father);
 | 
|---|
 | 332 |   molecule * StoreFragmentFromKeySet(ofstream *out, KeySet &Leaflet, bool IsAngstroem);
 | 
|---|
 | 333 |   void SPFragmentGenerator(ofstream *out, struct UniqueFragments *FragmentSearch, int RootDistance, bond **BondsSet, int SetDimension, int SubOrder);
 | 
|---|
 | 334 |   int LookForRemovalCandidate(ofstream *&out, KeySet *&Leaf, int *&ShortestPathList);
 | 
|---|
 | 335 |   int GuesstimateFragmentCount(ofstream *out, int order);
 | 
|---|
 | 336 | 
 | 
|---|
 | 337 |   // Recognize doubly appearing molecules in a list of them
 | 
|---|
 | 338 |   int * IsEqualToWithinThreshold(ofstream *out, molecule *OtherMolecule, double threshold);
 | 
|---|
 | 339 |   int * GetFatherSonAtomicMap(ofstream *out, molecule *OtherMolecule);
 | 
|---|
 | 340 | 
 | 
|---|
 | 341 |   // Output routines.
 | 
|---|
 | 342 |   bool Output(ofstream *out);
 | 
|---|
 | 343 |   bool OutputTrajectories(ofstream *out);
 | 
|---|
 | 344 |   void OutputListOfBonds(ofstream *out) const;
 | 
|---|
 | 345 |   bool OutputXYZ(ofstream *out) const;
 | 
|---|
 | 346 |   bool OutputTrajectoriesXYZ(ofstream *out);
 | 
|---|
 | 347 |   bool Checkout(ofstream *out) const;
 | 
|---|
 | 348 |   bool OutputTemperatureFromTrajectories(ofstream *out, int startstep, int endstep, ofstream *output);
 | 
|---|
 | 349 | 
 | 
|---|
 | 350 |   private:
 | 
|---|
 | 351 |   int last_atom;      //!< number given to last atom
 | 
|---|
| [14de469] | 352 | };
 | 
|---|
 | 353 | 
 | 
|---|
 | 354 | /** A list of \a molecule classes.
 | 
|---|
 | 355 |  */
 | 
|---|
 | 356 | class MoleculeListClass {
 | 
|---|
| [042f82] | 357 |   public:
 | 
|---|
 | 358 |     MoleculeList ListOfMolecules; //!< List of the contained molecules
 | 
|---|
 | 359 |     int MaxIndex;
 | 
|---|
 | 360 | 
 | 
|---|
 | 361 |   MoleculeListClass();
 | 
|---|
 | 362 |   ~MoleculeListClass();
 | 
|---|
 | 363 | 
 | 
|---|
 | 364 |   bool AddHydrogenCorrection(ofstream *out, char *path);
 | 
|---|
 | 365 |   bool StoreForcesFile(ofstream *out, char *path, int *SortIndex);
 | 
|---|
| [437922] | 366 |   void insert(molecule *mol);
 | 
|---|
| [042f82] | 367 |   molecule * ReturnIndex(int index);
 | 
|---|
 | 368 |   bool OutputConfigForListOfFragments(ofstream *out, config *configuration, int *SortIndex);
 | 
|---|
 | 369 |   int NumberOfActiveMolecules();
 | 
|---|
 | 370 |   void Enumerate(ofstream *out);
 | 
|---|
 | 371 |   void Output(ofstream *out);
 | 
|---|
 | 372 | 
 | 
|---|
 | 373 |   // merging of molecules
 | 
|---|
| [1907a7] | 374 |   bool SimpleMerge(molecule *mol, molecule *srcmol);
 | 
|---|
 | 375 |   bool SimpleAdd(molecule *mol, molecule *srcmol);
 | 
|---|
 | 376 |   bool SimpleMultiMerge(molecule *mol, int *src, int N);
 | 
|---|
 | 377 |   bool SimpleMultiAdd(molecule *mol, int *src, int N);
 | 
|---|
 | 378 |   bool ScatterMerge(molecule *mol, int *src, int N);
 | 
|---|
 | 379 |   bool EmbedMerge(molecule *mol, molecule *srcmol);
 | 
|---|
 | 380 | 
 | 
|---|
| [042f82] | 381 |   private:
 | 
|---|
| [14de469] | 382 | };
 | 
|---|
 | 383 | 
 | 
|---|
 | 384 | 
 | 
|---|
 | 385 | /** A leaf for a tree of \a molecule class
 | 
|---|
 | 386 |  * Wraps molecules in a tree structure
 | 
|---|
 | 387 |  */
 | 
|---|
 | 388 | class MoleculeLeafClass {
 | 
|---|
| [042f82] | 389 |   public:
 | 
|---|
 | 390 |     molecule *Leaf;                   //!< molecule of this leaf
 | 
|---|
 | 391 |     //MoleculeLeafClass *UpLeaf;        //!< Leaf one level up
 | 
|---|
 | 392 |     //MoleculeLeafClass *DownLeaf;      //!< First leaf one level down
 | 
|---|
 | 393 |     MoleculeLeafClass *previous;  //!< Previous leaf on this level
 | 
|---|
 | 394 |     MoleculeLeafClass *next;      //!< Next leaf on this level
 | 
|---|
 | 395 | 
 | 
|---|
 | 396 |   //MoleculeLeafClass(MoleculeLeafClass *Up, MoleculeLeafClass *Previous);
 | 
|---|
 | 397 |   MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf);
 | 
|---|
 | 398 |   ~MoleculeLeafClass();
 | 
|---|
 | 399 | 
 | 
|---|
 | 400 |   bool AddLeaf(molecule *ptr, MoleculeLeafClass *Previous);
 | 
|---|
 | 401 |   bool FillBondStructureFromReference(ofstream *out, molecule *reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList = false);
 | 
|---|
 | 402 |   bool FillRootStackForSubgraphs(ofstream *out, KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter);
 | 
|---|
 | 403 |   bool AssignKeySetsToFragment(ofstream *out, molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList = false);
 | 
|---|
 | 404 |   bool FillListOfLocalAtoms(ofstream *out, atom ***&ListOfLocalAtoms, const int FragmentCounter, const int GlobalAtomCount, bool &FreeList);
 | 
|---|
 | 405 |   void TranslateIndicesToGlobalIDs(ofstream *out, Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph);
 | 
|---|
 | 406 |   int Count() const;
 | 
|---|
| [14de469] | 407 | };
 | 
|---|
 | 408 | 
 | 
|---|
| [d1df9b] | 409 | class ConfigFileBuffer {
 | 
|---|
 | 410 |   public:
 | 
|---|
 | 411 |     char **buffer;
 | 
|---|
 | 412 |     int *LineMapping;
 | 
|---|
 | 413 |     int CurrentLine;
 | 
|---|
 | 414 |     int NoLines;
 | 
|---|
 | 415 | 
 | 
|---|
 | 416 |     ConfigFileBuffer();
 | 
|---|
 | 417 |     ConfigFileBuffer(char *filename);
 | 
|---|
 | 418 |     ~ConfigFileBuffer();
 | 
|---|
 | 419 | 
 | 
|---|
 | 420 |     void InitMapping();
 | 
|---|
 | 421 |     void MapIonTypesInBuffer(int NoAtoms);
 | 
|---|
 | 422 | };
 | 
|---|
 | 423 | 
 | 
|---|
 | 424 | 
 | 
|---|
| [14de469] | 425 | /** The config file.
 | 
|---|
 | 426 |  * The class contains all parameters that control a dft run also functions to load and save.
 | 
|---|
 | 427 |  */
 | 
|---|
 | 428 | class config {
 | 
|---|
| [042f82] | 429 |   public:
 | 
|---|
 | 430 |     int PsiType;
 | 
|---|
 | 431 |     int MaxPsiDouble;
 | 
|---|
 | 432 |     int PsiMaxNoUp;
 | 
|---|
 | 433 |     int PsiMaxNoDown;
 | 
|---|
 | 434 |     int MaxMinStopStep;
 | 
|---|
 | 435 |     int InitMaxMinStopStep;
 | 
|---|
 | 436 |     int ProcPEGamma;
 | 
|---|
 | 437 |     int ProcPEPsi;
 | 
|---|
 | 438 |     char *configpath;
 | 
|---|
 | 439 |     char *configname;
 | 
|---|
 | 440 |     bool FastParsing;
 | 
|---|
 | 441 |     double Deltat;
 | 
|---|
 | 442 |     string basis;
 | 
|---|
| [6ac7ee] | 443 | 
 | 
|---|
| [989bf6] | 444 |     char *databasepath;
 | 
|---|
 | 445 | 
 | 
|---|
| [6e9353] | 446 |     int DoConstrainedMD;
 | 
|---|
| [85bac0] | 447 |     int MaxOuterStep;
 | 
|---|
| [62f793] | 448 |     int Thermostat;
 | 
|---|
 | 449 |     int *ThermostatImplemented;
 | 
|---|
 | 450 |     char **ThermostatNames;
 | 
|---|
 | 451 |     double TempFrequency;
 | 
|---|
 | 452 |     double alpha;
 | 
|---|
 | 453 |     double HooverMass;
 | 
|---|
 | 454 |     double TargetTemp;
 | 
|---|
 | 455 |     int ScaleTempStep;
 | 
|---|
| [14de469] | 456 |     
 | 
|---|
| [042f82] | 457 |   private:
 | 
|---|
 | 458 |     char *mainname;
 | 
|---|
 | 459 |     char *defaultpath;
 | 
|---|
 | 460 |     char *pseudopotpath;
 | 
|---|
 | 461 | 
 | 
|---|
 | 462 |     int DoOutVis;
 | 
|---|
 | 463 |     int DoOutMes;
 | 
|---|
 | 464 |     int DoOutNICS;
 | 
|---|
 | 465 |     int DoOutOrbitals;
 | 
|---|
 | 466 |     int DoOutCurrent;
 | 
|---|
 | 467 |     int DoFullCurrent;
 | 
|---|
 | 468 |     int DoPerturbation;
 | 
|---|
 | 469 |     int DoWannier;
 | 
|---|
 | 470 |     int CommonWannier;
 | 
|---|
 | 471 |     double SawtoothStart;
 | 
|---|
 | 472 |     int VectorPlane;
 | 
|---|
 | 473 |     double VectorCut;
 | 
|---|
 | 474 |     int UseAddGramSch;
 | 
|---|
 | 475 |     int Seed;
 | 
|---|
 | 476 | 
 | 
|---|
 | 477 |     int OutVisStep;
 | 
|---|
 | 478 |     int OutSrcStep;
 | 
|---|
 | 479 |     int MaxPsiStep;
 | 
|---|
 | 480 |     double EpsWannier;
 | 
|---|
 | 481 | 
 | 
|---|
 | 482 |     int MaxMinStep;
 | 
|---|
 | 483 |     double RelEpsTotalEnergy;
 | 
|---|
 | 484 |     double RelEpsKineticEnergy;
 | 
|---|
 | 485 |     int MaxMinGapStopStep;
 | 
|---|
 | 486 |     int MaxInitMinStep;
 | 
|---|
 | 487 |     double InitRelEpsTotalEnergy;
 | 
|---|
 | 488 |     double InitRelEpsKineticEnergy;
 | 
|---|
 | 489 |     int InitMaxMinGapStopStep;
 | 
|---|
 | 490 | 
 | 
|---|
 | 491 |     //double BoxLength[NDIM*NDIM];
 | 
|---|
 | 492 | 
 | 
|---|
 | 493 |     double ECut;
 | 
|---|
 | 494 |     int MaxLevel;
 | 
|---|
 | 495 |     int RiemannTensor;
 | 
|---|
 | 496 |     int LevRFactor;
 | 
|---|
 | 497 |     int RiemannLevel;
 | 
|---|
 | 498 |     int Lev0Factor;
 | 
|---|
 | 499 |     int RTActualUse;
 | 
|---|
 | 500 |     int AddPsis;
 | 
|---|
 | 501 | 
 | 
|---|
 | 502 |     double RCut;
 | 
|---|
 | 503 |     int StructOpt;
 | 
|---|
 | 504 |     int IsAngstroem;
 | 
|---|
 | 505 |     int RelativeCoord;
 | 
|---|
 | 506 |     int MaxTypes;
 | 
|---|
 | 507 | 
 | 
|---|
 | 508 | 
 | 
|---|
 | 509 |   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);
 | 
|---|
 | 510 |   int ParseForParameter(int verbose, struct ConfigFileBuffer *FileBuffer, const char *name, int sequential, int const xth, int const yth, int type, void *value, int repetition, int critical);
 | 
|---|
 | 511 | 
 | 
|---|
 | 512 |   public:
 | 
|---|
 | 513 |   config();
 | 
|---|
 | 514 |   ~config();
 | 
|---|
 | 515 | 
 | 
|---|
 | 516 |   int TestSyntax(char *filename, periodentafel *periode, molecule *mol);
 | 
|---|
 | 517 |   void Load(char *filename, periodentafel *periode, molecule *mol);
 | 
|---|
 | 518 |   void LoadOld(char *filename, periodentafel *periode, molecule *mol);
 | 
|---|
 | 519 |   void RetrieveConfigPathAndName(string filename);
 | 
|---|
 | 520 |   bool Save(const char *filename, periodentafel *periode, molecule *mol) const;
 | 
|---|
 | 521 |   bool SaveMPQC(const char *filename, molecule *mol) const;
 | 
|---|
 | 522 |   void Edit();
 | 
|---|
 | 523 |   bool GetIsAngstroem() const;
 | 
|---|
 | 524 |   char *GetDefaultPath() const;
 | 
|---|
 | 525 |   void SetDefaultPath(const char *path);
 | 
|---|
| [62f793] | 526 |   void InitThermostats(ifstream *source);
 | 
|---|
| [14de469] | 527 | };
 | 
|---|
 | 528 | 
 | 
|---|
 | 529 | #endif /*MOLECULES_HPP_*/
 | 
|---|
 | 530 | 
 | 
|---|