In-Class Assignment 4#
Exploring MESA models (with Pandas)#
To read in these files, we will use Pandas
Note
Install pandas via conda using
conda install conda-forge::pandas
Credit: These exercises follow from work by Mike Zingale’s computational lectures.
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
Use Pandas to plot MESA data. The raw MESA data, same as from ICA3, can be loaded as a .csv
file, header=4
, and using sep=r'\s+'
. After loading the profiles and history files for all three models. Plot the following:
# load data here
The model files are again:
\(1 M_\odot\): M1_default_profile8.data; M1_default_profile218.data; M1_default_trimmed_history.data
\(8 M_\odot\): M8_basic_co_profile8.data; M8_basic_co_profile39.data; M8_basic_co_trimmed_history.data
\(15 M_\odot\): M15_aprox21_profile8.data; M15_aprox21_profile19.data; M15_aprox21_trimmed_history.data
a#
HR diagram#
Lets start with an HR diagram. Below are some possible steps to do that. For reference, here are some common commands working with Pandas CSV and here.
The matplotlib
reference page is linked here.
# Okay, now we have two arrays for the 1msun model
# plot those data here. you might want to use `plt.invert_xaxis()`
# Plot all three models on the same HR diagram here and add a legend.
# Make sure your x-axis is going the correct direction!
Can you identify the main sequence on this plot?
We also see that only the 1 solar mass star “finished’ stellar evolution, winding up as a cooling white dwarf at the end – the path it is following is essentially a line of constant radius, since the white dwarf does not contract as it cools (it is degenerate).
b#
Central evolution#
We want to plot the history of the evolution of the central conditions in the \(\log \rho\)-\(\log T\) plane.
Now we can plot the data
## in a similar way as above, plot the three stellar model history data, this time for the central density and
# central temperature
Note: The 1 solar mass star makes a transition from following \(T \approx \rho^{1/3}\) to \(\rho = \mbox{constant}\) when degeneracy kicks in - no density dependence!
c#
Main sequence lifetime#
We can estimate the main sequence lifetime just by looking for when the core H is all consumed. Consider plotting the central mass fraction of hydrogen over time.
#fig, ax = plt.subplots()
#ax.semilogx(# fill in here
From this plot, we see that the main sequence lifetime of the 15 \(M_\odot\) star is \(\sim 6\times 10^6\) yr, for the 8 \(M_\odot\) star \(\sim 2\times 10^7\) yr, and for the 1 \(M_\odot\) star \(\sim 9\times 10^9\) yr. Do these values match the rough estimates from HKT 1.88?
d#
For each mass of stellar model, plot an HR diagram individually and label at least 2 key evolutionary epochs. To annotate plots in matplotlib you can use. You can reference our slides on here for exammples of labels: MS, TO, RGB, etc.
## 1msun history model HR diagram here with two locations labeled
## same for 7m here
## same for 15m here