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

- Main Page
- Classes
- Files

- File List
- File Members

Classes | Typedefs | Functions
utils.h File Reference
`#include <complex.h>`
`#include <math.h>`
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Classes
struct | funcset
struct | ppot
struct | projection
struct | band
struct | rayleigh_set
struct | kpoint
struct | pswf
struct | projgrid
struct | real_proj
struct | real_proj_site

## Typedefs
typedef struct funcset | funcset_t
typedef struct ppot | ppot_t
typedef struct projection | projection_t
typedef struct band | band_t
typedef struct rayleigh_set | rayleigh_set_t
typedef struct kpoint | kpoint_t
typedef struct pswf | pswf_t
typedef struct projgrid | projgrid_t
typedef struct real_proj | real_proj_t
typedef struct real_proj_site | real_proj_site_t

## Functions
void | affine_transform (double *out, double *op, double *inv)
void | rotation_transform (double *out, double *op, double *inv)
int | min (int a, int b)
int | max (int a, int b)
void | vcross (double *res, double *top, double *bottom)
double | dot (double *x1, double *x2)
double | mag (double *x1)
double | determinant (double *m)
double | dist_from_frac (double *coords1, double *coords2, double *lattice)
void | frac_to_cartesian (double *coord, double *lattice)
void | cartesian_to_frac (double *coord, double *reclattice)
void | min_cart_path (double *coord, double *center, double *lattice, double *path, double *r)
void | trilinear_interpolate_values (double complex *x, double *frac, int *fftg, double complex *values)
double complex | trilinear_interpolate (double complex *c, double *frac, int *fftg)
void | free_projection_list (projection_t *projlist, int num)
void | clean_wave_projections (pswf_t *wf)
void | free_kpoint (kpoint_t *kpt, int num_elems, int num_sites, int wp_num, int *num_projs)
void | free_ppot (ppot_t *pp)
void | free_real_proj (real_proj_t *proj)
void | free_real_proj_site (real_proj_site_t *site)
void | free_pswf (pswf_t *wf)
void | free_ptr (void *ptr)
void | free_real_proj_site_list (real_proj_site_t *sites, int length)
void | free_ppot_list (ppot_t *pps, int length)
double * | get_occs (pswf_t *wf)
int | get_nband (pswf_t *wf)
int | get_nwk (pswf_t *wf)
int | get_nspin (pswf_t *wf)
int | is_ncl (pswf_t *wf)
double | get_encut (pswf_t *wf)
double | get_energy (pswf_t *wf, int band, int kpt, int spin)
double | get_occ (pswf_t *wf, int band, int kpt, int spin)
void | set_num_sites (pswf_t *wf, int nsites)
double | legendre (int l, int m, double x)
void | legendre_coeff (double *ptr, int l, int m)
double * | legendre_product (int l1, int l2, int m1, int m2)
double | fac (int n)
double complex | Ylm (int l, int m, double theta, double phi)
double complex | Ylm2 (int l, int m, double costheta, double phi)
double | proj_interpolate (double r, double rmax, int size, double *x, double *proj, double **proj_spline)
double | wave_interpolate (double r, int size, double *x, double *f, double **wave_spline)
double complex | proj_value_helper (double r, double rmax, int size, double *pos, double *x, double *f, double **s, int l, int m)
double complex | proj_value (funcset_t funcs, double *x, int m, double rmax, int size, double *ion_pos, double *pos, double *lattice)
double complex | smooth_wave_value (funcset_t funcs, double *x, int m, double rmax, int size, double *ion_pos, double *pos, double *lattice)
double complex | wave_value (funcset_t funcs, int size, double *x, int m, double *ion_pos, double *pos, double *lattice)
double complex | wave_value2 (double *x, double *wave, double **spline, int size, int l, int m, double *pos)
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)
double ** | spline_coeff (double *x, double *y, int N)
double | spline_integral (double *x, double *a, double **s, int size)
void | frac_from_index (int index, double *coord, int *fftg)
double | sph_bessel (double k, double r, int l)
double | sbf (double x, int l)
pswf_t * | expand_symm_wf (pswf_t *rwf, int num_kpts, int *maps, double *ops, double *drs, double *kws, int *trs)
void | CHECK_ALLOCATION (void *ptr)
void | ALLOCATION_FAILED (void)
void | CHECK_STATUS (int status)

## Detailed Description

Contains several sets of general purpose utilities:

1) structs used by pawpyseed as well as utility functions for freeing allocated memory being used by those structs.

2) General vector math (i.e. dot and cross product, determinant, etc.)

3) Other necessary functionality, such as spline interpolation, spherical harmonics, and plane-wave/radial function overlap, that is used in multiple locations throughout the code.

## Typedef Documentation

typedef struct band band_t

