Note
This tutorial was generated from a Jupyter notebook that can be downloaded here.
Energy and mixing diagram
In this notebook we will discuss how to create one of the possible tulips
diagrams. The energy and mixing diagrams gives an overview about the energy generation rates thoughout a the stellar model. Moreover, it provides information about the mixing processes occuring in the interior. In this diagram, tulips
visualizes the stellar model as a circle, where its radius represents the total mass of the star.
Load example model
Let’s plot an energy and mixing diagram of a \(11 M_{\odot}\) star. As explained in the Getting Started page, we first need to load in the history output of a MESA model with mesaPlot
and store it in an object called m11
.
[1]:
# Interactive matplotlib plotting for jupyter lab
%matplotlib inline
# If you use jupyter notebook
# %matplotlib notebook
import matplotlib.pyplot as plt
import mesaPlot as mp
import tulips
# Specify directory of MESA model
SINGLE_M11_DIR = "../../tulips/MESA_DIR_EXAMPLE/"
m11 = mp.MESA()
m11.loadHistory(f=SINGLE_M11_DIR)
Create an energy diagram
Then we create an instance of the stellar model at time_ind=2200
as follows:
[3]:
tulips.energy_and_mixing(m11, time_ind=2200, cmin=-10, cmax=10, show_total_mass=True, fig_size=(8,6))
plt.show()
The stellar model is shown as a circle, whose radius represents the total mass (however, this can be changed by modifying the raxis
property). The colors inside the star represents the energy generation rate. As indicated by the colorbar on the right, yellow to red colors are used for a positive energy generation rate, caused by nuclear burning processes. As we can see in the inset HR diagram, we are looking at a star in the later stages of its evolution. We can observe burning in a shell,
as well as a burning region in its core. The colors can also show energy loss by neutrino emission, which are shown in purple. You can hide the colorbar by setting show_colorbar
to False
. To see how you can change the colormap, have a look at the Customize options page. The label of the colorbar can be changed with the cbar_label
option. It is possible to put limits on the burning rates using the cmin
and cmax
property. In the example above we
used the default values. However, if you are for example only interested in energy generation and not in cooling, you could change cmin
to 0 to only include positive energy generation rates.
Note
Important here is to notice that this is a logarithmic quantity.
Create an energy and mixing diagram
Next to visualizing the regions where energy generation or losses occur, tulips
can also show the dominant mixing process in the interior. We can add this information to the diagram by changing the show_mix
and show_mix_legend
variables to True
:
[4]:
tulips.energy_and_mixing(m11, time_ind=0, cmin=-10, cmax=10, show_total_mass=True,
show_mix=True, show_mix_legend=True, fig_size=(8,6))
plt.show()
In addition to the energy generation rates, we now also see areas with grey patterns indicating the mixing process. Which patterns correspond to the different types of mixing processes can be seen in the legend. The mixing hatches can be customized by changing the tulips.MIX_HATCHES
variable. This stellar model has a convective core with overshooting at the edge.
Creating an animation
We can create an animation of our energy and mixing diagram by changing the time_ind
property. You can specify the start index, end index and timestep. In the following example we choose to show the first (0) to last (-1) model, with steps of 10. fps
(frames per second) controls the speed of the video.
[5]:
tulips.energy_and_mixing(m11, time_ind=(0,-1, 10), fps=30, cmin=-10, cmax=10, fig_size=(8,6)
show_total_mass=True, show_mix=True, show_mix_legend=True, output_fname="energy_and_mixing")
plt.show()
File "/tmp/ipykernel_307/3394379683.py", line 2
show_total_mass=True, show_mix=True, show_mix_legend=True, output_fname="energy_and_mixing")
^
SyntaxError: invalid syntax
[6]:
from IPython.display import Video
Video("energy_and_mixing.mp4", embed=True, width=700, height=600)
[6]: