1#ifndef VIENNASHE_SHE_ASSEMBLE_BOUNDARY_HPP
2#define VIENNASHE_SHE_ASSEMBLE_BOUNDARY_HPP
20#include "viennagrid/mesh/mesh.hpp"
21#include "viennagrid/algorithm/norm.hpp"
22#include "viennagrid/algorithm/volume.hpp"
23#include "viennagrid/algorithm/voronoi.hpp"
63 template <
typename DeviceType,
68 typename CouplingMatrixType>
71 SHEQuantity
const & quan,
74 CellType
const & cell, std::size_t index_H,
75 CouplingMatrixType
const & coupling_identity)
79 long row_index = quan.get_unknown_index(cell, index_H);
84 long expansion_order =
static_cast<long>(quan.get_expansion_order(cell, index_H));
92 double bnd_value = quan.get_boundary_value(cell, index_H);
93 double height =
box_height(quan, cell, index_H);
95 double coefficient = 0;
102 coefficient = height;
104 default:
throw std::runtime_error(
"assemble_boundary_on_box(): Unknown SHE discretization type!");
115 -bnd_value*coefficient,
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);
132 double coefficient = 0;
139 coefficient = box_volume * height / tau;
141 default:
throw std::runtime_error(
"assemble_boundary_on_box(): Unknown SHE discretization type!");
152 - bnd_value * coefficient,
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;
168 if (with_full_newton)
172 std::size_t(row_index),
173 box_volume * height / tau,
177 quan.get_values(cell, index_H));
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.
she_boundary_conditions_config const & she_boundary_conditions() const
viennashe::physics::dispersion_proxy dispersion_relation(viennashe::carrier_type_id ctype) const
Returns the dispersion relation for electrons.
nonlinear_solver_config_type & nonlinear_solver()
Returns the configuration object for the nonlinear solver.
she_discretization_type_id she_discretization_type() const
bool has_contact_potential(cell_type const &c) const
Returns true if a contact potential has been set for the respective vertex.
Defines the physical properties of a device, e.g. doping. This is the implementation for 2d and highe...
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!
double generation_recombination_rate() const
Returns the recombination rate used in a Robin boundary condition.
viennashe::boundary_type_id type() const
Returns the type of boundary conditions used by SHE.
long id() const
Returns the current linear solver ID.
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.
@ EVEN_HARMONICS_ITERATION_ID
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.
@ SHE_DISCRETIZATION_EVEN_ODD_ORDER_GENERALIZED_DF
@ SHE_DISCRETIZATION_EVEN_ODD_ORDER_DF
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.
Defines the log keys used within the viennashe::she namespace.