1#ifndef VIENNASHE_SHE_ASSEMBLE_ALL_HPP
2#define VIENNASHE_SHE_ASSEMBLE_ALL_HPP
40 template <
typename DeviceType,
41 typename TimeStepQuantitiesT,
47 TimeStepQuantitiesT & old_quantities,
48 TimeStepQuantitiesT & quantities,
53 bool use_timedependence,
bool quan_valid)
55 typedef typename DeviceType::mesh_type MeshType;
57 typedef typename viennagrid::result_of::facet<MeshType>::type FacetType;
58 typedef typename viennagrid::result_of::cell<MeshType>::type CellType;
60 typedef typename viennagrid::result_of::const_facet_range<MeshType>::type FacetContainer;
61 typedef typename viennagrid::result_of::iterator<FacetContainer>::type FacetIterator;
63 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
64 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
66 typedef typename viennagrid::result_of::const_facet_range<CellType>::type FacetOnCellContainer;
67 typedef typename viennagrid::result_of::iterator<FacetOnCellContainer>::type FacetOnCellIterator;
69 typedef typename viennagrid::result_of::const_coboundary_range<MeshType, FacetType, CellType>::type CellOnFacetContainer;
70 typedef typename viennagrid::result_of::iterator<CellOnFacetContainer>::type CellOnFacetIterator;
76 std::vector< scattering_base<DeviceType> * > scattering_processes;
101 const std::size_t num_harmonics = std::size_t(L_max+1) * std::size_t(L_max+1);
102 CouplingMatrixType scatter_op_in(num_harmonics, num_harmonics);
103 CouplingMatrixType scatter_op_out(num_harmonics, num_harmonics);
105 for (std::size_t i=0; i < std::size_t(L_max+1) * std::size_t(L_max+1); ++i)
106 scatter_op_out(i,i) += 1.0;
107 scatter_op_in(0,0) += 1.0;
111 std::size_t coupling_rows =
static_cast<std::size_t
>((Lmax+1) * (Lmax+1));
112 std::size_t coupling_cols = coupling_rows;
114 log::debug<log_assemble_all>() <<
"* assemble_all(): Computing coupling matrices..." << std::endl;
115 CouplingMatrixType identity(coupling_rows, coupling_cols);
116 for (std::size_t i=0; i<coupling_rows; ++i)
117 for (std::size_t j=0; j<coupling_cols; ++j)
118 identity(i,j) = (i == j) ? 1.0 : 0.0;
120 CouplingMatrixType a_x(coupling_rows, coupling_cols);
121 CouplingMatrixType a_y(coupling_rows, coupling_cols);
122 CouplingMatrixType a_z(coupling_rows, coupling_cols);
125 CouplingMatrixType b_x(coupling_rows, coupling_cols);
126 CouplingMatrixType b_y(coupling_rows, coupling_cols);
127 CouplingMatrixType b_z(coupling_rows, coupling_cols);
132 static_cast<int>(Lmax));
134 CouplingMatrixType a_x_transposed = a_x.trans();
135 CouplingMatrixType a_y_transposed = a_y.trans();
136 CouplingMatrixType a_z_transposed = a_z.trans();
138 CouplingMatrixType b_x_transposed = b_x.trans();
139 CouplingMatrixType b_y_transposed = b_y.trans();
140 CouplingMatrixType b_z_transposed = b_z.trans();
144 log::debug<log_assemble_all>() <<
"a_x: " << a_x << std::endl;
145 log::debug<log_assemble_all>() <<
"a_y: " << a_y << std::endl;
146 log::debug<log_assemble_all>() <<
"a_z: " << a_z << std::endl;
147 log::debug<log_assemble_all>() <<
"b_x: " << b_x << std::endl;
148 log::debug<log_assemble_all>() <<
"b_y: " << b_y << std::endl;
149 log::debug<log_assemble_all>() <<
"b_z: " << b_z << std::endl;
151 log::debug<log_assemble_all>() <<
"identity: " << identity << std::endl;
153 log::debug<log_assemble_all>() <<
"scatter_op_out: " << scatter_op_out << std::endl;
154 log::debug<log_assemble_all>() <<
"scatter_op_in: " << scatter_op_in << std::endl;
164 log::debug<log_assemble_all>() <<
"assemble(): Acoustic phonon scattering is ENABLED!" << std::endl;
170 log::debug<log_assemble_all>() <<
"assemble(): Optical phonon scattering is ENABLED!" << std::endl;
176 log::debug<log_assemble_all>() <<
"assemble(): Ionized impurity scattering is ENABLED!" << std::endl;
184 log::warn() << std::endl <<
"WARNING: II scattering enabled, but 'BTE for holes' is disabled! Expect inconsistent results!" << std::endl;
186 log::warn() << std::endl <<
"WARNING: II scattering enabled, but 'BTE for electrons' is disabled! Expect inconsistent results!" << std::endl;
193 log::debug<log_assemble_all>() <<
"assemble(): Trapped charge scattering is ENABLED!" << std::endl;
202 log::debug<log_assemble_all>() <<
"assemble(): Surface roughness scattering is ENABLED!" << std::endl;
218 log::debug<log_assemble_all>() <<
"assemble(): Electron electron scattering is ENABLED!" << std::endl;
225 log::debug<log_assemble_all>() <<
"* assemble_all(): Even unknowns..." << std::endl;
227 CellContainer cells(mesh);
228 for (CellIterator cit = cells.begin();
232 log::debug<log_assemble_all>() <<
"* assemble_all(): Assembling on cell " << *cit << std::endl;
237 log::debug<log_assemble_all>() <<
"* assemble_all(): Assembling on energy index " << index_H << std::endl;
254 scatter_op_in, scatter_op_out);
262 FacetOnCellContainer facets_on_cell(*cit);
263 for (FacetOnCellIterator focit = facets_on_cell.begin();
264 focit != facets_on_cell.end();
268 log::debug<log_assemble_all>() <<
"* assemble_all(): Assembling coupling with facet " << *focit << std::endl;
271 if (!other_cell_ptr)
continue;
287 *cit, *focit, index_H,
288 coupling_matrix_diffusion,
289 coupling_matrix_drift,
297 if (use_timedependence)
315 log::info<log_assemble_all>() <<
"* assemble_all(): Odd unknowns..." << std::endl;
317 FacetContainer facets(mesh);
318 for (FacetIterator fit = facets.begin();
323 log::debug<log_assemble_all>() <<
"* assemble_all(): Assembling on facet " << *fit << std::endl;
328 log::debug<log_assemble_all>() <<
"* assemble_all(): Assembling on energy index " << index_H << std::endl;
337 scatter_op_in, scatter_op_out);
345 CellOnFacetContainer cells_on_facet(mesh, fit.handle());
346 for (CellOnFacetIterator cofit = cells_on_facet.begin();
347 cofit != cells_on_facet.end();
351 log::debug<log_assemble_all>() <<
"* assemble_all(): Assembling coupling with cell " << *cofit << std::endl;
354 if (!other_cell_ptr)
continue;
370 *cofit, *fit, index_H,
371 coupling_matrix_diffusion,
372 coupling_matrix_drift,
380 if (use_timedependence)
399 log::debug<log_assemble_all>() <<
"assemble(): Assembly for traps ..." << std::endl;
406 for (std::size_t i=0; i<scattering_processes.size(); ++i)
408 if ( scattering_processes[i] )
delete scattering_processes[i];
409 scattering_processes[i] = 0;
Common routines for the assembly of SHE equations.
Implements the assembly for electron-electron scattering.
Generic assembly of the scattering operator(s) is implemented here.
Assembly of the free-streaming operator is implemented here.
Generic assembly of traps is implemented here. At the moment only SRH type traps are supported.
The main SHE configuration class. To be adjusted by the user for his/her needs.
long max_expansion_order() const
Returns the current maximum expansion order.
equation_id get_electron_equation() const
bool with_holes() const
Returns true if holes are considered in the simulation.
equation_id get_hole_equation() const
bool with_traps() const
Returns true if traps are considered in the simulation.
double energy_spacing() const
Returns the uniform energy spacing of discrete energies.
bool with_electrons() const
Returns true if electrons are considered in the simulation.
viennashe::she::scatter_config & scattering()
Returns the configuration object for scattering.
long get_material(cell_type const &elem) const
Returns the material id of the provided cell.
MeshT const & mesh() const
Returns the underlying mesh.
Defines the physical properties of a device, e.g. doping. This is the implementation for 2d and highe...
Acoustic phonon scattering process.
Impact ionization scattering process.
Ionized impurity scattering process.
Optical phonon scattering process.
ionized_impurity_scattering_parameters const & ionized_impurity() const
Returns the parameters for ionized impurity scattering. Const-version.
impact_ionization_scattering_parameters const & impact_ionization() const
Returns the parameters for impact ionization scattering. Const-version.
surface_scattering_parameters const & surface() const
Returns the parameters for surface scattering. Const-version.
acoustic_phonon_scattering_parameters const & acoustic_phonon() const
Returns the parameters for acoustic phonon scattering. Const-version.
trapped_charge_scattering_parameters const & trapped_charge() const
Returns the parameters for fixed charge scattering. Const-version.
optical_phonon_scattering_parameters const & optical_phonon() const
Returns the parameters for optical phonon scattering. Const-version.
bool electron_electron() const
Returns true if electron-electron scattering is activated.
Surface scattering process.
Trapped charge scattering process.
General representation of any solver quantity defined on two different element types (e....
carrier_type_id get_carrier_type_id() const
std::string get_name() const
std::size_t get_value_H_size() const
Exception for the case that a requested feature is not available (due to configuration or due to not ...
Computes the electric field from a potential.
A logging facility providing fine-grained control over logging in ViennaSHE.
logger< true > warn()
Used to log warnings. The logging level is logWARNING.
bool is_conductor(long material_id)
Convenience function for checking whether the supplied material ID refers to a metal.
void assemble_traps(DeviceType const &device, TimeStepQuantitiesT &quantities, viennashe::config const &conf, SHEQuantity const &quan, MatrixType &matrix, VectorType &rhs)
void fill_coupling_matrices(MatrixType &a_x, MatrixType &a_y, MatrixType &a_z, MatrixType &b_x, MatrixType &b_y, MatrixType &b_z, int L_max)
Public interface for filling coupling matrices.
void assemble_scattering_operator_on_box(ScatterProcessesT const &scatter_processes, DeviceType const &device, viennashe::config const &conf, SHEQuantity const &quan, MatrixType &A, VectorType &b, ElementType const &elem, std::size_t index_H, CouplingMatrix const &coupling_in_scatter, CouplingMatrix const &coupling_out_scatter)
void assemble(DeviceType &device, TimeStepQuantitiesT &old_quantities, TimeStepQuantitiesT &quantities, viennashe::config const &conf, viennashe::she::unknown_she_quantity< VertexT, EdgeT > const &quan, MatrixType &A, VectorType &b, bool use_timedependence, bool quan_valid)
MatrixType coupling_matrix_in_direction(MatrixType const &m1, MatrixType const &m2, MatrixType const &m3, VertexType const &v1, VertexType const &v2, PolarityTag const &polarity)
Returns dot(M, n), where M=(m1, m2, m3) is the vector of coupling matrices, and n = v2 - v1 is the di...
void assemble_ee_scattering(DeviceType const &device, viennashe::config const &conf, SHEQuantityT const &quan, SHEQuantityT const &quan_old, MatrixType &matrix, VectorType &rhs)
Interface function for electron-electron scattering. Differs significantly from ac,...
void assemble_timederivative(DeviceType const &device, viennashe::config const &conf, SHEQuantity const &quan, SHEQuantity const &quan_old, MatrixType &A, VectorType &b, ElementType const &elem, std::size_t index_H, CouplingMatrixType const &identity_matrix, QuantityPotential const &quan_pot, QuantityPotentialOld const &quan_pot_old)
void assemble_boundary_on_box(DeviceType const &device, viennashe::config const &conf, SHEQuantity const &quan, MatrixType &A, VectorType &b, CellType const &cell, std::size_t index_H, CouplingMatrixType const &coupling_identity)
Worker function for the assembly of the free streaming operator. Handles the assembly of both even an...
void assemble_free_streaming_operator_on_box(DeviceType const &device, viennashe::config const &conf, SHEQuantity const &quan, MatrixType &A, VectorType &, CellType const &cell, FacetType const &facet, std::size_t index_H, CouplingMatrixType const &coupling_matrix_diffusion, CouplingMatrixType const &coupling_matrix_drift, bool odd_assembly)
Worker function for the assembly of the free streaming operator. Handles the assembly of both even an...
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.
An accessor to the electric field on vertices and edges. Potential requiered.
Defines the log keys used within the viennashe::she namespace.