gimme-alpha 0.1

wavefunction.h File Reference

#include <libmodeling/bands.h>
Include dependency graph for wavefunction.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mstar_wavefunction_point_1d
struct  mstar_wavefunction_1d

Functions

struct mstar_wavefunction_1dmstar_wavefunction_1d_from_LAPACK_normlized (const struct mstar_wavefunction_1d *wf)
struct mstar_wavefunction_1dmstar_wavefunction_1d_new_gaussian (int N, double minx, double maxx, double sigma)
 generate an effective mass wavefunc that's just a gaussian
struct mstar_wavefunction_1dmstar_wavefunction_1d_new (int N)
 allocate an effective mass wavefunction
void mstar_wavefunction_1d_free (struct mstar_wavefunction_1d *wf)
 de-allocate an effective mass wavefunction
void mstar_wavefunction_1d_repack (const struct mstar_wavefunction_1d *wf, double **x, double **re, double **im, short int convert_lapack_to_density_normalization)

Function Documentation

void mstar_wavefunction_1d_free ( struct mstar_wavefunction_1d wf)

de-allocate an effective mass wavefunction

Parameters:
wfthe wavefunction to be freed

Definition at line 43 of file wavefunction.c.

References mstar_wavefunction_1d::points.

Referenced by avg_discrete_func_gaussian_1(), avg_discrete_func_gaussian_x(), convert_nextnano_mstar_wavefunction_to_general_1d(), and main().

                                                                  {
  free(wf->points);
  free(wf);
}

Here is the caller graph for this function:

struct mstar_wavefunction_1d* mstar_wavefunction_1d_from_LAPACK_normlized ( const struct mstar_wavefunction_1d wf) [read]

Gets a wavefunction that's been normalized to *integrate* to 1.

Parameters:
wfa LAPACK-normalized wavefunction, that is, a wavefunction which *sums* to 1 (i.e. each point has been multiplied by the square root of the grid spacing)

Definition at line 63 of file wavefunction.c.

References mstar_wavefunction_point_1d::im, mstar_wavefunction_1d::N, mstar_wavefunction_1d::points, mstar_wavefunction_point_1d::re, unlikely, and mstar_wavefunction_point_1d::x.

                                                                                                                  {
  struct mstar_wavefunction_1d* nwf = (struct mstar_wavefunction_1d*)malloc(sizeof(struct mstar_wavefunction_1d));
  if(nwf == NULL) return NULL;
  nwf->N = wf->N;
  nwf->points = (struct mstar_wavefunction_point_1d*)malloc(sizeof(struct mstar_wavefunction_point_1d)*nwf->N);
  if(nwf->points == NULL) {
    free(nwf);
    return NULL;
  }
  /*handle crazy cases gracefully*/
  if(unlikely(nwf->N < 3)) {
    if(nwf->N == 2) {
      nwf->points[0].x = wf->points[0].x;
      nwf->points[0].re = wf->points[0].re/sqrt(wf->points[1].x-wf->points[0].x);
      nwf->points[0].im = wf->points[0].im/sqrt(wf->points[1].x-wf->points[0].x);
      nwf->points[1].x = wf->points[1].x;
      nwf->points[1].re = wf->points[1].re/sqrt(wf->points[1].x-wf->points[0].x);
      nwf->points[1].im = wf->points[1].im/sqrt(wf->points[1].x-wf->points[0].x);
    }else{
      nwf->points[0].x = wf->points[0].x;
      nwf->points[0].re = wf->points[0].re;
      nwf->points[0].im = wf->points[0].im;
    }
  }else{
    /*Do average of forward and backward grid spaces, which necessitates special
     *  handling for the first and last points.*/
    nwf->points[0].x = wf->points[0].x;
    nwf->points[0].re = wf->points[0].re/sqrt(wf->points[1].x-wf->points[0].x);
    nwf->points[0].im = wf->points[0].im/sqrt(wf->points[1].x-wf->points[0].x);
    for(int i=1; i<(nwf->N-1); i++) {
      nwf->points[i].x = wf->points[i].x;
      nwf->points[i].re = wf->points[i].re/sqrt(0.5*(wf->points[i+1].x-wf->points[i-1].x));
      nwf->points[i].im = wf->points[i].im/sqrt(0.5*(wf->points[i+1].x-wf->points[i-1].x));
    }
    nwf->points[nwf->N-1].x = wf->points[nwf->N-1].x;
    nwf->points[nwf->N-1].re = wf->points[nwf->N-1].re/sqrt(wf->points[nwf->N-2].x-wf->points[nwf->N-1].x);
    nwf->points[nwf->N-1].im = wf->points[nwf->N-1].im/sqrt(wf->points[nwf->N-2].x-wf->points[nwf->N-1].x);
  }
  return nwf;
}
struct mstar_wavefunction_1d* mstar_wavefunction_1d_new ( int  N) [read]

allocate an effective mass wavefunction

Parameters:
Nnumber of points in the wavefunc
Returns:
an empty wavefunction with N points

Definition at line 31 of file wavefunction.c.

References mstar_wavefunction_1d::N, mstar_wavefunction_1d::points, and unlikely.

