ViennaSHE 1.3.0
Free open-source semiconductor device simulator using spherical harmonics expansions techniques.
boundary_conditions.hpp
Go to the documentation of this file.
1#ifndef VIENNASHE_SHE_BOUNDARY_CONDITIONS_HPP
2#define VIENNASHE_SHE_BOUNDARY_CONDITIONS_HPP
3
4/* ============================================================================
5 Copyright (c) 2011-2022, Institute for Microelectronics,
6 Institute for Analysis and Scientific Computing,
7 TU Wien.
8
9 -----------------
10 ViennaSHE - The Vienna Spherical Harmonics Expansion Boltzmann Solver
11 -----------------
12
13 http://viennashe.sourceforge.net/
14
15 License: MIT (X11), see file LICENSE in the base directory
16=============================================================================== */
17
18
19// std
20#include <iostream>
21#include <limits>
22
23// viennagrid
24#include "viennagrid/mesh/mesh.hpp"
25
26// viennashe
28#include "viennashe/forwards.h"
33
35#include "viennashe/config.hpp"
38
44namespace viennashe
45{
46 namespace she
47 {
48
55 template <typename DeviceType,
56 typename VertexT, typename EdgeT>
57 void write_boundary_conditions(DeviceType const & device,
59 viennashe::config const & conf)
60 {
61 typedef typename DeviceType::mesh_type MeshType;
62
63 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
64 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
65
66 MeshType const & mesh = device.mesh();
67
69
70 const double kB = viennashe::physics::constants::kB;
72
73 CellContainer cells(mesh);
74 for (CellIterator cit = cells.begin();
75 cit != cells.end();
76 ++cit)
77 {
78 const double T = device.get_lattice_temperature(*cit);
79
80 // Step 1: Find normalization
81 //
82 // Compute boundary correction such that boundary values are given by: n_conc * exp(-eps/(kB*T)) / bnd_corr
83 //
84 double bnd_corr = 0;
85
86 for (std::size_t index_H = 1;
87 index_H < quan.get_value_H_size() - 1;
88 ++index_H)
89 {
90 double energy_mid = quan.get_kinetic_energy(*cit, index_H);
91 double energy_lower = std::max<double>((quan.get_kinetic_energy(*cit, index_H - 1) + energy_mid) / 2.0, 0.0);
92 double energy_upper = (quan.get_kinetic_energy(*cit, index_H + 1) + energy_mid) / 2.0;
93
94 if (energy_lower < energy_upper && (energy_upper >= 0))
95 {
96 double height = box_height(quan, *cit, index_H);
97
98 bnd_corr += exp(-energy_mid / (kB*T)) * averaged_density_of_states(quan, dispersion, *cit, index_H) * height;
99 }
100 }
101 bnd_corr *= dispersion.symmetry_factor();
102
103 //
104 // Step 2: Write boundary values
105 //
106 for (std::size_t index_H = 1; index_H < quan.get_value_H_size() - 1; ++index_H)
107 {
108 double energy = quan.get_kinetic_energy(*cit, index_H);
109 double energy_lower = std::max<double>((quan.get_kinetic_energy(*cit, index_H - 1) + energy) / 2.0, 0.0);
110 double energy_upper = (quan.get_kinetic_energy(*cit, index_H + 1) + energy) / 2.0;
111
112 double bnd_value = 0.0;
113 if (energy_lower < energy_upper && (energy_upper >= 0)) // ensure conservation of density upon integration
114 {
115 const double TL = device.get_lattice_temperature(*cit);
116
117 switch (conf.she_discretization_type())
118 {
120 bnd_value = bnd_carrier_density(*cit, TL) * exp(-energy / (kB * T)) / bnd_corr;
121 break;
123 bnd_value = bnd_carrier_density(*cit, TL) * averaged_density_of_states(quan, dispersion, *cit, index_H) * exp(-energy / (kB * T)) / bnd_corr;
124 break;
125 default:
126 throw std::runtime_error("Unknown SHE discretization type");
127 }
128 }
129 quan.set_boundary_value(*cit, index_H, bnd_value);
130 } // for index_H
131
132 } // for cells
133
134 } // write_boundary_conditions())
135
136
137 template <typename DeviceType>
138 void write_boundary_conditions(DeviceType const & device,
140 viennashe::config const & conf)
141 {
143
144 SHEUnknownType & f_n = quantities.electron_distribution_function();
145 SHEUnknownType & f_p = quantities.hole_distribution_function();
146
147 // Setup energies for electrons:
148 if (conf.with_electrons() && conf.get_electron_equation() == EQUATION_SHE)
150
151 // Setup energies for holes:
152 if (conf.with_holes() && conf.get_hole_equation() == EQUATION_SHE)
154 }
155
156 }
157}
158
159#endif
Contains the definition of per-device accessors (read-only!) for various quantities.
Provides an accessor for the carrier density.
The main SHE configuration class. To be adjusted by the user for his/her needs.
Definition: config.hpp:124
viennashe::physics::dispersion_proxy dispersion_relation(viennashe::carrier_type_id ctype) const
Returns the dispersion relation for electrons.
Definition: config.hpp:266
equation_id get_electron_equation() const
Definition: config.hpp:230
bool with_holes() const
Returns true if holes are considered in the simulation.
Definition: config.hpp:234
equation_id get_hole_equation() const
Definition: config.hpp:238
bool with_electrons() const
Returns true if electrons are considered in the simulation.
Definition: config.hpp:226
she_discretization_type_id she_discretization_type() const
Definition: config.hpp:360
double get_lattice_temperature(cell_type const &c) const
Returns the lattice temperature on a cell.
Definition: device.hpp:255
MeshT const & mesh() const
Returns the underlying mesh.
Definition: device.hpp:145
Defines the physical properties of a device, e.g. doping. This is the implementation for 2d and highe...
Definition: device.hpp:818
A proxy object for a dispersion relation. Does NOT take ownership of the provided pointer!
Definition: dispersion.hpp:69
The main SHE simulator controller class. Acts as an accessor for all SHE quantities needed for the si...
UnknownSHEQuantityType const & electron_distribution_function() const
UnknownSHEQuantityType const & hole_distribution_function() const
General representation of any solver quantity defined on two different element types (e....
carrier_type_id get_carrier_type_id() const
ValueT get_kinetic_energy(AssociatedT1 const &elem, std::size_t index_H) const
void set_boundary_value(AssociatedT1 const &elem, std::size_t index_H, ValueT value)
The SHE configuration class is defined here.
Contains the dispersion relations for different materials and different polarities.
Contains forward declarations and definition of small classes that must be defined at an early stage.
Miscellaneous utilities.
double averaged_density_of_states(SHEQuantity const &quan, viennashe::config::dispersion_relation_type const &dispersion, CellFacetType const &cell_facet, std::size_t index_H)
Returns the density of states around a vertex or an edge at total energy specified by index_H....
void write_boundary_conditions(DeviceType const &device, viennashe::she::unknown_she_quantity< VertexT, EdgeT > &quan, viennashe::config const &conf)
Writes boundary conditions for SHE to the device. Stores the result using ViennaData.
double box_height(SHEQuantity const &quan, ElementType const &elem, std::size_t index_H)
Returns the height of the control box with respect to energy at the provided element (vertex or edge)...
The main ViennaSHE namespace. All functionality resides inside this namespace.
Definition: accessors.hpp:40
@ SHE_DISCRETIZATION_EVEN_ODD_ORDER_GENERALIZED_DF
Definition: forwards.h:146
@ SHE_DISCRETIZATION_EVEN_ODD_ORDER_DF
Definition: forwards.h:145
@ EQUATION_SHE
Definition: forwards.h:118
Provides a number of fundamental constants. All constants in SI units.
Returns a few helper routines for computing physical quantities. To be replaced in the future.
Defines a SHE quantity in (x, H)-space for use within the solvers of ViennaSHE.
Returns the carrier density at contacts modelled as thermal baths (used by DD and SHE)
Definition: accessors.hpp:317
static const double kB
Boltzmann constant.
Definition: constants.hpp:46
A container of all quantities defined for a certain timestep t.