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

Update line_interaction_in_r after moving the packet #2811

Merged
merged 3 commits into from
Sep 11, 2024
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
1 change: 1 addition & 0 deletions tardis/transport/montecarlo/interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ def line_emission(
"""
r_packet.last_line_interaction_out_id = emission_line_id
r_packet.last_line_interaction_shell_id = r_packet.current_shell_id
r_packet.last_interaction_in_r = r_packet.r

if emission_line_id != r_packet.next_line_id:
pass
Expand Down
2 changes: 0 additions & 2 deletions tardis/transport/montecarlo/r_packet_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ def trace_packet(
if tau_trace_combined > tau_event and not disable_line_scattering:
interaction_type = InteractionType.LINE # Line
r_packet.last_interaction_in_nu = r_packet.nu
r_packet.last_interaction_in_r = r_packet.r
r_packet.last_line_interaction_in_id = cur_line_id
r_packet.last_line_interaction_shell_id = r_packet.current_shell_id
r_packet.next_line_id = cur_line_id
distance = distance_trace
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,28 @@ def shell_id_in_use(
interaction_type_in_use,
):
"""
shell_id when last interaction is line from LastInteractionTracker class
`shell_id` when last interaction is line from LastInteractionTracker class
"""
transport_state = nb_simulation_verysimple.transport.transport_state
shell_id = transport_state.last_line_interaction_shell_id
mask = interaction_type_in_use == InteractionType.LINE
return shell_id[mask]


@pytest.fixture()
def r_in_use(
nb_simulation_verysimple,
interaction_type_in_use,
):
"""
`r` when last interaction is line from LastInteractionTracker class
"""
transport_state = nb_simulation_verysimple.transport.transport_state
r = transport_state.last_interaction_in_r
mask = interaction_type_in_use == InteractionType.LINE
return r[mask]


@pytest.fixture(scope="module")
def interaction_type_to_check(
nb_simulation_verysimple,
Expand Down Expand Up @@ -69,6 +83,24 @@ def shell_id_to_check(
return shell_id[mask]


@pytest.fixture()
def r_to_check(
nb_simulation_verysimple,
interaction_type_to_check,
):
"""
`r` when last interaction is line from RPacketLastInteractionTracker class
"""
transport_state = nb_simulation_verysimple.transport.transport_state
r = np.empty(len(transport_state.rpacket_tracker), dtype=np.int64)
for i, last_interaction_tracker in enumerate(
transport_state.rpacket_tracker
):
r[i] = last_interaction_tracker.r
mask = interaction_type_to_check == InteractionType.LINE
return r[mask]


@pytest.fixture()
def nu_packet_collection(
nb_simulation_verysimple,
Expand Down Expand Up @@ -127,6 +159,10 @@ def test_tracking_manual(static_packet):
"shell_id_in_use",
"shell_id_to_check",
),
(
"r_in_use",
"r_to_check",
),
("nu_packet_collection", "nu_to_check"),
],
)
Expand Down
Loading