Skip to content

Maxwellians narrower than their Hermite basis, and a bump-on-tail example - #51

Open
rogeriojorge wants to merge 5 commits into
mainfrom
feature/maxwellian-width-and-bump-example
Open

rogeriojorge wants to merge 5 commits into
mainfrom
feature/maxwellian-width-and-bump-example

Conversation

@rogeriojorge

@rogeriojorge rogeriojorge commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Target: main. Head: 30e67c4 (rebased on main ab87385; old head ff6a0a0). No dependencies. Supersedes #24.

Problem

  • compute_C_nmp assumed every Maxwellian has exactly its basis width.
  • Its factorial formula overflowed to NaN at high order (Nn = 112 and 256 on main).
  • A beam expanded in its own narrow basis diverges once it is trapped and spreads.

Change

  • Independent widths. compute_C_nmp(..., vth_s=None) takes physical thermal speeds separately from the basis widths alpha_s. The default alpha_s/√2 keeps the previous result.
  • Stable recurrence. Coefficients cⁿHₙ(d/c)/√(2ⁿn!), with c² = 1 − 2vₜ²/α², come from a three-term recurrence run as a lax.scan. There are no factorials, and compile time does not depend on Nn.
  • Corrected convergence statement.
    • The basis weight is exp(-(v-u)²/α²). A Maxwellian of standard deviation σ has finite weighted norm ∫ f²/F_b iff σ < α, and its normalised coefficients decay like |1 − 2σ²/α²|^(n/2).
    • The matched Maxwellian is σ = α/√2. So Maxwellians broader than matched (α/√2 ≤ σ < α) are admissible. The previous text wrongly said a Maxwellian wider than α/√2 does not converge.
    • This is a statement about this fixed weighted norm and the initial expansion only. It says nothing about other formulations, or about whether a truncated nonlinear run stays resolved.
  • Examples/1D_bump_on_tail.py (Nx 33, Nn 128, ν = 3, t = 100; about 9 s on a laptop CPU).
    • The beam is expanded in the bulk basis.
    • The dashed γ = 0.198 line is labelled as linear theory, for orientation only.
    • The docstring says that neither the line nor this single resolution certifies the nonlinear saturation phase.
    • The example prints max|E_k| and min f.

Tests (local, macOS CPU, Python 3.12, jax 0.11.2, at 30e67c4)

python -m pytest -q -n 2 tests: 19 passed.

Tests in tests/test_initialize_maxwellian.py:

  • Closed form: the default and explicit alpha_s/√2 reproduce the old formula (rtol 1e-12).
  • Narrow beam: a narrow Maxwellian is reconstructed to 1e-12.
  • High order: Nn = 256 stays finite.
  • New: σ/α = 0.5, 1/√2, 0.85, 0.95 against independent quadrature.
    • Setup: two species, anisotropic α per axis, shifted centres, σ < α on every axis, Nn = 96 × Nm 6 × Np 4.
    • Every C_nmp equals the product of 1D coefficients projected by independent quadrature, to 1e-11 of the maximum.
    • The tail decay rate matches √|1−2σ²/α²| within 10%.
  • New: at and beyond the bound.
    • At σ = α, the even coefficients stop converging: Σ|g|² keeps growing.
    • At σ = 1.1α they grow.
    • The recurrence stays finite in both cases.

Example run: python Examples/1D_bump_on_tail.py gives max|E_k| = 0.5298 and min f = −0.019, in 8.5 s wall time. This is a single resolution and not a convergence study.

GitHub CI: see the checks on this head. The local results above are not CI results.

Owner decision

Please personally check the weighted-norm statement and the test fixtures before merging.

@codecov

codecov Bot commented Sep 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
spectrax/_initialize_maxwellian.py 100.00% <100.00%> (+62.96%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

vth_s (default alpha/sqrt(2), the previous behaviour) gives the closed form
c^n H_n(d/c) / sqrt(2^n n!) with c^2 = 1 - 2 vth^2 / alpha^2, computed by a
three-term recurrence (no factorials). A thin beam can then share a wide
basis, where its expansion stays convergent as it spreads.
The unrolled loop compiled in 21 s at Nn=256; the scan compiles in well under a second. Adds a finiteness test at Nn=256.
…vth < alpha/sqrt(2)

The expansion of a Maxwellian of standard deviation vth in the basis with weight
exp(-(v-u)^2/alpha^2) converges in that weighted norm iff vth < alpha; the
coefficients decay like |1 - 2 vth^2/alpha^2|^(n/2). The matched Maxwellian has
vth = alpha/sqrt(2), so broader-than-matched Maxwellians are admissible.

Tests project shifted, anisotropic two-species Maxwellians with vth/alpha = 0.5,
1/sqrt(2), 0.85, 0.95 onto the basis by independent quadrature (Nn = 96), check
the predicted decay rate, and show the series stops converging at vth = alpha.
The bump-on-tail example's growth line is labelled as linear theory for
orientation, not as evidence of nonlinear convergence.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant