tardis.transport.montecarlo.packet_source.base module

class tardis.transport.montecarlo.packet_source.base.BasePacketSource(base_seed: int | None = None, legacy_mode_enabled: bool = False, legacy_second_seed: int | None = None)[source]

Bases: ABC

Abstract base packet source.

This abstract base class defines the interface for packet sources used in TARDIS Monte Carlo radiative transfer. Packet sources are responsible for creating radiation packets with specific properties.

Parameters:
base_seedint, optional

Base seed for random number generator. Default is None.

legacy_mode_enabledbool, optional

Whether to enable legacy mode for compatibility. Default is False.

legacy_second_seedint, optional

Secondary seed for global numpy rng (Deprecated: Legacy reasons only). Default is None.

Attributes:
MAX_SEED_VALint

Maximum seed value allowed by numpy (2**32 - 1).

base_seedint or None

Base seed for random number generator.

legacy_mode_enabledbool

Whether legacy mode is enabled.

rngnumpy.random.Generator

Random number generator instance.

MAX_SEED_VAL: int = 4294967295
calculate_radfield_luminosity() Quantity[source]

Calculate inner luminosity from blackbody radiation.

Uses the Stefan-Boltzmann law to calculate the luminosity from the inner boundary radius and temperature.

Returns:
astropy.units.Quantity

Inner luminosity in erg/s.

abstractmethod create_packet_energies(no_of_packets: int, *args: Any, **kwargs: Any)[source]

Create packet energies.

Parameters:
no_of_packetsint

Number of packets to create.

*args

Additional positional arguments.

**kwargs

Additional keyword arguments.

Returns:
array-like

Packet energy values.

abstractmethod create_packet_mus(no_of_packets: int, *args: Any, **kwargs: Any)[source]

Create packet direction cosines.

Parameters:
no_of_packetsint

Number of packets to create.

*args

Additional positional arguments.

**kwargs

Additional keyword arguments.

Returns:
array-like

Packet direction cosine values.

abstractmethod create_packet_nus(no_of_packets: int, *args: Any, **kwargs: Any)[source]

Create packet frequencies.

Parameters:
no_of_packetsint

Number of packets to create.

*args

Additional positional arguments.

**kwargs

Additional keyword arguments.

Returns:
array-like

Packet frequency values.

create_packet_radii(no_of_packets: int, *args: Any, **kwargs: Any)[source]

Create packet radii.

This method should be implemented by subclasses that create packets with specific radii. Either this method or create_packet_velocities should be implemented.

Parameters:
no_of_packetsint

Number of packets to create.

*args

Additional positional arguments.

**kwargs

Additional keyword arguments.

Returns:
array-like

Packet radii values.

Raises:
NotImplementedError

If the method is not implemented by the subclass.

create_packet_velocities(no_of_packets: int, *args: Any, **kwargs: Any)[source]

Create packet velocities.

This method should be implemented by subclasses that create packets with specific velocities. Either this method or create_packet_radii should be implemented.

Parameters:
no_of_packetsint

Number of packets to create.

*args

Additional positional arguments.

**kwargs

Additional keyword arguments.

Returns:
array-like

Packet velocity values.

Raises:
NotImplementedError

If the method is not implemented by the subclass.

create_packets(no_of_packets: int, seed_offset: int = 0, *args: Any, **kwargs: Any) PacketCollection[source]

Generate packet properties as arrays.

Parameters:
no_of_packetsint

Number of packets to create.

seed_offsetint, optional

Offset added to the base seed for randomness across iterations. Default is 0.

*args

Additional positional arguments passed to packet creation methods.

**kwargs

Additional keyword arguments passed to packet creation methods.

Returns:
PacketCollection

Collection containing packet radii, frequencies, directions, energies, seeds, and radiation field luminosity.