17 #pragma warning(disable:4503)
33#include "viennagrid/config/default_configs.hpp"
34#include "viennagrid/algorithm/centroid.hpp"
46template <
typename SHEQuanT>
47class kinetic_energy_wrapper
52 template <
typename ElementType>
53 double operator()(ElementType
const & el, std::size_t index_H)
const
55 return quan_.kinetic_energy(el, index_H, carrier_type_);
59 SHEQuanT
const & quan_;
71template <
typename DeviceType>
74 typedef typename DeviceType::mesh_type MeshType;
77 std::cout <<
"* init_device(): Setting doping..." << std::endl;
80 device.set_doping_n(1e16);
81 device.set_doping_p(1e16);
86 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
87 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
92 CellContainer cells(device.mesh());
93 for (CellIterator cit = cells.begin();
98 if (viennagrid::centroid(*cit)[0] < 0.1 *
len_x)
100 device.set_contact_potential(gnd, *cit);
104 if (viennagrid::centroid(*cit)[0] > 0.9 *
len_x)
105 device.set_contact_potential(vcc, *cit);
120template <
typename DeviceType,
typename SHEQuantity,
typename CellType>
122 DeviceType
const & device,
123 SHEQuantity
const & quan,
125 CellType
const & cell,
128 const double T = device.get_lattice_temperature(cell);
129 const double tol = 1e-3;
130 double kinetic_energy = quan.get_kinetic_energy(cell, index_H);
134 * quan.get_values(cell, 1)[0];
138 || (quan.get_values(cell, index_H)[0] < quan.get_values(cell, index_H)[0])
139 || (quan.get_values(cell, index_H)[0] > quan.get_values(cell, index_H)[0])
142 std::cerr <<
"* ERROR: Maxwell distribution test failed at vertex " << cell <<
" with index_H = " << index_H << std::endl;
148 for (
long m = -1; m <= 1; ++m)
150 double f_1m = interpolated_she_df(cell, kinetic_energy, 1, m, index_H);
151 if ( std::abs(f_1m) > 1e-18 )
153 std::cerr <<
"* ERROR: Check for vanishing first-order failed at vertex " << cell <<
" with index_H = " << index_H << std::endl;
154 std::cerr <<
" value: " << f_1m << std::endl;
161 double gdf_val1 = generalized_df(cell, kinetic_energy, 0.123, 1.02);
162 double gdf_val2 = generalized_df(cell, kinetic_energy, 0.420, 3.60);
163 double gdf_val3 = generalized_df(cell, kinetic_energy, 0.360, 4.02);
170 std::cerr <<
"* ERROR: Check for generalized distribution function failed at vertex " << cell <<
" with index_H = " << index_H << std::endl;
171 std::cerr <<
" val1: " << gdf_val1 << std::endl;
172 std::cerr <<
" val2: " << gdf_val2 << std::endl;
173 std::cerr <<
" val3: " << gdf_val3 << std::endl;
174 std::cerr <<
" ref: " << ref << std::endl;
180 double edf_val1 = generalized_edf(cell, kinetic_energy);
181 double edf_val2 = generalized_edf(cell, kinetic_energy);
182 double edf_val3 = generalized_edf(cell, kinetic_energy);
188 std::cerr <<
"* ERROR: Check for generalized energy distribution function failed at vertex " << cell <<
" with index_H = " << index_H << std::endl;
189 std::cerr <<
" val1: " << edf_val1 << std::endl;
190 std::cerr <<
" val2: " << edf_val2 << std::endl;
191 std::cerr <<
" val3: " << edf_val3 << std::endl;
192 std::cerr <<
" ref: " << ref << std::endl;
201inline int simulate(
double temperature)
203 typedef viennagrid::quadrilateral_2d_mesh MeshType;
206 std::cout <<
"* main(): Creating device..." << std::endl;
213 device.generate_mesh(generator_params);
214 device.set_lattice_temperature(temperature);
216 std::cout <<
"* main(): Initializing device..." << std::endl;
219 std::cout <<
"* main(): Creating DD simulator..." << std::endl;
229 std::cout <<
"* main(): Launching simulator..." << std::endl;
235 std::cout <<
"* main(): Setting up SHE..." << std::endl;
248 std::cout <<
"* main(): Computing SHE..." << std::endl;
255 std::cout <<
"Energy range: [" << she_simulator.quantities().electron_distribution_function().get_value_H(0) <<
", "
256 << she_simulator.quantities().electron_distribution_function().get_value_H(she_simulator.quantities().electron_distribution_function().get_value_H_size() - 1)
257 <<
"] (" << she_simulator.quantities().electron_distribution_function().get_value_H_size() <<
" discrete energies)" << std::endl;
259 std::cout <<
"* main(): Writing SHE result..." << std::endl;
260 std::stringstream ss;
261 ss <<
"equilibrium_resistor_" << temperature <<
"_edf";
263 she_simulator.config(),
264 she_simulator.quantities().electron_distribution_function(),
270 typedef viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
271 typedef viennagrid::result_of::iterator<CellContainer>::type CellIterator;
276 CellContainer cells(device.mesh());
277 for (CellIterator cit = cells.begin();
283 long index = she_simulator.quantities().electron_distribution_function().get_unknown_index(*cit, index_H);
286 if (she_simulator.config().with_electrons())
288 if (test_result_at_point(
viennashe::ELECTRON_TYPE_ID, device, she_simulator.quantities().electron_distribution_function(), config, *cit, index_H) != EXIT_SUCCESS)
291 else if (she_simulator.config().with_holes())
293 if (test_result_at_point(
viennashe::HOLE_TYPE_ID, device, she_simulator.quantities().hole_distribution_function(), config, *cit, index_H) != EXIT_SUCCESS)
298 std::cout <<
"Tests passed for cell " << cit->id().get() << std::endl;
308 std::cout <<
"--------- Testing at 300 K --------------" << std::endl;
309 int retval = simulate(300.0);
311 if (retval != EXIT_SUCCESS)
314 std::cout << std::endl;
315 std::cout <<
"--------- Testing at 400 K --------------" << std::endl;
316 retval = simulate(400.0);
317 if (retval != EXIT_SUCCESS)
320 std::cout <<
"*******************************" << std::endl;
321 std::cout <<
"* Test finished successfully! *" << std::endl;
322 std::cout <<
"*******************************" << std::endl;
The main SHE configuration class. To be adjusted by the user for his/her needs.
viennashe::physics::dispersion_proxy dispersion_relation(viennashe::carrier_type_id ctype) const
Returns the dispersion relation for electrons.
bool with_holes() const
Returns true if holes are considered in the simulation.
nonlinear_solver_config_type & nonlinear_solver()
Returns the configuration object for the nonlinear solver.
void set_electron_equation(equation_id equ_id)
double energy_spacing() const
Returns the uniform energy spacing of discrete energies.
void set_hole_equation(equation_id equ_id)
bool with_electrons() const
Returns true if electrons are considered in the simulation.
viennashe::she::scatter_config & scattering()
Returns the configuration object for scattering.
Defines the physical properties of a device, e.g. doping. This is the implementation for 2d and highe...
double density_of_states(double ekin, double theta=0, double phi=0) const
Returns the density of states as a function of kinetic energy (and angles, eventually)
A convenience wrapper for evaluating the generalized distribution function (i.e. f * Z,...
A convenience wrapper for accessing the generalized energy distribution function (f * Z,...
A convenience wrapper for accessing the distribution function coefficients over the device on each ve...
ionized_impurity_scattering_parameters const & ionized_impurity() const
Returns the parameters for ionized impurity scattering. Const-version.
Class for self-consistent SHE simulations.
std::size_t max_iters() const
Returns the maximum number of nonlinear solver iterations.
double get_length_x() const
Configuration class for the simple mesh generator.
void add_segment(double start_x, double start_y, double len_x, double len_y, unsigned long points_x, unsigned long points_y)
segment_description const & at(std::size_t i) const
Convenience header, which includes all core functionality available in ViennaSHE.
Contains forward declarations and definition of small classes that must be defined at an early stage.
void init_device(DeviceType &device, double Vg_init, double Nd, double Na)
Initalizes the MOS 1D device for testing.
void write_quantities_to_VTK_file(viennashe::simulator< DeviceType > const &simulator_obj, std::string filename, bool include_debug_information=false)
Generic interface function for writing simulated quantities to a VTK file.
std::string hole_density()
std::string electron_distribution_function()
std::string electron_density()
bool fuzzy_equal(double is, double should, double tol=1e-1)
Performs a fuzzy (up to a tolerance) equal. Returns true if is and should are equal within the tolera...
carrier_type_id
Enumeration type for selecting the carrier type.
A class referring to silicon and providing certain material parameters Note that this is the default ...
static const double q
Elementary charge.
static const double kB
Boltzmann constant.
Contains common functions, functors and other classes often needed by the tests.