Skip to content

Commit

Permalink
Modified sampling to use positron information
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewfullard committed Apr 22, 2024
1 parent 33213d6 commit cc27c05
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions tardis/energy_input/gamma_ray_packet_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def create_packet_radii(self, sampled_packets_df):
def create_packet_nus(
self,
no_of_packets,
energy_array,
packets,
positronium_fraction,
positronium_energy,
positronium_intensity,
Expand All @@ -557,8 +557,8 @@ def create_packet_nus(
----------
no_of_packets : int
Number of packets to produce frequency-energies for
energy_arry : numpy.array
Array of energies to process
packets : pd.DataFrame
DataFrame of packets
positronium_fraction : float
The fraction of positrons that form positronium
positronium_energy : array
Expand All @@ -570,22 +570,23 @@ def create_packet_nus(
-------
array
Array of sampled frequency-energies
array
Positron creation mask
"""
positrons = np.zeros(no_of_packets)
energy_array = np.zeros(no_of_packets)
zs = np.random.random(no_of_packets)
for i in range(no_of_packets):
# positron (could be handled with other masking options)
if energy_array[i] == 511:
# positron
if packets.iloc[i]["decay_type"] == "bp":
# positronium formation 25% of the time if fraction is 1
if zs[i] < positronium_fraction and np.random.random() < 0.25:
energy_array[i] = sample_energy(
positronium_energy, positronium_intensity
)
positrons[i] = 1
else:
energy_array[i] = 511
else:
energy_array[i] = packets.iloc[i]["radiation_energy_kev"]

return energy_array, positrons
return energy_array

def create_packet_directions(self, no_of_packets):
"""Create an array of random directions
Expand Down Expand Up @@ -765,9 +766,9 @@ def create_packets(

# the individual gamma-ray energy that makes up a packet
# co-moving frame, including positronium formation
nu_energies_cmf, positron_mask = self.create_packet_nus(
nu_energies_cmf = self.create_packet_nus(
number_of_packets,
sampled_packets_df["radiation_energy_keV"].values,
sampled_packets_df,
self.positronium_fraction,
positronium_energy,
positronium_intensity,
Expand Down

0 comments on commit cc27c05

Please sign in to comment.