-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathplot_M67withBSS_tracks.py
More file actions
80 lines (66 loc) · 2.53 KB
/
Copy pathplot_M67withBSS_tracks.py
File metadata and controls
80 lines (66 loc) · 2.53 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
"""
Minimal routine for running a stellar evolution code.
"""
from amuse.lab import *
from matplotlib import pyplot
from amuse.examples import plot_M67Data
TBSS = [6170, 6820, 6675, 7050, 6650]
LBSS = [12.259, 11.078, 12.127, 11.226, 12.892]
def single_star_evolution(M, z, model_time):
stellar = SeBa()
stellar.parameters.metallicity = z
stellar.particles.add_particle(Particle(mass=M))
stellar.commit_particles()
initial_luminosity = stellar.particles.luminosity
dt = 1 | units.Myr
time = 0 | units.Myr
L = [] | units.LSun
T = [] | units.K
while stellar.particles[0].age<model_time:
time += dt
stellar.evolve_model(time)
L.append(stellar.particles[0].luminosity)
T.append(stellar.particles[0].temperature)
final_luminosity = stellar.particles.luminosity
print("L(t=0)=", initial_luminosity, \
", L (t=", stellar.particles.age, ")=", \
final_luminosity, stellar.particles.radius)
stellar.stop()
return L, T
def new_option_parser():
from amuse.units.optparse import OptionParser
result = OptionParser()
result.add_option("-M", unit= units.MSun,
dest="M", type="float",default = 1.7 | units.MSun,
help="stellar mass [1.0] %unit")
result.add_option("-t", unit = units.Myr,
dest="model_time", type="float",
default = 4000.0|units.Myr,
help="end time of the simulation [4.7] %unit")
result.add_option("-z", dest="z", type="float",
default = 0.02, help="metalicity [0.02]")
return result
if __name__ in ('__main__', '__plot__'):
o, arguments = new_option_parser().parse_args()
pyplot.figure()
pyplot.xlabel("T [$K$]")
pyplot.ylabel("L [$L_\odot$]")
axes = pyplot.gca()
axes.set_yscale('log')
axes.tick_params(pad=7)
L, T = single_star_evolution(M=1.4|units.MSun, z=0.04,
model_time=4|units.Gyr)
pyplot.plot(T.value_in(units.K),L.value_in(units.LSun))
L, T = single_star_evolution(**o.__dict__)
pyplot.plot(T.value_in(units.K),L.value_in(units.LSun))
m67 = plot_M67Data.Cluster()
m67.read()
pyplot.scatter(m67.Teff, m67.L, lw=0, s=100)
pyplot.scatter(TBSS, LBSS, lw=0, s=250)
pyplot.scatter(TBSS[3], LBSS[3], lw=0, s=250)
pyplot.xlim(9000, 4000)
pyplot.ylim(1, 50)
save_file = 'fig_M67withBSS_tracks.png'
pyplot.savefig(save_file)
print('\nSaved figure in file', save_file,'\n')
pyplot.show()