MIDSX 0.1
A x-ray transport code system for dosimetry
Loading...
Searching...
No Matches
physics_engine.h
1#ifndef PHYSICSENGINE_H
2#define PHYSICSENGINE_H
3
4#include "photon.h"
5#include "computational_domain.h"
6#include "probability_dist.h"
7#include "interaction_data.h"
8#include "interpolators.h"
9#include "photon_interactions.h"
10#include "volume_tally.h"
11#include "voxel.h"
12#include "surface_tally.h"
13#include <cmath>
14#include <utility>
15
16namespace PhysicsEngineHelpers {
17 bool areCollinearAndSameDirection(const Eigen::Vector3d& vec1, const Eigen::Vector3d& vec2);
18}
19
20
22public:
23
30 PhysicsEngine(ComputationalDomain& comp_domain, InteractionData& interaction_data);
31
37 void transportPhoton(Photon& photon);
38
50 void transportPhotonOneStep(Photon& photon, std::vector<TempSurfaceTallyData>& temp_surface_tally_data_per_photon,
51 std::vector<TempVolumeTallyData>& temp_volume_tally_data_per_photon,
52 std::vector<TempVoxelData>& temp_voxel_data_per_photon);
53
64 void setInteractionType(Photon& photon, Material& material, double total_cross_section);
65
71 void addVolumeTallies(std::vector<std::unique_ptr<VolumeTally>>&& volume_tallies);
72
78 void addSurfaceTallies(std::vector<std::unique_ptr<SurfaceTally>>&& surface_tallies);
79
86
87
93 std::vector<VolumeQuantityContainer> getVolumeQuantityContainers();
94
100 std::vector<SurfaceQuantityContainer> getSurfaceQuantityContainers();
101
107
114private:
115 ComputationalDomain& comp_domain_;
116 ProbabilityDist::Uniform uniform_dist_;
117 InteractionData& interaction_data_;
118 std::vector<std::vector<std::unique_ptr<VolumeTally>>> thread_local_volume_tallies_;
119 std::vector<std::vector<std::unique_ptr<SurfaceTally>>> thread_local_surface_tallies_;
120 std::vector<std::vector<TempVoxelData>> thread_local_voxel_data_;
121 std::shared_ptr<PhotoelectricEffect> photoelectric_effect_;
122 std::shared_ptr<IncoherentScattering> incoherent_scattering_;
123 std::shared_ptr<CoherentScattering> coherent_scattering_;
124
133 double getFreePath(double max_cross_section);
134
142 bool isDeltaScatter(double cross_section, double max_cross_section);
143
152 void updateTempTallyPerPhoton(std::vector<TempSurfaceTallyData>& temp_surface_tally_data_per_photon,
153 std::vector<TempVolumeTallyData>& temp_volume_tally_data_per_photon,
154 TempSurfaceTallyData& temp_surface_tally_data, TempVolumeTallyData& temp_volume_tally_data);
155
163 void processTallies(std::vector<TempSurfaceTallyData>& temp_surface_tally_data_per_photon,
164 std::vector<TempVolumeTallyData>& temp_volume_tally_data_per_photon,
165 std::vector<TempVoxelData>& temp_voxel_data_per_photon);
166};
167
168#endif
Class which represents the computational domain.
Class which provides access to various simulation significant data.
Class which represents a material.
Definition material.h:19
Class which represents a photon. Inherits from Particle.
Definition photon.h:25
void transportPhotonOneStep(Photon &photon, std::vector< TempSurfaceTallyData > &temp_surface_tally_data_per_photon, std::vector< TempVolumeTallyData > &temp_volume_tally_data_per_photon, std::vector< TempVoxelData > &temp_voxel_data_per_photon)
Transports photon one step. Either performs a real or delta interaction.
void setInteractionType(Photon &photon, Material &material, double total_cross_section)
Sets the interaction type of the photon.
void addVolumeTallies(std::vector< std::unique_ptr< VolumeTally > > &&volume_tallies)
Sets the volume tallies of the simulation.
void initializeVoxelData()
Initializes the voxel data for a thread. Exists since omp_max_num_threads() is influenced by previous...
void transportPhoton(Photon &photon)
Transports a photon until an photoelectric interaction occurs or leaves the voxel grid (i....
PhysicsEngine(ComputationalDomain &comp_domain, InteractionData &interaction_data)
Constructor for the PhysicsEngine class.
void addVoxelDataToComputationalDomain()
Takes thread local voxel data and adds it to the computational domain. Should be called after all pho...
double getFreePath(double max_cross_section)
Returns the free path length of the photon.
static void processPhotonOutsideVoxelGrid(Photon &photon)
Processes the domain boundary crossing of a photon by terminating the photon.
bool isDeltaScatter(double cross_section, double max_cross_section)
Checks if the photon undergoes delta scattering or interacts.
std::vector< SurfaceQuantityContainer > getSurfaceQuantityContainers()
Returns the SurfaceQuantityContainers of the simulation.
void addSurfaceTallies(std::vector< std::unique_ptr< SurfaceTally > > &&surface_tallies)
Sets the surface tallies of the simulation.
void updateTempTallyPerPhoton(std::vector< TempSurfaceTallyData > &temp_surface_tally_data_per_photon, std::vector< TempVolumeTallyData > &temp_volume_tally_data_per_photon, TempSurfaceTallyData &temp_surface_tally_data, TempVolumeTallyData &temp_volume_tally_data)
Updates the temporary tallies for the photon.
void processTallies(std::vector< TempSurfaceTallyData > &temp_surface_tally_data_per_photon, std::vector< TempVolumeTallyData > &temp_volume_tally_data_per_photon, std::vector< TempVoxelData > &temp_voxel_data_per_photon)
Processes the tallies for the photon.
std::vector< VolumeQuantityContainer > getVolumeQuantityContainers()
Returns the VolumeQuantityContainers of the simulation.
Class which represents a uniform distribution.
Struct which represents the temporary data for a surface tally.
Definition tally_data.h:24
Struct which represents the temporary data for a volume tally.
Definition tally_data.h:37