source: src/molecules.hpp@ db066d

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 db066d was 2459b1, checked in by Frederik Heber <heber@…>, 17 years ago

ForcesFile and TEFactors are _needed_, reincorporated. UniqueFragments structure is now in BOSSANOVA

ForcesFile is again written, as we need it for the hydrogen not coming saturation (forces!)
TEFactors are back, as despite my notion they are needed in the evaluation
UniqueFragments structure is shifted from PowerSetGenerator to FragmentBOSSANOVA. Actually only for the labels - however, the if was changed to test the real indices (which are also always the same, which is better for adaptive runs) - but might be more useful there still.
analyzer and joiner again parse indices.

  • Property mode set to 100644
File size: 22.2 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, Graph *&FragmentList, bool IsAngstroem);
528 bool StoreKeySetFile(ofstream *out, Graph &KeySetList, char *path);
529 bool StoreForcesFile(ofstream *out, MoleculeListClass *BondFragments, char *path, int *SortIndex);
530 bool ScanBufferIntoKeySet(ofstream *out, char *buffer, KeySet &CurrentSet);
531 void BreadthFirstSearchAdd(ofstream *out, molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem);
532 /// -# BOSSANOVA
533 void FragmentBOSSANOVA(ofstream *out, Graph *&FragmentList, KeyStack &RootStack);
534 int PowerSetGenerator(ofstream *out, int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet);
535 bool BuildInducedSubgraph(ofstream *out, const molecule *Father);
536 molecule * StoreFragmentFromKeySet(ofstream *out, KeySet &Leaflet, bool IsAngstroem);
537 void SPFragmentGenerator(ofstream *out, struct UniqueFragments *FragmentSearch, int RootDistance, bond **BondsSet, int SetDimension, int SubOrder);
538 int LookForRemovalCandidate(ofstream *&out, KeySet *&Leaf, int *&ShortestPathList);
539 int GuesstimateFragmentCount(ofstream *out, int order);
540
541 // Recognize doubly appearing molecules in a list of them
542 int * IsEqualToWithinThreshold(ofstream *out, molecule *OtherMolecule, double threshold);
543 int * GetFatherSonAtomicMap(ofstream *out, molecule *OtherMolecule);
544
545 // Output routines.
546 bool Output(ofstream *out);
547 bool OutputXYZ(ofstream *out) const;
548 bool Checkout(ofstream *out) const;
549
550 private:
551 int last_atom; //!< number given to last atom
552};
553
554/** A list of \a molecule classes.
555 */
556class MoleculeListClass {
557 public:
558 molecule **ListOfMolecules; //!< pointer list of fragment molecules to check for equality
559 int NumberOfMolecules; //!< Number of entries in \a **FragmentList and of to be returned one.
560 int NumberOfTopAtoms; //!< Number of atoms in the molecule from which all fragments originate
561
562 MoleculeListClass();
563 MoleculeListClass(int Num, int NumAtoms);
564 ~MoleculeListClass();
565
566 /// Output configs.
567 bool StoreForcesFile(ofstream *out, char *path, int *SortIndex);
568 bool OutputConfigForListOfFragments(ofstream *out, config *configuration, int *SortIndex);
569 void Output(ofstream *out);
570
571 private:
572};
573
574
575/** A leaf for a tree of \a molecule class
576 * Wraps molecules in a tree structure
577 */
578class MoleculeLeafClass {
579 public:
580 molecule *Leaf; //!< molecule of this leaf
581 //MoleculeLeafClass *UpLeaf; //!< Leaf one level up
582 //MoleculeLeafClass *DownLeaf; //!< First leaf one level down
583 MoleculeLeafClass *previous; //!< Previous leaf on this level
584 MoleculeLeafClass *next; //!< Next leaf on this level
585
586 //MoleculeLeafClass(MoleculeLeafClass *Up, MoleculeLeafClass *Previous);
587 MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf);
588 ~MoleculeLeafClass();
589
590 bool AddLeaf(molecule *ptr, MoleculeLeafClass *Previous);
591};
592
593/** The config file.
594 * The class contains all parameters that control a dft run also functions to load and save.
595 */
596class config {
597 public:
598 int PsiType;
599 int MaxPsiDouble;
600 int PsiMaxNoUp;
601 int PsiMaxNoDown;
602 int MaxMinStopStep;
603 int InitMaxMinStopStep;
604 int ProcPEGamma;
605 int ProcPEPsi;
606 char *configpath;
607 char *configname;
608
609 private:
610 char *mainname;
611 char *defaultpath;
612 char *pseudopotpath;
613
614 int DoOutVis;
615 int DoOutMes;
616 int DoOutNICS;
617 int DoOutOrbitals;
618 int DoOutCurrent;
619 int DoFullCurrent;
620 int DoPerturbation;
621 int CommonWannier;
622 double SawtoothStart;
623 int VectorPlane;
624 double VectorCut;
625 int UseAddGramSch;
626 int Seed;
627
628 int MaxOuterStep;
629 double Deltat;
630 int OutVisStep;
631 int OutSrcStep;
632 double TargetTemp;
633 int ScaleTempStep;
634 int MaxPsiStep;
635 double EpsWannier;
636
637 int MaxMinStep;
638 double RelEpsTotalEnergy;
639 double RelEpsKineticEnergy;
640 int MaxMinGapStopStep;
641 int MaxInitMinStep;
642 double InitRelEpsTotalEnergy;
643 double InitRelEpsKineticEnergy;
644 int InitMaxMinGapStopStep;
645
646 //double BoxLength[NDIM*NDIM];
647
648 double ECut;
649 int MaxLevel;
650 int RiemannTensor;
651 int LevRFactor;
652 int RiemannLevel;
653 int Lev0Factor;
654 int RTActualUse;
655 int AddPsis;
656
657 double RCut;
658 int StructOpt;
659 int IsAngstroem;
660 int RelativeCoord;
661 int MaxTypes;
662
663
664 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);
665
666 public:
667 config();
668 ~config();
669
670 int TestSyntax(char *filename, periodentafel *periode, molecule *mol);
671 void Load(char *filename, periodentafel *periode, molecule *mol);
672 void LoadOld(char *filename, periodentafel *periode, molecule *mol);
673 void RetrieveConfigPathAndName(char *filename);
674 bool Save(ofstream *file, periodentafel *periode, molecule *mol) const;
675 void Edit(molecule *mol);
676 bool GetIsAngstroem() const;
677 char *GetDefaultPath() const;
678 void config::SetDefaultPath(const char *path);
679};
680
681#endif /*MOLECULES_HPP_*/
682
Note: See TracBrowser for help on using the repository browser.