tardis.transport.montecarlo.modes.montecarlo_transport module

Shared Monte Carlo transport loop utilities.

tardis.transport.montecarlo.modes.montecarlo_transport.add_vpacket_collection_to_histogram(v_packets_energy_hist: ndarray, vpacket_collection: VPacketCollection, spectrum_frequency_grid: ndarray, delta_nu: float) None[source]

Add virtual packet collection energies to a spectrum histogram.

Parameters:
v_packets_energy_histnumpy.ndarray

Energy histogram to update in place.

vpacket_collectionVPacketCollection

Finalized virtual packet collection.

spectrum_frequency_gridnumpy.ndarray

Frequency grid for the histogram.

delta_nufloat

Frequency bin width.

tardis.transport.montecarlo.modes.montecarlo_transport.create_vpacket_collections(no_of_packets: int, spectrum_frequency_grid: np.ndarray, montecarlo_configuration: MonteCarloConfiguration, number_of_vpackets: int)[source]

Create per-packet virtual packet collections.

Parameters:
no_of_packetsint

Number of real packets.

spectrum_frequency_gridnumpy.ndarray

Frequency grid for virtual packet spectra.

montecarlo_configurationMonteCarloConfiguration

Monte Carlo transport configuration.

number_of_vpacketsint

Number of virtual packets spawned per real packet interaction.

Returns:
numba.typed.List

Per-packet virtual packet collections.

tardis.transport.montecarlo.modes.montecarlo_transport.get_vpacket_tracker(vpacket_collections, spectrum_frequency_grid: np.ndarray, montecarlo_configuration: MonteCarloConfiguration) VPacketCollection[source]

Consolidate virtual packet tracking output when configured.

Parameters:
vpacket_collectionsnumba.typed.List

Per-packet virtual packet collections.

spectrum_frequency_gridnumpy.ndarray

Frequency grid for virtual packet spectra.

montecarlo_configurationMonteCarloConfiguration

Monte Carlo transport configuration.

Returns:
VPacketCollection

Consolidated tracker or an empty placeholder collection.

tardis.transport.montecarlo.modes.montecarlo_transport.make_r_packet(packet_collection: PacketCollection, packet_index: int)[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_with_vpackets(packet_collection: PacketCollection, geometry_state_numba, time_explosion: float, opacity_state_numba, montecarlo_configuration: MonteCarloConfiguration, spectrum_frequency_grid: np.ndarray, trackers, number_of_vpackets: int, show_progress_bars: bool, packet_propagation_function) tuple[np.ndarray, VPacketCollection, type, type][source]

Run line-only Monte Carlo transport with virtual packet tracking.

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.

spectrum_frequency_gridnumpy.ndarray

Frequency grid for virtual packet spectra.

trackers

Per-packet trackers.

number_of_vpacketsint

Number of virtual packets spawned per real packet interaction.

show_progress_barsbool

Whether packet progress bars are enabled.

packet_propagation_function

Mode-specific packet propagation function.

Returns:
tuple

Virtual packet histogram, consolidated virtual packet tracker, bulk estimators, 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.