ViennaSHE 1.3.0
Free open-source semiconductor device simulator using spherical harmonics expansions techniques.
config.cpp
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 * s
10 http://viennashe.sourceforge.net/
11
12 License: MIT (X11), see file LICENSE in the base directory
13=============================================================================== */
14
15// C++ includes
16#include "viennashe_all.hpp"
17
18// C includes
20
21
22#ifndef __FUNCTION_NAME__
23 #define LIBVIENNASHE_FUNCTION_NAME_MARKER
24 #ifdef WIN32 // WINDOWS
25 #define __FUNCTION_NAME__ __FUNCTION__
26 #else // UNIX
27 #define __FUNCTION_NAME__ __func__
28 #endif
29#endif
30
31/* DEFINE THE CONFIG GETTER - Undefined at the end of this file */
32#define LIBVIENNASHE_CONFIG_GETTER(conf, retval, func_name, code) try { if ((conf) == NULL) \
33 { \
34 viennashe::log::error() << "ERROR! " << (func_name) << "(): config must not be NULL! " << std::endl; return 1; \
35 } \
36 if ((retval) == NULL) \
37 { \
38 viennashe::log::error() << "ERROR! " << (func_name) << "(): The return pointer must not be NULL! " << std::endl; return 2; \
39 } \
40 viennashe::config * int_conf = reinterpret_cast<viennashe::config *>((conf)); \
41 code; \
42 } catch(...) {\
43 viennashe::log::error() << "ERROR! " << (func_name) << "(): UNKOWN ERROR!" << std::endl; return -1;\
44 } return 0;
45
46#ifdef __cplusplus
47extern "C"
48{
49#endif
50
56{
57 try
58 {
59 // Create the config
60 viennashe::config * int_conf = new viennashe::config();
61 // RETURN
62 *conf = reinterpret_cast<viennashe_config>(int_conf);
63 }
64 catch(...)
65 {
66 viennashe::log::error() << "ERROR! create_config(): UNKOWN ERROR!" << std::endl;
67 return -1;
68 }
69 return 0;
70}
71
78{
79 try
80 {
81 if (conf != NULL)
82 {
83 delete reinterpret_cast<viennashe::config *>(conf);
84 }
85 }
86 catch(...)
87 {
88 viennashe::log::error() << "ERROR! free_config(): UNKOWN ERROR!" << std::endl;
89 return -1;
90 }
91 return 0;
92}
93
100{
101 try
102 {
103 CHECK_ARGUMENT_FOR_NULL(conf,1,"conf");
104 viennashe::config * int_conf = reinterpret_cast<viennashe::config *>(conf);
105
106 int_conf->with_electrons(true);
107 int_conf->with_holes(true);
108 int_conf->with_traps(false);
111 int_conf->quantum_correction(false);
112 int_conf->with_quantum_correction(false);
113
114 }
115 catch(...)
116 {
117 viennashe::log::error() << "ERROR! config_standard_dd(): UNKOWN ERROR!" << std::endl;
118 return -1;
119 }
120 return 0;
121}
122
130{
131 try
132 {
133 CHECK_ARGUMENT_FOR_NULL(conf,1,"conf");
134 viennashe::config * int_conf = reinterpret_cast<viennashe::config *>(conf);
135 int_conf->with_electrons(true);
136 int_conf->with_holes(true);
137
138 if (with_traps) int_conf->with_traps(true);
139 else int_conf->with_traps(false);
140
143 //int_conf->quantum_correction(false);
144 //int_conf->with_quantum_correction(false);
145 }
146 catch(...)
147 {
148 viennashe::log::error() << "ERROR! config_she_bipolar(): UNKOWN ERROR!" << std::endl;
149 return -1;
150 }
151 return 0;
152}
153
160{
161 try
162 {
163 CHECK_ARGUMENT_FOR_NULL(conf,1,"conf");
164 viennashe::config * int_conf = reinterpret_cast<viennashe::config *>(conf);
165 int_conf->with_electrons(true);
166 int_conf->with_holes(true);
167
168 int_conf->with_traps(false);
169
172 //int_conf->quantum_correction(false);
173 //int_conf->with_quantum_correction(false);
174 }
175 catch(...)
176 {
177 viennashe::log::error() << "ERROR! config_she_unipolar_n(): UNKOWN ERROR!" << std::endl;
178 return -1;
179 }
180 return 0;
181}
182
189{
190 try
191 {
192 CHECK_ARGUMENT_FOR_NULL(conf,1,"conf");
193 viennashe::config * int_conf = reinterpret_cast<viennashe::config *>(conf);
194 int_conf->with_electrons(true);
195 int_conf->with_holes(true);
196
197 int_conf->with_traps(false);
198
201 //int_conf->quantum_correction(false);
202 //int_conf->with_quantum_correction(false);
203 }
204 catch(...)
205 {
206 viennashe::log::error() << "ERROR! config_she_unipolar_p(): UNKOWN ERROR!" << std::endl;
207 return -1;
208 }
209 return 0;
210}
211
218{
219 try
220 {
221 CHECK_ARGUMENT_FOR_NULL(conf,1,"conf");
222 viennashe::config * int_conf = reinterpret_cast<viennashe::config *>(conf);
223 int_conf->quantum_correction(true);
224 int_conf->with_quantum_correction(true);
225 }
226 catch(...)
227 {
228 viennashe::log::error() << "ERROR! config_enable_density_gradient(): UNKOWN ERROR!" << std::endl;
229 return -1;
230 }
231 return 0;
232}
233
240{
241 try
242 {
243 CHECK_ARGUMENT_FOR_NULL(conf,1,"conf");
244 viennashe::config * int_conf = reinterpret_cast<viennashe::config *>(conf);
245 int_conf->quantum_correction(false);
246 int_conf->with_quantum_correction(false);
247 }
248 catch(...)
249 {
250 viennashe::log::error() << "ERROR! config_enable_density_gradient(): UNKOWN ERROR!" << std::endl;
251 return -1;
252 }
253 return 0;
254}
255
264{
265 try
266 {
267 CHECK_ARGUMENT_FOR_NULL(conf,1,"conf");
268 if (max_iters <= 0)
269 {
270 viennashe::log::error() << "ERROR! set_linear_solver_config(): max_iters must be greater zero. max_iters = " << max_iters << std::endl;
271 return 3;
272 }
273
274 viennashe::config * int_conf = reinterpret_cast<viennashe::config *>(conf);
275 switch(sol_id)
276 {
279 break;
282 break;
285 break;
288 break;
289 default:
290 viennashe::log::error() << "ERROR! set_linear_solver_config(): sol_id must be a valid solver id!" << std::endl;
291 return 2;
292 }
293 int_conf->linear_solver().max_iters(static_cast<std::size_t>(max_iters));
294 }
295 catch(...)
296 {
297 viennashe::log::error() << "ERROR! set_linear_solver_config(): UNKOWN ERROR!" << std::endl;
298 return -1;
299 }
300 return 0;
301}
302
312{
313 try
314 {
315 CHECK_ARGUMENT_FOR_NULL(conf,1,"conf");
316 if (max_iters <= 0)
317 {
318 viennashe::log::error() << "ERROR! set_nonlinear_solver_config(): max_iters must be greater zero. max_iters = " << max_iters << std::endl;
319 return 3;
320 }
321 if (damping <= 0 || damping > 1)
322 {
323 viennashe::log::error() << "ERROR! set_nonlinear_solver_config(): damping must be in (0,1]. damping = " << damping << std::endl;
324 return 4;
325 }
326
327 viennashe::config * int_conf = reinterpret_cast<viennashe::config *>(conf);
328 switch(sol_id)
329 {
332 break;
335 break;
336 default:
337 viennashe::log::error() << "ERROR! set_nonlinear_solver_config(): sol_id must be a valid solver id!" << std::endl;
338 return 2;
339 }
340 int_conf->nonlinear_solver().max_iters(static_cast<std::size_t>(max_iters));
341 int_conf->nonlinear_solver().damping(damping);
342
343 }
344 catch(...)
345 {
346 viennashe::log::error() << "ERROR! set_nonlinear_solver_config(): UNKOWN ERROR!" << std::endl;
347 return -1;
348 }
349 return 0;
350}
351
352
354{
355 try
356 {
357 CHECK_ARGUMENT_FOR_NULL(conf,1,"conf");
358 viennashe::config * int_conf = reinterpret_cast<viennashe::config *>(conf);
359 int_conf->with_traps((enabled != 0) ? true : false);
360 }
361 catch(...)
362 {
363 viennashe::log::error() << "ERROR! viennashe_config_with_traps(): UNKOWN ERROR!" << std::endl;
364 return -1;
365 }
366 return 0;
367}
368
369
371{
372 try
373 {
374 CHECK_ARGUMENT_FOR_NULL(conf,1,"conf");
375 viennashe::config * int_conf = reinterpret_cast<viennashe::config *>(conf);
376 int_conf->scattering().optical_phonon().enabled((enabled != 0) ? true : false);
377 }
378 catch(...)
379 {
380 viennashe::log::error() << "ERROR! viennashe_set_optical_phonon_scattering(): UNKOWN ERROR!" << std::endl;
381 return -1;
382 }
383 return 0;
384}
385
387{
388 try
389 {
390 CHECK_ARGUMENT_FOR_NULL(conf,1,"conf");
391 viennashe::config * int_conf = reinterpret_cast<viennashe::config *>(conf);
392 int_conf->scattering().acoustic_phonon().enabled((enabled != 0) ? true : false);
393 }
394 catch(...)
395 {
396 viennashe::log::error() << "ERROR! viennashe_set_acoustic_phonon_scattering(): UNKOWN ERROR!" << std::endl;
397 return -1;
398 }
399 return 0;
400}
401
403{
404 try
405 {
406 CHECK_ARGUMENT_FOR_NULL(conf,1,"conf");
407 viennashe::config * int_conf = reinterpret_cast<viennashe::config *>(conf);
408 int_conf->scattering().ionized_impurity().enabled((enabled != 0) ? true : false);
409 }
410 catch(...)
411 {
412 viennashe::log::error() << "ERROR! viennashe_set_ionized_impurity_scattering(): UNKOWN ERROR!" << std::endl;
413 return -1;
414 }
415 return 0;
416}
417
419{
420 try
421 {
422 CHECK_ARGUMENT_FOR_NULL(conf,1,"conf");
423 viennashe::config * int_conf = reinterpret_cast<viennashe::config *>(conf);
424 int_conf->scattering().impact_ionization().enabled((enabled != 0) ? true : false);
425 }
426 catch(...)
427 {
428 viennashe::log::error() << "ERROR! viennashe_set_impact_ionization_scattering(): UNKOWN ERROR!" << std::endl;
429 return -1;
430 }
431 return 0;
432}
433
435{
436 try
437 {
438 CHECK_ARGUMENT_FOR_NULL(conf,1,"conf");
439 viennashe::config * int_conf = reinterpret_cast<viennashe::config *>(conf);
440 int_conf->scattering().electron_electron((enabled != 0) ? true : false);
441 }
442 catch(...)
443 {
444 viennashe::log::error() << "ERROR! viennashe_set_electron_electron_scattering(): UNKOWN ERROR!" << std::endl;
445 return -1;
446 }
447 return 0;
448}
449
450
451
452/* +++++++++++++++ GETTER +++++++++++++++ */
453
455{
456LIBVIENNASHE_CONFIG_GETTER(conf, enabled, __FUNCTION_NAME__, *enabled = int_conf->scattering().optical_phonon().enabled() ? libviennashe_true : libviennashe_false)
457}
458
460{
461LIBVIENNASHE_CONFIG_GETTER(conf, enabled, __FUNCTION_NAME__, *enabled = int_conf->scattering().acoustic_phonon().enabled() ? libviennashe_true : libviennashe_false)
462}
463
465{
466LIBVIENNASHE_CONFIG_GETTER(conf, enabled, __FUNCTION_NAME__, *enabled = int_conf->scattering().ionized_impurity().enabled() ? libviennashe_true : libviennashe_false)
467}
468
470{
471LIBVIENNASHE_CONFIG_GETTER(conf, enabled, __FUNCTION_NAME__, *enabled = int_conf->scattering().impact_ionization().enabled() ? libviennashe_true : libviennashe_false)
472}
473
475{
476LIBVIENNASHE_CONFIG_GETTER(conf, enabled, __FUNCTION_NAME__, *enabled = int_conf->scattering().electron_electron() ? libviennashe_true : libviennashe_false)
477}
478
480{
481LIBVIENNASHE_CONFIG_GETTER(conf, enabled, __FUNCTION_NAME__, *enabled = int_conf->with_traps() ? libviennashe_true : libviennashe_false)
482}
483
485{
486LIBVIENNASHE_CONFIG_GETTER(conf, enabled, __FUNCTION_NAME__, *enabled = ((int_conf->quantum_correction() && int_conf->with_quantum_correction()) ? libviennashe_true : libviennashe_false) )
487}
488
490{
491 try
492 {
493 CHECK_ARGUMENT_FOR_NULL(conf,1,"conf");
494 CHECK_ARGUMENT_FOR_NULL(sol_id,2,"sol_id");
495 CHECK_ARGUMENT_FOR_NULL(max_iters,3,"max_iters");
496
497 viennashe::config * int_conf = reinterpret_cast<viennashe::config *> ((conf));
502
503 *max_iters = static_cast<long>(int_conf->linear_solver().max_iters());
504
505 }
506 catch (...)
507 {
508 viennashe::log::error() << "ERROR! viennashe_get_linear_solver_config(): UNKOWN ERROR!" << std::endl;
509 return -1;
510 }
511 return 0;
512}
513
515{
516 try
517 {
518 CHECK_ARGUMENT_FOR_NULL(conf,1,"conf");
519 CHECK_ARGUMENT_FOR_NULL(sol_id,2,"sol_id");
520 CHECK_ARGUMENT_FOR_NULL(max_iters,3,"max_iters");
521 CHECK_ARGUMENT_FOR_NULL(damping,4,"damping");
522
523 viennashe::config * int_conf = reinterpret_cast<viennashe::config *> ((conf));
526
527 *max_iters = static_cast<long>(int_conf->nonlinear_solver().max_iters());
528 *damping = int_conf->nonlinear_solver().damping();
529
530 }
531 catch (...)
532 {
533 viennashe::log::error() << "ERROR! viennashe_get_nonlinear_solver_config(): UNKOWN ERROR!" << std::endl;
534 return -1;
535 }
536 return 0;
537}
538
539
540#ifdef __cplusplus
541}
542#endif
543
544/* UNDEFINE THE CONFIG GETTER */
545#undef LIBVIENNASHE_CONFIG_GETTER
546
547#ifdef LIBVIENNASHE_FUNCTION_NAME_MARKER
548#undef __FUNCTION_NAME__
549#undef LIBVIENNASHE_FUNCTION_NAME_MARKER
550#endif
551
The main SHE configuration class. To be adjusted by the user for his/her needs.
Definition: config.hpp:124
bool with_holes() const
Returns true if holes are considered in the simulation.
Definition: config.hpp:234
bool quantum_correction() const
Definition: config.hpp:509
bool with_traps() const
Returns true if traps are considered in the simulation.
Definition: config.hpp:243
nonlinear_solver_config_type & nonlinear_solver()
Returns the configuration object for the nonlinear solver.
Definition: config.hpp:495
void set_electron_equation(equation_id equ_id)
Definition: config.hpp:231
linear_solver_config_type & linear_solver()
Returns the configuration object for the linear solver.
Definition: config.hpp:485
void set_hole_equation(equation_id equ_id)
Definition: config.hpp:239
bool with_electrons() const
Returns true if electrons are considered in the simulation.
Definition: config.hpp:226
viennashe::she::scatter_config & scattering()
Returns the configuration object for scattering.
Definition: config.hpp:475
bool with_quantum_correction() const
Definition: config.hpp:512
ionized_impurity_scattering_parameters const & ionized_impurity() const
Returns the parameters for ionized impurity scattering. Const-version.
Definition: config.hpp:377
impact_ionization_scattering_parameters const & impact_ionization() const
Returns the parameters for impact ionization scattering. Const-version.
Definition: config.hpp:382
acoustic_phonon_scattering_parameters const & acoustic_phonon() const
Returns the parameters for acoustic phonon scattering. Const-version.
Definition: config.hpp:367
optical_phonon_scattering_parameters const & optical_phonon() const
Returns the parameters for optical phonon scattering. Const-version.
Definition: config.hpp:372
bool electron_electron() const
Returns true if electron-electron scattering is activated.
Definition: config.hpp:387
void set(long solver_id)
Sets a new linear solver. Provide IDs defined in.
Definition: config.hpp:84
long id() const
Returns the current linear solver ID.
Definition: config.hpp:79
std::size_t max_iters() const
Returns the maximum number of iterative linear solver iterations.
Definition: config.hpp:155
std::size_t max_iters() const
Returns the maximum number of nonlinear solver iterations.
Definition: config.hpp:317
double damping() const
Returns the damping for the nonlinear solver.
Definition: config.hpp:328
long id() const
Returns the current linear solver ID.
Definition: config.hpp:262
void set(long solver_id)
Sets a new linear solver. Provide IDs defined in.
Definition: config.hpp:270
viennashe_linear_solver_id
Enum of available linear solvers.
Definition: config.h:34
@ viennashe_linear_solver_gpu_parallel
Definition: config.h:35
@ viennashe_linear_solver_dense
Definition: config.h:34
@ viennashe_linear_solver_parallel
Definition: config.h:35
@ viennashe_linear_solver_serial
Definition: config.h:34
VIENNASHE_EXPORT viennasheErrorCode viennashe_get_linear_solver_config(viennashe_config conf, viennashe_linear_solver_id *sol_id, long *max_iters)
VIENNASHE_EXPORT viennasheErrorCode viennashe_free_config(viennashe_config conf)
VIENNASHE_EXPORT viennasheErrorCode viennashe_config_enable_density_gradient(viennashe_config conf)
viennashe_nonlinear_solver_id
Enum of available non-linear solvers.
Definition: config.h:38
@ viennashe_nonlinear_solver_gummel
Definition: config.h:38
@ viennashe_nonlinear_solver_newton
Definition: config.h:38
VIENNASHE_EXPORT viennasheErrorCode viennashe_config_with_traps(viennashe_config conf, libviennashe_bool enabled)
VIENNASHE_EXPORT viennasheErrorCode viennashe_set_ionized_impurity_scattering(viennashe_config conf, libviennashe_bool enabled)
VIENNASHE_EXPORT viennasheErrorCode viennashe_config_is_with_traps(viennashe_config conf, libviennashe_bool *enabled)
VIENNASHE_EXPORT viennasheErrorCode viennashe_config_standard_dd(viennashe_config conf)
VIENNASHE_EXPORT viennasheErrorCode viennashe_get_acoustic_phonon_scattering(viennashe_config conf, libviennashe_bool *enabled)
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_unipolar_p(viennashe_config conf)
VIENNASHE_EXPORT viennasheErrorCode viennashe_config_has_density_gradient(viennashe_config conf, libviennashe_bool *enabled)
VIENNASHE_EXPORT viennasheErrorCode viennashe_get_optical_phonon_scattering(viennashe_config conf, libviennashe_bool *enabled)
VIENNASHE_EXPORT viennasheErrorCode viennashe_get_ionized_impurity_scattering(viennashe_config conf, libviennashe_bool *enabled)
VIENNASHE_EXPORT viennasheErrorCode viennashe_set_linear_solver_config(viennashe_config conf, viennashe_linear_solver_id sol_id, long max_iters)
VIENNASHE_EXPORT viennasheErrorCode viennashe_set_electron_electron_scattering(viennashe_config conf, libviennashe_bool enabled)
VIENNASHE_EXPORT viennasheErrorCode viennashe_config_she_bipolar(viennashe_config conf, libviennashe_bool with_traps)
VIENNASHE_EXPORT viennasheErrorCode viennashe_set_impact_ionization_scattering(viennashe_config conf, libviennashe_bool enabled)
VIENNASHE_EXPORT viennasheErrorCode viennashe_get_electron_electron_scattering(viennashe_config conf, libviennashe_bool *enabled)
VIENNASHE_EXPORT viennasheErrorCode viennashe_set_acoustic_phonon_scattering(viennashe_config conf, libviennashe_bool enabled)
VIENNASHE_EXPORT viennasheErrorCode viennashe_get_nonlinear_solver_config(viennashe_config conf, viennashe_nonlinear_solver_id *sol_id, long *max_iters, double *damping)
VIENNASHE_EXPORT viennasheErrorCode viennashe_create_config(viennashe_config *conf)
VIENNASHE_EXPORT viennasheErrorCode viennashe_set_optical_phonon_scattering(viennashe_config conf, libviennashe_bool enabled)
VIENNASHE_EXPORT viennasheErrorCode viennashe_config_she_unipolar_n(viennashe_config conf)
VIENNASHE_EXPORT viennasheErrorCode viennashe_get_impact_ionization_scattering(viennashe_config conf, libviennashe_bool *enabled)
VIENNASHE_EXPORT viennasheErrorCode viennashe_config_disable_density_gradient(viennashe_config conf)
viennashe_config_impl * viennashe_config
Definition: config.h:31
int viennasheErrorCode
Definition: error.h:25
logger< true > error()
Used to log errors. The logging level is logERROR.
Definition: log.hpp:301
@ EQUATION_SHE
Definition: forwards.h:118
@ EQUATION_CONTINUITY
Definition: forwards.h:117
@ gpu_parallel_linear_solver
multi-threaded solver (block ILUT)
Definition: config.hpp:46
@ parallel_linear_solver
single-threaded solver (using ILUT)
Definition: config.hpp:45
@ serial_linear_solver
Gauss solver (use for systems up to ~1000-by-1000 only)
Definition: config.hpp:44
@ newton_nonlinear_solver
Gummel iteration.
Definition: config.hpp:244
libviennashe_bool
Definition: sys.h:31
@ libviennashe_false
Definition: sys.h:31
@ libviennashe_true
Definition: sys.h:31
Contains all viennashe includes and most of the C++/C-wrappers. Contains macros.
#define __FUNCTION_NAME__
#define CHECK_ARGUMENT_FOR_NULL(arg, pos, name)