You can interact with this notebook online: Launch notebook

Tracking the Properties of Real Packets

TARDIS has the functionality to track the properties of the RPackets that are generated when running the Simulation. The rpacket_tracker can track all the interactions a packet undergoes & thus keeps a track of the various properties, a packet may have.Currently, the rpacket_tracker tracks the properties of all the rpackets in the Last Iteration of the Simulation. It generates a List that contains the individual instances of RPacketCollection{Numba JITClass}, for storing all the interaction properties as listed below.

The properties that are tracked are as follows :

  1. index - Index of the Packet

  2. seed - Seed of the Packet

  3. status - Current Status for the Packet Interaction

  4. r - Radius of the Current Shell

  5. nu - Packet’s Frequency

  6. mu - Propagation Direction of the Packet (cosine of the angle the packet’s path makes with the radial direction)

  7. energy - Energy of the Packet

  8. shell_id - Current Shell Id where the Packet is present

  9. interaction_type - Last Interaction type of the packet

The data can be obtained in two ways i.e. rpacket_tracker and rpacket_tracker_df. The rpacket_tracker stores all the data for the interaction of the packets in a list, so it needs to accessed with a list index for each property for a particular rpacket. rpacket_tracker_df stores the data in a dataframe. Examples for the same are shown as follows.

How to Setup the Tracking for the RPackets?

TARDISrpacket_tracker is configured via the YAML file. This functionality of tracking the packets is turned off, by default. This is due to that fact that using this property, may slow down the execution time for the Simulation. An example configuration can be seen below for setting up the tracking:

...
montecarlo:
...
tracking:
    track_rpacket: true

The montecarlo section of the YAML file now has a tracking sub section which holds the configuration properties for the track_rpacket & the initial_array_length (discussed later in the tutorial).

Let us see, the new rpacket_tracker in action.

[1]:
from tardis.io.configuration.config_reader import Configuration
/usr/share/miniconda3/envs/tardis/lib/python3.11/site-packages/setuptools_scm/git.py:162: UserWarning: "/home/runner/work/tardis/tardis" is shallow and may cause errors
  warnings.warn(f'"{wd.path}" is shallow and may cause errors')
[2]:
# Reading the Configuration stored in `tardis_config_packet_tracking.yml` into config

config = Configuration.from_yaml("tardis_example.yml")
[3]:
# Checking the `tracking` section via the Schema

config["montecarlo"]["tracking"]
[3]:
{'track_rpacket': False, 'initial_array_length': 10}
[4]:
# Setting `r_packet_tracking` to True to turn on the Tracking

config["montecarlo"]["tracking"]["track_rpacket"] = True
[5]:
config["montecarlo"]["tracking"]
[5]:
{'track_rpacket': True, 'initial_array_length': 10}
[6]:
from tardis import run_tardis
from tardis.io.atom_data.util import download_atom_data
[7]:
download_atom_data('kurucz_cd23_chianti_H_He')
Atomic Data kurucz_cd23_chianti_H_He already exists in /home/runner/Downloads/tardis-data/kurucz_cd23_chianti_H_He.h5. Will not download - override with force_download=True.
[8]:
# Running the simulation from the config

sim = run_tardis(config, show_convergence_plots=False, show_progress_bars=False)
[tardis.simulation.base][INFO   ]

        Reading Atomic Data from kurucz_cd23_chianti_H_He.h5 (base.py:681)
[tardis.io.atom_data.util][INFO   ]

        Atom Data kurucz_cd23_chianti_H_He.h5 not found in local path.
        Exists in TARDIS Data repo /home/runner/Downloads/tardis-data/kurucz_cd23_chianti_H_He.h5 (util.py:36)
[tardis.io.atom_data.base][INFO   ]
        Reading Atom Data with: UUID = 6f7b09e887a311e7a06b246e96350010 MD5  = 864f1753714343c41f99cb065710cace  (base.py:258)
[tardis.io.atom_data.base][INFO   ]
        Non provided Atomic Data: synpp_refs, photoionization_data, yg_data, two_photon_data, linelist (base.py:262)
[tardis.model.parse_input][WARNING]
        Number of density points larger than number of shells. Assuming inner point irrelevant (parse_input.py:143)
[tardis.model.matter.decay][INFO   ]
        Decaying abundances for 1123200.0 seconds (decay.py:101)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 1 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 7.942e+42 erg / s
        Luminosity absorbed  = 2.659e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 9.93e+03 K 1.01e+04 K 0.4 0.507
