psim
1.0
Generalized 2D phonon transport using a Monte Carlo method
|
#include <model.h>
Public Types | |
using | Point = Geometry::Point |
using | SimulationType = Sensor::SimulationType |
Public Member Functions | |
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) | |
void | setSimulationType (SimulationType type, std::size_t step_interval=0) |
void | addMaterial (const std::string &material_name, const Material &material) |
void | addSensor (std::size_t ID, const std::string &material_name, double t_init, Sensor::SimulationType type) |
void | addCell (Geometry::Triangle &&triangle, std::size_t sensor_ID, double spec=1.) |
void | addCell (Point &&p1, Point &&p2, std::size_t sensor_ID, double spec=1.) |
bool | setEmitSurface (const Point &p1, const Point &p2, double temp, double duration, double start_time) |
void | runSimulation () |
void | exportResults (const fs::path &filepath, double time) const |
The Model class primarily controls the geometrical aspects of the simulation. Materials must be added first with the addMaterials function. Then the sensors must be added as each sensor is linked to a material. Then the cells can be added as they are linked to sensors. If a cell contains emitting surfaces, they must be added immediately after the cell is added. The class will throw if components are not added in this sequence.
using Model::Point = Geometry::Point |
Model::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 |
||
) |
num_cells | - The number of cells that the model will contain. |
num_sensors | - The number of sensors should be <= num_cells |
measurement_steps | - The total number of measurement steps (temp/flux recordings) |
num_phonons | - The total number of phonons to simulate. More phonons gives more precision but increases simulation time. |
simulation_time | - The duration of the simulation |
t_eq | - The linearization (equilibrium) temperature of the system - 0 indicates a full simulation |
phasor_sim | - True -> phonons have uniform direction & velocity & no scattering |
void Model::addCell | ( | Geometry::Triangle && | triangle, |
std::size_t | sensor_ID, | ||
double | spec = 1. |
||
) |
Adds a triangular cell to the system. Ensures new cells are not contained in existing cells and existing cells do not contain the new cell. Also verifies that the new cell does not intersect any existing cells. Will throw if any of these occur.
triangle | - The underlying shape of the cell |
sensor_ID | - The sensor this cell is linked to -> will throw if the sensor does not exist |
spec | - The specularity of the cell's boundary surfaces [0-1] |
This not not used as the python interface takes care of this
Adds a rectangular cell to the system. This will count as 2 cells as the surface is broken down into two right angled triangles.
p1 | - The lower left point of the rectangle |
p2 | - The upper right point of the rectangle |
sensor_ID | - The sensor this cell is linked to -> will throw if the sensor does not exist |
spec | - The specularity of the cell's boundary surfaces [0-1] |
void Model::addMaterial | ( | const std::string & | material_name, |
const Material & | material | ||
) |
void Model::addSensor | ( | std::size_t | ID, |
const std::string & | material_name, | ||
double | t_init, | ||
Sensor::SimulationType | type | ||
) |
Adds a Sensor object to the model. Each sensor is linked to a number of cells so that not every cell must independently track its own temperature and flux values in addition to scattering considerations.
ID | - The ID of the sensor, each sensor needs a unique ID. Throws if the ID already exists in the model |
material_name | - The name of the material this sensor is linked to. Throws if the material does not exist |
t_init | - The initial temperature of the cells linked to the sensor |
type | - The type of simulation - steady-state periodic or transient |
void Model::exportResults | ( | const fs::path & | filepath, |
double | time | ||
) | const |
void Model::runSimulation | ( | ) |
bool Model::setEmitSurface | ( | const Point & | p1, |
const Point & | p2, | ||
double | temp, | ||
double | duration, | ||
double | start_time | ||
) |
Tries to set the line given by p1 and p2 to an emitting surface. A transient surface is set if a start time and duration are specified. Otherwise, the surface emits from phonons from time 0 until the end of the simulation - non transient cases. If a transient surface is specified, the simulation type must be transient.
Throws if the input line overlaps with an existing transition or existing emitting surface or if start_times < 0 or >= simulation_time_ and if duration is < 0 or >= simulation_time_-start_time. Also throws if a transient surface is specified but the simulation type is not transient.
p1 | - point 1 of a line segment |
p2 | - point 2 of a line segment |
temp | - The temperature of the emitting surface |
duration | - The duration of time the transient surface will emit phonons |
start_time | - The amount of time into the simulation at which this surface starts emitting phonons |
void Model::setSimulationType | ( | SimulationType | type, |
std::size_t | step_interval = 0 |
||
) |
type | - The type of simulation. Default is steady state. |
step_interval | - For periodic and transient simulations only. The distance between steps for which measurements are recorded. Throws if the step interval is not valid for the given simulation type. This throw can be handled but an error here likely indicates the user is not performing the simulation they think they are. |