k-dot-p 0.1

kdotp::libmodelxx::continuous_structure Namespace Reference

Classes

struct  callback_get_material_privdat
struct  region
struct  doping
struct  potential
struct  continuous_structure

Enumerations

enum  length {
  ANGSTROM, NANOMETER, MICROMETER, MILLIMETER,
  CENTIMETER, METER, UNKNOWN_LENGTH
}
enum  energy {
  EVOLT, JOULE, ERG, HARTREE,
  UNKNOWN_ENERGY
}

Functions

static GError * callback_convert_type (double *location, double *values, int t, void *privdat)
static GError * callback_get_material (structure::material **location, double *values, int t, void *privdat)
struct
structure::generic_structure
postprocess_structure (struct continuous_structure *s, const struct structure::matdb *mdb, GHashTable *global_symbol_table, GError **gerr)
void print_structure (const struct continuous_structure *s)
enum length length_from_str (const char *str)
const char * str_from_length (enum length l)
enum energy energy_from_str (const char *str)
const char * str_from_energy (enum energy e)
double convert_length_to_nm (double len, enum length unit)
double convert_energy_to_hartree (double en, enum energy unit)

Enumeration Type Documentation

Enumerator:
EVOLT 
JOULE 
ERG 
HARTREE 
UNKNOWN_ENERGY 

Definition at line 91 of file continuous_structure.h++.

Enumerator:
ANGSTROM 
NANOMETER 
MICROMETER 
MILLIMETER 
CENTIMETER 
METER 
UNKNOWN_LENGTH 

Definition at line 81 of file continuous_structure.h++.


Function Documentation

static GError* kdotp::libmodelxx::continuous_structure::callback_convert_type ( double *  location,
double *  values,
int  t,
void *  privdat 
) [static]

Definition at line 35 of file continuous_structure.c++.

References CONTINUOUS_STRUCTURE_GERROR_DOMAIN.

Referenced by postprocess_structure().

                                                                                                   {
  for(int i=0; i<t; i++) {
    location[i] = values[i];
  }
  if(t == 0) {
    location[0] = values[0];
    return g_error_new(CONTINUOUS_STRUCTURE_GERROR_DOMAIN, 1, "::kdotp::libmodelxx::continuous_structure.c++::callback_convert_type:: warning: function data type boolean is invalid!");
  }
  if(t < 0) {
    return g_error_new(CONTINUOUS_STRUCTURE_GERROR_DOMAIN, 2, "::kdotp::libmodelxx::continuous_structure.c++::callback_convert_type:: warning: function data type is INVALID!");
  }
  return NULL;
      }

Here is the caller graph for this function:

static GError* kdotp::libmodelxx::continuous_structure::callback_get_material ( structure::material **  location,
double *  values,
int  t,
void *  privdat 
) [static]

Definition at line 55 of file continuous_structure.c++.

References CONTINUOUS_STRUCTURE_GERROR_DOMAIN, kdotp::libmodelxx::continuous_structure::callback_get_material_privdat::mat1, kdotp::libmodelxx::continuous_structure::callback_get_material_privdat::mat2, and kdotp::libmodelxx::continuous_structure::callback_get_material_privdat::mdb.

Referenced by postprocess_structure().

                                                                                                               {
  struct callback_get_material_privdat* p = (struct callback_get_material_privdat*)privdat;
  if(t != 1) {
    return g_error_new(CONTINUOUS_STRUCTURE_GERROR_DOMAIN, 1, "::kdotp::libmodelxx::continuous_structure.c++::callback_get_material: ERROR: I have no idea how to convert a vector to a material composed of (%s) and (%s)!", p->mat1, p->mat2);
  }
  fprintf(stderr, "Got material from function: %s(%g)%s\n", p->mat1, values[0], p->mat2);
  if((values[0] < 0) || (values[0] > 1)) return g_error_new(CONTINUOUS_STRUCTURE_GERROR_DOMAIN, 2, "::kdotp::libmodelxx::continuous_structure.c++::callback_get_material: ERROR: invalid percentage from function (material would be (%s)(%g)(%s))!", p->mat1, values[0], p->mat2);
  location[0] = new structure::material(p->mdb, p->mat1, p->mat2, values[0]);
  if(location[0] == NULL) return g_error_new(CONTINUOUS_STRUCTURE_GERROR_DOMAIN, 3, "::kdotp::libmodelxx::continuous_structure.c++::callback_get_material: ERROR: Error getting material from function: (material would be (%s)(%g)(%s))!", p->mat1, values[0], p->mat2);
  return NULL;
      }

