source: pcp/src/data.h@ 807e8a

Last change on this file since 807e8a was 08e223, checked in by Frederik Heber <heber@…>, 17 years ago

ChangeWannierCentres can now be called from outside ComputeMLWF()

Wannier centres and spread are exchanged via MPI to allow for external calling (necessary if read src densities shall be perturbed with different CommonWannier values!)

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