tardis.transport.montecarlo.modes.montecarlo_transport module

Shared Monte Carlo transport loop utilities.

tardis.transport.montecarlo.modes.montecarlo_transport.make_r_packet(packet_collection: PacketCollection, packet_index: int) → RPacket[source]

Build and seed a radiative packet from a packet collection.

Parameters:
packet_collectionPacketCollection

Packet collection containing the initial packet arrays.

packet_indexint

Packet index.

Returns:
RPacket

Radiative packet initialized from the packet collection.

tardis.transport.montecarlo.modes.montecarlo_transport.montecarlo_transport(packet_collection: PacketCollection, geometry_state_numba: NumbaHomologousRadial1DGeometry | NumbaRadial1DGeometry, time_explosion: float, opacity_state_numba: OpacityStateNumba, montecarlo_configuration: MonteCarloConfiguration, trackers: List[TrackerFull] | List[TrackerLastInteraction], show_progress_bars: bool, packet_propagation_function: Callable[[...], None]) → tuple[EstimatorsBulk, EstimatorsLine][source]

Run real-packet Monte Carlo transport and record packet histories.

Parameters:
packet_collectionPacketCollection

Packet collection containing packet input and output arrays.

geometry_state_numba

Numba geometry object for the transport mode.

time_explosionfloat

Time since explosion in seconds. Non-homologous mode accepts but does not use this value.

opacity_state_numba

Numba opacity state.

montecarlo_configurationMonteCarloConfiguration

Monte Carlo transport configuration.

trackers

Per-packet trackers.

show_progress_barsbool

Whether packet progress bars are enabled.

packet_propagation_function

Mode-specific packet propagation function.

Returns:
tuple

Bulk and line estimators.

tardis.transport.montecarlo.modes.montecarlo_transport.set_packet_collection_output(packet_collection: PacketCollection, r_packet: RPacket, packet_index: int) → None[source]

Store final packet frequency and signed energy in a packet collection.

Parameters:
packet_collectionPacketCollection

Packet collection to update.

r_packetRPacket

Packet after propagation.

packet_indexint

Packet index.

tardis.transport.montecarlo.modes.montecarlo_transport.update_packet_progress(show_progress_bars: bool, thread_id: int, main_thread_id: int, n_threads: int, no_of_packets: int) → None[source]

Update the packet progress bar from the main Numba worker thread.

Parameters:
show_progress_barsbool

Whether progress bars are enabled.

thread_idint

Current worker thread id.

main_thread_idint

Thread id selected to perform progress updates.

n_threadsint

Number of Numba worker threads.

no_of_packetsint

Total number of packets.