In [1]:
# Import some numerical math and plotting packages
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# Import the MesaProfile package
from MesaProfile import MesaProfile
# Import the OrderedDict package for working with MesaProfile outputs
from collections import OrderedDict
In [2]:
# Read the input MESA profile
mesa = MesaProfile('profile64.data')
mstar = mesa.getStar()
In [3]:
# List the data fields available in the profile
for k in mstar.keys():
print(k)
In [4]:
# Find out what isotopes the profile contains
isotope_list = mesa.getIsotopes()
nisotopes = len(isotope_list)
print('The MESA profile contains {} isotopes.'.format(nisotopes))
In [5]:
# Plot the abundances in the profile
# Yellow is high mass number isotopes, purple is low mass number isotopes
fig, ax = plt.subplots()
colormap = plt.get_cmap('viridis')
isocolors = [colormap(i) for i in np.linspace(0, 1, nisotopes)]
legend_handles = []
for i, isotope in enumerate(isotope_list):
handle = ax.plot(mstar['mass'], mstar[isotope], color=isocolors[i], label=isotope)
legend_handles.append(handle)
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
ax.set_xlabel('Mass ($M_\\odot$)')
ax.set_ylabel('Mass Fractions')
Out[5]:
In [6]:
# Plot the electron fraction (Ye) profile
#Number of electrons that you have for every baryon in your plasma. If you have extra neutrons,
# the fraction will go below .5
fig, ax = plt.subplots()
ax.plot(mstar['mass'],mstar['ye'],'b')
ax.set_xlabel('Mass ($M_\\odot$)')
ax.set_ylabel('Electron Fraction ($\\mathrm{Y_e}$)')
Out[6]:
In [40]:
# Plot the density profile
fig, ax = plt.subplots()
x = mstar['mass']
y = 10.0**mstar['logRho']
ax.plot(x,y,'b')
ax.set_xlabel('Mass ($M_\\odot$)')
ax.set_ylabel('Density ($g/cm^3$)')
print(x[0], y[0])
In [38]:
# Plot the temperature profile
fig, ax = plt.subplots()
x = mstar['mass']
y = 10.0**mstar['logT']
ax.plot(x,y,'b')
ax.set_xlabel('Mass ($M_\\odot$)')
ax.set_ylabel('Temperature ($K$)')
print(x[0], y[0])
In [39]:
# Plot the mass-radius profile
fig, ax = plt.subplots()
x = mstar['radiuscm']
y = mstar['mass']
ax.plot(x,y,'b')
ax.set_xlabel('Radius (cm)')
ax.set_ylabel('Mass ($M_\\odot$)')
print(x[0], y[0])
In [11]:
# Plot the luminosity profile
fig, ax = plt.subplots()
ax.plot(mstar['mass'],mstar['luminosity'],'b')
ax.set_xlabel('Mass ($M_\\odot$)')
ax.set_ylabel('Luminosity ($J/s$)')
Out[11]:
In [12]:
# Plot the entropy profile
fig, ax = plt.subplots()
ax.plot(mstar['mass'],mstar['entropy'],'b')
ax.set_xlabel('Mass ($M_\\odot$)')
ax.set_ylabel('Entropy ($J/K$)')
Out[12]:
In [16]:
# Plot the dr profile
fig, ax = plt.subplots()
mstar["dr"] = np.diff(mstar["radiuscm"])
ax.plot(mstar['mass'][:-1],mstar['dr'],'b')
ax.set_xlabel('Mass ($M_\\odot$)')
ax.set_ylabel('dr ($cm$)')
Out[16]:
In [ ]: