ViennaSHE 1.3.0
Free open-source semiconductor device simulator using spherical harmonics expansions techniques.
timestep_quantities.hpp
Go to the documentation of this file.
1#ifndef VIENNASHE_SHE_TIMESTEP_QUANTITIES_HPP
2#define VIENNASHE_SHE_TIMESTEP_QUANTITIES_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// std
19#include <iostream>
20
21// viennashe
22#include "viennashe/forwards.h"
24#include "viennashe/config.hpp"
30
35namespace viennashe
36{
37 namespace she
38 {
39
40
42 template <typename DeviceType>
44 {
46 typedef std::vector<double> VectorType;
47
48 typedef typename DeviceType::mesh_type MeshType;
49
50 typedef typename viennagrid::result_of::facet<MeshType>::type FacetType;
51 typedef typename viennagrid::result_of::cell<MeshType>::type CellType;
52 typedef typename viennagrid::result_of::cell_tag<MeshType>::type CellTag;
53
54 typedef std::vector<std::vector<long> > index_vector_type;
55 typedef std::vector<std::vector<double> > trap_occupancy_type;
56
57 typedef std::vector<long> expansion_order_vector_type;
58 typedef std::vector<double> boundary_values_vector_type;
59 typedef std::vector<double> error_values_vector_type;
60
61 public:
62 typedef DeviceType device_type;
63
67 typedef std::deque<UnknownSHEQuantityType> UnknownSHEQuantityListType;
68
72
76
80
81
82 // use default implementations (should suffice)
83 //timestep_quantities() {}
84 //simulator_controller(simulator_controller const &) {}
85 //void operator=(simulator_controller const &) {}
86
87
92 std::size_t num_trap_unknown_indices(CellType const & c) const
93 {
94 return cell_trap_unknown_indices_.at(std::size_t(c.id().get())).size();
95 }
96
102 long trap_unknown_index(CellType const & c, long inner_index) const
103 {
104 return cell_trap_unknown_indices_.at(c.id().get()).at(inner_index);
105 }
106
107 void setup_trap_unkown_indices(DeviceType const & device)
108 {
109 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
110 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
111
112 typedef typename DeviceType::trap_level_container_type TrapContainerType;
113 typedef typename TrapContainerType::const_iterator TrapIterator;
114
115 long i = 0;
116 CellContainer cells(device.mesh());
117
118 cell_trap_unknown_indices_.resize(cells.size());
119 cell_trap_occupancies_.resize(cells.size());
120
121 for (CellIterator cit = cells.begin();
122 cit != cells.end();
123 ++cit)
124 {
125 TrapContainerType const & traps = device.get_trap_levels(*cit);
126 if (viennashe::materials::is_semiconductor(device.get_material(*cit)) && traps.size() > 0 )
127 {
128 std::vector<long> & idx = cell_trap_unknown_indices_.at(std::size_t(cit->id().get()));
129 idx.resize(traps.size());
130 cell_trap_occupancies_.at(std::size_t(cit->id().get())).resize(traps.size(), 0);
131
132 std::size_t j = 0;
133 for (TrapIterator trap_it = traps.begin(); trap_it != traps.end(); ++trap_it, ++i, ++j)
134 idx[j] = i;
135 }
136 else
137 {
138 // NO UNKNOWNS HERE !
139 cell_trap_unknown_indices_.at(std::size_t(cit->id().get())).clear();
140 cell_trap_unknown_indices_.at(std::size_t(cit->id().get())).resize(0);
141 }
142 }
143 }
144
145 double trap_occupancy(CellType const & c, std::size_t inner_index) const
146 {
147 return cell_trap_occupancies_.at(std::size_t(c.id().get())).at(inner_index);
148 }
149
150 void trap_occupancy(CellType const & c, std::size_t inner_index, double new_occupancy)
151 {
152 if(new_occupancy < 0.0 || new_occupancy > 1.0)
153 {
154 log::error() << "ERROR: Invalid trap occupancy: " << new_occupancy << std::endl;
155 throw viennashe::invalid_value_exception("trap_level.occupancy: occupancies have to be between 0 and 1!", new_occupancy);
156 }
157 cell_trap_occupancies_.at(std::size_t(c.id().get())).at(inner_index) = new_occupancy;
158 }
159
161
167 UnknownSHEQuantityType const & she_quantity(std::string quantity_name) const
168 {
169 for (std::size_t i=0; i<unknown_she_quantities_.size(); ++i)
170 {
171 if (quantity_name == unknown_she_quantities_[i].get_name())
172 return unknown_she_quantities_[i];
173 }
174
175 // quantity not found -> throw exception
176 std::stringstream ss;
177 ss << "No SHE quantity named '" << quantity_name << "'";
178 throw quantity_not_found_exception(ss.str());
179 }
180
186 UnknownSHEQuantityType & she_quantity(std::string quantity_name)
187 {
188 for (std::size_t i=0; i<unknown_she_quantities_.size(); ++i)
189 {
190 if (quantity_name == unknown_she_quantities_[i].get_name())
191 return unknown_she_quantities_[i];
192 }
193
194 // quantity not found -> throw exception
195 std::stringstream ss;
196 ss << "No SHE quantity named '" << quantity_name << "'";
197 throw quantity_not_found_exception(ss.str());
198 }
199
202
205
207 {
209 else if (ctype == viennashe::HOLE_TYPE_ID) return this->hole_distribution_function();
210 else throw viennashe::carrier_type_not_supported_exception("In carrier_distribution_function");
211 }
213 {
214 return static_cast<const self_type*>(this)->carrier_distribution_function(ctype); // call the const version; avoid code duplication
215 }
216
217 UnknownSHEQuantityListType & unknown_she_quantities() { return unknown_she_quantities_; }
218 UnknownSHEQuantityListType const & unknown_she_quantities() const { return unknown_she_quantities_; }
219
221
227 ResultQuantityType quantity(std::string quantity_name) const
228 {
229 for (std::size_t i=0; i<unknown_quantities_.size(); ++i)
230 {
231 if (quantity_name == unknown_quantities_[i].get_name())
232 return ResultQuantityType(quantity_name, unknown_quantities_[i].values());
233 }
234
235 // quantity not found -> throw exception
236 std::stringstream ss;
237 ss << "No quantity named '" << quantity_name << "'";
238 throw quantity_not_found_exception(ss.str());
239 }
240
247
248 std::deque<UnknownQuantityType> & unknown_quantities() { return unknown_quantities_; }
249 std::deque<UnknownQuantityType> const & unknown_quantities() const { return unknown_quantities_; }
250
256 UnknownQuantityType & get_unknown_quantity(std::string quantity_name)
257 {
258 for (std::size_t i=0; i<unknown_quantities_.size(); ++i)
259 {
260 if (quantity_name == unknown_quantities_[i].get_name())
261 return unknown_quantities_[i];
262 }
263
264 // quantity not found -> throw exception
265 std::stringstream ss;
266 ss << "No unknown quantity named '" << quantity_name << "'";
267 throw quantity_not_found_exception(ss.str());
268 }
269
275 UnknownQuantityType const & get_unknown_quantity(std::string quantity_name) const
276 {
277 for (std::size_t i=0; i<unknown_quantities_.size(); ++i)
278 {
279 if (quantity_name == unknown_quantities_[i].get_name())
280 return unknown_quantities_[i];
281 }
282
283 // quantity not found -> throw exception
284 std::stringstream ss;
285 ss << "No unknown quantity named '" << quantity_name << "'";
286 throw quantity_not_found_exception(ss.str());
287 }
288
289 private:
290
291 // Quantities in SHE space (at least f^n and/or f^p):
292 UnknownSHEQuantityListType unknown_she_quantities_;
293
294 // Poisson and DD related:
295 std::deque<UnknownQuantityType> unknown_quantities_;
296
297 // traps ...
298 index_vector_type cell_trap_unknown_indices_;
299 trap_occupancy_type cell_trap_occupancies_;
300
301
302 };
303
304 }
305}
306
307#endif
Contains the definition of per-device accessors (read-only!) for various quantities.
Exception thrown in the case that any code does not support the given carrier type.
Definition: exception.hpp:154
Common representation of any quantity associated with objects of a certain type.
long get_material(cell_type const &elem) const
Returns the material id of the provided cell.
Definition: device.hpp:502
MeshT const & mesh() const
Returns the underlying mesh.
Definition: device.hpp:145
trap_level_container_type const & get_trap_levels(cell_type const &cell) const
Returns all the trap levels defined for the provided cell.
Definition: device.hpp:615
Defines the physical properties of a device, e.g. doping. This is the implementation for 2d and highe...
Definition: device.hpp:818
Exception for the case that an invalid value (depends on the method called) is encountered.
Definition: exception.hpp:76
Exception in case a (requested) quantity cannot be found.
Definition: exception.hpp:133
Common representation of any quantity associated with two objects of a certain type and an index.
A convenience wrapper for accessing the energy distribution function on each vertex of the device.
A convenience wrapper for accessing the generalized energy distribution function (f * Z,...
A convenience wrapper for accessing the distribution function coefficients over the device....
The main SHE simulator controller class. Acts as an accessor for all SHE quantities needed for the si...
UnknownSHEQuantityType const & carrier_distribution_function(viennashe::carrier_type_id ctype) const
long trap_unknown_index(CellType const &c, long inner_index) const
Returns an unknown index for traps associated with a cell.
const_quantity< CellType > ResultQuantityType
UnknownSHEQuantityListType & unknown_she_quantities()
UnknownSHEQuantityType & hole_distribution_function()
const_she_quantity< CellType, FacetType > ResultSHEQuantityType
unknown_quantity< CellType > UnknownQuantityType
UnknownSHEQuantityType const & electron_distribution_function() const
ResultQuantityType quantity(std::string quantity_name) const
Returns the quantity identified by its name.
ResultQuantityType electron_density() const
void setup_trap_unkown_indices(DeviceType const &device)
UnknownQuantityType & get_unknown_quantity(std::string quantity_name)
Returns a reference to the unkown quantity identified by its name.
void trap_occupancy(CellType const &c, std::size_t inner_index, double new_occupancy)
std::deque< UnknownQuantityType > const & unknown_quantities() const
UnknownSHEQuantityType const & hole_distribution_function() const
UnknownSHEQuantityType & electron_distribution_function()
UnknownSHEQuantityType & she_quantity(std::string quantity_name)
Returns a reference to a SHE quantity identified by its name.
std::deque< UnknownQuantityType > & unknown_quantities()
UnknownSHEQuantityListType const & unknown_she_quantities() const
viennashe::she::edf_wrapper< DeviceType, UnknownSHEQuantityType > edf_type
unknown_she_quantity< CellType, FacetType > UnknownSHEQuantityType
UnknownSHEQuantityType unknown_she_quantity_type
double trap_occupancy(CellType const &c, std::size_t inner_index) const
viennashe::she::she_df_wrapper< DeviceType, UnknownSHEQuantityType > she_df_type
UnknownQuantityType const & get_unknown_quantity(std::string quantity_name) const
Returns a const reference to the unkown quantity identified by its name.
viennashe::she::generalized_edf_wrapper< DeviceType, UnknownSHEQuantityType > generalized_edf_type
ResultQuantityType hole_density() const
UnknownSHEQuantityType const & she_quantity(std::string quantity_name) const
Returns a const reference to a SHE quantity identified by its name.
ResultQuantityType lattice_temperature() const
std::size_t num_trap_unknown_indices(CellType const &c) const
Returns the number of inner unknown indices (aka. degree of freedom - dof) for traps associated with ...
std::deque< UnknownSHEQuantityType > UnknownSHEQuantityListType
UnknownSHEQuantityType & carrier_distribution_function(viennashe::carrier_type_id ctype)
The SHE configuration class is defined here.
Provides a convenience wrapper for accessing the distribution function coefficients over the device.
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.
logger< true > error()
Used to log errors. The logging level is logERROR.
Definition: log.hpp:301
bool is_semiconductor(long material_id)
Convenience function for checking whether the supplied material ID refers to a semiconductor.
Definition: all.hpp:156
std::string lattice_temperature()
std::string electron_distribution_function()
std::string density_gradient_hole_correction()
std::string hole_distribution_function()
std::string density_gradient_electron_correction()
std::string electron_density()
The main ViennaSHE namespace. All functionality resides inside this namespace.
Definition: accessors.hpp:40
carrier_type_id
Enumeration type for selecting the carrier type.
Definition: forwards.h:185
@ HOLE_TYPE_ID
Definition: forwards.h:188
@ ELECTRON_TYPE_ID
Definition: forwards.h:187
Provides a number of fundamental constants. All constants in SI units.
Defines a SHE quantity in (x, H)-space for use within the solvers of ViennaSHE.
Defines a generic simulator quantity for use within the solvers of ViennaSHE.