k-dot-p 0.1

kdotp::libkdotp::hamiltonian::cartesian_8band Class Reference

#include <hamiltonian_cartesian_8band.h++>

Collaboration diagram for kdotp::libkdotp::hamiltonian::cartesian_8band:

List of all members.

Public Member Functions

int get_matrix_index (unsigned int row, unsigned int col, unsigned short band)
int get_array_index (unsigned int row, unsigned int col, unsigned short band)
double * get_eigenvectors_double (double eVmin, double eVmax, double **evals, int *n_eigs, GError **err)
double * get_eigenvectors_int (int imin, int imax, double **evals, int *n_eigs, GError **err)
double * get_eigenvectors (char VoI, double eVmin, double eVmax, int imin, int imax, double **evals, int *n_eigs, GError **err)
 cartesian_8band (struct libmodelxx::structure::generic_structure *gs, boundary_condition bc_, bool second_neighbor_)
 ~cartesian_8band ()

Public Attributes

double * upper_diagonal
double * diagonal
llw_complex_double * matrix
llw_complex_double * Q
unsigned int L
enum boundary_condition bc
bool second_neighbor
int n_neighbors
struct parameters_8band_nostrainparams

Private Member Functions

 cartesian_8band ()
cartesian_8band operator= (const cartesian_8band &em)

Detailed Description

Definition at line 69 of file hamiltonian_cartesian_8band.h++.


Constructor & Destructor Documentation

kdotp::libkdotp::hamiltonian::cartesian_8band::cartesian_8band ( struct libmodelxx::structure::generic_structure gs,
boundary_condition  bc_,
bool  second_neighbor_ 
)

Definition at line 186 of file hamiltonian_cartesian_8band.c++.