Referenced by convert_nextnano_mstar_wavefunction_to_general_1d(), and mstar_wavefunction_1d_new_gaussian().

                                                               {
  struct mstar_wavefunction_1d *wf = malloc(sizeof(struct mstar_wavefunction_1d));
  if(unlikely(wf == NULL)) return NULL;
  wf->points = malloc(N*sizeof(struct mstar_wavefunction_point_1d));
  if(unlikely(wf->points == NULL)) {
    free(wf);
    return NULL;
  }
  wf->N = N;
  return wf;
             }

Here is the caller graph for this function:

struct mstar_wavefunction_1d* mstar_wavefunction_1d_new_gaussian ( int  N,
double  minx,
double  maxx,
double  sigma 
) [read]

generate an effective mass wavefunc that's just a gaussian

Parameters:
Nnumber of points in the wavefunc
minxminium x to evaluate at
maxxmaximum x to evaluate at
sigmasigma to be used in evaluating the Gaußian
Returns:
1D effective mass Gaußian wavefunction

Definition at line 49 of file wavefunction.c.

References mstar_wavefunction_1d_new(), mstar_wavefunction_1d::N, mstar_wavefunction_1d::points, and unlikely.

Referenced by avg_discrete_func_gaussian_1(), and avg_discrete_func_gaussian_x().

                                                                                                                {
  struct mstar_wavefunction_1d* wf = mstar_wavefunction_1d_new(N);
  if(unlikely(wf == NULL)) return NULL;
  double oosqrtsigma = 1.0/pow(sigma*M_PI, 0.25);
  double oosigma = 1.0/(sigma*2);
  for(int i=0; i<N; i++) {
    double x = (maxx-minx)/N*i + minx;
    (wf->points)[i].x = x;
    (wf->points)[i].re = oosqrtsigma*exp(-x*x*oosigma);
    (wf->points)[i].im = 0.0;
  }
  return wf;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mstar_wavefunction_1d_repack ( const struct mstar_wavefunction_1d wf,
double **  x,
double **  re,
double **  im,
short int  convert_lapack_to_density_normalization 
)

Definition at line 104 of file wavefunction.c.

References mstar_wavefunction_point_1d::im, mstar_wavefunction_1d::N, mstar_wavefunction_1d::points, mstar_wavefunction_point_1d::re, unlikely, and mstar_wavefunction_point_1d::x.

Referenced by alpha_electric_term_mstar_nostrain(), alpha_from_del_psi2_nostrain(), alpha_interface_term_mstar_nostrain(), and average_discrete_function().

                                                                                                                                                                   {
  *x = malloc((wf->N)*sizeof(double));
  *re = malloc((wf->N)*sizeof(double));
  *im = malloc((wf->N)*sizeof(double));
  if(convert_lapack_to_density_normalization) {
    /*handle crazy cases gracefully*/
    if(unlikely(wf->N < 3)) {
      if(wf->N == 2) {
  (*x)[0] = wf->points[0].x;
  (*re)[0] = wf->points[0].re/sqrt(wf->points[1].x-wf->points[0].x);
  (*im)[0] = wf->points[0].im/sqrt(wf->points[1].x-wf->points[0].x);
  (*x)[1] = wf->points[1].x;
  (*re)[1] = wf->points[1].re/sqrt(wf->points[1].x-wf->points[0].x);
  (*im)[1] = wf->points[1].im/sqrt(wf->points[1].x-wf->points[0].x);
      }else{
  (*x)[0] = wf->points[0].x;
  (*re)[0] = wf->points[0].re;
  (*im)[0] = wf->points[0].im;
      }
    }else{
      /*Do average of forward and backward grid spaces, which necessitates special
       *  handling for the first and last points.*/
      (*x)[0] = wf->points[0].x;
      (*re)[0] = wf->points[0].re/sqrt(wf->points[1].x-wf->points[0].x);
      (*im)[0] = wf->points[0].im/sqrt(wf->points[1].x-wf->points[0].x);
      for(int i=1; i<(wf->N-1); i++) {
  (*x)[i] = wf->points[i].x;
  (*re)[i] = wf->points[i].re/sqrt(0.5*(wf->points[i+1].x-wf->points[i-1].x));
  (*im)[i] = wf->points[i].im/sqrt(0.5*(wf->points[i+1].x-wf->points[i-1].x));
      }
      (*x)[wf->N-1] = wf->points[wf->N-1].x;
      (*re)[wf->N-1] = wf->points[wf->N-1].re/sqrt(wf->points[wf->N-1].x-wf->points[wf->N-2].x);
      (*im)[wf->N-1] = wf->points[wf->N-1].im/sqrt(wf->points[wf->N-1].x-wf->points[wf->N-2].x);
    }
  }else{
    for(int i=0; i<wf->N; i++) {
      (*x)[i] = (wf->points)[i].x;
      (*re)[i] = (wf->points)[i].re;
      (*im)[i] = (wf->points)[i].im;
    }
  }
}

Here is the caller graph for this function:

 All Classes Files Functions Variables Enumerations Enumerator Defines