ViennaSHE 1.3.0
Free open-source semiconductor device simulator using spherical harmonics expansions techniques.
assemble_boundary.hpp
Go to the documentation of this file.
1#ifndef VIENNASHE_SHE_ASSEMBLE_BOUNDARY_HPP
2#define VIENNASHE_SHE_ASSEMBLE_BOUNDARY_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// viennagrid
20#include "viennagrid/mesh/mesh.hpp"
21#include "viennagrid/algorithm/norm.hpp"
22#include "viennagrid/algorithm/volume.hpp"
23#include "viennagrid/algorithm/voronoi.hpp"
24
25// viennashe
28
32
33#include "viennashe/config.hpp"
38
42
43#include "viennashe/log/log.hpp"
44
49namespace viennashe
50{
51 namespace she
52 {
53
63 template <typename DeviceType,
64 typename SHEQuantity,
65 typename MatrixType,
66 typename VectorType,
67 typename CellType,
68 typename CouplingMatrixType>
69 void assemble_boundary_on_box(DeviceType const & device,
70 viennashe::config const & conf,
71 SHEQuantity const & quan,
72 MatrixType & A,
73 VectorType & b,
74 CellType const & cell, std::size_t index_H,
75 CouplingMatrixType const & coupling_identity)
76 {
78
79 long row_index = quan.get_unknown_index(cell, index_H);
80
81 if (row_index < 0) //no unknown here
82 return;
83
84 long expansion_order = static_cast<long>(quan.get_expansion_order(cell, index_H));
85
86 if (device.has_contact_potential(cell)) // any boundary conditions required here?
87 {
88 typename viennashe::config::dispersion_relation_type dispersion = conf.dispersion_relation(quan.get_carrier_type_id());
89
90 if (conf.she_boundary_conditions().type() == viennashe::BOUNDARY_DIRICHLET) // Dirichlet boundary conditions
91 {
92 double bnd_value = quan.get_boundary_value(cell, index_H);
93 double height = box_height(quan, cell, index_H);
94
95 double coefficient = 0;
96 switch (conf.she_discretization_type())
97 {
99 coefficient = height * averaged_density_of_states(quan, dispersion, cell, index_H);
100 break;
102 coefficient = height;
103 break;
104 default: throw std::runtime_error("assemble_boundary_on_box(): Unknown SHE discretization type!");
105 }
106
107 viennashe::util::add_block_matrix(A, std::size_t(row_index), std::size_t(row_index),
108 coefficient,
109 coupling_identity,
112 );
113
114 write_boundary(b, std::size_t(row_index),
115 -bnd_value*coefficient,
116 coupling_identity,
118 );
119 return;
120 }
121 else // generation/recombination boundary conditions
122 {
123 //
124 // boundary term (for even unknowns): dg/dt + L - Q + (g - g^eq) / tau = 0 as a volume contribution on RHS
125 //
126
128 double height = box_height(quan, cell, index_H);
129 double bnd_value = quan.get_boundary_value(cell, index_H);
130 double box_volume = viennagrid::volume(cell);
131
132 double coefficient = 0;
133 switch (conf.she_discretization_type())
134 {
136 coefficient = box_volume * height / tau * averaged_density_of_states(quan, dispersion, cell, index_H);
137 break;
139 coefficient = box_volume * height / tau;
140 break;
141 default: throw std::runtime_error("assemble_boundary_on_box(): Unknown SHE discretization type!");
142 }
143
144 viennashe::util::add_block_matrix(A, std::size_t(row_index), std::size_t(row_index),
145 coefficient,
146 coupling_identity,
149 );
150
151 write_boundary(b, std::size_t(row_index),
152 - bnd_value * coefficient, //Note: sign choice is the same as for add_block_matrix(), i.e. write_boundary() inverts the sign for the rhs contribution internally
153 coupling_identity,
155 );
156
158 {
159 log::debug<log_assemble_free_streaming_operator>() << "* assemble_boundary_on_box(): boundary contribution:" << std::endl;
160 log::debug<log_assemble_free_streaming_operator>() << " bnd_value * box_volume * height / tau" << std::endl;
161 log::debug<log_assemble_free_streaming_operator>() << " at (" << row_index << ")" << std::endl;
162 log::debug<log_assemble_free_streaming_operator>() << " bnd_value = " << bnd_value << std::endl;
163 log::debug<log_assemble_free_streaming_operator>() << " box_volume = " << box_volume << std::endl;
164 log::debug<log_assemble_free_streaming_operator>() << " height = " << height << std::endl;
165 log::debug<log_assemble_free_streaming_operator>() << " tau = " << tau << std::endl;
166 }
167
168 if (with_full_newton)
169 {
170 // Only contributions to the residual, because (f - f^eq)/tau does neither have an explicit dependence on the potential, nor does it spatially couple.
172 std::size_t(row_index),
173 box_volume * height / tau,
174 coupling_identity,
177 quan.get_values(cell, index_H));
178 }
179 }
180
181 } // if boundary_terms
182
183 } //assemble_boundary_on_box
184
185
186
187 } //namespace she
188} //namespace viennashe
189
190#endif
Common routines for the assembly of SHE equations.
Writes a possibly scaled block matrix to the system matrix. Includes similar functionality for comput...
The main SHE configuration class. To be adjusted by the user for his/her needs.
Definition: config.hpp:124
she_boundary_conditions_config const & she_boundary_conditions() const
Definition: config.hpp:540
viennashe::physics::dispersion_proxy dispersion_relation(viennashe::carrier_type_id ctype) const
Returns the dispersion relation for electrons.
Definition: config.hpp:266
nonlinear_solver_config_type & nonlinear_solver()
Returns the configuration object for the nonlinear solver.
Definition: config.hpp:495
she_discretization_type_id she_discretization_type() const
Definition: config.hpp:360
bool has_contact_potential(cell_type const &c) const
Returns true if a contact potential has been set for the respective vertex.
Definition: device.hpp:577
Defines the physical properties of a device, e.g. doping. This is the implementation for 2d and highe...
Definition: device.hpp:818
Iteration over all spherical harmonics indices up to order L, with increasing indices l and m.
A proxy object for a dispersion relation. Does NOT take ownership of the provided pointer!
Definition: dispersion.hpp:69
double generation_recombination_rate() const
Returns the recombination rate used in a Robin boundary condition.
Definition: config.hpp:108
viennashe::boundary_type_id type() const
Returns the type of boundary conditions used by SHE.
Definition: config.hpp:96
long id() const
Returns the current linear solver ID.
Definition: config.hpp:262
The SHE configuration class is defined here.
Contains the dispersion relations for different materials and different polarities.
Defines several filter functors for the device. A filter functor returns true if the supplied argumen...
Provides the SHE coupling matrices and computes higher-order coupling matrices if required....
Implementation of numerical integration routines.
A logging facility providing fine-grained control over logging in ViennaSHE.
Miscellaneous utilities.
@ EVEN_HARMONICS_ITERATION_ID
Definition: forwards.h:161
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....
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)...
void assemble_boundary_on_box(DeviceType const &device, viennashe::config const &conf, SHEQuantity const &quan, MatrixType &A, VectorType &b, CellType const &cell, std::size_t index_H, CouplingMatrixType const &coupling_identity)
Worker function for the assembly of the free streaming operator. Handles the assembly of both even an...
void write_boundary(VectorType &rhs, std::size_t row_start, double prefactor, MatrixType const &coupling_matrix, IteratorType row_iter)
Write Dirichlet boundary conditions to right hand side.
void add_block_matrix(SystemMatrixType &system_matrix, std::size_t row_index, std::size_t col_index, double prefactor, BlockMatrixType const &coupling_matrix, RowIndexIterator row_iter, ColumnIndexIterator const &col_iter_init, bool elastic_scattering_roundoff_error_prevention=false)
Writes a sub-matrix of a block matrix 'coupling_matrix' into the global system matrix,...
void subtract_folded_block_vector(VectorType &residual, std::size_t row_index, double prefactor, BlockMatrixType const &coupling_matrix, RowIndexIterator row_iter, ColumnIndexIterator const &col_iter_init, double const *fold_vector)
Writes a sub-matrix of a block matrix 'coupling_matrix' to the residual vector. The columns are 'fold...
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
@ BOUNDARY_DIRICHLET
Definition: forwards.h:127
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.
Provides the exceptions used inside the viennashe::she namespace.
Implementation of spherical harmonics plus helper functions.
@ newton_nonlinear_solver
Gummel iteration.
Definition: config.hpp:244
Defines the log keys used within the viennashe::she namespace.