References bc, kdotp::libkdotp::hamiltonian::check_constants_hermiticity(), kdotp::libmodelxx::grid::cartesian_grid< T, D, Nc >::data, kdp::constants::e, kdotp::libmodelxx::structure::material::get_name(), kdotp::libmodelxx::structure::material::get_property(), kdotp::libkdotp::hamiltonian::HARDWALL, kdotp::libmodelxx::grid::cartesian_grid< T, D, Nc >::L, L, kdotp::libmodelxx::structure::generic_structure::material_grid, matrix, N_BANDS, n_neighbors, params, kdotp::libmodelxx::structure::generic_structure::potential_grid, and kdotp::libkdotp::hamiltonian::store_reduced_material_parameters().

                                                                                                                                     : upper_diagonal(NULL), diagonal(NULL), matrix(NULL), Q(NULL), bc(bc_), second_neighbor(second_neighbor_), params(NULL) {
  n_neighbors=second_neighbor_?2:1;
  /*Check to make sure our consts matrix is Hermitean*/
  {
    int col;
    short unsigned row;
    if((col=check_constants_hermiticity(&row)) != 0) {
      fprintf(stderr, "Hermiticty check of 8-band constants FAILED at row=%hu col=%d.\n", row, col);
    }else{
      fprintf(stderr, "Hermiticty check of 8-band constants PASSED.\n");
    }
  }
  matgrid *mg = (matgrid*)(gs->material_grid);
  potgrid *pg = (potgrid*)(gs->potential_grid);
  L = mg->L[0];
  /*Load the reduced material parameters into the array.*/
  params = (struct parameters_8band_nostrain*)malloc(L*sizeof(struct parameters_8band_nostrain));
  if(params == NULL) return;
  GError *e = NULL;
  if((e = store_reduced_material_parameters(params, mg, pg)) != NULL) {
    fprintf(stderr, "hamiltonian_cartesian_8band: ERROR calculating reduced band parameters: %s\n", e->message);
    g_error_free(e);
    free(params);
    params =NULL;
    return;
  }
        if(bc == HARDWALL) {
    matrix = new llw_complex_double[(n_neighbors+1)*L*N_BANDS];
      for(long unsigned i = 0; i<(n_neighbors+1)*L*N_BANDS; i++) {
        matrix[i].re = 0;
        matrix[i].im = 0;
      }
  }else{
    matrix = new llw_complex_double[L*L*N_BANDS*N_BANDS];
    for(long unsigned int i=0; i<(L*L*N_BANDS*N_BANDS); i++) {
      matrix[i].re = 0;
      matrix[i].im = 0;
    }
  }
  int e2=0;
        //double dconsts = -1/(nm_to_bohr(mg->a[0])*nm_to_bohr(mg->a[0]));
  /*Set up the constants for the diagonal, superdiagonal, and second superdiagonal for first nearest neighbor*/
  
  double ooms=0, ooms_prev=0, ooms_next=0, Eg=0, Ev=0, ooms_prev2=0, ooms_next2=0;
  /*Initialize the current ooms.*/
  ooms = 1.0/mg->data[0]->get_property("m_e_Gamma", &e2);
  if(e2 != 0) {
    fprintf(stderr, "hamiltonians::cartesian_8band: ERROR getting m_e_Gamma (err=%d).\n", e2);
    e2=0;
  }
  ooms_next = 1.0/mg->data[1]->get_property("m_e_Gamma", &e2);
  if(e2 != 0) {
    fprintf(stderr, "hamiltonians::cartesian_8band: ERROR getting m_e_Gamma (err=%d).\n", e2);
    e2=0;
  }
  for(unsigned int i=0; i<L; i++, ooms_prev2 = ooms_prev, ooms_prev=ooms, ooms=ooms_next, ooms_next = ooms_next2) {
    //Eg = ev_to_hartree(mg->data[i]->get_property("E_g_Gamma", &e2));
    Eg = mg->data[i]->get_property("E_g_Gamma", &e2);
    if(e2 != 0) {
      fprintf(stderr, "hamiltonians::cartesian_8band: ERROR getting E_g_Gamma (err=%d).\n", e2);
      e2=0;
    }
    //Ev = ev_to_hartree(mg->data[i]->get_property("E_v", &e2));
    Ev = mg->data[i]->get_property("E_v", &e2);
    if(e2 != 0) {
      fprintf(stderr, "hamiltonians::cartesian_8band: ERROR getting E_v (err=%d).\n", e2);
      e2=0;
    }
    if(i < L-2) {
      ooms_next2 = 1.0/mg->data[i+2]->get_property("m_e_Gamma", &e2);
      if(e2 != 0) {
        fprintf(stderr, "hamiltonians::cartesian_8band: ERROR getting m_e_Gamma (err=%d).\n", e2);
        e2=0;
      }
    }
    char *s;
    fprintf(stderr, "%05u(%s): ooms_prev2=%g ooms_prev=%g ooms=%g ooms_next=%g ooms_next2=%g Ev+Eg=%g\n", i, s=mg->data[i]->get_name(), ooms_prev2, ooms_prev, ooms, ooms_next, ooms_next2, Ev+Eg);
    g_free(s);
    ////////////////////////////////////////////////////////////////
    // NOTHING BELOW THIS LINE HAS BEEN FULLY IMPLEMENTED FOR 8BAND;
    // THIS IS ALL PLACEHOLDER/FORM CODE WHICH HAS BEEN MADE TO
    // COMPILE.
    ////////////////////////////////////////////////////////////////
    if(bc == HARDWALL) {
    }else{
    }
  }
      }

Here is the call graph for this function:

kdotp::libkdotp::hamiltonian::cartesian_8band::~cartesian_8band ( )

Definition at line 275 of file hamiltonian_cartesian_8band.c++.

References diagonal, matrix, Q, and upper_diagonal.

                                       {
  if(matrix != NULL) delete[] matrix;
  if(diagonal != NULL) delete[] diagonal;
  if(upper_diagonal != NULL) delete[] upper_diagonal;
  if(Q != NULL) delete[] Q;
  if(matrix != NULL) delete[] matrix;
      }
kdotp::libkdotp::hamiltonian::cartesian_8band::cartesian_8band ( ) [inline, private]

Definition at line 133 of file hamiltonian_cartesian_8band.h++.

{}

Member Function Documentation

int kdotp::libkdotp::hamiltonian::cartesian_8band::get_array_index ( unsigned int  row,
unsigned int  col,
unsigned short  band 
) [inline]

Converts an upper subdiagonal and index into an index into the array

Note:
that the 0 subdiagonal is the diagonal

Definition at line 104 of file hamiltonian_cartesian_8band.h++.

References n_neighbors.

                                                                                      {
    /*Addresses are (kd+1+i-j), j
     *i = row index
     *j = column index
     *row index = n_neighbors + 1 + i - j - 1 (start at 0 in C)
     *row index = n_neighbors + (i - j)
     *i, i+n (n-th column of 1st superdiag) ->
     *  j = i+n => row index = n_neighbors - n
     *             col index = i + n
     *there are n_neighbors + 1 rows.
     **\note update for 8-band:
     *  For each neighbor, we have 8 bands
     *  n_neighbors -> n_neighbors*8
     *  
     */
    return n_neighbors*8 + ((row*8+band) - (col*8+band)) + ((n_neighbors+1)*8)*(col*8+band);
    //return (n_neighbors - subdiagonal) + i*(n_neighbors+1);
  }
double * kdotp::libkdotp::hamiltonian::cartesian_8band::get_eigenvectors ( char  VoI,
double  eVmin,
double  eVmax,
int  imin,
int  imax,
double **  evals,
int *  n_eigs,
GError **  err 
)

Definition at line 283 of file hamiltonian_cartesian_8band.c++.

References bc, diagonal, kdotp::libkdotp::hamiltonian::HAMILTONIAN_CARTESIAN_8BAND_GERROR_DOMAIN, L, matrix, n_neighbors, kdotp::libkdotp::hamiltonian::PERIODIC, Q, second_neighbor, and upper_diagonal.

Referenced by get_eigenvectors_double(), and get_eigenvectors_int().

                                                                                                                                                    {
  int info;
  if ((bc == PERIODIC) && (diagonal == NULL) && (upper_diagonal == NULL) && (Q == NULL)) {
    /*If we're not hardwall, we first have to reduce to tridiagonal.*/
    /*We're a symmetric matrix, but not tridiag.
     *Call DSYTRD to get the tri-diag matrix*/
    /*Call DORGTR to get the matrix Q to convert the eigenfunctions back to the position basis.*/
  } else if (second_neighbor && (diagonal == NULL) && (upper_diagonal == NULL) && (Q == NULL)) {
    /*We're a banded matrix.*/
    /*Call DSBTRD to get the tri-diagonal matrix and Q*/
    info = llw_complex_double_sbtrd_a('V', 'U', L, n_neighbors, matrix, n_neighbors+1, &diagonal, &upper_diagonal, &Q);
    if(info != 0) {
      *err = g_error_new(HAMILTONIAN_CARTESIAN_8BAND_GERROR_DOMAIN, 1, "Got error from llw_complex_double_sbtrd_a: %d\n", info);
      if(diagonal != NULL) {
        free(diagonal);
        diagonal = NULL;
      }
      if(upper_diagonal != NULL) {
        free(upper_diagonal);
        upper_diagonal = NULL;
      }
      if(Q != NULL) {
        free(Q);
        Q = NULL;
      }
      return NULL;
    }
  }
  double *eigvecs = NULL;
  int n_eigvecs = -1;
  int* isuppz = NULL;
  //info = llw_complex_double_stegr_a('V', VoI, L, diagonal, upper_diagonal, eVmin, eVmax, imin, imax, n_eigs, evals, &eigvecs, &n_eigvecs, &isuppz);
  if((n_eigvecs <= *n_eigs) || (info != 0)) {
    if(n_eigvecs <= *n_eigs) {
      *err = g_error_new(HAMILTONIAN_CARTESIAN_8BAND_GERROR_DOMAIN, 6, "in return from llw_complex_double_stegr_a: failed to get same number or more eigenvec storage than there were eigenvals (%d and %d, respectively)", n_eigvecs, *n_eigs);
    }else{
      if(info < 0) {
        *err = g_error_new(HAMILTONIAN_CARTESIAN_8BAND_GERROR_DOMAIN, 1, "Bad argument to LAPACK call DSTEGR: %d\n", -info);
      }else if(info < 10) {
        *err = g_error_new(HAMILTONIAN_CARTESIAN_8BAND_GERROR_DOMAIN, 2, "Error in BLAS call DLARRE called by LAPACK call DSGEGR: %d\n", info);
      }else if(info < 20) {
        *err = g_error_new(HAMILTONIAN_CARTESIAN_8BAND_GERROR_DOMAIN, 3, "Error in BLAS call DLARRV called by LAPACK call DSGEGR: %d\n", info/2);
      }else if(info == 100) {
        *err = g_error_new(HAMILTONIAN_CARTESIAN_8BAND_GERROR_DOMAIN, 5, "Error in liblapackwrap llw_complex_double_stegr_a: malloc failed (%d)\n", info/100);
      }else{
        *err = g_error_new(HAMILTONIAN_CARTESIAN_8BAND_GERROR_DOMAIN, 4, "Got error (info=%d) from DSTEGR, but don't know what it means.\n", info);
      }
    }
    free(*evals);
    free(eigvecs);
    *evals=NULL;
    eigvecs=NULL;
  }else{
    free(isuppz);
    if(Q != NULL) {
      double* final_eigvecs = NULL;
      double one = 1.0;
      //info = llw_complex_double_gemm_a('N', 'N', L, n_eigvecs, L, &one, Q, L, eigvecs, L, &final_eigvecs);
      if(info != 0) {
        *err = g_error_new(HAMILTONIAN_CARTESIAN_8BAND_GERROR_DOMAIN, 4, "Got error (info=%d) from llw_complex_double_gemmm_a\n", info);
        if(final_eigvecs != NULL) free(final_eigvecs);
        return eigvecs;
      }
      free(eigvecs);
      return final_eigvecs;
    }
  }
  return eigvecs;
      }

