psim  1.0
Generalized 2D phonon transport using a Monte Carlo method
material.h
Go to the documentation of this file.
1 #ifndef PSIM_MATERIAL_H
2 #define PSIM_MATERIAL_H
3 
4 #include "phonon.h"// for Phonon, Phonon::RelaxRates, Phonon::Polariz...
5 #include <array>// for array
6 #include <cstddef>// for size_t
7 #include <utility>// for pair, move
8 #include <vector>// for vector
9 
10 struct DispersionData;
11 struct RelaxationData;
12 struct TableData;
13 
14 
15 class Material {
16 public:
17  static constexpr std::size_t NUM_FREQ_BINS = 1000;// Used on one occasion outside this class
18 
19  using Array = std::array<double, NUM_FREQ_BINS>;
20  using Table = std::array<std::pair<double, double>, NUM_FREQ_BINS>;
22 
23  Material(std::size_t mat_id, const DispersionData& disp_data, const RelaxationData& relax_data);
24 
25  void setFullSimulation() noexcept {
26  full_simulation_ = true;
27  }
28 
29  [[nodiscard]] std::size_t id() const noexcept {
30  return id_;
31  }
32  [[nodiscard]] double max_freq_la() const noexcept {
33  return w_max_la_;
34  }
35  [[nodiscard]] double max_freq_ta() const noexcept {
36  return w_max_ta_;
37  }
38  [[nodiscard]] Phonon::RelaxRates relaxRates(double temp, double freq, Polar polarization) const noexcept;
39  [[nodiscard]] Phonon::RelaxRates relaxRates(std::size_t freq_index, Polar polarization, double temp) const;
40  [[nodiscard]] static std::pair<std::size_t, Polar> freqIndex(const Table& dist) noexcept;
41 
42  [[nodiscard]] const Array& getFrequencies() const noexcept {
43  return frequencies_;
44  }
45  [[nodiscard]] double getFreq(std::size_t index) const noexcept;
46  [[nodiscard]] double getVel(std::size_t index, Polar polar) const noexcept;
47  [[nodiscard]] const Table* baseTable(double temp) const {
48  return baseData(temp).first;
49  }
50  [[nodiscard]] double baseEnergy(double temp) const {
51  return baseData(temp).second;
52  }
53  [[nodiscard]] const Table* emitTable(double temp) const {
54  return emitData(temp).first;
55  }
56  // Needed to determine the amount of energy emitted by emitting surfaces
57  [[nodiscard]] double emitEnergy(double temp) const {
58  return emitData(temp).second;
59  }
60  [[nodiscard]] const Table* scatterTable(double temp) const {
61  return scatterData(temp).first;
62  }
63  // Needed for second numerical inversion when doing a full simulation
64  [[nodiscard]] double scatterEnergy(double temp) const {
65  return scatterData(temp).second;
66  }
67  // If pseudo=true -> scales results by the relaxation rates (returns scatterEnergy(temp))
68  [[nodiscard]] double theoreticalEnergy(double temp, bool pseudo = false) const noexcept;
69  void initializeTables(double low_temp, double high_temp, float temp_interval);
70 
71 private:
72  std::size_t id_;
73  double b_l_;
74  double b_tn_;
75  double b_tu_;
76  double b_i_;
77  double w_;// Cutoff for TA Umklapp scattering
78 
79  double w_max_la_;// Maximum frequency of LA phonons that can exist in this material
80  double w_max_ta_;
81 
82  double freq_width_;// Width of frequency bin.
83  bool full_simulation_{ false };
84 
85  Array frequencies_{ 0. };
86  Array densities_la_{ 0. };
87  Array densities_ta_{ 0. };
88  Array velocities_la_{ 0. };
89  Array velocities_ta_{ 0. };
90 
91  std::vector<double> temps_;
92  std::vector<TableData> base_tables_;
93  std::vector<TableData> emit_tables_;
94  std::vector<TableData> scatter_tables_;
95 
96  [[nodiscard]] static double getK(double freq, std::array<double, 3> coeffs);
97  [[nodiscard]] static double getGv(double freq, std::array<double, 3> coeffs);
98 
99  [[nodiscard]] std::pair<const Table*, double> baseData(double temp) const;
100  [[nodiscard]] std::pair<const Table*, double> emitData(double temp) const;
101  [[nodiscard]] std::pair<const Table*, double> scatterData(double temp) const;
102 
103  [[nodiscard]] std::pair<Table, double> cumulDistEmit(Array&& la_dist, Array&& ta_dist) const;
104  [[nodiscard]] std::pair<Table, double> cumulDistScatter(Array&& la_dist, Array&& ta_dist, double temp) const;
105  [[nodiscard]] static Table buildCumulDist(const Array& t1, const Array& t2);// NOLINT
106  [[nodiscard]] Array phononDist(double temp, Polar polarization) const;
107 
108  [[nodiscard]] double tauNInv(double temp, double freq, Polar polarization) const noexcept;
109  [[nodiscard]] double tauUInv(double temp, double freq, Polar polarization) const noexcept;
110  [[nodiscard]] double tauIInv(double freq) const noexcept;// Impurity scattering
111 
112  static void verifyInput(double low_temp, double high_temp, float interval_size);
113  [[nodiscard]] std::size_t getTempIndex(double temp) const noexcept;
114 };
115 
116 // Should extend this to a class
118  double b_l{ 0. };
119  double b_tn{ 0. };
120  double b_tu{ 0. };
121  double b_i{ 0. };
122  double w{ 0. };
123 };
124 
125 // Only handles quadratic data - consider extending to a class as well
127  std::array<double, 3> LA_data{
128  0.,
129  0.,
130  0.,
131  };
132  std::array<double, 3> TA_data{
133  0.,
134  0.,
135  0.,
136  };
137  // std::Array<double, 3> LO_data {0., 0., 0.,};
138  // std::Array<double, 3> TO_data {0., 0., 0.,};
139  double w_max_la{ 0. };
140  double w_max_ta{ 0. };
141 };
142 
143 struct TableData {
144  TableData(Material::Table mat_table, double cumulative_sum)
145  : table{ std::move(mat_table) }
146  , cumul_sum{ cumulative_sum } {
147  }
148 
149  std::array<std::pair<double, double>, Material::NUM_FREQ_BINS> table;
150  double cumul_sum{ 0. };
151 };
152 
153 #endif// PSIM_MATERIAL_H
Definition: material.h:15
double max_freq_la() const noexcept
Definition: material.h:32
Material(std::size_t mat_id, const DispersionData &disp_data, const RelaxationData &relax_data)
Definition: material.cpp:20
double scatterEnergy(double temp) const
Definition: material.h:64
double baseEnergy(double temp) const
Definition: material.h:50
double getVel(std::size_t index, Polar polar) const noexcept
Definition: material.cpp:82
std::array< double, NUM_FREQ_BINS > Array
Definition: material.h:19
static std::pair< std::size_t, Polar > freqIndex(const Table &dist) noexcept
Definition: material.cpp:64
void initializeTables(double low_temp, double high_temp, float temp_interval)
Definition: material.cpp:101
double theoreticalEnergy(double temp, bool pseudo=false) const noexcept
Definition: material.cpp:97
double max_freq_ta() const noexcept
Definition: material.h:35
const Table * scatterTable(double temp) const
Definition: material.h:60
const Array & getFrequencies() const noexcept
Definition: material.h:42
const Table * emitTable(double temp) const
Definition: material.h:53
const Table * baseTable(double temp) const
Definition: material.h:47
std::size_t id() const noexcept
Definition: material.h:29
static constexpr std::size_t NUM_FREQ_BINS
Definition: material.h:17
double getFreq(std::size_t index) const noexcept
Definition: material.cpp:77
void setFullSimulation() noexcept
Definition: material.h:25
std::array< std::pair< double, double >, NUM_FREQ_BINS > Table
Definition: material.h:20
double emitEnergy(double temp) const
Definition: material.h:57
Phonon::RelaxRates relaxRates(double temp, double freq, Polar polarization) const noexcept
Definition: material.cpp:54
Polarization
Definition: phonon.h:19
std::array< double, NUM_RELAX_RATES > RelaxRates
Definition: phonon.h:21
Material::Array Array
Definition: material.cpp:16
Material::Table Table
Definition: material.cpp:17
Definition: material.h:126
std::array< double, 3 > TA_data
Definition: material.h:132
double w_max_ta
Definition: material.h:140
std::array< double, 3 > LA_data
Definition: material.h:127
double w_max_la
Definition: material.h:139
Definition: material.h:117
double b_l
Definition: material.h:118
double b_tu
Definition: material.h:120
double b_i
Definition: material.h:121
double b_tn
Definition: material.h:119
double w
Definition: material.h:122
Definition: material.h:143
std::array< std::pair< double, double >, Material::NUM_FREQ_BINS > table
Definition: material.h:149
TableData(Material::Table mat_table, double cumulative_sum)
Definition: material.h:144
double cumul_sum
Definition: material.h:150