source: pcp/src/data.h@ 60a9f9

Last change on this file since 60a9f9 was 88e890, checked in by Frederik Heber <heber@…>, 17 years ago

RealBasisCenter[] is present and initialised.

RealBasisCenter[] is part of Lattice structure (fixed NDIM_NDIM) and initialised during InitLattice() by vector (.5, .5, .5) and MatrixTrafo with RealBasis[].

  • Property mode set to 100644
File size: 40.8 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, forces and temperatures 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 for each orbital are written to
249 FILE *ReciSpreadFile; //!< where reciprocal spread for each orbital is written to
250 FILE *MinimisationFile; //!< where TE, ATE, delta and various other elements from each minimisation steps are written to
251 FILE *TemperatureFile;//!< where the temperatures are written to
252 /* Arrays */
253 int TotalSize; //!< total number of coefficients (nodes) on all processes
254 int LocalSizeR; //!< local (total) number of real nodes, twice FileData::LocalSizeC
255 int LocalSizeC; //!< local (total) number of real nodes
256 int MaxNUp;
257 fftw_complex *PosC; //!< complex coefficients array for the output of densities
258 fftw_complex *PosTemp;
259 fftw_complex *PosFactor;
260 fftw_complex *work; //!< working coefficients array for the output of densities
261 fftw_real *PosR; //!< real coefficients array for the output of densities
262 enum ModeType *OutputPosType; //!< active - RiemannTensor is used, nonactive/standby - not
263 int DoOutVis; //!< 1 - visual data are written to files, 0 - no output (generally)
264 int DoOutMes; //!< 1 - energy and forces are written to files, 0 - no output (generally)
265 int DoOutCurr; //!< 1 - visual data of current density written to file, 0 - no output, no calculation
266 int DoOutNICS; //!< 1 - visual data of nuclear induced current shieldings written to file, 0 - no output, no calculation
267 int DoOutOrbitals; //!< 1 - output each orbital density, 0 - just total density
268};
269
270/** Structure containing info for MPI interface.
271 * Such as process number, various communicators (interfacing groups in MPI), TID.
272 * Always it's my (of this current process) process number within the group, within
273 * the communicator, etc.
274 */
275struct ParallelSimulationData {
276 int procs; //!< overall number of processes
277 int proc[PROCDIM]; //!< number of processes per gamma point and per wave function
278 int mypos[PROCDIM]; //!< I am the mypos-th process with the per gamma point or per wave function group
279 int me; //!< my process id among all
280 int mytid; //!< My TID
281 int partid; //!< Parent TID
282
283 MPI_Comm world; //!< Group: MPI_COMM_WORLD (including maybe callers)
284 MPI_Comm comm; //!< Group: all participating processe on this Problem at hand
285
286 MPI_Comm comm_ST; //!< Communicator for SpinDouble or SpinUpDown, thus either the whold world of one half of the world
287 int me_comm_ST; //!< my number within this communicator (going from 0 to Max_me_comm_ST-1)
288 int my_color_comm_ST; //!< either just 0 color(SpinDouble) or 0,1 (SpinUp - SpinDown)
289 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
290 int Max_my_color_comm_ST; //!< maximum number regarding color (either 1 for SpinDouble or 2 for SpinUpDown)
291
292 MPI_Comm comm_STInter; //!< InterComm needed for SpinUp/Down case
293
294 MPI_Comm comm_ST_Psi; //!< SubComm for comm_ST Communicator Psi, these refer to the same wave function, sharing its coefficients on both grids
295 int me_comm_ST_Psi; //!< my number within this communicator
296 int my_color_comm_ST_Psi; //!< my number, either just one color(SpinDouble) or two (SpinUp - SpinDown)
297 int Max_me_comm_ST_Psi; //!< maximum number of processes in this Psi communicator
298 int Max_my_color_comm_ST_Psi; //!< ??? maximum number regarding color (one or two)
299
300 MPI_Comm comm_ST_PsiT; //!< SubComm of comm_ST Communicator of processes that need to exchange wave funcions (GramSch())
301 int me_comm_ST_PsiT; //!< Transposed of comm_ST_Psi
302 int my_color_comm_ST_PsiT; //!< either just one color(SpinDouble) or two (SpinUp - SpinDown)
303 int Max_me_comm_ST_PsiT; //!< maximum number of processes in this GramSch communicator
304 int Max_my_color_comm_ST_PsiT;//!< ??? maximum number regarding color (one or two)
305};
306
307struct RPlans {
308 struct LevelPlan *plan;
309 fftw_complex *cdata;
310 fftw_real *rdata;
311};
312
313/** one reciprocal grid vector G.
314 */
315struct OneGData {
316 int Index; //!< index is needed to access elements in the upper Lev0, when densities are stored in reciprocal base, Density#DensityCArray
317 int GlobalIndex;
318 double GSq; //!< squared norm of G vector
319 double G[NDIM]; //!< integer cooefficients of reciprocal vector
320};
321
322struct GDataHash {
323 int i; //!< index running over each GArray from process zero to max.
324 int myPE; //!< to which process does it belong
325};
326
327/** Structure for the Psis per LatticeLevel.
328 */
329struct LevelPsi {
330 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
331 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()
332 fftw_complex *PsiDat; //!< contains the initial complex coefficients of all wave functions (even temporary ones)
333 fftw_complex *OldPsiDat; //!< contains the old complex coefficients of all wave functions (even temporary ones)
334 fftw_complex *TempPsi; //!< temporal array used in GramSch(), size of LatticeLevel:MaxG, always the Psi to be orthogonalized
335 fftw_complex *TempPsi2; //!< pointer to a Psi used in GramSch(), always the Psi already orthogonalized
336};
337
338/** Structure containing one wave function.
339 */
340struct OnePsiElement {
341 int me_comm_ST_Psi; //!< this wave function belongs to this process in the communicator Psi
342 int my_color_comm_ST_Psi; //!< this wave function belongs to this process in the communicator PsiT
343 int MyLocalNo; //!< continuing number among the Psis that are local to this process
344 int MyGlobalNo; //!< continuing global number among all Psis
345 int/*enum PsiGramSchStatusType*/ PsiGramSchStatus; //!< Status of how far the Gram-Schmidt-Orthonormalization has gone yet for this Psi
346 enum MinimisationStatusType MinimisationStatus; //!< Status of how far the Gram-Schmidt-Orthonormalization has gone yet for this Psi
347 enum PsiTypeTag PsiType; //!< what type of wave function: normal (occupied), extra (gradient) or unoccupied Psi
348 double PsiFactor; //!< occupation number, hard-coded (2.0 in SpinDouble case or 1.0 in SpinUpDown case)
349 double PsiReciNorm2; //!< reciprocal norm of Psi being the Sum over all reciprocal grid vectors.
350 int DoBrent; //!< signals switching to brent iteration in line search
351};
352
353/** Additional Data to a wave function OnePsiElement.
354 * Contains energy, kinetic eigenvalues, performed minimalization steps.
355 */
356struct OnePsiElementAddData {
357 double Lambda; //!< energy eigenvalue \f$\lambda_i = \langle \psi_i^{(m)}|H|\psi_i^{(m)} \rangle\f$
358 double T; //!< kinetic eigenvalue \f$\langle \psi_i | \ \frac{1}{2} \nabla^2 | psi_i \rangle\f$
359 double Gamma; //!< scalar product between the gradient of the wave function and the preconditioned one at this \ref Step
360 int Step; //!< holds count of currently made minimalization steps
361 double WannierCentre[NDIM]; //!< NDIM coordinates of wannier centre of this orbital
362 double WannierSpread; //!< current spread of this orbital
363};
364
365
366/** Structure about all wave functions a.k.a orbits.
367 * Containing variables such as SpinType, LocalNo, PsiGroup, OnePsiElement array and
368 * various densities.
369 */
370struct Psis {
371 enum UseSpinType Use; //!< Use Spin Up/Down or not (Double)
372 enum SpinType PsiST; //!< Spin Type: Up, Down or Double
373 int GlobalNo[MaxPsiNoType];//!< global number of Psis for the four plus one cases: Max, MaxDouble, MaxUp, MaxDown, MaxAdd
374 int LocalNo; //!< number of occupied and unoccupied Psis that are local (ly accessible) in this process
375 int LocalNoAdd; //!< number of unoccupied Psis that are local (ly accessible) in this process (spinup/-down or double)
376 int NoOfPsis; //!< contains SpinType-dependent sum of GlobalNo, giving number of wave functions in the current minimisation group (except for PsiTypeTag#UnOccupied of course)
377 int NoOfTotalPsis; //!< contains SpinType-dependent sum of GlobalNo with added PsiTypeTag#UnOccupied states
378 int TypeStartIndex[Extra+2];//!< index array where the respective PsiTypeTag type starts in LocalPsiStatus
379 int AllMaxLocalNo; //!< maximum local number of Psis on one process (some processes have one more due to modulo != 0 on sharing)
380 int MaxPsiGroup; //!< number of processes among which the Psis are divided
381 int PsiGroup; //!< rank of this process in the communicator ParallelSimulationData::comm_ST_Psi
382 int MaxPsiOfType; //!< overall number of Psis
383 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
384 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]
385 int MyStartNo; //!< at which Psis do the locally accessible of this process start (going to MyStartNo+LocalNo)
386 struct OnePsiElement *AllPsiStatus; //!< array over all PsiTypeTag's of all wave functions, yet without coefficients (see Psis::LocalPsiStatus)
387 struct OnePsiElement *AllPsiStatusForSort; //!< temporary array of same size as *AllPsiStatus, only used in naturalmergesort()
388 struct OnePsiElement *LocalPsiStatus; //!< array over all PsiTypeTag's of the local wave functions which are accessible to/stored in this process
389 int *TempSendA; //!< In GramSch(): Holds count to which process in GramSch group a local wave function has been sent
390 double NIDensity[Extra]; //!< Density over all
391 double NIDensityUp[Extra]; //!< Density of SpinUp
392 double NIDensityDown[Extra]; //!< Density of SpinDown
393 int *AllActualLocalPsiNo;
394 int *AllOldActualLocalPsiNo;
395 struct OnePsiElementAddData *AddData; //!< some additional local data, such as energy eigenvalue
396 double **lambda; //!< contains \f$\lambda_{kl} = \langle \varphi_k^{(0)} | H^{(0)} | \varphi_l^{(0)} \rangle\f$, sa CalculateHamiltonian()
397 double **Overlap; //!< contains \f$S_{kl} = \langle \varphi_k^{(1)} | \varphi_l^{(1)} \rangle\f$, sa CalculatePerturbedOverlap()
398};
399
400/** Structure containing the various (radially discretized) densities.
401 * Densities are always calculated on one level higher than the respective wave functions as the fftransformation then
402 * becomes exact (fourier basis).
403 */
404struct Density {
405 int TotalSize; // total number of nodes
406 int LocalSizeC; // number of nodes in radial mesh of the complex density (locally accessible)
407 int LocalSizeR; // number of nodes in radial mesh of the density (locally accessible)
408 enum UseType DensityTypeUse[MaxDensityTypes]; //!< Density is used or not (e.g. Up/Down not used in SpinType::SpinDouble case)
409 fftw_real *DensityArray[MaxDensityTypes]; //!< density array (wave functions summed and squared, R-dependent) (radially discretized), \sa CalculateOneDensityR()
410 fftw_complex *DensityCArray[MaxDensityTypes]; //!< density array (wave functions summed and squared, G-dependent), \sa CalculateOneDensityC()
411 enum UseType LockArray[MaxDensityTypes]; //!< 1 - real density array is currently in use, 0 - array may be locked for sole
412 enum UseType LockCArray[MaxDensityTypes]; //!< 1 - complex density array is currently in use, 0 - array may be locked for sole
413};
414
415enum complex {
416 real, //!< number is real
417 imag //!< number is complex
418 };
419/** Structure containing one lattice level.
420 * Containing Level number LevelNo, maximum grid mesh points normal MaxN and reciprocal MaxG, factors
421 * between this one and upper levels, array of the grid vectors GArray, wave function on this level
422 * LPsi and densities Dens.
423 */
424struct LatticeLevel {
425 int LevelNo; //!< current number of this level
426 int MaxN; //!< number of grid points
427 int N[NDIM]; //!< number of grid points for this level in each dimension NDIM
428 int NUp[NDIM]; //!< ratio of number of mesh points between this and the upper level for each dimension NDIM
429 int NUp0[NDIM]; //!< ratio of number of mesh points this and the 0th level for each dimension NDIM
430 int NUp1[NDIM]; //!< ratio of number of mesh points and the first level for each dimension NDIM
431 int MaxNUp; //!< ratio of grid points between this and the upper level overall (all dimensions together)
432 int MaxG; //!< number of reciprocal grid vectors
433 int MaxDoubleG; //!< number of reciprocal grid vectors which are double by gamma point symmetry (only one is stored)
434 int *AllMaxG; //!< number of reciprocal grid vectors for each process
435 int TotalAllMaxG; //!< number of reciprocal grid (complex) vectors for all process
436 int TotalRealAllMaxG; //!< number of reciprocal grid (real) vectors for all process
437 double ECut; //!< Cutoff energy (discretizes possible reciprocal vectors), here: maximum norm of reciprocal grid vector
438 struct RPlans Plan0;
439 struct OneGData *GArray; //!< Array of reciprocal grid vectors
440 struct GDataHash *HashG; //!< Hash-array with global index for each G
441 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)
442 int G0; //!< OneGData::Index of the reciprocal grid vector with zero components
443 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()
444 struct LevelPsi *LPsi;
445 struct Density *Dens; //!< Density on this level
446 int Step; //!< holds count of Molecular Dynamics steps
447};
448
449
450//! List of NField types, for this level, for the upper level
451//! Enumerating entries in nFields for current and upper level
452enum FFTNFields { FFTNF1, //!< Number of nFields in current level
453 FFTNFUp //!< Number of nFields in upper level
454 };
455enum FFTNFieldsS { FFTNFSVecUp=2,
456 FFTNFSVec
457 };
458enum FFTNFieldsR { FFTNFRMatUp0=2,
459 FFTNFRMatVecUpS,
460 FFTNFRVecUp0
461 };
462enum FFTNFields0 { FFTNF0Vec=1
463 };
464
465#define MAXRTPOSFAC 2 //!< maximum number of different RiemannTensor position factors
466//! Enumerating to which level the position factor relates
467enum RTPosFacType { RTPFRtoS, //!< position factor is relative to STANDARDLEVEL
468 RTPFRto0 //!< position factor is relative to topmost level
469 };
470
471#define MAXRTARRAYS 8 //!< maximum number of different RiemannTensor arrays
472//! Enumerating different RiemannTensor arrays
473enum RTArrayType { RTADetPreRT,
474 RTAPreA,
475 RTAA,
476 RTAIRT,
477 RTARTA,
478 RTAARTA,
479 RTAiGcg,
480 RTAcg
481 };
482
483struct RiemannTensor {
484 int RiemannLevel;
485 int NUpLevRS[NDIM];
486 int NUpLevR0[NDIM];
487 enum UseRiemannTensor Use;
488 enum ModeType ActualUse;
489 fftw_complex *Coeff;
490 struct LatticeLevel *LevR; /* RiemannLevel */
491 struct LatticeLevel *LevS; /* StandartLevel */
492 struct LatticeLevel *Lev0; /* 0 Level */
493 int MaxNUp[MAXRTPOSFAC];
494 int TotalSize[MAXRTARRAYS];
495 int LocalSizeC[MAXRTARRAYS];
496 int LocalSizeR[MAXRTARRAYS];
497 int NFields[MAXRTARRAYS];
498 fftw_complex *PosFactor[MAXRTPOSFAC];
499 fftw_complex *DensityC[MAXRTARRAYS];
500 fftw_real *DensityR[MAXRTARRAYS];
501 fftw_complex *RTLaplaceS;
502 fftw_complex *RTLaplace0;
503 fftw_complex *TempC;
504 size_t TempTotalSize;
505};
506
507#define MAXALLPSIENERGY 4 //!< number of different wave function energies
508
509//! Enumerating energy types of wave function
510enum AllPsiEnergyTypes { KineticEnergy, //!< kinetic energy
511 NonLocalEnergy, //!< non-local pseudo potential energy
512 Perturbed1_0Energy, //!< \f$\langle \varphi_l^{(1)} | H^{(1)} | \varphi_l^{(0)} \rangle \f$
513 Perturbed0_1Energy //!< \f$\langle \varphi_l^{(0)} | H^{(1)} | \varphi_l^{(1)} \rangle \f$
514 };
515#define MAXALLDENSITYENERGY 6 //!< number of different density energies
516//! Enumerating density energy types
517enum AllDensityEnergyTypes { CorrelationEnergy, //!< correlation energy \f$E_C\f$
518 ExchangeEnergy, //!< exchange energy \f$E_X\f$
519 GaussEnergy, //!< gaussian energy \f$E_{gauss}\f$
520 PseudoEnergy, //!< pseudopotential energy \f$E_{ps}\f$
521 HartreePotentialEnergy, //!< Hartree potential energy including gaussian density \f$E_H\f$
522 HartreeEnergy //!< Hartree energy \f$E_H\f$
523 };
524#define MAXALLIONSENERGY 2 //!< number of different ion energies
525//! Enumerating different ion energy types
526enum AllIonsEnergyTypes { GaussSelfEnergy, //!< Gaussian self energy due to charge
527 EwaldEnergy //!< core to core energy summed over all super cells by ewald summation
528 };
529#define MAXOLD 2 //!< how many older calculated values are archived in various arrays
530
531/** Energy structure.
532 * Contains Total and local (i.e. within one process) energies of the
533 * three classes: wave function, density and ion, also the first and
534 * second time derivative, dating back to MAXOLD
535 */
536struct Energy {
537 double AllTotalPsiEnergy[MAXALLPSIENERGY]; //!< Total energy in SpinType#SpinDouble case
538 double AllLocalPsiEnergy[MAXALLPSIENERGY]; //!< Calculated energies of the local process, summed up via MPI_Allreduce to Energy::AllUpPsiEnergy, Energy::AllDownPsiEnergy or Energy::AllTotalPsiEnergy respectively
539 double AllUpPsiEnergy[MAXALLPSIENERGY]; //!< Total energy in SpinType#SpinUp case
540 double AllDownPsiEnergy[MAXALLPSIENERGY]; //!< Total energy in SpinType#SpinDown case
541 double *PsiEnergy[MAXALLPSIENERGY];
542 double AllLocalDensityEnergy[MAXALLDENSITYENERGY]; //!< local total energy of electron density within one process
543 double AllTotalDensityEnergy[MAXALLDENSITYENERGY]; //!< Total energy resulting from electron density
544 double AllTotalIonsEnergy[MAXALLIONSENERGY]; //!< Total energy of the Ions, Ewald and gaussian
545 double TotalEnergy[MAXOLD]; //!< Total energy as the sum of AllTotalPsiEnergy, AllTotalDensityEnergy and AllTotalIonsEnergy
546 double TotalEnergyOuter[MAXOLD];
547 double TotalEnergyFixed[MAXOLD];
548 double delta[MAXOLD];
549 double dEdt0[MAXOLD];
550 double ddEddt0[MAXOLD];
551 double ATE[MAXOLD];
552 double parts[3];
553 double bandgap;
554 //double homolumo;
555};
556
557/** Lattice structure.
558 * containing real, inverted, reciprocal basis (squared and/or orthonormal), Volume,
559 * ECut, LatticeLevel structure, Psis structure , the fft_plan_3d structure and
560 * Energy structure
561 */
562struct Lattice {
563 double RealBasis[NDIM_NDIM]; //!< Coefficients of the basis vectors
564 double RealBasisSQ[NDIM]; //!< squared Norm of each basis vector
565 double RealBasisCenter[NDIM]; //!< center of the unit cell ((0.5,0.5,0.5) transformed by RealBasis)
566 double InvBasis[NDIM_NDIM]; //!< Matrix-wise inverted basis vectors
567 double ReciBasis[NDIM_NDIM]; //!< Coefficients of the transposed(!), inverse basis "matrix" (i.e. reciprocal basis)
568 double ReciBasisSQ[NDIM]; //!< Norm of each reciprocal basis vectors
569 double ReciBasisO[NDIM]; //!< Measure of how orthonormal each basis vectors is to the others
570 double ReciBasisOSQ[NDIM]; //!< Square of the orthonormality measure ReciBasisO[]
571 double Volume; //!< volume as the determinant of the matrix of the basis vectors
572 double ECut; //!< Energy cutoff, limiting number of reciprocal wave vectors
573 double SawtoothStart;
574 int Lev0Factor; //!< LevelSizes of 0th level
575 int LevRFactor; //!< LevelSizes of (RL-1)th level (upper of RiemannLevel)
576 int MaxLevel; //!< Maximum number of levels
577 int AddNFactor;
578 int *LevelSizes; //!< Factor for all levels, stating the size in comparsion to the one below (most often factor 2)
579 int *MaxNoOfnFields; //!< maximum number of entries in NFields array per level
580 int **NFields;
581 struct LatticeLevel *Lev; //!< Array of different LatticeLevels, up to MaxLevel
582 struct OneGData *GArrayForSort;
583 struct Psis Psi; //!< Wave function structure residing within the lattice
584 struct RiemannTensor RT;
585 struct fft_plan_3d *plan;
586 struct Energy Energy[Extra]; //!< Energy structure for this particular lattice setting
587 struct Energy *E; //!< pointer to current Energy structure within minimisation scheme
588};
589
590#define MAXTIMETYPES 19 //!< specifying number of TimeTypes
591//! Enumerating timing groups, each having its own timer \warning LevSMaxG must be the last one */
592enum TimeTypes { SimTime, //!< simulation time
593 InitSimTime, //!< simulation time during which initialisation of calculations is performed
594 InitTime, //!< initialization time at programme start
595 InitGramSchTime, //!< initialization time for Gram-Schmidt-Orthogonalization
596 InitLocTime, //!< initialization time for local pseudopotential calculations
597 InitNonLocTime, //!< initialization time for non-local pseudopotential calculations
598 InitDensityTime, //!< initialization time for density calculations
599 GramSchTime, //!< time spent orthonormalizing the orbits
600 LocTime, //!< time spent evaluating local pseudopotential
601 NonLocTime, //!< time spent evaluating non-local pseudopotential
602 DensityTime, //!< time spent evaluating density
603 LocFTime, //!< time spent evaluating local form factors
604 NonLocFTime, //!< time spent evaluating non-local form factors
605 EwaldTime, //!< time spent evaluating ewald summation over ion core-to-core forces
606 GapTime, //!< time spent evaluating the gap energy
607 CurrDensTime, //!< time spent evaluating the current density
608 WannierTime, //!< time spent localizing the orbitals
609 ReadnWriteTime, //!< time spent during reading and writing of wave function coefficients
610 LevSMaxG}; //!< number of reciprocal grid vectors to calculate standard deviation, must always be the last one!
611
612//! enumerating if time is started or stopped
613enum TimeDoTypes { StartTimeDo, //!< start timer
614 StopTimeDo //!< stop timer
615 };
616
617
618/** Array structure for timekeeping.
619 * It consists of arrays for each timing group(!) for
620 * steps, averages, stored times, deviations, min and max
621 */
622struct SpeedStruct {
623 double SpeedStep[MAXTIMETYPES];
624 double time1[MAXTIMETYPES]; //!< time before the time before current time
625 double time2[MAXTIMETYPES]; //!< time before current time
626 double time[MAXTIMETYPES]; //!< current time
627 double average[MAXTIMETYPES]; //!< storing average
628 double stddev[MAXTIMETYPES]; //!< standard deviation
629 double min[MAXTIMETYPES]; //!< minimum time
630 double max[MAXTIMETYPES]; //!< maximum time
631 int InitSteps;
632 int LevUpSteps;
633 int Steps; //!< holds count of made Molecular dynamic steps
634};
635
636struct Problem;
637#include "ions.h"
638#include "pseudo.h"
639#include "excor.h"
640#include "grad.h"
641#include "run.h"
642
643/** Physical problem superstructure.
644 * This structure contains all the vital information specifying the
645 * problem at hand, such as the command line and parameter file options,
646 * also very important RunStruct for mpi groups and SpeedStruct for time measuring,
647 * or simply all other structures.
648 * \sa GetOptions() and ReadParameters()
649 */
650struct Problem {
651 struct CallOptions Call;
652 struct FileData Files;
653 struct ParallelSimulationData Par;
654 struct Lattice Lat;
655 struct Ions Ion;
656 struct PseudoPot PP;
657 struct ExCor ExCo;
658 struct Gradient Grad;
659 struct RunStruct R;
660 struct SpeedStruct Speed;
661};
662
663
664#endif
Note: See TracBrowser for help on using the repository browser.