ViennaSHE 1.3.0
Free open-source semiconductor device simulator using spherical harmonics expansions techniques.
electric_field.hpp
Go to the documentation of this file.
1#ifndef VIENNASHE_UTIL_POSTPROC_ELECTRIC_FIELD_HPP
2#define VIENNASHE_UTIL_POSTPROC_ELECTRIC_FIELD_HPP
3
4/* ============================================================================
5 Copyright (c) 2011-2022, Institute for Microelectronics,
6 Institute for Analysis and Scientific Computing,
7 TU Wien.
8
9 -----------------
10 ViennaSHE - The Vienna Spherical Harmonics Expansion Boltzmann Solver
11 -----------------
12
13 http://viennashe.sourceforge.net/
14
15 License: MIT (X11), see file LICENSE in the base directory
16=============================================================================== */
17
18
19// std
20#include <iostream>
21#include <fstream>
22#include <vector>
23
24// viennagrid
25#include "viennagrid/mesh/mesh.hpp"
26#include "viennagrid/algorithm/volume.hpp"
27#include "viennagrid/algorithm/inner_prod.hpp"
28
29// viennashe
35
36#include "viennashe/log/log.hpp"
37
41
46namespace viennashe
47{
48 namespace detail
49 {
51 template <typename DeviceType,
52 typename PotentialAccessorType>
54 {
55 typedef typename DeviceType::mesh_type MeshType;
56
57 typedef typename viennagrid::result_of::facet<MeshType>::type FacetType;
58 typedef typename viennagrid::result_of::cell<MeshType>::type CellType;
59
60 electric_field_on_facet(DeviceType const & device, PotentialAccessorType const & potential) : device_(device), potential_(potential) {}
61
62 template < typename FacetType>
63 double operator()(FacetType const & facet) const
64 {
65 typedef typename viennagrid::result_of::const_coboundary_range<MeshType, FacetType, CellType>::type CellOnFacetContainer;
66 typedef typename viennagrid::result_of::iterator<CellOnFacetContainer>::type CellOnFacetIterator;
67
68 CellOnFacetContainer cells_on_facet(device_.mesh(), viennagrid::handle(device_.mesh(), facet));
69
70 if (cells_on_facet.size() < 2)
71 return 0;
72
73 CellOnFacetIterator cofit = cells_on_facet.begin();
74 CellType const & c1 = *cofit;
75 ++cofit;
76 CellType const & c2 = *cofit;
77
78
79 const double potential_center = potential_.get_value(c1);
80 const double potential_outer = potential_.get_value(c2);
81
82 const double connection_len = viennagrid::norm_2(viennagrid::centroid(c2) - viennagrid::centroid(c1));
83 const double Emag = -(potential_outer - potential_center) / connection_len;
84
85 return Emag;
86 }
87 private:
88 DeviceType const & device_;
89 PotentialAccessorType const & potential_;
90
91 }; // electric_field_on_edge
92
93 } // namespace detail
94
96 template < typename DeviceType, typename PotentialAccessorType >
98 {
99 private:
100 typedef typename DeviceType::mesh_type MeshType;
101 typedef typename MeshType::config_type ConfigType;
102
103 typedef typename viennagrid::result_of::point<MeshType>::type PointType;
104
105 public:
106 typedef typename viennagrid::result_of::facet<MeshType>::type FacetType;
107 typedef typename viennagrid::result_of::cell<MeshType>::type CellType;
108
109 typedef std::vector<double> value_type;
110
111 electric_field_wrapper(DeviceType const & device, PotentialAccessorType const & potential) : device_(device), potential_(potential) { }
112
113 double operator()(FacetType const & facet) const
114 {
116
117 return facet_eval(facet);
118 }
119
120
121 value_type operator()(CellType const & cell) const
122 {
123 typedef typename viennagrid::result_of::const_facet_range<CellType>::type FacetOnCellContainer;
125
127
128 std::vector<double> E(3);
129
130 if (!no_conductor_filter(device_.get_material(cell))) return E;
131
133
134 FieldOnFacetEvaluator facet_evaluator(device_, potential_);
135
136 FacetOnCellContainer facets_on_cell(cell);
138 cell, facets_on_cell,
139 result, facet_evaluator);
140
141 return result();
142 } // operator()
143
144 private:
145 DeviceType const & device_;
146 PotentialAccessorType const & potential_;
147
148
149 }; // electric_field_wrapper
150
151
159 template <typename DeviceType,
160 typename PotentialAccessor,
161 typename ContainerType>
163 PotentialAccessor const & potential,
164 ContainerType & container)
165 {
167
169 }
170
171} // viennashe
172
173#endif
174
Defines a set of checker functors for micro-tests within ViennaSHE.
Defines the physical properties of a device, e.g. doping. This is the implementation for 2d and highe...
Definition: device.hpp:818
Simple checker class for checking whether a certain material is of a given type (conductor,...
Definition: all.hpp:184
A functor which holds a single value. Used in most of the postprocessing routines.
Definition: misc.hpp:59
Helper routines for projecting normal components of a vector-valued quantity defined on edges to vert...
A logging facility providing fine-grained control over logging in ViennaSHE.
Writer for arbitrary macroscopic quantities.
A very simple material database. Needs to be replaced by something more versatile soon.
Miscellaneous utilities.
VectorType::value_type norm_2(VectorType const &v)
Definition: linalg_util.hpp:37
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.
Definition: accessors.hpp:40
@ MATERIAL_NO_CONDUCTOR_ID
Definition: forwards.h:136
void write_electric_field_to_container(DeviceType const &device, PotentialAccessor const &potential, ContainerType &container)
Convenience function for writing the electric field to a container.
void write_macroscopic_quantity_to_container(DeviceType const &device, MacroscopicQuantityAccessor const &quantity, ContainerType &quantity_container)
Writes the provided macroscopic quantity to the container provided.
Definition: macroscopic.hpp:46
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.
An accessor to the electric field along a given edge. Electrostatic potential required.
viennagrid::result_of::cell< MeshType >::type CellType
electric_field_on_facet(DeviceType const &device, PotentialAccessorType const &potential)
viennagrid::result_of::facet< MeshType >::type FacetType
double operator()(FacetType const &facet) const
An accessor to the electric field on vertices and edges. Potential requiered.
electric_field_wrapper(DeviceType const &device, PotentialAccessorType const &potential)
viennagrid::result_of::facet< MeshType >::type FacetType
viennagrid::result_of::cell< MeshType >::type CellType
value_type operator()(CellType const &cell) const
double operator()(FacetType const &facet) const