Here is the caller graph for this function:

double kdotp::libmodelxx::continuous_structure::convert_energy_to_hartree ( double  en,
enum energy  unit 
)

converts an energy to hartree

Parameters:
enenergy
unitunits

Definition at line 220 of file continuous_structure.c++.

References ERG, EVOLT, HARTREE, JOULE, and str_from_energy().

Referenced by yyparse().

                                                                    {
  switch(unit) {
  case HARTREE:
    return en;
  case EVOLT:
    return en*3.674932540e-2;
  case JOULE:
    return en*2.29371269e17;
  case ERG:
    /*From wikipedia: 1 erg = 1e-7 J */
    return en*2.29371269e10;
  default:
    fprintf(stderr, "kdotp::libmodelxx::continuous_structure::convert_energy_to_hartree: ERROR while converting units: unknown unit of energy (%s)\n", str_from_energy(unit));
    return nan("NaN");
  }
      }

Here is the call graph for this function:

Here is the caller graph for this function:

double kdotp::libmodelxx::continuous_structure::convert_length_to_nm ( double  len,
enum length  unit 
)

converts a length to nm

Parameters:
lenlength
unitunits

Definition at line 199 of file continuous_structure.c++.

References ANGSTROM, CENTIMETER, METER, MICROMETER, MILLIMETER, NANOMETER, and str_from_length().

Referenced by yyparse().

                                                                {
  switch(unit) {
  case NANOMETER:
    return len;
  case ANGSTROM:
    return len/10.0;
  case MICROMETER:
    return len*1.0e3;
  case MILLIMETER:
    return len*1.0e6;
  case CENTIMETER:
    return len*1.0e7;
  case METER:
    return len*1.0e9;
  default:
    fprintf(stderr, "kdotp::libmodelxx::continuous_structure::convert_length_to_nm: ERROR while converting units: unknown unit of length (%s)\n", str_from_length(unit));
    return nan("NaN");
  }
      }

Here is the call graph for this function:

Here is the caller graph for this function:

enum energy kdotp::libmodelxx::continuous_structure::energy_from_str ( const char *  str)

Gets the energy corresponding to a string

Parameters:
strthe string to convert

Definition at line 176 of file continuous_structure.c++.

References ERG, EVOLT, HARTREE, JOULE, and UNKNOWN_ENERGY.

Referenced by while().

                                                   {
  if(!strcmp(str, "eV")) return EVOLT;
  else if(!strcmp(str, "J")) return JOULE;
  else if(!strcmp(str, "erg")) return ERG;
  else if(!strcmp(str, "Eh")) return HARTREE;
  return UNKNOWN_ENERGY;
      }

Here is the caller graph for this function:

enum length kdotp::libmodelxx::continuous_structure::length_from_str ( const char *  str)

Gets the length corresponding to a string

Parameters:
strthe string to convert

Definition at line 147 of file continuous_structure.c++.

References ANGSTROM, CENTIMETER, METER, MICROMETER, MILLIMETER, NANOMETER, and UNKNOWN_LENGTH.

Referenced by while().

                                                   {
  if(!strcmp(str, "nm")) return NANOMETER;
  else if(!strcmp(str, "A")) return ANGSTROM;
  else if(!strcmp(str, "um")) return MICROMETER;
  else if(!strcmp(str, "mm")) return MILLIMETER;
  else if(!strcmp(str, "cm")) return CENTIMETER;
  else if(!strcmp(str, "m")) return METER;
  return UNKNOWN_LENGTH;
      }

Here is the caller graph for this function:

