From 30d6e281b14926452c846fb26d40286849b4a060 Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Tue, 17 Feb 2026 15:32:51 -0500 Subject: [PATCH 01/16] remove testflag from mlwind.f --- src/cosmic/src/mlwind.f | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/cosmic/src/mlwind.f b/src/cosmic/src/mlwind.f index 0a7b4fe0..502d3057 100644 --- a/src/cosmic/src/mlwind.f +++ b/src/cosmic/src/mlwind.f @@ -2,7 +2,7 @@ real*8 FUNCTION mlwind(kw,lum,r,mt,mc,rl,z) IMPLICIT NONE INCLUDE 'const_bse.h' - integer kw,testflag + integer kw real*8 lum,r,mt,mc,rl,z,teff,alpha real*8 dml,dms,dmt,p0,x,mew,lum0,kap real*8 MLalpha @@ -146,7 +146,6 @@ real*8 FUNCTION mlwind(kw,lum,r,mt,mc,rl,z) dms = 9.6d-15*x*(r**0.81d0)*(lum**1.24d0)*(mt**0.16d0) alpha = 0.5d0 dms = dms*(z/zsun)**(alpha) - testflag = 1 endif if(kw.ge.2.and.kw.le.6)then * 'Reimers' mass loss @@ -175,7 +174,6 @@ real*8 FUNCTION mlwind(kw,lum,r,mt,mc,rl,z) & 1.339d0*LOG10(mt/30.d0) - 1.601d0*LOG10(1.3d0/2.d0) + & alpha*LOG10(z/zsun) + 1.07d0*LOG10(teff/2.0d+04) dms = 10.d0**dms - testflag = 2 elseif(teff.gt.25000.)then * Although Vink et al. formulae are only defined until Teff=50000K, * we follow the Dutch prescription of MESA, and extend to higher Teff @@ -184,7 +182,6 @@ real*8 FUNCTION mlwind(kw,lum,r,mt,mc,rl,z) & alpha*LOG10(z/zsun) +0.933d0*LOG10(teff/4.0d+04) - & 10.92d0*(LOG10(teff/4.0d+04)**2) dms = 10.d0**dms - testflag = 2 endif if((windflag.eq.3.or.kw.ge.2).and.kw.le.6)then @@ -196,7 +193,6 @@ real*8 FUNCTION mlwind(kw,lum,r,mt,mc,rl,z) if(eddlimflag.eq.0) alpha = 0.d0 if(eddlimflag.eq.1) alpha = MLalpha(mt,lum,kw) dms = 1.5d0*1.0d-04*((z/zsun)**alpha) - testflag = 3 endif elseif(kw.ge.7.and.kw.le.9)then !WR (naked helium stars) * If naked helium use Hamann & Koesterke (1998) WR winds reduced by factor of @@ -204,7 +200,6 @@ real*8 FUNCTION mlwind(kw,lum,r,mt,mc,rl,z) if(eddlimflag.eq.0) alpha = 0.86d0 if(eddlimflag.eq.1) alpha = MLalpha(mt,lum,kw) dms = 1.0d-13*(lum**1.5d0)*((z/zsun)**alpha) - testflag = 4 endif * mlwind = dms From fa3a314b198ad7bd9ed85354ec002b31083c2e4d Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Tue, 17 Feb 2026 15:48:54 -0500 Subject: [PATCH 02/16] add LBV_winds function --- src/cosmic/src/mlwind.f | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/cosmic/src/mlwind.f b/src/cosmic/src/mlwind.f index 502d3057..6896b947 100644 --- a/src/cosmic/src/mlwind.f +++ b/src/cosmic/src/mlwind.f @@ -243,3 +243,41 @@ real*8 FUNCTION mlwind(kw,lum,r,mt,mc,rl,z) return end *** + + + real*8 FUNCTION LBV_winds(lum,r,mt,kw,z) +* Calculate mass loss from LBV-like winds + IMPLICIT NONE + INCLUDE 'const_bse.h' + real*8 lum,r,mt,z,alpha,x + integer kw + real*8 MLalpha + external MLalpha + + x = 1.0d-5*r*sqrt(lum) + alpha = 0.d0 + + ! if the star is beyond the Humphreys-Davidson limit, apply LBVs + if(lum.gt.6.0d+05.and.x.gt.1.d0.and.LBV_flag.ne.0)then + if(LBV_flag.eq.1)then + ! use Hurley+2000 LBV-like mass loss (Section 7.1, equation is unnumbered oof) + LBV_winds = 0.1d0*(x-1.d0)**3*(lum/6.0d+05-1.d0) + elseif(LBV_flag.eq.2)then + ! use StarTrack (Belczynski+08) LBV-like mass loss + ! adjust metallicity dependence near eddington limit if eddlimflag is set + if(eddlimflag.eq.1) alpha = MLalpha(mt,lum,kw) + + ! use constant LBV-like mass loss + LBV_winds = 1.5d0*1.0d-04*((z/zsun)**alpha) + else + ! this should never happen, throw error + write(*,*) "Error: LBV_flag must be 0, 1, or 2. Exiting." + stop + endif + else + ! otherwise no mass loss + LBV_winds = 0.d0 + endif + + return + end From 4b1fc08ad4c3022d8c8da70400a56630d763c8d2 Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Tue, 17 Feb 2026 16:14:43 -0500 Subject: [PATCH 03/16] use LBV function throughout --- src/cosmic/src/mlwind.f | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/src/cosmic/src/mlwind.f b/src/cosmic/src/mlwind.f index 6896b947..cee3511c 100644 --- a/src/cosmic/src/mlwind.f +++ b/src/cosmic/src/mlwind.f @@ -5,8 +5,8 @@ real*8 FUNCTION mlwind(kw,lum,r,mt,mc,rl,z) integer kw real*8 lum,r,mt,mc,rl,z,teff,alpha real*8 dml,dms,dmt,p0,x,mew,lum0,kap - real*8 MLalpha - external MLalpha + real*8 MLalpha,LBV_winds + external MLalpha,LBV_winds parameter(lum0=7.0d+04,kap=-0.5d0) * * windflag = 0 !BSE=0, startrack08=1, vink=2, vink+LBV for all @@ -56,11 +56,7 @@ real*8 FUNCTION mlwind(kw,lum,r,mt,mc,rl,z) dms = MAX(dml,dms) endif * LBV-like mass loss beyond the Humphreys-Davidson limit. - x = 1.0d-5*r*sqrt(lum) - if(lum.gt.6.0d+05.and.x.gt.1.d0)then - dml = 0.1d0*(x-1.d0)**3*(lum/6.0d+05-1.d0) - dms = dms + dml - endif + dms = dms + LBV_winds(lum,r,mt,kw,z) endif endif * @@ -115,11 +111,7 @@ real*8 FUNCTION mlwind(kw,lum,r,mt,mc,rl,z) dms = MAX(dml,dms) endif * LBV-like mass loss beyond the Humphreys-Davidson limit. - x = 1.0d-5*r*sqrt(lum) - if(lum.gt.6.0d+05.and.x.gt.1.d0)then - dml = 0.1d0*(x-1.d0)**3*(lum/6.0d+05-1.d0) - dms = dms + dml - endif + dms = dms + LBV_winds(lum,r,mt,kw,z) endif endif * @@ -188,12 +180,10 @@ real*8 FUNCTION mlwind(kw,lum,r,mt,mc,rl,z) * LBV-like mass loss beyond the Humphreys-Davidson limit. * Optional flag (windflag=3) to use for every non-degenerate star * past the limit, rather than just for giant, evolved stars - x = 1.0d-5*r*sqrt(lum) - if(lum.gt.6.0d+05.and.x.gt.1.d0)then - if(eddlimflag.eq.0) alpha = 0.d0 - if(eddlimflag.eq.1) alpha = MLalpha(mt,lum,kw) - dms = 1.5d0*1.0d-04*((z/zsun)**alpha) - endif + +* TW: Note this is overwrite the other mass loss, might want a sum here +* not assignment, but leaving it consistent for now + dms = LBV_winds(lum,r,mt,kw,z) elseif(kw.ge.7.and.kw.le.9)then !WR (naked helium stars) * If naked helium use Hamann & Koesterke (1998) WR winds reduced by factor of * 10 (Yoon & Langer 2005), with Vink & de Koter (2005) metallicity dependence @@ -228,11 +218,7 @@ real*8 FUNCTION mlwind(kw,lum,r,mt,mc,rl,z) dms = MAX(dml,dms) endif * LBV-like mass loss beyond the Humphreys-Davidson limit. - x = 1.0d-5*r*sqrt(lum) - if(lum.gt.6.0d+05.and.x.gt.1.d0)then - dml = 0.1d0*(x-1.d0)**3*(lum/6.0d+05-1.d0) - dms = dms + dml - endif + dms = dms + LBV_winds(lum,r,mt,kw,z) endif endif * From 5f8b0e229b828c10cb60a999ad7ceb505ce3420f Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Tue, 17 Feb 2026 16:23:39 -0500 Subject: [PATCH 04/16] add LBV_flag setting --- src/cosmic/data/cosmic-settings.json | 21 ++++++++++++++++++ src/cosmic/evolve.py | 3 ++- src/cosmic/src/const_bse.h | 3 ++- src/cosmic/tests/data/Params.ini | 2 ++ .../data/initial_conditions_for_testing.hdf5 | Bin 15337 -> 15380 bytes .../tests/data/kick_initial_conditions.h5 | Bin 13088 -> 13128 bytes 6 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/cosmic/data/cosmic-settings.json b/src/cosmic/data/cosmic-settings.json index 4ca0eec6..c8487a6d 100644 --- a/src/cosmic/data/cosmic-settings.json +++ b/src/cosmic/data/cosmic-settings.json @@ -688,6 +688,27 @@ } ] }, + { + "name": "LBV_flag", + "description": "Selects the model for Luminous Blue Variable (LBV) mass loss", + "type": "dropdown", + "options-preface": "", + "options": [ + { + "name": 0, + "description": "No LBV mass loss" + }, + { + "name": 1, + "description": "LBV mass loss following Hurley+2000", + "default": true + }, + { + "name": 2, + "description": "LBV mass loss following Belczynski+2008" + } + ] + }, { "settings-section": "Common-envelope", "settings-section-description": "Note: there are cases where a common envelope is forced regardless of the critical mass ratio for unstable mass transfer. In the following cases, a common envelope occurs regardless of the choices below:
  • contact: the stellar radii go into contact (common for similar ZAMS systems)
  • periapse contact: the periapse distance is smaller than either of the stellar radii (common for highly eccentric systems)
  • core Roche overflow: either of the stellar radii overflow their component's Roche radius (in this case, mass transfer from the convective core is always dynamically unstable)
", diff --git a/src/cosmic/evolve.py b/src/cosmic/evolve.py index ccf7e780..53956251 100644 --- a/src/cosmic/evolve.py +++ b/src/cosmic/evolve.py @@ -107,7 +107,7 @@ 'beta', 'xi', 'acc2', 'epsnov', 'eddfac', 'gamma', 'don_lim', 'acc_lim', 'bdecayfac', 'bconst', 'ck', - 'windflag', 'qcflag', 'eddlimflag', + 'windflag', 'qcflag', 'eddlimflag', 'LBV_flag', 'fprimc_array', 'dtp', 'randomseed', 'bhspinflag', 'bhspinmag', 'rejuv_fac', 'rejuvflag', 'htpmb', 'ST_cr', 'ST_tide', 'rembar_massloss', 'zsun', 'kickflag'] @@ -572,6 +572,7 @@ def _evolve_single_system(f): _evolvebin.windvars.epsnov = f["epsnov"] _evolvebin.windvars.eddfac = f["eddfac"] _evolvebin.windvars.gamma = f["gamma"] + _evolvebin.windvars.LBV_flag = f["LBV_flag"] _evolvebin.flags.bdecayfac = f["bdecayfac"] _evolvebin.magvars.bconst = f["bconst"] _evolvebin.magvars.ck = f["ck"] diff --git a/src/cosmic/src/const_bse.h b/src/cosmic/src/const_bse.h index 1c411ff8..997e97fe 100644 --- a/src/cosmic/src/const_bse.h +++ b/src/cosmic/src/const_bse.h @@ -26,8 +26,9 @@ COMMON /METVARS/ zsun REAL*8 neta,bwind,hewind,beta,xi,acc2,epsnov REAL*8 eddfac,gamma + INTEGER LBV_flag COMMON /WINDVARS/ neta,bwind,hewind,beta,xi,acc2,epsnov, - & eddfac,gamma + & eddfac,gamma,LBV_flag REAL*8 alpha1,lambdaf REAL*8 qcrit_array(16) COMMON /CEVARS/ qcrit_array,alpha1,lambdaf diff --git a/src/cosmic/tests/data/Params.ini b/src/cosmic/tests/data/Params.ini index b4a11f9c..9244f96c 100644 --- a/src/cosmic/tests/data/Params.ini +++ b/src/cosmic/tests/data/Params.ini @@ -147,6 +147,8 @@ xi=0.5 ; default=1.5 acc2=1.5 +LBV_flag=1 + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/src/cosmic/tests/data/initial_conditions_for_testing.hdf5 b/src/cosmic/tests/data/initial_conditions_for_testing.hdf5 index adf91ea81e77e75c17ac2c26aa98135fc376d370..0af1633580731efdfac706df33b864fbf837d01e 100644 GIT binary patch delta 351 zcmaD^KBZ!U29t=*My+S;jE$QGIleP8PMpli<;mp9JK5Jzf=T_(3QPEO=jXJV8EiFrW9N+xdviajxyxG`@spW64$_Pq8y`aVu!@o71U=}bSXFIkE+ I37~rw02r}WNB{r; delta 294 zcmbPI@v?k^2GdLHjatvx8S^#^a(riGteecq<;i5mJ2}Bng6Y`G$@68qCja1aVA>}& zaibik1_K1#o1Dn4&h$Ntq9y~x3T8spEHbEsp^dzH_$#0Ak zI0YC4z@qaecS)_}s#An0;b4GTxjA26jB#?Vj1ObmTe8d`E*w165sIo?nb;+0>MON9#FB0$s0jp>JvBSZT8?%;MDYS3X4z6Nlb^zGcYnpfSHVpj9_{) zRATbvM$!9>GbSgBtpr-lEv^W(bF-d!5+h^7Q0~@F~-d?GE2AxRiH*gEMj0#nS4>qlIw*&L|B0lrXx>7ijfnhSY`4@ nDMKy}Lx>^=CYU0yv46C_uuguU&oTK2pTlMY!w-xC=-vYWY(-DK delta 289 zcmX?+wjgbS2BX48&FAcl5t{`$zB4jrOy=bBWK!UqoFgg0bZq71Jg!qrE5s≪hN3 zfPfQ|6S>uyZb*Q{JfLD3lQ)9I)F*Dt+w8%kz$wYdAOV(QWMl->lb{MGO`a%vpRr?d zq1Z~GRnp>$Ksz?ui6=2K7EE3!aS%u*OM=8E+ll|0+#tolxL|Up)Jm=w3K0Dt*r4tL z>JekyoFlV@TTmHlG{hnX2Ia{Q#VomQ=tG1h7-2f Date: Tue, 17 Feb 2026 16:39:30 -0500 Subject: [PATCH 05/16] for some incredibly annoying reason, these can't be capitals --- src/cosmic/evolve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cosmic/evolve.py b/src/cosmic/evolve.py index 53956251..a27a61fb 100644 --- a/src/cosmic/evolve.py +++ b/src/cosmic/evolve.py @@ -572,7 +572,7 @@ def _evolve_single_system(f): _evolvebin.windvars.epsnov = f["epsnov"] _evolvebin.windvars.eddfac = f["eddfac"] _evolvebin.windvars.gamma = f["gamma"] - _evolvebin.windvars.LBV_flag = f["LBV_flag"] + _evolvebin.windvars.lbv_flag = f["LBV_flag"] _evolvebin.flags.bdecayfac = f["bdecayfac"] _evolvebin.magvars.bconst = f["bconst"] _evolvebin.magvars.ck = f["ck"] From 04b0d6f22070cdd042ddfd33c479283773bbfb7b Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Wed, 18 Feb 2026 11:48:15 -0500 Subject: [PATCH 06/16] ensure luminosity calculate before returning after stripping during hrdiag --- src/cosmic/src/hrdiag.f | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/cosmic/src/hrdiag.f b/src/cosmic/src/hrdiag.f index ebba5922..08eddb50 100644 --- a/src/cosmic/src/hrdiag.f +++ b/src/cosmic/src/hrdiag.f @@ -54,7 +54,7 @@ SUBROUTINE hrdiag(mass,aj,mt,tm,tn,tscls,lums,GB,zpars, real*8 rzamsf,rtmsf,ralphf,rbetaf,rgammf,rhookf real*8 rgbf,rminf,ragbf,rzahbf,rzhef,rhehgf,rhegbf,rpertf real*8 mctmsf,mcgbtf,mcgbf,mcheif,mcagbf,lzahbf -* real*8 mrem + logical stripped_during_hrdiag external thookf,tblf external lalphf,lbetaf,lnetaf,lhookf,lgbtf,lmcgbf,lzhef,lpertf external rzamsf,rtmsf,ralphf,rbetaf,rgammf,rhookf @@ -81,6 +81,8 @@ SUBROUTINE hrdiag(mass,aj,mt,tm,tn,tscls,lums,GB,zpars, * * Make evolutionary changes to stars that have not reached KW > 5. * + ! track whether a star stripped during hrdiag + stripped_during_hrdiag = .false. mch = 1.44d0 !set here owing to AIC ECSN model. * mass0 = mass @@ -202,8 +204,8 @@ SUBROUTINE hrdiag(mass,aj,mt,tm,tn,tscls,lums,GB,zpars, kw = 7 CALL star(kw,mass,mt,tm,tn,tscls,lums,GB,zpars) - ! return so that bpp logs the stellar type change - return + ! flag to return so that bpp logs the stellar type change + stripped_during_hrdiag = .true. else * * Zero-age helium white dwarf. @@ -276,8 +278,8 @@ SUBROUTINE hrdiag(mass,aj,mt,tm,tn,tscls,lums,GB,zpars, kw = 7 CALL star(kw,mass,mt,tm,tn,tscls,lums,GB,zpars) - ! return so that bpp logs the stellar type change - return + ! flag to return so that bpp logs the stellar type change + stripped_during_hrdiag = .true. else * * Zero-age helium white dwarf. @@ -412,8 +414,8 @@ SUBROUTINE hrdiag(mass,aj,mt,tm,tn,tscls,lums,GB,zpars, CALL star(kw,mass,mt,tm,tn,tscls,lums,GB,zpars) aj = xx*tm - ! return so that bpp logs the stellar type change - return + ! flag to return so that bpp logs the stellar type change + stripped_during_hrdiag = .true. else kw = 4 endif @@ -457,8 +459,8 @@ SUBROUTINE hrdiag(mass,aj,mt,tm,tn,tscls,lums,GB,zpars, endif aj = MAX(aj,tm) - ! return so that bpp logs the stellar type change - return + ! flag to return so that bpp logs the stellar type change + stripped_during_hrdiag = .true. else kw = 5 endif @@ -546,6 +548,10 @@ SUBROUTINE hrdiag(mass,aj,mt,tm,tn,tscls,lums,GB,zpars, mc_he(kidx) = mt - mc mc_co(kidx) = mc + if(stripped_during_hrdiag)then + return + endif + ! core mass for a He star to become a COWD (Hurley 2000, Eq. 89) mtc = MIN(mt,1.45d0*mt-0.31d0) From 49ec6f5d1365e530049869438ce91ec17044bf3a Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Wed, 18 Feb 2026 11:49:16 -0500 Subject: [PATCH 07/16] make LBVs additive in all windflags --- src/cosmic/src/mlwind.f | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cosmic/src/mlwind.f b/src/cosmic/src/mlwind.f index cee3511c..df1f1644 100644 --- a/src/cosmic/src/mlwind.f +++ b/src/cosmic/src/mlwind.f @@ -181,9 +181,8 @@ real*8 FUNCTION mlwind(kw,lum,r,mt,mc,rl,z) * Optional flag (windflag=3) to use for every non-degenerate star * past the limit, rather than just for giant, evolved stars -* TW: Note this is overwrite the other mass loss, might want a sum here -* not assignment, but leaving it consistent for now - dms = LBV_winds(lum,r,mt,kw,z) +* TW: This previously overwrote the other mass loss, changed it to a sum + dms = dms + LBV_winds(lum,r,mt,kw,z) elseif(kw.ge.7.and.kw.le.9)then !WR (naked helium stars) * If naked helium use Hamann & Koesterke (1998) WR winds reduced by factor of * 10 (Yoon & Langer 2005), with Vink & de Koter (2005) metallicity dependence From 46eb96d28edee5b4c844195ba8bd0d9c7a202af3 Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Wed, 18 Feb 2026 11:49:58 -0500 Subject: [PATCH 08/16] add sphinx_gallery requirement --- docs/conf.py | 8 ++++++++ requirements.txt | 1 + 2 files changed, 9 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 804e0e22..338cff05 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -62,6 +62,7 @@ def setup(app): 'numpydoc', 'sphinx_design', 'sphinx_copybutton', + 'sphinx_gallery.gen_gallery', ] # -- Extensions --------------------------------------------------------------- @@ -76,6 +77,13 @@ def setup(app): autoclass_content = 'class' autodoc_default_flags = ['show-inheritance', 'members', 'inherited-members'] +# -- sphinx_gallery ----------------------------- + +sphinx_gallery_conf = { + 'examples_dirs': 'settings_examples', # path to your example scripts + 'gallery_dirs': 'auto_examples', # path to where to save gallery generated output +} + # -- autosummary -------------------------------- autosummary_generate = True diff --git a/requirements.txt b/requirements.txt index 2c7bf7fe..8317cf3b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,4 +24,5 @@ wheel furo sphinx-design sphinx-copybutton +sphinx-gallery meson From d2b68b78c24c52a01dc376ee66ff646d76bf26a8 Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Wed, 18 Feb 2026 11:50:05 -0500 Subject: [PATCH 09/16] update test data --- src/cosmic/tests/data/Params.ini | 2 +- .../data/initial_conditions_for_testing.hdf5 | Bin 15380 -> 15380 bytes .../tests/data/kick_initial_conditions.h5 | Bin 13128 -> 13128 bytes 3 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cosmic/tests/data/Params.ini b/src/cosmic/tests/data/Params.ini index 9244f96c..6fa2996e 100644 --- a/src/cosmic/tests/data/Params.ini +++ b/src/cosmic/tests/data/Params.ini @@ -147,7 +147,7 @@ xi=0.5 ; default=1.5 acc2=1.5 -LBV_flag=1 +LBV_flag=2 diff --git a/src/cosmic/tests/data/initial_conditions_for_testing.hdf5 b/src/cosmic/tests/data/initial_conditions_for_testing.hdf5 index 0af1633580731efdfac706df33b864fbf837d01e..802853af59f2a0d3661a837a9917e55abce6e5f4 100644 GIT binary patch delta 76 zcmbPIF{NTd4i{s|lM*si- diff --git a/src/cosmic/tests/data/kick_initial_conditions.h5 b/src/cosmic/tests/data/kick_initial_conditions.h5 index 95ef5bb381bd99444d4c07b266b8e296b6f720c9..8e6e428b7c1335236497d1045502673e9f13fc53 100644 GIT binary patch delta 69 zcmX?+b|P&<4i{s|=3K7xJV44;+?|QBWU{UJ@5v2PSHJ?|jGJ?01VECt8s&^IAs+27 Mtc*;X84cZ;09#2F@&Et; delta 71 zcmX?+b|P&<4i}^P=3K7xJV44;+?|P0eX_0i@5v2PSHJ?|jGJ?01VECt8s&^IAs+27 Ptdl?Jb8O}?bYKDiMuZjH From 27134d523abe1235583f5bb43cce23380bc663be Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Wed, 18 Feb 2026 11:50:15 -0500 Subject: [PATCH 10/16] ignore generated examples --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b82f7e98..c053e033 100644 --- a/.gitignore +++ b/.gitignore @@ -118,4 +118,5 @@ fort.99 savefig/ # ignore generated docs files -_generated/ \ No newline at end of file +_generated/ +docs/auto_examples/ \ No newline at end of file From cff554e5ab5d3c198d2703805b906568111dbe41 Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Wed, 18 Feb 2026 12:39:00 -0500 Subject: [PATCH 11/16] add example gallery, start with LBV flag --- .gitignore | 3 +- docs/_static/cosmic-docs.css | 11 +++ docs/_static/gallery.mplstyle | 14 +++ docs/conf.py | 1 + docs/pages/reference_material.rst | 13 ++- docs/settings_examples/GALLERY_HEADER.rst | 9 ++ docs/settings_examples/plot_LBV_flag.py | 104 ++++++++++++++++++++++ 7 files changed, 153 insertions(+), 2 deletions(-) create mode 100644 docs/_static/gallery.mplstyle create mode 100644 docs/settings_examples/GALLERY_HEADER.rst create mode 100644 docs/settings_examples/plot_LBV_flag.py diff --git a/.gitignore b/.gitignore index c053e033..b6122f16 100644 --- a/.gitignore +++ b/.gitignore @@ -119,4 +119,5 @@ savefig/ # ignore generated docs files _generated/ -docs/auto_examples/ \ No newline at end of file +docs/auto_examples/ +sg_execution_times.rst \ No newline at end of file diff --git a/docs/_static/cosmic-docs.css b/docs/_static/cosmic-docs.css index 41cbbd2c..5a181680 100644 --- a/docs/_static/cosmic-docs.css +++ b/docs/_static/cosmic-docs.css @@ -469,4 +469,15 @@ select.form-control { .btn-toggle.active { filter: brightness(1.1); font-weight: bold; +} + +/* Centre gallery thumbnail labels and titles */ +.sphx-glr-thumbcontainer[tooltip]:hover::after, +.sphx-glr-thumbnail-title { + text-align: center; +} + +/* vertically align content in the thumbnails */ +.sphx-glr-thumbcontainer { + justify-content: center; } \ No newline at end of file diff --git a/docs/_static/gallery.mplstyle b/docs/_static/gallery.mplstyle new file mode 100644 index 00000000..d3ec8e44 --- /dev/null +++ b/docs/_static/gallery.mplstyle @@ -0,0 +1,14 @@ +font.family: serif +text.usetex: False +figure.figsize: 12, 8 +axes.titlesize: 24 +legend.title_fontsize: 18 +legend.fontsize: 16 +axes.labelsize: 24 +xtick.labelsize: 21 +ytick.labelsize: 21 +axes.linewidth: 1.1 +xtick.major.size: 7 +xtick.minor.size: 4 +ytick.major.size: 7 +ytick.minor.size: 4 \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 338cff05..43a86826 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -82,6 +82,7 @@ def setup(app): sphinx_gallery_conf = { 'examples_dirs': 'settings_examples', # path to your example scripts 'gallery_dirs': 'auto_examples', # path to where to save gallery generated output + 'download_all_examples': False, } # -- autosummary -------------------------------- diff --git a/docs/pages/reference_material.rst b/docs/pages/reference_material.rst index bba77b61..aff6befd 100644 --- a/docs/pages/reference_material.rst +++ b/docs/pages/reference_material.rst @@ -27,4 +27,15 @@ Configuration and output output_info.rst - Descriptions of the output files generated by COSMIC simulations. \ No newline at end of file + Descriptions of the output files generated by COSMIC simulations. + + .. grid-item-card:: + :link: gallery + :link-type: ref + + .. toctree:: + :maxdepth: 1 + + ../auto_examples/index.rst + + Examples of the effects of different configuration options on the evolution of binaries. \ No newline at end of file diff --git a/docs/settings_examples/GALLERY_HEADER.rst b/docs/settings_examples/GALLERY_HEADER.rst new file mode 100644 index 00000000..34880775 --- /dev/null +++ b/docs/settings_examples/GALLERY_HEADER.rst @@ -0,0 +1,9 @@ +Impact of settings on evolution +=============================== + +This gallery shows examples of how different settings affect the evolution of binaries. + +.. admonition:: Under construction + :class: warning + + This page is still being developed, but will eventually contain examples of how all settings affect the evolution of binaries. For now it's just a few. \ No newline at end of file diff --git a/docs/settings_examples/plot_LBV_flag.py b/docs/settings_examples/plot_LBV_flag.py new file mode 100644 index 00000000..8b37b841 --- /dev/null +++ b/docs/settings_examples/plot_LBV_flag.py @@ -0,0 +1,104 @@ +""" +``LBV_flag`` +============ + +This example shows the effect of the ``LBV_flag`` on the evolution of massive stars. + +The ``LBV_flag`` controls which prescription to use for LBV-like mass loss for stars that are above the Humphreys-Davidson limit. The plots below show the evolution of a few single stars and highlight the LBV regime in which we'd expect to see differences with this flag. +""" + +#---------------------------------------------------------------------------------- +#---------------------------------------------------------------------------------- +## You'll want to edit this part locally to use your own BSEDict and style sheet! + +import sys +sys.path.append("..") +import generate_default_bsedict +BSEDict = generate_default_bsedict.get_default_BSE_settings(to_python=True) + +import matplotlib.pyplot as plt +plt.style.use("../_static/gallery.mplstyle") +#---------------------------------------------------------------------------------- +#---------------------------------------------------------------------------------- + +import numpy as np +import astropy.units as u +import astropy.constants as consts + +from cosmic.sample import InitialBinaryTable +from cosmic.evolve import Evolve +from cosmic.output import kstar_translator + +def LBV_limit(T_eff): + """ Compute the luminosity of the LBV limit given a certain temperature """ + return np.maximum(np.sqrt(1e10 * u.Rsun**2 * u.Lsun * (4 * np.pi * consts.sigma_sb * (T_eff * u.K)**4)).to(u.Lsun), np.repeat(6e5 * u.Lsun, len(T_eff))) + + +# create a small grid of single stars +masses = [30, 33, 36, 40, 45, 50] +grid = InitialBinaryTable.InitialBinaries( + m1=masses, + m2=np.zeros(len(masses)), + porb=np.ones(len(masses))*-1.0, + ecc=np.ones(len(masses))*0.0, + tphysf=np.ones(len(masses))*13700.0, + kstar1=np.ones(len(masses)), + kstar2=np.ones(len(masses)), + metallicity=np.ones(len(masses))*0.014*0.01 +) + +# loop over different flag choices +for LBV_flag, label in zip([0, 1, 2], ["No LBV mass loss", "LBV mass loss following Hurley+2000", + "LBV mass loss following Belczynski+2008"]): + # evolve with updated BSEDict + BSEDict["LBV_flag"] = LBV_flag + bpp, bcm, initC, kick_info = Evolve.evolve( + initialbinarytable=grid, BSEDict=BSEDict, + dtp=0 + ) + + # plot a HR diagram of the evolution of these stars, colour coded by kstar + fig, ax = plt.subplots(figsize=(10, 16)) + + for i, bin_num in enumerate(np.unique(bcm["bin_num"])): + log_teff = np.log10(bcm[bcm["bin_num"] == bin_num]["teff_1"].values) + log_lum = np.log10(bcm[bcm["bin_num"] == bin_num]["lum_1"].values) + kstar = bcm[bcm["bin_num"] == bin_num]["kstar_1"].values + + mask = kstar < 10 + + ax.scatter(log_teff[mask], log_lum[mask], c=[kstar_translator[k]["colour"] for k in kstar[mask]], + s=5) + ax.plot(log_teff[mask], log_lum[mask], color='grey', alpha=0.5, lw=0.5, zorder=-1) + + # annotate the first point with the initial mass + ax.annotate(f'{bcm[bcm["bin_num"] == bin_num]["mass_1"].values[0]:.0f} M$_\odot$', (log_teff[0], log_lum[0]), + fontsize=14, ha="right", color='black', va='top') + + # annotate the various kstar types + for k in bcm["kstar_1"].unique(): + if k < 10: + ax.scatter([], [], color=kstar_translator[k]["colour"], label=kstar_translator[k]["short"], s=50) + ax.legend() + + # make some fairly reasonable temperature range + T_eff_range = np.logspace(3.5, 5.4, 1000) + + # plot a line at the HD limit and fill the area + ax.plot(np.log10(T_eff_range), np.log10(LBV_limit(T_eff_range).value), color="grey", linestyle="dotted") + ax.fill_between(np.log10(T_eff_range), np.log10(LBV_limit(T_eff_range).value), 9, color="black", lw=2, alpha=0.03) + + # annotate the regime with a custom location + ax.annotate("LBV Regime", xy=(0.77, 0.93), xycoords="axes fraction", ha="center", va="center", + fontsize=20, color="grey", zorder=10) + + ax.set( + xlabel=r"$\log_{10}(T_{\rm eff} \, [\rm K])$", + ylabel=r"$\log_{10}(L \, [\rm L_{\odot}])$", + title=f"LBV_flag = {LBV_flag}\n{label}", + ylim=(5, 6.2) + ) + + ax.invert_xaxis() + + plt.show() \ No newline at end of file From 7e7c43111a72f92e967f28cf01c1d8458be5a611 Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Wed, 18 Feb 2026 13:03:37 -0500 Subject: [PATCH 12/16] add pisn flag demo --- docs/conf.py | 3 +- docs/settings_examples/plot_pisn.py | 109 ++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 docs/settings_examples/plot_pisn.py diff --git a/docs/conf.py b/docs/conf.py index 43a86826..7a231857 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -58,7 +58,7 @@ def setup(app): 'sphinxcontrib.programoutput', 'matplotlib.sphinxext.plot_directive', 'IPython.sphinxext.ipython_console_highlighting', - 'IPython.sphinxext.ipython_directive', + # 'IPython.sphinxext.ipython_directive', 'numpydoc', 'sphinx_design', 'sphinx_copybutton', @@ -83,6 +83,7 @@ def setup(app): 'examples_dirs': 'settings_examples', # path to your example scripts 'gallery_dirs': 'auto_examples', # path to where to save gallery generated output 'download_all_examples': False, + 'remove_config_comments': True, } # -- autosummary -------------------------------- diff --git a/docs/settings_examples/plot_pisn.py b/docs/settings_examples/plot_pisn.py new file mode 100644 index 00000000..ead2c948 --- /dev/null +++ b/docs/settings_examples/plot_pisn.py @@ -0,0 +1,109 @@ +""" +``pisn`` +============ + +This example shows the effect of the ``pisn`` on the remnant masses for stars with large CO cores. + +The ``pisn`` controls which prescription to use for pair-instability supernovae (PISN) for stars that are above a certain CO core mass. +The plots below show the remnant masses for a grid of single stars with different choices of the ``pisn`` flag. +""" + +# sphinx_gallery_thumbnail_number = 3 + +#---------------------------------------------------------------------------------- +#---------------------------------------------------------------------------------- +## You'll want to edit this part locally to use your own BSEDict and style sheet! + +import sys +sys.path.append("..") +import generate_default_bsedict +BSEDict = generate_default_bsedict.get_default_BSE_settings(to_python=True) + +import matplotlib.pyplot as plt +plt.style.use("../_static/gallery.mplstyle") +#---------------------------------------------------------------------------------- +#---------------------------------------------------------------------------------- + +import numpy as np +import astropy.units as u +import astropy.constants as consts + +from cosmic.sample import InitialBinaryTable +from cosmic.evolve import Evolve +from cosmic.output import kstar_translator + + +pisn_flags = [0, -1, -2, -3, -4, 45] +labels = ["No PISN", "PISN following Spera & Mapelli 2017", "PISN following Marchant+2018", + "PISN following Woolsey+2019", "PISN following\nRenzo+2022/Hendriks+2023", + "Assume PPISN from 45-65 Msun He Cores\nPISN above that"] + +bpps = {} +initCs = {} + +for pisn_flag, label in zip(pisn_flags, labels): + n_grid = 500 + + binary_grid = InitialBinaryTable.InitialBinaries(m1=np.geomspace(50, 150, n_grid), + m2=np.zeros(n_grid), + porb=np.ones(n_grid)*-1.0, + ecc=np.ones(n_grid)*0.0, + tphysf=np.ones(n_grid)*13700.0, + kstar1=np.ones(n_grid), + kstar2=np.ones(n_grid), + metallicity=np.ones(n_grid)*0.014*0.01) + + + BSEDict['pisn'] = pisn_flag + bpp, _, initC, _ = Evolve.evolve( + initialbinarytable=binary_grid, BSEDict=BSEDict, + bpp_columns=['tphys', 'mass_1', 'kstar_1', 'massc_co_layer_1', + 'massc_he_layer_1', 'evol_type', "SN_1", "kstar_2"], + nproc=16 + ) + final_bpp = bpp.drop_duplicates(subset="bin_num", keep="last") + + fig, ax = plt.subplots(figsize=(8, 5), constrained_layout=True) + + sn_rows = bpp[bpp["evol_type"] == 15] + co_core_mass = sn_rows["massc_co_layer_1"].values + total_core_mass = co_core_mass + sn_rows["massc_he_layer_1"].values + remnant_mass = final_bpp["mass_1"].values + kstars = sn_rows["kstar_1"].values + + ax.scatter(total_core_mass, remnant_mass, c=[kstar_translator[k]["colour"] for k in kstars]) + ax.plot(total_core_mass, total_core_mass - 0.5, color='k', ls=':') + + ax.set( + xlabel=r"Total core mass, $M_{\rm c, tot} \, [\rm M_{\odot}]$", + ylabel=r"Remnant mass, $M_r \, [\rm M_{\odot}]$", + xlim=(15, 62), + ylim=(15, 62), + title=label + ) + + ax.yaxis.set_major_locator(plt.MultipleLocator(10)) + ax.yaxis.set_minor_locator(plt.MultipleLocator(5)) + + ax.xaxis.set_major_locator(plt.MultipleLocator(10)) + ax.xaxis.set_minor_locator(plt.MultipleLocator(2)) + + if pisn_flag == 0: + pisn_turn_on = -100 + elif pisn_flag == -1: + pisn_turn_on = 32 + elif pisn_flag == -2: + pisn_turn_on = 32 + elif pisn_flag == -3: + pisn_turn_on = 29.53 + elif pisn_flag == -4: + idx = np.argmin(np.abs(co_core_mass - 38)) + pisn_turn_on = total_core_mass[idx] + else: + pisn_turn_on = pisn_flag + + ax.axvline(pisn_turn_on, color='k', ls='--') + ax.annotate("(P)PISN turns on", xy=(pisn_turn_on, ax.get_ylim()[-1] - 2), rotation=90, + fontsize=10, bbox=dict(boxstyle="round", fc="w"), ha='center', va='top') + + plt.show() \ No newline at end of file From ac183927ecca70e37d55744cc4bdfd88ec16aad6 Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Wed, 18 Feb 2026 13:06:41 -0500 Subject: [PATCH 13/16] remove my speed hack --- docs/conf.py | 2 +- docs/settings_examples/plot_pisn.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 7a231857..8009f975 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -58,7 +58,7 @@ def setup(app): 'sphinxcontrib.programoutput', 'matplotlib.sphinxext.plot_directive', 'IPython.sphinxext.ipython_console_highlighting', - # 'IPython.sphinxext.ipython_directive', + 'IPython.sphinxext.ipython_directive', 'numpydoc', 'sphinx_design', 'sphinx_copybutton', diff --git a/docs/settings_examples/plot_pisn.py b/docs/settings_examples/plot_pisn.py index ead2c948..93da2281 100644 --- a/docs/settings_examples/plot_pisn.py +++ b/docs/settings_examples/plot_pisn.py @@ -5,7 +5,7 @@ This example shows the effect of the ``pisn`` on the remnant masses for stars with large CO cores. The ``pisn`` controls which prescription to use for pair-instability supernovae (PISN) for stars that are above a certain CO core mass. -The plots below show the remnant masses for a grid of single stars with different choices of the ``pisn`` flag. +The plots below show the remnant masses for a grid of single stars with different choices of the ``pisn`` flag at a metallicity of :math:`Z = 0.01 Z_{\odot}`. """ # sphinx_gallery_thumbnail_number = 3 @@ -42,7 +42,7 @@ initCs = {} for pisn_flag, label in zip(pisn_flags, labels): - n_grid = 500 + n_grid = 250 binary_grid = InitialBinaryTable.InitialBinaries(m1=np.geomspace(50, 150, n_grid), m2=np.zeros(n_grid), From fecec69c7da3281e1825ae92dc63b7c2dc0ea620 Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Wed, 18 Feb 2026 13:45:59 -0500 Subject: [PATCH 14/16] track version added in docs --- docs/_static/cosmic-docs.css | 53 ++++++++++++++++++++++++++++ docs/create_settings_html.py | 15 ++++++-- src/cosmic/_version.py | 2 +- src/cosmic/data/cosmic-settings.json | 6 +++- 4 files changed, 72 insertions(+), 4 deletions(-) diff --git a/docs/_static/cosmic-docs.css b/docs/_static/cosmic-docs.css index 5a181680..3989e656 100644 --- a/docs/_static/cosmic-docs.css +++ b/docs/_static/cosmic-docs.css @@ -125,6 +125,16 @@ html[data-theme="dark"] .sd-card { max-width: 100%; } +.setting-chooser .name-cont { + display: flex; + align-items: center; +} + +.setting-chooser .name { + display: inline-block; + margin-right: 0.5rem; +} + .setting-chooser .description { margin-bottom: 0; } @@ -134,6 +144,10 @@ html[data-theme="dark"] .sd-card { font-weight: bold; } +.setting-chooser .version-added { + font-style: italic; +} + .options { overflow: hidden; } @@ -152,6 +166,41 @@ html[data-theme="dark"] .sd-card { color: var(--color-brand-primary); } +.options .opt-badge-cont { + margin-left: 0.5rem; + font-style: italic; +} + +/* base badge */ +.badge { + display: inline-block; + padding: 0.35em 0.65em; + font-size: 0.75em; + font-weight: 700; + line-height: 1; + color: #fff; + text-align: center; + white-space: nowrap; + vertical-align: baseline; + border-radius: 0.375rem; +} + +/* pill style */ +.badge.rounded-pill { + border-radius: 50rem; +} + +.badge-primary { background-color: #0d6efd; } +.badge-secondary { background-color: #6c757d; } +.badge-success { background-color: #198754; } +.badge-danger { background-color: #dc3545; } +.badge-warning { background-color: #ffc107; color: #000; } +.badge-info { background-color: #0dcaf0; color: #000; } +.badge-light { background-color: #f8f9fa; color: #000; } +.badge-dark { background-color: #212529; } + + + .setting .col-3 label { cursor: pointer; } @@ -480,4 +529,8 @@ select.form-control { /* vertically align content in the thumbnails */ .sphx-glr-thumbcontainer { justify-content: center; +} + +.link-white { + color: white!important; } \ No newline at end of file diff --git a/docs/create_settings_html.py b/docs/create_settings_html.py index 02a78208..fdbb7450 100644 --- a/docs/create_settings_html.py +++ b/docs/create_settings_html.py @@ -10,6 +10,7 @@ import bs4 import json import pandas as pd +from cosmic import __version__ as cosmic_version # blame BS4 for me calling this soup main_soup = """ @@ -29,7 +30,7 @@ settings_template = """
-

+

@@ -43,7 +44,7 @@
""" # same as above, but for an option for a setting, this will go in the
    element -option_template = """
  • :
  • """ +option_template = """
  • :
  • """ # read the settings file with open("../src/cosmic/data/cosmic-settings.json") as f: @@ -93,6 +94,11 @@ new_setting.select_one(".description").clear() new_setting.select_one(".description").append(bs4.BeautifulSoup(setting["description"], 'html.parser')) + + # add the version added if it's there + if "version_added" in setting: + new_setting.select_one(".version-added").append(bs4.BeautifulSoup( + f"""Added in v{setting['version_added']}""", 'html.parser')) # colour the sublinks the same as the border of the group new_setting.select_one(".options-expander")["style"] = "color: " + group["docs-colour"] + ";" @@ -165,6 +171,11 @@ new_option_expl = bs4.BeautifulSoup(option_template, 'html.parser') new_option_expl.select_one(".opt-val").string = str(option["name"]) new_option_expl.select_one(".opt-desc").append(bs4.BeautifulSoup(option["description"], 'html.parser')) + + if "version_added" in option: + new_option_expl.select_one(".opt-badge-cont").append(bs4.BeautifulSoup( + f"""Added in v{option['version_added']}""", 'html.parser' + )) new_setting.select_one(".options").ul.append(new_option_expl) # convert the default options to a string and display it diff --git a/src/cosmic/_version.py b/src/cosmic/_version.py index 3bdbbae2..221485ae 100644 --- a/src/cosmic/_version.py +++ b/src/cosmic/_version.py @@ -1 +1 @@ -__version__ = "3.7.2" +__version__ = "3.7.3" diff --git a/src/cosmic/data/cosmic-settings.json b/src/cosmic/data/cosmic-settings.json index c8487a6d..4c20e4e9 100644 --- a/src/cosmic/data/cosmic-settings.json +++ b/src/cosmic/data/cosmic-settings.json @@ -693,6 +693,7 @@ "description": "Selects the model for Luminous Blue Variable (LBV) mass loss", "type": "dropdown", "options-preface": "", + "version_added": "3.7.3", "options": [ { "name": 0, @@ -1371,7 +1372,8 @@ }, { "name": -4, - "description": "Uses the top-down approach from Renzo+2022, with adjustable parameters from Hendriks+2023" + "description": "Uses the top-down approach from Renzo+2022, with adjustable parameters from Hendriks+2023", + "version_added": "3.7.2" }, { "name": "positive values", @@ -1383,6 +1385,7 @@ "name": "ppi_co_shift", "description": "Shifts the CO core mass thresholds for pulsational pair instability and pair instability SNe by a constant amount in COSMIC's implementation of the Renzo+2022/Hendriks+2023 prescription (only relevant if pisn = -4). Default threshold is 38 Msun.", "type": "number", + "version_added": "3.7.2", "options-preface": "Note the default threshold is 38 Msun.", "options": [ { @@ -1404,6 +1407,7 @@ "name": "ppi_extra_ml", "description": "Sets the amount of extra mass loss in Msun that is applied to stars that go through pulsational pair instability in COSMIC's implementation of the Renzo+2022/Hendriks+2023 prescription (only relevant if pisn = -4). Default is 0 Msun.", "type": "number", + "version_added": "3.7.2", "options-preface": "", "options": [ { From 987488646702ee98bd67a2bfb1dbfbf49fd22b87 Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Wed, 18 Feb 2026 13:55:19 -0500 Subject: [PATCH 15/16] only show recent version changes --- docs/create_settings_html.py | 27 ++++++++++++++++++++++----- src/cosmic/data/cosmic-settings.json | 15 ++++++++++++--- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/docs/create_settings_html.py b/docs/create_settings_html.py index fdbb7450..9d4f6e50 100644 --- a/docs/create_settings_html.py +++ b/docs/create_settings_html.py @@ -12,6 +12,21 @@ import pandas as pd from cosmic import __version__ as cosmic_version +# how many versions in the past should we show as badges for when options were added? +VERSION_CUTOFFS = { + "major": 0, + "minor": 3, + "patch": 1000 +} + +def version_is_recent(version_string): + version_nums = version_string.split(".") + cosmic_nums = cosmic_version.split(".") + for i, label in enumerate(["major", "minor", "patch"]): + if int(cosmic_nums[i]) - int(version_nums[i]) > VERSION_CUTOFFS[label]: + return False + return True + # blame BS4 for me calling this soup main_soup = """
    @@ -97,8 +112,9 @@ # add the version added if it's there if "version_added" in setting: - new_setting.select_one(".version-added").append(bs4.BeautifulSoup( - f"""Added in v{setting['version_added']}""", 'html.parser')) + if version_is_recent(setting["version_added"]): + new_setting.select_one(".version-added").append(bs4.BeautifulSoup( + f"""Added in v{setting['version_added']}""", 'html.parser')) # colour the sublinks the same as the border of the group new_setting.select_one(".options-expander")["style"] = "color: " + group["docs-colour"] + ";" @@ -173,9 +189,10 @@ new_option_expl.select_one(".opt-desc").append(bs4.BeautifulSoup(option["description"], 'html.parser')) if "version_added" in option: - new_option_expl.select_one(".opt-badge-cont").append(bs4.BeautifulSoup( - f"""Added in v{option['version_added']}""", 'html.parser' - )) + if version_is_recent(option["version_added"]): + new_option_expl.select_one(".opt-badge-cont").append(bs4.BeautifulSoup( + f"""Added in v{option['version_added']}""", 'html.parser' + )) new_setting.select_one(".options").ul.append(new_option_expl) # convert the default options to a string and display it diff --git a/src/cosmic/data/cosmic-settings.json b/src/cosmic/data/cosmic-settings.json index 4c20e4e9..8804a45f 100644 --- a/src/cosmic/data/cosmic-settings.json +++ b/src/cosmic/data/cosmic-settings.json @@ -544,7 +544,8 @@ "options": [ { "name": -1, - "description": "No wind mass loss" + "description": "No wind mass loss", + "version_added": "3.7.2" }, { "name": 0, @@ -1152,6 +1153,7 @@ "name": "mm_mu_ns", "description": "Sets the NS kick scaling prefactor for the Mandel & Mueller 2020 kick prescription (only relevant if kickflag = 6)", "type": "number", + "version_added": "3.7.0", "options-preface": "", "options": [ { @@ -1169,6 +1171,7 @@ "name": "mm_mu_bh", "description": "Sets the BH kick scaling prefactor for the Mandel & Mueller 2020 kick prescription (only relevant if kickflag = 6)", "type": "number", + "version_added": "3.7.0", "options-preface": "", "options": [ { @@ -1212,11 +1215,13 @@ }, { "name": 5, - "description": "follows the prescription from Mandel & Mueller 2020. The method is stochastic. NOTE: We recommend that this prescription be used in conjunction with the Mandel & Mueller 2020 kick prescription (kickflag = 6) and with mxns set to 2.0 Msun and rembar_massloss set to 0.1 Msun." + "description": "follows the prescription from Mandel & Mueller 2020. The method is stochastic. NOTE: We recommend that this prescription be used in conjunction with the Mandel & Mueller 2020 kick prescription (kickflag = 6) and with mxns set to 2.0 Msun and rembar_massloss set to 0.1 Msun.", + "version_added": "3.7.0" }, { "name": 6, - "description": "follows the prescription from Maltsev+2025, with additions from Willcox+2025 for the definition of BH masses." + "description": "follows the prescription from Maltsev+2025, with additions from Willcox+2025 for the definition of BH masses.", + "version_added": "3.7.0" } ] }, @@ -1224,6 +1229,7 @@ "name": "fryer_mass_limit", "description": "Sets the mass limit to use when applying a remnant mass prescription from Fryer+12 (remnantflag=3 or 4).", "type": "dropdown", + "version_added": "3.7.2", "options-preface": "", "options": [ { @@ -1296,6 +1302,7 @@ "name": "maltsev_mode", "description": "Sets the mode to use Maltsev remnant mass prescription (only relevant if remnantflag = 6)", "type": "number", + "version_added": "3.7.0", "options-preface": "", "options": [ { @@ -1317,6 +1324,7 @@ "name": "maltsev_fallback", "description": "Sets the fallback fraction for partial fallback in the Maltsev remnant mass prescription (only relevant if remnantflag = 6). This fallback fraction, \\(f_{\\rm fallback}\\), is used to calculate the remnant mass by calculating \\(M_{\\rm rem} = M_{\\rm NS} + f_{\\rm fallback} (M_{\\rm core, total} - M_{\\rm NS})\\), where this prescription assumes that \\(M_{\\rm NS} = 1.4 \\, \\mathrm{M}_\\odot\\).", "type": "number", + "version_added": "3.7.0", "options-preface": "", "options": [ { @@ -1334,6 +1342,7 @@ "name": "maltsev_pf_prob", "description": "Sets the probability of partial fallback leading to BH formation occurring in the Maltsev remnant mass prescription when the CO core mass is in the partial fallback regime of \\(M_2 \\le M_{\\rm CO} \\le M_3\\) (only relevant if remnantflag = 6)", "type": "number", + "version_added": "3.7.0", "options-preface": "", "options": [ { From 082472aafbbe3bfd048c7789a3eb02ad1a6f8ad4 Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Wed, 18 Feb 2026 13:56:31 -0500 Subject: [PATCH 16/16] update changelog --- changelog.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index d6966756..a01f15ef 100644 --- a/changelog.md +++ b/changelog.md @@ -101,4 +101,14 @@ This release contains _several_ fixes to how CO core masses/remnant masses are h - WD chandrasekhar check use ``mc_co`` instead of ``mc`` - Remnant flags 0-4 inclusive use ``mc_co`` instead of ``mc`` - Got rid of ``mcx`` in ``assign_remnant`` in favour of clearer ``m_proto`` and ``m_FeNi`` to match the papers - - [Very minor] Fryer Rapid was using <= instead of < everywhere \ No newline at end of file + - [Very minor] Fryer Rapid was using <= instead of < everywhere + + +## 3.7.3 +- Additions/changes: + - Add new setting ``LBV_flag`` which allows one to turn off LBV winds, use Hurley+2000, or use Belcyznski+2008 + - Change the default LBV winds to Hurley + +- Documentation: + - Start new settings gallery in the documentation + - Tag settings/options with the version they were added in the docs page and auto link them to release \ No newline at end of file