Authors: Andy Tzanidakis, James Davenport Date: 01.17.2022 For general questions or inquiries, please reach out to Andy
As we have learned so far in this course, stellar spectra are the gateway to understanding stellar theory. In this homework set, you will learn how to use the beautiful Saha and Boltzmann fraction equations. Hopefully these sets of exercises will give you an intuition on how the Saha/Boltzmann equation relate to the fraction of various energy states, and the strength of the Balmer lines (in the case of hydrogen!)
As always, if you have any comments or concerns, please feel free to reach out with questions š
First, letās begin with importing relevant Python packages that I will be using for the solutions:
import numpy as np
from astropy.io import ascii
import matplotlib.pyplot as plt
import astropy.units as u
import astropy.constants as constant
import os
%matplotlib inline
%config InlineBackend.figure_format = "retina"
Before we get started, itās always a good idea to get familiar with the data we will be using. Letās read the NLTE files:
# Path to where the data is sitting
path = '../data/'
# Load the data
vega = ascii.read(path + 'vega_nlt.txt')
sol = ascii.read(path + 'sun_nlt.txt')
print (sol) # let's see what the data looks like
Cool, it looks like astropy.io.ascii
opened my file. We know from the homework description that the first row is the āinverse temperatureā, and the second row is the electron pressure (in log10). Above you scan see a screenshot of the first 9 columns of the data...
Letās take this one step further and organize our variables:
# Let's unpack the LTE data and plot the sun vega ionization fractions
theta_sol = [sol[f'{key}'].data[0] for key in sol.keys()] # index 0: Theta
pe_sol = [sol[f'{key}'].data[1] for key in sol.keys()] # index 1: Electron Pressure
#Generally, I like to work with numpy arrays, so let's covert them to arrays
theta_sol, pe_sol = np.array(theta_sol), np.array(pe_sol)
# Same for Vega now
theta_vega = [vega[f'{key}'].data[0] for key in vega.keys()] # index 0: Theta
pe_vega = [vega[f'{key}'].data[1] for key in vega.keys()] # index 1: Electron Pressure
theta_vega, pe_vega = np.array(theta_vega), np.array(pe_vega) # as numpy arrays
Beautiful, now we should have our data neatly organized into variables! š
You are asked to evaluate the partition function for ionized and neutral hydrogen.
First, the ionized hydrogen is the easiest and will have a partition function of $Z_{I}=1$ since the electron has only one state it can be in.