@@ -114,7 +114,7 @@ def get_independent_sampler(
114
114
Duration of constant star formation beginning from SF_Start in Myr
115
115
116
116
binfrac_model : `str or float`
117
- Model for binary fraction; choices include: vanHaaften or a fraction where 1.0 is 100% binaries
117
+ Model for binary fraction; choices include: vanHaaften, offner22, or a fraction where 1.0 is 100% binaries
118
118
119
119
binfrac_model_msort : `str or float`
120
120
Same as binfrac_model for M>msort
@@ -601,6 +601,7 @@ def binary_select(self, primary_mass, binfrac_model=0.5, **kwargs):
601
601
either a binary fraction specified by a float or a
602
602
primary-mass dependent binary fraction following
603
603
`van Haaften et al.(2009) <http://adsabs.harvard.edu/abs/2013A%26A...552A..69V>`_ in appdx
604
+ or `Offner et al.(2022) <https://arxiv.org/abs/2203.10066>`_ in fig 1
604
605
605
606
Parameters
606
607
----------
@@ -609,6 +610,9 @@ def binary_select(self, primary_mass, binfrac_model=0.5, **kwargs):
609
610
610
611
binfrac_model : str or float
611
612
vanHaaften - primary mass dependent and ONLY VALID up to 100 Msun
613
+
614
+ offner22 - primary mass dependent
615
+
612
616
float - fraction of binaries; 0.5 means 2 in 3 stars are a binary pair while 1
613
617
means every star is in a binary pair
614
618
@@ -650,13 +654,35 @@ def binary_select(self, primary_mass, binfrac_model=0.5, **kwargs):
650
654
binary_choose_low = np .random .uniform (
651
655
0 , 1.0 , primary_mass [lowmassIdx ].size )
652
656
657
+ (singleIdx_low ,) = np .where (
658
+ binary_fraction_low < binary_choose_low )
659
+ (binaryIdx_low ,) = np .where (
660
+ binary_fraction_low >= binary_choose_low )
661
+ elif binfrac_model == "offner22" :
662
+ from scipy .interpolate import BSpline
663
+ t = [0.0331963853 , 0.0331963853 , 0.0331963853 , 0.0331963853 , 0.106066017 ,
664
+ 0.212132034 , 0.424264069 , 0.866025404 , 1.03077641 , 1.11803399 ,
665
+ 1.95959179 , 3.87298335 , 6.32455532 , 11.6619038 , 29.1547595 ,
666
+ 40 , 50 , 60 , 70 , 80 , 90 , 100 , 110 , 120 , 130 , 150 , 150 , 150 , 150 ]
667
+ c = [0.08 , 0.15812003 , 0.20314101 , 0.23842953 , 0.33154153 , 0.39131739 ,
668
+ 0.46020725 , 0.59009569 , 0.75306454 , 0.81652502 , 0.93518422 , 0.92030594 ,
669
+ 0.96 , 0.96 , 0.96 , 0.96 , 0.96 , 0.96 , 0.96 , 0.96 , 0.96 , 0.96 , 0.96 , 0.96 , 0.96 ]
670
+ k = 3
671
+ def offner_curve (x ):
672
+ a = - 0.16465041
673
+ b = - 0.11616329
674
+ return np .piecewise (x , [x < 6.4 , x >= 6.4 ], [BSpline (t ,c ,k ), lambda x : a * np .exp (b * x ) + 0.97 ])
675
+ binary_fraction_low = offner_curve (primary_mass [lowmassIdx ])
676
+ binary_choose_low = np .random .uniform (
677
+ 0 , 1.0 , primary_mass [lowmassIdx ].size )
678
+
653
679
(singleIdx_low ,) = np .where (
654
680
binary_fraction_low < binary_choose_low )
655
681
(binaryIdx_low ,) = np .where (
656
682
binary_fraction_low >= binary_choose_low )
657
683
else :
658
684
raise ValueError (
659
- "You have supplied a non-supported binary fraction model. Please choose vanHaaften or a float"
685
+ "You have supplied a non-supported binary fraction model. Please choose vanHaaften, offner22, or a float"
660
686
)
661
687
elif type (binfrac_model ) == float :
662
688
if (binfrac_model <= 1.0 ) & (binfrac_model >= 0.0 ):
@@ -675,7 +701,7 @@ def binary_select(self, primary_mass, binfrac_model=0.5, **kwargs):
675
701
)
676
702
else :
677
703
raise ValueError (
678
- "You have not supplied a model or a fraction. Please choose either vanHaaften or a float"
704
+ "You have not supplied a model or a fraction. Please choose either vanHaaften, offner22, or a float"
679
705
)
680
706
681
707
# --- if using a different binary fraction for high-mass systems
@@ -686,13 +712,35 @@ def binary_select(self, primary_mass, binfrac_model=0.5, **kwargs):
686
712
binary_choose_high = np .random .uniform (
687
713
0 , 1.0 , primary_mass [highmassIdx ].size )
688
714
715
+ (singleIdx_high ,) = np .where (
716
+ binary_fraction_high < binary_choose_high )
717
+ (binaryIdx_high ,) = np .where (
718
+ binary_fraction_high >= binary_choose_high )
719
+ elif binfrac_model_msort == "offner22" :
720
+ from scipy .interpolate import BSpline
721
+ t = [0.0331963853 , 0.0331963853 , 0.0331963853 , 0.0331963853 , 0.106066017 ,
722
+ 0.212132034 , 0.424264069 , 0.866025404 , 1.03077641 , 1.11803399 ,
723
+ 1.95959179 , 3.87298335 , 6.32455532 , 11.6619038 , 29.1547595 ,
724
+ 40 , 50 , 60 , 70 , 80 , 90 , 100 , 110 , 120 , 130 , 150 , 150 , 150 , 150 ]
725
+ c = [0.08 , 0.15812003 , 0.20314101 , 0.23842953 , 0.33154153 , 0.39131739 ,
726
+ 0.46020725 , 0.59009569 , 0.75306454 , 0.81652502 , 0.93518422 , 0.92030594 ,
727
+ 0.96 , 0.96 , 0.96 , 0.96 , 0.96 , 0.96 , 0.96 , 0.96 , 0.96 , 0.96 , 0.96 , 0.96 , 0.96 ]
728
+ k = 3
729
+ def offner_curve (x ):
730
+ a = - 0.16465041
731
+ b = - 0.11616329
732
+ return np .piecewise (x , [x < 6.4 , x >= 6.4 ], [BSpline (t ,c ,k ), lambda x : a * np .exp (b * x ) + 0.97 ])
733
+ binary_fraction_high = offner_curve (primary_mass [highmassIdx ])
734
+ binary_choose_high = np .random .uniform (
735
+ 0 , 1.0 , primary_mass [highmassIdx ].size )
736
+
689
737
(singleIdx_high ,) = np .where (
690
738
binary_fraction_high < binary_choose_high )
691
739
(binaryIdx_high ,) = np .where (
692
740
binary_fraction_high >= binary_choose_high )
693
741
else :
694
742
raise ValueError (
695
- "You have supplied a non-supported binary fraction model. Please choose vanHaaften or a float"
743
+ "You have supplied a non-supported binary fraction model. Please choose vanHaaften, offner22, or a float"
696
744
)
697
745
elif (binfrac_model_msort is not None ) and (type (binfrac_model_msort ) == float ):
698
746
if (binfrac_model_msort <= 1.0 ) & (binfrac_model_msort >= 0.0 ):
@@ -711,7 +759,7 @@ def binary_select(self, primary_mass, binfrac_model=0.5, **kwargs):
711
759
)
712
760
elif (binfrac_model_msort is not None ):
713
761
raise ValueError (
714
- "You have not supplied a model or a fraction. Please choose either vanHaaften or a float"
762
+ "You have not supplied a model or a fraction. Please choose either vanHaaften, offner22, or a float"
715
763
)
716
764
717
765
0 commit comments