tardis.simulation.base module¶
- class tardis.simulation.base.PlasmaStateStorerMixin(iterations, no_of_shells)[source]¶
 Bases:
objectMixin 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,HDFWriterMixinA composite object containing all the required information for a simulation.
- Parameters:
 - convergedbool
 - iterationsint
 - modeltardis.model.SimulationState
 - plasmatardis.plasma.BasePlasma
 - transporttardis.transport.montecarlo.MontecarloTransport
 - opacitytardis.opacities.opacity_solver.OpacitySolver
 - macro_atomtardis.opacities.macro_atom.macroatom_solver.MacroAtomSolver
 - 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(emitted_luminosity)[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
 
- estimate_t_inner(input_t_inner, luminosity_requested, emitted_luminosity, 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, atom_data=None, plasma=None, transport=None, opacity=None, macro_atom=None, **kwargs)[source]¶
 Create a simulation instance from the provided configuration.
- Parameters:
 - configobject
 The configuration object for the simulation.
- packet_sourceobject, optional
 The packet source for the simulation.
- virtual_packet_loggingbool, optional
 Flag indicating virtual packet logging.
- show_convergence_plotsbool, optional
 Flag indicating whether to show convergence plots.
- show_progress_barsbool, optional
 Flag indicating whether to show progress bars.
- legacy_mode_enabledbool, optional
 Flag indicating if legacy mode is enabled.
- atom_dataobject, optional
 The atom data for the simulation.
- plasmaobject, optional
 The plasma object for the simulation.
- transportobject, optional
 The transport solver for the simulation.
- **kwargs
 Additional keyword arguments.
- Returns:
 - object
 The created simulation instance.
- hdf_name = 'simulation'¶
 
- hdf_properties = ['simulation_state', 'plasma', 'transport', 'iterations_w', 'iterations_t_rad', 'iterations_electron_densities', 'iterations_t_inner', 'spectrum_solver']¶
 
- 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
- dilution_factornp.ndarray
 current dilution_factor
- next_t_radastropy.units.Quanity
 next t_rad
- next_dilution_factornp.ndarray
 next dilution_factor
- log_samplingint
 the n-th shells to be plotted
- Returns: