Repository navigation
Integration pin: #44 + #24 + #12 + #17 (+#9), no new code - #47
rogeriojorge wants to merge 23 commits into
Conversation
…ang inverse-design example simulation: expose max_steps, adjoint and progress_meter, with Diffrax's checkpointed discrete adjoint as the default so jax.grad/jvp/vjp compose with any real scalar of the output. diagnostics: real-valued kinetic energies. Tests check reverse = forward = finite differences on the adaptive Dopri8 path, invariance to the checkpoint budget, a reverse-pass workspace that does not grow with the step count, and a current-density functional through plasma_current. The example optimises the initial in-plane magnetic field of the Orszag-Tang vortex for magnetic-energy conversion or current-sheet intensity and benchmarks gradient cost and memory against finite differences.
…ang example validate re-evaluates the frozen initial and optimised controls of an optimize report at other resolutions and ODE tolerances, with the total-energy error. --fixed-amplitudes optimises phases only, so every mode energy stays fixed. Every report records commit, package versions and device. The objective panel plots accepted L-BFGS iterates over the line-search trials, and panel (d) adds the peak-current trace.
--tolerances now sets the Dopri8 tolerance for optimize and benchmark (first value) as well as the validate sweep. Shorter panel (d) title and no trailing separator when a report has no device recorded.
A long run imports the example once; recording the commit when the report is written can name a later checkout than the code that ran.
One RTX A4000, float64: a gradient costs about 6.5 forward solves for 4 to 64 parameters; with 8 checkpoints its peak memory is 2.8-2.9x a forward solve up to 128^2x6^3, and its workspace is flat in the number of time steps.
Label the log x-axes at the measured values only, and alternate the resolution labels below and above the workspace curves.
Labels below the forward curve crossed it and the left spine; above the top curve, at alternating heights, they cross nothing.
Left-align the leftmost label so it does not touch the spine, and show CPU instead of JAX's internal device name for reports written before provenance was recorded.
The example gains a mean_conversion objective averaged over --snapshots saved states and a sensitivity mode: forward-mode (ForwardMode, jacfwd) logarithmic derivatives of every objective with respect to collision frequency, mass ratio, guide field and in-plane amplitude at the initial and optimised controls of an optimize report, checked against centred differences, with a figure. setup takes these parameters; solve accepts an adjoint override. A test checks the gradient of a time-averaged objective against finite differences. No library change.
The scientific offset label collided with the axis label.
orszag_tang_control.py holds the shared control problem (setup, solve, objectives). 2D_Orszag_Tang_optimization.py optimises and optionally validates at other resolutions, 2D_Orszag_Tang_sensitivity.py computes forward-mode sensitivities to physical parameters, and 2D_Orszag_Tang_gradient_benchmark.py measures gradient cost and memory. Each writes a JSON report and its figure. Outputs match the previous single script on the same settings.
The helper now owns the plotting style, report writing and figure saving, and records only commit, device type and JAX version. The four files total fewer lines than the former single script, with identical outputs.
Restore README.md to main; the usage is in the example scripts' docstrings.
…study Reused unchanged from uwplasma/SPECTRAX PR #24; see that PR for its tests and rationale.
Reused unchanged from uwplasma/SPECTRAX PR #12; see that PR for its tests and rationale.
Example-local units, free-streaming Gaussian proton pulse initializer built on compute_C_nmp, parallel moments, Gauss residual, continuous probe, finite-baseline antenna voltage, fixed-window spectrogram, and an independent Faddeeva kinetic dispersion root. No library changes.
Collisionless PIC cross-check with JAX-in-Cell: review and plan (no runs yet)Why this is worth doingSPECTRAX matches the independent full-kinetic linear roots only with a strong high-Hermite sink, ν ≈ 1 ω_pe; see the G2 update in the description. In linear theory this is harmless, because the sink stands in for the electron Landau resonance, which sits deep inside the truncated electron Hermite spectrum (ζ_e ≈ 0.02). In the nonlinear phase it may not be harmless. The concern. SPECTRAX has one ν for all populations. The damping it applies to Hermite mode n is ν n³/H³. For protons at H = 128 and n ≈ 40, that is about 0.03 ω_pe, or about 1.4 ω_pc, far above the growth rates of about 0.016 ω_pc. Why it matters. Proton trapping at saturation creates velocity structure of width v_tr/σ_c = 2(eφ/T_c)^½. That width maps onto exactly those Hermite orders. Saturation level, trapping, phase-space holes and the late-time chirp could therefore be set by the numerical closure rather than by the physics. The test. A collisionless particle-in-cell (PIC) run has no Hermite truncation and no sink. It is the right independent check of the nonlinear (M2) results, which the kinetic roots cannot supply. Review of JAX-in-Cell at
|
| Run | Particles | Steps | Estimated time per seed |
|---|---|---|---|
| P1/P2, M = 1836 (to 2× saturation) | 3×10⁶ | about 3×10⁵ | about 3 h |
| P1/P2, M = 100 | 3×10⁶ | about 7×10⁴ | about 40 min |
| P3 pilot (L ≈ 2 km, Nx = 512) | about 1.5×10⁶ | about 10⁵ | about 30 min |
That is roughly one to two days of GPU time for the full gate with 4-seed ensembles. Run M = 100 first. If P2 already shows the sink bias there, M = 1836 is confirmation only. Wait for an idle card, because other users' jobs distort timing, and check the office disk (it was nearly full on 2026-09-13).
Deliverables, local only
scripts/pic_benchmark.py: P1 and P2.scripts/pic_pulse.py: P3.runs/pic_*: manifests with the commit, seed, particle counts, Δt, Δx, filter settings, E₀ history and energy error.- One comparison figure for the research note: the growth and saturation history, SPECTRAX at three values of ν against the PIC ensemble band, plus phase-space snapshots.
12201a6 to
14fa5c3
Compare
Integration branch. Do not merge. This PR is a pin target, not a feature.
This branch combines the unchanged commits of four open PRs:
12201a6): the differentiable driver, with adjoint, checkpoint, step-budget and progress controls.6f3e7cd): the stable high-order Maxwellian initializer.e428bb3): perturbation bookkeeping for all populations.bc90950), which carries Fix odd-grid RFFT energy weights; add a Hermite boundary diagnostic #9 (c3a6598): the Hermite-tail diagnostic and the odd-grid energy weights.The merge commit
a7ca601(tree4e1ad06) is the SPECTRAX version pinned by the Parker Solar Probe chirp study. That study now lives in a separate repository.Why both #44 and #24 are needed:
No other open PR contains both.
Checks at
a7ca601:All 17 existing tests pass.
Linear three-Maxwellian ion-acoustic growth rates match independent full-kinetic roots when the high-Hermite sink is ν ≈ 1 ω_pe:
The last commit on this branch only removes the study files, so the branch tree is identical to
a7ca601. When #44 and #24 are inmain, close this PR and move the study's pin tomain.