ViennaSHE 1.3.0
Free open-source semiconductor device simulator using spherical harmonics expansions techniques.
electric_flux_density.hpp
Go to the documentation of this file.
1#ifndef VIENNASHE_UTIL_POSTPROC_ELECTRIC_FLUX_DENSITY_HPP
2#define VIENNASHE_UTIL_POSTPROC_ELECTRIC_FLUX_DENSITY_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
30#include "viennashe/forwards.h"
35
36#include "viennashe/log/log.hpp"
37
40
45namespace viennashe
46{
47 namespace detail
48 {
52 template < typename DeviceType, 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_flux_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 typedef typename viennagrid::result_of::point<MeshType>::type PointType;
68
69 CellOnFacetContainer cells_on_facet(device_.mesh(), viennagrid::handle(device_.mesh(), facet));
70
71 if (cells_on_facet.size() < 2)
72 return 0;
73
74 CellOnFacetIterator cofit = cells_on_facet.begin();
75 CellType const & c1 = *cofit;
76 ++cofit;
77 CellType const & c2 = *cofit;
78
79
81
82 const double potential_center = potential_.get_value(c1);
83 const double potential_outer = potential_.get_value(c2);
84
85 PointType centroid_other_cell = viennagrid::centroid(c2);
86 PointType centroid_cell = viennagrid::centroid(c1);
87 PointType cell_connection = centroid_other_cell - centroid_cell;
88 //PointType cell_connection_normalized = cell_connection / viennagrid::norm(cell_connection);
89 //PointType facet_normal = cell_connection_normalized; // TODO: Substitute facet normal calculation here
90
91 const double connection_len = viennagrid::norm_2(cell_connection);
92 //const double interface_area = viennagrid::volume(facet) * viennagrid::inner_prod(facet_normal, cell_connection_normalized);
93
94 PointType facet_center = viennagrid::centroid(facet); //TODO: Use intersection of facet plane with connection
95 double connection_in_cell = viennagrid::norm(facet_center - centroid_cell);
96 double connection_in_other_cell = viennagrid::norm(facet_center - centroid_other_cell);
97 const double permittivity_mean = (connection_in_cell + connection_in_other_cell) /
98 (connection_in_cell/permittivity(c1) + connection_in_other_cell/permittivity(c2));
99
100 const double Emag = -(potential_outer - potential_center) / connection_len;
101
102 return Emag * permittivity_mean;
103 }
104
105 private:
106 DeviceType const & device_;
107 PotentialAccessorType const & potential_;
108
109
110 }; // electric_flux_on_facet
111
112 } // namespace detail
113
114
118 template < typename DeviceType, typename PotentialAccessorType >
120 {
121 private:
122 typedef typename DeviceType::mesh_type MeshType;
123 typedef typename MeshType::config_type ConfigType;
124
125 typedef typename viennagrid::result_of::point<MeshType>::type PointType;
126
127 public:
128 typedef typename viennagrid::result_of::facet<MeshType>::type FacetType;
129 typedef typename viennagrid::result_of::cell<MeshType>::type CellType;
130
131 typedef std::vector<double> value_type;
132
133 electric_flux_wrapper(DeviceType const & device, PotentialAccessorType const & potential)
134 : device_(device), potential_(potential)
135 { }
136
137 double operator()(FacetType const & facet) const
138 {
140
141 return facet_eval(facet);
142 }
143
144
145 value_type operator()(CellType const & cell) const
146 {
147 typedef typename viennagrid::result_of::const_facet_range<CellType>::type FacetOnCellContainer;
149
151
152 std::vector<double> E(3);
153
154 if (!no_conductor_filter(device_.get_material(cell))) return E;
155
157
158 FieldOnFacetEvaluator facet_evaluator(device_, potential_);
159
160 FacetOnCellContainer facets_on_cell(cell);
162 cell, facets_on_cell,
163 result, facet_evaluator);
164 return result();
165 } // operator()
166
167 private:
168 DeviceType const & device_;
169 PotentialAccessorType const & potential_;
170
171 }; // electric_flux_wrapper
172
173
174} // viennashe
175
176#endif /* VIENNASHE_DD_POSTPROC_ELECTRIC_FLUX_DENSITY_HPP */
177
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
Accessor for obtaining the permittivity in the device.
Definition: accessors.hpp:254
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...
Contains forward declarations and definition of small classes that must be defined at an early stage.
A logging facility providing fine-grained control over logging in ViennaSHE.
A very simple material database. Needs to be replaced by something more versatile soon.
Miscellaneous utilities.
double permittivity(long material_id)
Convenience function for returning the permittivity of the material identified by the ID provided.
Definition: all.hpp:214
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
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.
Simple accessor to get the electric flux density along an edge.
viennagrid::result_of::cell< MeshType >::type CellType
electric_flux_on_facet(DeviceType const &device, PotentialAccessorType const &potential)
viennagrid::result_of::facet< MeshType >::type FacetType
double operator()(FacetType const &facet) const
An electric flux accessor. Provides the electric flux along edges and on vertices given the electrost...
double operator()(FacetType const &facet) const
viennagrid::result_of::cell< MeshType >::type CellType
value_type operator()(CellType const &cell) const
viennagrid::result_of::facet< MeshType >::type FacetType
electric_flux_wrapper(DeviceType const &device, PotentialAccessorType const &potential)