1 | /** \file molecule.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 | /*********************************************** includes ***********************************/
|
---|
12 |
|
---|
13 | // GSL headers
|
---|
14 | #include <gsl/gsl_eigen.h>
|
---|
15 | #include <gsl/gsl_heapsort.h>
|
---|
16 | #include <gsl/gsl_linalg.h>
|
---|
17 | #include <gsl/gsl_matrix.h>
|
---|
18 | #include <gsl/gsl_multimin.h>
|
---|
19 | #include <gsl/gsl_vector.h>
|
---|
20 | #include <gsl/gsl_randist.h>
|
---|
21 |
|
---|
22 | //// STL headers
|
---|
23 | #include <map>
|
---|
24 | #include <set>
|
---|
25 | #include <deque>
|
---|
26 | #include <list>
|
---|
27 | #include <vector>
|
---|
28 |
|
---|
29 | #include <string>
|
---|
30 |
|
---|
31 | #include "types.hpp"
|
---|
32 | #include "graph.hpp"
|
---|
33 | #include "tesselation.hpp"
|
---|
34 | #include "Patterns/Observer.hpp"
|
---|
35 | #include "Patterns/ObservedIterator.hpp"
|
---|
36 | #include "Patterns/Cacheable.hpp"
|
---|
37 |
|
---|
38 | #include "Descriptors/MoleculeDescriptor_impl.hpp"
|
---|
39 |
|
---|
40 | /****************************************** forward declarations *****************************/
|
---|
41 |
|
---|
42 | class atom;
|
---|
43 | class bond;
|
---|
44 | class BondedParticle;
|
---|
45 | class BondGraph;
|
---|
46 | class element;
|
---|
47 | class ForceMatrix;
|
---|
48 | class LinkedCell;
|
---|
49 | class molecule;
|
---|
50 | class MoleculeLeafClass;
|
---|
51 | class MoleculeListClass;
|
---|
52 | class periodentafel;
|
---|
53 | class Vector;
|
---|
54 | class Shape;
|
---|
55 | template <class> class StackClass;
|
---|
56 |
|
---|
57 | /******************************** Some definitions for easier reading **********************************/
|
---|
58 |
|
---|
59 | #define MoleculeList list <molecule *>
|
---|
60 | #define MoleculeListTest pair <MoleculeList::iterator, bool>
|
---|
61 |
|
---|
62 | #define DistancePair pair < double, atom* >
|
---|
63 | #define DistanceMap multimap < double, atom* >
|
---|
64 | #define DistanceTestPair pair < DistanceMap::iterator, bool>
|
---|
65 |
|
---|
66 |
|
---|
67 | /************************************* Class definitions ****************************************/
|
---|
68 |
|
---|
69 | /** Structure to contain parameters needed for evaluation of constraint potential.
|
---|
70 | */
|
---|
71 | struct EvaluatePotential
|
---|
72 | {
|
---|
73 | int startstep; //!< start configuration (MDStep in atom::trajectory)
|
---|
74 | int endstep; //!< end configuration (MDStep in atom::trajectory)
|
---|
75 | atom **PermutationMap; //!< gives target ptr for each atom, array of size molecule::AtomCount (this is "x" in \f$ V^{con}(x) \f$ )
|
---|
76 | DistanceMap **DistanceList; //!< distance list of each atom to each atom
|
---|
77 | DistanceMap::iterator *StepList; //!< iterator to ascend through NearestNeighbours \a **DistanceList
|
---|
78 | int *DoubleList; //!< count of which sources want to move to this target, basically the injective measure (>1 -> not injective)
|
---|
79 | DistanceMap::iterator *DistanceIterators; //!< marks which was the last picked target as injective candidate with smallest distance
|
---|
80 | bool IsAngstroem; //!< whether coordinates are in angstroem (true) or bohrradius (false)
|
---|
81 | double *PenaltyConstants; //!< penalty constant in front of each term
|
---|
82 | };
|
---|
83 |
|
---|
84 | /** The complete molecule.
|
---|
85 | * Class incorporates number of types
|
---|
86 | */
|
---|
87 | class molecule : public PointCloud , public Observable {
|
---|
88 | friend molecule *NewMolecule();
|
---|
89 | friend void DeleteMolecule(molecule *);
|
---|
90 |
|
---|
91 | public:
|
---|
92 | typedef std::list<atom*> atomSet;
|
---|
93 | typedef std::set<atomId_t> atomIdSet;
|
---|
94 | typedef ObservedIterator<atomSet> iterator;
|
---|
95 | typedef atomSet::const_iterator const_iterator;
|
---|
96 |
|
---|
97 | const periodentafel * const elemente; //!< periodic table with each element
|
---|
98 | // old deprecated atom handling
|
---|
99 | //atom *start; //!< start of atom list
|
---|
100 | //atom *end; //!< end of atom list
|
---|
101 | //bond *first; //!< start of bond list
|
---|
102 | //bond *last; //!< end of bond list
|
---|
103 | int MDSteps; //!< The number of MD steps in Trajectories
|
---|
104 | //int AtomCount; //!< number of atoms, brought up-to-date by CountAtoms()
|
---|
105 | int BondCount; //!< number of atoms, brought up-to-date by CountBonds()
|
---|
106 | int ElementCount; //!< how many unique elements are therein
|
---|
107 | int ElementsInMolecule[MAX_ELEMENTS]; //!< list whether element (sorted by atomic number) is alread present or not
|
---|
108 | mutable int NoNonHydrogen; //!< number of non-hydrogen atoms in molecule
|
---|
109 | mutable int NoNonBonds; //!< number of non-hydrogen bonds in molecule
|
---|
110 | mutable int NoCyclicBonds; //!< number of cyclic bonds in molecule, by DepthFirstSearchAnalysis()
|
---|
111 | double BondDistance; //!< typical bond distance used in CreateAdjacencyList() and furtheron
|
---|
112 | bool ActiveFlag; //!< in a MoleculeListClass used to discern active from inactive molecules
|
---|
113 | Vector Center; //!< Center of molecule in a global box
|
---|
114 | int IndexNr; //!< index of molecule in a MoleculeListClass
|
---|
115 | char name[MAXSTRINGSIZE]; //!< arbitrary name
|
---|
116 |
|
---|
117 | private:
|
---|
118 | Cacheable<string> formula;
|
---|
119 | Cacheable<int> AtomCount;
|
---|
120 | moleculeId_t id;
|
---|
121 | atomSet atoms; //<!list of atoms
|
---|
122 | atomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms
|
---|
123 | protected:
|
---|
124 | //void CountAtoms();
|
---|
125 | /**
|
---|
126 | * this iterator type should be used for internal variables, \
|
---|
127 | * since it will not lock
|
---|
128 | */
|
---|
129 | typedef atomSet::iterator internal_iterator;
|
---|
130 |
|
---|
131 |
|
---|
132 | molecule(const periodentafel * const teil);
|
---|
133 | virtual ~molecule();
|
---|
134 |
|
---|
135 |
|
---|
136 | public:
|
---|
137 | //getter and setter
|
---|
138 | const std::string getName();
|
---|
139 | int getAtomCount() const;
|
---|
140 | int doCountAtoms();
|
---|
141 | moleculeId_t getId();
|
---|
142 | void setId(moleculeId_t);
|
---|
143 | void setName(const std::string);
|
---|
144 | const std::string getFormula();
|
---|
145 | std::string calcFormula();
|
---|
146 |
|
---|
147 | iterator begin();
|
---|
148 | const_iterator begin() const;
|
---|
149 | iterator end();
|
---|
150 | const_iterator end() const;
|
---|
151 | bool empty() const;
|
---|
152 | size_t size() const;
|
---|
153 | const_iterator erase( const_iterator loc );
|
---|
154 | const_iterator erase( atom * key );
|
---|
155 | const_iterator find ( atom * key ) const;
|
---|
156 | pair<iterator,bool> insert ( atom * const key );
|
---|
157 | bool containsAtom(atom* key);
|
---|
158 |
|
---|
159 |
|
---|
160 | // re-definition of virtual functions from PointCloud
|
---|
161 | const char * const GetName() const;
|
---|
162 | Vector *GetCenter() const ;
|
---|
163 | TesselPoint *GetPoint() const ;
|
---|
164 | int GetMaxId() const;
|
---|
165 | void GoToNext() const ;
|
---|
166 | void GoToFirst() const ;
|
---|
167 | bool IsEmpty() const ;
|
---|
168 | bool IsEnd() const ;
|
---|
169 |
|
---|
170 | // templates for allowing global manipulation of all vectors
|
---|
171 | template <typename res> void ActOnAllVectors( res (Vector::*f)() ) const;
|
---|
172 | template <typename res> void ActOnAllVectors( res (Vector::*f)() const) const;
|
---|
173 | template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T), T t ) const;
|
---|
174 | template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T) const, T t ) const;
|
---|
175 | template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T&), T &t ) const;
|
---|
176 | template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const;
|
---|
177 | template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const;
|
---|
178 | template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const;
|
---|
179 | template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const;
|
---|
180 | template <typename res, typename T, typename U, typename V> void ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const;
|
---|
181 |
|
---|
182 | // templates for allowing global manipulation of molecule with each atom as single argument
|
---|
183 | template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) ) const;
|
---|
184 | template <typename res> void ActWithEachAtom( res (molecule::*f)(atom *) const) const;
|
---|
185 |
|
---|
186 | // templates for allowing global copying of molecule with each atom as single argument
|
---|
187 | template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const;
|
---|
188 | template <typename res> void ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const;
|
---|
189 |
|
---|
190 | // templates for allowing global manipulation of all atoms
|
---|
191 | template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() ) const;
|
---|
192 | template <typename res, typename typ> void ActOnAllAtoms( res (typ::*f)() const) const;
|
---|
193 | template <typename res, typename typ, typename T> void ActOnAllAtoms( res (typ::*f)(T), T t ) const;
|
---|
194 | template <typename res, typename typ, typename T> void ActOnAllAtoms( res (typ::*f)(T) const, T t ) const;
|
---|
195 | template <typename res, typename typ, typename T, typename U> void ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const;
|
---|
196 | template <typename res, typename typ, typename T, typename U> void ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const;
|
---|
197 | template <typename res, typename typ, typename T, typename U, typename V> void ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const;
|
---|
198 | template <typename res, typename typ, typename T, typename U, typename V> void ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const;
|
---|
199 | template <typename res, typename typ, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const;
|
---|
200 | template <typename res, typename typ, typename T, typename U, typename V, typename W> void ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const;
|
---|
201 |
|
---|
202 | // templates for allowing conditional global copying of molecule with each atom as single argument
|
---|
203 | template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const;
|
---|
204 | template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const;
|
---|
205 | template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const;
|
---|
206 | template <typename res> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () const ) const;
|
---|
207 | template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const;
|
---|
208 | template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const;
|
---|
209 | template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T), T t ) const;
|
---|
210 | template <typename res, typename T> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T) const, T t ) const;
|
---|
211 | template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const;
|
---|
212 | template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const;
|
---|
213 | template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const;
|
---|
214 | template <typename res, typename T, typename U> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const;
|
---|
215 | template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const;
|
---|
216 | template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const;
|
---|
217 | template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const;
|
---|
218 | template <typename res, typename T, typename U, typename V> void ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const;
|
---|
219 |
|
---|
220 | // templates for allowing global manipulation of an array with one entry per atom
|
---|
221 | void SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::* index) const;
|
---|
222 | template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *)) const;
|
---|
223 | template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *), T t) const;
|
---|
224 | template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::* index, void (*Setor)(T *, T *), T *t) const;
|
---|
225 | template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *)) const;
|
---|
226 | template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *), T t) const;
|
---|
227 | template <typename T> void SetIndexedArrayForEachAtomTo ( T *array, int element::* index, void (*Setor)(T *, T *), T *t) const;
|
---|
228 | template <typename T, typename typ> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value) const;
|
---|
229 | template <typename T, typename typ> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value) const;
|
---|
230 | template <typename T, typename typ> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const;
|
---|
231 | template <typename T, typename typ> void SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const;
|
---|
232 |
|
---|
233 | // templates for allowing global manipulation of each atom by entries in an array
|
---|
234 | template <typename T, typename typ, typename typ2> void SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const;
|
---|
235 | template <typename T, typename typ> void SetAtomValueToValue ( T value, T typ::*ptr ) const;
|
---|
236 |
|
---|
237 | template <typename res, typename typ> res SumPerAtom(res (typ::*f)() ) const;
|
---|
238 | template <typename res, typename typ> res SumPerAtom(res (typ::*f)() const ) const;
|
---|
239 | template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) , T t ) const;
|
---|
240 | template <typename res, typename typ, typename T> res SumPerAtom(res (typ::*f)(T) const, T t ) const;
|
---|
241 |
|
---|
242 | /// remove atoms from molecule.
|
---|
243 | bool AddAtom(atom *pointer);
|
---|
244 | bool RemoveAtom(atom *pointer);
|
---|
245 | bool UnlinkAtom(atom *pointer);
|
---|
246 | bool CleanupMolecule();
|
---|
247 |
|
---|
248 | /// Add/remove atoms to/from molecule.
|
---|
249 | atom * AddCopyAtom(atom *pointer);
|
---|
250 | bool AddXYZFile(string filename);
|
---|
251 | bool AddHydrogenReplacementAtom(bond *Bond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem);
|
---|
252 | bond * AddBond(atom *first, atom *second, int degree = 1);
|
---|
253 | bool RemoveBond(bond *pointer);
|
---|
254 | bool RemoveBonds(atom *BondPartner);
|
---|
255 | bool hasBondStructure();
|
---|
256 | unsigned int CountBonds() const;
|
---|
257 |
|
---|
258 | /// Find atoms.
|
---|
259 | atom * FindAtom(int Nr) const;
|
---|
260 | atom * AskAtom(string text);
|
---|
261 |
|
---|
262 | /// Count and change present atoms' coordination.
|
---|
263 | void CountElements();
|
---|
264 | bool CenterInBox();
|
---|
265 | bool BoundInBox();
|
---|
266 | void CenterEdge(Vector *max);
|
---|
267 | void CenterOrigin();
|
---|
268 | void CenterPeriodic();
|
---|
269 | void CenterAtVector(Vector *newcenter);
|
---|
270 | void Translate(const Vector *x);
|
---|
271 | void TranslatePeriodically(const Vector *trans);
|
---|
272 | void Mirror(const Vector *x);
|
---|
273 | void Align(Vector *n);
|
---|
274 | void Scale(const double ** const factor);
|
---|
275 | void DeterminePeriodicCenter(Vector ¢er);
|
---|
276 | Vector * DetermineCenterOfGravity();
|
---|
277 | Vector * DetermineCenterOfAll() const;
|
---|
278 | Vector * DetermineCenterOfBox() const;
|
---|
279 | void SetNameFromFilename(const char *filename);
|
---|
280 | void SetBoxDimension(Vector *dim);
|
---|
281 | void ScanForPeriodicCorrection();
|
---|
282 | bool VerletForceIntegration(char *file, config &configuration, const size_t offset);
|
---|
283 | void Thermostats(config &configuration, double ActualTemp, int Thermostat);
|
---|
284 | void PrincipalAxisSystem(bool DoRotate);
|
---|
285 | double VolumeOfConvexEnvelope(bool IsAngstroem);
|
---|
286 |
|
---|
287 | double ConstrainedPotential(struct EvaluatePotential &Params);
|
---|
288 | double MinimiseConstrainedPotential(atom **&permutation, int startstep, int endstep, bool IsAngstroem);
|
---|
289 | void EvaluateConstrainedForces(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force);
|
---|
290 | bool LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string &prefix, config &configuration, bool MapByIdentity);
|
---|
291 |
|
---|
292 | bool CheckBounds(const Vector *x) const;
|
---|
293 | void GetAlignvector(struct lsq_params * par) const;
|
---|
294 |
|
---|
295 | /// Initialising routines in fragmentation
|
---|
296 | void CreateAdjacencyListFromDbondFile(ifstream *output);
|
---|
297 | void CreateAdjacencyList(double bonddistance, bool IsAngstroem, void (BondGraph::*f)(BondedParticle * const , BondedParticle * const , double &, double &, bool), BondGraph *BG = NULL);
|
---|
298 | int CorrectBondDegree() const;
|
---|
299 | void OutputBondsList() const;
|
---|
300 | void CyclicBondAnalysis() const;
|
---|
301 | void OutputGraphInfoPerAtom() const;
|
---|
302 | void OutputGraphInfoPerBond() const;
|
---|
303 |
|
---|
304 |
|
---|
305 | // Graph analysis
|
---|
306 | MoleculeLeafClass * DepthFirstSearchAnalysis(class StackClass<bond *> *&BackEdgeStack) const;
|
---|
307 | void CyclicStructureAnalysis(class StackClass<bond *> *BackEdgeStack, int *&MinimumRingSize) const;
|
---|
308 | bool PickLocalBackEdges(atom **ListOfLocalAtoms, class StackClass<bond *> *&ReferenceStack, class StackClass<bond *> *&LocalStack) const;
|
---|
309 | bond * FindNextUnused(atom *vertex) const;
|
---|
310 | void SetNextComponentNumber(atom *vertex, int nr) const;
|
---|
311 | void ResetAllBondsToUnused() const;
|
---|
312 | int CountCyclicBonds();
|
---|
313 | bool CheckForConnectedSubgraph(KeySet *Fragment);
|
---|
314 | string GetColor(enum Shading color) const;
|
---|
315 | bond * CopyBond(atom *left, atom *right, bond *CopyBond);
|
---|
316 |
|
---|
317 |
|
---|
318 | molecule *CopyMolecule();
|
---|
319 | molecule* CopyMoleculeFromSubRegion(const Shape&) const;
|
---|
320 |
|
---|
321 | /// Fragment molecule by two different approaches:
|
---|
322 | int FragmentMolecule(int Order, std::string &prefix);
|
---|
323 | bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, std::string path = "");
|
---|
324 | bool StoreBondsToFile(std::string &filename, std::string path = "");
|
---|
325 | bool StoreAdjacencyToFile(std::string &filename, std::string path = "");
|
---|
326 | bool CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms);
|
---|
327 | bool ParseOrderAtSiteFromFile(std::string &path);
|
---|
328 | bool StoreOrderAtSiteFile(std::string &path);
|
---|
329 | bool StoreForcesFile(MoleculeListClass *BondFragments, std::string &path, int *SortIndex);
|
---|
330 | bool CreateMappingLabelsToConfigSequence(int *&SortIndex);
|
---|
331 | bool CreateFatherLookupTable(atom **&LookupTable, int count = 0);
|
---|
332 | void BreadthFirstSearchAdd(molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem);
|
---|
333 | /// -# BOSSANOVA
|
---|
334 | void FragmentBOSSANOVA(Graph *&FragmentList, KeyStack &RootStack, int *MinimumRingSize);
|
---|
335 | int PowerSetGenerator(int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet);
|
---|
336 | bool BuildInducedSubgraph(const molecule *Father);
|
---|
337 | molecule * StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem);
|
---|
338 | void SPFragmentGenerator(struct UniqueFragments *FragmentSearch, int RootDistance, bond **BondsSet, int SetDimension, int SubOrder);
|
---|
339 | int LookForRemovalCandidate(KeySet *&Leaf, int *&ShortestPathList);
|
---|
340 | int GuesstimateFragmentCount(int order);
|
---|
341 |
|
---|
342 | // Recognize doubly appearing molecules in a list of them
|
---|
343 | int * IsEqualToWithinThreshold(molecule *OtherMolecule, double threshold);
|
---|
344 | int * GetFatherSonAtomicMap(molecule *OtherMolecule);
|
---|
345 |
|
---|
346 | // Output routines.
|
---|
347 | bool Output(ofstream * const output);
|
---|
348 | bool OutputTrajectories(ofstream * const output);
|
---|
349 | void OutputListOfBonds() const;
|
---|
350 | bool OutputXYZ(ofstream * const output) const;
|
---|
351 | bool OutputTrajectoriesXYZ(ofstream * const output);
|
---|
352 | bool Checkout(ofstream * const output) const;
|
---|
353 | bool OutputTemperatureFromTrajectories(ofstream * const output, int startstep, int endstep);
|
---|
354 |
|
---|
355 | // Manipulation routines
|
---|
356 | void flipActiveFlag();
|
---|
357 |
|
---|
358 | private:
|
---|
359 | int last_atom; //!< number given to last atom
|
---|
360 | mutable internal_iterator InternalPointer; //!< internal pointer for PointCloud
|
---|
361 | };
|
---|
362 |
|
---|
363 | molecule *NewMolecule();
|
---|
364 | void DeleteMolecule(molecule* mol);
|
---|
365 |
|
---|
366 | #include "molecule_template.hpp"
|
---|
367 |
|
---|
368 | /** A list of \a molecule classes.
|
---|
369 | */
|
---|
370 | class MoleculeListClass : public Observable {
|
---|
371 | public:
|
---|
372 | MoleculeList ListOfMolecules; //!< List of the contained molecules
|
---|
373 | int MaxIndex;
|
---|
374 |
|
---|
375 | MoleculeListClass(World *world);
|
---|
376 | ~MoleculeListClass();
|
---|
377 |
|
---|
378 | bool AddHydrogenCorrection(std::string &path);
|
---|
379 | bool StoreForcesFile(std::string &path, int *SortIndex);
|
---|
380 | void insert(molecule *mol);
|
---|
381 | void erase(molecule *mol);
|
---|
382 | molecule * ReturnIndex(int index);
|
---|
383 | bool OutputConfigForListOfFragments(std::string &prefix, int *SortIndex);
|
---|
384 | int NumberOfActiveMolecules();
|
---|
385 | void Enumerate(ostream *out);
|
---|
386 | void Output(ofstream *out);
|
---|
387 | void DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration);
|
---|
388 | int CountAllAtoms() const;
|
---|
389 |
|
---|
390 | // Methods moved here from the menus
|
---|
391 | // TODO: more refactoring needed on these methods
|
---|
392 | void flipChosen();
|
---|
393 | void createNewMolecule(periodentafel *periode);
|
---|
394 | void loadFromXYZ(periodentafel *periode);
|
---|
395 | void setMoleculeFilename();
|
---|
396 | void parseXYZIntoMolecule();
|
---|
397 | void eraseMolecule();
|
---|
398 |
|
---|
399 |
|
---|
400 | // merging of molecules
|
---|
401 | bool SimpleMerge(molecule *mol, molecule *srcmol);
|
---|
402 | bool SimpleAdd(molecule *mol, molecule *srcmol);
|
---|
403 | bool SimpleMultiMerge(molecule *mol, int *src, int N);
|
---|
404 | bool SimpleMultiAdd(molecule *mol, int *src, int N);
|
---|
405 | bool ScatterMerge(molecule *mol, int *src, int N);
|
---|
406 | bool EmbedMerge(molecule *mol, molecule *srcmol);
|
---|
407 |
|
---|
408 | private:
|
---|
409 | World *world; //!< The world this List belongs to. Needed to avoid deadlocks in the destructor
|
---|
410 | };
|
---|
411 |
|
---|
412 |
|
---|
413 | /** A leaf for a tree of \a molecule class
|
---|
414 | * Wraps molecules in a tree structure
|
---|
415 | */
|
---|
416 | class MoleculeLeafClass {
|
---|
417 | public:
|
---|
418 | molecule *Leaf; //!< molecule of this leaf
|
---|
419 | //MoleculeLeafClass *UpLeaf; //!< Leaf one level up
|
---|
420 | //MoleculeLeafClass *DownLeaf; //!< First leaf one level down
|
---|
421 | MoleculeLeafClass *previous; //!< Previous leaf on this level
|
---|
422 | MoleculeLeafClass *next; //!< Next leaf on this level
|
---|
423 |
|
---|
424 | //MoleculeLeafClass(MoleculeLeafClass *Up, MoleculeLeafClass *Previous);
|
---|
425 | MoleculeLeafClass(MoleculeLeafClass *PreviousLeaf);
|
---|
426 | ~MoleculeLeafClass();
|
---|
427 |
|
---|
428 | bool AddLeaf(molecule *ptr, MoleculeLeafClass *Previous);
|
---|
429 | bool FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList = false);
|
---|
430 | bool FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter);
|
---|
431 | bool AssignKeySetsToFragment(molecule *reference, Graph *KeySetList, atom ***&ListOfLocalAtoms, Graph **&FragmentList, int &FragmentCounter, bool FreeList = false);
|
---|
432 | bool FillListOfLocalAtoms(atom ***&ListOfLocalAtoms, const int FragmentCounter, const int GlobalAtomCount, bool &FreeList);
|
---|
433 | void TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph);
|
---|
434 | int Count() const;
|
---|
435 | };
|
---|
436 |
|
---|
437 |
|
---|
438 | #endif /*MOLECULES_HPP_*/
|
---|
439 |
|
---|