Skip to content

Commit

Permalink
restored to master's version
Browse files Browse the repository at this point in the history
  • Loading branch information
DhruvSondhi committed Dec 13, 2021
1 parent cdface2 commit 31524b8
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tardis/montecarlo/tests/test_montecarlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import tardis.montecarlo.montecarlo_configuration as mc
from tardis import constants as const
from tardis.montecarlo.montecarlo_numba.numba_interface import Estimators
from tardis.montecarlo.montecarlo_numba.numba_interface import RPacketCollection
from tardis.montecarlo.montecarlo_numba import macro_atom

from tardis.montecarlo.montecarlo_numba.frame_transformations import (
Expand Down Expand Up @@ -816,3 +817,49 @@ def test_compute_distance2line_relativistic(

assert_allclose(comov_nu, nu_line, rtol=1e-14)


"""
Tests for Tracking RPacket Properties
"""


@pytest.mark.parametrize("seed", [2274437677])
@pytest.mark.parametrize(
["index", "r", "nu", "mu", "energy"],
[
(0, 0, 0, 0, 0),
(10, 1.43e15, 6.57e14, 0.92701038, 0.00010347),
(20, 2.04e15, 9.59e14, 0.96005622, 0.00010347),
(30, 1.12e15, 2.17e14, 0.96787487, 0.00010347),
(40, 2.15e15, 9.17e14, 0.96428633, 0.00010347),
(100000, 2.23e15, 8.56e14, 0.96946856, 0.00010347),
],
)
def test_rpacket_tracking(index, seed, r, nu, mu, energy):
# Setup Montecarlo_Configuration.INITIAL_TRACKING_ARRAY_LENGTH
mc.INITIAL_TRACKING_ARRAY_LENGTH = 10

tracked_rpacket_properties = RPacketCollection()
test_rpacket = r_packet.RPacket(
index=index,
seed=seed,
r=r,
nu=nu,
mu=mu,
energy=energy,
)

# TearDown Montecarlo_Configuration.INITIAL_TRACKING_ARRAY_LENGTH
mc.INITIAL_TRACKING_ARRAY_LENGTH = None

tracked_rpacket_properties.track(test_rpacket)
tracked_rpacket_properties.finalize_array()

assert test_rpacket.index == tracked_rpacket_properties.index
assert test_rpacket.seed == tracked_rpacket_properties.seed
assert test_rpacket.r == tracked_rpacket_properties.r
assert test_rpacket.nu == tracked_rpacket_properties.nu
assert test_rpacket.mu == tracked_rpacket_properties.mu
assert test_rpacket.energy == tracked_rpacket_properties.energy
assert tracked_rpacket_properties.interact_id == 1

0 comments on commit 31524b8

Please sign in to comment.