-
-
Notifications
You must be signed in to change notification settings - Fork 421
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Basic skeleton * Lots of progress Solvers pass info to each other Simplified some parts * Adds setup method, refactors some functions, removes unused items * Move convergence setup to setup method * Add docs notebook, fix a couple of errors * Move setup to init * Fix iteration and convergence * Simplify spectrumsolver init * Separate plasma "solver" and simulation state updates * Simplify convergence solver setup with a dict. * Minor formatting change * Minor refactoring * Fixes plasma update step * Fixes loggers and progress bars Also adds docstrings to methods. Updates some methods to use new functionality of the plasma. Adds requirements for the convergence plots (still broken) * Fixes convergence plot rendering * Fixes convergence plots in the final iteration * black * Simplify convergence plot updating * Move logging handling to a separate class * Add HDF output capability to solver * Move more basic logging back into workflow * Add not-converged error message * Update notebook with export option * Added simple base workflow and changed some verbiage * Fix typo * Moved solver workflow over to updated branch * Added reprojection method for comparing arrays between iterations * Updated schema and parser to add v_inner_boundary, added property to the model because it is named weirdly * Added ntoebook for the IBVS workflow * Updated workflow notebook to have correct convergence information, updated simple solver to properly set up the plasma with the new assembly * Reduced size of overloaded functions to make them more in-line with the simple solver, updated simple solver to handle current tardis master branch * cleared notebook outputs * Updated notebook to use correctmethod * Updated the docstrings * removed unused imports * Updated notebook to stop if converged * Updated v_inner_solver to deal with detailed radiative rates types * removed old comment * Added docstrings, removed old comments * Fixed typo * Updated notebook to be more explicit * removed old comment * removed unused variable * Changed the radiation_field to use the radiation field state properties with no explicit sovler method * Added back radaition field to plasma solver in v_inner solver * Added a solve opacity method * Added docstring to solve_opacity method * Fixed initializing opacity at the last iteration * Added initial v_inner estimate in the __init__ * massively simplified the reproject method by just doing basic math * added docstring describing the simplified reproject method so I don't forget why it works later * Formatting error in doscstring * Added nice logger output showing changes in geometry state * Cleaned up the notebook a bit * Updated the formal integral to handle changes in geometry * Fixed the standard simulation solver * Remove old files * Fixes v_inner workflow * Minor formatting changes * Clean up confusing v_boundary_inner vs v_inner_boundary variable names --------- Co-authored-by: Andrew Fullard <[email protected]>
- Loading branch information
1 parent
0a0ecbf
commit 5e2d0bb
Showing
10 changed files
with
655 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from tardis.workflows.v_inner_solver import InnerVelocitySolverWorkflow\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": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"This code modifies the TARDIS example configuration to include convergence information for the inner boundary velocity solver.\n", | ||
"Note that the number of shells is increased and the starting velocity is reduced to provide more granularity and a wider search window, respectively." | ||
] | ||
}, | ||
{ | ||
"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 = InnerVelocitySolverWorkflow(\n", | ||
" config, tau=2.0/3,\n", | ||
" mean_optical_depth=\"rosseland\"\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": [ | ||
"%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(r\"Wavelength [$\\AA$]\")\n", | ||
"plt.ylabel(r\"Luminosity density [erg/s/$\\AA$]\")\n", | ||
"plt.legend()\n", | ||
"plt.show()" | ||
] | ||
} | ||
], | ||
"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.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.