Stores the data for a single band, or Kohn Sham single particle state, for a structure

typedef struct funcset funcset_t

One set of augmentation region functions, i.e. p_i, phi_i, and phit_i (projector, all electron partial wave, and partial wave), as well as the difference of the partial waves, the difference expanded in spherical Bessel functions, and spline coefficients for each grid.

typedef struct kpoint kpoint_t

typedef struct ppot ppot_t

typedef struct projection projection_t

typedef struct projgrid projgrid_t

typedef struct pswf pswf_t

typedef struct rayleigh_set rayleigh_set_t

typedef struct real_proj_site real_proj_site_t

typedef struct real_proj real_proj_t

## Function Documentation

void affine_transform | ( | double * | out,
|  | double * | op,
|  | double * | inv
| ) |  |

void ALLOCATION_FAILED | ( | void |  | ) |

Called when a memory allocation fails to exit the program

void cartesian_to_frac | ( | double * | coord,
|  | double * | reclattice
| ) |  |

void CHECK_ALLOCATION | ( | void * | ptr | ) |

Called after a malloc or calloc call to check that the allocation was successful.

void CHECK_STATUS | ( | int | status | ) |

Checks to see if a routine returned a non-zero status. If so, prints the status and exits the program.

void clean_wave_projections | ( | pswf_t * | wf | ) |

double determinant | ( | double * | m | ) |

Calculates the determinant of the matrix m with the precondition m is 3x3 (length 9) and in row major order.

double dist_from_frac | ( | double * | coords1,
|  | double * | coords2,
|  | double * | lattice
| ) |  |

Given coords1: fractional coordinate in lattice (length 3) coords2: fractional coordinate in lattice (length 3) lattice: row major lattice matrix, where each row is a lattice unit vector (length 9), returns the distance between coords1 and coords2.

double dot | ( | double * | x1,
|  | double * | x2
| ) |  |

Returns the dot product of x1 and x2 assuming that x1 and x2 are both of length three

pswf_t* expand_symm_wf | ( | pswf_t * | rwf,
|  | int | num_kpts,
|  | int * | maps,
|  | double * | ops,
|  | double * | drs,
|  | double * | kws,
|  | int * | trs
| ) |  |

Takes a reference wavefunction and a list of symmetry operations to new kpoints, and calculates a new wavefunction that has the additional kpoints.

double fac | ( | int | n | ) |

factorial

void frac_from_index | ( | int | index,
|  | double * | coord,
|  | int * | fftg
| ) |  |

void frac_to_cartesian | ( | double * | coord,
|  | double * | lattice
| ) |  |

void free_kpoint | ( | kpoint_t * | kpt,
|  | int | num_elems,
|  | int | num_sites,
|  | int | wp_num,
|  | int * | num_projs
| ) |  |

void free_ppot | ( | ppot_t * | pp | ) |

void free_ppot_list | ( | ppot_t * | pps,
|  | int | length
| ) |  |

void free_projection_list | ( | projection_t * | projlist,
|  | int | num
| ) |  |

void free_pswf | ( | pswf_t * | wf | ) |

void free_ptr | ( | void * | ptr | ) |

void free_real_proj | ( | real_proj_t * | proj | ) |

void free_real_proj_site | ( | real_proj_site_t * | site | ) |

void free_real_proj_site_list | ( | real_proj_site_t * | sites,
|  | int | length
| ) |  |

double get_encut | ( | pswf_t * | wf | ) |

Return the encut of the plane-wave basis of the wavefunction.

double get_energy | ( | pswf_t * | wf,
|  | int | band,
|  | int | kpt,
|  | int | spin
| ) |  |

int get_nband | ( | pswf_t * | wf | ) |

Return the number of bands in the wavefunction.

int get_nspin | ( | pswf_t * | wf | ) |

Return the number of spins in the wavefunction.

int get_nwk | ( | pswf_t * | wf | ) |

Return the number of kpoins in the wavefunction.

double get_occ | ( | pswf_t * | wf,
|  | int | band,
|  | int | kpt,
|  | int | spin
| ) |  |

double* get_occs | ( | pswf_t * | wf | ) |

Returns a list with the occupation of each band of the wavefunction at each kpoint as shown: loop over bands loop over spins loop over kpoints

int is_ncl | ( | pswf_t * | wf | ) |

Return whether wf is noncollinear.

double legendre | ( | int | l,
|  | int | m,
|  | double | x
| ) |  |

Associated legendre polynomial P_lm(x)

void legendre_coeff | ( | double * | ptr,
|  | int | l,
|  | int | m
| ) |  |

double* legendre_product | ( | int | l1,
|  | int | l2,
|  | int | m1,
|  | int | m2
| ) |  |

double mag | ( | double * | x1 | ) |

Magnitude of a three-element vector

int max | ( | int | a,
|  | int | b
| ) |  |

