psim  1.0
Generalized 2D phonon transport using a Monte Carlo method
sensor.h
Go to the documentation of this file.
1 #ifndef PSIM_SENSOR_H
2 #define PSIM_SENSOR_H
3 
4 #include "material.h"// for Material, Material::Table
5 #include "sensorController.h"// for SensorController
6 #include <array>// for array
7 #include <cstddef>// for size_t
8 #include <memory>// for unique_ptr
9 #include <mutex>// for mutex
10 #include <vector>// for vector
11 
12 class Phonon;
13 
14 class Sensor {
15 public:
17  Sensor(std::size_t ID,// NOLINT
18  const Material& material,
19  SimulationType type,
20  std::size_t num_measurements,
21  double t_init);
22 
23  void initialUpdate(Phonon& p, const Material::Table& table) const noexcept;// NOLINT
24  void initialUpdate(Phonon& p) const noexcept;// NOLINT
25  void scatterUpdate(Phonon& p) const noexcept;// NOLINT
26  void addToArea(double area) noexcept {
27  area_covered_ += area;
28  }
29  // final temps vector is only needed for transient simulations -> included for all calls to keep a common interface
30  [[nodiscard]] bool resetRequired(double t_final, std::vector<double>&& final_temps = {}) noexcept;
31 
32  [[nodiscard]] std::size_t getID() const noexcept {
33  return ID_;
34  }
35  [[nodiscard]] const Material& getMaterial() const noexcept {
36  return controller_->getMaterial();
37  }
38  [[nodiscard]] double getHeatCapacity(std::size_t step = 0) const noexcept {
39  return controller_->getHeatCapacity(step);
40  }
41  [[nodiscard]] double getHeatCapacityAtFreq(std::size_t freq_index) const noexcept {
42  return controller_->getHeatCapacityAtFreq(freq_index);
43  }
44  [[nodiscard]] double getInitTemp() const noexcept {
45  return controller_->getInitTemp();
46  }
47  [[nodiscard]] double getSteadyTemp(std::size_t step = 0) const noexcept {
48  return controller_->getSteadyTemp(step);
49  }
50  [[nodiscard]] double getArea() const noexcept {
51  return area_covered_;
52  }
53  [[nodiscard]] const std::vector<std::array<double, 2>>& getFluxes() const noexcept {
54  return inc_flux_;
55  }
56  [[nodiscard]] const std::vector<int>& getEnergies() const noexcept {
57  return inc_energy_;
58  }
59 
65  void updateHeatParams(const Phonon& p, std::size_t step) noexcept;// NOLINT
66  void reset() noexcept;
67  void updateTables() {
68  controller_->updateTables();
69  }
70 
71 private:
72  std::size_t ID_;
73  std::unique_ptr<SensorController> controller_;
74  double area_covered_{ 0. };
75 
76  std::vector<int> inc_energy_;
77  std::vector<std::array<double, 2>> inc_flux_;
78  std::unique_ptr<std::mutex> updateMutex_;
79 };
80 
82  std::size_t id{ 0 };
83  double t_steady{ 0. };
84  double std_t_steady{ 0. };
85  double x_flux{ 0. };
86  double std_x_flux{ 0. };
87  double y_flux{ 0. };
88  double std_y_flux{ 0. };
89  // For animations and full analyses
90  std::vector<double> final_temps;
91  std::vector<std::array<double, 2>> final_fluxes;
92 };
93 
94 #endif// PSIM_SENSOR_H
Definition: material.h:15
std::array< std::pair< double, double >, NUM_FREQ_BINS > Table
Definition: material.h:20
Definition: phonon.h:16
Definition: sensor.h:14
void reset() noexcept
Definition: sensor.cpp:63
bool resetRequired(double t_final, std::vector< double > &&final_temps={}) noexcept
Definition: sensor.cpp:48
std::size_t getID() const noexcept
Definition: sensor.h:32
double getHeatCapacityAtFreq(std::size_t freq_index) const noexcept
Definition: sensor.h:41
double getInitTemp() const noexcept
Definition: sensor.h:44
SimulationType
Definition: sensor.h:16
void updateTables()
Definition: sensor.h:67
void updateHeatParams(const Phonon &p, std::size_t step) noexcept
Definition: sensor.cpp:52
const std::vector< std::array< double, 2 > > & getFluxes() const noexcept
Definition: sensor.h:53
const std::vector< int > & getEnergies() const noexcept
Definition: sensor.h:56
void addToArea(double area) noexcept
Definition: sensor.h:26
const Material & getMaterial() const noexcept
Definition: sensor.h:35
void scatterUpdate(Phonon &p) const noexcept
Definition: sensor.cpp:44
double getArea() const noexcept
Definition: sensor.h:50
Sensor(std::size_t ID, const Material &material, SimulationType type, std::size_t num_measurements, double t_init)
Definition: sensor.cpp:12
double getSteadyTemp(std::size_t step=0) const noexcept
Definition: sensor.h:47
void initialUpdate(Phonon &p, const Material::Table &table) const noexcept
Definition: sensor.cpp:36
double getHeatCapacity(std::size_t step=0) const noexcept
Definition: sensor.h:38
Definition: sensor.h:81
double std_t_steady
Definition: sensor.h:84
std::vector< double > final_temps
Definition: sensor.h:90
double std_x_flux
Definition: sensor.h:86
double std_y_flux
Definition: sensor.h:88
std::vector< std::array< double, 2 > > final_fluxes
Definition: sensor.h:91
double y_flux
Definition: sensor.h:87
double t_steady
Definition: sensor.h:83
double x_flux
Definition: sensor.h:85