-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_AGB.py
More file actions
181 lines (166 loc) · 5.81 KB
/
plot_AGB.py
File metadata and controls
181 lines (166 loc) · 5.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import pandas as pd
import matplotlib.pyplot as plt
import pylab as pb
import numpy as np
from nugridpy import nugridse as mp
from nugridpy import mesa as ms
#LOGS = '../mppnp/z1m2/m1p65z1m2' #13
#LOGS = '../mppnp/z2m2/m1p65z2m2' #18
#LOGS= '../mppnp/z1m2/m2z1m2' #20
#LOGS = '../mppnp/z2m2/m2z2m2' #30
LOGS = '../mppnp/z3m2/m2z3m2_mk2' #27
#LOGS = '../mppnp/z1m2/m3z1m2' #13
#LOGS = '../mppnp/z2m2/m3z2m2' #18
#LOGS = '../mppnp/z3m2/m3z3m2' #16
#LOGS = '../mppnp/z6m3/m2z6m3' #21
#LOGS = '../mppnp/z2m2/m1p85z2m2_hCBM' #22
#LOGS = '../mppnp/z1m2/m2z1m2_hCBM' #17
#LOGS = '../mppnp/z2m2/m2z2m2_hCBM' #20
#LOGS = '../mppnp/z2m2/m3z2m2_hCBM' #17
#LOGS = '../mppnp/z6m3/m2z6m3_hCBM' #15
#LOGS = '../mppnp/z6m3/m3z6m3_hCBM' #
LOGS1= LOGS.replace('_','\_')
MODEL = LOGS1[14:]
st1=ms.star_log(LOGS)
cutting=150000
shift_t0=0
t0_model=st1.find_first_TP()+shift_t0
t0_idx=int(t0_model-st1.get("model_number")[0])
first_TP_he_lum=10**(st1.get("log_LHe")[t0_idx])
he_lum=10**(st1.get("log_LHe")[t0_idx:])
h_lum=10**(st1.get("log_LH")[t0_idx:])
model=st1.get("model_number")[t0_idx:]
h1_bndry=st1.get("h1_boundary_mass")[t0_idx:]
##define label
z=st1.header_attr["initial_z"]
mass=st1.header_attr["initial_mass"]
leg=str(mass)+"M$_{\odot}$ Z= "+str(z)
peak_lum_model=[]
h1_mass_tp=[]
h1_mass_min_DUP_model=[]
##TP identification with he lum if within 1% of first TP luminosity
perc=0.01
min_TP_distance=300 #model
lum_1=[]
model_1=[]
h1_mass_model=[]
TP_counter=0
new_TP=True
TP_interpulse=False
interpulse_counter=0
for i in range(len(he_lum)):
if (h_lum[i]>he_lum[i]):
TP_interpulse=True
interpulse_counter+=1
if (h_lum[i]<he_lum[i]):
interpulse_counter=0
new_TP=True
TP_interpulse=False
if i > 0:
h1_mass_1.append(h1_bndry[i])
h1_mass_model.append(model[i])
if i ==0:
lum_1.append(first_TP_he_lum)
model_1.append(t0_model)
h1_mass_1=[h1_bndry[0]]
h1_mass_model=[t0_model]
else:
lum_1.append(he_lum[i])
model_1.append(model[i])
if (new_TP == True and TP_interpulse==True and interpulse_counter> 80):
max_value=np.array(lum_1).max()
max_index = lum_1.index(max_value)
peak_lum_model.append(model_1[max_index])
max_lum_idx=h1_mass_model.index(model_1[max_index])
min_value=np.array(h1_mass_1[max_lum_idx:]).min()
min_index = h1_mass_1.index(min_value)
h1_mass_min_DUP_model.append(h1_mass_model[min_index])
new_TP=False
modeln=[]
modeln1=[]
interp_md=[]
for i in range(len(peak_lum_model)):
modeln.append(int(peak_lum_model[i]))
modeln1.append(int(h1_mass_min_DUP_model[i]))
if i < (len(peak_lum_model)-1):
if ((peak_lum_model[i]+h1_mass_min_DUP_model[i])/2. < cutting):
interp_md.append(int((peak_lum_model[i]+h1_mass_min_DUP_model[i])/2.))
modeln2=[]
for i in modeln1:
modeln2.append(i-100)
run=mp.se(LOGS+'/H5_restart','restart.h5')
targets=np.unique(modeln2)
He4=[]
C12=[]
O16=[]
N14=[]
for cycle in targets:
He4.append(run.se.get(cycle,'iso_massf','He-4'))
C12.append(run.se.get(cycle,'iso_massf','C-12'))
O16.append(run.se.get(cycle,'iso_massf','O-16'))
N14.append(run.se.get(cycle,'iso_massf','N-14'))
print(cycle)
c125=[]
he45=[]
o165=[]
for j, item in enumerate(N14):
for i, line in enumerate(item):
if (N14[j][::-1][i] < 0.000000000001 and
He4[j][::-1][i] > 0.1 and
C12[j][::-1][i] > 0.1 and
O16[j][::-1][i] + C12[j][::-1][i] + He4[j][::-1][i] > 0.9):
he45.append(He4[j][::-1][i])
c125.append(C12[j][::-1][i])
o165.append(O16[j][::-1][i])
break
tp7=np.linspace(1,len(o165),len(o165))
plt.rcParams['text.usetex'] = True
plt.rcParams['axes.linewidth'] = 2
plt.rcParams['xtick.major.size'] = 20
plt.rcParams['xtick.major.width'] = 2
plt.rcParams['ytick.major.size'] = 20
plt.rcParams['ytick.major.width'] = 2
plt.rcParams['ytick.minor.size'] = 10
plt.rcParams['ytick.minor.width'] = 2
plt.tick_params(axis='both',which='both',pad=10,labelsize=30,direction='in')
plt.semilogy(tp7,o165,'ro-',markersize=15,label='$O^{16}$'+' '+'$'+MODEL+'$',lw=3)
plt.semilogy(tp7,c125,'g^-',markersize=15,label='$C^{12}$'+' '+'$'+MODEL+'$',lw=3)
plt.semilogy(tp7,he45,'bs-',markersize=15,label='$He^4$'+' '+'$'+MODEL+'$',lw=3)
plt.ylabel('$Mass$ $Fraction$ $(X)$', fontsize=40)
plt.xlabel('$TP$ $number$', fontsize=40)
plt.legend(prop={'size':25})
plt.show()
df = pd.read_csv('Werner,Herwig_2006_Table1.txt', sep='\t',usecols=[0,4,5,7],skiprows=[1,2,3,5,7,8,9,10,12])
x1 = df['He'].values
x2 = df['C'].values
x3 = df['O'].values
y1 = df['Spectral Class Star'].values
y=[1,2,3,4,5]
y2=[]
for i in y1:
y2.append('$'+i+'$')
plt.rcParams['text.usetex'] = True
plt.rcParams['xtick.major.size'] = 20
plt.rcParams['xtick.major.width'] = 2
plt.rcParams['ytick.major.size'] = 20
plt.rcParams['ytick.major.width'] = 2
plt.rcParams['ytick.minor.size'] = 10
plt.rcParams['ytick.minor.width'] = 2
plt.rcParams['xtick.labelsize'] = 30
plt.rcParams['ytick.labelsize'] = 30
plt.tick_params(axis='both',which='both',pad=5,direction='in')
plt.semilogy(y,x1,'bo',markersize=30,lw=2,linestyle='None')
plt.semilogy(y,x2,'gs',markersize=30,lw=2,linestyle='None')
plt.semilogy(y,x3,'r^',markersize=30,lw=2,linestyle='None')
plt.errorbar(y,x1,yerr=x1/2,marker='o',color='b',markersize=30,lw=2,linestyle='None',label='$He$')
plt.errorbar(y,x2,yerr=x2/2,marker='s',color='g',markersize=30,lw=2,linestyle='None',label='$C$')
plt.errorbar(y,x3,yerr=x3/2,marker='^',color='r',markersize=30,lw=2,linestyle='None',label='$O$')
#Model
plt.axhline(y=he45[-1:],color='b',lw=2.2, label='$He$'+' '+'$'+MODEL+'$')
plt.axhline(y=c125[-1:],color='g',lw=2.2,label='$C$'+' '+'$'+MODEL+'$')
plt.axhline(y=o165[-1:],color='r',lw=2.2,label='$O$'+' '+'$'+MODEL+'$')
plt.ylabel('$Mass$ $Fraction$ $(X)$', fontsize=40)
pb.xticks(y, y2)
plt.legend(loc='best',prop={'size':25})
plt.xlim(0.5,5.5)
plt.show()