source: pcp/src/data.h@ cfaf42

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

CallOptions#ReadSrcFile is now enumerated ParseSrcDensities

This is done to distinguish between when only Occ are parsed (i.e. when StructOpt has been done before and now we do perturbed run), all or we pare and minimise subsequently.

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