Run your first MESA HMS-HMS binary simulation with POSYDON

If you haven’t done it already, export all the relevan POSYDON and MESA enviroment variables.

Tip: create a file called .bash_posydon with the following content:

export PATH_TO_POSYDON=/srv/beegfs/scratch/shares/astro/posydon/simone/documentation/POSYDON/
export PATH_TO_POSYDON_DATA=/srv/beegfs/scratch/shares/astro/posydon/POSYDON_GRIDS_v2/POSYDON_data/230914/

export MESA_DIR=/srv/beegfs/scratch/shares/astro/posydon/software/mesa-r11701-posydon-v2-fiximplicit
export OMP_NUM_THREADS=4
export MESASDK_ROOT=/srv/beegfs/scratch/shares/astro/posydon/software/mesasdk-r11701
source $MESASDK_ROOT/bin/mesasdk_init.sh

so that every time you open a new terminal you can just run:

source .bash_posydon

If you haven’t done it already, please download the development branch of the POSYDON-MESA-INLISTS submodule. This is the branch that contains the simulation properties of all POSYDON MESA grids.

Creating the Initialization File for the POSYDON MESA Submission Script

From the submodule, you can now copy in your working directory the API ini file configuration of HMS-HMS binaries: $PATH_TO_POSYDON/grid_params/POSYDON-MESA-INLISTS/r11701/running_scripts/HMS-HMS_yggdrasil.ini.

For each grid we support two ini file configured to the Northwestern and UNIGE HPC clusters.

[5]:
import os
import shutil
from posydon.config import PATH_TO_POSYDON

path_to_ini = os.path.join(PATH_TO_POSYDON, "grid_params/POSYDON-MESA-INLISTS/r11701/running_scripts/HMS-HMS_yggdrasil.ini")
shutil.copyfile(path_to_ini, './HMS-HMS_yggdrasil.ini')
[5]:
'./HMS-HMS_yggdrasil.ini'

Open the file and edit the following parameters: - user=your_username - account=your_account - email=your_email - posydon_github_root=your_path_to_POSYDON

The scanrio parameter of the ini file is where the magic happens. This parameter let’s us decide which simulation we want to run. The syntax is the following: - the first argument is the name of the submodule posydon which points to the POSYDON-MESA-INLISTS submodule (other options are avaialble, e.g. user which points to a private submodule) - the second argument is the name of the branch and commit of the submodule we want to use connected by a dash -. In this case we want to use the development branch of the submodule and it’s latest commit, so we write development-c4f90ce2d93595f66751011d2002fc3ab3d090ec - the third argument is the name of the simulation grid we want to run, in this case we want to run a HMS-HMS grid. The name of the grid is HMS-HMS.

To summarize, you should have scenario = ['posydon', 'development-c4f90ce2d93595f66751011d2002fc3ab3d090ec', 'HMS-HMS']

The zams_file points to the ZAMS model used to generate the HMS stars in the binary system. POSYDON v2.0.0 supports 8 different metallicities, here we use the default value that points to the 0.1Zsun POSYDON MESA ZAMS model $PATH_TO_POSYDON/grid_params/POSYDON-MESA-INLISTS/r11701/ZAMS_models/zams_z1.42m3_y0.2511.data

The last parameter of this file is grid and points to the csv file containing the initial coditions of the grid. In this case we want to run a HMS-HMS grid consisting of one system, so we keep grid = grid_test.csv and generate such file specifying the metallicity, the two star masses and the initial orbital period.

Craeting the Initial Simulation Points CSV File

Note: a notebook showing you how all the grid points of v2.0.0 are generated is available in the POSYDON-MESA-INLISTS submodule at $PATH_TO_POSYDON/grid_params/POSYDON-MESA-INLISTS/r11701/running_scripts/parameter_space_v2/create_csv.ipynb

[7]:
import csv
import numpy as np
import pandas as pd

with open('./grid_test.csv', 'w', newline='') as file:
    writer = csv.writer(file)
    writer.writerow(['initial_z','Zbase','m1','m2','initial_period_in_days'])
    writer.writerow([0.00142, 0.00142, 30., 21., 10.])

