This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

← Posts

demoAINuclear physics

Nuclear level density, by counting the states

Put 100 fermions in equally spaced levels and count, one by one, the states with excitation energy . The counts are the partition numbers , exactly, up to . They grow like Bethe's ; at the count is 4.4% below the leading Hardy-Ramanujan term, and the next term of the series, , accounts for all but 0.06% of that.

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

The exact integers the test compares against come from Euler's pentagonal-number recurrence, a different computation from this program's state count; posts/refs/nuclear-level-density-by-counting.py also enumerates the states of 12 fermions by brute force and finds the same numbers. The asymptotic ratios are evaluated there in 30-digit arithmetic.

What a level density is for

A heavy nucleus hit by a neutron is left with a few MeV of excitation energy, and at that energy it has an enormous number of states. How many states lie near a given energy, the level density , decides how likely it is to capture the neutron, and what it emits as it cools down. It enters reaction rates in reactors and in the formation of the heavy elements in stars.

The simplest model that gives the right trend is a Fermi gas: nucleons that do not interact with each other, sitting in single-particle levels. Here the levels are equally spaced, at energies in units of the spacing, and there is one kind of fermion, so each level holds at most one particle (the Pauli principle). With particles the lowest state fills levels to . An excited state is any other choice of occupied levels, and its excitation energy is its total energy minus the lowest one. The program counts the choices at each .

Counting without listing

Listing every choice of 100 levels out of 200 is out of the question, so the program counts with a table: after deciding about levels to , entry is the number of ways to have placed particles in them with energy above the least possible for particles, . Level is either empty, which changes nothing, or holds the -th particle, which adds to the energy and to . Going through from the top down uses each level at most once. Energies above are never needed, and no level above can be occupied at those energies, so the table is small.

Printed

N_LEVELS: 200
1
1
2
3
5
190569292

The first counts can be checked by hand. : one state, the ground state. : one, the top particle up one level. : two, the top particle up two, or the top two particles up one each. : three. The pattern is the sequence of partition numbers , the number of ways to write as a sum of positive integers without regard to order ().

The reason: number the particles from the top, and let be how far the -th one moved up. The Pauli principle keeps them in order, which forces , and the add up to . So an excited state is a partition of into at most parts, and for the limit on the number of parts never binds.

Tests 1 of 1 pass

  • every count from E = 0 to 100 is the partition number p(E), exactly (passes)

Bethe's formula

Hans Bethe worked out in 1936 how a Fermi gas's level density grows: , where the level density parameter is times the number of single-particle levels per unit energy, which is 1 here. Hardy and Ramanujan had found the growth of the partition numbers in 1918, with the prefactor:

and is Bethe's exponent with . The two results are the same count.

Before looking: the formula is only the leading term of a series. Is it closer at or at , and by how much?

Printed

C_NEXT: 0.443288
ratio_25: 0.912704
ratio_100: 0.956285
below_25: 0.0872955
below_100: 0.0437152
gap_times_root_e: 0.437152
States of 100 fermions in equally spaced levels10⁰10³10⁶020406080100excitation energy E (level spacings)number of states ρ(E)
countedHardy-Ramanujan: e2aE/(43E)
How close the leading term is
counted / Hardy-Ramanujan1−0.4433/E
0.80.91.0020406080100excitation energy Ecounted / Hardy-Ramanujan

Tests 3 of 3 pass

  • p(100) is 4.37 percent below the leading term, and p(25) is 8.73 percent below (passes)
  • and the relative gap times sqrt(E) is 0.437 at E = 100, on its way to c = 0.4433 (passes)
  • with the next term, 1 - c / sqrt(E), the formula is within 0.0007 of the count at E = 100 (passes)

At the count is 8.7% below the leading term and at it is 4.4% below (ratio_25, ratio_100): four times the energy, half the gap. The relative gap times is at (gap_times_root_e), and posts/refs/nuclear-level-density-by-counting.py follows it with exact integers to , where it is . The limit is the coefficient of the next term of the asymptotic series, (C_NEXT), and is the dashed curve in the second figure. At it misses the count by , and the miss falls like .

Reading off the level density parameter

An experiment measures , not , and extracts from how fast grows with . The exponent alone says the slope of against is . The prefactor subtracts from it. Before running: between and , where goes from to , which of the two will the counts show?

Printed

slope: 2.3594
slope_bare: 2.5651
slope_with_prefactor: 2.35457
a_from_slope: 1.3917

Tests 2 of 2 pass

  • the slope of ln rho against sqrt(E) from 81 to 100 is 2 sqrt(a) - 2 / sqrt(E) within 0.005 (passes)
  • read without the prefactor, the slope puts a at 1.39, 15% below pi^2/6 (passes)

The counts give a slope of (slope), not : taking from them without the prefactor would put at instead of , 15% low. With the term the prediction is , within . The prefactor matters at energies this low.

Checked when the site was built: 6 of 6 tests passed, in 0.4 s. Download 2026-09-25-nuclear-level-density-by-counting.viv