ViennaSHE 1.3.0
Free open-source semiconductor device simulator using spherical harmonics expansions techniques.
current_density.hpp
Go to the documentation of this file.
1#ifndef VIENNASHE_SHE_CURRENT_DENSITY_HPP
2#define VIENNASHE_SHE_CURRENT_DENSITY_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
20#include <math.h>
21#include <vector>
22
23#include "viennagrid/mesh/mesh.hpp"
24
25#include "viennashe/forwards.h"
34
39namespace viennashe
40{
41 namespace she
42 {
43
44 namespace detail
45 {
46
47 template <typename DeviceT, typename SHEQuantityT>
49 {
51
52 public:
54 viennashe::config const & conf,
55 SHEQuantityT const & quan)
56 : device_(d), conf_(conf), quan_(quan),
57 a_x(4, 4), a_y(4, 4), a_z(4, 4),
58 b_x(4, 4), b_y(4, 4), b_z(4, 4)
59 {
60 fill_coupling_matrices(a_x, a_y, a_z,
61 b_x, b_y, b_z,
62 1);
63 }
64
65 template <typename FacetType>
66 double operator()(FacetType const & facet) const
67 {
68 typedef typename DeviceT::mesh_type MeshType;
69 typedef typename viennagrid::result_of::point<FacetType>::type PointType;
70 typedef typename viennagrid::result_of::cell<MeshType>::type CellType;
71
72 typedef typename viennagrid::result_of::const_coboundary_range<MeshType, FacetType, CellType>::type CellOnFacetContainer;
73 typedef typename viennagrid::result_of::iterator<CellOnFacetContainer>::type CellOnFacetIterator;
74
76 typename viennashe::config::dispersion_relation_type dispersion = conf_.dispersion_relation(quan_.get_carrier_type_id());
77
78 CellOnFacetContainer cells_on_facet(device_.mesh(), viennagrid::handle(device_.mesh(), facet));
79
80 if (cells_on_facet.size() < 2)
81 return 0;
82
83 CellOnFacetIterator cofit = cells_on_facet.begin();
84 CellType const & c1 = *cofit;
85 ++cofit;
86 CellType const & c2 = *cofit;
87
88 PointType normal_vector = viennagrid::centroid(c2) - viennagrid::centroid(c1);
89 normal_vector /= viennagrid::norm_2(normal_vector);
90
91 double velocity_in_normal = 0;
92 double polarity = (quan_.get_carrier_type_id() == ELECTRON_TYPE_ID) ? -1.0 : 1.0;
93
94 double m_t = viennashe::materials::si::transverse_effective_mass(quan_.get_carrier_type_id());
95 double m_d = viennashe::materials::si::dos_effective_mass(quan_.get_carrier_type_id());
96 double m_l = viennashe::materials::si::longitudinal_effective_mass(quan_.get_carrier_type_id());
97
98 for (std::size_t index_H = 1; index_H < quan_.get_value_H_size()-1; ++index_H)
99 {
100 long index = quan_.get_unknown_index(facet, index_H);
101 if (index < 0)
102 continue;
103
104 double factor = 0;
105 switch (conf_.she_discretization_type())
106 {
108 factor = integral_vZ(quan_, dispersion, facet, index_H) * dispersion.symmetry_factor();
109 break;
111 factor = integral_v(quan_, dispersion, facet, index_H) * dispersion.symmetry_factor();
112 break;
113 default: throw std::runtime_error("carrier_density_wrapper_by_reference::operator(): Unknown SHE discretization type!");
114 }
115
116 velocity_in_normal += ( a_x(0, 1) * quan_.get_values(facet, index_H)[0]
117 + a_x(0, 2) * quan_.get_values(facet, index_H)[1]
118 + a_x(0, 3) * quan_.get_values(facet, index_H)[2] ) * factor * sqrt(m_d / m_t) * normal_vector[0];
119
120 if (PointType::dim > 1)
121 velocity_in_normal += ( a_y(0, 1) * quan_.get_values(facet, index_H)[0]
122 + a_y(0, 2) * quan_.get_values(facet, index_H)[1]
123 + a_y(0, 3) * quan_.get_values(facet, index_H)[2] ) * factor * sqrt(m_d / m_t) * normal_vector[1];
124
125 if (PointType::dim > 2)
126 velocity_in_normal += ( a_z(0, 1) * quan_.get_values(facet, index_H)[0]
127 + a_z(0, 2) * quan_.get_values(facet, index_H)[1]
128 + a_z(0, 3) * quan_.get_values(facet, index_H)[2] ) * factor * sqrt(m_d / m_l) * normal_vector[2];
129 }
130
131 return -polarity * viennashe::physics::constants::q * velocity_in_normal / Y_00(0,0);
132 }
133
134
135 SHEQuantityT const & get_quan() const { return this->quan_; }
136
137
138 private:
139 DeviceT const & device_;
140 viennashe::config conf_;
141 SHEQuantityT const & quan_;
142
143 CouplingMatrixType a_x;
144 CouplingMatrixType a_y;
145 CouplingMatrixType a_z;
146
147 CouplingMatrixType b_x;
148 CouplingMatrixType b_y;
149 CouplingMatrixType b_z;
150 };
151
153 template <typename ValueType>
155 {
156 public:
157 typedef ValueType value_type;
158
159 template <typename T>
160 void operator()(T const &, value_type val) const { value_ = val; }
161
162 value_type operator()() const { return value_; }
163
164 private:
165 mutable value_type value_;
166 };
167
168 } // namespace detail
169
170
172 template <typename DeviceType,
173 typename SHEQuantity>
175 {
176 protected:
177 typedef typename DeviceType::mesh_type MeshType;
178 typedef typename viennagrid::result_of::point<MeshType>::type PointType;
179
180 public:
181 typedef std::vector<double> value_type;
182 typedef typename viennagrid::result_of::cell<MeshType>::type cell_type;
183 typedef typename viennagrid::result_of::facet<MeshType>::type facet_type;
184
185 current_density_wrapper(DeviceType const & device,
186 viennashe::config const & conf,
187 SHEQuantity const & quan)
188 : device_(device), quan_(quan), facet_evaluator_(device, conf, quan)
189 { }
190
192 : device_(o.device_), quan_(o.quan_), facet_evaluator_(o.facet_evaluator_) {}
193
195 double operator()(facet_type const & facet) const
196 {
197 return facet_evaluator_(facet);
198 }
199
201 value_type operator()(cell_type const & cell) const
202 {
203 typedef typename viennagrid::result_of::const_facet_range<cell_type>::type FacetOnCellContainer;
204
205 std::vector<double> J(3);
206
207 if (!viennashe::materials::is_semiconductor(device_.get_material(cell))) return J;
208
210
211 FacetOnCellContainer facets_on_cell(cell);
213 cell, facets_on_cell,
214 result, facet_evaluator_);
215 return result();
216 }
217
218 private:
219 DeviceType const & device_;
220 SHEQuantity quan_;
221 detail::current_on_facet_by_ref_calculator<DeviceType, SHEQuantity> facet_evaluator_; // REFERENCES quan_ and dispersion_
222 };
223
224
232 template <typename DeviceType,
233 typename SHEQuantity,
234 typename ContainerType>
236 viennashe::config const & conf,
237 SHEQuantity const & quan,
238 ContainerType & container)
239 {
240 current_density_wrapper<DeviceType, SHEQuantity> current_wrapper(device, conf, quan);
241
243 }
244
245
252 template <typename DeviceT, typename SHEQuantity>
253 void check_current_conservation(DeviceT const & device,
254 viennashe::config const & conf,
255 SHEQuantity const & quan)
256 {
258
260 }
261 } //namespace she
262} //namespace viennashe
263
264#endif
Common routines for the assembly of SHE equations.
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
she_discretization_type_id she_discretization_type() const
Definition: config.hpp:360
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
Accessor class providing the carrier velocity inside the device.
double operator()(facet_type const &facet) const
Functor interface returning the current density magnitude on the facet.
current_density_wrapper(current_density_wrapper const &o)
current_density_wrapper(DeviceType const &device, viennashe::config const &conf, SHEQuantity const &quan)
viennagrid::result_of::cell< MeshType >::type cell_type
viennagrid::result_of::point< MeshType >::type PointType
viennagrid::result_of::facet< MeshType >::type facet_type
value_type operator()(cell_type const &cell) const
Functor interface returning the current density at the provided cell.
current_on_facet_by_ref_calculator(DeviceT const &d, viennashe::config const &conf, SHEQuantityT const &quan)
A simple functor to hold a single value. Operator() should not take any arguments.
void operator()(T const &, value_type val) const
A functor which holds a single value. Used in most of the postprocessing routines.
Definition: misc.hpp:59
Helper routines for projecting normal components of a vector-valued quantity defined on edges to vert...
Contains forward declarations and definition of small classes that must be defined at an early stage.
Provides the SHE coupling matrices and computes higher-order coupling matrices if required....
Implementation of numerical integration routines.
Writer for arbitrary macroscopic quantities.
A very simple material database. Needs to be replaced by something more versatile soon.
bool is_semiconductor(long material_id)
Convenience function for checking whether the supplied material ID refers to a semiconductor.
Definition: all.hpp:156
VectorType::value_type norm_2(VectorType const &v)
Definition: linalg_util.hpp:37
void fill_coupling_matrices(MatrixType &a_x, MatrixType &a_y, MatrixType &a_z, MatrixType &b_x, MatrixType &b_y, MatrixType &b_z, int L_max)
Public interface for filling coupling matrices.
double integral_v(SHEQuantity const &quan, viennashe::config::dispersion_relation_type const &dispersion, CellFacetType const &cell_facet, std::size_t index_H)
Computes \int v dH using a Simpson rule, where v is velocity.
double integral_vZ(SHEQuantity const &quan, viennashe::config::dispersion_relation_type const &dispersion, CellFacetType const &cell_facet, std::size_t index_H)
Computes \int v Z dH using a Simpson rule, where v is velocity and Z is the density of states.
void write_current_density_to_container(DeviceType const &device, viennashe::config const &conf, SHEQuantity const &quan, ContainerType &container)
Convenience function for writing the current density to the container provided.
void check_current_conservation(DeviceT const &device, viennashe::config const &conf, SHEQuantity const &quan)
Checks current conservation for SHE. Writes information using log::info().
void dual_box_flux_to_cell(DeviceT const &device, CellT const &cell, FacetContainerT const &facets, CellSetterT &cell_setter, FacetAccessorT const &facet_access)
Interpolates normal components of the flux defined on each facet to cells. Mostly used for visualizat...
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
@ ELECTRON_TYPE_ID
Definition: forwards.h:187
void check_current_conservation(DeviceT const &device, CurrentDensityT const &current_on_facet)
Checks current conservation for SHE. Writes information using log::info().
void write_macroscopic_quantity_to_container(DeviceType const &device, MacroscopicQuantityAccessor const &quantity, ContainerType &quantity_container)
Writes the provided macroscopic quantity to the container provided.
Definition: macroscopic.hpp:46
Provides a number of fundamental constants. All constants in SI units.
Computes the current density (both Jn and Jp) after using a drift diffusion solution.
static double longitudinal_effective_mass(viennashe::carrier_type_id ctype)
Definition: all.hpp:66
static double transverse_effective_mass(viennashe::carrier_type_id ctype)
Definition: all.hpp:74
static double dos_effective_mass(viennashe::carrier_type_id ctype)
Definition: all.hpp:58
static const double q
Elementary charge.
Definition: constants.hpp:44