Skip to content

Commit 9804686

Browse files
committed
Fix Merge head
2 parents 5bf619f + 6f7adb1 commit 9804686

File tree

4 files changed

+144
-139
lines changed

4 files changed

+144
-139
lines changed

spisea/evolution.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import pdb
88
import warnings
99
from astropy.table import Table, vstack, Column
10+
import astropy.constants as cs
11+
import astropy.units as un
1012
from scipy import interpolate
1113
import pylab as py
1214
from spisea.utils import objects
@@ -1697,6 +1699,9 @@ def isochrone(self, filePath='', age=1 * 10 ** 8.1, metallicity=0.0,
16971699
as follows:
16981700
White dwarf -> 101
16991701
All other stars (no neutron stars or black holes) -> -1
1702+
Just to make sure, I do have word that neutron stars
1703+
and black holes are NOT INCLUDED in the BPASS
1704+
evolution grids.
17001705
If you are REALLY curious about black holes, try using TUI
17011706
with BPASS.
17021707
"""
@@ -1739,10 +1744,8 @@ def isochrone(self, filePath='', age=1 * 10 ** 8.1, metallicity=0.0,
17391744
isWR = Column([False] * len(iso), name='isWR')
17401745
isWR2 = Column([False] * len(iso), name='isWR2')
17411746
colG = Column([0.0] * len(iso), name='logg')
1742-
currentMass = Column([0.0] * len(iso), name='mass_current')
17431747
colP = Column([-1] * len(iso), name='phase')
17441748
colP2 = Column([-1] * len(iso), name='phase2')
1745-
colTWR= Column([np.nan]*len(iso), name='logT_WR')
17461749
iso.add_column(colG)
17471750
iso.add_column(isWR)
17481751
iso.add_column(currentMass)
@@ -1752,20 +1755,18 @@ def isochrone(self, filePath='', age=1 * 10 ** 8.1, metallicity=0.0,
17521755
# We may as well delete a for loop here
17531756

17541757
iso['age']=np.log10(iso['age'])
1755-
iso['logg'] = np.log10(( iso['M1'] * cs.GM_sun / ((cs.R_sun) ** 2))*un.s*un.s/un.m)
1756-
iso['logg2'] = np.log10(( iso['M2'] * cs.GM_sun / ((cs.R_sun) ** 2))*un.s*un.s/un.m)
1758+
iso['logg'] = np.log10(( iso['M1'] * cs.GM_sun / ((10**iso['log(R1)']*cs.R_sun) ** 2))*un.s*un.s/un.m)
1759+
iso['logg2'] = np.log10(( iso['M2'] * cs.GM_sun / ((10**iso['log(R2)']*cs.R_sun) ** 2))*un.s*un.s/un.m)
1760+
iso.rename_column('M1', 'mass_current')
17571761
for x in iso:
17581762
x['age'] = np.log10(x['age'])
1759-
x['mass_current'] = x['M1']
17601763

17611764
# Using Stanway and Elridge Criterion for calculating whether
17621765
# a star is a WR star or not for using the PotsDam Atmospheres
17631766

17641767
x['isWR'] = x['X'] < 0.40 and x['log(T1)'] > 4.45
17651768
x['isWR']=x['isWR'] and x['secondary']
17661769
x['isWR2']=x['isWR']
1767-
if x['isWR']:
1768-
x['logT_WR']=x['log(T1)']
17691770

17701771
# Calculated logg=log10(Mass*G/(Radius of the star)^2)
17711772
# I made one solar radius equal to 695508 * 10 ** 3 meters

spisea/imf/imf.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def generate_cluster(self, totalMass, seed=None):
113113
# Generate output arrays.
114114
masses = np.array([], dtype=float)
115115
isMultiple = np.array([], dtype=bool)
116-
compMasses = []
116+
compMasses = np.array([], dtype=np.object)
117117
systemMasses = np.array([], dtype=float)
118118

119119
# Loop through and add stars to the cluster until we get to
@@ -139,8 +139,8 @@ def generate_cluster(self, totalMass, seed=None):
139139

140140
# Dealing with multiplicity
141141
if self._multi_props != None:
142-
compMasses = np.empty((len(newMasses),), dtype=np.object)
143-
compMasses.fill([])
142+
newCompMasses = np.empty((len(newMasses),), dtype=np.object)
143+
newCompMasses.fill([])
144144

145145
# Determine the multiplicity of every star
146146
MF = self._multi_props.multiplicity_fraction(newMasses)
@@ -152,13 +152,14 @@ def generate_cluster(self, totalMass, seed=None):
152152
newSystemMasses = newMasses.copy()
153153

154154
# Function to calculate multiple systems more efficiently
155-
compMasses, newSystemMasses, newIsMultiple = self.calc_multi(newMasses, compMasses,
156-
newSystemMasses, newIsMultiple,
157-
CSF, MF)
155+
newCompMasses, newSystemMasses, newIsMultiple = self.calc_multi(newMasses, newCompMasses,
156+
newSystemMasses, newIsMultiple,
157+
CSF, MF)
158158

159159
newTotalMassTally = newSystemMasses.sum()
160160
isMultiple = np.append(isMultiple, newIsMultiple)
161161
systemMasses = np.append(systemMasses, newSystemMasses)
162+
compMasses = np.append(compMasses, newCompMasses)
162163
else:
163164
newTotalMassTally = newMasses.sum()
164165

spisea/imf/tests/test_imf.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ def test_generate_cluster():
2424
# range of the requested mass.
2525
assert np.abs(M_cl - sysMass.sum()) < 120.0
2626

27-
return
27+
# Check that enough companions were generated.
28+
# Should be greater than 25% of the stars with companions.
29+
mdx = np.where(isMulti)[0]
30+
for mm in mdx:
31+
assert len(compMass[mm]) > 0
2832

33+
return
2934

3035
def test_prim_power():
3136
from .. import imf

0 commit comments

Comments
 (0)