---
title: "Inside a Star in Hydrostatic Balance Interactive Lab | Sandbox Physics"
description: "What holds a star up against its own gravity? Pressure rises toward the center, so each layer feels a stronger push from below than from above. That pressure difference balances the inward pull of the mass enclosed by the layer."
canonical_url: "https://sandboxphysics.com/labs/stellar-hydrostatic-structure/"
language: "en"
page_type: "lab"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/labs/stellar-hydrostatic-structure/"
last_modified: "2026-10-24"
---

F-X3 · The pressure inside a star

# Inside a Star in Hydrostatic Balance

**What holds a star up against its own gravity?** Pressure rises toward the center, so each layer feels a stronger push from below than from above. That pressure difference balances the inward pull of the mass enclosed by the layer.

Open a stellar cross-section and drag a shell from the core to the surface. Compare the inward pull of gravity with the outward push from the pressure gradient.

> Interactive simulation: open this page in a web browser to change the parameters and run the model.

The model solves the spherical Newtonian Lane–Emden equation for polytropic indices from zero to four. Mass and radius set the density and pressure scales; neither is inferred from an observation. Density and pressure colors use separate normalized scales. Equal arrows show the two opposing accelerations at the selected radius. Their common length is normalized to the strongest interior gravity. This static model contains no nuclear burning, opacity, radiation transport, composition changes, rotation, magnetic fields or relativistic gravity. A polytropic index describes a pressure–density relation; it does not give a stellar age. The zero-index case is an incompressible mathematical reference. The cross-section depicts density, not a photograph or a temperature map.

Numerical hydrostatic solution

## How the star changes with depth

### Density and pressure

$r/R,\quad \rho/\rho_c,\quad P/P_c$

Gold: density. Pink: pressure. Each is divided by its own central value. The bright marker follows the selected shell.

### How much mass lies inside a shell

$r/R,\quad m(r)/M$

Teal: the mass enclosed by radius. The surface contains the whole stellar mass.

[Read the discoveries behind these models →](https://sandboxphysics.com/stories/astronomy-gravity/)

Physics tutorial

## Why the pressure rises toward the center

**Background** A star contains layers of gas that all attract each other. A shell has to support the weight of the material above it.

**Why it matters** The surface tells us little about how mass is packed inside. Compare stars with the same mass and radius but different internal concentration.

Start with the essentials

- **Focus question**: What holds a star up against its own gravity?
- **One-sentence intuition**: A pressure difference between the two faces of each layer balances its weight.

### Core mathematical model

#### Balance at each radius

$$
\frac{dP}{dr}=-\rho(r)\frac{Gm(r)}{r^2}
$$

Pressure P decreases outward. Density is rho, the mass inside radius r is m, and G is the gravitational constant. The pressure gradient supplies an outward force per volume equal to the inward gravitational force.

#### A polytropic pressure law

$$
P=K\rho^{1+1/n}
$$

The index n sets the shape of the pressure–density relation. The constant K follows from the selected mass and radius. The uniform reference is the incompressible limit at index zero.

### Common difficulties

#### Pressure and force

**Typical misconception** High pressure pushes the gas outward by itself.

**Better mental model** Pressure acts from every direction. The outward force comes from the difference between the stronger pressure below a layer and the weaker pressure above it.

### Run the experiment

1. 01

   #### Look below the surface

   Choose Broad interior and drag the bright shell toward the center.

   **What to observe:** The pressure and enclosed mass change smoothly. The two arrows stay equal because every layer is in equilibrium.

2. 02

   #### Concentrate the mass

   Choose Dense core. Compare its density profile with Broad interior at the same mass and radius.

   **What to observe:** Much more mass sits near the center. The central density rises relative to the mean density.

3. 03

   #### Compress the star

   Reduce Radius in Suns while leaving the mass fixed.

   **What to observe:** The central pressure rises steeply. A smaller sphere needs stronger internal pressure to support the same mass.

Physical conclusion

A star can be still even when both gravity and pressure forces are large.

Motion & dynamics · Starter path

## From a falling ball to an orbit

Start by measuring gravity and splitting motion into components. Then add contact forces and collisions, and follow the same laws all the way to an orbit.

[Start here → **Free Fall & Measuring Gravity** Capture a few drops and fit the camera positions to estimate gravitational acceleration. Then add air damping and watch the fit drift from the truth. Observe · 14 min](https://sandboxphysics.com/labs/free-fall/)

1. [1 Free Fall & Measuring Gravity](https://sandboxphysics.com/labs/free-fall/)
2. [2 Projectile Flight Designer](https://sandboxphysics.com/labs/projectile-flight/)
3. [3 Inclined Plane & Friction](https://sandboxphysics.com/labs/inclined-plane/)
4. [4 One-Dimensional Collision Bench](https://sandboxphysics.com/labs/collision-bench/)
5. [5 Mass–Spring Oscillator](https://sandboxphysics.com/labs/mass-spring/)
6. [6 How Orbits Take Shape](https://sandboxphysics.com/labs/orbit/)

[View the full path →](https://sandboxphysics.com/topics/mechanics/#starter-path)
