tardis.transport.montecarlo.packet_source module

class tardis.transport.montecarlo.packet_source.BasePacketSource(base_seed=None, legacy_mode_enabled=False, legacy_second_seed=None)[source]

Bases: ABC

Abstract base packet source

Parameters:
base_seedint

Base Seed for random number generator

legacy_secondary_seedint

Secondary seed for global numpy rng (Deprecated: Legacy reasons only)

MAX_SEED_VAL = 4294967295
calculate_radfield_luminosity()[source]

Calculate inner luminosity.

Parameters:
modelmodel.SimulationState
Returns:
astropy.units.Quantity
abstract create_packet_energies(no_of_packets, *args, **kwargs)[source]
abstract create_packet_mus(no_of_packets, *args, **kwargs)[source]
abstract create_packet_nus(no_of_packets, *args, **kwargs)[source]
abstract create_packet_radii(no_of_packets, *args, **kwargs)[source]
create_packets(no_of_packets, seed_offset=0, *args, **kwargs)[source]

Generate packet properties as arrays

Parameters:
no_of_packetsint

Number of packets

Returns:
array

Packet radii

array

Packet frequencies

array

Packet directions

array

Packet energies

class tardis.transport.montecarlo.packet_source.BlackBodySimpleSource(*args, **kwargs)[source]

Bases: BasePacketSource, HDFWriterMixin

Simple packet source that generates Blackbody packets for the Montecarlo part.

Parameters:
radiusastropy.units.Quantity

Initial packet radius

temperatureastropy.units.Quantity

Absolute Temperature.

base_seedint

Base Seed for random number generator

legacy_secondary_seedint

Secondary seed for global numpy rng (Deprecated: Legacy reasons only)

create_packet_energies(no_of_packets)[source]

Uniformly distribute energy in arbitrary units where the ensemble of packets has energy of 1.

Parameters:
no_of_packetsint

number of packets

Returns:
energies for packets

numpy.ndarray

create_packet_mus(no_of_packets)[source]

Create zero-limb-darkening packet \(\mu\) distributed according to \(\mu=\sqrt{z}, z \isin [0, 1]\)

Parameters:
no_of_packetsint

number of packets to be created

Returns:
Directions for packets

numpy.ndarray

create_packet_nus(no_of_packets, l_samples=1000)[source]

Create packet \(\nu\) distributed using the algorithm described in Bjorkman & Wood 2001 (page 4) which references Carter & Cashwell 1975: First, generate a uniform random number, \(\xi_0 \in [0, 1]\) and determine the minimum value of \(l, l_{\rm min}\), that satisfies the condition .. math:

\sum_{i=1}^{l} i^{-4} \ge {{\pi^4}\over{90}} m_0 \;.

Next obtain four additional uniform random numbers (in the range 0 to 1) \(\xi_1, \xi_2, \xi_3, {\rm and } \xi_4\). Finally, the packet frequency is given by .. math:

x = -\ln{(\xi_1\xi_2\xi_3\xi_4)}/l_{\rm min}\;.

where \(x=h\nu/kT\)

Parameters:
no_of_packetsint
l_samplesint

number of l_samples needed in the algorithm

Returns:
array of frequencies

numpy.ndarray

create_packet_radii(no_of_packets)[source]

Create packet radii

Parameters:
no_of_packetsint

number of packets to be created

Returns:
Radii for packets

numpy.ndarray

create_packets(no_of_packets, *args, **kwargs)[source]

Generate packet properties as arrays

Parameters:
no_of_packetsint

Number of packets

Returns:
array

Packet radii

array

Packet frequencies

array

Packet directions

array

Packet energies

classmethod from_simulation_state(simulation_state, *args, **kwargs)[source]
hdf_name = 'black_body_simple_source'
hdf_properties = ['radius', 'temperature', 'base_seed']
set_temperature_from_luminosity(luminosity: Quantity)[source]

Set blackbody packet source temperature from luminosity

Parameters:
luminosityu.Quantity
class tardis.transport.montecarlo.packet_source.BlackBodySimpleSourceRelativistic(*args, **kwargs)[source]

Bases: BlackBodySimpleSource, HDFWriterMixin

Simple packet source that generates Blackbody packets for the Montecarlo part.

Parameters:
time_explosionastropy.units.Quantity

Time elapsed since explosion

radiusastropy.units.Quantity

Initial packet radius

temperatureastropy.units.Quantity

Absolute Temperature.

base_seedint

Base Seed for random number generator

legacy_secondary_seedint

Secondary seed for global numpy rng (Deprecated: Legacy reasons only)

create_packet_energies(no_of_packets)[source]

Uniformly distribute energy in arbitrary units where the ensemble of packets has energy of 1 multiplied by relativistic correction factors.

Parameters:
no_of_packetsint

number of packets

Returns:
energies for packets

numpy.ndarray

create_packet_mus(no_of_packets)[source]

Create zero-limb-darkening packet \(\mu^\prime\) distributed according to \(\mu^\prime=2 \frac{\mu^\prime + \beta}{2 \beta + 1}\). The complicated distribution is due to the fact that the inner boundary on which the packets are initialized is not comoving with the material.

Parameters:
no_of_packetsint

number of packets to be created

Returns:
Directions for packets

numpy.ndarray

create_packets(no_of_packets)[source]

Generate relativistic black-body packet properties as arrays

Parameters:
no_of_packetsint

Number of packets

Returns:
array

Packet radii

array

Packet frequencies

array

Packet directions

array

Packet energies

classmethod from_simulation_state(simulation_state, *args, **kwargs)[source]
hdf_properties = ['time_explosion', 'radius', 'temperature', 'base_seed']