5 9.85e+03 K 1.02e+04 K 0.211 0.197
10 9.78e+03 K 1.01e+04 K 0.143 0.117
15 9.71e+03 K 9.87e+03 K 0.105 0.0869
[tardis.simulation.base][INFO   ]

        Current t_inner = 9933.952 K
        Expected t_inner for next iteration = 10703.212 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 2 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.071e+43 erg / s
        Luminosity absorbed  = 3.576e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.01e+04 K 1.08e+04 K 0.507 0.525
5 1.02e+04 K 1.1e+04 K 0.197 0.203
10 1.01e+04 K 1.08e+04 K 0.117 0.125
15 9.87e+03 K 1.05e+04 K 0.0869 0.0933
[tardis.simulation.base][INFO   ]

        Current t_inner = 10703.212 K
        Expected t_inner for next iteration = 10673.712 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 3 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.074e+43 erg / s
        Luminosity absorbed  = 3.391e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.08e+04 K 1.1e+04 K 0.525 0.483
5 1.1e+04 K 1.12e+04 K 0.203 0.189
10 1.08e+04 K 1.1e+04 K 0.125 0.118
15 1.05e+04 K 1.06e+04 K 0.0933 0.0895
[tardis.simulation.base][INFO   ]

        Current t_inner = 10673.712 K
        Expected t_inner for next iteration = 10635.953 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 4 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.058e+43 erg / s
        Luminosity absorbed  = 3.352e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.1e+04 K 0.483 0.469
5 1.12e+04 K 1.12e+04 K 0.189 0.182
10 1.1e+04 K 1.1e+04 K 0.118 0.113
15 1.06e+04 K 1.07e+04 K 0.0895 0.0861
[tardis.simulation.base][INFO   ]

        Current t_inner = 10635.953 K
        Expected t_inner for next iteration = 10638.407 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 5 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.055e+43 erg / s
        Luminosity absorbed  = 3.399e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]
        Iteration converged 1/4 consecutive times. (base.py:268)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.1e+04 K 0.469 0.479
5 1.12e+04 K 1.13e+04 K 0.182 0.178
10 1.1e+04 K 1.1e+04 K 0.113 0.113
15 1.07e+04 K 1.07e+04 K 0.0861 0.0839
[tardis.simulation.base][INFO   ]

        Current t_inner = 10638.407 K
        Expected t_inner for next iteration = 10650.202 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 6 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.061e+43 erg / s
        Luminosity absorbed  = 3.398e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]
        Iteration converged 2/4 consecutive times. (base.py:268)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.1e+04 K 0.479 0.47
5 1.13e+04 K 1.12e+04 K 0.178 0.185
10 1.1e+04 K 1.11e+04 K 0.113 0.112
15 1.07e+04 K 1.07e+04 K 0.0839 0.0856
[tardis.simulation.base][INFO   ]

        Current t_inner = 10650.202 K
        Expected t_inner for next iteration = 10645.955 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 7 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.061e+43 erg / s
        Luminosity absorbed  = 3.382e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]
        Iteration converged 3/4 consecutive times. (base.py:268)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.1e+04 K 0.47 0.47
5 1.12e+04 K 1.13e+04 K 0.185 0.178
10 1.11e+04 K 1.11e+04 K 0.112 0.112
15 1.07e+04 K 1.07e+04 K 0.0856 0.086
[tardis.simulation.base][INFO   ]

        Current t_inner = 10645.955 K
        Expected t_inner for next iteration = 10642.050 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 8 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.062e+43 erg / s
        Luminosity absorbed  = 3.350e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]
        Iteration converged 4/4 consecutive times. (base.py:268)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.11e+04 K 0.47 0.472
5 1.13e+04 K 1.14e+04 K 0.178 0.175
10 1.11e+04 K 1.11e+04 K 0.112 0.111
15 1.07e+04 K 1.07e+04 K 0.086 0.084
[tardis.simulation.base][INFO   ]

        Current t_inner = 10642.050 K
        Expected t_inner for next iteration = 10636.106 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 9 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.052e+43 erg / s
        Luminosity absorbed  = 3.411e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]
        Iteration converged 5/4 consecutive times. (base.py:268)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 K 1.11e+04 K 0.472 0.469
