Table of Contents
This is an old revision of the document!
Modeling a star
This article shows how to build a static stellar model (one that does not model the time evolution) by numerically integrating the seven equations of stellar structure with the program
STATSTAR (The Python-3 version is in this Colab Notebook).
You will (i) supply basic global inputs, (ii) let the code step inward through thin spherical shells using Runge–Kutta, and (iii) inspect the shell-by-shell output to judge whether the model is physically consistent.
What STATSTAR does
STATSTAR integrates the primary structure ODEs with radius \(r\):
- Hydrostatic equilibrium: \(\displaystyle \frac{dP}{dr}=-\rho\,\frac{G M}{r^2}\)
- Mass conservation: \(\displaystyle \frac{dM}{dr}=4\pi r^2\rho\)
- Energy generation (luminosity): \(\displaystyle \frac{dL}{dr}=4\pi r^2\rho\,\epsilon\)
- Temperature gradient by radiation or by convection (picked locally)
and closes them with the secondary relations:
- Equation of state (ideal-gas baseline, extendable with radiation/degeneracy)
- Ionization balance (Saha; affects \(\mu\) and \(\kappa\))
The code walks inward shell-by-shell:
- compute auxiliary quantities in the current shell (\(\rho,\ \kappa,\ \epsilon\)),
- evaluate derivatives \(dM/dr,\ dL/dr,\ dT/dr,\ dP/dr\),
- advance to the next shell (4th-order Runge–Kutta),
- repeat until a termination criterion is reached.
Inputs you provide
When run, STATSTAR prompts for five global inputs:
- total mass \(M\) (in \(M_\odot\))
- total luminosity \(L\) (in \(L_\odot\))
- effective temperature \(T_{\!eff}\) (K)
- hydrogen mass fraction \(X\)
- metal mass fraction \(Z\) (with helium \(Y=1-X-Z\))
These define the composition and the approximate outer boundary conditions for the integration that proceeds inward.
Running STATSTAR
*Initialization.* STATSTAR constructs an outermost layer from your \(L,\ T_{\!eff}\) and composition, then begins stepping inward (\(dr<0\)). The integrator is 4th-order Runge–Kutta for accuracy and stability.
*Termination.* A run ends either in success (“CONGRATULATIONS, I THINK YOU FOUND IT!” printed) when a sensible center is reached, or in failure if a sanity check is violated (e.g., nonphysical central values, premature termination). Either way, inspect starmodl_py.dat.
Create an input file (or type values interactively). Example inputs:
- Mass (M/M⊙)*: 1.0
- Luminosity (L/L⊙)*: 0.860710
- Effective temperature (K)*: 5500 .2
- X*: 0.70
- Z*: 0.008
These values reproduce a “near-solar” demonstration. The model proceeds inward through several hundred shells, writing a column table per shell (radius, \(M_r, L_r, T, P, \rho, \kappa, \epsilon,\dots\)).
Reading the output sensibly
A viable model has:
- \(r\) ranging smoothly to (near) zero,
- \(T\) rising to \(\sim10^7\)–\(10^7.5\) K in the center for a solar-type star,
- \(P,\ \rho\) monotonic inward increases,
- no unphysical spikes at the innermost gridpoints.
Runs with slightly different \(T_{\!eff}\) can “miss” the center (e.g., wrong mass at \(r\to0\)) or produce implausible central temperatures; these are cues to adjust outer inputs and re-run.
STATSTAR solves static (time-independent) stellar structure for homogeneous main-sequence-like models: composition is fixed through the star, rotation and magnetic fields are neglected, and the program chooses radiative or convective transport locally. Only certain \((L,\,T_{\!eff})\) pairs are consistent for a given \(M\) and composition, reflecting the classic constraints on ZAMS models.
Insights
Families of STATSTAR-type models reproduce the qualitative behavior of real stars on the H–R diagram: luminosity rises steeply with mass on the main sequence, central temperature correlates with mass, and radii grow mildly with mass (since \(L\) increases a bit faster than \(T^4\)). Such trends echo classic evolutionary sequences (e.g., Iben 1967) and Gaia observations.
- Primary vs. secondary: the four ODEs (+ one transport choice) control the *geometry and balances*; EOS+Saha close the *microphysics* each step.
- Numerics matter: RK4 stepping and robust start/stop criteria are essential; small changes to \(T_{\!eff}\) can make or break a run.
- Outputs need physics checks: center too cool for the specified \(L\) ⇒ inconsistent model; revisit inputs or microphysics.
Inquiries
- Starting from your \(M, L, T_{\!eff}, X, Z\), run STATSTAR and plot \(T(r), P(r), \rho(r)\). Is the model sensible at \(r\to0\)? Why?
- For fixed \(M\), vary \(T_{\!eff}\) slightly. How do the central values and the success of the run change? Explain using the transport equations.
- Using starmodl.dat, estimate \(R\) and compare \(L\) to \(4\pi R^2\sigma T_{\!eff}^4\). Discuss consistency.
- Replace the EOS with a partially degenerate term in the deep interior. Predict qualitative changes to \(P(r)\) and \(T(r)\).
