psim  1.0
Generalized 2D phonon transport using a Monte Carlo method
sensorController.h
Go to the documentation of this file.
1 #ifndef PSIM_SENSORCONTROLLER_H
2 #define PSIM_SENSORCONTROLLER_H
3 
4 #include "material.h"// for Material, Material::Table
5 #include <cstddef>// for size_t
6 #include <vector>// for vector
7 
8 class Phonon;
9 
10 // Abstract class is perhaps not necessary here
12 public:
13  SensorController(const Material& material, double t_init, std::size_t num_measurements = 0);
14  virtual ~SensorController() = default;
16  SensorController(SensorController&&) noexcept = default;
17  SensorController& operator=(const SensorController&) = delete;
18  SensorController& operator=(SensorController&&) noexcept = delete;
19 
20  [[nodiscard]] const Material& getMaterial() const noexcept {
21  return material_;
22  }
23  [[nodiscard]] double getHeatCapacityAtFreq(std::size_t freq_index) const noexcept;
24  [[nodiscard]] virtual double getHeatCapacity(std::size_t step) const noexcept = 0;
25  [[nodiscard]] virtual double getInitTemp() const noexcept = 0;
26  [[nodiscard]] virtual double getSteadyTemp(std::size_t step) const noexcept = 0;
27 
28  void initialUpdate(Phonon& p, const Material::Table& table) const noexcept;// NOLINT
29  void initialUpdate(Phonon& p) const noexcept;// NOLINT
30  virtual void updateTables();
31  virtual void scatterUpdate(Phonon& p) const noexcept;// NOLINT
38  [[nodiscard]] virtual bool resetRequired(double t_final, std::vector<double>&&) noexcept;
39  virtual void reset() noexcept = 0;
40 
41 protected:
43  double t_init_;
44  std::size_t num_measurements_;// For transient surfaces only
45 
46  double t_steady_{ 0. };// Steady state temperature of the cell. Used to set the energy tables & heat_capacity_
47  double heat_capacity_{ 0. };// Energy per unit volume in full simulations - heat capacity in deviational simulations
48  const Material::Table* base_table_{ nullptr };
49  const Material::Table* scatter_table_{ nullptr };
50 
51  // Transient sensor containers -> not needed for steady state or periodic simulations
52  std::vector<const Material::Table*>
53  scatter_tables_;// Transient controllers need a scatter table for each measurement step
54  std::vector<double> heat_capacities_;
55  std::vector<double> steady_temps_;
56 };
57 
59 public:
61 
62  [[nodiscard]] double getHeatCapacity([[maybe_unused]] std::size_t step) const noexcept override {
63  return heat_capacity_;
64  }
65  // This is not a bug -> Init temp for next iteration is the steady temp of the previous iteration
66  // Not interested in periodic progression of the system here, will converge faster this way
67  [[nodiscard]] double getInitTemp() const noexcept override {
68  return t_steady_;
69  }
70  [[nodiscard]] double getSteadyTemp([[maybe_unused]] std::size_t step) const noexcept override {
71  return t_steady_;
72  }
73 
74  void reset() noexcept override;
75 };
76 
78 public:
80 
81  [[nodiscard]] double getHeatCapacity([[maybe_unused]] std::size_t step) const noexcept override {
82  return heat_capacity_;
83  }
84  // Need to restore sensors to their initial temperatures to see the periodic progression of the system
85  [[nodiscard]] double getInitTemp() const noexcept override {
86  return t_init_;
87  }
88  [[nodiscard]] double getSteadyTemp([[maybe_unused]] std::size_t step) const noexcept override {
89  return t_steady_;
90  }
91 
92  void reset() noexcept override;
93 };
94 
95 // May want to average results of final 10% of runs or something like this
97 public:
99 
100  [[nodiscard]] double getHeatCapacity(std::size_t step) const noexcept override {
101  return heat_capacities_[step];
102  }
103  [[nodiscard]] double getInitTemp() const noexcept override {
104  return t_init_;
105  }
106  // 0 if no step and steady_temps_[step] if step specified (t_eq update pointless)
107  [[nodiscard]] double getSteadyTemp(std::size_t step) const noexcept override;
108 
109  void scatterUpdate(Phonon& p) const noexcept override;// NOLINT
110  [[nodiscard]] bool resetRequired([[maybe_unused]] double t_final,
111  std::vector<double>&& final_temps) noexcept override;
112  void reset() noexcept override;
113 
114 private:
115 };
116 
117 #endif// PSIM_SENSORCONTROLLER_H
Definition: material.h:15
std::array< std::pair< double, double >, NUM_FREQ_BINS > Table
Definition: material.h:20
Definition: sensorController.h:77
double getInitTemp() const noexcept override
Definition: sensorController.h:85
double getHeatCapacity([[maybe_unused]] std::size_t step) const noexcept override
Definition: sensorController.h:81
double getSteadyTemp([[maybe_unused]] std::size_t step) const noexcept override
Definition: sensorController.h:88
Definition: phonon.h:16
Definition: sensorController.h:11
std::vector< double > heat_capacities_
Definition: sensorController.h:54
SensorController(SensorController &&) noexcept=default
virtual double getSteadyTemp(std::size_t step) const noexcept=0
SensorController(const Material &material, double t_init, std::size_t num_measurements=0)
Definition: sensorController.cpp:18
double t_steady_
Definition: sensorController.h:46
const Material & material_
Definition: sensorController.h:42
virtual void reset() noexcept=0
void initialUpdate(Phonon &p, const Material::Table &table) const noexcept
Definition: sensorController.cpp:30
double getHeatCapacityAtFreq(std::size_t freq_index) const noexcept
Definition: sensorController.cpp:25
std::vector< double > steady_temps_
Definition: sensorController.h:55
double heat_capacity_
Definition: sensorController.h:47
virtual bool resetRequired(double t_final, std::vector< double > &&) noexcept
Definition: sensorController.cpp:59
const Material::Table * scatter_table_
Definition: sensorController.h:49
virtual double getInitTemp() const noexcept=0
virtual ~SensorController()=default
virtual double getHeatCapacity(std::size_t step) const noexcept=0
virtual void scatterUpdate(Phonon &p) const noexcept
Definition: sensorController.cpp:54
virtual void updateTables()
Definition: sensorController.cpp:40
double t_init_
Definition: sensorController.h:43
const Material::Table * base_table_
Definition: sensorController.h:48
const Material & getMaterial() const noexcept
Definition: sensorController.h:20
SensorController(const SensorController &)=default
std::size_t num_measurements_
Definition: sensorController.h:44
std::vector< const Material::Table * > scatter_tables_
Definition: sensorController.h:53
Definition: sensorController.h:58
double getInitTemp() const noexcept override
Definition: sensorController.h:67
double getHeatCapacity([[maybe_unused]] std::size_t step) const noexcept override
Definition: sensorController.h:62
void reset() noexcept override
Definition: sensorController.cpp:66
double getSteadyTemp([[maybe_unused]] std::size_t step) const noexcept override
Definition: sensorController.h:70
Definition: sensorController.h:96
double getHeatCapacity(std::size_t step) const noexcept override
Definition: sensorController.h:100
double getInitTemp() const noexcept override
Definition: sensorController.h:103
Material::Table Table
Definition: material.cpp:17