You can interact with this notebook online: Launch notebook

Setup ExampleΒΆ

We show an example of setting up a TARDIS simulation.

[1]:
# We import the necessary packages
from tardis.io.configuration.config_reader import Configuration
from tardis.simulation import Simulation
from tardis.io.atom_data.util import download_atom_data

# We download the atomic data needed to run the simulation
download_atom_data('kurucz_cd23_chianti_H_He')
/home/runner/micromamba/envs/tardis/lib/python3.11/site-packages/setuptools_scm/git.py:162: UserWarning: "/home/runner/work/tardis/tardis" is shallow and may cause errors
  warnings.warn(f'"{wd.path}" is shallow and may cause errors')
Atomic Data kurucz_cd23_chianti_H_He already exists in /home/runner/Downloads/tardis-data/kurucz_cd23_chianti_H_He.h5. Will not download - override with force_download=True.

We read a configuration as shown here:

[2]:
tardis_config = Configuration.from_yaml('tardis_example.yml')

We create a Simulation object from the configuration using the Simulation.from_config() class method.

[3]:
sim = Simulation.from_config(tardis_config)
sim
Number of density points larger than number of shells. Assuming inner point irrelevant
/home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
/home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
[3]:
<tardis.simulation.base.Simulation at 0x7fcf81771990>

When the Simulation object is created, a SimulationState, BasePlasma, and MontecarloTransport object are created and stored as attributes of the Simulation object.

[4]:
sim.simulation_state
[4]:
<tardis.model.base.SimulationState at 0x7fcf83bcb190>
[5]:
sim.plasma
[5]:
<tardis.plasma.base.BasePlasma at 0x7fcf8cb1e850>
[6]:
sim.transport
[6]:
<tardis.montecarlo.base.MonteCarloTransportSolver at 0x7fcf8128c6d0>