Skip to content

Commit

Permalink
Added old functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Knights-Templars committed Apr 9, 2024
1 parent f31f934 commit b5d74bd
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 3 deletions.
89 changes: 89 additions & 0 deletions tardis/energy_input/gamma_ray_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,95 @@ def calculate_ejecta_velocity_volume(model):
return ejecta_velocity_volume


def calculate_total_decays_old(inventories, time_delta):
"""Function to create inventories of isotope
Parameters
----------
model : tardis.Radial1DModel
The tardis model to calculate gamma ray propagation through
time_end : float
End time of simulation in days
Returns
-------
Total decay list : List
list of total decays for x g of isotope for time 't'
"""
time_delta = u.Quantity(time_delta, u.s)
total_decays = {}
for shell, isotopes in inventories.items():
total_decays[shell] = {}
for isotope, name in isotopes.items():
# decays = name.decay(time_delta.value, "s")
total_decays[shell][isotope] = name.cumulative_decays(
time_delta.value
)
return total_decays


def create_isotope_dicts_old(raw_isotope_abundance, cell_masses):
"""
Function to create a dictionary of isotopes for each shell with their masses.
Parameters
----------
raw_isotope_abundance : pd.DataFrame
isotope abundance in mass fractions.
cell_masses : numpy.ndarray
shell masses in units of g
Returns
-------
isotope_dicts : Dict
dictionary of isotopes for each shell with their ``masses``.
For eg: {0: {(28, 56): {'Ni56': 0.0001}, (27, 57): {'Co56': 0.0001}}
{1: {(28, 56): {'Ni56': 0.0001}, (27, 57): {'Co56': 0.0001}}} etc
"""
isotope_dicts = {}
for i in range(len(raw_isotope_abundance.columns)):
isotope_dicts[i] = {}
for (
atomic_number,
mass_number,
), abundances in raw_isotope_abundance.iterrows():
isotope_dicts[i][atomic_number, mass_number] = {}
nuclear_symbol = f"{rd.utils.Z_to_elem(atomic_number)}{mass_number}"
isotope_dicts[i][atomic_number, mass_number][nuclear_symbol] = (
abundances[i] * cell_masses[i].to(u.g).value
)

return isotope_dicts


def create_inventories_dict_old(isotope_dict):
"""Function to create dictionary of inventories for each shell
Parameters
----------
isotope_dict : Dict
dictionary of isotopes for each shell with their ``masses``.
Returns
-------
inv : Dict
dictionary of inventories for each shell
For eg: {0: {'Ni56': <radioactivedecay.Inventory at 0x7f7d2c0d0e50>,
'Co56': <radioactivedecay.Inventory at 0x7f7d2c0d0e50>},
{1: {'Ni56': <radioactivedecay.Inventory at 0x7f7d2c0d0e50>,
'Co56': <radioactivedecay.Inventory at 0x7f7d2c0d0e50>}} etc
"""
inv = {}
for shell, isotopes in isotope_dict.items():
inv[shell] = {}
for isotope, name in isotopes.items():
inv[shell][isotope] = rd.Inventory(name, "g")

return inv


def calculate_average_energies(raw_isotope_abundance, gamma_ray_lines):
"""
Function to calculate average energies of positrons and gamma rays
Expand Down
12 changes: 9 additions & 3 deletions tardis/energy_input/main_gamma_ray_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
create_inventories_dict,
create_isotope_dicts,
)

from tardis.energy_input.gamma_ray_transport import (
calculate_total_decays_old,
create_isotope_dicts_old,
create_inventories_dict_old,
)
from tardis.energy_input.gamma_ray_packet_source import RadioactivePacketSource
from tardis.energy_input.gamma_ray_transport import (
calculate_average_energies,
Expand Down Expand Up @@ -104,9 +110,9 @@ def run_gamma_ray_loop(

mass_density_time = shell_masses[:, np.newaxis] * inv_volume_time
gamma_ray_lines = get_nuclear_lines_database(path_to_decay_data)
isotope_dict = create_isotope_dicts(raw_isotope_abundance, shell_masses)
inventories_dict = create_inventories_dict(isotope_dict)
total_decays = calculate_total_decays(
isotope_dict = create_isotope_dicts_old(raw_isotope_abundance, shell_masses)
inventories_dict = create_inventories_dict_old(isotope_dict)
total_decays = calculate_total_decays_old(
inventories_dict, time_end - time_start
)

Expand Down

0 comments on commit b5d74bd

Please sign in to comment.