psim  1.0
Generalized 2D phonon transport using a Monte Carlo method
model.h
Go to the documentation of this file.
1 #ifndef PSIM_MODEL_H
2 #define PSIM_MODEL_H
3 
4 #include "cell.h"// for Cell
5 #include "material.h"// for Material
6 #include "modelSimulator.h"// for ModelSimulator
7 #include "outputManager.h"// for OutputManager
8 #include "psim/geometry.h"// for Point, Triangle (ptr only)
9 #include "psim/sensor.h"// for Sensor, Sensor::SimulationType
10 #include "sensorInterpreter.h"// for SensorInterpreter
11 #include <cstddef>// for size_t
12 #include <filesystem>// for path
13 #include <memory>// for unique_ptr
14 #include <mutex>// for mutex
15 #include <optional>// for optional
16 #include <string>// for string, basic_string
17 #include <unordered_map>// for unordered_map
18 #include <utility>// for pair
19 #include <vector>// for vector
20 
21 
29 class Model {
30 public:
33 
44  Model(std::size_t num_cells,
45  std::size_t num_sensors,
46  std::size_t measurement_steps,
47  std::size_t num_phonons,
48  double simulation_time,
49  double t_eq,
50  bool phasor_sim = false);
58  void setSimulationType(SimulationType type, std::size_t step_interval = 0);
65  void addMaterial(const std::string& material_name, const Material& material);
74  void addSensor(std::size_t ID,
75  const std::string& material_name,
76  double t_init,
77  Sensor::SimulationType type);// NOLINT
86  void addCell(Geometry::Triangle&& triangle, std::size_t sensor_ID, double spec = 1.);
97  void addCell(Point&& p1, Point&& p2, std::size_t sensor_ID, double spec = 1.);// NOLINT
114  [[nodiscard]] bool
115  setEmitSurface(const Point& p1, const Point& p2, double temp, double duration, double start_time);// NOLINT
116 
117  void runSimulation();
118  void exportResults(const fs::path& filepath, double time) const;
119 
120 private:
122  std::size_t num_cells_;
123  std::size_t measurement_steps_;
124  double simulation_time_;
125  std::size_t num_phonons_;
126  double t_eq_{ 0. };// Changes as the system evolves between runs
127  bool phasor_sim_;
128  std::size_t start_step_{ 0 };// 0 for SS simulations -> measurements vectors are scaled down in the sensors
129 
130  ModelSimulator simulator_;
131  OutputManager outputManager_;
132  SensorInterpreter interpreter_;
133  std::unique_ptr<std::mutex> addMeasurementMutex_;
134 
135  std::vector<Cell> cells_;
136  std::vector<Sensor> sensors_;
137  std::unordered_map<std::string, Material> materials_;
138 
144  [[nodiscard]] Sensor& getSensor(std::size_t ID);// NOLINT
145  [[nodiscard]] double getTotalInitialEnergy() const noexcept;
150  [[nodiscard]] std::pair<double, double> setTemperatureBounds() noexcept;
151  void initializeMaterialTables(double low_temp, double high_temp);
152  [[nodiscard]] double avgTemp() const;
153  void storeResults() noexcept;
158  [[nodiscard]] std::optional<double> resetRequired() noexcept;
159  void reset() noexcept;
160 };
161 
162 
163 #endif// PSIM_MODEL_H
Geometry::Point Point
Definition: cell.cpp:18
Definition: material.h:15
Definition: modelSimulator.h:17
Definition: model.h:29
void addMaterial(const std::string &material_name, const Material &material)
Definition: model.cpp:89
void runSimulation()
Definition: model.cpp:157
void setSimulationType(SimulationType type, std::size_t step_interval=0)
Definition: model.cpp:63
void exportResults(const fs::path &filepath, double time) const
Definition: model.cpp:191
Model(std::size_t num_cells, std::size_t num_sensors, std::size_t measurement_steps, std::size_t num_phonons, double simulation_time, double t_eq, bool phasor_sim=false)
Definition: model.cpp:43
bool setEmitSurface(const Point &p1, const Point &p2, double temp, double duration, double start_time)
Definition: model.cpp:142
void addSensor(std::size_t ID, const std::string &material_name, double t_init, Sensor::SimulationType type)
Definition: model.cpp:98
void addCell(Geometry::Triangle &&triangle, std::size_t sensor_ID, double spec=1.)
Definition: model.cpp:115
Definition: outputManager.h:14
Definition: sensorInterpreter.h:9
Definition: sensor.h:14
SimulationType
Definition: sensor.h:16
Definition: geometry.h:23
Definition: geometry.h:76