5 1.14e+04 K 1.15e+04 K 0.175 0.17
10 1.11e+04 K 1.11e+04 K 0.111 0.109
15 1.07e+04 K 1.08e+04 K 0.084 0.0822
[tardis.simulation.base][INFO   ]

        Current t_inner = 10636.106 K
        Expected t_inner for next iteration = 10654.313 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 10 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.070e+43 erg / s
        Luminosity absorbed  = 3.335e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 K 1.1e+04 K 0.469 0.475
5 1.15e+04 K 1.14e+04 K 0.17 0.177
10 1.11e+04 K 1.11e+04 K 0.109 0.112
15 1.08e+04 K 1.06e+04 K 0.0822 0.0878
[tardis.simulation.base][INFO   ]

        Current t_inner = 10654.313 K
        Expected t_inner for next iteration = 10628.190 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 11 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.053e+43 erg / s
        Luminosity absorbed  = 3.363e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]
        Iteration converged 1/4 consecutive times. (base.py:268)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.1e+04 K 0.475 0.472
5 1.14e+04 K 1.12e+04 K 0.177 0.184
10 1.11e+04 K 1.1e+04 K 0.112 0.114
15 1.06e+04 K 1.06e+04 K 0.0878 0.0859
[tardis.simulation.base][INFO   ]

        Current t_inner = 10628.190 K
        Expected t_inner for next iteration = 10644.054 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 12 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.056e+43 erg / s
        Luminosity absorbed  = 3.420e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.11e+04 K 0.472 0.467
5 1.12e+04 K 1.13e+04 K 0.184 0.176
10 1.1e+04 K 1.11e+04 K 0.114 0.11
15 1.06e+04 K 1.08e+04 K 0.0859 0.0821
[tardis.simulation.base][INFO   ]

        Current t_inner = 10644.054 K
        Expected t_inner for next iteration = 10653.543 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 13 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.062e+43 erg / s
        Luminosity absorbed  = 3.406e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]
        Iteration converged 1/4 consecutive times. (base.py:268)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 K 1.11e+04 K 0.467 0.466
5 1.13e+04 K 1.13e+04 K 0.176 0.18
10 1.11e+04 K 1.11e+04 K 0.11 0.111
15 1.08e+04 K 1.08e+04 K 0.0821 0.0841
[tardis.simulation.base][INFO   ]

        Current t_inner = 10653.543 K
        Expected t_inner for next iteration = 10647.277 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 14 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.063e+43 erg / s
        Luminosity absorbed  = 3.369e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]
        Iteration converged 2/4 consecutive times. (base.py:268)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 K 1.11e+04 K 0.466 0.469
5 1.13e+04 K 1.13e+04 K 0.18 0.182
10 1.11e+04 K 1.1e+04 K 0.111 0.113
15 1.08e+04 K 1.07e+04 K 0.0841 0.0854
[tardis.simulation.base][INFO   ]

        Current t_inner = 10647.277 K
        Expected t_inner for next iteration = 10638.875 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 15 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.053e+43 erg / s
        Luminosity absorbed  = 3.417e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]
        Iteration converged 3/4 consecutive times. (base.py:268)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 K 1.1e+04 K 0.469 0.484
5 1.13e+04 K 1.13e+04 K 0.182 0.181
10 1.1e+04 K 1.1e+04 K 0.113 0.113
15 1.07e+04 K 1.07e+04 K 0.0854 0.0858
[tardis.simulation.base][INFO   ]

        Current t_inner = 10638.875 K
        Expected t_inner for next iteration = 10655.125 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 16 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.059e+43 erg / s
        Luminosity absorbed  = 3.445e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]
        Iteration converged 4/4 consecutive times. (base.py:268)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.1e+04 K 0.484 0.472
5 1.13e+04 K 1.13e+04 K 0.181 0.177
10 1.1e+04 K 1.1e+04 K 0.113 0.113
15 1.07e+04 K 1.06e+04 K 0.0858 0.0858
[tardis.simulation.base][INFO   ]

        Current t_inner = 10655.125 K
        Expected t_inner for next iteration = 10655.561 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 17 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.067e+43 erg / s
        Luminosity absorbed  = 3.372e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.11e+04 K 0.472 0.468
5 1.13e+04 K 1.14e+04 K 0.177 0.175
10 1.1e+04 K 1.11e+04 K 0.113 0.11
15 1.06e+04 K 1.08e+04 K 0.0858 0.0816
[tardis.simulation.base][INFO   ]

        Current t_inner = 10655.561 K
        Expected t_inner for next iteration = 10636.536 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 18 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.057e+43 erg / s
        Luminosity absorbed  = 3.365e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]
        Iteration converged 1/4 consecutive times. (base.py:268)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 K 1.11e+04 K 0.468 0.464
