---
title: "Replaying an official Jeans initial condition"
description: "Read a pinned native Athena input, recover its three-dimensional wavevector and recompute stable and growing modes before checking a separate gas solver."
canonical_url: "https://sandboxphysics.com/stories/molecular-clouds/replay-the-official-jeans-input/"
language: "en"
page_type: "story"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/stories/molecular-clouds/replay-the-official-jeans-input/"
last_modified: "2026-11-04"
---

[Molecular cloud collapse and magnetic support](https://sandboxphysics.com/stories/molecular-clouds/)

Molecular clouds · L3

# Replaying an official Jeans initial condition

Sandbox Physics · 2026-11-04

Open the Athena++ Jeans input at commit 053bc738d5c85dac717326b4338b34c7db4e715d. Its box dimensions let you recover the wavevector and recompute stable and growing linear modes. The standalone package contains complete small original files; start with them, then run the equivalent mode and a separate two-dimensional gas calculation.

## Before you begin

Read L1 on dispersion and L3 on grid comparisons. You need to extract an archive, run Python and read JSON. These are original numerical benchmark inputs, not molecular-cloud observations. The equivalent-mode calculation requires no Athena installation.

## Identify the original files and their license

Extract the scientific ZIP and enter molecular-cloud-jeans-science. The official directory contains athinput.jeans\_3d, the Jeans initialization source, two regression scripts and the complete BSD license. manifest.json records member lengths and SHA hashes. These members belong to one pinned commit.

The Python files implement independent calculations. replay.py first checks member integrity, then actually executes the scientific steps into the directory you name. Ordinary NumPy, SciPy and Matplotlib dependencies need installing once; subsequent scientific replay is offline. The package contains neither simulation-tool binaries nor restricted paper originals.

Run the full replay first and keep its terminal output and replay-receipt.json. The eleven space-reference cases account for most of the runtime. Reference JSON provides a comparison; the fresh output directory supplies the recomputed results. Use the virtual-environment interpreter in the later commands too.

```
python3 -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
PYTHONDONTWRITEBYTECODE=1 .venv/bin/python replay.py --out-dir rerun
```

Reading: Athena++ native Jeans input and regression at commit 053bc738d5c85dac717326b4338b34c7db4e715d · Molecular-cloud Jeans standalone scientific reproduction

## Recover the wavevector from the rectangular box

The native lengths are $L_x=1$ and $L_y=L_z=0.5$. The initialization gives one phase turn across each box direction. Each component is therefore $2\pi/L_i$. The wave is not confined to the longest side.

Its wavevector is $(2\pi,4\pi,4\pi)$, with magnitude $6\pi$ and wavelength $1/3$. The original wave passes obliquely through a three-dimensional box. The equivalent linear calculation rotates coordinates along that wave and uses its actual wavenumber.

Locate wavevector and wavelength in the output and compare them with the input. Substituting the longest side as wavelength would also change the inferred gravity scale and oscillation frequency.

$$
\mathbf k=\left(\frac{2\pi}{L_x},\frac{2\pi}{L_y},\frac{2\pi}{L_z}\right),\qquad \lambda=\frac{2\pi}{|\mathbf k|}=\frac13
$$

One phase turn in each direction defines three components. The vector magnitude determines the wavelength.

Reading: Athena++ native Jeans input and regression at commit 053bc738d5c85dac717326b4338b34c7db4e715d

## Read the sound derivative and the regression override

An old input comment mentions pressure 0.1. The actual initialization source sets $\rho_0=1$ and $p_0=1/\Gamma$, where $\Gamma$ is the adiabatic exponent. Its adiabatic derivative gives $c_s^2=\Gamma p_0/\rho_0=1$. The initialized state defines the pressure used here.

The native Jeans ratio is $0.5$. The unstable regression script overrides it with $1.5$ and sets end time $0.046$. Here the ratio refers to the calculated wavelength, $\lambda/\lambda_J$, so changing it changes the gravity parameter too.

Our equivalent linear mode uses an isothermal derivative with the same numerical sound speed. This permits a first-order Jeans-frequency comparison. Reproducing nonlinear adiabatic evolution would also require the original energy equation.

$$
4\pi G\rho_0=(J|\mathbf k|c_s)^2,\qquad \omega^2=c_s^2|\mathbf k|^2-4\pi G\rho_0
$$

Use this input’s native units. The separate dimensionless gas patch sets its gravity coefficient to one.

Reading: Athena++ native Jeans input and regression at commit 053bc738d5c85dac717326b4338b34c7db4e715d

## Recompute the two equivalent time histories

Run audit\_official\_input.py separately. It writes official-input-audit.json and two NPZ time histories. The records array distinguishes the native stable case from the unstable regression override, with sound speed, gravity, frequency squared, end time and comparison error.

The stable case has $4\pi G=88.8264$, $\omega^2=266.479$ and end time $2$. The unstable override has $799.438$, $-444.132$ and $0.046$, respectively. These use native time units and cannot be aligned directly with a gas calculation using $4\pi G=1$.

The source also includes an extra density seed of order amplitude squared. With main amplitude $10^{-6}$, that term is $10^{-12}$. The official first-order analytic reference and this equivalent linear calculation omit it; the output retains the distinction.

The executed programs here are our linear integrator and analytic comparison. Athena has not been compiled, and its three-dimensional MPI, FFT or multigrid regressions have not run. Report both the original input source and the independent program that executed the comparison.

```
.venv/bin/python audit_official_input.py --input official/athinput.jeans_3d --out-dir native-check
```

Reading: Athena++ native Jeans input and regression at commit 053bc738d5c85dac717326b4338b34c7db4e715d · Molecular-cloud Jeans standalone scientific reproduction

## Compare a separate nonlinear gas calculation

verify\_prototype.py evolves periodic isothermal gas invariant in the third direction. Finite-volume fluxes update density and momentum, and Poisson’s equation subtracts mean density. The fixed $J=1.5$, contrast $0.2$ case is recalculated at 32, 64 and 128 cells per side.

In verification.json, inspect linearHydro, nonlinearHydro and spatialAdjacentRestrictedRms. The first compares with analytic small waves; the latter fields examine finite amplitude and grid refinement. A successful small-wave check cannot by itself certify late strong compression.

Inspect the complete NPZ state too. Average fine subcells into a coarse cell before comparing fields. Selecting matching array indices would change the sampled position and averaging region.

```
.venv/bin/python verify_prototype.py --out-dir gas-check
.venv/bin/python verify_domain.py --out-dir domain-check
```

Reading: Molecular-cloud Jeans standalone scientific reproduction

## Refine the independent reference in space

spectral-space-verification.json separates flux quadrature, retained spatial modes and time-step comparisons. Hold 64 points fixed while increasing quadrature from twofold to fourfold, compare 64 and 128 retained grids, then halve the time step at fixed spatial settings. All ten original support cases and the fixed longer case appear.

The default command recomputes every one of the eleven cases. It does not use the development option that reuses completed local arrays. Check that reusedCompletedLocalNumericalRun is false for each case, then read the numerical differences. Locate the inputs and saved states as well as the PASS status.

The manufactured near-zero-density rational-flux counterexample is recalculated too. It exposes the incorrect assumption that output masking always removes aliasing. That algebraic test lies outside the gas operating domain.

```
.venv/bin/python verify_spectral_space.py --out-dir reference-check
```

Reading: Molecular-cloud Jeans standalone scientific reproduction

## Read the retained failures by their purpose

The failures directory retains coarse 32-cell cancellation, the point-versus-average comparison and the original pseudospectral source and results. Names identify the earlier versions. The current method and fresh output explain the correction separately.

A long-time stress run retains a state with $N_J=8.01589$ and rejects its next candidate below eight cells. It demonstrates stopping; it has no late same-time spatial accuracy certification. Turning that peak into a stellar-fragment mass would change the question the record actually answers.

editorial/worked\_examples.py reads the actual accepted and rejected diagnostics from verification.json and independently recalculates their Jeans-cell indicator. It also computes the chapter’s growth amplitudes, magnetic-angle examples and specified mass-list exercise.

```
.venv/bin/python editorial/worked_examples.py --science-results rerun --out worked-examples.json
```

Reading: Molecular-cloud Jeans standalone scientific reproduction

## Leave enough information for the next calculation

Record the original commit, member hashes, interpreter and dependency versions, physical initial conditions, dimensions, boundary treatment and actual end time. State what changed in each numerical comparison. Keep failed cases and stop reasons so another reader can continue the check.

An interactive export needs the model branch and complete field too. Dragging the density center prepares a new initial condition. Records before and after that preparation should identify different initial positions; it does not represent instantly moving an evolved cloud.

The default replay runs nine scientific programs. Its last program, implementation/export\_reference\_fields.py, regenerates all eleven complete gas fields and the independent magnetic matrix-exponential comparison. These arrays check the browser calculation; they are not played back as its animation.

The first magnetic integration step $0.01$ missed the unchanged $10^{-9}$ component-error threshold in one of eighty independent states. Refining to $0.0025$ reduced the maximum error to $6.16\times10^{-12}$. The original failed log stays in failures. Read reference/magnetic-step-refinement.json and the fresh complete-field output together: solving a linear system accurately does not validate nonlinear magnetic clouds.

Apply the same sequence to another benchmark: identify files and units, reconstruct the wave and initial state, run the named program, then compare references and failures. Each step leaves a concrete object that someone else can examine.

```
.venv/bin/python implementation/export_reference_fields.py --science-results rerun --out complete-fields.json.gz
```

Reading: Molecular-cloud Jeans standalone scientific reproduction · Athena++ native Jeans input and regression at commit 053bc738d5c85dac717326b4338b34c7db4e715d

## Exercises and explanations

1. How do all three box lengths give the native wavelength of one third?

   Read the explanation

   One phase turn in every direction gives $\mathbf k=(2\pi,4\pi,4\pi)$ and $|\mathbf k|=6\pi$. Thus $\lambda=2\pi/|\mathbf k|=1/3$. Reading only the longest side drops two wavevector components.

2. If the equivalent mode matches its analytic curve, has the Athena three-dimensional regression run?

   Read the explanation

   The executed calculation is the independent Python linear integrator. Official files specify its input conditions. The original three-dimensional solver, parallel implementation and energy equation have not executed. Report the actual program and comparison level.

3. Why can labeling two outputs “time two” still leave them incomparable?

   Read the explanation

   Different native gravity coefficients imply different gravitational time units. Read the physical units or convert each to its own dimensionless gravitational time. Matching axis names are insufficient when the underlying definitions differ.

## Try the prediction

### [Watch pressure and gravity change the same gas](https://sandboxphysics.com/labs/molecular-cloud-jeans/)

1. Save a complete gas-branch field and note its Jeans ratio, initial amplitude, density center and actual time. Compare with the same conditions in the standalone calculation.
2. Move only the density center, prepare the new state and save another evolution. Check that the initial position changes while the mass and periodic-boundary convention stay the same.
3. List the official equivalent mode, nonlinear gas patch and linear magnetic branch separately. For each record, state its dimensions, variables and the comparison it can answer.

## Standalone scientific materials

[Download the scientific ZIP](https://sandboxphysics.com/stories/molecular-clouds/materials/molecular-cloud-jeans-science.zip) · [Read the setup and calculation scope](https://sandboxphysics.com/stories/molecular-clouds/materials/README.md)

The package recomputes periodic gas, separate linear magnetic modes, native-input comparisons and resolution tests. It includes complete small licensed official members and newly written scientific code.

[Previous: When a grid can no longer resolve contraction](https://sandboxphysics.com/stories/molecular-clouds/when-a-cloud-grid-stops-being-evidence/) [Next: One converged mass scale does not establish an IMF](https://sandboxphysics.com/stories/molecular-clouds/why-a-converged-mass-is-not-the-imf/)

## Sources and calculation scope

1. [Athena++ native Jeans input and regression at commit 053bc738d5c85dac717326b4338b34c7db4e715d](https://github.com/PrincetonUniversity/athena/tree/053bc738d5c85dac717326b4338b34c7db4e715d)

   Complete BSD-3-Clause members: inputs/hydro/athinput.jeans\_3d, src/pgen/jeans.cpp, and the stable/unstable gravity regression scripts. The tutorial computes the equivalent first-order Fourier mode; it does not compile or execute Athena.

2. [Molecular-cloud Jeans standalone scientific reproduction](https://sandboxphysics.com/stories/molecular-clouds/materials/molecular-cloud-jeans-science.zip)

   Independent finite-volume and oversampled pseudospectral producers; analytic Jeans and full linear MHD references; all ten support cases, a fixed longer case, original official inputs and retained failures. Default replay actually recomputes its scientific steps offline after ordinary Python dependencies are installed.
