# Building Polytropic Structure Files¶

This appendix describes the build_poly executable, which builds a composite polytropic stellar model and writes it to a file in the POLY format (see the poly-format section).

## Composite Polytropes¶

A composite polytropic model comprises $$N$$ regions extending from the origin out to the stellar surface. In the $$i$$’th region ($$1 \leq i \leq N$$), the density and pressure are related by the polytropic equation of state

$P = K_{i} \rho^{(n_{i} + 1)/n_{i}}$

where $$K_{i}$$ and the polytropic index $$n_{i}$$ are constant across the region (but may differ from one region to the next). At the $$N-1$$ boundaries between adjacent regions, the pressure is required to be continuous but the density may jump.

The structure of a composite polytrope is found by integrating the composite Lane-Emden equation

$\frac{1}{\xi^{2}} \deriv{}{z} \left( \xi^{2} \deriv{\theta_{i}}{\xi} \right) = - B_{i} \theta^{n_{i}}$

in each region. Here, the independent variable is

$\xi = \left[ \frac{K_{1} \rho_{\rm c}^{(1-n_{1})/n_{1}} (n_{1} + 1)}{4 \pi G} \right]^{-1/2} \, r,$

where $$\rho_{\rm c}$$ is the central density of the star. In the first region, the initial conditions are

$\theta_{1}(0) = 1, \qquad \theta_{1}'(0) = 0$

and $$B_{1} = 1$$. In the subsequent regions, the initial conditions are

$\theta_{i}(\xi_{i-1/2}) = 1, \qquad \theta'_{i}(\xi_{i-1/2}) = \frac{n_{i-1}+1}{n_{i}} \frac{\left[ \theta_{i}(\xi_{k-1/2}) \right]^{n_{i}+1}}{\left[ \theta_{i-1}(\xi_{i-1/2}) \right]^{n_{i-1}+1}} \frac{t_{i}}{t_{i-1}} \, \theta'_{i-1}(\xi_{i-1/2})$

where $$\xi_{i-1/2}$$ is the coordinate of the boundary between the $$i-1$$ and $$i$$ regions; moreover,

$B_{i} = B_{i-1} \frac{n_{i-1}+1}{n_{i}+1} \frac{\left[ \theta_{i}(\xi_{k-1/2}) \right]^{n_{i}+1}}{\left[ \theta_{i-1}(\xi_{i-1/2}) \right]^{n_{i-1}+1}} \frac{t_{i}^{2}}{t_{i-1}^{2}}$

and the recurrence for $$t_{i}$$ is

$\ln t_{k} = \ln t_{i-1} + n_{i-1} \ln \theta_{i-1}(\xi_{i-1/2}) - n_{i} \ln \theta_{i}(\xi_{i-1/2}) + \Delta_{i-1/2},$

with $$t_{1} = 1$$ and

$\Delta_{i-1/2} = \ln \left[ \frac{\rho_{i}(\xi_{i-1/2})}{\rho_{i-1}(\xi_{i-1/2})}$

quantifying the density jump at $$\xi_{i-1/2}$$.

The surface of the composite polytropic model, $$\xi=\xi_{\rm s}$$, is defined implicitly by the boundary condition

$\theta_{N}(\xi_{\rm s}) = 0.$

### Pre-Requisites¶

In addition to GYRE’s general pre-requisites (see the Installation chapter), build_poly needs a thread-safe version of the ODEPACK ordinary differential integrator library. This library is shipped with version 20.3.2 (and more recent) of the MESA SDK.

### Compiling¶

The build_poly executable is automatically compiled when GYRE is built, and installed in the \$GYRE_DIR/bin directory (see the Installation chapter).