5 1.14e+04 K 1.13e+04 K 0.175 0.177
10 1.11e+04 K 1.1e+04 K 0.11 0.113
15 1.08e+04 K 1.07e+04 K 0.0816 0.0848
[tardis.simulation.base][INFO   ]

        Current t_inner = 10636.536 K
        Expected t_inner for next iteration = 10641.692 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 19 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.056e+43 erg / s
        Luminosity absorbed  = 3.405e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)
[tardis.simulation.base][INFO   ]
        Iteration converged 2/4 consecutive times. (base.py:268)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 K 1.11e+04 K 0.464 0.466
5 1.13e+04 K 1.13e+04 K 0.177 0.177
10 1.1e+04 K 1.11e+04 K 0.113 0.111
15 1.07e+04 K 1.07e+04 K 0.0848 0.0853
[tardis.simulation.base][INFO   ]

        Current t_inner = 10641.692 K
        Expected t_inner for next iteration = 10650.463 K
 (base.py:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Simulation finished in 19 iterations
        Simulation took 92.61 s
 (base.py:476)
[tardis.simulation.base][INFO   ]

        Starting iteration 20 of 20 (base.py:398)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.061e+43 erg / s
        Luminosity absorbed  = 3.401e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:580)

Now, the tracked properties can be accessed via the rpacket_tracker attribute of the sim.transport object.

[9]:
type(sim.transport.transport_state.rpacket_tracker)
[9]:
numba.typed.typedlist.List

It can be seen from the above code, that the sim.transport.rpacket_tracker is an instance of the List specifically Numba Typed List. The RPacketCollection class has the following structure for the properties : {More information in the TARDIS API for RPacketCollection class}

# Basic structure for the RPacketCollection Class
class RPacketCollection:
   # Properties
    index
    seed
    status
    r
    nu
    mu
    energy
    shell_id
    interaction_type
[10]:
len(sim.transport.transport_state.rpacket_tracker)
[10]:
100000

Accessing properties through rpacket_tracker

To access these different properties, we may consider the following examples for the rpacket_tracker: In this Example, we are trying to access the properties of the packet at index 10.In a similar way, we can check for any property for any packet in the range of packets for the last iteration.

Accessing the index property for the packet with index = 10 :

[11]:
sim.transport.transport_state.rpacket_tracker[10].index
[11]:
10

Accessing the seed property for the packet with index = 10 :

[12]:
sim.transport.transport_state.rpacket_tracker[10].seed
[12]:
2729103521

Accessing the status property for the packet with index = 10 :

[13]:
sim.transport.transport_state.rpacket_tracker[10].status
[13]:
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 1])

Thus, all other properties (r, nu, mu, energy, shell_id,interaction_type) can be accessed accordingly.

We can also see the total number of interactions of index 10 packet under went, with the following example:

[14]:
len(sim.transport.transport_state.rpacket_tracker[10].shell_id)
[14]:
53

Warning

If we try to access sim.transport.rpacket_tracker property when we have the track_rpacket property in the tracking subsection of montecarlo config, turned off as follows config["montecarlo"]["tracking"]["track_rpacket"] = False, it will return None. Error will be raised if we try to access the properties i.e. seed, index, etc.

Note

When we initialise the RPacketCollection() class, the properties arrays {index, seed, status, etc} are allocated certain length based on the initial_array_length parameter that can be set via the initial_array_length property under montecarlo -> tracking section of the configuration. The default size of the array is 10. This variable is important as the number of interactions a packet may have is variable, thus we need to allocate space dynamically. This variable is used to compute the size and expand the array such that the properties are able to hold these values for the packet interaction. Higher number, allocates more space initially leading to lesser times the arrays expands and vice versa. It can be set in the following manner config["montecarlo"]["tracking"]["initial_array_length"] = {value}.

Accessing properties with rpacket_tracker_df

Also, the tracked properties can be accessed via the rpacket_tracker_df attribute of the sim.transport object.

[15]:
type(sim.transport.transport_state.rpacket_tracker_df)
[15]:
pandas.core.frame.DataFrame

Here, all the properties of the rpackets discussed above are stored as a Pandas.Dataframe object. This makes accessing the properties of any rpacket more convenient and in a more organized way.

The Basic structure of the Dataframe is as follows: Index Columns:

  1. index - Indicates the index number of the packet.

  2. step - It is the step number that any particular packet is on, as it moves through the ejecta.

