source: pcp/src/data.h@ f70c2a

Last change on this file since f70c2a was e08f45, checked in by Frederik Heber <heber@…>, 17 years ago

Merge branch 'ConcaveHull' of ../espack2 into ConcaveHull

Conflicts:

molecuilder/src/boundary.cpp
molecuilder/src/boundary.hpp
molecuilder/src/builder.cpp
molecuilder/src/linkedcell.cpp
molecuilder/src/linkedcell.hpp
molecuilder/src/vector.cpp
molecuilder/src/vector.hpp
util/src/NanoCreator.c

Basically, this resulted from a lot of conversions two from spaces to one tab, which is my standard indentation. The mess was caused by eclipse auto-indenting. And in espack2:ConcaveHull was the new stuff, so all from ConcaveHull was replaced in case of doubt.
Additionally, vector had ofstream << operator instead ostream << ...

  • Property mode set to 100755
File size: 41.6 KB
Line 
1#ifndef data_h
2#define data_h
3
4/** \file data.h
5 * Defines most of the important data structures.
6 * Such as structures containing command line options CallOptions, densities Density, energies Energy,
7 * lattice information Lattice and levelwise LatticeLevel, for all wave functions Psis downto one Psi
8 * OnePsiElement and OnePsiElementAddData, wave functions on the lattice level LevelPsi, the reciprocal
9 * grid vector OneGData, filenames and paths FileData oder super structures containing the whole Problem
10 * or data for the parallelisation ParallelSimulationData and the fft plans RPlans.
11 *
12 Project: ParallelCarParrinello
13 Jan Hamaekers
14 2000
15
16 File: data.h
17 $Id: data.h,v 1.102 2007-02-09 09:13:48 foo Exp $
18*/
19
20#ifdef HAVE_CONFIG_H
21#include <config.h>
22#endif
23
24#include "mpi.h"
25
26// use double precision fft when we have it
27#ifdef HAVE_DFFTW_H
28#include "dfftw.h"
29#else
30#include "fftw.h"
31#endif
32
33#include "defs.h"
34#include <signal.h>
35/*extern volatile sig_atomic_t cpulim;*/
36#define PROCDIM (2) //!< specifying the number in \ref ParallelDivideDims
37#define MaxOutGroup 7 //!< specifying the number in \ref OutGroup
38//! various verbose output groups, individually associable with levels (LeaderOut = process 0,...)
39enum OutGroup { MinOut, //!< minimum output
40 NormalOut, //!< normal output
41 ValueOut, //!< output of calculated value
42 LeaderOut, //!< output of process 0
43 ReadOut, //!< output of parsed values
44 PsiOut, //!< output of Psi-related numbers
45 StepLeaderOut //!< output of minimsation step and NIDensity
46 };
47//! enumerating output verbosity levels
48enum OutType { OutNone, //!< no -v specified (no output)
49 OutNormal, //!< -v (status information, minimum output, some calculate values)
50 OutNormalP, //!< -vv (status information, minimum output, more calculated values)
51 OutMore, //!< -vvv (steady output while minimising)
52 OutMoreP, //!< -vvvv (all processes)
53 OutAll, //!< not used
54 OutAllP //!< not used
55 };
56
57//! enumerating whether to parse source coefficients from file
58enum ParseSrcDensities { DoNotParse,
59 DoReadAllSrcDensities,
60 DoReadOccupiedSrcDensities,
61 DoReadAndMinimise
62};
63
64//! enumerating usage status
65enum UseType { NotInUse, //!< is not in use
66 InUse //!< is in use
67 };
68//! enumerating the two groups in parallel divide&conquer strategy
69enum ParallelDivideDims { PEGamma, //!< process in Psi group among coefficients are shared
70 PEPsi //!< process groups among wave functions are shared
71 };
72//! enumerating RiemannTensor usage
73enum UseRiemannTensor { UseNotRT, //!< don't use RiemannTensor calculus
74 UseRT //!< use RiemannTensor calculus
75 };
76//! enumerating how to deal with spin
77enum UseSpinType { UseSpinDouble, //!< Spin is always double in each orbit (occupation number is 2)
78 UseSpinUpDown //!< Treat each orbit differently for its SpinType#SpinUp and SpinType#SpinDown part
79 };
80//! SpinType is separated Up and Down or combined Double
81enum SpinType { SpinDouble, //!< Type is double, orbits always fully occupied
82 SpinUp, //!< Type of orbit spin is up
83 SpinDown //!< Type of orbit spin is down
84 }; /*!< Double == 0 !!! */
85#define MaxDensityTypes 22 //!< number of different densities
86#define MaxInitDensityTypes 13 //!< cardinal number of density up to which all before need to be reseted in InitDensityCalculation()
87//! enumerating the various density types
88enum DensityTypes { ActualDensity, //!< current density (in calculation)
89 TotalDensity, //!< total density over all processes
90 TotalLocalDensity, //!< total density stored in this process
91 TotalUpDensity, //!< total density with spin up over all processes
92 TotalDownDensity, //!< total density with spin down over all processes
93 CoreWaveDensity, //!< density of the wave functions in the core range, see PseudoPot
94 HGcDensity, //!< sum of gaussian and local PseudoPot'ential density
95 GapDensity, //!< density of the all "unoccupied" additional wave functions
96 GapUpDensity, //!< density of the all "unoccupied" additional wave functions
97 GapDownDensity, //!< density of the all "unoccupied" additional wave functions
98 GapLocalDensity, //!< density of the "unoccupied" additional wave functions stored in this process
99 TempDensity, //!< temporal working array, used mostly in fft transforms
100 Temp2Density, //!< another temporal working array
101 CurrentDensity0, //!< current density[0][0] = d/dB_0 current[0]
102 CurrentDensity1, //!< current density[1][0] = d/dB_0 current[1]
103 CurrentDensity2, //!< current density[2][0] = d/dB_0 current[2]
104 CurrentDensity3, //!< current density[0][1] = d/dB_1 current[0]
105 CurrentDensity4, //!< current density[1][1] = d/dB_1 current[1]
106 CurrentDensity5, //!< current density[2][1] = d/dB_1 current[2]
107 CurrentDensity6, //!< current density[0][2] = d/dB_2 current[0]
108 CurrentDensity7, //!< current density[1][2] = d/dB_2 current[1]
109 CurrentDensity8 //!< current density[2][2] = d/dB_2 current[2]
110 };
111/*! enumerating density types which differ for DensityArray and DensityCArray, as follows:
112 CoreWave only DensityArray (real)
113 ActualPsiDensity only DensityCArray (complex)
114 HGcDensity only DensityArray (real)
115 HGDensity only DensityCArray (complex)
116 */
117
118enum DoubleDensityTypes { HGDensity=HGcDensity, //!< the local potential \f$V^H (G) + V^{ps,loc} (G)\f$
119 ActualPsiDensity=CoreWaveDensity //!< the local psi coefficients
120 };
121#define MaxPsiNoType 7 //!< maximum number of different wave function types
122//! enumerating Psi numbering type
123enum PsiNoType { PsiMaxNo, //!< maximum number of wave functions
124 PsiMaxNoDouble, //!< maximum number of wave functions in SpinType#SpinDouble case
125 PsiMaxNoUp, //!< maximum number of wave functions with spin up
126 PsiMaxNoDown, //!< maximum number of wave functions with spin down
127 PsiMaxAdd //!< number of additional (unoccupied) wave functions helpful in improving the minimisation
128 };
129//! Enumerating different G vector types, due to the gamma point symmetry! (mirroring of Gs)
130enum DoubleGType { DoubleGNot, //!< not a reciprocal grid vector on (z=0)-plane (no symmetry can be utilized)
131 DoubleG0, //!< is the (0,0,0) reciprocal grid vector
132 DoubleGUse, //!< reciprocal grid vector which resides on the (z=0)-plane in the first and third sector and thus has symmetry \f$c_{i,G}^\ast = -c_{i,-G}\f$
133 DoubleGNotUse //!< reciprocal grid vector which resides on the (z=0)-plane in the second and fourth sector
134 };
135//! Enumerating states of the current GramSchmidt-Orthonormalization of a wave function
136enum PsiGramSchStatusType { NotOrthogonal, //!< is not yet orthogonalized
137 IsOrthogonal, //!< is orthohonal yet not normalized
138 IsOrthonormal, //!< is orthonormal
139 NotUsedToOrtho //!< not touched during GramSch()
140 };
141//! Enumerating what remains to do for this wave function
142enum PsiGramSchToDoType { Orthonormalize, //!< must still be orthogonalized and normalized
143 Orthogonalize //!< must still be normalized
144 };
145
146//! Enumerating the ToDo status for this wave function
147enum MinimisationStatusType { Minimalise, //!< wave function ought to be minimalized
148 DoNotMinimalise, //!< wave function is used to evaluate however not itself minimised
149 NotUsedToMinimalise //!< ignore this wave function completely during minimisation
150 };
151
152// Specifying the cast type to be read of a parameter, see ParseForParameter()
153enum value_type { string_type, double_type, int_type, row_int, row_double, grid, lower_trigrid, upper_trigrid};
154
155// Specifting whether a value in the parameter file must be specified or is optional
156enum necessity { optional, //!< parameter is optional, if not given sensible value is chosen
157 critical //!< parameter must be given or programme won't initiate
158 };
159
160
161#define perturbations 6
162
163//! Enumerating the Type of this wave function
164enum PsiTypeTag { Occupied, //!< normal occupied wave function
165 UnOccupied, //!< additional unoccupied wave function foor gap energy
166 Perturbed_P0, //!< perturbed wave function \f$|\varphi^{(p_0)}\rangle\f$ used to evaluate current density
167 Perturbed_P1, //!< perturbed wave function \f$|\varphi^{(p_1)}\rangle\f$ used to evaluate current density
168 Perturbed_P2, //!< perturbed wave function \f$|\varphi^{(p_2)}\rangle\f$ used to evaluate current density
169 Perturbed_RxP0, //!< perturbed wave function \f$|\varphi^{(r\times p)_0}\rangle\f$ used to evaluate current density
170 Perturbed_RxP1, //!< perturbed wave function \f$|\varphi^{(r\times p)_1}\rangle\f$ used to evaluate current density
171 Perturbed_RxP2, //!< perturbed wave function \f$|\varphi^{(r\times p)_2}\rangle\f$ used to evaluate current density
172 Extra //!< extra wave function (used for gradient calculation)
173 };
174
175//! Enumerating whether this is active or not (such as motion of ions, use of RiemannTensor, ...)
176enum ModeType { inactive, //!< generally deactivated
177 active, //!< activated
178 standby //!< temporarily deactivated
179 };
180/* MPI Tags */
181#define GramSchTag1 100 //!< Message consists of wave function coefficients needed during the Orthogonalization in GramSch()
182#define GramSchTag2 101 //!< Message consists of orthogonal projections calculated during the Orthogonalization in GramSch()
183#define GramSchTag3 102 //!< Message consists of wave function coefficients during Testing in TestGramSch()
184#define InterTag1 110
185#define DensityTag1 120 //!< Message on exchange of complex TotalUpDensity, see InitDensityCalculation()
186#define DensityTag2 121 //!< Message on exchange of complex TotalDownDensity, see InitDensityCalculation()
187#define DensityTag3 122 //!< Message on exchange of TotalUpDensity, see InitDensityCalculation()
188#define DensityTag4 123 //!< Message on exchange of TotalDownDensity, see InitDensityCalculation()
189#define DensityTag5 124 //!< Message on exchange of NIUpDensity, see InitDensityCalculation()
190#define DensityTag6 125 //!< Message on exchange of NIDownDensity, see InitDensityCalculation()
191#define DensityTag7 126 //!< Message on exchange of complex GapUpDensity, see InitDensityCalculation()
192#define DensityTag8 127 //!< Message on exchange of complex GapDownDensity, see InitDensityCalculation()
193#define DensityTag9 128 //!< Message on exchange of GapUpDensity, see InitDensityCalculation()
194#define DensityTag0 129 //!< Message on exchange of GapDownDensity, see InitDensityCalculation()
195#define OutputDensTag 140 //!< Message consists of FileData::work being sent to process 0 on output of visual data, see OutputOutVisDensity()
196#define ReadSrcPsiTag 141 //!< Used during reading and send/recv of psi coefficients in ReadSrcPsiDensity()
197#define OutputSrcPsiTag 142 //!< Message consists of Density::DensityArray[TempDensity] being sent to process 0 on output of source Psis (saving of current state), see OutputSrcPsiDensity()
198#define ParseWannierTag 143 //!< Used during send/recv of wannier centres and spread in ParseWannierFile()
199#define PlotRealDensityTag 145 //!< 4 doubles exchanged during PlotRealDensity() storing to file
200#define AllMaxLocalNoTag1 150
201#define AllMaxLocalNoTag2 151
202#define HamiltonianTag 160 //!< Message consists of orbit coefficients sent/received during the setup of the hamiltonian matrix
203#define HamiltonianTag2 161 //!< Message consists of orbit coefficients sent/received during the setup of the hamiltonian matrix
204#define WannierTag1 170 //!< Message consists of orbital coefficients sent/received during iteration of wannier functions
205#define WannierTag2 171 //!< Message consists of orbital coefficients sent/received during application of transformation matrix
206#define WannierTag3 172 //!< Message consists of matrix elements A_ij sent/received during evaluating of operator matrices
207#define WannierTag4 173 //!< Message consists of matrix elements B_ij sent/received during evaluating of operator matrices
208#define WannierTag5 174 //!< Message consists of wannier centres and spread sent/received during ChangeWannierCentres()
209#define OtherPsiTag1 180 //!< Message consists of OnePsiElement data from the Spinype#SpinUp group
210#define OtherPsiTag2 181 //!< Message consists of OnePsiElement data from the Spinype#SpinDown group
211#define StopTag1 190 //!< Message consists of stop flag from the Spinype#SpinUp group
212#define StopTag2 191 //!< Message consists of stop flag from the Spinype#SpinDown group
213#define EnergyTag1 200 //!< Message consists of Energy#AllUpPsiEnergy during EnergyAllReduce()
214#define EnergyTag2 201 //!< Message consists of Energy#AllDownPsiEnergy during EnergyAllReduce()
215#define EnergyTag3 203
216#define EnergyTag4 204
217#define EnergyTag5 205 //!< Message consists of partial Energy#TotalEnergy results, sent during EnergyAllReduce()
218#define EnergyTag6 206 //!< Message consists of partial Energy#TotalEnergy results, sent during EnergyAllReduce()
219#define OverlapTag 210 //!< Message consists of wave function coefficients sent during CalculatePerturbedOverlap()
220#define PerturbedTag 211 //!< Message consists of wave function coefficients sent during Calculate1stPerturbedDerivative()
221#define CurrentTag1 221 //!< Message consists of current density SpinType#SpinUp components sent during CalculateForce()
222#define CurrentTag2 222 //!< Message consists of current density Spinype#SpinDown components sent during CalculateForce()
223#define WannierCTag 230 //!< Wannier rotation exchange
224#define WannierSTag 231 //!< Wannier rotation exchange
225#define WannierALTag 240 //!< Wannier index exchange
226#define WannierARTag 241 //!< Wannier index exchange
227
228
229/** Options from command line.
230 * This structure is generally filled with options from the command
231 * line, scanned by \ref GetOptions()
232 */
233struct CallOptions {
234 char* MainParameterFile; //!< main parameter file
235 char* ForcesFile; //!< ForcesFile: is NULL if we don't parse forces from file and solve the ground state problem, otherwise don't solve and parse
236 int debug; //!< (1) debug, (2) debug on errors
237 int nicelevel; //!< nice level for executable
238 int Out; //!< verbosity level
239 int out[MaxOutGroup]; //!< print stderr-msg? for each group -v
240 unsigned int alarm; //!< set alarm after alarm seconds
241 int proc[PROCDIM]; //!< process per gamma point, process per wave fct
242 enum ParseSrcDensities ReadSrcFiles; //!< whether to parse source coefficients from file or use minimisation
243 int WriteSrcFiles; //!< 0 - don't, 1 - write source file on exit with so far made calculations
244 int AddNFactor; //!< ugly hack to fix read srcpsi
245};
246
247/** Structure containing file names and paths.
248 * mainname, mainpath, path to config file, but also integers stating
249 * whether outputfile (visual, measures) should be written and their
250 * respective output file pointers
251 */
252struct FileData {
253 char *mainname; //!< full name of programme including path
254 char *filename; //!< name of programme
255 char *mainpath; //!< full path to programme
256 char *default_path; //!< path to default parameter file
257 char *pseudopot_path; //!< path ot pseudopotential files
258 int *OutVisStep; //!< Currently so and so often has visual data output occurred
259 int MeOutVis; //!< 1 - visual data are written to files, 0 - no output (for this process)
260 int MeOutCurr; //!< 1 - visual data of current density written to file, 0 - no output, no calculation (for this process)
261 int MeOutMes; //!< 1 - energy, forces and temperatures are written to files, 0 - no output (for this process)
262 FILE *ForcesFile; //!< where the forces are written to
263 FILE *EnergyFile; //!< where the energies are written to
264 FILE *SpeedFile; //!< where the timing are written to
265 FILE *HamiltonianFile;//!< where the explicit hamiltonian is written to (for retrieving Kohn-Sham-Eigenvalues)
266 FILE *SpreadFile; //!< where spread and wannier centers for each orbital are written to
267 FILE *ReciSpreadFile; //!< where reciprocal spread for each orbital is written to
268 FILE *MinimisationFile; //!< where TE, ATE, delta and various other elements from each minimisation steps are written to
269 FILE *TemperatureFile;//!< where the temperatures are written to
270 /* Arrays */
271 int TotalSize; //!< total number of coefficients (nodes) on all processes
272 int LocalSizeR; //!< local (total) number of real nodes, twice FileData::LocalSizeC
273 int LocalSizeC; //!< local (total) number of real nodes
274 int MaxNUp;
275 fftw_complex *PosC; //!< complex coefficients array for the output of densities
276 fftw_complex *PosTemp;
277 fftw_complex *PosFactor;
278 fftw_complex *work; //!< working coefficients array for the output of densities
279 fftw_real *PosR; //!< real coefficients array for the output of densities
280 enum ModeType *OutputPosType; //!< active - RiemannTensor is used, nonactive/standby - not
281 int DoOutVis; //!< 1 - visual data are written to files, 0 - no output (generally)
282 int DoOutMes; //!< 1 - energy and forces are written to files, 0 - no output (generally)
283 int DoOutCurr; //!< 1 - visual data of current density written to file, 0 - no output, no calculation
284 int DoOutNICS; //!< 1 - visual data of nuclear induced current shieldings written to file, 0 - no output, no calculation
285 int DoOutOrbitals; //!< 1 - output each orbital density, 0 - just total density
286};
287
288/** Structure containing info for MPI interface.
289 * Such as process number, various communicators (interfacing groups in MPI), TID.
290 * Always it's my (of this current process) process number within the group, within
291 * the communicator, etc.
292 */
293struct ParallelSimulationData {
294 int procs; //!< overall number of processes
295 int proc[PROCDIM]; //!< number of processes per gamma point and per wave function
296 int mypos[PROCDIM]; //!< I am the mypos-th process with the per gamma point or per wave function group
297 int me; //!< my process id among all
298 int mytid; //!< My TID
299 int partid; //!< Parent TID
300
301 MPI_Comm world; //!< Group: MPI_COMM_WORLD (including maybe callers)
302 MPI_Comm comm; //!< Group: all participating processe on this Problem at hand
303
304 MPI_Comm comm_ST; //!< Communicator for SpinDouble or SpinUpDown, thus either the whold world of one half of the world
305 int me_comm_ST; //!< my number within this communicator (going from 0 to Max_me_comm_ST-1)
306 int my_color_comm_ST; //!< either just 0 color(SpinDouble) or 0,1 (SpinUp - SpinDown)
307 int Max_me_comm_ST; //!< maximum number of processes in this SinUp/Down communicator, full number of total processes in SpinDouble, half the number in SpinUpDown
308 int Max_my_color_comm_ST; //!< maximum number regarding color (either 1 for SpinDouble or 2 for SpinUpDown)
309
310 MPI_Comm comm_STInter; //!< InterComm needed for SpinUp/Down case
311
312 MPI_Comm comm_ST_Psi; //!< SubComm for comm_ST Communicator Psi, these refer to the same wave function, sharing its coefficients on both grids
313 int me_comm_ST_Psi; //!< my number within this communicator
314 int my_color_comm_ST_Psi; //!< my number, either just one color(SpinDouble) or two (SpinUp - SpinDown)
315 int Max_me_comm_ST_Psi; //!< maximum number of processes in this Psi communicator
316 int Max_my_color_comm_ST_Psi; //!< ??? maximum number regarding color (one or two)
317
318 MPI_Comm comm_ST_PsiT; //!< SubComm of comm_ST Communicator of processes that need to exchange wave funcions (GramSch())
319 int me_comm_ST_PsiT; //!< Transposed of comm_ST_Psi
320 int my_color_comm_ST_PsiT; //!< either just one color(SpinDouble) or two (SpinUp - SpinDown)
321 int Max_me_comm_ST_PsiT; //!< maximum number of processes in this GramSch communicator
322 int Max_my_color_comm_ST_PsiT;//!< ??? maximum number regarding color (one or two)
323};
324
325struct RPlans {
326 struct LevelPlan *plan;
327 fftw_complex *cdata;
328 fftw_real *rdata;
329};
330
331/** one reciprocal grid vector G.
332 */
333struct OneGData {
334 int Index; //!< index is needed to access elements in the upper Lev0, when densities are stored in reciprocal base, Density#DensityCArray
335 int GlobalIndex;
336 double GSq; //!< squared norm of G vector
337 double G[NDIM]; //!< integer cooefficients of reciprocal vector
338};
339
340struct GDataHash {
341 int i; //!< index running over each GArray from process zero to max.
342 int myPE; //!< to which process does it belong
343};
344
345/** Structure for the Psis per LatticeLevel.
346 */
347struct LevelPsi {
348 fftw_complex **LocalPsi; //!< are the current complex coefficients of Psis, stored locally in this process (OnePsiElement::LocalNo), initialised by PsiDat, used for orthonormlization of non-Psis
349 fftw_complex **OldLocalPsi;//!< are the old complex coefficients of Psis, stored locally in this process (OnePsiElement::LocalNo), initialised by OldPsiDat. Needed to UpdateWavesAfterIonMove() and ComputeMLWF()
350 fftw_complex *PsiDat; //!< contains the initial complex coefficients of all wave functions (even temporary ones)
351 fftw_complex *OldPsiDat; //!< contains the old complex coefficients of all wave functions (even temporary ones)
352 fftw_complex *TempPsi; //!< temporal array used in GramSch(), size of LatticeLevel:MaxG, always the Psi to be orthogonalized
353 fftw_complex *TempPsi2; //!< pointer to a Psi used in GramSch(), always the Psi already orthogonalized
354};
355
356/** Structure containing one wave function.
357 */
358struct OnePsiElement {
359 int me_comm_ST_Psi; //!< this wave function belongs to this process in the communicator Psi
360 int my_color_comm_ST_Psi; //!< this wave function belongs to this process in the communicator PsiT
361 int MyLocalNo; //!< continuing number among the Psis that are local to this process
362 int MyGlobalNo; //!< continuing global number among all Psis
363 int/*enum PsiGramSchStatusType*/ PsiGramSchStatus; //!< Status of how far the Gram-Schmidt-Orthonormalization has gone yet for this Psi
364 enum MinimisationStatusType MinimisationStatus; //!< Status of how far the Gram-Schmidt-Orthonormalization has gone yet for this Psi
365 enum PsiTypeTag PsiType; //!< what type of wave function: normal (occupied), extra (gradient) or unoccupied Psi
366 double PsiFactor; //!< occupation number, hard-coded (2.0 in SpinDouble case or 1.0 in SpinUpDown case)
367 double PsiReciNorm2; //!< reciprocal norm of Psi being the Sum over all reciprocal grid vectors.
368 int DoBrent; //!< signals switching to brent iteration in line search
369};
370
371/** Additional Data to a wave function OnePsiElement.
372 * Contains energy, kinetic eigenvalues, performed minimalization steps.
373 */
374struct OnePsiElementAddData {
375 double Lambda; //!< energy eigenvalue \f$\lambda_i = \langle \psi_i^{(m)}|H|\psi_i^{(m)} \rangle\f$
376 double T; //!< kinetic eigenvalue \f$\langle \psi_i | \ \frac{1}{2} \nabla^2 | psi_i \rangle\f$
377 double Gamma; //!< scalar product between the gradient of the wave function and the preconditioned one at this \ref Step
378 int Step; //!< holds count of currently made minimalization steps
379 double WannierCentre[NDIM]; //!< NDIM coordinates of wannier centre of this orbital
380 double WannierSpread; //!< current spread of this orbital
381};
382
383
384/** Structure about all wave functions a.k.a orbits.
385 * Containing variables such as SpinType, LocalNo, PsiGroup, OnePsiElement array and
386 * various densities.
387 */
388struct Psis {
389 enum UseSpinType Use; //!< Use Spin Up/Down or not (Double)
390 enum SpinType PsiST; //!< Spin Type: Up, Down or Double
391 int GlobalNo[MaxPsiNoType];//!< global number of Psis for the four plus one cases: Max, MaxDouble, MaxUp, MaxDown, MaxAdd
392 int LocalNo; //!< number of occupied and unoccupied Psis that are local (ly accessible) in this process
393 int LocalNoAdd; //!< number of unoccupied Psis that are local (ly accessible) in this process (spinup/-down or double)
394 int NoOfPsis; //!< contains SpinType-dependent sum of GlobalNo, giving number of wave functions in the current minimisation group (except for PsiTypeTag#UnOccupied of course)
395 int NoOfTotalPsis; //!< contains SpinType-dependent sum of GlobalNo with added PsiTypeTag#UnOccupied states
396 int TypeStartIndex[Extra+2];//!< index array where the respective PsiTypeTag type starts in LocalPsiStatus
397 int AllMaxLocalNo; //!< maximum local number of Psis on one process (some processes have one more due to modulo != 0 on sharing)
398 int MaxPsiGroup; //!< number of processes among which the Psis are divided
399 int PsiGroup; //!< rank of this process in the communicator ParallelSimulationData::comm_ST_Psi
400 int MaxPsiOfType; //!< overall number of Psis
401 int *AllLocalNo; //!< array over all processes in the GramSch() communicator ParallelSimulationData::comm_ST_PsiT containing their number of local Psis, AllLocalNo[i] = RealAllLocalNo[i] + 1
402 int *RealAllLocalNo; //!< array over all processes in the GramSch() communicator ParallelSimulationData::comm_ST_PsiT containing their number of local Psis, i-th process: Psi->LocalNo = RealAllLocalNo[i]
403 int MyStartNo; //!< at which Psis do the locally accessible of this process start (going to MyStartNo+LocalNo)
404 struct OnePsiElement *AllPsiStatus; //!< array over all PsiTypeTag's of all wave functions, yet without coefficients (see Psis::LocalPsiStatus)
405 struct OnePsiElement *AllPsiStatusForSort; //!< temporary array of same size as *AllPsiStatus, only used in naturalmergesort()
406 struct OnePsiElement *LocalPsiStatus; //!< array over all PsiTypeTag's of the local wave functions which are accessible to/stored in this process
407 int *TempSendA; //!< In GramSch(): Holds count to which process in GramSch group a local wave function has been sent
408 double NIDensity[Extra]; //!< Density over all
409 double NIDensityUp[Extra]; //!< Density of SpinUp
410 double NIDensityDown[Extra]; //!< Density of SpinDown
411 int *AllActualLocalPsiNo;
412 int *AllOldActualLocalPsiNo;
413 struct OnePsiElementAddData *AddData; //!< some additional local data, such as energy eigenvalue
414 double **lambda; //!< contains \f$\lambda_{kl} = \langle \varphi_k^{(0)} | H^{(0)} | \varphi_l^{(0)} \rangle\f$, sa CalculateHamiltonian()
415 double **Overlap; //!< contains \f$S_{kl} = \langle \varphi_k^{(1)} | \varphi_l^{(1)} \rangle\f$, sa CalculatePerturbedOverlap()
416};
417
418/** Structure containing the various (radially discretized) densities.
419 * Densities are always calculated on one level higher than the respective wave functions as the fftransformation then
420 * becomes exact (fourier basis).
421 */
422struct Density {
423 int TotalSize; // total number of nodes
424 int LocalSizeC; // number of nodes in radial mesh of the complex density (locally accessible)
425 int LocalSizeR; // number of nodes in radial mesh of the density (locally accessible)
426 enum UseType DensityTypeUse[MaxDensityTypes]; //!< Density is used or not (e.g. Up/Down not used in SpinType::SpinDouble case)
427 fftw_real *DensityArray[MaxDensityTypes]; //!< density array (wave functions summed and squared, R-dependent) (radially discretized), \sa CalculateOneDensityR()
428 fftw_complex *DensityCArray[MaxDensityTypes]; //!< density array (wave functions summed and squared, G-dependent), \sa CalculateOneDensityC()
429 enum UseType LockArray[MaxDensityTypes]; //!< 1 - real density array is currently in use, 0 - array may be locked for sole
430 enum UseType LockCArray[MaxDensityTypes]; //!< 1 - complex density array is currently in use, 0 - array may be locked for sole
431};
432
433enum complex {
434 real, //!< number is real
435 imag //!< number is complex
436 };
437/** Structure containing one lattice level.
438 * Containing Level number LevelNo, maximum grid mesh points normal MaxN and reciprocal MaxG, factors
439 * between this one and upper levels, array of the grid vectors GArray, wave function on this level
440 * LPsi and densities Dens.
441 */
442struct LatticeLevel {
443 int LevelNo; //!< current number of this level
444 int MaxN; //!< number of grid points
445 int N[NDIM]; //!< number of grid points for this level in each dimension NDIM
446 int NUp[NDIM]; //!< ratio of number of mesh points between this and the upper level for each dimension NDIM
447 int NUp0[NDIM]; //!< ratio of number of mesh points this and the 0th level for each dimension NDIM
448 int NUp1[NDIM]; //!< ratio of number of mesh points and the first level for each dimension NDIM
449 int MaxNUp; //!< ratio of grid points between this and the upper level overall (all dimensions together)
450 int MaxG; //!< number of reciprocal grid vectors
451 int MaxDoubleG; //!< number of reciprocal grid vectors which are double by gamma point symmetry (only one is stored)
452 int *AllMaxG; //!< number of reciprocal grid vectors for each process
453 int TotalAllMaxG; //!< number of reciprocal grid (complex) vectors for all process
454 int TotalRealAllMaxG; //!< number of reciprocal grid (real) vectors for all process
455 double ECut; //!< Cutoff energy (discretizes possible reciprocal vectors), here: maximum norm of reciprocal grid vector
456 struct RPlans Plan0;
457 struct OneGData *GArray; //!< Array of reciprocal grid vectors
458 struct GDataHash *HashG; //!< Hash-array with global index for each G
459 int *DoubleG; //!< Array of indices of the doubly appearing grid vectors, with twice entries per vector: normal index and the inverse index (-x,-y,-z)
460 int G0; //!< OneGData::Index of the reciprocal grid vector with zero components
461 fftw_complex *PosFactorUp; //!< precalculated position factor \f$P_p(G) \f$when going from wave coefficients to density, huge array of \ref MaxNUp times \ref MaxG, see CreatePosFacForG()
462 struct LevelPsi *LPsi;
463 struct Density *Dens; //!< Density on this level
464 int Step; //!< holds count of Molecular Dynamics steps
465};
466
467
468//! List of NField types, for this level, for the upper level
469//! Enumerating entries in nFields for current and upper level
470enum FFTNFields { FFTNF1, //!< Number of nFields in current level
471 FFTNFUp //!< Number of nFields in upper level
472 };
473enum FFTNFieldsS { FFTNFSVecUp=2,
474 FFTNFSVec
475 };
476enum FFTNFieldsR { FFTNFRMatUp0=2,
477 FFTNFRMatVecUpS,
478 FFTNFRVecUp0
479 };
480enum FFTNFields0 { FFTNF0Vec=1
481 };
482
483#define MAXRTPOSFAC 2 //!< maximum number of different RiemannTensor position factors
484//! Enumerating to which level the position factor relates
485enum RTPosFacType { RTPFRtoS, //!< position factor is relative to STANDARDLEVEL
486 RTPFRto0 //!< position factor is relative to topmost level
487 };
488
489#define MAXRTARRAYS 8 //!< maximum number of different RiemannTensor arrays
490//! Enumerating different RiemannTensor arrays
491enum RTArrayType { RTADetPreRT,
492 RTAPreA,
493 RTAA,
494 RTAIRT,
495 RTARTA,
496 RTAARTA,
497 RTAiGcg,
498 RTAcg
499 };
500
501struct RiemannTensor {
502 int RiemannLevel;
503 int NUpLevRS[NDIM];
504 int NUpLevR0[NDIM];
505 enum UseRiemannTensor Use;
506 enum ModeType ActualUse;
507 fftw_complex *Coeff;
508 struct LatticeLevel *LevR; /* RiemannLevel */
509 struct LatticeLevel *LevS; /* StandartLevel */
510 struct LatticeLevel *Lev0; /* 0 Level */
511 int MaxNUp[MAXRTPOSFAC];
512 int TotalSize[MAXRTARRAYS];
513 int LocalSizeC[MAXRTARRAYS];
514 int LocalSizeR[MAXRTARRAYS];
515 int NFields[MAXRTARRAYS];
516 fftw_complex *PosFactor[MAXRTPOSFAC];
517 fftw_complex *DensityC[MAXRTARRAYS];
518 fftw_real *DensityR[MAXRTARRAYS];
519 fftw_complex *RTLaplaceS;
520 fftw_complex *RTLaplace0;
521 fftw_complex *TempC;
522 size_t TempTotalSize;
523};
524
525#define MAXALLPSIENERGY 4 //!< number of different wave function energies
526
527//! Enumerating energy types of wave function
528enum AllPsiEnergyTypes { KineticEnergy, //!< kinetic energy
529 NonLocalEnergy, //!< non-local pseudo potential energy
530 Perturbed1_0Energy, //!< \f$\langle \varphi_l^{(1)} | H^{(1)} | \varphi_l^{(0)} \rangle \f$
531 Perturbed0_1Energy //!< \f$\langle \varphi_l^{(0)} | H^{(1)} | \varphi_l^{(1)} \rangle \f$
532 };
533#define MAXALLDENSITYENERGY 6 //!< number of different density energies
534//! Enumerating density energy types
535enum AllDensityEnergyTypes { CorrelationEnergy, //!< correlation energy \f$E_C\f$
536 ExchangeEnergy, //!< exchange energy \f$E_X\f$
537 GaussEnergy, //!< gaussian energy \f$E_{gauss}\f$
538 PseudoEnergy, //!< pseudopotential energy \f$E_{ps}\f$
539 HartreePotentialEnergy, //!< Hartree potential energy including gaussian density \f$E_H\f$
540 HartreeEnergy //!< Hartree energy \f$E_H\f$
541 };
542#define MAXALLIONSENERGY 2 //!< number of different ion energies
543//! Enumerating different ion energy types
544enum AllIonsEnergyTypes { GaussSelfEnergy, //!< Gaussian self energy due to charge
545 EwaldEnergy //!< core to core energy summed over all super cells by ewald summation
546 };
547#define MAXOLD 2 //!< how many older calculated values are archived in various arrays
548
549/** Energy structure.
550 * Contains Total and local (i.e. within one process) energies of the
551 * three classes: wave function, density and ion, also the first and
552 * second time derivative, dating back to MAXOLD
553 */
554struct Energy {
555 double AllTotalPsiEnergy[MAXALLPSIENERGY]; //!< Total energy in SpinType#SpinDouble case
556 double AllLocalPsiEnergy[MAXALLPSIENERGY]; //!< Calculated energies of the local process, summed up via MPI_Allreduce to Energy::AllUpPsiEnergy, Energy::AllDownPsiEnergy or Energy::AllTotalPsiEnergy respectively
557 double AllUpPsiEnergy[MAXALLPSIENERGY]; //!< Total energy in SpinType#SpinUp case
558 double AllDownPsiEnergy[MAXALLPSIENERGY]; //!< Total energy in SpinType#SpinDown case
559 double *PsiEnergy[MAXALLPSIENERGY];
560 double AllLocalDensityEnergy[MAXALLDENSITYENERGY]; //!< local total energy of electron density within one process
561 double AllTotalDensityEnergy[MAXALLDENSITYENERGY]; //!< Total energy resulting from electron density
562 double AllTotalIonsEnergy[MAXALLIONSENERGY]; //!< Total energy of the Ions, Ewald and gaussian
563 double TotalEnergy[MAXOLD]; //!< Total energy as the sum of AllTotalPsiEnergy, AllTotalDensityEnergy and AllTotalIonsEnergy
564 double TotalEnergyOuter[MAXOLD];
565 double TotalEnergyFixed[MAXOLD];
566 double delta[MAXOLD];
567 double dEdt0[MAXOLD];
568 double ddEddt0[MAXOLD];
569 double ATE[MAXOLD];
570 double parts[3];
571 double bandgap;
572 //double homolumo;
573};
574
575/** Lattice structure.
576 * containing real, inverted, reciprocal basis (squared and/or orthonormal), Volume,
577 * ECut, LatticeLevel structure, Psis structure , the fft_plan_3d structure and
578 * Energy structure
579 */
580struct Lattice {
581 double RealBasis[NDIM_NDIM]; //!< Coefficients of the basis vectors
582 double RealBasisSQ[NDIM]; //!< squared Norm of each basis vector
583 double RealBasisCenter[NDIM]; //!< center of the unit cell ((0.5,0.5,0.5) transformed by RealBasis)
584 double InvBasis[NDIM_NDIM]; //!< Matrix-wise inverted basis vectors
585 double ReciBasis[NDIM_NDIM]; //!< Coefficients of the transposed(!), inverse basis "matrix" (i.e. reciprocal basis)
586 double ReciBasisSQ[NDIM]; //!< Norm of each reciprocal basis vectors
587 double ReciBasisO[NDIM]; //!< Measure of how orthonormal each basis vectors is to the others
588 double ReciBasisOSQ[NDIM]; //!< Square of the orthonormality measure ReciBasisO[]
589 double Volume; //!< volume as the determinant of the matrix of the basis vectors
590 double ECut; //!< Energy cutoff, limiting number of reciprocal wave vectors
591 double SawtoothStart;
592 int Lev0Factor; //!< LevelSizes of 0th level
593 int LevRFactor; //!< LevelSizes of (RL-1)th level (upper of RiemannLevel)
594 int MaxLevel; //!< Maximum number of levels
595 int AddNFactor;
596 int *LevelSizes; //!< Factor for all levels, stating the size in comparsion to the one below (most often factor 2)
597 int *MaxNoOfnFields; //!< maximum number of entries in NFields array per level
598 int **NFields;
599 struct LatticeLevel *Lev; //!< Array of different LatticeLevels, up to MaxLevel
600 struct OneGData *GArrayForSort;
601 struct Psis Psi; //!< Wave function structure residing within the lattice
602 struct RiemannTensor RT;
603 struct fft_plan_3d *plan;
604 struct Energy Energy[Extra]; //!< Energy structure for this particular lattice setting
605 struct Energy *E; //!< pointer to current Energy structure within minimisation scheme
606};
607
608#define MAXTIMETYPES 19 //!< specifying number of TimeTypes
609//! Enumerating timing groups, each having its own timer \warning LevSMaxG must be the last one */
610enum TimeTypes { SimTime, //!< simulation time
611 InitSimTime, //!< simulation time during which initialisation of calculations is performed
612 InitTime, //!< initialization time at programme start
613 InitGramSchTime, //!< initialization time for Gram-Schmidt-Orthogonalization
614 InitLocTime, //!< initialization time for local pseudopotential calculations
615 InitNonLocTime, //!< initialization time for non-local pseudopotential calculations
616 InitDensityTime, //!< initialization time for density calculations
617 GramSchTime, //!< time spent orthonormalizing the orbits
618 LocTime, //!< time spent evaluating local pseudopotential
619 NonLocTime, //!< time spent evaluating non-local pseudopotential
620 DensityTime, //!< time spent evaluating density
621 LocFTime, //!< time spent evaluating local form factors
622 NonLocFTime, //!< time spent evaluating non-local form factors
623 EwaldTime, //!< time spent evaluating ewald summation over ion core-to-core forces
624 GapTime, //!< time spent evaluating the gap energy
625 CurrDensTime, //!< time spent evaluating the current density
626 WannierTime, //!< time spent localizing the orbitals
627 ReadnWriteTime, //!< time spent during reading and writing of wave function coefficients
628 LevSMaxG}; //!< number of reciprocal grid vectors to calculate standard deviation, must always be the last one!
629
630//! enumerating if time is started or stopped
631enum TimeDoTypes { StartTimeDo, //!< start timer
632 StopTimeDo //!< stop timer
633 };
634
635
636/** Array structure for timekeeping.
637 * It consists of arrays for each timing group(!) for
638 * steps, averages, stored times, deviations, min and max
639 */
640struct SpeedStruct {
641 double SpeedStep[MAXTIMETYPES];
642 double time1[MAXTIMETYPES]; //!< time before the time before current time
643 double time2[MAXTIMETYPES]; //!< time before current time
644 double time[MAXTIMETYPES]; //!< current time
645 double average[MAXTIMETYPES]; //!< storing average
646 double stddev[MAXTIMETYPES]; //!< standard deviation
647 double min[MAXTIMETYPES]; //!< minimum time
648 double max[MAXTIMETYPES]; //!< maximum time
649 int InitSteps;
650 int LevUpSteps;
651 int Steps; //!< holds count of made Molecular dynamic steps
652};
653
654struct Problem;
655#include "ions.h"
656#include "pseudo.h"
657#include "excor.h"
658#include "grad.h"
659#include "run.h"
660
661/** Physical problem superstructure.
662 * This structure contains all the vital information specifying the
663 * problem at hand, such as the command line and parameter file options,
664 * also very important RunStruct for mpi groups and SpeedStruct for time measuring,
665 * or simply all other structures.
666 * \sa GetOptions() and ReadParameters()
667 */
668struct Problem {
669 struct CallOptions Call;
670 struct FileData Files;
671 struct ParallelSimulationData Par;
672 struct Lattice Lat;
673 struct Ions Ion;
674 struct PseudoPot PP;
675 struct ExCor ExCo;
676 struct Gradient Grad;
677 struct RunStruct R;
678 struct SpeedStruct Speed;
679};
680
681
682#endif
Note: See TracBrowser for help on using the repository browser.