ViennaSHE 1.3.0
Free open-source semiconductor device simulator using spherical harmonics expansions techniques.
rescaling.hpp
Go to the documentation of this file.
1#ifndef VIENNASHE_SHE_RESCALING_HPP
2#define VIENNASHE_SHE_RESCALING_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#include <math.h>
21#include <cfloat>
22
23// viennashe
24#include "viennashe/config.hpp"
27
28// viennagrid
29#include "viennagrid/mesh/mesh.hpp"
30
35namespace viennashe
36{
37 namespace she
38 {
39
47 template <typename DeviceType,
48 typename SHEQuantity,
49 typename VectorType>
50 void setup_unknown_scaling(DeviceType const & device,
51 viennashe::config const & conf,
52 SHEQuantity & quan,
53 VectorType & scaling_vector)
54 {
55 typedef typename DeviceType::mesh_type MeshType;
56 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
57 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
58
59 CellContainer cells(device.mesh());
60 for (CellIterator cit = cells.begin();
61 cit != cells.end();
62 ++cit)
63 {
64 double T = device.get_lattice_temperature(*cit);
65
66 for (std::size_t index_H = 0; index_H < quan.get_value_H_size(); ++index_H)
67 {
68 long index_base = quan.get_unknown_index(*cit, index_H);
69 if (index_base < 0)
70 continue;
71
72 long num_per_node = static_cast<long>(quan.get_unknown_num(*cit, index_H));
73 for (long i=0; i<num_per_node; ++i)
74 {
76 scaling_vector[std::size_t(index_base + i)] = exp(- quan.get_kinetic_energy(*cit, index_H) / (viennashe::physics::constants::kB * T));
77 else
78 scaling_vector[std::size_t(index_base + i)] = exp(- quan.get_value_H(index_H) / (viennashe::physics::constants::kB * T));
79 }
80 }
81 }
82 }
83
89 template <typename MatrixType,
90 typename VectorType>
91 void rescale_system(MatrixType & system_matrix,
92 VectorType const & scaling)
93 {
94 typedef typename MatrixType::row_type RowType;
95 typedef typename MatrixType::iterator2 AlongRowIterator;
96
97 for (std::size_t i=0; i<system_matrix.size1(); ++i)
98 {
99 RowType & row_i = system_matrix.row(i);
100 for (AlongRowIterator iter = row_i.begin();
101 iter != row_i.end();
102 ++iter)
103 {
104 iter->second *= scaling[iter->first];
105 }
106 }
107 }
108
109
110 } //namespace she
111} //namespace viennashe
112
113#endif
The main SHE configuration class. To be adjusted by the user for his/her needs.
Definition: config.hpp:124
she_scaling_type_id she_scaling_type() const
Definition: config.hpp:363
double get_lattice_temperature(cell_type const &c) const
Returns the lattice temperature on a cell.
Definition: device.hpp:255
MeshT const & mesh() const
Returns the underlying mesh.
Definition: device.hpp:145
Defines the physical properties of a device, e.g. doping. This is the implementation for 2d and highe...
Definition: device.hpp:818
The SHE configuration class is defined here.
void rescale_system(MatrixType &system_matrix, VectorType const &scaling)
Scales the system matrix (right-preconditioner) with respect to the rescaled unknowns.
Definition: rescaling.hpp:91
void setup_unknown_scaling(DeviceType const &device, viennashe::config const &conf, SHEQuantity &quan, VectorType &scaling_vector)
Initializes the unknown scaling. Returns a vector holding the scaling factors.
Definition: rescaling.hpp:50
The main ViennaSHE namespace. All functionality resides inside this namespace.
Definition: accessors.hpp:40
@ SHE_SCALING_KINETIC_ENERGY
Definition: forwards.h:151
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.
static const double kB
Boltzmann constant.
Definition: constants.hpp:46