Skip to content

Add mainline magnetic reconnection example - #34

Open
rogeriojorge wants to merge 4 commits into
mainfrom
agent/reconnection-mainline-example
Open

rogeriojorge wants to merge 4 commits into
mainfrom
agent/reconnection-mainline-example

Conversation

@rogeriojorge

@rogeriojorge rogeriojorge commented Jul 16, 2026 •

Copy link
Copy Markdown
Member

Problem

Main has no magnetic-reconnection example on the rFFT solver.

Change

One file, Examples/2D_magnetic_reconnection.py: periodic double Harris sheet with the Camporeale et al. (2006, sec. IV.C) parameters (m_i/m_e=16, omega_pe/Omega_ce=3, T_i=T_e, rho_i/a=2, guide field 5). Harris pressure balance gives v_th,e = sqrt(2)/6 c and hence a = sqrt(2) d_e; thermal speeds a/6, a/24 and drifts ±1/(6a) follow. Evolves in chunks, fits the half-sheet magnetic-mode growth, and writes a growth/flux plot, a J_z movie with A_z contours and an npz file. --perturbation 1e-4 is the linear diagnostic, 0.1 a finite-seed nonlinear island.

Effect (CPU, shared 36-core node)

  • default 33x9, H=4, t=10: finite, 12 s
  • 65x17, H=4, t=500, perturbation 0.1: closed island, 258 s; last-Hermite-mode fractions 4.3e-8, 2.6e-5, 3.5e-5
  • Linear tearing (perturbation 1e-4, ny 5, nu 1, t = 1000; ky = 1 mode at the X point, fit over 500 <= t <= 1000) against Camporeale's 0.256 Omega_ci = 5.33e-3 omega_pe:
nx H gamma vs paper runtime
65 10 2.39e-3 -55 % 3.7 h
129 6 4.76e-3 -11 % 53 min
129 8 4.84e-3 -9 % 3.3 h
257 6 5.07e-3 -4.9 % 3.9 h

The rate converges in nx (the sheet needs nx >= 257 in this box); extrapolating nx (second order) and H gives about 5.25e-3, 1.5 % below the paper. The docstring records the table.

Tests

Example only, no solver change; full suite 7 passed (also with JAX_ENABLE_X64=1).

Update 2026-10-03 (head 87c4cf7)

  • Growth observable and fit now match: the docstring names the observable (first ky mode of (Bx, By) over the left half-box), and gamma is a least-squares fit of its log over --fit-window (default: second half of the run). The output also has the fit rms log residual and the rates of the two halves of the window, as a check that the window is in a single exponential phase. The earlier fit through local maxima for t >= t_max/4 is gone.
  • The movie shows the kinetic current J_z/Omega_ce from the Hermite moments (plasma_current). It is not labelled curl B, which also contains dE_z/dt.
  • Hermite tails: hermite_tail_fraction per population (from Fix odd-grid RFFT energy weights; add a Hermite boundary diagnostic #9) replaces the unweighted all-species sum without Parseval weights. Depends on Fix odd-grid RFFT energy weights; add a Hermite boundary diagnostic #9. With main's two-population dCk bookkeeping, populations 3 and 4 keep their k=0 background, so the tail fractions are exact only after Fix multispecies perturbation bookkeeping #12.
  • The convergence table is kept, but labelled as measured with the old peak fit and not re-measured. The "second-order extrapolation to 5.25e-3" is removed because no spatial order was measured.
  • Run here: default smoke (33x9, H=4, t=10) and t=40 with --fit-window 10 40, both finite, on main + Fix odd-grid RFFT energy weights; add a Hermite boundary diagnostic #9 (4.6 s and 10.5 s on a laptop CPU). These short runs are transient, not tearing growth: the rms residual is 0.46 and 0.98, so the new output flags them.
  • Equilibrium normalization: checked independently (see Correct Camporeale tearing sheet width and box size #33). Harris drift V = v_th^2/(Omega_ce a) = 1/(6a) and J_z/Omega_ce = (curl B)_z = sech^2/a with a = sqrt(2) d_e. This example uses the exact 1/3, 1/48 constants.

@codecov

codecov Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rogeriojorge
rogeriojorge marked this pull request as ready for review July 17, 2026 20:26
…c current, per-population tails

The growth rate is now a least-squares fit over an explicit --fit-window
(default: second half of the run) of the observable the docstring names, with
the fit residual and the per-half rates printed. The movie shows the kinetic
current J_z/Omega_ce instead of curl B, which also contains dE_z/dt. Hermite
tails use hermite_tail_fraction per population (needs #9). The convergence
table is labelled as measured with the previous peak fit and the assumed
second-order extrapolation is removed.
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