source: pcp/src/data.h@ 460e95

Last change on this file since 460e95 was 7b1792, checked in by Frederik Heber <heber@…>, 17 years ago

pointer TemperatureFile added to FileData structure for thermostats

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