Here is the caller graph for this function:

double* kdotp::libkdotp::hamiltonian::cartesian_8band::get_eigenvectors_double ( double  eVmin,
double  eVmax,
double **  evals,
int *  n_eigs,
GError **  err 
) [inline]

Definition at line 123 of file hamiltonian_cartesian_8band.h++.

References get_eigenvectors().

                                                                                                         {
    return get_eigenvectors('V', eVmin, eVmax, 0, 0, evals, n_eigs, err);
  }

Here is the call graph for this function:

double* kdotp::libkdotp::hamiltonian::cartesian_8band::get_eigenvectors_int ( int  imin,
int  imax,
double **  evals,
int *  n_eigs,
GError **  err 
) [inline]

Definition at line 126 of file hamiltonian_cartesian_8band.h++.

References get_eigenvectors().

                                                                                              {
    return get_eigenvectors('I', 0, 0, imin, imax, evals, n_eigs, err);
  }

Here is the call graph for this function:

int kdotp::libkdotp::hamiltonian::cartesian_8band::get_matrix_index ( unsigned int  row,
unsigned int  col,
unsigned short  band 
) [inline]

Converts row column into matrix array address

Note:
for 8-band: we have 8 bands for each row and column address, so the final row and coumn is (row*8 + band) and (col*8+band).

Definition at line 100 of file hamiltonian_cartesian_8band.h++.

References L.

{return (8*col+band) + (row*8+band)*L;}
cartesian_8band kdotp::libkdotp::hamiltonian::cartesian_8band::operator= ( const cartesian_8band em) [inline, private]

Definition at line 134 of file hamiltonian_cartesian_8band.h++.

{return *this;}

Member Data Documentation

For periodic boundary conditions

Note:
that the matrix here is column-major, for compatibility with ACML
that this is also used for banded matrices; use banded_index to get the index.

Definition at line 82 of file hamiltonian_cartesian_8band.h++.

Referenced by cartesian_8band(), get_eigenvectors(), and ~cartesian_8band().

Sets up the effective mass Hamiltonian for later calculations

Parameters:
structhe generic structure to be set up for calculating
bcthe boundary conditions on the calculation

Definition at line 76 of file hamiltonian_cartesian_8band.h++.

Referenced by get_eigenvectors(), and ~cartesian_8band().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines