1#ifndef VIENNASHE_SHE_ASSEMBLE_TRAPS_HPP
2#define VIENNASHE_SHE_ASSEMBLE_TRAPS_HPP
20#include "viennagrid/mesh/mesh.hpp"
21#include "viennagrid/algorithm/voronoi.hpp"
63 template <
typename DeviceType,
64 typename TimeStepQuantitiesT,
68 typename CouplingMatrixType>
70 TimeStepQuantitiesT
const & quantities,
71 SHEQuantity
const & quan,
73 typename DeviceType::cell_type
const & el,
75 MatrixType & matrix, VectorType & rhs,
76 CouplingMatrixType
const & diagonal_coupling_matrix,
77 CouplingMatrixType
const & coupling_matrix_00
80 typedef typename DeviceType::trap_level_container_type TrapContainerType;
81 typedef typename TrapContainerType::const_iterator TrapIterator;
83 const long row_index = quan.get_unknown_index(el, index_H);
90 const std::size_t num_trap_unknowns = quantities.num_trap_unknown_indices(el);
92 if (num_trap_unknowns <= 0)
95 if (num_trap_unknowns != traps.size())
96 throw viennashe::invalid_value_exception(
"The number of traps configured in the device does not match the number of unknowns for traps!",
static_cast<double>(num_trap_unknowns));
99 const long expansion_order =
static_cast<long>(quan.get_expansion_order(el, index_H));
100 const double energy_height =
box_height(quan, el, index_H);
104 double volume_contribution = viennagrid::volume(el);
106 std::size_t inner_index = 0;
107 for ( TrapIterator trap_it = traps.begin();
108 trap_it != traps.end();
109 ++trap_it, ++inner_index)
111 log::debug<log_traps>() << el <<
" => " << *trap_it << std::endl;
113 const double occupancy = quantities.trap_occupancy(el, inner_index);
122 const double trap_density = trap_it->density();
125 quantities, quan.get_carrier_type_id(),
129 std::size_t(row_index), std::size_t(row_index),
131 diagonal_coupling_matrix,
147 quantities, quan.get_carrier_type_id(),
150 -
gamma_generation * trap_density * Z * volume_contribution * energy_height,
160 template <
typename DeviceType,
161 typename TimeStepQuantitiesT,
162 typename SHEQuantity,
165 typename CouplingMatrixType>
167 TimeStepQuantitiesT
const & quantities,
168 SHEQuantity
const & quan,
170 typename DeviceType::facet_type
const & el,
172 MatrixType & matrix, VectorType & rhs,
173 CouplingMatrixType
const & diagonal_coupling_matrix,
174 CouplingMatrixType
const & coupling_matrix_00
177 typedef typename DeviceType::mesh_type MeshType;
178 typedef typename DeviceType::cell_type CellType;
179 typedef typename DeviceType::trap_level_container_type TrapContainerType;
180 typedef typename TrapContainerType::const_iterator TrapIterator;
181 typedef typename viennagrid::result_of::point<MeshType>::type PointType;
182 typedef typename viennagrid::result_of::const_coboundary_range<MeshType, typename DeviceType::facet_type, CellType>::type CellOnFacetContainer;
184 (void)rhs; (void)coupling_matrix_00;
185 const long row_index = quan.get_unknown_index(el, index_H);
191 const long expansion_order =
static_cast<long>(quan.get_expansion_order(el, index_H));
192 const double energy_height =
box_height(quan, el, index_H);
196 double volume_contribution = viennagrid::volume(el);
201 for (std::size_t cell_index = 0; cell_index < cells_on_facet.size(); ++cell_index)
203 CellType
const & cell = cells_on_facet[cell_index];
206 const std::size_t num_trap_unknowns = quantities.num_trap_unknown_indices(cell);
208 if (num_trap_unknowns <= 0)
211 if (num_trap_unknowns != traps.size())
212 throw viennashe::invalid_value_exception(
"The number of traps configured in the device does not match the number of unknowns for traps!",
static_cast<double>(num_trap_unknowns));
214 std::size_t inner_index = 0;
215 for ( TrapIterator trap_it = traps.begin();
216 trap_it != traps.end();
217 ++trap_it, ++inner_index)
219 log::debug<log_traps>() << el <<
" => " << *trap_it << std::endl;
221 const double occupancy = quantities.trap_occupancy(cell, inner_index);
230 const double trap_density = trap_it->density();
233 quantities, quan.get_carrier_type_id(), occupancy, index_H);
236 std::size_t(row_index), std::size_t(row_index),
238 diagonal_coupling_matrix,
258 template <
typename DeviceType,
259 typename TimeStepQuantitiesT,
260 typename SHEQuantity,
264 TimeStepQuantitiesT
const & quantities,
266 SHEQuantity
const & quan,
270 typedef typename DeviceType::mesh_type MeshType;
272 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
273 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
275 typedef typename viennagrid::result_of::const_facet_range<MeshType>::type FacetContainer;
276 typedef typename viennagrid::result_of::iterator<FacetContainer>::type FacetIterator;
286 std::size_t num_harmonics =
static_cast<std::size_t
>(L_max+1) *
static_cast<std::size_t
>(L_max+1);
287 CouplingMatrixType diagonal_coupling_matrix(num_harmonics, num_harmonics);
288 CouplingMatrixType coupling_matrix_00(num_harmonics, num_harmonics);
291 for (std::size_t i=0; i< (L_max+1) * (L_max+1); ++i)
292 diagonal_coupling_matrix(i,i) += 1.0;
293 coupling_matrix_00(0,0) = 1.0 / Y_00(0,0);
298 CellContainer cells(mesh);
299 for (CellIterator cit = cells.begin();
303 for (std::size_t index_H = 0; index_H < quan.get_value_H_size(); ++index_H)
311 FacetContainer facets(mesh);
312 for (FacetIterator fit = facets.begin();
316 for (std::size_t index_H = 0; index_H < quan.get_value_H_size(); ++index_H)
325 template <
typename DeviceType,
326 typename TimeStepQuantitiesT,
327 typename SHEQuantity,
331 TimeStepQuantitiesT & quantities,
333 SHEQuantity
const & quan,
338 typedef typename DeviceType::mesh_type MeshType;
340 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
341 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
343 typedef typename DeviceType::trap_level_container_type TrapContainerType;
344 typedef typename TrapContainerType::const_iterator TrapIterator;
346 (void)quan; (void)matrix; (void)rhs;
350 CellContainer cells(mesh);
351 for (CellIterator cit = cells.begin();
355 const std::size_t num_trap_unknowns = quantities.num_trap_unknown_indices(*cit);
357 if (num_trap_unknowns > 0)
360 if (num_trap_unknowns != traps.size())
361 throw viennashe::invalid_value_exception(
"The number of traps configured in the device does not match the number of unknowns for traps!",
static_cast<double>(num_trap_unknowns));
363 std::size_t inner_index = 0;
365 for (TrapIterator trap_it = traps.begin();
366 trap_it != traps.end();
367 ++trap_it, ++inner_index)
374 quantities.trap_occupancy(*cit, inner_index, new_ft);
396 template <
typename DeviceType,
397 typename TimeStepQuantitiesT,
398 typename SHEQuantity,
402 TimeStepQuantitiesT & quantities,
404 SHEQuantity
const & quan,
Contains the definition of per-device accessors (read-only!) for various quantities.
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.
viennashe::physics::dispersion_proxy dispersion_relation(viennashe::carrier_type_id ctype) const
Returns the dispersion relation for electrons.
long max_expansion_order() const
Returns the current maximum expansion order.
bool with_trap_selfconsistency() const
Returns true if traps are considered self-consistently in the simulation.
MeshT const & mesh() const
Returns the underlying mesh.
trap_level_container_type const & get_trap_levels(cell_type const &cell) const
Returns all the trap levels defined for the provided cell.
Defines the physical properties of a device, e.g. doping. This is the implementation for 2d and highe...
Exception for the case that an invalid value (depends on the method called) is encountered.
Iteration over all spherical harmonics indices up to order L, with increasing indices l and m.
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...
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.
Implementation of various utilities related to linear algebra.
A logging facility providing fine-grained control over logging in ViennaSHE.
Provides a number of fundamental math constants.
harmonics_iteration_type
An enumeration of spherical harmonics types (all, even, odd) ViennaSHE supports.
@ EVEN_HARMONICS_ITERATION_ID
@ ODD_HARMONICS_ITERATION_ID
double gamma_generation(viennashe::trap_level const &trap, DeviceType const &device, ElementType const &el, viennashe::config const &conf, TimeStepQuantitiesT const &quantities, viennashe::carrier_type_id ctype, double occupancy, std::size_t index_H=0)
Returns the carrier generation, where the occupancies have been considered!
double evaluate(viennashe::trap_level const &trap, DeviceType const &device, ElementType const &el, viennashe::config const &conf, TimeStepQuantitiesT const &quantities)
Returns the trap occupancy based on a bipolar SHE or DD solution.
double gamma_recombination(viennashe::trap_level const &trap, DeviceType const &device, ElementType const &el, viennashe::config const &conf, TimeStepQuantitiesT const &quantities, viennashe::carrier_type_id ctype, double occupancy, std::size_t index_H=0)
Returns the carrier recombination, where the occupancies have been considered!
void assemble_traps_coupling_on_cell(DeviceType const &device, TimeStepQuantitiesT const &quantities, SHEQuantity const &quan, viennashe::config const &conf, typename DeviceType::cell_type const &el, std::size_t index_H, MatrixType &matrix, VectorType &rhs, CouplingMatrixType const &diagonal_coupling_matrix, CouplingMatrixType const &coupling_matrix_00)
Assembles the coupling of the distribution function with the trap occupancy for a cell (even-order f_...
double cell_connection_length(MeshT const &, CellT const &, CellT const &)
Static dispatcher for computing the connection between two cells adjacent to a facet....
void assemble_traps_coupling_on_facet(DeviceType const &device, TimeStepQuantitiesT const &quantities, SHEQuantity const &quan, viennashe::config const &conf, typename DeviceType::facet_type const &el, std::size_t index_H, MatrixType &matrix, VectorType &rhs, CouplingMatrixType const &diagonal_coupling_matrix, CouplingMatrixType const &coupling_matrix_00)
Assembles the coupling of the distribution function with the trap occupancy for either a facet (odd-o...
void assemble_traps(DeviceType const &device, TimeStepQuantitiesT &quantities, viennashe::config const &conf, SHEQuantity const &quan, MatrixType &matrix, VectorType &rhs)
void assemble_traps_solver(DeviceType const &device, TimeStepQuantitiesT &quantities, viennashe::config const &conf, SHEQuantity const &quan, MatrixType &matrix, VectorType &rhs)
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_traps_coupling(DeviceType const &device, TimeStepQuantitiesT const &quantities, viennashe::config const &conf, SHEQuantity const &quan, MatrixType &matrix, VectorType &rhs)
Interface function for the assembly of traps.
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,...
The main ViennaSHE namespace. All functionality resides inside this namespace.
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.
Contains the definition of convenience functors for accessing device quantities (see class device)....
Implementation of spherical harmonics plus helper functions.
A container of all quantities defined for a certain timestep t.
Defines the log keys used within the viennashe::she namespace.