Skip to content

Commit 60d1d78

Browse files
committed
add meson back in
2 parents 90c2f56 + b3b9518 commit 60d1d78

File tree

5 files changed

+55
-120
lines changed

5 files changed

+55
-120
lines changed

.gitignore

-104
This file was deleted.

src/cosmic/evolve.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def evolve(cls, initialbinarytable, pool=None, **kwargs):
250250
# check the initial conditions of the system and warn user if
251251
# anything is weird about them, such as the star starts
252252
# in Roche Lobe overflow
253-
utils.check_initial_conditions(initialbinarytable)
253+
utils.check_initial_conditions(initialbinarytable,SSEDict)
254254

255255
# assign some columns based on keyword arguments but that
256256
# can be overwritten by the params or BSEDict
@@ -526,6 +526,8 @@ def _evolve_single_system(f):
526526
_evolvebin.se_flags.using_sse = False
527527
path_to_tracks = f["path_to_tracks"]
528528
path_to_he_tracks = f["path_to_he_tracks"]
529+
else:
530+
raise ValueError("Use either 'sse' or 'metisse' as stellar engine")
529531

530532
[bpp_index, bcm_index, kick_info] = _evolvebin.evolv2([f["kstar_1"], f["kstar_2"]],
531533
[f["mass_1"], f["mass_2"]],

src/cosmic/sample/sampler/independent.py

+21-5
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def get_independent_sampler(
4545
SF_duration,
4646
binfrac_model,
4747
met,
48+
SSEDict=None,
4849
size=None,
4950
total_mass=np.inf,
5051
sampling_target="size",
@@ -159,6 +160,8 @@ def get_independent_sampler(
159160
n_binaries : `int`
160161
Number of binaries needed to generate a population
161162
"""
163+
164+
162165
if sampling_target == "total_mass" and (total_mass is None or total_mass == np.inf):
163166
raise ValueError("If `sampling_target == 'total mass'` then `total_mass` must be supplied")
164167
if size is None and (total_mass is None or total_mass == np.inf):
@@ -284,8 +287,8 @@ def get_independent_sampler(
284287

285288
zsun = kwargs.pop("zsun", 0.02)
286289

287-
rad1 = initconditions.set_reff(mass1_binary, metallicity=met, zsun=zsun)
288-
rad2 = initconditions.set_reff(mass2_binary, metallicity=met, zsun=zsun)
290+
rad1 = initconditions.set_reff(SSEDict, mass1_binary, metallicity=met, zsun=zsun)
291+
rad2 = initconditions.set_reff(SSEDict, mass2_binary, metallicity=met, zsun=zsun)
289292

290293
# sample periods and eccentricities
291294
# if the porb_model is moe19, the metallicity needs to be supplied
@@ -1072,7 +1075,7 @@ def set_kstar(self, mass):
10721075

10731076
return kstar
10741077

1075-
def set_reff(self, mass, metallicity, zsun=0.02):
1078+
def set_reff(self, SSEDict ,mass, metallicity, zsun=0.02):
10761079
"""
10771080
Better way to set the radii from BSE, by calling it directly
10781081
@@ -1092,12 +1095,25 @@ def set_reff(self, mass, metallicity, zsun=0.02):
10921095

10931096
_evolvebin.metvars.zsun = zsun
10941097

1098+
if (SSEDict == None) or (SSEDict["stellar_engine"] == "sse"):
1099+
_evolvebin.se_flags.using_sse = True
1100+
_evolvebin.se_flags.using_metisse = False
1101+
path_to_tracks = ""
1102+
path_to_he_tracks = ""
1103+
elif SSEDict["stellar_engine"] == "metisse":
1104+
_evolvebin.se_flags.using_metisse = True
1105+
_evolvebin.se_flags.using_sse = False
1106+
path_to_tracks = SSEDict["path_to_tracks"]
1107+
path_to_he_tracks = SSEDict["path_to_he_tracks"]
1108+
else:
1109+
raise ValueError("Use either 'sse' or 'metisse' as stellar engine")
1110+
10951111
idx = 0
10961112
while total_length > max_array_size:
10971113
## cycle through the masses max_array_size number at a time
10981114
temp_mass = mass[idx*max_array_size:(idx+1)*max_array_size]
10991115

1100-
temp_radii = _evolvebin.compute_r(temp_mass,metallicity,max_array_size)
1116+
temp_radii = _evolvebin.compute_r(temp_mass,metallicity,max_array_size,path_to_tracks,path_to_he_tracks)
11011117

11021118
## put these in the radii array
11031119
radii[idx*max_array_size:(idx+1)*max_array_size] = temp_radii
@@ -1111,7 +1127,7 @@ def set_reff(self, mass, metallicity, zsun=0.02):
11111127
temp_mass = np.zeros(max_array_size)
11121128
temp_mass[:length_remaining] = mass[-length_remaining:]
11131129

1114-
temp_radii = _evolvebin.compute_r(temp_mass,metallicity,length_remaining)
1130+
temp_radii = _evolvebin.compute_r(temp_mass,metallicity,length_remaining,path_to_tracks,path_to_he_tracks)
11151131

11161132
#finish up the array
11171133
radii[-length_remaining:] = temp_radii[:length_remaining]

src/cosmic/src/comprad.f

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
***
2-
SUBROUTINE compute_r(mass,z,num,rad)
2+
SUBROUTINE compute_r(mass,z,num,rad,
3+
& path_to_tracks,path_to_he_tracks)
34
IMPLICIT NONE
45
INCLUDE 'const_bse.h'
56

@@ -17,8 +18,9 @@ SUBROUTINE compute_r(mass,z,num,rad)
1718
PARAMETER(loop=100000)
1819
real*8 mass(loop),rad(loop),z
1920
integer k,kstar,num
20-
real*8 mt,tm,tn,mass0,age,lum,mc,rc,me,re
21+
real*8 mt,tm,tn,mass0,age,lum,mc,rc,me,re,dtm
2122
REAL*8 tscls(20),lums(10),GB(10),zpars(20),k2,bhspin
23+
CHARACTER*256 path_to_tracks,path_to_he_tracks
2224

2325
***
2426
* f2py directives go here; we'll return the radii as a 10^5 array
@@ -29,7 +31,11 @@ SUBROUTINE compute_r(mass,z,num,rad)
2931
Cf2py intent(in) num
3032
Cf2py intent(out) rad
3133

32-
CALL zcnsts(z,zpars)
34+
if(using_METISSE) CALL initialize_front_end('cosmic')
35+
CALL zcnsts(z,zpars,path_to_tracks,path_to_he_tracks)
36+
37+
if(using_METISSE) call allocate_track(num,mass)
38+
3339

3440
***
3541
* Then just loop through everything
@@ -46,11 +52,15 @@ SUBROUTINE compute_r(mass,z,num,rad)
4652
kstar = 0
4753
if(mt.ge.0.7) kstar = 1
4854
bhspin = 0.d0
49-
rc = 0.d0
50-
CALL star(kstar,mass0,mt,tm,tn,tscls,lums,GB,zpars)
55+
rc = 0.d0
56+
dtm = 0.d0
57+
CALL star(kstar,mass0,mt,tm,tn,tscls,lums,GB,zpars,dtm,k)
5158
CALL hrdiag(mass0,age,mt,tm,tn,tscls,lums,GB,zpars,
5259
& rad(k),lum,kstar,mc,rc,me,re,k2,bhspin,k)
53-
60+
5461
10 continue
62+
63+
64+
if (using_METISSE) call dealloc_track()
5565

5666
END SUBROUTINE compute_r

src/cosmic/utils.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -1604,13 +1604,14 @@ def error_check(BSEDict, SSEDict, filters=None, convergence=None, sampling=None)
16041604
return
16051605

16061606

1607-
def check_initial_conditions(full_initial_binary_table):
1607+
def check_initial_conditions(full_initial_binary_table, SSEDict):
16081608
"""Checks initial conditions and reports warnings
16091609
16101610
Only warning provided right now is if star begins in Roche lobe
16111611
overflow
16121612
"""
1613-
1613+
from cosmic import _evolvebin
1614+
16141615
def rzamsf(m):
16151616
"""A function to evaluate Rzams
16161617
( from Tout et al., 1996, MNRAS, 281, 257 ).
@@ -1637,10 +1638,20 @@ def rzamsf(m):
16371638

16381639
if np.all(mass2 == 0.0):
16391640
return
1640-
else:
1641+
elif (SSEDict["stellar_engine"] == "sse"):
16411642
rzams1 = rzamsf(mass1)
16421643
rzams2 = rzamsf(mass2)
1643-
1644+
1645+
# TODO: the following section with METISSE is incomplete
1646+
# elif (SSEDict["stellar_engine"] == "metisse"):
1647+
# _evolvebin.se_flags.using_sse = False
1648+
# _evolvebin.se_flags.using_metisse = True
1649+
# path_to_tracks = SSEDict["path_to_tracks"]
1650+
# path_to_he_tracks = SSEDict["path_to_he_tracks"]
1651+
1652+
# rzams1 = _evolvebin.compute_r(mass1,z,len(mass1),path_to_tracks,path_to_he_tracks)
1653+
# rzams1 = _evolvebin.compute_r(mass2,z,len(mass2),path_to_tracks,path_to_he_tracks)
1654+
16441655
# assume some time step in order to calculate sep
16451656
yeardy = 365.24
16461657
aursun = 214.95

0 commit comments

Comments
 (0)