1#ifndef VIENNASHE_SHE_SIMULATOR_HPP
2#define VIENNASHE_SHE_SIMULATOR_HPP
73 template<
typename DeviceT,
typename QuantityT>
76 typedef typename DeviceT::mesh_type MeshType;
78 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
79 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
82 for (CellIterator cit = cells.begin();
89 quan.set_unknown_mask(*cit,
true);
93 template<
typename DeviceT,
typename QuantityT>
96 typedef typename DeviceT::mesh_type MeshType;
98 typedef typename viennagrid::result_of::cell<MeshType>::type CellType;
100 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
101 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
104 for (CellIterator cit = cells.begin();
108 quan.set_unknown_mask(*cit,
false);
111 quan.set_unknown_mask(*cit,
true);
117 quan.set_unknown_mask(*cit,
true);
133 template<
typename DeviceT,
typename QuantityT,
typename BoundaryValueAccessorT>
137 BoundaryValueAccessorT boundary_value_accessor,
140 typedef typename DeviceT::mesh_type MeshType;
142 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
143 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
146 for (CellIterator cit = cells.begin();
153 typename BoundaryValueAccessorT::value_type bnd_value = boundary_value_accessor(*cit);
154 quan.set_boundary_type(*cit, bnd_id);
155 quan.set_boundary_value(*cit, bnd_value);
156 quan.set_value(*cit, bnd_value);
170 template<
typename DeviceT,
typename CellT,
typename FacetT>
176 typedef typename DeviceT::mesh_type MeshType;
178 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
179 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
182 for (CellIterator cit = cells.begin();
199 template<
typename DeviceT,
typename QuantityT,
typename BoundaryValueAccessorT>
202 BoundaryValueAccessorT
const & initial_guess_accessor)
204 typedef typename DeviceT::mesh_type MeshType;
206 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
207 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
210 for (CellIterator cit = cells.begin();
214 quan.set_value(*cit, initial_guess_accessor(*cit));
222 template<
typename DeviceT,
typename UnknownQuantityListT>
225 typedef typename DeviceT::mesh_type MeshType;
227 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
228 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
235 for (CellIterator cit = cells.begin();
256 template<
typename UnknownQuantityT,
typename VectorType>
261 for ( std::size_t j = 0; j < x.size(); ++j)
265 norm += x.at(j) * x.at(j);
269 const double current_val = spatial_quan.values().at(j);
270 const double zw = (std::abs(current_val) > 0) ? (x.at(j) / current_val) : ( x.at(j) );
285 template<
typename DeviceT,
typename CellT,
typename FacetT>
291 typedef typename DeviceT::mesh_type MeshType;
293 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
294 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
304 for (CellIterator cit = cells.begin();
308 const double new_value = density_wrapper(*cit);
309 const double old_value = spatial_quan.
get_value(*cit);
311 if (std::fabs(old_value) > 0)
312 zw = (new_value - old_value) / old_value;
319 return std::sqrt(norm);
330 template<
typename DeviceT,
typename TimeStepQuantitiesT,
typename VectorT>
332 TimeStepQuantitiesT
const & unknown_quantities,
335 typedef typename DeviceT::mesh_type MeshType;
337 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
338 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
340 typedef typename TimeStepQuantitiesT::UnknownQuantityType UnknownQuantityType;
343 CellContainer cells(mesh);
345 double potential_update_norm = 0;
347 for (std::size_t i=0; i<unknown_quantities.unknown_quantities().size(); ++i)
349 UnknownQuantityType
const & current_quan = unknown_quantities.unknown_quantities()[i];
354 for (CellIterator cit = cells.begin();
358 long idx = current_quan.get_unknown_index(*cit);
360 potential_update_norm += x[std::size_t(idx)] * x[std::size_t(idx)];
364 return std::sqrt(potential_update_norm);
373 template<
typename DeviceT,
typename UnknownQuantityT,
typename VectorT>
375 UnknownQuantityT
const & unknown_quantities_,
378 (void)
device; (void)unknown_quantities_;
379 double total_update_norm = 0;
381 for ( std::size_t j = 0; j < x.size(); ++j)
382 total_update_norm += x.at(j) * x.at(j);
384 return total_update_norm;
394 template<
typename DeviceT,
typename TimeStepQuantitiesT,
typename VectorType>
397 TimeStepQuantitiesT & unknown_quantities,
398 VectorType
const & x)
400 typedef typename DeviceT::mesh_type MeshType;
402 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
403 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
405 typedef typename TimeStepQuantitiesT::UnknownQuantityType UnknownQuantityType;
408 CellContainer cells(mesh);
413 for (std::size_t i=0; i<unknown_quantities.unknown_quantities().size(); ++i)
415 UnknownQuantityType & current_quan = unknown_quantities.unknown_quantities()[i];
417 double norm_inf_update = 0;
418 double norm_inf_current = 0;
420 for (CellIterator cit = cells.begin();
424 long idx = current_quan.get_unknown_index(*cit);
427 norm_inf_current = std::max(norm_inf_current, current_quan.get_value(*cit));
428 norm_inf_update = std::max(norm_inf_update, x[std::size_t(idx)]);
432 double norm_rel_update = norm_inf_current > 0 ? norm_inf_update / norm_inf_current : 1.0;
434 if (norm_inf_update == 0.0
441 std::size_t damping_iter_max = 10;
444 for (std::size_t damping_iter = 0; damping_iter < damping_iter_max; ++damping_iter)
446 if (damping_iter == 0)
448 else if (damping_iter == 1)
449 alpha = (1.0 + delta * std::log(norm_rel_update)) / (1.0 + delta * (norm_rel_update - 1.0));
453 double update_norm = 0.0;
454 double current_norm = 0.0;
456 bool do_reject =
false;
459 for (CellIterator cit = cells.begin();
463 long index = current_quan.get_unknown_index(*cit);
466 double update_value = alpha * x[std::size_t(index)];
467 double current_value = current_quan.get_value(*cit);
469 update_norm += update_value * update_value;
470 current_norm += current_value * current_value;
472 if ( std::abs(current_value) != 0.0
473 && std::abs(current_value) < 0.5 * std::abs(alpha * update_value)
477 if (current_quan.get_logarithmic_damping() && current_value + update_value <= 0)
482 if (update_norm > current_norm)
486 if ( (damping_iter < damping_iter_max - 1)
493 for (CellIterator cit = cells.begin();
497 long index = current_quan.get_unknown_index(*cit);
500 double update_value = alpha * x[std::size_t(index)];
501 double current_value = current_quan.get_value(*cit);
503 current_quan.set_value(*cit, current_value + update_value);
523 template<
typename DeviceT,
typename CellT,
typename FacetT,
typename VectorType>
528 VectorType
const & x,
bool force_no_damping =
false)
530 typedef typename DeviceT::mesh_type MeshType;
532 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
533 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
535 typedef typename viennagrid::result_of::const_facet_range<MeshType>::type FacetContainer;
536 typedef typename viennagrid::result_of::iterator<FacetContainer>::type FacetIterator;
542 density_wrapper_type density_wrapper(conf, quan);
546 for (CellIterator cit = cells.begin();
554 quan.
set_values(*cit, index_H, &(x[
static_cast<std::size_t
>(index)]));
558 if (force_no_damping)
560 spatial_quan.
set_value(*cit, density_wrapper(*cit));
565 double new_value = density_wrapper(*cit);
566 const double current_value = spatial_quan.
get_value(*cit);
569 if (new_value < current_value * 1e-10)
570 new_value = current_value * 1e-10;
572 const double a1 = std::pow(current_value, 1.0 - alpha);
573 const double a2 = std::pow(new_value, alpha);
579 spatial_quan.
set_value(*cit, current_value * (1.0 - alpha) + new_value * alpha);
585 for (FacetIterator fit = facets.begin();
593 quan.
set_values(*fit, index_H, &(x[
static_cast<std::size_t
>(index)]));
606 template<
typename DeviceT,
typename VertexT,
typename VectorType>
610 VectorType
const & x)
612 typedef typename DeviceT::mesh_type MeshType;
614 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
615 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
617 double update_norm = 0;
619 for (CellIterator cit = cells.begin();
624 double new_value = current_value;
631 update_norm += std::abs(new_value - current_value);
635 if (new_value < current_value * 1e-10)
637 new_value = current_value * 1e-10;
659 template<
typename DeviceT,
typename VertexT,
typename VectorType>
663 VectorType
const & x,
bool force_no_damping =
false)
673 template <
typename DeviceType>
680 typedef std::vector<double> VectorType;
682 typedef typename DeviceType::mesh_type MeshType;
684 typedef typename viennagrid::result_of::vertex<MeshType>::type VertexType;
685 typedef typename viennagrid::result_of::edge<MeshType>::type EdgeType;
686 typedef typename viennagrid::result_of::cell<MeshType>::type CellType;
688 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
689 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
725 if(conf.setup_insulator_distances())
727 throw std::runtime_error(
"TODO: setup_insulator_distances()");
736 std::size_t cell_num = viennagrid::cells(
device.
mesh()).size();
737 std::size_t facet_num = viennagrid::facets(
device.
mesh()).size();
749 if (conf.with_electrons())
761 if (conf.with_holes())
781 if (conf.quantum_correction())
782 viennashe::log::info<viennashe::log_simulator>() <<
"* simulator(): Density Gradient (electrons) ... Insulator boundary condition is DIRICHLET " << std::endl;
788 if (conf.quantum_correction())
789 viennashe::log::info<viennashe::log_simulator>() <<
"* simulator(): Density Gradient (electrons) ... Insulator boundary condition is ROBIN " << std::endl;
802 if (conf.quantum_correction())
803 viennashe::log::info<viennashe::log_simulator>() <<
"* simulator(): Density Gradient (holes) ... Insulator boundary condition is DIRICHLET " << std::endl;
809 if (conf.quantum_correction())
810 viennashe::log::info<viennashe::log_simulator>() <<
"* simulator(): Density Gradient (holes) ... Insulator boundary condition is ROBIN " << std::endl;
840 if (conf.with_electrons())
851 if (conf.with_holes())
865 template <
typename QuantityAccessorT>
868 CellContainer cells(
device().mesh());
870 transfer_provided_quantities(quan_acc,
quantities().get_unknown_quantity(quan_name), cells);
888 double initial_residual_norm = 0;
892 bool update_no_damping =
false;
893 bool break_after_update =
false;
902 update_no_damping =
true;
928 if ( quantities_history_.size() > 1 )
943 if (nonlinear_iter == 1)
955 if (nonlinear_iter == 1)
961 log::info<log_simulator>() <<
"* run(): -- Newton scheme --" << std::endl;
963 log::info<log_simulator>() <<
"* run(): -- Gummel scheme --" << std::endl;
965 log::info<log_simulator>() << std::setw(5) <<
" Iter" <<
" | ";
968 log::info<log_simulator>() << std::setw(9) <<
"#f_even^e" <<
" | " << std::setw(8) <<
"#f_odd^e" <<
" | ";
970 log::info<log_simulator>() << std::setw(8) <<
"#f_even^h" <<
" | " << std::setw(8) <<
"#f_odd^h" <<
" | ";
972 log::info<log_simulator>() << std::setw(9) <<
"ResidNorm" <<
" | "
973 << std::setw(9) <<
"|d_pot|_2" <<
" | "
974 << std::setw(9) <<
"TotUpdate" <<
" | "
975 << std::setw(8) <<
"Time (s)" << std::endl;
978 log::info<log_simulator>() << std::setw(5) << nonlinear_iter <<
" | ";
987 std::cout << std::flush ;
994 double potential_norm_increment = 0;
995 double current_residual_norm = 0;
996 double total_update_norm = 0;
1000 std::size_t total_number_of_unknowns = 0;
1001 for (viennashe::map_info_type::const_iterator it = map_info.begin(); it != map_info.end(); ++it)
1002 total_number_of_unknowns += (it->second).first + (it->second).second;
1004 MatrixType A(total_number_of_unknowns, total_number_of_unknowns);
1005 VectorType b(total_number_of_unknowns);
1014 (quantities_history_.size() > 1), nonlinear_iter > 1);
1017 VectorType x = this->solve(A, b,
true);
1032 if (number_of_unknowns == 0)
1036 MatrixType A(number_of_unknowns, number_of_unknowns);
1037 VectorType b(number_of_unknowns);
1042 VectorType x = solve(A, b);
1059 std::size_t number_of_unknowns = quan_unknowns.first + quan_unknowns.second;
1060 if (number_of_unknowns == 0)
1064 MatrixType A(number_of_unknowns, number_of_unknowns);
1065 VectorType b(number_of_unknowns);
1068 this->
quantities().unknown_she_quantities()[i], A, b,
1069 (quantities_history_.size() > 1), nonlinear_iter > 1);
1085 config(), x, update_no_damping);
1094 config(), x, update_no_damping);
1100 log::info<log_simulator>() << std::scientific << std::setprecision(3) << std::setw(9) << current_residual_norm <<
" | "
1101 << std::scientific << std::setprecision(3) << std::setw(9) << potential_norm_increment <<
" | "
1102 << std::scientific << std::setprecision(3) << std::setw(9) << total_update_norm <<
" | "
1103 << std::fixed << std::setprecision(3) << std::setw(8) << stopwatch.
get() << std::endl;
1108 if (break_after_update)
1111 if (!current_residual_norm)
1115 if (nonlinear_iter == 1)
1117 initial_residual_norm = current_residual_norm;
1119 else if (current_residual_norm / initial_residual_norm < 1e-10)
1121 update_no_damping =
true;
1122 break_after_update =
true;
1125 else if (potential_norm_increment < this->
config().nonlinear_solver().tolerance())
1127 update_no_damping =
true;
1128 break_after_update =
true;
1213 DeviceType
const &
device()
const {
return *p_device_; }
1219 template <
typename QuantitySrcT,
1220 typename QuantityDestT,
1221 typename ElementContainer>
1222 void transfer_provided_quantities(QuantitySrcT
const & src_quantity,
1223 QuantityDestT & dest_quantity,
1224 ElementContainer
const & elements)
1228 typedef typename ElementContainer::iterator ElementIterator;
1229 for (ElementIterator elit = elements.begin();
1230 elit != elements.end();
1233 dest_quantity.set_value(*elit, src_quantity.at(*elit));
1245 template <
typename MatrixType>
1246 VectorType solve(MatrixType & matrix, VectorType & rhs, VectorType & rescaling_vector)
1254 for (std::size_t i=0; i<matrix.size1(); ++i)
1256 RowType & row_i = matrix.row(i);
1257 for (AlongRowIterator iter = row_i.begin();
1258 iter != row_i.end();
1261 iter->second *= rescaling_vector[iter->first];
1275 if (lin_sol_res > 1e-3)
1276 log::warning() <<
"Warning: Linear solver shows only mild convergence! Residual: " << lin_sol_res << std::endl;
1277 if (lin_sol_res > 1)
1279 log::error() <<
"ERROR: Linear solver failed to converge properly! Residual: " << lin_sol_res << std::endl;
1283 for (std::size_t i=0; i<update.size(); ++i)
1284 update[i] *= scale_factors[i];
1288 for (std::size_t i=0; i<update.size(); ++i)
1289 update[i] *= rescaling_vector[i];
1301 template <
typename MatrixType>
1302 VectorType solve(MatrixType & matrix, VectorType & rhs,
bool is_newton =
false)
1304 VectorType rescaling_vector(rhs.size());
1307 std::fill(rescaling_vector.begin(), rescaling_vector.end(), 1.0);
1311 MeshType
const & mesh =
device().mesh();
1312 CellContainer cells(mesh);
1318 double scaling_factor = 1.0;
1321 scaling_factor = 1e16;
1324 for (CellIterator cit = cells.begin();
1328 long idx = current_quan.get_unknown_index(*cit);
1330 rescaling_vector[
static_cast<std::size_t
>(idx)] = scaling_factor;
1336 return solve(matrix, rhs, rescaling_vector);
1542 DeviceType * p_device_;
1545 std::vector<SHETimeStepQuantitiesT> quantities_history_;
Dimension-independent assembling routines for the Drift-diffusion model using a Newton scheme or Gumm...
Generic assembly of traps is implemented here.
Writes the SHE boundary conditions to the mesh.
Provides an accessor for the carrier density.
Defines a set of checker functors for micro-tests within ViennaSHE.
Accessor for obtaining the Dirichlet boundary condition for the Poisson equation in the device (conta...
Accessor for retrieving the built-in potential in the device.
The main SHE configuration class. To be adjusted by the user for his/her needs.
nonlinear_solver_config_type & nonlinear_solver()
Returns the configuration object for the nonlinear solver.
linear_solver_config_type & linear_solver()
Returns the configuration object for the linear solver.
Common representation of any quantity associated with objects of a certain type.
An accessor which returns a constant value independent of the object passed.
void set_lattice_temperature(double new_value)
Sets the homogeneous temperature of the device.
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...
Returns the lattice temperature on the device.
Simple checker class for checking whether a certain material is of a given type (conductor,...
MapType::iterator iterator2
An accessor for the carrier density in the device.
An accessor for the carrier density in the device by reference
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...
UnknownSHEQuantityListType & unknown_she_quantities()
ResultQuantityType electron_density() const
ResultQuantityType potential() 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.
std::deque< UnknownQuantityType > & unknown_quantities()
ResultQuantityType hole_density() const
ResultQuantityType dg_pot_p() const
ResultQuantityType dg_pot_n() const
General representation of any solver quantity defined on two different element types (e....
long get_unknown_index(AssociatedT1 const &elem, std::size_t index_H) const
std::size_t get_value_H_size() const
void set_values(AssociatedT1 const &elem, std::size_t index_H, ValueT const *values)
void set_boundary_type(AssociatedT1 const &elem, boundary_type_id value)
Class for self-consistent SHE simulations.
viennashe::config const & config() const
Returns the config object used by the simulator controller.
UnknownQuantityType unknown_quantity_type
unknown_quantity< CellType > UnknownQuantityType
generalized_edf_type generalized_edf(carrier_type_id ctype) const
Returns a wrapper for the evaluation of the generalized energy distribution function (f * Z,...
const_quantity< CellType > ResultQuantityType
viennashe::she::timestep_quantities< DeviceType > SHETimeStepQuantitiesT
ResultQuantityType dg_pot_p() const
SHETimeStepQuantitiesT const & quantity_history(std::size_t index) const
Returns a wrapper for the trap occupancy, which can be evaluated in every vertex of the mesh.
she_df_type she_df(carrier_type_id ctype) const
Returns a wrapper for the distribution function for electrons and holes (whatever is computed by the ...
DeviceType const & device() const
ResultQuantityType hole_density_type
SHETimeStepQuantitiesT::generalized_edf_type generalized_edf_type
void run()
Launches the solver. Uses the built-in potential as initial guess for the potential and the doping co...
electron_density_type electron_density() const
Returns a wrapper for the electron density, which can be evaluated in every vertex of the mesh.
simulator(DeviceType &device, viennashe::config const &conf=viennashe::config())
Constructs the self-consistent simulator object.
ResultQuantityType electron_density_type
SHETimeStepQuantitiesT const & quantities() const
Returns the controller object. Const version.
void set_initial_guess(std::string quan_name, QuantityAccessorT const &quan_acc)
Transfers the inital guess for the given quantity.
SHETimeStepQuantitiesT::edf_type edf_type
SHETimeStepQuantitiesT & quantities()
Returns the controller object. Non-const version.
viennashe::config & config()
SHETimeStepQuantitiesT::UnknownSHEQuantityType she_quantity_type
SHETimeStepQuantitiesT::she_df_type she_df_type
edf_type edf(carrier_type_id ctype) const
Returns a wrapper for the evaluation of the energy distribution function (i.e. the isotropic part of ...
void advance_in_time()
Cycles the quantities. Moves (copy) the current quantities to the history and empties the current qua...
ResultQuantityType dg_pot_n() const
ResultQuantityType potential_type
potential_type potential() const
Returns a wrapper for the potential, which can be evaluated in every vertex of the mesh.
std::size_t quantity_history_size() const
hole_density_type hole_density() const
Returns a wrapper for the hole density, which can be evaluated in every vertex of the mesh
Exception thrown in the case that an equation solver failed.
void scale(bool value)
Controls the scaling of unkowns. Give "false" to disable unkown scaling.
std::size_t max_iters() const
Returns the maximum number of nonlinear solver iterations.
double damping() const
Returns the damping for the nonlinear solver.
long id() const
Returns the current linear solver ID.
bool get_unknown_mask(associated_type const &elem) const
ValueT get_value(associated_type const &elem) const
bool get_logarithmic_damping() const
ValueT get_boundary_value(associated_type const &elem) const
long get_unknown_index(associated_type const &elem) const
boundary_type_id get_boundary_type(associated_type const &elem) const
void set_value(associated_type const &elem, ValueT value)
void start()
Starts the timer.
double get() const
Returns the number of seconds elapsed.
Contains the definition of a device class independent of the actual macroscopic model to be solved.
Provides a convenience wrapper for accessing the distribution function coefficients over the device.
Implements the elimination and the recovery of odd-order unknowns from the discrete system of equatio...
Provides all routines for distributing unknown indices (dofs) over the device. Includes expansion ord...
Contains forward declarations and definition of small classes that must be defined at an early stage.
Implementation of various utilities related to linear algebra.
Provides the linear solvers for SHE.
A logging facility providing fine-grained control over logging in ViennaSHE.
Distributes the unknown indices ('mapping') for the Poisson equation and the continuity equations.
void set_unknown_for_material(DeviceT const &device, QuantityT &quan, materials::checker const &material_check)
Sets the unknown masks per material.
void smooth_doping_at_contacts(DeviceT &d)
Utility function for smoothing the doping next to contacts.
void set_she_unknown(DeviceT const &device, QuantityT &quan)
void set_initial_guess(DeviceT const &device, QuantityT &quan, BoundaryValueAccessorT const &initial_guess_accessor)
Sets the initial guess per quantity and device.
void set_boundary_for_material(DeviceT const &device, QuantityT &quan, materials::checker const &material_check, BoundaryValueAccessorT boundary_value_accessor, boundary_type_id bnd_id)
Sets the boundary condition (type and value) per vertex depending on the material.
logger< true > error()
Used to log errors. The logging level is logERROR.
logger< true > warning()
Used to log warnings. The logging level is logWARNING.
logger< true > info()
Used to log infos. The logging level is logINFO.
bool is_semiconductor(long material_id)
Convenience function for checking whether the supplied material ID refers to a semiconductor.
bool is_conductor(long material_id)
Convenience function for checking whether the supplied material ID refers to a metal.
VectorType::value_type norm_2(VectorType const &v)
VectorType subtract(VectorType const &x, VectorType const &y)
Helper routine for the generic vector subtraction z = x - y;.
VectorType prod(sparse_matrix< NumericT > const &system_matrix, VectorType const &x)
Computes A * x for a sparse A and a vector x.
VectorT row_normalize_system(sparse_matrix< NumericT > &system_matrix, VectorT &rhs)
Normalizes an equation system such that all diagonal entries are non-negative, and such that all 2-no...
std::string lattice_temperature()
std::string hole_density()
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()
void transfer_to_new_h_space(DeviceType const &device, viennashe::she::timestep_quantities< DeviceType > const &old_quantities, viennashe::she::timestep_quantities< DeviceType > &new_quantities, viennashe::config const &conf)
Interface transferring a solution given by 'old_solution' on some other (old) grid to the new grid.
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)
void setup_energies(DeviceT const &device, viennashe::she::unknown_she_quantity< VertexT, EdgeT > &quan, viennashe::config const &conf, viennashe::unknown_quantity< VertexT > const &potential, viennashe::unknown_quantity< VertexT > const &quantum_correction)
Computes the kinetic energy over the device as obtained from the provided potential.
void write_boundary_conditions(DeviceType const &device, viennashe::she::unknown_she_quantity< VertexT, EdgeT > &quan, viennashe::config const &conf)
Writes boundary conditions for SHE to the device. Stores the result using ViennaData.
void distribute_expansion_orders(DeviceType &device, viennashe::she::unknown_she_quantity< VertexT, EdgeT > &quan, viennashe::config const &conf)
Assigns the various expansion orders to the device. This is the public interface.
VectorType solve(DeviceType const &device, SHEQuantity const &quan, viennashe::config const &configuration, MatrixType &full_matrix, VectorType &full_rhs, std::size_t reduced_unknowns)
Public interface for solving the provided system of discretized SHE equations.
std::vector< double > solve(viennashe::math::sparse_matrix< double > &A, std::vector< double > const &b, linear_solver_config const &config)
Public interface for solving a system of linear equations represented using a sparse matrix.
std::string format_number_to_width(T number, int width)
Returns the formatted number as string with the given length, where spaces are used as padding charac...
CellT const * get_connected_semiconductor_cell(DeviceT const &device, 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.
std::map< std::string, std::pair< std::size_t, std::size_t > > map_info_type
Information on the number of unknowns per quantity.
void update_quantities(DeviceT const &device, viennashe::config const &conf, TimeStepQuantitiesT &unknown_quantities, VectorType const &x)
Updater for Newton.
carrier_type_id
Enumeration type for selecting the carrier type.
double get_potential_update_norm_newton(DeviceT const &device, TimeStepQuantitiesT const &unknown_quantities, VectorT const &x)
Potential update calculator for Newton.
@ EQUATION_DENSITY_GRADIENT
void transfer_quantity_to_device(DeviceT &device, UnknownQuantityListT const &quantities, viennashe::config const &conf)
void update_quantity(DeviceT const &device, viennashe::she::unknown_she_quantity< CellT, FacetT > &quan, viennashe::unknown_quantity< CellT > &spatial_quan, viennashe::config const &conf, VectorType const &x, bool force_no_damping=false)
Updater for SHE quantities when using Gummel iteration.
long create_mapping(DeviceType const &device, viennashe::unknown_quantity< VertexT > &quantity, long start_index=0)
Maps unkown indices in the system matrix to the given unknown spatial quantity.
boundary_type_id
An enumeration of all boundary conditions ViennaSHE supports.
double get_relative_update_norm(UnknownQuantityT const &spatial_quan, VectorType const &x)
Returns the relative update norm (L_2 ; realtive to the current value). Except for the potential.
double get_total_update_norm_newton(DeviceT const &device, UnknownQuantityT const &unknown_quantities_, VectorT const &x)
Total update calculator for Newton. Needs to be called before update_quantities!
@ MATERIAL_SEMICONDUCTOR_ID
@ MATERIAL_NO_CONDUCTOR_ID
void assemble(DeviceType const &device, TimeStepQuantitiesT &quantities, viennashe::config const &conf, viennashe::unknown_quantity< VertexT > const &quan, MatrixType &A, VectorType &b)
Assemble a spatial quantity, where the equation is deduced from 'quan'.
Writes the kinetic energies to each nodes in the (x,H)-domain.
Provides the exceptions used inside the viennashe::she namespace.
File to gather all scattering operators.
Defines a generic simulator quantity for use within the solvers of ViennaSHE.
Defines a set of setup routines and checkers for simulators.
Routines for ensuring a constant doping along contacts.
@ newton_nonlinear_solver
Gummel iteration.
Contains a timer class. Contains one windows implementation and one *NIX implementation.
A container of all quantities defined for a certain timestep t.
Interpolation of a solution defined in one H-space to another H-space (required by Newton's method)
Defines the log keys used within the main viennashe:: namespace.
Defines the log keys used within the viennashe::she namespace.