Properties: These following properties are present as columns in the Dataframe. These are the same properties that were present in the rpacket_tracker

  1. status

  2. seed

  3. r

  4. nu

  5. mu

  6. energy

  7. shell_id

  8. interaction_type

The entire dataframe, containing all the properties mentioned above, can be fetched as:

[16]:
sim.transport.transport_state.rpacket_tracker_df
[16]:
status seed r nu mu energy shell_id interaction_type
index step
0 0 0 3338016338 1.235520e+15 1.736483e+15 0.839765 0.00001 0 -1
1 0 3338016338 1.263676e+15 2.569811e+15 -0.608549 0.00001 0 2
2 0 3338016338 1.244956e+15 1.684571e+15 0.052209 0.00001 0 2
3 0 3338016338 1.245022e+15 1.682866e+15 0.025872 0.00001 0 2
4 0 3338016338 1.248276e+15 9.577869e+14 -0.281524 0.00001 0 2
... ... ... ... ... ... ... ... ... ...
99999 17 0 864415001 2.044224e+15 1.159042e+14 0.904834 0.00001 16 1
18 0 864415001 2.094768e+15 1.159042e+14 0.909597 0.00001 17 1
19 0 864415001 2.145312e+15 1.159042e+14 0.914006 0.00001 18 1
20 0 864415001 2.195856e+15 1.159042e+14 0.918094 0.00001 19 1
21 1 864415001 2.246400e+15 1.159042e+14 0.921893 0.00001 19 1

1981438 rows × 8 columns

To access these different properties in the dataframe, we may consider the following examples for the rpacket_tracker_df: In this Example, we are trying to access the properties of the packet at index 10.In a similar way, we can check for any property for any packet in the range of packets for the last iteration.

Accessing all the properties for the packet with index = 10:

