PAWpySeed Parallel C/Python package for numerical analysis of PAW DFT wavefunctions

- Main Page
- Classes
- Files

- File List
- File Members

utils.h
Go to the documentation of this file.
1
17 #ifndef UTILS_H
18 #define UTILS_H
19 #include <complex.h>
20 #include <math.h>
21
30 typedef struct funcset {
31 int l;
32 double* proj;
33 double** proj_spline;
34 double* aewave;
35 double** aewave_spline;
36 double* pswave;
37 double** pswave_spline;
38 double* diffwave;
39 double** diffwave_spline;
40 double* kwave;
41 double** kwave_spline;
42 double* smooth_diffwave;
43 double** smooth_diffwave_spline;
44 double* dense_kwave;
45 double** dense_kwave_spline;
46 } funcset_t;
47
48 typedef struct ppot {
49 int num_projs;
50 int total_projs;
51 int lmax;
52 funcset_t* funcs;
53 double rmax; //< maximum radius of the projector functions
54 double wave_rmax;
55 double* pspw_overlap_matrix;
56 double* aepw_overlap_matrix;
57 double* diff_overlap_matrix;
58 int proj_gridsize;
59 int wave_gridsize;
60 int num_cart_gridpts;
61 double* wave_grid;
62 double* kwave_grid;
63 double* proj_grid;
64 double* smooth_grid;
65 double* dense_kgrid;
66 } ppot_t;
67
68 typedef struct projection {
69 int num_projs;
70 int total_projs;
71 int* ns;
72 int* ls;
73 int* ms;
74 double complex* overlaps;
75 } projection_t;
76
82 typedef struct band {
83 int n;
84 int num_waves;
85 double occ;
86 double N;
87 double energy;
88 float complex* Cs;
89 double complex* CRs;
90 float complex* CAs;
91 projection_t* projections;
92 projection_t* up_projections;
93 projection_t* down_projections;
94 projection_t* wave_projections;
95 } band_t;
96
97 typedef struct rayleigh_set {
98 int l;
99 double complex* terms;
100 } rayleigh_set_t;
101
102 typedef struct kpoint {
103 short int up;
104 int num_waves;
105 int* Gs;
106 double* k;
107 double weight;
108 int num_bands;
109 band_t** bands;
110 rayleigh_set_t** expansion;
111 } kpoint_t;
112
113 typedef struct pswf {
114 double encut;
115 int num_elems;
116 int* num_projs;
117 int num_sites;
118 ppot_t* pps;
119 int* G_bounds;
120 kpoint_t** kpts;
121 int nspin;
122 int nband;
123 int nwk;
124 double* lattice;
125 double* reclattice;
126 int* fftg;
127
128 int is_ncl;
129
130 int wp_num;
131 int num_aug_overlap_sites;
132 double* dcoords;
133 double complex** overlaps;
134 } pswf_t;
135
136 typedef struct projgrid {
137 double complex* values;
138 } projgrid_t;
139
140 typedef struct real_proj {
141 int l;
142 int m;
143 int func_num;
144 double complex* values;
145 } real_proj_t;
146
147 typedef struct real_proj_site {
148 int index;
149 int elem;
150 int num_projs;
151 int total_projs;
152 int num_indices;
153 int gridsize;
154 double rmax;
155 double* coord;
156 int* indices;
157 double* paths;
158 real_proj_t* projs;
159 } real_proj_site_t;
160
161 void affine_transform(double* out, double* op, double* inv);
162
163 void rotation_transform(double* out, double* op, double* inv);
164
168 int min(int a, int b);
169
173 int max(int a, int b);
174
180 void vcross(double* res, double* top, double* bottom);
181
186 double dot(double* x1, double* x2);
187
191 double mag(double* x1);
192
197 double determinant(double* m);
198
207 double dist_from_frac(double* coords1, double* coords2, double* lattice);
208
209 void frac_to_cartesian(double* coord, double* lattice);
210
211 void cartesian_to_frac(double* coord, double* reclattice);
212
213 void min_cart_path(double* coord, double* center, double* lattice, double* path, double* r);
214
215 void trilinear_interpolate_values(double complex* x, double* frac, int* fftg, double complex* values);
216
217 double complex trilinear_interpolate(double complex* c, double* frac, int* fftg);
218
219 void free_projection_list(projection_t* projlist, int num);
220
221 void clean_wave_projections(pswf_t* wf);
222
223 void free_kpoint(kpoint_t* kpt, int num_elems, int num_sites, int wp_num, int* num_projs);
224
225 void free_ppot(ppot_t* pp);
226
227 void free_real_proj(real_proj_t* proj);
228
229 void free_real_proj_site(real_proj_site_t* site);
230
231 void free_pswf(pswf_t* wf);
232
233 void free_ptr(void* ptr);
234
235 void free_real_proj_site_list(real_proj_site_t* sites, int length);
236
237 void free_ppot_list(ppot_t* pps, int length);
238
246 double* get_occs(pswf_t* wf);
247
249 int get_nband(pswf_t* wf);
250
252 int get_nwk(pswf_t* wf);
253
255 int get_nspin(pswf_t* wf);
256
258 int is_ncl(pswf_t* wf);
259
261 double get_encut(pswf_t* wf);
262
263 double get_energy(pswf_t* wf, int band, int kpt, int spin);
264
265 double get_occ(pswf_t* wf, int band, int kpt, int spin);
266
268 void set_num_sites(pswf_t* wf, int nsites);
269
271 double legendre(int l, int m, double x);
272 void legendre_coeff(double* ptr, int l, int m);
273 double* legendre_product(int l1, int l2, int m1, int m2);
274
276 double fac(int n);
277
282 double complex Ylm(int l, int m, double theta, double phi);
283
287 double complex Ylm2(int l, int m, double costheta, double phi);
288
295 double proj_interpolate(double r, double rmax, int size, double* x,
296 double* proj, double** proj_spline);
297
303 double wave_interpolate(double r, int size, double* x, double* f,
304 double** wave_spline);
305
309 double complex proj_value_helper(double r, double rmax, int size,
310 double* pos, double* x, double* f, double** s, int l, int m);
311
316 double complex proj_value(funcset_t funcs, double* x, int m, double rmax,
317 int size, double* ion_pos, double* pos, double* lattice);
318
323 double complex smooth_wave_value(funcset_t funcs, double* x, int m, double rmax,
324 int size, double* ion_pos, double* pos, double* lattice);
325
330 double complex wave_value(funcset_t funcs, int size, double* x, int m,
331 double* ion_pos, double* pos, double* lattice);
332
337 double complex wave_value2(double* x, double* wave, double** spline, int size,
338 int l, int m, double* pos);
339
343 void setup_site(real_proj_site_t* sites, ppot_t* pps, int num_sites, int* site_nums,
344 int* labels, double* coords, double* lattice, int* fftg, int pr0_pw1);
345
352 double** spline_coeff(double* x, double* y, int N);
353
360 double spline_integral(double* x, double* a, double** s, int size);
361
362 void frac_from_index(int index, double* coord, int* fftg);
363
364 double sph_bessel(double k, double r, int l);
365
369 double sbf(double x, int l);
370
376 pswf_t* expand_symm_wf(pswf_t* rwf, int num_kpts, int* maps,
377 double* ops, double* drs, double* kws, int* trs);
378
383 void CHECK_ALLOCATION(void* ptr);
384
388 void ALLOCATION_FAILED(void);
389
394 void CHECK_STATUS(int status);
395
396 #endif
pswf::G_bounds
int * G_bounds
highest-frequency plane-waves in basis set (xmin, xmax, ymin, ymax, zmin, zmax)
Definition: utils.h:119
get_nband
int get_nband(pswf_t *wf)
projection::total_projs
int total_projs
number of projector functions
Definition: utils.h:70
real_proj_site::rmax
double rmax
Definition: utils.h:154
kpoint::bands
band_t ** bands
bands with this k-point
Definition: utils.h:109
funcset::aewave
double * aewave
all electron partial wave
Definition: utils.h:34
real_proj_site::projs
real_proj_t * projs
Definition: utils.h:158
projection_t
struct projection projection_t
dist_from_frac
double dist_from_frac(double *coords1, double *coords2, double *lattice)
kpoint::up
short int up
spin
Definition: utils.h:103
spline_coeff
double ** spline_coeff(double *x, double *y, int N)
pswf::lattice
double * lattice
lattice (length 9, each row is a lattice, vector, row major)
Definition: utils.h:124
Ylm2
double complex Ylm2(int l, int m, double costheta, double phi)
ppot::smooth_grid
double * smooth_grid
Definition: utils.h:64
band::occ
double occ
occupancy of the band
Definition: utils.h:85
sbf
double sbf(double x, int l)
pswf::nspin
int nspin
1 for non-spin-polarized/noncollinear, 2 for spin-polarized
Definition: utils.h:121
ppot::proj_grid
double * proj_grid
real radial grid for projector functions
Definition: utils.h:63
funcset::smooth_diffwave_spline
double ** smooth_diffwave_spline
spline coefficients for smooth_diffwave
Definition: utils.h:43
projection::overlaps
double complex * overlaps
list of <p_i|psi>
Definition: utils.h:74
legendre_coeff
void legendre_coeff(double *ptr, int l, int m)
ppot::pspw_overlap_matrix
double * pspw_overlap_matrix
overlap matrix for pseudo partial waves
Definition: utils.h:55
wave_value
double complex wave_value(funcset_t funcs, int size, double *x, int m, double *ion_pos, double *pos, double *lattice)
band::num_waves
int num_waves
number of plane waves
Definition: utils.h:84
fac
double fac(int n)
Ylm
double complex Ylm(int l, int m, double theta, double phi)
funcset::smooth_diffwave
double * smooth_diffwave
diffwave on linear grid with high-frequency components removed
Definition: utils.h:42
real_proj_site::index
int index
Definition: utils.h:148
funcset::dense_kwave
double * dense_kwave
Definition: utils.h:44
dot
double dot(double *x1, double *x2)
proj_value
double complex proj_value(funcset_t funcs, double *x, int m, double rmax, int size, double *ion_pos, double *pos, double *lattice)
kpoint::weight
double weight
k-point weight
Definition: utils.h:107
kpoint::Gs
int * Gs
plane wave coefficients, in sets of three
Definition: utils.h:105
kpoint
Definition: utils.h:102
real_proj_site::coord
double * coord
Definition: utils.h:155
pswf::nwk
int nwk
number of kpoints
Definition: utils.h:123
band::n
int n
band number
Definition: utils.h:83
projection
Definition: utils.h:68
ppot
Definition: utils.h:48
pawpyseed.core.rayleigh.y
y
Definition: rayleigh.py:27
real_proj_site::num_projs
int num_projs
Definition: utils.h:150
band::energy
double energy
energy of the band
Definition: utils.h:87
ppot::num_projs
int num_projs
number of radial projector functions
Definition: utils.h:49
real_proj_site::total_projs
int total_projs
Definition: utils.h:151
funcset::diffwave
double * diffwave
aewave-pswave
Definition: utils.h:38
proj_value_helper
double complex proj_value_helper(double r, double rmax, int size, double *pos, double *x, double *f, double **s, int l, int m)
free_ppot
void free_ppot(ppot_t *pp)
get_occs
double * get_occs(pswf_t *wf)
band::projections
projection_t * projections
length==number of sites in structure
Definition: utils.h:91
real_proj::m
int m
Definition: utils.h:142
band::N
double N
Definition: utils.h:86
pawpyseed.core.gaunt.f
f
Definition: gaunt.py:29
determinant
double determinant(double *m)
projection::num_projs
int num_projs
number of radial projector functions
Definition: utils.h:69
setup_site
void setup_site(real_proj_site_t *sites, ppot_t *pps, int num_sites, int *site_nums, int *labels, double *coords, double *lattice, int *fftg, int pr0_pw1)
funcset::diffwave_spline
double ** diffwave_spline
spline coefficients for diffwave
Definition: utils.h:39
mag
double mag(double *x1)
funcset::proj
double * proj
projector function
Definition: utils.h:32
band::up_projections
projection_t * up_projections
length==number of sites in structure
Definition: utils.h:92
real_proj
Definition: utils.h:140
affine_transform
void affine_transform(double *out, double *op, double *inv)
kpoint::k
double * k
k-point vector
Definition: utils.h:106
trilinear_interpolate
double complex trilinear_interpolate(double complex *c, double *frac, int *fftg)
free_real_proj_site
void free_real_proj_site(real_proj_site_t *site)
projection::ns
int * ns
radial projector index
Definition: utils.h:71
free_ptr
void free_ptr(void *ptr)
vcross
void vcross(double *res, double *top, double *bottom)
pswf::wp_num
int wp_num
length==size of wave_projections in each band
Definition: utils.h:130
band::Cs
float complex * Cs
plane wave coefficients (normalized to 1)
Definition: utils.h:88
rayleigh_set::l
int l
angular momentum quantum number
Definition: utils.h:98
real_proj_t
struct real_proj real_proj_t
pawpyseed.core.quadrature.x
list x
Definition: quadrature.py:9
free_projection_list
void free_projection_list(projection_t *projlist, int num)
pswf::nband
int nband
number of bands
Definition: utils.h:122
band_t
struct band band_t
projgrid
Definition: utils.h:136
real_proj_site::num_indices
int num_indices
Definition: utils.h:152
pswf::encut
double encut
Definition: utils.h:114
set_num_sites
void set_num_sites(pswf_t *wf, int nsites)
kpoint::num_bands
int num_bands
number of bands
Definition: utils.h:108
kpoint::expansion
rayleigh_set_t ** expansion
Definition: utils.h:110
real_proj_site_t
struct real_proj_site real_proj_site_t
rotation_transform
void rotation_transform(double *out, double *op, double *inv)
clean_wave_projections
void clean_wave_projections(pswf_t *wf)
pswf::overlaps
double complex ** overlaps
used for Projector operations
Definition: utils.h:133
real_proj::values
double complex * values
Definition: utils.h:144
expand_symm_wf
pswf_t * expand_symm_wf(pswf_t *rwf, int num_kpts, int *maps, double *ops, double *drs, double *kws, int *trs)
legendre
double legendre(int l, int m, double x)
real_proj_site::gridsize
int gridsize
Definition: utils.h:153
free_pswf
void free_pswf(pswf_t *wf)
funcset::pswave_spline
double ** pswave_spline
ps partial wave spline coefficients
Definition: utils.h:37
real_proj_site::elem
int elem
Definition: utils.h:149
funcset_t
struct funcset funcset_t
ppot::num_cart_gridpts
int num_cart_gridpts
number of real space grid points that can fit in the projector sphere
Definition: utils.h:60
projgrid::values
double complex * values
Definition: utils.h:137
free_real_proj_site_list
void free_real_proj_site_list(real_proj_site_t *sites, int length)
funcset::aewave_spline
double ** aewave_spline
ae partial wave spline coefficients
Definition: utils.h:35
pswf::num_aug_overlap_sites
int num_aug_overlap_sites
used for Projector operations
Definition: utils.h:131
pswf::num_projs
int * num_projs
number of projectors for each element
Definition: utils.h:116
sph_bessel
double sph_bessel(double k, double r, int l)
funcset::kwave_spline
double ** kwave_spline
spline coefficients for kwave
Definition: utils.h:41
projgrid_t
struct projgrid projgrid_t
funcset
Definition: utils.h:30
ppot::rmax
double rmax
Definition: utils.h:53
cartesian_to_frac
void cartesian_to_frac(double *coord, double *reclattice)
max
int max(int a, int b)
ppot::lmax
int lmax
maximum l-value of any projector
Definition: utils.h:51
pswf
Definition: utils.h:113
get_nwk
int get_nwk(pswf_t *wf)
ppot::kwave_grid
double * kwave_grid
reciprocal radial grid for partial waves
Definition: utils.h:62
trilinear_interpolate_values
void trilinear_interpolate_values(double complex *x, double *frac, int *fftg, double complex *values)
wave_value2
double complex wave_value2(double *x, double *wave, double **spline, int size, int l, int m, double *pos)
pswf::fftg
int * fftg
FFT grid dimensions.
Definition: utils.h:126
free_ppot_list
void free_ppot_list(ppot_t *pps, int length)
frac_from_index
void frac_from_index(int index, double *coord, int *fftg)
pswf::is_ncl
int is_ncl
1 if noncollinear, 0 otherwise
Definition: utils.h:128
kpoint_t
struct kpoint kpoint_t
band::CAs
float complex * CAs
wavefunction in reciprocal space
Definition: utils.h:90
ppot::proj_gridsize
int proj_gridsize
number of points on projector radial grid
Definition: utils.h:58
rayleigh_set_t
struct rayleigh_set rayleigh_set_t
real_proj::func_num
int func_num
Definition: utils.h:143
ppot::total_projs
int total_projs
number of projector functions
Definition: utils.h:50
is_ncl
int is_ncl(pswf_t *wf)
CHECK_STATUS
void CHECK_STATUS(int status)
free_kpoint
void free_kpoint(kpoint_t *kpt, int num_elems, int num_sites, int wp_num, int *num_projs)
projection::ls
int * ls
l values of projectors
Definition: utils.h:72
ALLOCATION_FAILED
void ALLOCATION_FAILED(void)
pswf_t
struct pswf pswf_t
ppot_t
struct ppot ppot_t
proj_interpolate
double proj_interpolate(double r, double rmax, int size, double *x, double *proj, double **proj_spline)
real_proj::l
int l
Definition: utils.h:141
spline_integral
double spline_integral(double *x, double *a, double **s, int size)
ppot::dense_kgrid
double * dense_kgrid
Definition: utils.h:65
real_proj_site::indices
int * indices
Definition: utils.h:156
get_occ
double get_occ(pswf_t *wf, int band, int kpt, int spin)
band
Definition: utils.h:82
band::down_projections
projection_t * down_projections
length==number of sites in structure
Definition: utils.h:93
ppot::wave_gridsize
int wave_gridsize
number of points on partial wave radial grid
Definition: utils.h:59
pawpyseed.core.rayleigh.k
int k
Definition: rayleigh.py:4
free_real_proj
void free_real_proj(real_proj_t *proj)
legendre_product
double * legendre_product(int l1, int l2, int m1, int m2)
pswf::num_elems
int num_elems
number of elements in the structure
Definition: utils.h:115
pawpyseed.core.rayleigh.r
r
Definition: rayleigh.py:38
pswf::reclattice
double * reclattice
reciprocal lattice (with 2pi factor!), formatted like lattice
Definition: utils.h:125
funcset::l
int l
l quantum number
Definition: utils.h:31
ppot::aepw_overlap_matrix
double * aepw_overlap_matrix
overlap matrix for all electron partial waves
Definition: utils.h:56
pswf::dcoords
double * dcoords
used for Projector operations
Definition: utils.h:132
real_proj_site::paths
double * paths
Definition: utils.h:157
rayleigh_set
Definition: utils.h:97
pswf::kpts
kpoint_t ** kpts
list of kpoint_t objects for the structure
Definition: utils.h:120
funcset::kwave
double * kwave
Expansion of diffwave in spherical Bessel functions.
Definition: utils.h:40
projection::ms
int * ms
m values of projectors
Definition: utils.h:73
CHECK_ALLOCATION
void CHECK_ALLOCATION(void *ptr)
funcset::dense_kwave_spline
double ** dense_kwave_spline
Definition: utils.h:45
min_cart_path
void min_cart_path(double *coord, double *center, double *lattice, double *path, double *r)
wave_interpolate
double wave_interpolate(double r, int size, double *x, double *f, double **wave_spline)
pswf::pps
ppot_t * pps
list of ppot_t objects, one for each element
Definition: utils.h:118
ppot::funcs
funcset_t * funcs
funcset for each projector, see funcset
Definition: utils.h:52
get_encut
double get_encut(pswf_t *wf)
band::CRs
double complex * CRs
wavefunction in real space
Definition: utils.h:89
min
int min(int a, int b)
pswf::num_sites
int num_sites
number of sites in the structure
Definition: utils.h:117
ppot::wave_grid
double * wave_grid
real radial grid for partial waves
Definition: utils.h:61
get_energy
double get_energy(pswf_t *wf, int band, int kpt, int spin)
real_proj_site
Definition: utils.h:147
funcset::pswave
double * pswave
pseudo partial wave
Definition: utils.h:36
smooth_wave_value
double complex smooth_wave_value(funcset_t funcs, double *x, int m, double rmax, int size, double *ion_pos, double *pos, double *lattice)
frac_to_cartesian
void frac_to_cartesian(double *coord, double *lattice)
ppot::wave_rmax
double wave_rmax
maximum radius of the partial waves
Definition: utils.h:54
rayleigh_set::terms
double complex * terms
rayleigh expansion terms
Definition: utils.h:99
ppot::diff_overlap_matrix
double * diff_overlap_matrix
overlap matrix of difference between all electron and partial waves
Definition: utils.h:57
band::wave_projections
projection_t * wave_projections
used for offsite compensation terms
Definition: utils.h:94
get_nspin
int get_nspin(pswf_t *wf)
funcset::proj_spline
double ** proj_spline
projector function spline
Definition: utils.h:33
kpoint::num_waves
int num_waves
number of plane waves in a band
Definition: utils.h:104