Skip to content

Commit

Permalink
mesa model and parallel tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenmonk committed Apr 11, 2024
1 parent a5343d9 commit 3de3604
Show file tree
Hide file tree
Showing 8 changed files with 1,482 additions and 0 deletions.
50 changes: 50 additions & 0 deletions docs/Tutorials/Mesa_model.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Using a MESA model"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Using a MESA model entails a few changes in the utilization of STARDIS. Firstly, you must change the model type to 'mesa' under the 'model' section, like this: \n",
"\n",
"```\n",
"model:\n",
" type: mesa\n",
" fname: end_core_h_burn.mod\n",
"```\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Next, you can now specify the outmost depth point for the simulation using the 'truncate_to_shell' parameter. It defaults to -99, which tells the model to use all shells. Place the parameter in the 'model' section, like this: \n",
"```\n",
"model:\n",
" type: mesa\n",
" fname: end_core_h_burn.mod\n",
" truncate_to_shell: 40\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
"language_info": {
"name": "python"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
114 changes: 114 additions & 0 deletions docs/Tutorials/Running_in_Parallel.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Running the Simulation in Parallel"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can change the number of threads that STARDIS uses with the n_threads keyword. \n",
"A few things to remember when running STARDIS in parallel: \n",
" \n",
"If no n_threads argument is provided, it defaults to 1 and runs in series. \n",
" \n",
"Set n_threads to 0 to use all available threads. \n",
" \n",
"The n_threads argument must be between the config version and the atom data, like this: \n",
"```\n",
"stardis_config_version: 1.0 \n",
"n_threads: 4 \n",
"atom_data: kurucz_cd23_chianti_H_He.h5\n",
"```\n",
"\n",
"In the [stardis_config_parallel](stardis_config_parallel.yml) file, an n_threads value of 4 is added to the example config. Try running this code yourself to see how n_threads affects STARDIS's efficiency."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "25723fa78e8d43ef8129a7667a39ebf8",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Iterations: 0/? [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "86699bb231414753bfb51786d4a12b7f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Packets: 0/? [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Atomic Data kurucz_cd23_chianti_H_He already exists in /home/monkhayd/Downloads/tardis-data/kurucz_cd23_chianti_H_He.h5. Will not download - override with force_download=True.\n",
"WARNING: UnitsWarning: 'erg/cm2/s' contains multiple slashes, which is discouraged by the FITS standard [astropy.units.format.generic]\n",
"WARNING:astropy:UnitsWarning: 'erg/cm2/s' contains multiple slashes, which is discouraged by the FITS standard\n",
"/home/monkhayd/Software/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide\n",
" (g_lower * n_upper) / (g_upper * n_lower)\n",
"/home/monkhayd/Software/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide\n",
" (g_lower * n_upper) / (g_upper * n_lower)\n"
]
}
],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from tardis.io.atom_data.util import download_atom_data\n",
"from stardis.base import run_stardis\n",
"from astropy import units as u, constants as const\n",
"\n",
"download_atom_data('kurucz_cd23_chianti_H_He')\n",
"tracing_lambdas = np.mgrid[6540:6590:.01]* u.Angstrom\n",
"\n",
"sim = run_stardis('Tutorial_data/stardis_config_parallel.yml', tracing_lambdas)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.5"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit 3de3604

Please sign in to comment.