{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Running Single Stars with POSYDON " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Single stars, hydrogen or helium main sequence stars (HMS; HeMS), can be run with POSYDON specifying the `single_star_grid = True` option in the `ini` file. This function takes care of setting up the MESA simulation to run a single star instead of a binary star system." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Creating the Initialization File" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can get the template to run a 0.1Zsun HMS star by running the following code cell. Do not forget to fill up the header of the `ini` file with the appropriate information corresponding to your HPC account. In this example we will run the following MESA inlist branch and commit\n", "```ini\n", "scenario = ['posydon', 'development-c4f90ce2d93595f66751011d2002fc3ab3d090ec', 'HMS-HMS']\n", "```" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'./single_HMS_yggdrasil.ini'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import os\n", "import shutil\n", "from posydon.config import PATH_TO_POSYDON\n", "\n", "path_to_ini = os.path.join(PATH_TO_POSYDON, \"grid_params/POSYDON-MESA-INLISTS/r11701/running_scripts/single_HMS_yggdrasil.ini\")\n", "shutil.copyfile(path_to_ini, './single_HMS_yggdrasil.ini')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Creating the Initial Simulation Points CSV File " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We now need to generate the `grid.csv` containing 10 initial values for 10 stars, in this case the initial values are just the mass and metallicity paramters. You can do this by running the following code cell. The code that follows was copied from `$PATH_TO_POSYDON/grid_params/POSYDON-MESA-INLISTS/r11701/running_scripts/parameter_space_v2/create_csv.ipynb`." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import os\n", "import csv\n", "import numpy as np\n", "import pandas as pd\n", "\n", "def log_range(x_min,x_max,x_n):\n", " return 10**np.linspace(np.log10(x_min),np.log10(x_max), x_n)\n", "\n", "# digit rounding pick 10 to be sure we resolve 10^-4Zsun\n", "NDIG = 10\n", "\n", "Zsun = 0.0142\n", "m1_min = 5.\n", "m1_max = 100.\n", "m1_n = 10\n", "m1 = log_range(m1_min,m1_max,m1_n)\n", "met = [0.1*Zsun]\n", "\n", "for Z in met:\n", " with open('./grid.csv', 'w', newline='') as file:\n", " writer = csv.writer(file)\n", " writer.writerow(['initial_z','Zbase','initial_mass'])\n", " for i in range(m1_n):\n", " writer.writerow([round(Z,NDIG),round(Z,NDIG),round(m1[i],NDIG)])" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "initial_z,Zbase,initial_mass\n", "0.00142,0.00142,5.0\n", "0.00142,0.00142,6.9747539698\n", "0.00142,0.00142,9.7294385879\n", "0.00142,0.00142,13.572088083\n", "0.00142,0.00142,18.9323950471\n", "0.00142,0.00142,26.4097595025\n", "0.00142,0.00142,36.8403149864\n", "0.00142,0.00142,51.3904266401\n", "0.00142,0.00142,71.6871164437\n", "0.00142,0.00142,100.0\n" ] } ], "source": [ "!head -n 12 ./grid.csv" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Runing the MESA Grid with the POSYDON Submission Script" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We are now ready to run the simulation, with the following commands:\n", "\n", "```bash\n", "posydon-setup-grid --grid-type fixed --inifile single_HMS_yggdrasil.ini --submission-type slurm\n", "sbatch slurm_job_array_grid_submit.sh\n", "```\n", "\n", "Sit back relax, and wait for the grid to finish. Check out the advanced tutorial on how to generate the PSyGrid object for single stars." ] } ], "metadata": { "kernelspec": { "display_name": "posydon_env", "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" } }, "nbformat": 4, "nbformat_minor": 2 }