In [56]:
%pylab
from nugridpy import mesa as ms
import os
In [85]:
# Before we start have a look at NuGrid Set1 model (Ritter+ 17)
ms.set_nugrid_path('/data/nugrid_apod2')
nsa=ms.star_log(mass=2,Z=0.0001)
In [86]:
# check we got the right model
nsa.header_attr
#nsa.get('surface_o16')[0]+nsa.get('surface_c12')[0]
Out[86]:
In [99]:
figure(101); shapes=['-',':','--','-.']; i=0
nsa.plot('model_number','log_LH',shape=shapes[mod(i,4)]); i+=1
nsa.plot('model_number','log_LHe',shape=shapes[mod(i,4)]); i+=1
title('Z='+str(nsa.header_attr['initial_z'])); ylim(2,8); xlim(0,40000); ylabel("log L shell")
Out[99]:
In [101]:
nsa.kippenhahn(102,'model'); xlim(0,40000)
Out[101]:
In [58]:
from nugridpy import utils as ut
In [59]:
data_dir='/data/nugrid_apod2/scratch/MESA/Set_M2Zrange/'
In [60]:
!ls $data_dir
In [61]:
cases = [ case for case in os.listdir(data_dir) if 'M2.00' in case]
cases.sort()
cases[0], cases[-1] = cases[-1], cases[0]
print(cases)
In [62]:
%%capture
sints=[]
for case in cases:
sints.append(ms.star_log(os.path.join(data_dir,case,'LOGS')))
In [63]:
ZZ=[]
for s in sints:
ZZ.append(s.header_attr['initial_z'])
print(ZZ )
In [64]:
figure(1)
for s in sints:
s.hrd_new()
In [65]:
figure(2)
shapes=['-',':','--','-.']; i=0
for s in sints:
s.plot('model_number','log_LH',shape=shapes[mod(i,4)],\
legend='Z='+str(s.header_attr['initial_z'])); i+=1
ylim(3,12); xlim(0,10000)
In [66]:
s.get('h1_boundary_mass')[-1]
Out[66]:
In [67]:
mhfree = []
for s in sints:
mhfree.append(s.get('h1_boundary_mass')[-1])
In [68]:
mhfree
Out[68]:
In [70]:
figure(121)
plot(log10(array(ZZ)),mhfree,'o')
xlabel('$ \log Z$'); ylabel('$M_\mathrm{H-free}$')
Out[70]:
In [72]:
modstart=4600; s=sints[3]
s.kip_cont(ifig=15, modstart=modstart, modstop=5300, \
t0_model=modstart, ixaxis='age', xres=2000, yres=2000, ylims=[0.58,0.62])
title('Z='+str(s.header_attr['initial_z']))
Out[72]:
In [73]:
shapes=['-',':','--','-.']; i=5
for s in sints[3:]:
close(i);figure(i)
s.kippenhahn_CO(i,'model'); i+=1
title('Z='+str(s.header_attr['initial_z']))
close(i);figure(i)
s.plot('model_number','log_LHe',shape=shapes[mod(i,3)]); i+=1
s.plot('model_number','log_LH',shape=shapes[mod(i,3)]); i+=1
ylim(3,12)
title('Shell luminosity evolution, Z='+str(s.header_attr['initial_z']))
In [74]:
modstart=3090; modstop=4100; s=sints[4]; ifig=16; close(ifig)
s.kip_cont(ifig=ifig, modstart=modstart, modstop=modstop, \
t0_model=modstart, ixaxis='age', xres=2000, yres=2000, ylims=[0.6,0.65])
title('Z='+str(s.header_attr['initial_z']))
Out[74]:
In [102]:
figure(201); shapes=['-',':','--','-.']; i=0
s.plot('model_number','log_LH',shape=shapes[mod(i,4)]); i+=1
s.plot('model_number','log_LHe',shape=shapes[mod(i,4)]); i+=1
title('Z='+str(s.header_attr['initial_z'])); ylim(2,12); xlim(3300,3500); ylabel("log L shell")
Out[102]:
In [180]:
modstart=3090; modstop=4100; s=sints[4]; ifig=19; close(ifig)
s.kip_cont(ifig=ifig, modstart=modstart, modstop=modstop, \
ixaxis='model_number', xres=2000, yres=2000, ylims=[0.6,0.65], xlims=[3300,3500])
title('Z='+str(s.header_attr['initial_z']))
Out[180]:
In [185]:
ifig=20; close(ifig); figure(ifig)
plot(s.get('model_number'),log10(s.get('surface_n14')+s.get('surface_c12')+\
s.get('surface_o16')),'-',label='CNO')
plot(s.get('model_number'),log10(s.get('surface_c12')+s.get('surface_o16')),':',label='CO')
plot(s.get('model_number'),log10(s.get('surface_c12')),'-.',label='C')
title('Z='+str(s.header_attr['initial_z'])); legend(loc=0)
Out[185]:
In [77]:
# Z = 1e-6
modstart=2820; modstop=3850; s=sints[5]; ifig=17; close(ifig)
s.kip_cont(ifig=ifig, modstart=modstart, modstop=modstop, \
t0_model=modstart, ixaxis='age', xres=2000, yres=2000, ylims=[0.62,0.66])
title('Z='+str(s.header_attr['initial_z']))
Out[77]:
In [245]:
%%capture
s5s=[]; case='M2.00Z1.e-5'
for i in range(3):
s5s.append(ms.star_log(os.path.join(data_dir,case,'LOGS'+str(i+1))))
In [269]:
figure(29)
for s in s5s:
s.plot('model_number','log_LHe',shape=shapes[mod(i+3,3)], legend='$L_He$_'+str(i))
s.plot('model_number','log_LH',shape=shapes[mod(i,3)],\
legend='$L_H$_'+str(i)); i+=1
ylim(3,12) #; xlim(750332457.29442167, 750332458.28505421)
Out[269]:
In [246]:
figure(30)
for s in s5s:
s.plot('star_age','log_LHe',shape=shapes[mod(i+3,3)], legend='$L_He$_'+str(i))
s.plot('star_age','log_LH',shape=shapes[mod(i,3)],\
legend='$L_H$_'+str(i)); i+=1
ylim(3,12); xlim(750332457.29442167, 750332458.28505421)
Out[246]:
In [247]:
s=s5s[-1]
t = s.get('star_age')
LH = s.get('log_LH'); LHe = s.get('log_LHe')
In [248]:
mod0=where(s.get('model_number')==15000)[0][0]
print(s.get('model_number')[mod0])
In [273]:
21./3600
Out[273]:
In [272]:
figure(28)
s=s5s[-1]
s.plot('model_number','log_LH',shape='o',legend='$L_H$_'); i+=1
s.plot('model_number','log_LHe',shape=shapes[1], legend='$L_He$_')
ylim(3,12)
Out[272]:
In [268]:
close(31); figure(31,figsize=(6, 4), dpi=125)
t0 = t[mod0]; tend = t[where(s.get('model_number')==32000)[0][0]]
plot(t-t[mod0],LH,shapes[0], label='$L_\mathrm{H}$')
plot(t-t[mod0],LHe,shapes[2], label='$L_\mathrm{He}$')
legend(loc=2)
ylim(3,11); xlim(0,tend-t0)
xlabel('t/yr'); ylabel('$\log \ L_\mathrm{shell}/L_\odot$')
savefig('TP_stellar_evolution_shell_L.pdf')
In [139]:
print(k) for k in s.cols and
Out[139]:
In [254]:
[ print(k) for k in s.cols.keys() if 'bound' in k]
Out[254]:
In [252]:
figure(301);s5s[-1].plot('model_number','h1_boundary_mass')
In [258]:
figure(309) #s5s[-1].plot('model_number','h1_boundary_radius')
plot(s5s[-1].get('model_number'),\
s5s[-1].get('h1_boundary_radius')*ast.rsun_cm/1.e5,'o')
title('radius of H-free core immediately before and during HIF')
ylabel('radius $M_\mathrm{H-free}$ / [Mm]')
xlabel('model number')
Out[258]:
In [263]:
#amount of mass by which M_Hfree decreases at the first time step of H-ingestion
# 0.0060725578854978757 Msun
# delta_R by which the H-free core is reduced during the one time step when the HIF starts:
delta_R = 1000*(30.5 - 21.5)
print('delta_R H-free: ','%7.1fkm'%(delta_R))
print('delta_R H-free: ','%7.1fHp'%(delta_R/Hp))
# model number after which HIF happens:
mod_phif = 29420
In [265]:
5200/Hp
Out[265]:
In [253]:
figure(302);s.plot('model_number','log_dt');xlim((29349, 29448))
Out[253]:
In [266]:
# time step just before the HIF:
dt_evol = 10**-3.945 * 3.14e7/3600 # in hours
print("Time step just before HIF: ","%4.2fhr"%dt_evol)
dt_evol = 10**-5.27 * 3.14e7/60 # in min
print("Third time step into HIF: ","%4.2fmin"%dt_evol)
dt_evol = 10**-6.175 * 3.14e7 # in sec
print("Time step in developed HIF: ","%4.2fs"%dt_evol)
In [175]:
case='M2.00Z1.e-5' ; print(mod_phif)
pphif=ms.mesa_profile(os.path.join(data_dir,case,'LOGS3'),mod_phif)
In [221]:
# look for variables containing velocity
[ print(k) for k in pphif.cols.keys() if 'pres' in k]
Out[221]:
In [188]:
figure(303)
pphif.plot('mass','conv_vel_div_csound',logy=True)
xlim(0.6,0.65)
Out[188]:
In [215]:
figure(304)
pphif.plot('mass','log_conv_vel',shape='--')
xlim(0.6,0.65);ylim(3,6)
Out[215]:
In [238]:
# range for Ma numbers in convection zone just before HIF
sef = '%10.3e'
print(sef%(10**-2.8),sef%(10**-2.895))
In [222]:
figure(306)
pphif.plot('mass','pressure_scale_height',logy=True)
xlim(0.6,0.65)
Out[222]:
In [234]:
# pressure scale height in convection zone
Hp = 1.e-5*ast.rsun_cm*10**-2.3 # km
print("pressure scale height: ","%6.1fkm"%Hp)
In [216]:
figure(305)
#pphif.plot('radius','log_conv_vel')
plot(pphif.get('radius')*ast.rsun_cm/1.e5,1.e-5*10**pphif.get('log_conv_vel'))
xlim(5900, 38800); ylim(0, 2)
xlabel('radius / [Mm]'); ylabel('$v_\mathrm{conv}$ / [km/s]')
title('convective velocity in PDCZ')
Out[216]:
In [230]:
delta_R_conv = (30.38-11.25)*1e3 # km
v_conv = 1.5 # km/s
t_conv = delta_R_conv/v_conv
print('convection zone crossing time: ',t_conv/3600.,"hr")
t_conv = 1.7*Hp/v_conv
print('convective turnover: ',t_conv/3600.,"hr")
In [283]:
R_c = 15.e8 # cm
M_PDCZ = 2e-2 # Msun
M_c = 0.61 # Msun
Lh = 10**10.5 # Lsun
t_conv = 3600 # s
Lh*ast.lsun_erg_s*t_conv*R_c/(2.*ast.grav_const*M_PDCZ*M_c*ast.msun_g**2)
Out[283]:
In [278]:
E_velconv = 0.5*M_PDCZ*ast.msun_g*(v_conv * 1.e5)**2
In [279]:
Lh*ast.lsun_erg_s*t_conv/E_velconv
Out[279]:
In [280]:
Lh*ast.lsun_erg_s*t_conv
Out[280]:
In [282]:
10**5.9*ast.lsun_erg_s*t_conv/E_velconv
Out[282]:
In [ ]: