You can interact with this notebook online: Launch notebook
How to use Adaptive Damping for Convergence in TARDIS¶
This notebook demonstrates how to run the TARDIS example configuration with the existing damped convergence strategy and the new adaptive_damped strategy, and illustrates their convergence behavior across iterations.
Damped Convergence Strategy¶
This example uses the standard TARDIS damped convergence strategy specified in the configuration file tardis_example.yml with the damping constant set to 0.5 (or another user-specified value between 0.1 and 1.0).
[1]:
!cat tardis_example.yml
# Example YAML configuration for TARDIS
tardis_config_version: v1.0
supernova:
luminosity_requested: 9.44 log_lsun
time_explosion: 13 day
atom_data: kurucz_cd23_chianti_H_He_latest.h5
model:
structure:
type: specific
velocity:
start: 1.1e4 km/s
stop: 20000 km/s
num: 20
density:
type: branch85_w7
abundances:
type: uniform
O: 0.19
Mg: 0.03
Si: 0.52
S: 0.19
Ar: 0.04
Ca: 0.03
plasma:
disable_electron_scattering: no
ionization: lte
excitation: lte
radiative_rates_type: dilute-blackbody
line_interaction_type: macroatom
montecarlo:
seed: 23111963
no_of_packets: 4.0e+4
iterations: 20
nthreads: 1
last_no_of_packets: 1.e+5
no_of_virtual_packets: 10
convergence_strategy:
type: damped
damping_constant: 1.0
threshold: 0.05
fraction: 0.8
hold_iterations: 3
t_inner:
damping_constant: 0.5
spectrum:
start: 500 angstrom
stop: 20000 angstrom
num: 10000
Running the Simulation¶
To run the simulation, import the run_tardis function and create the sim_damped object.
[2]:
from tardis import run_tardis
[3]:
sim_damped = run_tardis("tardis_example.yml",
virtual_packet_logging=True,
show_convergence_plots=True,
export_convergence_plots=True,
log_level="INFO")
Auto-detected Sphinx build environment
Auto-detected Sphinx build environment
Initializing tabulator and plotly panel extensions for widgets to work
Embedding the final state for Jupyter environments
Adaptive Damped Convergence Strategy¶
This example uses the adaptive_damped convergence strategy specified in the configuration file tardis_adaptive_damped_example.yml, where the damping factor is adjusted dynamically during the simulation, removing the need for manual tuning.
[4]:
!cat tardis_adaptive_damped_example.yml
# Example YAML configuration for the adaptive damped convergence strategy in TARDIS
tardis_config_version: v1.0
supernova:
luminosity_requested: 9.44 log_lsun
time_explosion: 13 day
atom_data: kurucz_cd23_chianti_H_He_latest.h5
model:
structure:
type: specific
velocity:
start: 1.1e4 km/s
stop: 20000 km/s
num: 20
density:
type: branch85_w7
abundances:
type: uniform
O: 0.19
Mg: 0.03
Si: 0.52
S: 0.19
Ar: 0.04
Ca: 0.03
plasma:
disable_electron_scattering: no
ionization: lte
excitation: lte
radiative_rates_type: dilute-blackbody
line_interaction_type: macroatom
montecarlo:
seed: 23111963
no_of_packets: 4.0e+4
iterations: 20
nthreads: 1
last_no_of_packets: 1.e+5
no_of_virtual_packets: 10
convergence_strategy:
type: adaptive_damped
threshold: 0.05
fraction: 0.8
hold_iterations: 3
stop_if_converged: no
spectrum:
start: 500 angstrom
stop: 20000 angstrom
num: 10000
Running the Simulation¶
To run the simulation, import the run_tardis function and create the sim_adaptive object.
[5]:
sim_adaptive = run_tardis("tardis_adaptive_damped_example.yml",
virtual_packet_logging=True,
show_convergence_plots=True,
export_convergence_plots=True,
log_level="INFO")
Embedding the final state for Jupyter environments
[ ]: