Example Walkthrough: Composite Polytrope

As the second example of build_poly in action, let’s build a two-region composite polytrope. The polytropic index is \(n=3\) in the inner region, and \(n=1.5\) in the outer region. At the boundary between the regions, located at radial coordinate \(z=1.4\), the logarithmic density jump is \(\Delta = -0.5\).

Assembling a Namelist File

Using a text editor, create the file build_poly.composite.in with the following content cut-and-pasted in:

	n_r = 2           ! Number of regions
	n_poly = 3.0, 1.5 ! Polytropic indices of regions
        z_b = 1.4         ! Radial coordinate of region boundaries
        Delta_b = -0.5    ! Logarithmic density jump at region boundaries

	dz = 1E-2     ! Radial spacing of points
	toler = 1E-10 ! Tolerance of integrator

	file = 'poly.composite.h5' ! Name of output file

Again, detailed information on the namelist groups expected in build_poly input files can be found in the Input Files section. Here, let’s briefly narrate the parameters appearing in the file above:

  • In the &poly namelist group, the n_r parameter sets the number of regions; the n_poly parameter sets the polytropic indices in the two regions; the z_b sets the radial coordinate of the boundary between the regions; and the Delta_b sets the density jump at this boundary.

  • In the &num namelist group, the dz parameter sets the radial spacing of points, and the toler parameter sets the tolerance of the numerical integrator.

  • In the &output namelist group, the file parameter sets the name of the output file.

Running build_poly

As before, to run build_poly use the command

$GYRE_DIR/bin/build_poly build_poly.composite.in

There is no screen output produced during the run, but at the end the poly.composite.h5 will be written to disk. This file, which is in POLY format, can be used as the input stellar model in a GYRE calculation; but it can also be explored in Python (see Fig. 13) using the read_model function from PyGYRE.

Plot showing the structure of the simple polytrope model

Fig. 13 Plot of the Lane-Emden solution variable \(\theta\), density \(\rho\), pressure \(P\) and interior mass \(M_{r}\) as a function of radial coordinate, for the composite polytrope. Note the density discontinuity, and the associated discontinuities in the gradients of the pressure and interior mass. (Source)