Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V inner boundary solver workflow #2797

Closed
wants to merge 91 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
a7175bf
Basic skeleton
andrewfullard Jul 23, 2024
032f34b
Lots of progress
andrewfullard Jul 23, 2024
b6628fc
Adds setup method, refactors some functions, removes unused items
andrewfullard Jul 23, 2024
1a67aba
Move convergence setup to setup method
andrewfullard Jul 23, 2024
5008b80
Add docs notebook, fix a couple of errors
andrewfullard Jul 23, 2024
a95d547
Move setup to init
andrewfullard Jul 23, 2024
d5f65cb
Fix iteration and convergence
andrewfullard Jul 23, 2024
5a3c94e
Simplify spectrumsolver init
andrewfullard Jul 23, 2024
4df9c41
Separate plasma "solver" and simulation state updates
andrewfullard Jul 23, 2024
2d253c7
Simplify convergence solver setup with a dict.
andrewfullard Jul 23, 2024
372b44b
Minor formatting change
andrewfullard Jul 23, 2024
24943f4
Minor refactoring
andrewfullard Jul 24, 2024
6372d5b
Merge branch 'master' into simulation-solver-workflow
andrewfullard Jul 29, 2024
5a1e45f
Fixes plasma update step
andrewfullard Jul 29, 2024
2dbeb69
Merge branch 'master' into simulation-solver-workflow
andrewfullard Aug 12, 2024
6a457f4
Fixes loggers and progress bars
andrewfullard Aug 12, 2024
cf49518
Fixes convergence plot rendering
andrewfullard Aug 12, 2024
85403c5
Fixes convergence plots in the final iteration
andrewfullard Aug 12, 2024
858ab1d
black
andrewfullard Aug 12, 2024
9b10be6
Simplify convergence plot updating
andrewfullard Aug 12, 2024
a521c10
Move logging handling to a separate class
andrewfullard Aug 12, 2024
8f4955e
Add HDF output capability to solver
andrewfullard Aug 12, 2024
b02390d
Move more basic logging back into workflow
andrewfullard Aug 12, 2024
426459a
Add not-converged error message
andrewfullard Aug 12, 2024
8d45b7d
Update notebook with export option
andrewfullard Aug 12, 2024
0353589
Added simple base workflow and changed some verbiage
andrewfullard Aug 13, 2024
3a24f98
Fix typo
andrewfullard Aug 13, 2024
cd9cd64
Merge branch 'simulation-solver-workflow' of https://github.com/andre…
Rodot- Aug 14, 2024
8caaf6e
Moved solver workflow over to updated branch
Rodot- Aug 14, 2024
82ffb83
Added reprojection method for comparing arrays between iterations
Rodot- Aug 14, 2024
4d3c747
Updated schema and parser to add v_inner_boundary, added property to …
Rodot- Aug 14, 2024
16042ce
Added ntoebook for the IBVS workflow
Rodot- Aug 14, 2024
545f751
Updated workflow notebook to have correct convergence information, up…
Rodot- Aug 14, 2024
54a5d83
Reduced size of overloaded functions to make them more in-line with t…
Rodot- Aug 14, 2024
3d022a2
cleared notebook outputs
Rodot- Aug 14, 2024
af0430a
Updated notebook to use correctmethod
Rodot- Aug 14, 2024
fb9a49b
Updated the docstrings
Rodot- Aug 14, 2024
5aded66
removed unused imports
Rodot- Aug 14, 2024
4ce4ab9
Updated notebook to stop if converged
Rodot- Aug 14, 2024
8ae6158
Updated v_inner_solver to deal with detailed radiative rates types
Rodot- Aug 14, 2024
ba5696c
removed old comment
Rodot- Aug 14, 2024
b1570db
Added docstrings, removed old comments
Rodot- Aug 14, 2024
398f39f
Fixed typo
Rodot- Aug 14, 2024
75c9e9b
Updated notebook to be more explicit
Rodot- Aug 14, 2024
5cf5b45
removed old comment
Rodot- Aug 14, 2024
004d32d
removed unused variable
Rodot- Aug 14, 2024
31a96d5
Changed the radiation_field to use the radiation field state properti…
Rodot- Aug 14, 2024
ca34743
Added back radaition field to plasma solver in v_inner solver
Rodot- Aug 14, 2024
d336379
Added a solve opacity method
Rodot- Aug 14, 2024
a73eee6
Added docstring to solve_opacity method
Rodot- Aug 14, 2024
783ecae
Fixed initializing opacity at the last iteration
Rodot- Aug 14, 2024
9ebb6f2
Added initial v_inner estimate in the __init__
Rodot- Aug 14, 2024
f7e9748
massively simplified the reproject method by just doing basic math
Rodot- Aug 14, 2024
e79c821
added docstring describing the simplified reproject method so I don't…
Rodot- Aug 14, 2024
5627d73
Formatting error in doscstring
Rodot- Aug 14, 2024
a3178ad
Added nice logger output showing changes in geometry state
Rodot- Aug 14, 2024
bc17364
Cleaned up the notebook a bit
Rodot- Aug 14, 2024
a7f778d
Fixed the standard simulation solver
Rodot- Aug 15, 2024
379b84f
Updated the kernels in the workflows notebooks
Rodot- Aug 15, 2024
23cb26e
Once again updating the notebook kernels
Rodot- Aug 15, 2024
63a22b1
Merge branch 'master' of github.com:tardis-sn/tardis into v_inner_sol…
Rodot- Aug 15, 2024
bf4fca1
Basic skeleton
andrewfullard Jul 23, 2024
73f55a4
Lots of progress
andrewfullard Jul 23, 2024
ffbc45e
Adds setup method, refactors some functions, removes unused items
andrewfullard Jul 23, 2024
e85a6c9
Move convergence setup to setup method
andrewfullard Jul 23, 2024
76ae414
Add docs notebook, fix a couple of errors
andrewfullard Jul 23, 2024
1bb1d47
Move setup to init
andrewfullard Jul 23, 2024
516fa65
Fix iteration and convergence
andrewfullard Jul 23, 2024
550f4e7
Simplify spectrumsolver init
andrewfullard Jul 23, 2024
afca806
Separate plasma "solver" and simulation state updates
andrewfullard Jul 23, 2024
3a47c9f
Simplify convergence solver setup with a dict.
andrewfullard Jul 23, 2024
83dd33a
Minor formatting change
andrewfullard Jul 23, 2024
bf127de
Minor refactoring
andrewfullard Jul 24, 2024
6b11f0b
Fixes plasma update step
andrewfullard Jul 29, 2024
6f705bf
Fixes loggers and progress bars
andrewfullard Aug 12, 2024
0f369af
Fixes convergence plot rendering
andrewfullard Aug 12, 2024
01e5cc3
Fixes convergence plots in the final iteration
andrewfullard Aug 12, 2024
2351c8b
black
andrewfullard Aug 12, 2024
692e3b9
Simplify convergence plot updating
andrewfullard Aug 12, 2024
dfca04e
Move logging handling to a separate class
andrewfullard Aug 12, 2024
b67f6cb
Add HDF output capability to solver
andrewfullard Aug 12, 2024
f9f31d4
Move more basic logging back into workflow
andrewfullard Aug 12, 2024
4de0e1f
Add not-converged error message
andrewfullard Aug 12, 2024
94f749b
Update notebook with export option
andrewfullard Aug 12, 2024
c2a636a
Added simple base workflow and changed some verbiage
andrewfullard Aug 13, 2024
011c415
Fix typo
andrewfullard Aug 13, 2024
a68ebaa
Black format
andrewfullard Aug 15, 2024
9634be0
Merge branch 'simulation-solver-workflow' of https://github.com/andre…
Rodot- Aug 15, 2024
e4eeee5
Ran black on the files I made tiny changes to to satisfy our benevole…
Rodot- Aug 15, 2024
e36ccd5
Fixes spectrum solver test
andrewfullard Aug 15, 2024
a301095
Merge branch 'simulation-solver-workflow' of https://github.com/andre…
Rodot- Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions docs/workflows/simple_workflow.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from tardis.workflows.simple_simulation import SimpleSimulation\n",
"from tardis.io.configuration.config_reader import Configuration"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"config = Configuration.from_yaml('../tardis_example.yml')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"workflow = SimpleSimulation(config)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"workflow.run()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"spectrum = workflow.spectrum_solver.spectrum_real_packets\n",
"spectrum_virtual = workflow.spectrum_solver.spectrum_virtual_packets\n",
"spectrum_integrated = workflow.spectrum_solver.spectrum_integrated"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"plt.figure(figsize=(10, 6.5))\n",
"\n",
"spectrum.plot(label=\"Normal packets\")\n",
"spectrum_virtual.plot(label=\"Virtual packets\")\n",
"spectrum_integrated.plot(label='Formal integral')\n",
"\n",
"plt.xlim(500, 9000)\n",
"plt.title(\"TARDIS example model spectrum\")\n",
"plt.xlabel(\"Wavelength [$\\AA$]\")\n",
"plt.ylabel(\"Luminosity density [erg/s/$\\AA$]\")\n",
"plt.legend()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "tardis",
"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.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
110 changes: 110 additions & 0 deletions docs/workflows/standard_workflow.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from tardis.workflows.standard_simulation import StandardSimulation\n",
"from tardis.io.configuration.config_reader import Configuration"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"config = Configuration.from_yaml('../tardis_example.yml')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"workflow = StandardSimulation(config, show_convergence_plots=True,show_progress_bars=True,convergence_plots_kwargs={\"export_convergence_plots\":True})"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"workflow.run()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"spectrum = workflow.spectrum_solver.spectrum_real_packets\n",
"spectrum_virtual = workflow.spectrum_solver.spectrum_virtual_packets\n",
"spectrum_integrated = workflow.spectrum_solver.spectrum_integrated"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"plt.figure(figsize=(10, 6.5))\n",
"\n",
"spectrum.plot(label=\"Normal packets\")\n",
"spectrum_virtual.plot(label=\"Virtual packets\")\n",
"spectrum_integrated.plot(label='Formal integral')\n",
"\n",
"plt.xlim(500, 9000)\n",
"plt.title(\"TARDIS example model spectrum\")\n",
"plt.xlabel(\"Wavelength [$\\AA$]\")\n",
"plt.ylabel(\"Luminosity density [erg/s/$\\AA$]\")\n",
"plt.legend()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "tardis",
"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.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
129 changes: 129 additions & 0 deletions docs/workflows/v_inner_solver_workflow.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from tardis.workflows.v_inner_solver import InnerVelocitySimulationSolver\n",
"from tardis.io.configuration.config_reader import Configuration"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"config = Configuration.from_yaml('../tardis_example.yml')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"from astropy import units as u\n",
"\n",
"config.montecarlo.convergence_strategy['v_inner_boundary'] = {\n",
" 'damping_constant' : 0.5,\n",
" 'threshold' : 0.01,\n",
" 'type' : 'damped'\n",
" }\n",
"\n",
"config.montecarlo.convergence_strategy.stop_if_converged = True\n",
"config.model.structure.velocity.start = 5000 * u.km/u.s # Larger window over which to search\n",
"config.model.structure.velocity.num = 50 # Increase number of shells\n",
"\n",
"workflow = InnerVelocitySimulationSolver(\n",
" config, tau=2.0/3, \n",
" mean_optical_depth=\"rossland\"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"workflow.run()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"spectrum = workflow.spectrum_solver.spectrum_real_packets\n",
"spectrum_virtual = workflow.spectrum_solver.spectrum_virtual_packets\n",
"#spectrum_integrated = workflow.spectrum_solver.spectrum_integrated"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%debug"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"plt.figure(figsize=(10, 6.5))\n",
"\n",
"spectrum.plot(label=\"Normal packets\")\n",
"spectrum_virtual.plot(label=\"Virtual packets\")\n",
"#spectrum_integrated.plot(label=\"Integrated Spectrum\")\n",
"\n",
"plt.xlim(500, 9000)\n",
"plt.title(\"TARDIS example model spectrum\")\n",
"plt.xlabel(r\"Wavelength [$\\AA$]\")\n",
"plt.ylabel(r\"Luminosity density [erg/s/$\\AA$]\")\n",
"plt.legend()\n",
"plt.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.11.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
7 changes: 6 additions & 1 deletion tardis/io/configuration/config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,12 @@ def parse_convergence_section(convergence_section_dict):
"""
convergence_parameters = ["damping_constant", "threshold", "type"]

for convergence_variable in ["t_inner", "t_rad", "w"]:
for convergence_variable in [
"t_inner",
"t_rad",
"w",
"v_inner_boundary",
]:
if convergence_variable not in convergence_section_dict:
convergence_section_dict[convergence_variable] = {}
convergence_variable_section = convergence_section_dict[
Expand Down
18 changes: 18 additions & 0 deletions tardis/io/configuration/schemas/montecarlo_definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ definitions:
type: string
default: 'damped'
description: THIS IS A DUMMY VARIABLE DO NOT USE
v_inner_boundary:
type: object
additionalProperties: false
properties:
damping_constant:
type: number
default: 0.0
description: damping constant
minimum: 0
threshold:
type: number
description: specifies the threshold that is taken as convergence (i.e.
0.05 means that the value does not change more than 5%)
minimum: 0
type:
type: string
default: 'damped'
description: THIS IS A DUMMY VARIABLE DO NOT USE
t_rad:
type: object
additionalProperties: false
Expand Down
Loading
Loading