source: src/molecules.hpp@ bd6579

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since bd6579 was db942e, checked in by Frederik Heber <heber@…>, 17 years ago

HUGE REWRITE to allow for adaptive increase of the bond order, first working commit

Lots of code was thrown out:
-BottomUp, TopDown and GetAtomicFragments
-TEFactors are now used as "CreationCounters", i.e. the count how often a fragment as been created (ideal would be only once)
-ReduceToUniqueOnes and stuff all thrown out, since they are out-dated since use of hash table
Other changes:
-CreateListofUniqueFragments renamed to PowerSetGenerator
-PowerSetGenerator goes not over all reachable roots, but one given by calling function FragmentBOSSANOVA
-FragmentBOSSANOVA loops over all possible root sites and hands this over to PowerSetGenerator
-by the virtue of the hash table it is not important anymore whether created keysets are unique or not, as this is recognized in log(n). Hence, the label < label is not important anymore (and not applicable in an adaptive scheme with old, parsed keysets and unknown labels) (THIS IS HOWEVER NOT DONE YET!)
The setup is then as follows:

  1. FragmentMolecule
    1. parses adjacency, keysets and orderatsite files
    2. performs DFS to find connected subgraphs (to leave this in was a design decision: might be useful later)
    3. a RootStack is created for every subgraph (here, later we implement the "update 10 sites with highest energy contribution", and that's why this consciously not done in the following loop)
    4. in a loop over all subgraphs

d1. calls FragmentBOSSANOVA with this RootStack and within the subgraph molecule structure
d2. creates molecule (fragment)s from the returned keysets (StoreFragmentFromKeySet)

  1. combines the generated molecule lists from all subgraphs
  2. saves to disk: fragment configs, adjacency, orderatsite, keyset files
  1. FragmentBOSSANOVA
    1. constructs a complete keyset of the molecule
    2. In a loop over all possible roots from the given rootstack

b1. increases order of root site
b2. calls PowerSetGenerator with this order, the complete keyset and the rootkeynr
b3. for all consecutive lower levels PowerSetGenerator is called with the suborder, the higher order keyset as the restricted one and each site in the set as the root)
b4. these are merged into a fragment list of keysets

  1. All fragment lists (for all orders, i.e. from all destination fields) are merged into one list for return
  1. PowerSetGenerator
    1. initialises UniqueFragments structure
    2. fills edge list via BFS
    3. creates the fragment by calling recursive function SPFragmentGenerator with UniqueFragments structure, 0 as root distance, the edge set, its dimension and the current suborder
    4. Free'ing structure
  2. SPFragmentGenerator (nothing much has changed here)
    1. loops over every possible combination (2dimension of edge set)

a1. inserts current set, if there's still space left

a11. yes: calls SPFragmentGenerator with structure, created new edge list and size respective to root distance+1
a12. no: stores fragment into keyset list by calling InsertFragmentIntoGraph

a2. removes all items added into the snake stack (in UniqueFragments structure) added during level (root distance) and current set

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