ViennaSHE 1.3.0
Free open-source semiconductor device simulator using spherical harmonics expansions techniques.
spherical_harmonics_iter.cpp
Go to the documentation of this file.
1/* ============================================================================
2 Copyright (c) 2011-2022, Institute for Microelectronics,
3 Institute for Analysis and Scientific Computing,
4 TU Wien.
5
6 -----------------
7 ViennaSHE - The Vienna Spherical Harmonics Expansion Boltzmann Solver
8 -----------------
9
10 http://viennashe.sourceforge.net/
11
12 License: MIT (X11), see file LICENSE in the base directory
13=============================================================================== */
14
15
16
17#include <iostream>
18#include <cstdlib>
19#include <cmath>
20#include <vector>
21#include <sstream>
22
25
27
28#include <math.h>
29
41inline bool test_iterator(viennashe::math::spherical_harmonics_iterator iter,
42 std::vector<long> ref_values,
43 std::vector<bool> ref_valid)
44{
45 for (std::size_t i=0; i<ref_values.size(); ++i)
46 {
47 if (ref_values[i] != *iter)
48 {
49 std::cerr << "Error after " << i << "increments: Expected value " << ref_values[i] << ", but got " << *iter << std::endl;
50 return false;
51 }
52 if (ref_valid[i] != iter.valid())
53 {
54 std::cerr << "Error after " << i << "increments: Expected valid status " << ref_valid[i] << ", but got " << iter.valid() << std::endl;
55 return false;
56 }
57 ++iter;
58 }
59 return true;
60}
61
62int main()
63{
67
68 bool ok = false;
69
70 std::cout << "--- Iteration over all harmonics: ---" << std::endl;
71 std::vector<bool> ref_all_valid(17, true);
72 ref_all_valid[16] = false;
73 std::vector<long> ref_all_values(17);
74 for (std::size_t i=0; i<17; ++i)
75 ref_all_values[i] = long(i);
76
77 ok = test_iterator(iter_all, ref_all_values, ref_all_valid);
78 if (ok == false) return (EXIT_FAILURE);
79
80 std::cout << "--- Iteration over even harmonics: ---" << std::endl;
81 std::vector<bool> ref_even_valid(7, true);
82 ref_even_valid[6] = false;
83 std::vector<long> ref_even_values(7);
84 ref_even_values[1] = 4;
85 ref_even_values[2] = 5;
86 ref_even_values[3] = 6;
87 ref_even_values[4] = 7;
88 ref_even_values[5] = 8;
89 ref_even_values[6] = 16;
90 ok = test_iterator(iter_even, ref_even_values, ref_even_valid);
91 if (ok == false) return (EXIT_FAILURE);
92
93 std::cout << "--- Iteration over odd harmonics: ---" << std::endl;
94 std::vector<bool> ref_odd_valid(11, true);
95 ref_odd_valid[10] = false;
96 std::vector<long> ref_odd_values(11);
97 ref_odd_values[0] = 1;
98 ref_odd_values[1] = 2;
99 ref_odd_values[2] = 3;
100 ref_odd_values[3] = 9;
101 ref_odd_values[4] = 10;
102 ref_odd_values[5] = 11;
103 ref_odd_values[6] = 12;
104 ref_odd_values[7] = 13;
105 ref_odd_values[8] = 14;
106 ref_odd_values[9] = 15;
107 ref_odd_values[10] = 25;
108 ok = test_iterator(iter_odd, ref_odd_values, ref_odd_valid);
109 if (ok == false) return (EXIT_FAILURE);
110
111 std::cout << "*******************************" << std::endl;
112 std::cout << "* Test finished successfully! *" << std::endl;
113 std::cout << "*******************************" << std::endl;
114
115 return (EXIT_SUCCESS);
116
117} //main()
118
Iteration over all spherical harmonics indices up to order L, with increasing indices l and m.
Provides the SHE coupling matrices and computes higher-order coupling matrices if required....
Implementation of numerical integration routines.
@ ALL_HARMONICS_ITERATION_ID
Definition: forwards.h:160
@ EVEN_HARMONICS_ITERATION_ID
Definition: forwards.h:161
@ ODD_HARMONICS_ITERATION_ID
Definition: forwards.h:162
int main()
Definition: resistor1d-c.c:108
Implementation of spherical harmonics plus helper functions.