tardis.simulation.base module

class tardis.simulation.base.PlasmaStateStorerMixin(iterations, no_of_shells)[source]

Bases: object

Mixin class to provide the capability to the simulation object of storing plasma information and the inner boundary temperature during each MC iteration.

Currently, storage for the dilution factor, the radiation temperature and the electron density in each cell is provided. Additionally, the temperature at the inner boundary is saved.

reshape_plasma_state_store(executed_iterations)[source]

Reshapes the storage arrays in case convergence was reached before all specified iterations were executed.

Parameters
executed_iterationsint

iteration index, i.e. number of iterations executed minus one!

store_plasma_state(i, w, t_rad, electron_densities, t_inner)[source]

Store current plasma information and inner boundary temperature used in iterated i.

Parameters
iint

current iteration index (0 for the first)

wnp.ndarray

dilution factor

t_radastropy.units.Quantity

radiation temperature

electron_densitiesnp.ndarray

electron density

t_innerastropy.units.Quantity

temperature of inner boundary

class tardis.simulation.base.Simulation(*args, **kwargs)[source]

Bases: PlasmaStateStorerMixin, HDFWriterMixin

A composite object containing all the required information for a simulation.

Parameters
convergedbool
iterationsint
modeltardis.model.SimulationState
plasmatardis.plasma.BasePlasma
transporttardis.transport.montecarlo.MontecarloTransport
no_of_packetsint
last_no_of_packetsint
no_of_virtual_packetsint
luminosity_nu_startastropy.units.Quantity
luminosity_nu_endastropy.units.Quantity
luminosity_requestedastropy.units.Quantity
convergence_plots_kwargs: dict
add_callback(cb_func, *args)[source]

Add a function which will be called after every iteration.

The cb_func signature must look like: cb_func(simulation, extra_arg1, …)

Parameters
cb_funccallable

The callback function

arg1

The first additional arguments passed to the callable function

Returns
: int

The callback ID

advance_state()[source]

Advances the state of the model and the plasma for the next iteration of the simulation. Returns True if the convergence criteria are met, else False.

Returns
convergedbool
static damped_converge(value, estimated_value, damping_factor)[source]
estimate_t_inner(input_t_inner, luminosity_requested, t_inner_update_exponent=-0.5)[source]
classmethod from_config(config, packet_source=None, virtual_packet_logging=False, show_convergence_plots=False, show_progress_bars=True, legacy_mode_enabled=False, **kwargs)[source]

Create a new Simulation instance from a Configuration object.

Parameters
configtardis.io.config_reader.Configuration
**kwargs

Allow overriding some structures, such as model, plasma, atomic data and the transport, instead of creating them from the configuration object.

Returns
Simulation
hdf_name = 'simulation'
hdf_properties = ['simulation_state', 'plasma', 'transport', 'iterations_w', 'iterations_t_rad', 'iterations_electron_densities', 'iterations_t_inner']
iterate(no_of_packets, no_of_virtual_packets=0)[source]
log_plasma_state(t_rad, dilution_factor, t_inner, next_t_rad, next_dilution_factor, next_t_inner, log_sampling=5)[source]

Logging the change of the plasma state

Parameters
t_radastropy.units.Quanity

current t_rad

wastropy.units.Quanity

current w

next_t_radastropy.units.Quanity

next t_rad

next_wastropy.units.Quanity

next_w

log_samplingint

the n-th shells to be plotted

Returns
log_run_results(emitted_luminosity, absorbed_luminosity)[source]
remove_callback(id)[source]

Remove the callback with a specific ID (which was returned by add_callback)

Parameters
idint

The callback ID

Returns
: True if the callback was successfully removed.
run_convergence()[source]

run the simulation

run_final()[source]

run the last iteration of the simulation