ViennaSHE 1.3.0
Free open-source semiconductor device simulator using spherical harmonics expansions techniques.
resistor1d-c.c
Go to the documentation of this file.
1/* ============================================================================
2 Copyright (c) 2011-2022, Institute for Microelectronics,
3 Institute for Analysis and Scientific Computing,
4 TU Wien.
5
6 -----------------
7 ViennaSHE - The Vienna Spherical Harmonics Expansion Boltzmann Solver
8 -----------------
9
10 http://viennashe.sourceforge.net/
11
12 License: MIT (X11), see file LICENSE in the base directory
13=============================================================================== */
14
17#include <stdio.h>
18#include <stdlib.h>
19
20/* Main include for libviennashe */
21#include "../../libviennashe/include/libviennashe.h"
22
23/* Definition of true and false */
24#define FALSE libviennashe_false
25#define TRUE libviennashe_true
26
27/* Define the number of points to use for the resistor */
28#define POINTSX 51
29
32{
33 /* Initialize the variables */
34 char ** names = NULL;
35 viennashe_index_type num_quan = 0;
37
38 /* Get the number of available quantities */
40 printf("Number of Quanitites: %ld\n", num_quan);
41
42 /* Retrieve the quantity names */
43 names = (char**)malloc(sizeof(char*) * num_quan);
45
46 /* Print the names on stdout */
47 printf("#############################\n");
48 for (i = 0; i < num_quan; ++i)
49 {
50 printf("%3ld: '%s'\n", i, names[i]);
51 free(names[i]);
52 }
53 printf("#############################\n");
54
55 /* Do not forget: Free memory! */
56 free(names); names = NULL;
57}
58
61{
62 /* Initialize the variables */
64 viennashe_index_type * len = NULL;
65 double ** values = NULL;
69
70 /* First check if there is a quantity named "Electrostatic potential" */
71 viennashe_has_cell_based_quantity(reg, "Electrostatic potential", &check);
72 if(check)
73 {
74 /* Get the number of cells to preallocate memory */
76
77 /* Allocate memory to hold all the values */
79
80 /* Retrieve the values */
81 viennashe_get_cell_based_quantity(reg, "Electrostatic potential", values, len);
82
83 /* Print the values to stdout */
84 for ( i = 0; i < num_cells; ++i)
85 {
86 printf("%2ld => ", i);
87 for ( j = 0; j < len[i]; ++j)
88 {
89 printf("%e", values[i][j]);
90 }
91 printf("\n");
92 }
93
94 /* Free previously allocated memory */
96 }
97 else
98 {
99 /* If there is no electrostatic potential print an error message */
100 printf("Unable to find the electrostatic potential by name ('Electrostatic potential') !\n");
101 }
102}
103
104
105/*
106 *
107 */
108int main()
109{
110 /* Prealloc needed variables */
111 const double len_x = 1e-6;
112 const long points_x = POINTSX;
113
114 /* Material and doping */
116 double Nd[POINTSX-1];
117 double Na[POINTSX-1];
118 /* Array of cell ids on which to set boundary potentials */
119 viennashe_index_type bnd_cells[] = { 0, 49 };
120 /* Array of boundary potentials */
121 double bnd_pot[] = { 0.0, 1.0 };
122 long i = 0;
123
124 /* Handles */
125 viennashe_device dev = NULL;
126 viennashe_config conf = NULL;
127 viennashe_simulator sim = NULL;
131
132 /* Init arrays */
135
136 Nd[0] = 0;
137 Nd[points_x-2] = 0;
138 Na[0] = 0;
139 Na[points_x-2] = 0;
140
141 for (i = 1; i < points_x - 1; i++)
142 {
144 Na[i] = 1e7;
145 Nd[i] = 1e25;
146 }
147 /* +++++++++++ */
148
149 /* Init ViennaSHE */
151
152 /* Create device */
154
155 /* Init the device */
158
159 /* Create the simulator configuration */
161
162 /* Apply standard DD configuration */
165
166 /* Get the simulator instance */
168
169 /* This is DD, so we do not need to give any inital guess */
170 /* RUN! */
172
174
176
177 /* print_potential(dom, reg); */
178
179 /* Write solution to CSV files for gnuplot */
180 viennashe_write_to_gnuplot(reg, "Electrostatic potential", "potential_dd.dat");
181 viennashe_write_to_gnuplot(reg, "Electron density", "n_dd.dat");
182 viennashe_write_to_gnuplot(reg, "Hole density", "p_dd.dat");
183
184 /* Free the quantity register */
186
187 /* A single SHE postprocessing step */
189
190 /* Bipolar SHE (n and p) */
193
194 /* Get the simulator instance */
195 viennashe_create_simulator(&sim, dev, conf);
196
197 /* Transfer DD solution as init guess to SHE */
199
200 /* Free memory */
203
204 /* RUN SHE! */
205 viennashe_run(sim);
206
207 /* Get the quantity register for the SHE-simulator */
209
210 /* Print some info */
212
213 /* Write pot, n and p to CSV files for gnuplot */
214 viennashe_write_to_gnuplot(reg, "Electrostatic potential", "potential_she.dat");
215 viennashe_write_to_gnuplot(reg, "Electron density", "n_she.dat");
216 viennashe_write_to_gnuplot(reg, "Hole density", "p_she.dat");
217 /* Write the complete SHE result */
220 /* Write the average carrier energy to file */
221 viennashe_write_to_gnuplot(reg, "Average electron energy SHE", "n_energy.dat");
222
223 /* Free memory */
225 viennashe_free_simulator(sim); sim = NULL;
226 viennashe_free_config(conf); conf = NULL;
228
230
231 return (EXIT_SUCCESS);
232}
233
VIENNASHE_EXPORT viennasheErrorCode viennashe_free_config(viennashe_config conf)
@ viennashe_nonlinear_solver_gummel
Definition: config.h:38
VIENNASHE_EXPORT viennasheErrorCode viennashe_config_standard_dd(viennashe_config conf)
VIENNASHE_EXPORT viennasheErrorCode viennashe_set_nonlinear_solver_config(viennashe_config conf, viennashe_nonlinear_solver_id sol_id, long max_iters, double damping)
VIENNASHE_EXPORT viennasheErrorCode viennashe_config_she_bipolar(viennashe_config conf, libviennashe_bool with_traps)
VIENNASHE_EXPORT viennasheErrorCode viennashe_create_config(viennashe_config *conf)
viennashe_config_impl * viennashe_config
Definition: config.h:31
VIENNASHE_EXPORT viennasheErrorCode viennashe_free_device(viennashe_device dev)
VIENNASHE_EXPORT viennasheErrorCode viennashe_set_contact_potential_cells(viennashe_device dev, viennashe_index_type *cell_ids, double *values, viennashe_index_type len)
VIENNASHE_EXPORT viennasheErrorCode viennashe_create_1d_device(viennashe_device *dev, double len_x, size_t points_x)
VIENNASHE_EXPORT viennasheErrorCode viennashe_get_num_cells(viennashe_device dev, viennashe_index_type *num)
VIENNASHE_EXPORT viennasheErrorCode viennashe_initalize_device(viennashe_device dev, viennashe_material_id *material_ids, double *doping_n, double *doping_p)
VIENNASHE_EXPORT viennasheErrorCode viennashe_finalize(void)
Finalizes ViennaSHE.
VIENNASHE_EXPORT viennasheErrorCode viennashe_initalize(void)
Initializes ViennaSHE. To be called before ViennaSHE is used.
long viennashe_material_id
Definition: material.h:26
VIENNASHE_EXPORT viennasheErrorCode viennashe_get_metal_id(viennashe_material_id *id)
VIENNASHE_EXPORT viennasheErrorCode viennashe_get_silicon_id(viennashe_material_id *id)
int points_x
Definition: resistor.py:39
conf_dd
Create the simulator configuration.
Definition: resistor.py:72
list Nd
Definition: resistor.py:59
list bnd_cells
Definition: resistor.py:64
sim_dd
Apply standard DD configuration.
Definition: resistor.py:79
int len_x
Definition: resistor.py:38
list bnd_pot
Definition: resistor.py:65
reg
This is DD, so we do not need to give any inital guess.
Definition: resistor.py:84
list matids
Definition: resistor.py:54
VIENNASHE_EXPORT viennasheErrorCode viennashe_write_to_gnuplot(viennashe_quan_register reg, char const *name, char const *filename)
VIENNASHE_EXPORT viennasheErrorCode viennashe_write_she_results_to_gnuplot(viennashe_quan_register reg, viennashe_carrier_ids ctype, char const *filename)
viennashe_quan_register_impl * viennashe_quan_register
Definition: quantity.h:31
VIENNASHE_EXPORT viennasheErrorCode viennashe_free_quantity_register(viennashe_quan_register reg)
VIENNASHE_EXPORT viennasheErrorCode viennashe_has_cell_based_quantity(viennashe_quan_register reg, char const *name, libviennashe_bool *exists)
VIENNASHE_EXPORT viennasheErrorCode viennashe_create_quantity_register(viennashe_quan_register *reg, viennashe_simulator sim)
VIENNASHE_EXPORT viennasheErrorCode viennashe_get_cell_based_quantity_list(viennashe_quan_register reg, char **names)
VIENNASHE_EXPORT viennasheErrorCode viennashe_get_cell_based_quantity(viennashe_quan_register reg, char const *name, double **values, viennashe_index_type *len)
VIENNASHE_EXPORT viennasheErrorCode viennashe_prealloc_cell_based_quantity(viennashe_device dev, double ***uarray, viennashe_index_type **len)
@ viennashe_hole_id
Definition: quantity.h:34
@ viennashe_electron_id
Definition: quantity.h:34
VIENNASHE_EXPORT viennasheErrorCode viennashe_free_cell_based_quantity(viennashe_device dev, double ***uarray, viennashe_index_type **len)
VIENNASHE_EXPORT viennasheErrorCode viennashe_get_num_cell_based(viennashe_quan_register reg, viennashe_index_type *num)
void print_quan_info(viennashe_quan_register reg)
Prints the names of the available quantities in a register
Definition: resistor1d-c.c:31
#define POINTSX
Definition: resistor1d-c.c:28
void print_potential(viennashe_device dev, viennashe_quan_register reg)
Prints the electrostatic potential profile to stdout
Definition: resistor1d-c.c:60
#define FALSE
Definition: resistor1d-c.c:24
int main()
Definition: resistor1d-c.c:108
VIENNASHE_EXPORT viennasheErrorCode viennashe_run(viennashe_simulator sim)
VIENNASHE_EXPORT viennasheErrorCode viennashe_set_initial_guess_from_other_sim(viennashe_simulator sim, viennashe_simulator other_sim)
VIENNASHE_EXPORT viennasheErrorCode viennashe_free_simulator(viennashe_simulator sim)
VIENNASHE_EXPORT viennasheErrorCode viennashe_create_simulator(viennashe_simulator *sim, viennashe_device dev, viennashe_config conf)
Internal C++ to C wrapper for the device. Has typedefs and destructor.
Internal C++ to C wrapper for the simulator. Has typedefs and destructor.
libviennashe_bool
Definition: sys.h:31
unsigned long viennashe_index_type
Definition: sys.h:42