diff --git a/hadrons/common/continous_beam.py b/hadrons/common/continous_beam.py index e05ad2b..fc943d8 100644 --- a/hadrons/common/continous_beam.py +++ b/hadrons/common/continous_beam.py @@ -3,6 +3,7 @@ import numpy as np from numpy.random import Generator, default_rng +from tqdm import tqdm from hadrons.common.generic_hadron_solver import GenericHadronSolver from hadrons.utils.common import doserate_to_fluence @@ -69,6 +70,7 @@ def __post_init__(self): def get_number_of_tracks(self, time_step: int) -> bool: if time_step == 0: print(self.track_distribution) + return 1 return self.track_distribution[time_step] def get_random_xy_coordinate(self): @@ -96,11 +98,18 @@ def get_track_for_time_step(self, time_step: int): x, y = self.get_random_coordinates() - for k in range(self.no_z_electrode, self.no_z + self.no_z_electrode): + for k in tqdm( + range(self.no_z_electrode, self.no_z + self.no_z_electrode), + desc="Calculating track...", + ): for i in range(self.no_xy): + x_track_dist_squared = (i - x) ** 2 + x_chamber_dist_squared = (i - self.xy_middle_idx) ** 2 + for j in range(self.no_xy): distance_from_center = ( - sqrt((i - x) ** 2 + (j - y) ** 2) * self.grid_spacing + sqrt(x_track_dist_squared + (j - y) ** 2) + * self.grid_spacing ) ion_density = self.Gaussian_factor * exp( -(distance_from_center**2) / self.track_radius**2 @@ -109,12 +118,11 @@ def get_track_for_time_step(self, time_step: int): negative_array[i, j, k] += ion_density # calculate the recombination only for charge carriers inside the circle if ( - sqrt( - (i - self.xy_middle_idx) ** 2 - + (j - self.xy_middle_idx) ** 2 - ) + sqrt(x_chamber_dist_squared + (j - self.xy_middle_idx) ** 2) < self.inner_radius ): + # TODO: I'm not sure why this check is here - when separatioon_time_steps >= computation_time_steps, + # the simulation will not work properly since we are ignoring all the initialised charge carriers if time_step > self.separation_time_steps: no_initialised_charge_carriers += ion_density diff --git a/hadrons/common/generic_hadron_solver.py b/hadrons/common/generic_hadron_solver.py index fcb713e..5f627f3 100644 --- a/hadrons/common/generic_hadron_solver.py +++ b/hadrons/common/generic_hadron_solver.py @@ -54,7 +54,7 @@ class GenericHadronSolver(ABC): electrode_gap: float # [cm] energy: float # [MeV/u] RDD_model: Literal["Gauss", "Geiss"] = "Gauss" - grid_spacing: float = 3e-4 # [cm] + grid_spacing: float = 3e-3 # [cm] # TODO: Narrow this type down particle: str = "proton" no_z_electrode: int = ( @@ -118,7 +118,7 @@ def separation_time_steps(self) -> int: @property def computation_time_steps(self) -> int: - return self.separation_time_steps * 2 + return self.separation_time_steps * 5 @property def RDD_function(self):