1#ifndef VIENNASHE_SHE_CARRIER_DENSITY_HPP
2#define VIENNASHE_SHE_CARRIER_DENSITY_HPP
23#include "viennagrid/mesh/mesh.hpp"
45 template <
typename SHEQuantity>
55 SHEQuantity
const & quan,
56 double energy_start = 0.0,
57 double energy_end = 1.0) : conf_(conf), quan_(quan), energy_start_(energy_start), energy_end_(energy_end) {}
60 : quan_(o.quan_), conf_(o.conf_), energy_start_(o.energy_start_), energy_end_(o.energy_end_)
64 : conf_(o.conf_), quan_(quan), energy_start_(o.energy_start_), energy_end_(o.energy_end_)
67 template <
typename ElementType>
74 if (quan_.get_unknown_mask(elem))
76 for (std::size_t index_H=1; index_H < quan_.get_value_H_size() - 1; ++index_H)
78 const long unknown_index = quan_.get_unknown_index(elem, index_H);
79 if (unknown_index < 0)
82 const double energy_lower = std::max( (quan_.get_kinetic_energy(elem, index_H - 1) + quan_.get_kinetic_energy(elem, index_H)) / 2.0,
84 const double energy_upper = std::min( (quan_.get_kinetic_energy(elem, index_H + 1) + quan_.get_kinetic_energy(elem, index_H)) / 2.0,
87 if (energy_upper >= 0 && energy_lower < energy_upper)
89 double height =
box_height(quan_, elem, index_H);
96 density += quan_.get_values(elem, index_H)[0] * height;
98 default:
throw std::runtime_error(
"carrier_density_wrapper_by_reference::operator(): Unknown SHE discretization type!");
105 for (std::size_t index_H=1; index_H < quan_.get_value_H_size() - 1; ++index_H)
107 const double energy_lower = std::max( (quan_.get_kinetic_energy(elem, index_H - 1) + quan_.get_kinetic_energy(elem, index_H)) / 2.0,
109 const double energy_upper = std::min( (quan_.get_kinetic_energy(elem, index_H + 1) + quan_.get_kinetic_energy(elem, index_H)) / 2.0,
111 if (energy_upper >= 0 && energy_lower < energy_upper)
113 double height =
box_height(quan_, elem, index_H);
120 density += quan_.get_boundary_value(elem, index_H) * height;
122 default:
throw std::runtime_error(
"carrier_density_wrapper_by_reference::operator(): Unknown SHE discretization type!");
136 SHEQuantity
const & quan_;
137 double energy_start_;
143 template <
typename SHEQuantity>
154 SHEQuantity
const & quan,
155 double energy_start = 0.0,
156 double energy_end = 1.0)
158 density_impl_by_ref_(conf, quan_ , energy_start, energy_end) { }
162 density_impl_by_ref_(o.density_impl_by_ref_, quan_ )
165 template <
typename ElementType>
168 return this->density_impl_by_ref_(elem);
173 carrier_density_by_ref_type density_impl_by_ref_;
178 template <
typename DeviceType,
179 typename SHEQuantity,
182 SHEQuantity
const & quan,
184 VectorType & carrier)
186 typedef typename DeviceType::mesh_type MeshType;
187 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
188 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
195 CellContainer cells(mesh);
196 for (CellIterator cit = cells.begin();
200 long carrier_index = quan.get_unknown_index(*cit);
203 if (carrier_index >= 0)
204 carrier[carrier_index] = carrier_dens(*cit);
218 template <
typename DeviceType,
219 typename SHEQuantity,
220 typename ContainerType>
222 SHEQuantity
const & quan,
224 ContainerType & container,
225 double energy_start = 0.0,
226 double energy_end = 1.0)
Defines a set of checker functors for micro-tests within ViennaSHE.
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
MeshT const & mesh() const
Returns the underlying mesh.
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
An accessor for the carrier density in the device.
carrier_density_wrapper(carrier_density_wrapper const &o)
carrier_density_by_ref_type::value_type value_type
value_type operator()(ElementType const &elem) const
carrier_density_wrapper(viennashe::config const &conf, SHEQuantity const &quan, double energy_start=0.0, double energy_end=1.0)
An accessor for the carrier density in the device by reference
carrier_density_wrapper_by_reference(carrier_density_wrapper_by_reference const &o, SHEQuantity const &quan)
value_type operator()(ElementType const &elem) const
carrier_density_wrapper_by_reference(carrier_density_wrapper_by_reference const &o)
carrier_density_wrapper_by_reference(viennashe::config const &conf, SHEQuantity const &quan, double energy_start=0.0, double energy_end=1.0)
The SHE configuration class is defined here.
Contains forward declarations and definition of small classes that must be defined at an early stage.
Implementation of numerical integration routines.
Writer for arbitrary macroscopic quantities.
logger< true > warn()
Used to log warnings. The logging level is logWARNING.
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....
void compute_carrier_density_vector(DeviceType const &device, SHEQuantity const &quan, viennashe::config::dispersion_relation_type const &dispersion, VectorType &carrier)
Computes the carrier density in the device and writes the result to a vector. Used during Gummel iter...
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 write_carrier_density_to_container(DeviceType const &device, SHEQuantity const &quan, viennashe::config::dispersion_relation_type const &dispersion, ContainerType &container, double energy_start=0.0, double energy_end=1.0)
Convenience function for writing the average expansion order to the container provided.
bool is_Inf(const ValueType &val)
Checks if a value of type ValueType is Inf using (value - value) != 0.
bool is_NaN(const ValueType &val)
Checks if a value of type ValueType is NaN using value != value.
The main ViennaSHE namespace. All functionality resides inside this namespace.
@ SHE_DISCRETIZATION_EVEN_ODD_ORDER_GENERALIZED_DF
@ SHE_DISCRETIZATION_EVEN_ODD_ORDER_DF
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.
Implementation of spherical harmonics plus helper functions.