[17]:
sim.transport.transport_state.rpacket_tracker_df.loc[10]
[17]:
status seed r nu mu energy shell_id interaction_type
step
0 0 2729103521 1.235520e+15 2.100434e+15 0.587433 0.000010 0 -1
1 0 2729103521 1.286064e+15 2.100434e+15 0.628923 0.000010 1 -1
2 0 2729103521 1.336608e+15 2.100434e+15 0.663623 0.000010 2 -1
3 0 2729103521 1.387152e+15 2.100434e+15 0.693133 0.000010 3 -1
4 0 2729103521 1.437696e+15 2.100434e+15 0.718556 0.000010 4 -1
5 0 2729103521 1.488240e+15 2.100434e+15 0.740688 0.000010 5 -1
6 0 2729103521 1.514008e+15 1.966980e+15 -0.707127 0.000010 5 1
7 0 2729103521 1.488240e+15 1.966980e+15 -0.694668 0.000010 4 1
8 0 2729103521 1.437696e+15 1.966980e+15 -0.667490 0.000010 3 1
9 0 2729103521 1.387152e+15 1.966980e+15 -0.635925 0.000010 2 1
10 0 2729103521 1.387113e+15 2.093418e+15 0.868696 0.000010 2 2
11 0 2729103521 1.387152e+15 2.093418e+15 0.868704 0.000010 3 2
12 0 2729103521 1.437696e+15 2.093418e+15 0.878405 0.000010 4 2
13 0 2729103521 1.488240e+15 2.093418e+15 0.887043 0.000010 5 2
14 0 2729103521 1.538784e+15 2.093418e+15 0.894773 0.000010 6 2
15 0 2729103521 1.589328e+15 2.093418e+15 0.901720 0.000010 7 2
16 0 2729103521 1.639872e+15 2.093418e+15 0.907988 0.000010 8 2
17 0 2729103521 1.690416e+15 2.093418e+15 0.913665 0.000010 9 2
18 0 2729103521 1.709334e+15 2.754770e+15 0.357089 0.000010 9 2
19 0 2729103521 1.726723e+15 3.040742e+15 0.224209 0.000010 9 2
20 0 2729103521 1.740960e+15 3.040742e+15 0.256398 0.000010 10 2
21 0 2729103521 1.752721e+15 1.680385e+15 0.226400 0.000010 10 2
22 0 2729103521 1.764487e+15 1.669485e+15 0.129774 0.000010 10 2
23 0 2729103521 1.791504e+15 1.669485e+15 0.215107 0.000010 11 2
24 0 2729103521 1.793179e+15 1.575386e+15 -0.889332 0.000009 11 2
25 0 2729103521 1.791504e+15 1.575386e+15 -0.889112 0.000009 10 2
26 0 2729103521 1.740960e+15 1.575386e+15 -0.882145 0.000009 9 2
27 0 2729103521 1.690416e+15 1.575386e+15 -0.874481 0.000009 8 2
28 0 2729103521 1.639872e+15 1.575386e+15 -0.866019 0.000009 7 2
29 0 2729103521 1.589328e+15 1.575386e+15 -0.856642 0.000009 6 2
30 0 2729103521 1.538784e+15 1.575386e+15 -0.846205 0.000009 5 2
31 0 2729103521 1.488240e+15 1.575386e+15 -0.834535 0.000009 4 2
32 0 2729103521 1.439546e+15 1.610949e+15 -0.287407 0.000009 4 1
33 0 2729103521 1.437696e+15 1.610949e+15 -0.283268 0.000009 3 1
34 0 2729103521 1.419306e+15 2.160489e+15 0.495893 0.000010 3 2
35 0 2729103521 1.437696e+15 2.160489e+15 0.514857 0.000010 4 2
36 0 2729103521 1.488240e+15 2.160489e+15 0.560490 0.000010 5 2
37 0 2729103521 1.513523e+15 1.212817e+15 0.618740 0.000010 5 2
38 0 2729103521 1.538784e+15 1.212817e+15 0.634772 0.000010 6 2
39 0 2729103521 1.589328e+15 1.212817e+15 0.663557 0.000010 7 2
40 0 2729103521 1.639872e+15 1.212817e+15 0.688678 0.000010 8 2
41 0 2729103521 1.690416e+15 1.212817e+15 0.710807 0.000010 9 2
42 0 2729103521 1.740960e+15 1.212817e+15 0.730450 0.000010 10 2
43 0 2729103521 1.791504e+15 1.212817e+15 0.748001 0.000010 11 2
44 0 2729103521 1.842048e+15 1.212817e+15 0.763771 0.000010 12 2
45 0 2729103521 1.892592e+15 1.212817e+15 0.778013 0.000010 13 2
46 0 2729103521 1.943136e+15 1.212817e+15 0.790930 0.000010 14 2
47 0 2729103521 1.993680e+15 1.212817e+15 0.802692 0.000010 15 2
48 0 2729103521 2.044224e+15 1.212817e+15 0.813441 0.000010 16 2
49 0 2729103521 2.094768e+15 1.212817e+15 0.823295 0.000010 17 2
50 0 2729103521 2.145312e+15 1.212817e+15 0.832357 0.000010 18 2
51 0 2729103521 2.195856e+15 1.212817e+15 0.840712 0.000010 19 2
52 1 2729103521 2.246400e+15 1.212817e+15 0.848435 0.000010 19 2

Accessing the energy property for the packet with index = 10:

[18]:
sim.transport.transport_state.rpacket_tracker_df.loc[10]["energy"]
[18]:
step
0     0.000010
1     0.000010
2     0.000010
3     0.000010
4     0.000010
5     0.000010
6     0.000010
7     0.000010
8     0.000010
9     0.000010
10    0.000010
11    0.000010
12    0.000010
13    0.000010
14    0.000010
15    0.000010
16    0.000010
17    0.000010
18    0.000010
19    0.000010
20    0.000010
21    0.000010
22    0.000010
23    0.000010
24    0.000009
25    0.000009
26    0.000009
27    0.000009
28    0.000009
29    0.000009
30    0.000009
31    0.000009
32    0.000009
33    0.000009
34    0.000010
35    0.000010
36    0.000010
37    0.000010
38    0.000010
39    0.000010
40    0.000010
41    0.000010
42    0.000010
43    0.000010
44    0.000010
45    0.000010
46    0.000010
47    0.000010
48    0.000010
49    0.000010
50    0.000010
51    0.000010
52    0.000010
Name: energy, dtype: float64

The above command returns a Pandas Series for the packet #10 across different steps. To access any property at a particular step (for example at step 5), the following commands can be used.

[19]:
sim.transport.transport_state.rpacket_tracker_df.loc[10,5]["energy"]
[19]:
1.0220289382469194e-05
[20]:
sim.transport.transport_state.rpacket_tracker_df.loc[10]["energy"][5]
[20]:
1.0220289382469194e-05

Thus, all other properties (status, seed, r, nu, mu, shell_id,interaction_type) can be accessed accordingly.