|
gimme-alpha 0.1
|
#include <stdio.h>#include <stdlib.h>#include <glib.h>#include <gio/gio.h>#include <math.h>#include <libcommon/gimme_alpha_types.h>#include <gimmeprogs/process-average-efield-args.h>#include <libnextnano/read_nextnano_inputfile.h>#include <libnextnano/read_nextnano_effectivemass_output.h>#include <libnextnano/read_nextnano_bandstructure.h>#include <libnextnano/read_nextnano_8x8kp_output.h>#include <libcommon/gimme-alpha_structs.h>#include <libpostproccalx/alpha_calc.h>#include <libmodeling/wavefunction.h>
Include dependency graph for average_efield.c:Go to the source code of this file.
Functions | |
| int | main (int argc, char *argv[]) |
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 42 of file average_efield.c.
References average_discrete_function(), args::base_dirs, CB, mstar_wavefunction_1d_free(), NEU, args::no_print_integration_error, POTENTIAL_FILE, process_args(), read_effectivemass_complex_wavefunction2(), read_nextnano_bandstructure_file(), read_nextnano_dbfile2(), read_nextnano_inputfile2(), read_nextnano_keyfile2(), args::request_integration_abs_error, args::request_integration_rel_error, and unlikely.
{
g_type_init();
GFile* pwd = g_file_new_for_commandline_arg(".");
struct args* arg = process_args(argc, argv);
if(arg == NULL) return 2;
GList *l = g_list_first(arg->base_dirs);
GList *p;
GError *err = NULL;
char* filename = NULL;
for(p=l; p!= NULL; p=g_list_next(p)) {
err = NULL;
GFile* bd = (GFile*)(p->data);
GHashTable *keys = read_nextnano_keyfile2(bd, &err);
if(unlikely((err != NULL) || (keys == NULL))) {
char* bdi = g_file_get_uri(bd);
g_warning("average_efield.c::main: error reading keys (%s/keywords.in): %s", bdi, err->message);
free(bdi);
if(keys != NULL) g_hash_table_destroy(keys);
continue;
}
GHashTable *db = read_nextnano_dbfile2(bd, &err);
if(unlikely((err != NULL) || (keys == NULL))) {
char* bdi = g_file_get_uri(bd);
g_warning("average_efield.c::main: error reading database (%s/database.in): %s", bdi, err->message);
free(bdi);
g_hash_table_destroy(keys);
if(db != NULL) g_hash_table_destroy(db);
continue;
}
GHashTable *infile = read_nextnano_inputfile2(bd, keys, 1, &err, &filename);
if(unlikely((err != NULL) || (keys == NULL))) {
char* bdi = g_file_get_uri(bd);
g_warning("average_efield.c::main: error reading input file %d (%s) (basedir: %s): %s", 1, filename, bdi, err->message);
free(bdi);
g_hash_table_destroy(keys);
g_hash_table_destroy(db);
if(infile != NULL) g_hash_table_destroy(infile);
continue;
}
struct mstar_wavefunction_1d* wf = read_effectivemass_complex_wavefunction2(CB, 1, 1, 1, NEU, 1, 1, bd, infile, &err);
if(unlikely((err != NULL) || (wf == NULL))) {
char* bdi = g_file_get_uri(bd);
g_warning("average_efield.c::main: error reading wavefunction solution %d (basedir: %s): %s", 1, bdi, err->message);
free(bdi);
g_hash_table_destroy(keys);
g_hash_table_destroy(db);
g_hash_table_destroy(infile);
if(wf != NULL) mstar_wavefunction_1d_free(wf);
continue;
}
double* pot_x = NULL;
int pot_N;
double* pot = read_nextnano_bandstructure_file(POTENTIAL_FILE, bd, infile, &err, &pot_x, &pot_N);
if(unlikely((err != NULL) || (wf == NULL))) {
char* bdi = g_file_get_uri(bd);
g_warning("average_efield.c::main: error reading potential (basedir: %s): %s", bdi, err->message);
free(bdi);
g_hash_table_destroy(keys);
g_hash_table_destroy(db);
g_hash_table_destroy(infile);
mstar_wavefunction_1d_free(wf);
if(pot_x != NULL) free(pot_x);
if(pot != NULL) free(pot);
continue;
}
double err;
double val = average_discrete_function(pot, pot_x, pot_N, wf, 1, arg->request_integration_abs_error, arg->request_integration_rel_error, &err);
printf("%g\n", val);
if(!(arg->no_print_integration_error)) {
printf("%g\n", err);
}else{
printf("\n");
}
free(pot_x);
free(pot);
mstar_wavefunction_1d_free(wf);
g_hash_table_destroy(keys);
g_hash_table_destroy(db);
g_hash_table_destroy(infile);
}
return 0;
}
Here is the call graph for this function: