In [1]:
%pylab inline
from matplotlib.pyplot import *
from numpy import *
In [2]:
alpha=[1.593890e3,2.706708e3,1.466143e2,4.141960e-2,3.426349e-1]
beta=[2.053038e3,1.483131e3,-1.048442e2,4.564888e-2,0.0]
gamma=[1.231226e3,5.772723e2,-6.795374e1,2.958542e-2,0.0]
eta=[2.327785e2,7.411230e1,-1.391127e1,5.571483e-3,0.0]
In [7]:
def f_lft(mass,z):
""" calculate MS lifetime based on mass and metallization
Parameters
---------
mass: MS mass in M_sun
z: 0.02 as solar metallicity
Returns
-----
MS lifetime in the form of mass
"""
ksi=log10(z/0.02)
a=lambda n: alpha[n-1]+beta[n-1]*ksi+gamma[n-1]*ksi**2+eta[n-1]*ksi**3
T=lambda M: (a(1)+a(2)*M**4+a(3)*M**5.5+M**7)/(a(4)*M**2+a(5)*M**7)
return map(T,mass)
In [8]:
mass=10**linspace(-0.4,2.8,33)
l1=loglog(mass,f_lft(mass,0.0001),'-+b','0.0001')
l2=loglog(mass,f_lft(mass, 0.003),'-*r','0.03')
grid(True)
l3=loglog([10**-0.5,10**3],[10,10]) # Minimum timestep & the corresponding mass
xlim([10**-0.6,10**3])
ylim([10**0.2,10**5.5])
xlabel("Mass [$M_\odot$]")
ylabel("MS lifetime [$Myr$]")
title("Main Sequence lifetime against stellar Mass")
Out[8]:
MS lifetime for different stellar mass
In [71]:
# find y value at given x value
np.interp(100, xvalues, yvalues)
Out[71]:
In [ ]: