Note
This tutorial was generated from a Jupyter notebook that can be downloaded here.
Property profile diagram
In this notebook we demonstrate how to create a property profile diagram. The diagram can be used when we want to explore a certain property throughout the stellar interior, such as the density, at a given moment in time. It will show us the profile of that property of the star and helps to visualize how the property changes from the center to the surface of the stellar object. The property profile diagram is customizable and offers many options that we will demonstrate in this notebook. To
generate these diagrams, tulips
divides the star into rings and computes the physical property at the location of each ring. Each ring is assigned a color that represents the value of the property at this location within the star. In the following example we will show how to create a property diagram that represents the density of a \(11 M_{\odot}\) star.
Load example model
To create a tulips
diagram, we first need to load in a MESA output model. We can load the output file in an object called m11
as follows:
[5]:
# 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 = "../../../../old_tulips_project/tulips/tulips/MESA_DIR_EXAMPLE/LOGS/"
m11 = mp.MESA()
m11.loadHistory(f=SINGLE_M11_DIR)
Warning
As explained in the Getting Started page, MESA produces two types of output: history.data
and profile.data
files. When making a property profile diagram, make sure that both of these types of files are stored in the MESA output folder.
Example 1: density
Let’s try to plot the density of this stellar model in the diagram. To do this, we call the tulips.property_profile
function, which requires our MESA object m11
as the first argument. With the raxis
keyword, we can specify what the radius of the circle represents. In this example the radius of the circle represents the mass of the star, but sometimes it might be useful to represent other quantities instead, such as the radius of the star. property_name
indicates which physical
property we want to show in the diagram, which in this case will be logarithm of the density. With time_ind
we specify a time index. Here, we plot the first model. The time index is further explained in the Getting Started page.
[3]:
tulips.property_profile(m11, time_ind=0, property_name='logRho', num_rings=100, cmin=-2, cmax=0)
plt.show()
../../../../old_tulips_project/tulips/tulips/MESA_DIR_EXAMPLE/LOGS///profile1.data

The property diagram shows us a stellar model represented by a circle that is divided in num_rings
layers. If num_rings
is -1 (default), it shows the maximum amount of rings, but this will computationally be more heavy. Each layer has its own color, corresponding to a certain density, as indicated by the colorbar on the right. To see how you can change the colormap, have a look at the Customize options page. You can hide the colorbar with
show_colorbar=False
and you can specify a label with cbar_label
. Here, we see that the density decreases when you move outward. With the cmin
and cmax
argument you can specify what range of values of the property you want to show. In this example, we showed log densities densities in the range of \(10^{-2}\) to 1 \([\mathrm{g}\,\mathrm{cm}^{-3}]\). By default, cmin
and cmax
correspond to the mininum and maximum value of that property in the complete
profile.data
file of the stellar object.
Note
Make sure you are pointing to the correct folder that contains the profile data! MESA usually stores the profiles.data
in a LOGS folder. If you get an error about profiles not being found, try m11.log_fold='<your_directory>/LOGS'
. This will make sure that tulips
can find the profile data.
Example 2: Helium-4
Not only the density, but many more properties of the star can be shown with this tulips
diagram. Here, we will show the \(^{4}\mathrm{He}\) mass fraction throughout the stellar interior. If we want to see how this quantity changes from the center to the edge of the stellar object, we only have to change property_name
to 'he4'
. If we then plot the diagram at a later time index, where the star is burning hydrogen in a shell, it looks as follows:
[4]:
tulips.property_profile(m11, time_ind=1000, property_name='he4', num_rings=100, log=True)
plt.show()
../../../../old_tulips_project/tulips/tulips/MESA_DIR_EXAMPLE/LOGS///profile102.data

Here we didn’t specify cmin
and cmax
, so the colorbar just shows the full range that is stored in the profile.data
file. For this example, we also put log=True
. With this option, we now see the log values of the property on the colorbar, which can be useful if you have quantities that span a wide range. In this case, when specifying cmin
and cmax
, you should also use the log values (for example:cmin
=-0.4, cmax
=0). With the log_low_lim
keyword, you can
define the value to adopt for negative and zero values of a property.
Tip
To explore the available properties, load a MESA profile with m11.loadProfile(num=-1)
, then type m11.prof.
+ Tab
, which will reveal a list with the options. Default units are in cgs
. For more information about the properties in the output file, have a look at the MESA documentation.
Creating an animation
To create an animation to see how the property changes over time, we just have to change the time_ind
variable. In the example below we chose to create an animation from the first (0) to the last (-1) time index. With fps
(frames per second) you can adjust the speed of the video. To see the video, you need to save it first as a .mp4 file. You can specify the directory and the name with output_fname
.
Warning
The amount of profiles stores in the profile.data
file can be small. When making an animation, make sure that enough profile output has been saved to show a meaningful time evolution of the property of interest. You can check when profiles are saved with m11.prof_ind['model']
. This returns a list with indices at which model number a profile is saved. You can use this to see how many profiles you have and decide if they cover the interesting stages in the evolution.
[ ]:
tulips.property_profile(m11, time_ind=(0, -1), fps=30, property_name='logRho', num_rings=100, output_fname='property_diagrams')
plt.show()
[19]:
from IPython.display import Video
Video("property_diagrams.mp4", embed=True, width=700, height=600)
[19]: