\documentclass[preprint, 12pt]{aastex}

\pagestyle{empty}

\usepackage{listings}
\usepackage{color}

\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

\lstset{frame=tb,
  language=Java,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  basicstyle={\small\ttfamily},
  numbers=none,
  numberstyle=\tiny\color{gray},
  keywordstyle=\color{blue},
  commentstyle=\color{dkgreen},
  stringstyle=\color{mauve},
  breaklines=true,
  breakatwhitespace=true,
  tabsize=3
}


\begin{document}

\section*{Simulating Stars 2018}
\section*{Novae Lab 1: A First Nova Model}
%\vspace{-1em}

\noindent
In this lab, we will make a first model of a nova by accreting hydrogen and helium onto a $0.6\,M_\odot$ white dwarf. We'll look at one model in some detail first before going on to study the larger parameter space in the next lab.

\vspace{1.0em}
{\noindent\bf Part 1: What happens when you accrete hydrogen onto a white dwarf?}

\noindent
We've provided a starting white dwarf model {\verb mesa_wd_M0.6_L-1.mod } that we made by running {\verb make_co_wd } in the MESA test suite. This evolves a $\approx 3\ M_\odot$ main sequence star through the main sequence, RGB, AGB and eventually creates a white dwarf with mass $0.6\ M_\odot$. Because this takes some time to run, we've given you the final white dwarf model here to save time. We used the default parameters as specified in the test suite except that we made a small change to stop the run when the white dwarf luminosity is $10^{-1}\ L_{\odot}$ rather than $10^{-2}\ L_\odot$. 

\noindent
We've provided two inlist files {\verb inlist_flash } and {\verb inlist_pgstar }. The first turns on accretion at a rate $10^{-9}\ M_\odot\ {\rm yr^{-1}}$, and the second makes a pgstar window tailored to this problem, so you will be able to see what is happening. 

\begin{itemize}
	\item Copy the files {\verb mesa_wd_M0.6_L-1.mod }, {\verb inlist_flash } and {\verb inlist_pgstar } into a new MESA {\verb work } directory.
	\item If you try running MESA using these inlists, you should find that MESA complains about not being able to find {\verb h_rich_layer_mass } and {\verb max_eps_h_lgT } in the history files, so you will need to add these to get it to run. Note that the option to write out png files is turned on in {\verb inlist_pgstar }, so that you can make a movie of the run (using \verb|images_to_movie.sh |).	
	\item Watch carefully to see what happens! 	
	
\end{itemize}	


\vspace{1.0em}
{\noindent\bf Part 2: Looking at the model in more detail}

\noindent
Use your model to answer the following questions: 

\begin{itemize}
	\item What is the recurrence time and ignition mass of the novae? Is this model gaining or losing mass over time? How does the rate of change of mass compare with the mass accretion rate?
	\item Plot the lightcurve $L(t)$ of one of the flashes, as well as the nuclear luminosity $L_{\rm nuc}(t)$, and Eddington luminosity $L_{\rm Edd}$. By how much does $L$ exceed the Eddington luminosity? At this luminosity, how much time would it take for the super-Eddington wind to eject the ignition mass? Compare this with the time it would take to burn the hydrogen away at the nuclear luminosity.
	\item How does the radius of the star and the effective temperature evolve over time? How would you expect the visual lightcurve to compare with the bolometric lightcurve? 
	\item How does the temperature and pressure in the burning layer, the pressure scale height $H$ there, and aspect ratio $H/R$ evolve during the flash?
\end{itemize}

To help you, we've made a Jupyter notebook that plots the lightcurve of the last nova in the run, look at \verb|plot_lightcurve.ipynb|. Remember that if a quantity you need is not being output in the history.dat files, you can look in {\verb mesa/star/defaults/history_columns.list }. MESA probably already calculates it for you and you can just add it to your history file and rerun the model.






\end{document}




	\item What happens to the abundance pattern of different nuclei during and between flashes? Does it make sense? 

\vspace{1.0em}
{\noindent\bf Hints and tips}

\begin{itemize}
	\item 
You can use {\verb genfromtxt() } from {\verb numpy } to read in the history files. For example

\verb|data = numpy.genfromtxt('history.data', names=True, skip_header=5)|

will read in the history file and then you can access columns by name, e.g.

\verb|    t = data['star_age']|

\verb|    L = data['log_L']|

\verb|    plt.plot(t, L)|


\item One way to divide the lightcurve into individual flashes is to look for times when the luminosity crosses a particular value (such as the average). For example, here's how I found the lightcurve of a single flash (there's probably a better way to do this!):

\verb| def extract_lc(t,L): |

\verb|    Lav = 0.5*(max(L)+min(L)) | 
   
\verb|    i = len(L)-1|

\verb|    while L[i] > Lav:     # first make sure we start off below Lav |

\verb|        i = i-1|

\verb|    i2 = i|

\verb|    while L[i] < Lav:    # count backwards until we cross Lav   |

\verb|        i = i-1|

\verb|    while L[i] > Lav:    # and again  |

\verb|        i = i-1|

\verb|    i1 = i|
    
\verb|    t1 = t[i1:i2]|

\verb|    L1 = L[i1:i2]|

\verb|    t1 = t1 - t1[0]     # set the starting time to zero |
    
\verb|    return t1, L1 |


\item To make a movie, you can use the {\verb images_to_movie.sh } script which is included with the MESA SDK. For example, if you have MESA writing png files to the png directory, you could use 

\verb| images_to_movie.sh 'png/grid1_*.png' movie.mp4 |


\item Remember that if a quantity you need is not being output in the history.dat files, look in {\verb mesa/star/defaults/history_columns.list }. MESA probably already calculates it for you and you can just add it to your history file.



\end{itemize}





The model that comes out of the test suite is quite hot, so the first thing to do is to let it cool down until it reaches a temperature appropriate for accreting white dwarfs. 

	\begin{itemize}
	\item In a new MESA {\verb work } directory, use the control {\verb log_center_temp_lower_limit } to let the white dwarf cool down to a central temperature of $10^7\ {\rm K}$. Save the model under a different name, e.g. you could call it {\verb mesa_wd_M0.6_T7.0.mod }.
	\end{itemize}