struct structure::generic_structure * kdotp::libmodelxx::continuous_structure::postprocess_structure ( struct continuous_structure *  s,
const struct structure::matdb *  mdb,
GHashTable *  global_symbol_table,
GError **  err 
) [read]

Processes the structure after it's been read in from a file.*

Parameters:
spointer to the structure from the input file

Definition at line 67 of file continuous_structure.c++.

References callback_convert_type(), callback_get_material(), CONTINUOUS_STRUCTURE_DOMAIN, kdotp::libmodelxx::grid::grid::dimensions, kdotp::libmodelxx::structure::generic_structure::doping_grid, kdotp::libmodelxx::continuous_structure::continuous_structure::dopings, kdp::constants::e, kdotp::libmodelxx::continuous_structure::doping::f, kdotp::libmodelxx::continuous_structure::region::f, kdotp::libmodelxx::postprocessing::function_print_tree(), kdotp::libmodelxx::structure::generic_structure::g, kdotp::libmodelxx::continuous_structure::continuous_structure::g, kdotp::libmodelxx::structure::generic_structure_free(), kdotp::libmodelxx::structure::generic_structure_new(), kdotp::libmodelxx::continuous_structure::region::m, kdotp::libmodelxx::continuous_structure::callback_get_material_privdat::mat1, kdotp::libmodelxx::continuous_structure::region::mat1, kdotp::libmodelxx::continuous_structure::callback_get_material_privdat::mat2, kdotp::libmodelxx::continuous_structure::region::mat2, kdotp::libmodelxx::structure::generic_structure::material_grid, kdotp::libmodelxx::continuous_structure::callback_get_material_privdat::mdb, kdotp::libmodelxx::grid::postprocess_shape_tree(), kdotp::libmodelxx::continuous_structure::continuous_structure::potential, kdotp::libmodelxx::continuous_structure::continuous_structure::regions, kdotp::libmodelxx::grid::set_value_in_grid(), kdotp::libmodelxx::continuous_structure::doping::st, kdotp::libmodelxx::continuous_structure::region::st, kdotp::libmodelxx::grid::grid::t, and kdotp::libmodelxx::continuous_structure::region::x.

Referenced by main().

                                                                                                                                                                                 {
  struct structure::generic_structure* ngs;
  if((ngs = structure::generic_structure_new(s->g)) == NULL) {
    *gerr = g_error_new(CONTINUOUS_STRUCTURE_DOMAIN, 1, "kdotp::libmodelxx::continouous_structure::postprocess_structure: failed to set up new generic structure (got NULL)");
    return NULL;
  }
  int err=0;
  GList* l;
  GError *e = NULL;
  struct region* r;
  int i=0;
  for(l=s->regions; l!=NULL; l=l->next) {
    fprintf(stderr, "region %d:", i);
    r = (struct region*)(l->data);
    if(((r->st)=postprocess_shape_tree(r->st, s->g->dimensions)) == NULL) {
      *gerr = g_error_new(CONTINUOUS_STRUCTURE_DOMAIN, 100+err, "kdotp::libmodelxx::continuous_structure::postprocess_structure failed to set up a region shape tree (error in postprocess_shape_tree (error %d))", err);
      structure::generic_structure_free(ngs);
      return NULL;
    }
    /*Set up the specified material.*/
    if(r->f == NULL) {
      (r->m) = new structure::material(mdb, r->mat1, r->mat2, r->x);
      if((r->m) == NULL) {
        *gerr = g_error_new(CONTINUOUS_STRUCTURE_DOMAIN, 2, "kdotp::libmodelxx::continuous_structure::postprocess_structure failed to set up constat material (%s(%f)%s)", r->mat1, r->x, r->mat2);
        structure::generic_structure_free(ngs);
        return NULL;
      }
      /*Set the material*/
      e = set_value_in_grid(ngs->g->t, ngs->g->dimensions, ngs->material_grid, r->st, r->m, global_symbol_table);
      if(e != NULL) {
        g_propagate_prefixed_error(gerr, e, "kdotp::libmodelxx::continuous_structure.c++::postprocess_structure: got error setting material in grid (mat1=%s mat2=%s x=%f): ", r->mat1, r->mat2, r->x);
      }
    }else{
      GString *s = g_string_new("");
      function_print_tree(r->f, &s, 0);
      fprintf(stderr, "Got r->f tree:%s\n", s->str);
      g_string_free(s, TRUE);
      struct callback_get_material_privdat pd;
      pd.mat1 = r->mat1;
      pd.mat2 = r->mat2;
      pd.mdb = mdb;
      e = set_value_in_grid(ngs->g->t, ngs->g->dimensions, ngs->material_grid, r->st, r->f, global_symbol_table, callback_get_material, &pd);
      if(e != NULL) {
        g_propagate_prefixed_error(gerr, e, "kdotp::libmodelxx::continuous_structure.c++::postprocess_structure: got error setting material in grid with function: ");
      }
    }
    fprintf(stderr, " (set material in grid)");
    i++;
    fprintf(stderr, "\n");
  }
  struct doping *d;
  for(l=s->dopings; l!=NULL; l=l->next) {
    d=(struct doping*)(l->data);
    if(((d->st)=postprocess_shape_tree(d->st, s->g->dimensions)) == NULL) {
      *gerr = g_error_new(CONTINUOUS_STRUCTURE_DOMAIN, 100+err, "kdotp::libmodelxx::continuous_structure::postprocess_structure failed to set up a doping shape tree (error in postprocess_shape_tree (error %d))", err);
      structure::generic_structure_free(ngs);
      return NULL;
    }
    GString *s = g_string_new("");
    function_print_tree(d->f, &s, 0);
    fprintf(stderr, "Got d->f tree:%s\n", s->str);
    g_string_free(s, TRUE);
    e = set_value_in_grid(ngs->g->t, ngs->g->dimensions, ngs->doping_grid, d->st, d->f, global_symbol_table, callback_convert_type, NULL);
    if(e != NULL) {
      g_propagate_prefixed_error(gerr, e, "kdotp::libmodelxx::continuous_structure.c++::postprocess_structure: got error setting doping in grid: ");
    }
  }
  struct potential *p;
  for(l=s->potential; l != NULL; l=l->next) {
    //TODO!!
  }
        return ngs;
      }

Here is the call graph for this function:

Here is the caller graph for this function:

void kdotp::libmodelxx::continuous_structure::print_structure ( const struct continuous_structure *  s)

pretty-prints a processed structure.

Parameters:
spointer to the structure from the input file

Definition at line 141 of file continuous_structure.c++.

                                                                 {
  fprintf(stderr, "================================================================\n");
  fprintf(stderr, "Grid data:\n");
  fprintf(stderr, "Regions:\n");
      }
const char * kdotp::libmodelxx::continuous_structure::str_from_energy ( enum energy  e)

Gets the energy string from an energy

Parameters:
ethe energy

Definition at line 184 of file continuous_structure.c++.

References ERG, EVOLT, HARTREE, and JOULE.

Referenced by convert_energy_to_hartree().

                                                 {
  switch(e) {
  case EVOLT:
    return "eV";
  case JOULE:
    return "J";
  case ERG:
    return "erg";
  case HARTREE:
    return "Eh";
  default:
    return "<unknown unit of energy>";
  }
      }

Here is the caller graph for this function:

const char * kdotp::libmodelxx::continuous_structure::str_from_length ( enum length  l)

Gets the length string from a length

Parameters:
lthe length

Definition at line 157 of file continuous_structure.c++.

References ANGSTROM, CENTIMETER, METER, MICROMETER, MILLIMETER, and NANOMETER.

Referenced by convert_length_to_nm().

                                                 {
  switch(l) {
  case NANOMETER:
    return "nm";
  case ANGSTROM:
    return "A";
  case MICROMETER:
    return "um";
  case MILLIMETER:
    return "mm";
  case CENTIMETER:
    return "cm";
  case METER:
    return "m";
  default:
    return "<unknown unit of length>";
  }
      }

Here is the caller graph for this function:

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines