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: tardis.simulation.base.PlasmaStateStorerMixin, tardis.io.util.HDFWriterMixin

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

Parameters
convergedbool
iterationsint
modeltardis.model.Radial1DModel
plasmatardis.plasma.BasePlasma
runnertardis.montecarlo.MontecarloRunner
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
nthreadsint

The number of threads to run montecarlo with

Note

TARDIS must be built with OpenMP support in order for nthreads to have effect.

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, **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 runner, instead of creating them from the configuration object.

Returns
Simulation
hdf_name = 'simulation'
hdf_properties = ['model', 'plasma', 'runner', 'iterations_w', 'iterations_t_rad', 'iterations_electron_densities', 'iterations_t_inner']
iterate(no_of_packets, no_of_virtual_packets=0, last_run=False)[source]
log_plasma_state(t_rad, w, t_inner, next_t_rad, next_w, 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

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()[source]

run the simulation