1#ifndef VIENNASHE_ACCESSORS_HPP
2#define VIENNASHE_ACCESSORS_HPP
19#include "viennagrid/forwards.hpp"
20#include "viennagrid/mesh/mesh.hpp"
21#include "viennagrid/algorithm/voronoi.hpp"
22#include "viennagrid/mesh/neighbor_iteration.hpp"
50 template <
typename DeviceType,
typename CellType >
52 double * doping_n_ret,
double * doping_p_ret)
54 typedef typename viennagrid::result_of::const_facet_range<CellType>::type FacetOnCellContainer;
55 typedef typename viennagrid::result_of::iterator<FacetOnCellContainer>::type FacetOnCellIterator;
62 FacetOnCellContainer facets(cell);
63 for (FacetOnCellIterator focit = facets.begin(); focit != facets.end(); ++focit)
66 if (other_cell_ptr == 0)
continue;
75 if(N > 1) doping_n = std::pow(doping_n, 1.0/N);
76 if(N > 1) doping_p = std::pow(doping_p, 1.0/N);
79 if(doping_n_ret) *doping_n_ret = doping_n;
80 if(doping_p_ret) *doping_p_ret = doping_p;
89 template <
typename ConstantType>
101 ConstantType constant_;
105 template <
typename DeviceType>
108 typedef typename DeviceType::mesh_type MeshType;
110 typedef typename viennagrid::result_of::cell<MeshType>::type
cell_type;
118 DeviceType
const & device_;
122 template <
typename DeviceType>
125 typedef typename DeviceType::mesh_type MeshType;
127 typedef typename viennagrid::result_of::cell<MeshType>::type
cell_type;
135 DeviceType
const & device_;
139 template <
typename DeviceType>
142 typedef typename DeviceType::mesh_type MeshType;
144 typedef typename viennagrid::result_of::cell<MeshType>::type
cell_type;
153 DeviceType
const & device_;
159 template <
typename DeviceType>
162 typedef typename DeviceType::mesh_type MeshType;
165 typedef typename viennagrid::result_of::cell<MeshType>::type
cell_type;
166 typedef typename viennagrid::result_of::facet<MeshType>::type
facet_type;
175 device_.get_doping_n(c),
176 device_.get_doping_p(c));
180 typedef typename viennagrid::result_of::const_neighbor_range<MeshType, cell_type, facet_type>::type NeighborRange;
181 typedef typename viennagrid::result_of::iterator<NeighborRange>::type NeighborIterator;
184 NeighborRange neighbors(device_.mesh(), viennagrid::handle(device_.mesh(), c));
185 for (NeighborIterator nit = neighbors.begin(); nit != neighbors.end(); ++nit)
189 device_.get_doping_n(*nit),
190 device_.get_doping_p(*nit));
199 DeviceType
const & device_;
204 template <
typename DeviceT>
207 typedef typename DeviceT::mesh_type MeshType;
210 typedef typename viennagrid::result_of::cell<MeshType>::type
cell_type;
219 return device_.get_contact_potential(c) + built_in_pot_(c);
221 throw std::runtime_error(
"Logic error: Accessing boundary potential for insulators!");
225 DeviceT
const & device_;
230 template <
typename DeviceType>
233 typedef typename DeviceType::mesh_type MeshType;
236 typedef typename viennagrid::result_of::cell<MeshType>::type
cell_type;
243 return device_.get_contact_potential(c);
247 DeviceType
const & device_;
252 template <
typename DeviceType>
255 typedef typename DeviceType::mesh_type MeshType;
258 typedef typename viennagrid::result_of::cell<MeshType>::type
cell_type;
266 DeviceType
const & device_;
271 template <
typename DeviceType>
274 typedef typename DeviceType::mesh_type MeshType;
277 typedef typename viennagrid::result_of::cell<MeshType>::type
cell_type;
285 return device_.get_fixed_charge(c);
289 DeviceType
const & device_;
293 template <
typename DeviceType>
296 typedef typename DeviceType::mesh_type MeshType;
299 typedef typename viennagrid::result_of::cell<MeshType>::type
cell_type;
311 DeviceType
const & device_;
315 template <
typename DeviceType>
321 : device_(d), carrier_type_id_(ctype), doping_bnd_(doping_bnd) { }
323 template <
typename ElementType >
326 const double temperature = device_.get_lattice_temperature(el);
327 return (this->
operator ()(el, temperature));
330 template <
typename ElementType >
335 const long matid = device_.get_material(el);
340 double doping_n = device_.get_doping_n(el);
341 double doping_p = device_.get_doping_p(el);
348 if (doping_bnd_ ==
true)
364 DeviceType
const & device_;
Accessor for obtaining the Dirichlet boundary condition for the Poisson equation in the device (conta...
value_type operator()(cell_type const &c) const
viennagrid::result_of::cell< MeshType >::type cell_type
boundary_potential_accessor(DeviceT const &d)
Accessor for retrieving the built-in potential in the device.
viennagrid::result_of::cell< MeshType >::type cell_type
value_type operator()(cell_type const &c) const
built_in_potential_accessor(DeviceType const &d)
viennagrid::result_of::facet< MeshType >::type facet_type
Exception thrown in the case that any code does not support the given carrier type.
An accessor which returns a constant value independent of the object passed.
value_type operator()(T const &) const
constant_accessor(ConstantType const &c)
double get_doping_p(cell_type const &c) const
Returns the donator doping (in m^-3) in the specified cell.
long get_material(cell_type const &elem) const
Returns the material id of the provided cell.
MeshT const & mesh() const
Returns the underlying mesh.
double get_doping_n(cell_type const &c) const
Returns the donator doping (in m^-3) in the specified cell.
Defines the physical properties of a device, e.g. doping. This is the implementation for 2d and highe...
Accessor to get the diffusivity. Used in the assembly of the heat diffusion equation.
viennagrid::result_of::cell< MeshType >::type cell_type
diffusivity_accessor(DeviceType const &d)
value_type operator()(cell_type const &cell, double T) const
Accessor for returning the doping (donator/acceptor doping is defined in the CTOR)
viennagrid::result_of::cell< MeshType >::type cell_type
doping_accessor(DeviceType const &d, viennashe::carrier_type_id ctype)
This CTOR specifies donator doping.
value_type operator()(cell_type const &c) const
Accessor for fixed charges.
viennagrid::result_of::cell< MeshType >::type cell_type
fixed_charge_accessor(DeviceType const &d)
value_type operator()(cell_type const &c) const
Returns the fixed charge in As.
Exception for the case that an invalid value (depends on the method called) is encountered.
Returns the lattice temperature on the device.
value_type operator()(cell_type const &c) const
lattice_temperature_accessor(DeviceType const &d)
viennagrid::result_of::cell< MeshType >::type cell_type
Accessor for obtaining the permittivity in the device.
value_type operator()(cell_type const &cell) const
permittivity_accessor(DeviceType const &d)
viennagrid::result_of::cell< MeshType >::type cell_type
Returns the thermal potential in the device.
value_type operator()(cell_type const &c) const
viennagrid::result_of::cell< MeshType >::type cell_type
thermal_potential_accessor(DeviceType const &d)
Contains the definition of a device class independent of the actual macroscopic model to be solved.
Provides the exceptions used in the main viennashe namespace.
Contains forward declarations and definition of small classes that must be defined at an early stage.
A very simple material database. Needs to be replaced by something more versatile soon.
void get_dopings_from_neighboring_semiconductor_cells(DeviceType const &device, CellType const &cell, double *doping_n_ret, double *doping_p_ret)
Retrieves the averaged dopings from neighboring semiconductor cells.
bool is_semiconductor(long material_id)
Convenience function for checking whether the supplied material ID refers to a semiconductor.
double permittivity(long material_id)
Convenience function for returning the permittivity of the material identified by the ID provided.
bool is_insulator(long material_id)
Convenience function for checking whether the supplied material ID refers to an oxide.
double diffusivity(long material_id)
bool is_conductor(long material_id)
Convenience function for checking whether the supplied material ID refers to a metal.
double get_thermal_potential(double T)
Returns the thermal potential for the provided temperature.
double contact_carrier_ohm(double temperature, double doping_n, double doping_p, viennashe::carrier_type_id ctype)
Consistently calculates the contact carrier concentrations for thermal bath contacts.
double built_in_potential(double temperature, double doping_n, double doping_p)
Computes the built-in potential for a given temperature and given doping.
CellT const * get_other_cell_of_facet(MeshT const &mesh, FacetT const &facet, CellT const &cell)
Helper function returning a const-pointer to the 'second cell' of a facet, or NULL if there is no sec...
The main ViennaSHE namespace. All functionality resides inside this namespace.
carrier_type_id
Enumeration type for selecting the carrier type.
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.