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.
Numerical workflow (one shell)
In a typical outer shell, the state vector is \((M_r,L_r,T,P)\). From these, STATSTAR obtains \(\rho\) via the EOS, \(\kappa\) from opacity formulae/tables, and \(\epsilon\) from nuclear-energy fits. Those “auxiliary sources” provide the microphysics that the differential system itself does not specify. Then the program evaluates the radial derivatives and steps inward to the next shell.
Primary equations used each step:
- \(dP/dr=-\rho GM/r^2\) (mechanical balance)
- \(dM/dr=4\pi r^2\rho\) (geometry + continuity)
- \(dL/dr=4\pi r^2\rho\,\epsilon\) (energy conservation)
- \(dT/dr\) chosen as
\[ \left(\frac{dT}{dr}\right)_{\!\rm rad}=-\frac{3\kappa\rho L}{16\pi a c\,T^3 r^2} \qquad\text{or}\qquad \left(\frac{dT}{dr}\right)_{\!\rm ad}\;(\text{if convective}), \]
with the switch ruled by the convective instability condition. (Full derivations are deferred to [[un:heat-transfer-in-stars|Heat transfer in stars]].)
Secondary relations used inside each step:
- EOS (ideal-gas baseline) \(\Rightarrow\) \(\rho(P,T,\mu)\)
- Saha ionization \(\Rightarrow\) \(\mu(\rho,T)\), \(\kappa(\rho,T)\)
Starting, stepping, and stopping
*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.
Running STATSTAR (Python-3)
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.
Physical scope and assumptions
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. :contentReference[oaicite:16]{index=16}
- Numerics matter: RK4 stepping and robust start/stop criteria are essential; small changes to \(T_{\!eff}\) can make or break a run. :contentReference[oaicite:17]{index=17}
- Outputs need physics checks: center too cool for the specified \(L\) ⇒ inconsistent model; revisit inputs or microphysics. :contentReference[oaicite:18]{index=18}
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? :contentReference[oaicite:19]{index=19}
- For fixed \(M\), vary \(T_{\!eff}\) slightly. How do the central values and the success of the run change? Explain using the transport equations. :contentReference[oaicite:20]{index=20}
- 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)\).
