Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR to separate main gamma ray loop #2529

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
514 changes: 514 additions & 0 deletions docs/working_gamma_ray_test.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tardis/energy_input/GXPacket.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class GXPacketStatus(IntEnum):
PAIR_CREATION = 2
IN_PROCESS = 3
END = 4
ESCAPED = 5


gxpacket_spec = [
Expand Down Expand Up @@ -92,7 +93,6 @@ def initialize_packet_properties(
initial_radius,
times,
effective_times,
inventory,
average_power_per_mass,
uniform_packet_energies=True,
):
Expand Down
41 changes: 35 additions & 6 deletions tardis/energy_input/gamma_packet_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
energy_df_rows,
energy_plot_df_rows,
energy_out,
packets_out,
packets_info_array,
):
"""Propagates packets through the simulation

Expand Down Expand Up @@ -151,28 +153,31 @@
# electron count per isotope
photoabsorption_opacity = 0
# photoabsorption_opacity_calculation_kasen()
else:
elif photoabsorption_opacity_type == "tardis":

Check warning on line 156 in tardis/energy_input/gamma_packet_loop.py

View check run for this annotation

Codecov / codecov/patch

tardis/energy_input/gamma_packet_loop.py#L156

Added line #L156 was not covered by tests
photoabsorption_opacity = (
photoabsorption_opacity_calculation(
comoving_energy,
mass_density_time[packet.shell, time_index],
iron_group_fraction_per_shell[packet.shell],
)
)
else:
raise ValueError("Invalid photoabsorption opacity type!")

Check warning on line 165 in tardis/energy_input/gamma_packet_loop.py

View check run for this annotation

Codecov / codecov/patch

tardis/energy_input/gamma_packet_loop.py#L165

Added line #L165 was not covered by tests

if pair_creation_opacity_type == "artis":
pair_creation_opacity = pair_creation_opacity_artis(
comoving_energy,
mass_density_time[packet.shell, time_index],
iron_group_fraction_per_shell[packet.shell],
)
else:
elif pair_creation_opacity_type == "tardis":

Check warning on line 173 in tardis/energy_input/gamma_packet_loop.py

View check run for this annotation

Codecov / codecov/patch

tardis/energy_input/gamma_packet_loop.py#L173

Added line #L173 was not covered by tests
pair_creation_opacity = pair_creation_opacity_calculation(
comoving_energy,
mass_density_time[packet.shell, time_index],
iron_group_fraction_per_shell[packet.shell],
)

else:
raise ValueError("Invalid pair creation opacity type!")

Check warning on line 180 in tardis/energy_input/gamma_packet_loop.py

View check run for this annotation

Codecov / codecov/patch

tardis/energy_input/gamma_packet_loop.py#L180

Added line #L180 was not covered by tests
else:
compton_opacity = 0.0
pair_creation_opacity = 0.0
Expand Down Expand Up @@ -235,7 +240,6 @@
)

elif distance == distance_interaction:

packet.status = scatter_type(
compton_opacity,
photoabsorption_opacity,
Expand Down Expand Up @@ -277,14 +281,18 @@

if packet.shell > len(mass_density_time[:, 0]) - 1:
rest_energy = packet.nu_rf * H_CGS_KEV
lum_rf = (packet.energy_rf * 1.6022e-9) / dt

Check warning on line 284 in tardis/energy_input/gamma_packet_loop.py

View check run for this annotation

Codecov / codecov/patch

tardis/energy_input/gamma_packet_loop.py#L284

Added line #L284 was not covered by tests
bin_index = get_index(rest_energy, energy_bins)
bin_width = (
energy_bins[bin_index + 1] - energy_bins[bin_index]
)
energy_out[bin_index, time_index] += rest_energy / (
bin_width * dt
)
packet.status = GXPacketStatus.END
packets_out[bin_index] = np.array(

Check warning on line 292 in tardis/energy_input/gamma_packet_loop.py

View check run for this annotation

Codecov / codecov/patch

tardis/energy_input/gamma_packet_loop.py#L292

Added line #L292 was not covered by tests
[bin_index, i, rest_energy, packet.Z, packet.A]
)
packet.status = GXPacketStatus.ESCAPED

Check warning on line 295 in tardis/energy_input/gamma_packet_loop.py

View check run for this annotation

Codecov / codecov/patch

tardis/energy_input/gamma_packet_loop.py#L295

Added line #L295 was not covered by tests
escaped_packets += 1
if scattered:
scattered_packets += 1
Expand All @@ -293,10 +301,31 @@
packet.energy_cmf = 0.0
packet.status = GXPacketStatus.END

packets_info_array[i] = np.array(

Check warning on line 304 in tardis/energy_input/gamma_packet_loop.py

View check run for this annotation

Codecov / codecov/patch

tardis/energy_input/gamma_packet_loop.py#L304

Added line #L304 was not covered by tests
[
i,
packet.status,
packet.nu_cmf,
packet.nu_rf,
packet.energy_cmf,
lum_rf,
packet.energy_rf,
packet.shell,
]
)

print("Escaped packets:", escaped_packets)
print("Scattered packets:", scattered_packets)

return energy_df_rows, energy_plot_df_rows, energy_out, deposition_estimator
return (

Check warning on line 320 in tardis/energy_input/gamma_packet_loop.py

View check run for this annotation

Codecov / codecov/patch

tardis/energy_input/gamma_packet_loop.py#L320

Added line #L320 was not covered by tests
energy_df_rows,
energy_plot_df_rows,
energy_out,
deposition_estimator,
packets_out,
bin_width,
packets_info_array,
)


@njit(**njit_dict_no_parallel)
Expand Down
Loading
Loading