Maximum of a and b

int min | ( | int | a,
|  | int | b
| ) |  |

Minimum of a and b

void min_cart_path | ( | double * | coord,
|  | double * | center,
|  | double * | lattice,
|  | double * | path,
|  | double * | r
| ) |  |

double proj_interpolate | ( | double | r,
|  | double | rmax,
|  | int | size,
|  | double * | x,
|  | double * | proj,
|  | double ** | proj_spline
| ) |  |

Interpolate the discretely defined projector function proj, defined on linear radial grid x, at radius r. rmax is the maximum radius of the projector. Uses spline interpolation, where proj_spline is the set of spline coefficients for proj set up by spline_coeff

double complex proj_value | ( | funcset_t | funcs,
|  | double * | x,
|  | int | m,
|  | double | rmax,
|  | int | size,
|  | double * | ion_pos,
|  | double * | pos,
|  | double * | lattice
| ) |  |

Return the value of funcs->proj, defined on linear radial grid x centered at 3D vector ion_pos, at position pos, given the real space lattice.

double complex proj_value_helper | ( | double | r,
|  | double | rmax,
|  | int | size,
|  | double * | pos,
|  | double * | x,
|  | double * | f,
|  | double ** | s,
|  | int | l,
|  | int | m
| ) |  |

Helper function for proj_value and smooth_wave_value

void rotation_transform | ( | double * | out,
|  | double * | op,
|  | double * | inv
| ) |  |

double sbf | ( | double | x,
|  | int | l
| ) |  |

Return the value of the l-order spherical bessel function at x.

void set_num_sites | ( | pswf_t * | wf,
|  | int | nsites
| ) |  |

Sets the numer of sites in the structure for the wavefunction.

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
| ) |  |

Convenience function for setting up real_proj_site_t* lists

double complex smooth_wave_value | ( | funcset_t | funcs,
|  | double * | x,
|  | int | m,
|  | double | rmax,
|  | int | size,
|  | double * | ion_pos,
|  | double * | pos,
|  | double * | lattice
| ) |  |

Return the value of funcs->smooth_diffwave, defined on linear radial grid x centered at 3D vector ion_pos, at position pos, given the real space lattice

double sph_bessel | ( | double | k,
|  | double | r,
|  | int | l
| ) |  |

double** spline_coeff | ( | double * | x,
|  | double * | y,
|  | int | N
| ) |  |

Set up spline coefficients for spline interpolation. Essentially a translation into C of the VASP SPLCOF function. G. Kresse and J. Hafner. Ab initio molecular dynamics for liquid metals. Phys. Rev. B, 47:558, 1993.

double spline_integral | ( | double * | x,
|  | double * | a,
|  | double ** | s,
|  | int | size
| ) |  |

Find the integral of a discretely defined function that is fitted with spline coefficients at each point. x is the independent variable grid, a is the function values, s is the spline, and size is the number of points on the grid.

double complex trilinear_interpolate | ( | double complex * | c,
|  | double * | frac,
|  | int * | fftg
| ) |  |

void trilinear_interpolate_values | ( | double complex * | x,
|  | double * | frac,
|  | int * | fftg,
|  | double complex * | values
| ) |  |

void vcross | ( | double * | res,
|  | double * | top,
|  | double * | bottom
| ) |  |

Calculates the cross product top X bottom and places it in res, assuming that top and bottom are both length three

double wave_interpolate | ( | double | r,
|  | int | size,
|  | double * | x,
|  | double * | f,
|  | double ** | wave_spline
| ) |  |

Interpolate the discretely defined partial wave f, defined on logarithmic radial grix x, at radius r. Uses spline interpolation, where wave_spline is the set of spline coefficients for f set up by spline_coeff

double complex wave_value | ( | funcset_t | funcs,
|  | int | size,
|  | double * | x,
|  | int | m,
|  | double * | ion_pos,
|  | double * | pos,
|  | double * | lattice
| ) |  |

Return the value of funcs->aewave-funcs->pswave, defined on logarithmic radial grid x center at 3D vector ion_pos, at position pos, given the real space lattice.

double complex wave_value2 | ( | double * | x,
|  | double * | wave,
|  | double ** | spline,
|  | int | size,
|  | int | l,
|  | int | m,
|  | double * | pos
| ) |  |

Interpolates the value of a function on a logarithmic radial grid at location pos.

double complex Ylm | ( | int | l,
|  | int | m,
|  | double | theta,
|  | double | phi
| ) |  |

Returns the value of the complex spherical harmonic assuming physics notation (phi is azimuthal angle)

double complex Ylm2 | ( | int | l,
|  | int | m,
|  | double | costheta,
|  | double | phi
| ) |  |

Same as Ylm but takes the cosine of theta instead of the angle itself.