1#ifndef VIENNASHE_SHE_CURRENT_DENSITY_HPP
2#define VIENNASHE_SHE_CURRENT_DENSITY_HPP
23#include "viennagrid/mesh/mesh.hpp"
47 template <
typename DeviceT,
typename SHEQuantityT>
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)
65 template <
typename FacetType>
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;
72 typedef typename viennagrid::result_of::const_coboundary_range<MeshType, FacetType, CellType>::type CellOnFacetContainer;
73 typedef typename viennagrid::result_of::iterator<CellOnFacetContainer>::type CellOnFacetIterator;
78 CellOnFacetContainer cells_on_facet(device_.mesh(), viennagrid::handle(device_.mesh(), facet));
80 if (cells_on_facet.size() < 2)
83 CellOnFacetIterator cofit = cells_on_facet.begin();
84 CellType
const & c1 = *cofit;
86 CellType
const & c2 = *cofit;
88 PointType normal_vector = viennagrid::centroid(c2) - viennagrid::centroid(c1);
91 double velocity_in_normal = 0;
92 double polarity = (quan_.get_carrier_type_id() ==
ELECTRON_TYPE_ID) ? -1.0 : 1.0;
98 for (std::size_t index_H = 1; index_H < quan_.get_value_H_size()-1; ++index_H)
100 long index = quan_.get_unknown_index(facet, index_H);
113 default:
throw std::runtime_error(
"carrier_density_wrapper_by_reference::operator(): Unknown SHE discretization type!");
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];
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];
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];
135 SHEQuantityT
const &
get_quan()
const {
return this->quan_; }
139 DeviceT
const & device_;
141 SHEQuantityT
const & quan_;
143 CouplingMatrixType a_x;
144 CouplingMatrixType a_y;
145 CouplingMatrixType a_z;
147 CouplingMatrixType b_x;
148 CouplingMatrixType b_y;
149 CouplingMatrixType b_z;
153 template <
typename ValueType>
159 template <
typename T>
172 template <
typename DeviceType,
173 typename SHEQuantity>
178 typedef typename viennagrid::result_of::point<MeshType>::type
PointType;
182 typedef typename viennagrid::result_of::cell<MeshType>::type
cell_type;
183 typedef typename viennagrid::result_of::facet<MeshType>::type
facet_type;
187 SHEQuantity
const & quan)
188 : device_(
device), quan_(quan), facet_evaluator_(
device, conf, quan)
192 : device_(o.device_), quan_(o.quan_), facet_evaluator_(o.facet_evaluator_) {}
197 return facet_evaluator_(facet);
203 typedef typename viennagrid::result_of::const_facet_range<cell_type>::type FacetOnCellContainer;
205 std::vector<double> J(3);
211 FacetOnCellContainer facets_on_cell(cell);
213 cell, facets_on_cell,
214 result, facet_evaluator_);
219 DeviceType
const & device_;
232 template <
typename DeviceType,
233 typename SHEQuantity,
234 typename ContainerType>
237 SHEQuantity
const & quan,
238 ContainerType & container)
252 template <
typename DeviceT,
typename SHEQuantity>
255 SHEQuantity
const & quan)
Common routines for the assembly of SHE equations.
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.
she_discretization_type_id she_discretization_type() const
Defines the physical properties of a device, e.g. doping. This is the implementation for 2d and highe...
A proxy object for a dispersion relation. Does NOT take ownership of the provided pointer!
double symmetry_factor() const
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
DeviceType::mesh_type MeshType
std::vector< double > value_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.
double operator()(FacetType const &facet) const
current_on_facet_by_ref_calculator(DeviceT const &d, viennashe::config const &conf, SHEQuantityT const &quan)
SHEQuantityT const & get_quan() const
A simple functor to hold a single value. Operator() should not take any arguments.
void operator()(T const &, value_type val) const
value_type operator()() const
A functor which holds a single value. Used in most of the postprocessing routines.
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.
VectorType::value_type norm_2(VectorType const &v)
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.
@ SHE_DISCRETIZATION_EVEN_ODD_ORDER_GENERALIZED_DF
@ SHE_DISCRETIZATION_EVEN_ODD_ORDER_DF
void check_current_conservation(DeviceT const &device, CurrentDensityT const ¤t_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.
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)
static double transverse_effective_mass(viennashe::carrier_type_id ctype)
static double dos_effective_mass(viennashe::carrier_type_id ctype)
static const double q
Elementary charge.