{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# How to use Adaptive Damping for Convergence in TARDIS" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This notebook demonstrates how to run the TARDIS example configuration with\n", "the existing `damped` convergence strategy and the new `adaptive_damped`\n", "strategy, and illustrates their convergence behavior across iterations." ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Damped Convergence Strategy\n", "\n", "This example uses the standard TARDIS damped convergence strategy specified in the configuration file `tardis_example.yml` with the\n", "damping constant set to 0.5 (or another user-specified value between 0.1 and 1.0)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!cat tardis_example.yml" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Running the Simulation\n", "\n", "To run the simulation, import the `run_tardis` function and create the `sim_damped` object. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from tardis import run_tardis" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim_damped = run_tardis(\"tardis_example.yml\", \n", " virtual_packet_logging=True,\n", " show_convergence_plots=True,\n", " export_convergence_plots=True,\n", " log_level=\"INFO\") " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Adaptive Damped Convergence Strategy\n", "\n", "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." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!cat tardis_adaptive_damped_example.yml" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Running the Simulation\n", "\n", "To run the simulation, import the `run_tardis` function and create the `sim_adaptive` object. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim_adaptive = run_tardis(\"tardis_adaptive_damped_example.yml\", \n", " virtual_packet_logging=True,\n", " show_convergence_plots=True,\n", " export_convergence_plots=True,\n", " log_level=\"INFO\") " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "tardis-dev", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.3" } }, "nbformat": 4, "nbformat_minor": 4 }