|
k-dot-p 0.1
|
#include <material.h++>
Public Member Functions | |
| material (const struct matdb *mdb, const char *mat1, const char *mat2, double x) | |
| char * | get_name () |
| double | get_property (const char *ppt, int *err) |
| double | get_property (int ppt) |
| int | get_property_index (const char *ppt, int *err) |
| bool | operator== (const material &m2) |
| bool | operator!= (const material &m2) |
| bool | lenient_equals (const material &m2, double tolerance=1e-10) |
Public Attributes | |
| char * | matname1 |
| char * | matname2 |
| double | m_x |
| double * | indexed_properties |
| GHashTable * | property_indices |
| GHashTable * | properties |
Private Member Functions | |
| material () | |
Definition at line 35 of file material.h++.
| kdotp::libmodelxx::structure::material::material | ( | const struct matdb * | mdb, |
| const char * | mat1, | ||
| const char * | mat2, | ||
| double | x | ||
| ) |
Definition at line 55 of file material.c++.
References kdotp::libmodelxx::structure::get_material(), kdotp::libmodelxx::structure::index_properties(), indexed_properties, m_x, matname1, matname2, properties, and property_indices.
{
properties = get_material(mdb, mat1, mat2, x);
/*Kick out if the material specified doesn't exist.*/
if(properties == NULL) {
fprintf(stderr, "ERROR in material consturctor: unable to get properties for material: %s/%g/%s\n", mat1, x, mat2);
return;
}
int ptsize = g_hash_table_size(properties);
indexed_properties = (double*)malloc(ptsize*sizeof(double));
property_indices = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
struct index_struct idxs = {indexed_properties, property_indices, 0};
/*Now we go ahead and set up the indexed hash*/
//g_hash_table_foreach(properties, print_property, NULL);
if(properties == NULL) {
fprintf(stderr, "material::material: properties is NULL!\n");
}
if(property_indices == NULL) {
fprintf(stderr, "material::material: property_indices is NULL!\n");
}
g_hash_table_foreach(properties, index_properties, &idxs);
//g_hash_table_foreach(properties, print_property, NULL);
matname1 = g_strdup(mat1);
matname2 = g_strdup(mat2);
m_x = x;
}
Here is the call graph for this function:| kdotp::libmodelxx::structure::material::material | ( | ) | [inline, private] |
Definition at line 71 of file material.h++.
{}
| char * kdotp::libmodelxx::structure::material::get_name | ( | ) |
Definition at line 110 of file material.c++.
References kdp::constants::c, m_x, matname1, and matname2.
Referenced by kdotp::libkdotp::hamiltonian::cartesian_8band::cartesian_8band(), and kdotp::libkdotp::hamiltonian::store_reduced_material_parameters().
{
GString* s = g_string_new("");
if(matname2 != NULL) {
g_string_printf(s, "%s(%f)%s", matname1, m_x, matname2);
}else{
g_string_printf(s, "%s", matname1);
}
char *c = s->str;
g_string_free(s, FALSE);
return c;
}
Here is the caller graph for this function:| double kdotp::libmodelxx::structure::material::get_property | ( | const char * | ppt, |
| int * | err | ||
| ) |
Gets a property for this material. If you need speed, use the int version.
| ppt | property name |
| err | pointer to int to store the error code |
Definition at line 81 of file material.c++.
References properties.
Referenced by kdotp::libkdotp::hamiltonian::cartesian_8band::cartesian_8band(), kdotp::libkdotp::hamiltonian::cartesian_effective_mass::cartesian_effective_mass(), and kdotp::libkdotp::hamiltonian::store_reduced_material_parameters().
{
//fprintf(stderr, "Looking up property %s: ", ppt);
if(properties == NULL) {
fprintf(stderr, "Error getting property %s: properties is NULL!!\n", ppt);
return nan("NaN");
}
double* match = (double*)g_hash_table_lookup(properties, ppt);
if(match == NULL) {
//fprintf(stderr, "FAILED\n");
*err = 1;
return nan("NaN");
}
//fprintf(stderr, "%g\n", *match);
*err = 0;
return *match;
}
Here is the caller graph for this function:| double kdotp::libmodelxx::structure::material::get_property | ( | int | ppt | ) | [inline] |
Definition at line 50 of file material.h++.
References indexed_properties.
{return indexed_properties[ppt];}
| int kdotp::libmodelxx::structure::material::get_property_index | ( | const char * | ppt, |
| int * | err | ||
| ) |
Definition at line 99 of file material.c++.
References property_indices.
{
if(property_indices == NULL) {
return -2;
}
int* i = (int*)g_hash_table_lookup(property_indices, ppt);
if(i == NULL) {*err = 1; return -1;}
*err = 0;
return *i;
}
| bool kdotp::libmodelxx::structure::material::lenient_equals | ( | const material & | m2, |
| double | tolerance = 1e-10 |
||
| ) |
compares two materials like the operator, but uses a tolerance to compare the percentage of material1.
Definition at line 142 of file material.c++.
| bool kdotp::libmodelxx::structure::material::operator!= | ( | const material & | m2 | ) |
| bool kdotp::libmodelxx::structure::material::operator== | ( | const material & | m2 | ) |
comparison operator for material classes
Definition at line 127 of file material.c++.
Definition at line 56 of file material.h++.
Referenced by get_property(), and material().
Definition at line 54 of file material.h++.
Referenced by get_name(), lenient_equals(), material(), operator!=(), kdotp::libmodelxx::structure::operator!=(), operator==(), and kdotp::libmodelxx::structure::operator==().
Definition at line 52 of file material.h++.
Referenced by get_name(), lenient_equals(), material(), operator!=(), kdotp::libmodelxx::structure::operator!=(), operator==(), and kdotp::libmodelxx::structure::operator==().
Definition at line 53 of file material.h++.
Referenced by get_name(), lenient_equals(), material(), operator!=(), kdotp::libmodelxx::structure::operator!=(), operator==(), and kdotp::libmodelxx::structure::operator==().
Definition at line 60 of file material.h++.
Referenced by get_property(), and material().
Definition at line 58 of file material.h++.
Referenced by get_property_index(), and material().