GGEMS  1.1
GPU GEant4-based Monte Carlo Simulations
GGEMSPhotonNavigator.hh
Go to the documentation of this file.
1 #ifndef GUARD_GGEMS_NAVIGATORS_GGEMSPHOTONNAVIGATOR_HH
2 #define GUARD_GGEMS_NAVIGATORS_GGEMSPHOTONNAVIGATOR_HH
3 
4 // ************************************************************************
5 // * This file is part of GGEMS. *
6 // * *
7 // * GGEMS is free software: you can redistribute it and/or modify *
8 // * it under the terms of the GNU General Public License as published by *
9 // * the Free Software Foundation, either version 3 of the License, or *
10 // * (at your option) any later version. *
11 // * *
12 // * GGEMS is distributed in the hope that it will be useful, *
13 // * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 // * GNU General Public License for more details. *
16 // * *
17 // * You should have received a copy of the GNU General Public License *
18 // * along with GGEMS. If not, see <https://www.gnu.org/licenses/>. *
19 // * *
20 // ************************************************************************
21 
34 #ifdef __OPENCL_C_VERSION__
35 
37 
39 
43 
47 
57 inline void GetPhotonNextInteraction(
58  global GGEMSPrimaryParticles* primary_particle,
59  global GGEMSRandom* random,
60  global GGEMSParticleCrossSections const* particle_cross_sections,
61  GGuchar const index_material,
62  GGint const particle_id)
63 {
64  // Getting energy of the particle and the index of energy in cross section table
65  GGint energy_id = BinarySearchLeft(primary_particle->E_[particle_id], particle_cross_sections->energy_bins_, particle_cross_sections->number_of_bins_, 0, 0);
66 
67  // Initialization of next interaction distance
68  GGfloat next_interaction_distance = OUT_OF_WORLD;
69  GGchar next_discrete_process = NO_PROCESS;
70  GGchar photon_process_id = 0;
71  GGfloat interaction_distance = 0.0f;
72 
73  // Loop over activated processes
74  for (GGchar i = 0; i < particle_cross_sections->number_of_activated_photon_processes_; ++i) {
75  // Getting index of process
76  photon_process_id = particle_cross_sections->photon_cs_id_[i];
77 
78  // Getting the interaction distance
79  interaction_distance =
80  -log(KissUniform(random, particle_id))/
81  particle_cross_sections->photon_cross_sections_[photon_process_id][energy_id + particle_cross_sections->number_of_bins_*index_material];
82 
83  if (interaction_distance < next_interaction_distance) {
84  next_interaction_distance = interaction_distance;
85  next_discrete_process = photon_process_id;
86  }
87  }
88 
89  // Storing results in particle buffer
90  primary_particle->E_index_[particle_id] = energy_id;
91  primary_particle->next_interaction_distance_[particle_id] = next_interaction_distance;
92  primary_particle->next_discrete_process_[particle_id] = next_discrete_process;
93 }
94 
98 
109 inline void PhotonDiscreteProcess(
110  global GGEMSPrimaryParticles* primary_particle,
111  global GGEMSRandom* random,
112  global GGEMSMaterialTables const* materials,
113  global GGEMSParticleCrossSections const* particle_cross_sections,
114  GGuchar const material_id,
115  GGint const particle_id
116 )
117 {
118  // Get photon process
119  GGchar next_iteraction_process = primary_particle->next_discrete_process_[particle_id];
120 
121  // Select process
122  if (next_iteraction_process == COMPTON_SCATTERING) {
123  KleinNishinaComptonSampleSecondaries(primary_particle, random, particle_id);
124  }
125  else if (next_iteraction_process == PHOTOELECTRIC_EFFECT) {
126  StandardPhotoElectricSampleSecondaries(primary_particle, particle_id);
127  }
128  else if (next_iteraction_process == RAYLEIGH_SCATTERING) {
129  LivermoreRayleighSampleSecondaries(primary_particle, random, materials, particle_cross_sections, material_id, particle_id);
130  }
131 }
132 
133 #endif
134 
135 #endif // GUARD_GGEMS_NAVIGATORS_GGEMSPHOTONNAVIGATOR_HH
GGEMSMathAlgorithms.hh
Definitions of miscellaneous mathematical functions.
COMPTON_SCATTERING
__constant GGchar COMPTON_SCATTERING
Definition: GGEMSProcessConstants.hh:43
GGEMSPrimaryParticles_t
Structure storing informations about primary particles.
Definition: GGEMSPrimaryParticles.hh:42
GGEMSParticleCrossSections_t
Structure storing the photon cross sections for OpenCL device.
Definition: GGEMSParticleCrossSections.hh:41
BinarySearchLeft
GGint BinarySearchLeft(GGfloat const key, GGfloat const *array, GGint const size, GGint const offset, GGint min)
Find the index of the key value in the p_array buffer.
Definition: GGEMSMathAlgorithms.hh:49
GGchar
#define GGchar
Definition: GGEMSTypes.hh:196
PHOTOELECTRIC_EFFECT
__constant GGchar PHOTOELECTRIC_EFFECT
Definition: GGEMSProcessConstants.hh:44
OUT_OF_WORLD
__constant GGfloat OUT_OF_WORLD
Definition: GGEMSParticleConstants.hh:41
GGint
#define GGint
Definition: GGEMSTypes.hh:224
GGEMSRandom_t
Structure storing informations about random.
Definition: GGEMSRandom.hh:42
GGEMSMaterialTables_t
Structure storing the material tables on OpenCL device.
Definition: GGEMSMaterialTables.hh:42
GGEMSKissEngine.hh
Functions for pseudo random number generator using KISS (Keep it Simple Stupid) engine....
GGEMSComptonScatteringModels.hh
Models for Compton scattering, only for OpenCL kernel usage.
GGEMSRayleighScatteringModels.hh
Models for Rayleigh scattering, only for OpenCL kernel usage.
RAYLEIGH_SCATTERING
__constant GGchar RAYLEIGH_SCATTERING
Definition: GGEMSProcessConstants.hh:45
GGuchar
#define GGuchar
Definition: GGEMSTypes.hh:203
NO_PROCESS
__constant GGchar NO_PROCESS
Definition: GGEMSProcessConstants.hh:38
GGEMSPhotoElectricEffectModels.hh
Models for PhotoElectric effect, only for OpenCL kernel usage.
GGfloat
#define GGfloat
Definition: GGEMSTypes.hh:273