# Example Walkthrough¶

This chapter provides a walkthrough of a example GYRE project, to illustrate the typical steps involved. For this example, we’ll be focusing on finding eigenfrequencies and eigenfunctions of quadrupole ($$\ell=2$$) gravity modes for a MESA model of slowly pulsating B (SPB) star.

## Making a Place to Work¶

When starting a new project, it’s a good idea to create a dedicated working directory to contain the various input and output files that GYRE operates on. These commands will make a new directory beneath your home directory with the name work, and then set this directory as the current working directory:

## Grabbing a Stellar Model¶

The next step is to grab the stellar model. There are a number of example models provided in the \$GYRE_DIR/models directory; the following commands will copy a MESA model for a $$5\,\Msun$$ SPB star into your working directory:

## Creating a Namelist File¶

Now comes the fun part: creating an input file containing the various parameters which control a GYRE run. Using a text editor, create the file gyre.in in your working directory with the following content cut-and-pasted in:

&constants
/

&model
model_type = 'EVOL'  ! Obtain stellar structure from an evolutionary model
file = 'spb.mesa'    ! File name of the evolutionary model
file_format = 'MESA' ! File format of the evolutionary model
/

&mode
l = 2 ! Harmonic degree
/

&osc
outer_bound = 'VACUUM' ! Use a zero-pressure outer mechanical boundary condition
/

&rot
/

&num
diff_scheme = 'COLLOC_GL4' ! 4th-order collocation scheme for difference equations
/

&scan
grid_type = 'INVERSE' ! Scan grid uniform in inverse frequency
freq_min = 0.5        ! Minimum frequency to scan from
freq_max = 1.0        ! Maximum frequency to scan to
n_freq = 250          ! Number of frequency points in scan
/

&grid
w_osc = 10 ! Oscillatory region weight parameter
w_exp = 2  ! Exponential region weight parameter
w_ctr = 10 ! Central region weight parameter
/

summary_file = 'summary.txt'                 ! File name for summary file
summary_file_format = 'TXT'                  ! Format of summary file
summary_item_list = 'l,n_pg,freq,freq_units' ! Items to appear in summary file
detail_template = 'detail.%J.txt'            ! File name template for detail files
detail_file_format = 'TXT'                   ! Format of detail files
detail_item_list = 'n_pg,x,xi_r,xi_h'        ! Items to appear in detail files
freq_units = 'CYC_PER_DAY'                   ! Units of freq output items
/

/


This file is an example of a Fortran ‘namelist’ file, containing multiple namelist groups. Each group begins with the line &name (where name is the name of the group); a list of parameter-value pairs then follows, and the group ends with a slash /. Detailed information on the namelist groups expected in GYRE’s input files can be found in the Namelist Input Files chapter; for now, let’s just focus on some of the more-important aspects of the file above:

• the &constants namelist group is empty, telling GYRE to use default values for fundamental constants;
• the &model namelist group tells GYRE to read an evolutionary model, in MESA format, from the file spb.mesa;
• the &mode namelist group tells GYRE to search for quadrupole ($$\ell=2$$) modes;
• the &osc namelist group tells GYRE to apply a zero-pressure outer mechanical boundary condition in the oscillation equations;
• the &scan namelist group tells GYRE to scan a region of dimensionless angular frequency space typically occupied by gravity modes;
• the &grid namelist group tells GYRE how to refine the model spatial grid;
• the &ad_output namelist group tells GYRE to write out summary data to the file summary.txt, and individual mode data to files having the prefix mode.;
• the &nad_output namelist group is empty, telling GYRE not to write out any non-adiabatic data (see the Non-Adiabatic Calculations chapter for more info).

## Running GYRE¶

With the hard work done, it’s now trivial to run GYRE:

As the code runs (on multiple cores, if you have a multi-core machine; see the FAQ for more details), it will print lots of data to the screen. Let’s break down this output, chunk by chunk.

First, GYRE prints out its version number, tells us (in OpenMP threads) how many cores it is running on, and indicates which file it is reading parameters from (here, gyre.in):

gyre [6.0]
----------

Input filename   : gyre.in


Next, GYRE loads the stellar model from the file spb.mesa. This model comprises 1814 points and extends from the surface all the way to the center (which is why GYRE decides not to add a central point).

Model Init
----------

File name spb.mesa
File version 1.00
No need to add central point


GYRE then prepares to searching for modes with harmonic degree $$\ell=2$$ and azimuthal order $$m=0$$ (not specified in gyre.in, but assumed by default), by building a frequency grid and a spatial grid:

Mode Search
-----------

Mode parameters
l : 2
m : 0

Building frequency grid
added scan interval :  0.5000E+00 ->  0.1000E+01 (250 points, INVERSE)

Building spatial grid
Refined 6 subinterval(s) in iteration 1
Refined 0 subinterval(s) in iteration 2
Final grid has 1 segment(s) and 1820 point(s):
Segment 1 : x range 0.0000 -> 1.0000 (1 -> 1820)


(The concepts of spatial and frequency grids are explored in greater detail in the GYRE Fundamentals and Understanding Grids chapters). Next, GYRE attempts to bracket roots of the discriminant function (again, see the GYRE Fundamentals chapter) by searching for changes in its sign:

Starting search (adiabatic)

Root bracketing
Time elapsed :     1.926 s


Finally, for each bracket found GYRE uses a root solver to converge to the eigenfrequency. Each row of output here corresponds to a mode that GYRE has successfully found:

Root Solving
l    m    n_pg    n_p    n_g       Re(omega)       Im(omega)        chi n_iter
2    0     -16      0     16  0.51863360E+00  0.00000000E+00 0.2146E-13      6
2    0     -15      0     15  0.55636039E+00  0.00000000E+00 0.6402E-13      5
2    0     -14      0     14  0.59457063E+00  0.00000000E+00 0.7281E-13      7
2    0     -13      0     13  0.62301082E+00  0.00000000E+00 0.3057E-13      6
2    0     -12      0     12  0.67563432E+00  0.00000000E+00 0.1162E-12      6
2    0     -11      0     11  0.74334407E+00  0.00000000E+00 0.3407E-14      5
2    0     -10      0     10  0.79690602E+00  0.00000000E+00 0.6071E-13      6
2    0      -9      0      9  0.87152970E+00  0.00000000E+00 0.7861E-13      8
2    0      -8      0      8  0.99746970E+00  0.00000000E+00 0.1223E-12      6
Time elapsed :      0.557 s


The columns appearing are as follows:

l
harmonic degree $$\ell$$
m
azimuthal order $$m$$
n_pg
radial order $$n$$ (in the Eckart-Osaki-Scuflaire-Takata scheme)
n_p
acoustic-wave winding number $$n_{\rm p}$$
n_g
gravity-wave winding number $$n_{\rm g}$$
Re(omega)
real part of dimensionless eigenfrequency $$\omega$$
Im(omega)
imaginary part of dimensionless eigenfrequency $$\omega$$ (zero here because we’ve performed an adiabatic calculation)
chi
convergence parameter
n_iter
number of iterations required for convergence

These values are printed to screen primarily to give an idea of GYRE’s progress; more-detailed information about the modes found is given in the output files discussed below. Some things to watch out for:

• The convergence parameter chi, defined as the ratio of discriminant values before and after the root finding, should small (on the order of 1E-9 to 1E-13). If it is significantly larger than this, the mode may not be properly converged; and if it is significantly smaller than this, there may be numerical issues with the discretization scheme.
• The number of iterations n_iter should be moderate; values above 20 or so indicate that GYRE is having problems converging.
• The mode index n_pg should be monotonic-increasing. Departures from this behavior can happen for a number of reasons:
• Missing values can indicate that GYRE has skipped a mode in frequency space; the fix is to use a finer frequency grid.
• Missing values together with duplicate and/or non-monotonic values can indicate that GYRE isn’t resolving the spatial structure of eigenfunctions; the fix is to use a finer spatial grid.
• Missing values together with duplicate and/or non-monotonic values can also incdicate problems with the input stellar model — for instance, incorrect values for the Brunt-Vaisala frequency across density discontinuities; the fix is to stop expecting GYRE to give sensible output when fed crap stellar models!

## Interpreting Output Files¶

Overall properties of all modes found (radial orders, eigenfrequencies, etc.) are collected together in the summary file, which in this case has the name summary.txt. For each mode GYRE also writes a detail file containing data (eigenfrequency, eigenfunctions, etc.) specific to the mode. In this case, the detail files have names of the form detail.NNNNN.txt, where NNNNN denotes a 5-digit index which increments (starting at 00001) for each mode found. Note that this index bears no relation to the radial order n_pg; it merely serves as a unique label for the modes.

Both the sumamry file and the detail files are text-based (it’s possible to write HDF5-format files instead; see the Output Files chapter for details). The command

will print out the first 10 lines of the summary file, which should look something like this:


1
freq_units
CYC_PER_DAY
1                         2                         3                         4
l                      n_pg                  Re(freq)                  Im(freq)
2                       -16   0.1108864144066767E+001   0.0000000000000000E+000
2                       -15   0.1189525885019410E+001   0.0000000000000000E+000
2                       -14   0.1271221263586421E+001   0.0000000000000000E+000
2                       -13   0.1332027784135520E+001   0.0000000000000000E+000


The first three lines give column numbers, labels, and values for the scalar data — here, the units freq_units of the frequency data in the file. The next two lines give column numbers and labels for the per-mode data; the Re(freq) and Im(freq) columnss contains the real and imaginary parts of the eigenfrequencies, units of cycles per day. The detail files have a similar layout, with scalar data followed by array data representing the eigenfunctions (one line per spatial grid point).

The choice of which data appear in output files isn’t hardwired, but rather determined by the summary_item_list and mode_item_list parameters of the &ad_output and &nad_output namelist groups. Changing these parameters allows you to tailor the files to contain exactly the data you need. For a full list of possible items, consult the Output Files chapter.