You should now have the following files in your working directory:

[8]:
!ls
1_hms_hms.ipynb  grid_test.csv  HMS-HMS_yggdrasil.ini

Let’s now use the magic of POSYDON to set up the MESA simulation. In your termianal run

posydon-setup-grid --grid-type fixed --inifile HMS-HMS_yggdrasil.ini --submission-type slurm

The following files will be created:

[11]:
!ls
1_hms_hms.ipynb  grid_test.csv          mk                              star1
binary           HMS-HMS_yggdrasil.ini  slurm_job_array_grid_submit.sh  star2

Running the MESA Model and Exploring the Simulaiton Output

You are now ready to submit the simulation to the cluster with the following command:

[12]:
!sbatch slurm_job_array_grid_submit.sh
Submitted batch job 28453658
[15]:
!squeue -u bavera
             JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
      28453658_[0] private-a mesa_gri   bavera PD       0:00      1 (Priority)

After the job is finished, we can check the output files:

[1]:
!ls
1_hms_hms.ipynb
binary
grid_test.csv
HMS-HMS_yggdrasil.ini
mesa_grid.28453658_0.out
mk
slurm_job_array_grid_submit.sh
star1
star2
Zbase_0.0014_m1_30.0000_m2_21.0000_initial_z_1.4200e-03_initial_period_in_days_1.0000e+01_grid_index_0
[2]:
!ls Zbase_0.0014_m1_30.0000_m2_21.0000_initial_z_1.4200e-03_initial_period_in_days_1.0000e+01_grid_index_0
binary_history_columns.list  inlist_grid_points
binary_history.data          inlist_grid_star1_binary_controls
final_star1.mod              inlist_grid_star2_binary_controls
final_star2.mod              LOGS1
history_columns.list         LOGS2
initial_star1.mod            out.txt
initial_star2.mod            profile_columns.list
inlist                       tmp.hdf5
[4]:
!head -n 200 Zbase_0.0014_m1_30.0000_m2_21.0000_initial_z_1.4200e-03_initial_period_in_days_1.0000e+01_grid_index_0/out.txt


 read /srv/beegfs/scratch/shares/astro/posydon/simone/documentation/running_mesa/running_1_hms_hms/binary/inlist_project
 read inlist_grid_points
                                         version_number       11701
 read inlist_grid_star1_binary_controls
 set_eos_PC_parameters
                             mass_fraction_limit_for_PC    1.0000000000000000D-03
                                       logRho1_PC_limit    2.9990000000000001D+00
                                       logRho2_PC_limit    2.7999999999999998D+00
                                     log_Gamma_all_HELM    1.0000000000000000D+00
                                       log_Gamma_all_PC    1.3010299956000000D+00
                                 PC_Gamma_start_crystal    1.5000000000000000D+02
                                  PC_Gamma_full_crystal    1.7500000000000000D+02
                                               PC_min_Z    9.9900000000000000D-01
 change rates preference to           2
                                        set_initial_age    0.0000000000000000D+00
                               set_initial_model_number           0
 change to "approx21.net"
 number of species          21
 new_rotation_flag T
                                 new_surface_rotation_v           0    0.0000000000000000D+00    0.0000000000000000D+00
 net name approx21.net
 rotation_flag T
 species
     1   neut
     2   h1
     3   prot
     4   he3
     5   he4
     6   c12
     7   n14
     8   o16
     9   ne20
    10   mg24
    11   si28
    12   s32
    13   ar36
    14   ca40
    15   ti44
    16   cr48
    17   cr56
    18   fe52
    19   fe54
    20   fe56
    21   ni56

 kappa_file_prefix gs98
 kappa_lowT_prefix lowT_fa05_gs98
                                        OMP_NUM_THREADS           4




 read inlist_grid_star2_binary_controls
 set_eos_PC_parameters
                             mass_fraction_limit_for_PC    1.0000000000000000D-03
                                       logRho1_PC_limit    2.9990000000000001D+00
                                       logRho2_PC_limit    2.7999999999999998D+00
                                     log_Gamma_all_HELM    1.0000000000000000D+00
                                       log_Gamma_all_PC    1.3010299956000000D+00
                                 PC_Gamma_start_crystal    1.5000000000000000D+02
                                  PC_Gamma_full_crystal    1.7500000000000000D+02
                                               PC_min_Z    9.9900000000000000D-01
 change rates preference to           2
                                        set_initial_age    0.0000000000000000D+00
                               set_initial_model_number           0
 change to "approx21.net"
 number of species          21
 new_rotation_flag T
                                 new_surface_rotation_v           0    0.0000000000000000D+00    0.0000000000000000D+00
 net name approx21.net
 rotation_flag T
 species
     1   neut
     2   h1
     3   prot
     4   he3
     5   he4
     6   c12
     7   n14
     8   o16
     9   ne20
    10   mg24
    11   si28
    12   s32
    13   ar36
    14   ca40
    15   ti44
    16   cr48
    17   cr56
    18   fe52
    19   fe54
    20   fe56
    21   ni56

 kappa_file_prefix gs98
 kappa_lowT_prefix lowT_fa05_gs98
                                        OMP_NUM_THREADS           4





                                                     m2    2.1000000000000000D+01
                                                     m1    3.0000000000000000D+01
                                 initial_period_in_days    1.0000000000000000D+01
                             initial_separation_in_Rsun    7.2417496333000003D+01
                                        jdot_multiplier    1.0000000000000000D+00
                                                     fr    1.0000000000000000D-02



 The binary terminal output contains the following information

      'step' is the number of steps since the start of the run,
      'lg_dt' is log10 timestep in years,
      'age_yr' is the simulated years since the start run,
      'M1+M2' is the total mass of the system (Msun),
      'M1' is the mass of the primary (Msun)
      'M2' is the mass of the secondary (Msun)
      'separ' is the semi-major axis of the orbit (Rsun),
      'R1' is the radius of the primary (Rsun)
      'R2' is the radius of the secondary (Rsun)
      'Porb' is the orbital period (days),
      'P1' is the rotation period of star 1 (days, zero if not modeling rotation),
      'P2' is the rotation period of star 2 (days, zero if not modeling rotation),
      'e' orbital eccentricity,
      'dot_e' time derivative of e (1/yr),
      'Eorb' orbital energy G*M1*M2/2*separation (ergs),
      'M2/M1' mass ratio,
      'vorb1' orbital velocity of star 1 (km/s),
      'vorb2' orbital velocity of star 2 (km/s),
      'pm_i' index of star evolved as point mass, zero if both stars are modeled,
      'RL1' Roche lobe radius of star 1 (Rsun),
      'Rl2' Roche lobe radius of star 2 (Rsun),
      'donor_i' index of star taken as donor,
      'RL_gap1' (R1-Rl1)/Rl1,
      'RL_gap2' (R2-Rl2)/Rl2,
      'dot_Mmt', mass transfer rate (Msun/yr),
      'dot_M1', time derivative for the mass of star 1 (Msun/yr),
      'dot_M2', time derivative for the mass of star 2 (Msun/yr),
      'eff', mass transfer efficiency, computed as -dot_M2/dot_M1 (zero if dot_M1=0),
      'dot_Medd', Eddington accretion rate (Msun/yr),
      'L_acc', accretion luminosity when accreting to a point mass (ergs/s),
      'Jorb', orbital angular momentum (g*cm^2/s)
      'spin1', spin angular momentum of star 1 (g*cm^2/s),
      'spin2', spin angular momentum of star 2 (g*cm^2/s),
      'dot_J', time derivative of Jorb (g*cm^2/s^2),
      'dot_Jgr', time derivative of Jorb due to gravitational waves (g*cm^2/s^2),
      'dot_Jml', time derivative of Jorb due to mass loss (g*cm^2/s^2),
      'dot_Jmb', time derivative of Jorb due to magnetic braking (g*cm^2/s^2),
      'dot_Jls', time derivative of Jorb due to spin-orbit coupling (g*cm^2/s^2),
      'rlo_iters', number of iterations for implicit calculation of mass transfer,

 All this and more can be saved in binary_history.data during the run.
 num_steps_to_relax_rotation          50
        relax to omega: wanted-current, current, wanted           1    7.2722052166430393D-06    0.0000000000000000D+00    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted           2    7.1239371671217664D-06    1.4826804952127298D-07    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted           3    6.9775031537422630D-06    2.9470206290077610D-07    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted           4    6.8325228134160023D-06    4.3968240322703724D-07    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted           5    6.6880335934326623D-06    5.8417162321037739D-07    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted           6    6.5429720944820478D-06    7.2923312216099155D-07    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted           7    6.3960414376057951D-06    8.7616377903724423D-07    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted           8    6.2481185101766360D-06    1.0240867064664032D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted           9    6.0988144371784416D-06    1.1733907794645978D-06    7.2722052166430393D-06
         10   7.649681  4.541E+04   5.083637   5.083787  30.000000  30.000000   0.746765   0.000508   0.251100   0.747141  -6.159624   2598      0
   3.021836   0.768039   0.749893 -23.011309   3.935137 -99.000000   0.000000   0.251795   0.000441   0.001420   0.251427   0.009963      3      0
 2.3543E+03  16.667399   5.081908   1.622938   4.361599  -8.707435   0.000000   0.000004   0.000133   0.000071  1.432E-03  0.000E+00  max increase

        relax to omega: wanted-current, current, wanted          10    5.9494923842667907D-06    1.3227128323762491D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          11    5.8047902383525235D-06    1.4674149782905158D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          12    5.6656472219130140D-06    1.6065579947300258D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          13    5.5253850379006039D-06    1.7468201787424357D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          14    5.3813998139082310D-06    1.8908054027348084D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          15    5.2360332812183832D-06    2.0361719354246558D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          16    5.0905569484589031D-06    2.1816482681841367D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          17    4.9451036922867509D-06    2.3271015243562889D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          18    4.7996593421142631D-06    2.4725458745287766D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          19    4.6542152662843934D-06    2.6179899503586464D-06    7.2722052166430393D-06
         20   7.648797  4.525E+04   5.069089   5.069239  30.000000  30.000000   0.746765   0.000508   0.251100   0.747141  -6.164975   2613      0
   6.032136   0.764405   0.746596 -23.057888   3.920548 -99.000000   0.000000   0.251795   0.000441   0.001420   0.251427   0.009955      2      0
 2.1539E+06  16.663052   5.069239   1.607921   4.359365  -8.704639   0.000000   0.000004   0.000133   0.000071  1.432E-03  0.000E+00  max increase

        relax to omega: wanted-current, current, wanted          20    4.5087711728839026D-06    2.7634340437591372D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          21    4.3633267819036798D-06    2.9088784347393599D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          22    4.2178823225008446D-06    3.0543228941421948D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          23    4.0724377789053992D-06    3.1997674377376405D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          24    3.9269931252400189D-06    3.3452120914030209D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          25    3.7815483288686108D-06    3.4906568877744285D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          26    3.6361034654341649D-06    3.6361017512088744D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          27    3.4906587737615971D-06    3.7815464428814422D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          28    3.3452144110082463D-06    3.9269908056347930D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          29    3.1997702456217982D-06    4.0724349710212411D-06    7.2722052166430393D-06
         30   7.648797  4.525E+04   5.069078   5.069228  30.000000  30.000000   0.746765   0.000508   0.251100   0.747141  -6.164960   2610      0
   9.042435   0.764409   0.746606 -23.057923   3.920536 -99.000000   0.000000   0.251795   0.000441   0.001420   0.251427   0.009955      2      0
 2.2053E+09  16.663054   5.069228   1.607910   4.359335  -8.704658   0.000000   0.000004   0.000133   0.000071  1.432E-03  0.000E+00  max increase

        relax to omega: wanted-current, current, wanted          30    3.0543261335993711D-06    4.2178790830436683D-06    7.2722052166430393D-06
        relax to omega: wanted-current, current, wanted          31    2.9088820289801618D-06    4.3633231876628776D-06    7.2722052166430393D-06

Congratulation, you now know how to harvast the power of POSYDON to run a grid of simulations on a supercomputer!