Repository navigation
ForceFreeStates.Riccati - FEATURE! - Integrate each chunk once, cross surfaces through the asymptotic series and store ξ profiles - #676
Conversation
…n the result summaries
…oundary stability to the summaries
…rminant in both verdicts
…he available plots
…m an output struct
…ture/analysis-result-plots
…es instead of a MethodError
…gure theme and a plots CI group Makie becomes a weak dependency with the GPECMakieExt extension, which holds the figure theme, the label helpers and saving with whichever backend is loaded. Analysis._draw is the entry point ported plots use; it throws an ArgumentError naming `using CairoMakie` or `using GLMakie` when no backend is loaded. The plot tests move to a new `plots` group whose CI job stacks a CairoMakie environment onto LOAD_PATH, so Makie stays out of the package's own dependencies; changes under ext/ now trigger the test workflow.
…e whole Δ′ family
…d add the control-surface, (R, Z) and island views
…nd docs figures with Makie
… plane to the perturbed-equilibrium plots
…poloidal-plane panel
…t every Analysis plot
… list summaries only when a panel can be drawn
…ational surfaces on a bare equilibrium
…l surfaces on the equilibrium summary
…ercentile of |value| by default
…lar values and singular vectors
…d poloidal-plane field
…e in the eigenvector heatmap
…tests without one and compare every extractor
|
On this PR's head, DIII-D-like n = 3 Forward ( |
…ger, with whole-number ticks and labels that fit
There was a problem hiding this comment.
@matt-pharr I found no bugs. Logan and Jake covered the defaults, Solovev Δ′, Double64 and speed, so I looked at what they hadn't, at 8e2c8db12.
Checked in the code
- Crossing vs Glasser & Kolemen 2018, Eq. 36. The nonresonant coefficients are carried across unchanged. Zeroing the resonant small coefficients of the non-pivot columns is a choice of basis within the same span, since the pivot column is the pure small solution.
fill_crossings!drops the big part from every stored column. That is exact for the physical solution, because its total big coefficient is zero. - Chunk solves go through
solve_elwith the per-columnabstol. Δ′ used to depend on the chunk layout through an unsetabstol, and that cause is gone. - Test tolerances only got tighter. The three new checks at
1e-4are a near-marginal multi-n eigenvalue and the minimal two-chunks-per-segment layout, both of which the body lists as known limits. - The kinetic
singfac_mindefault reaches the auto grid as well, throughctrl.singfac_min.
Independent runs (feynman, Riccati Δ′ example plus its q₀ = 0.9 variant):
- Threads: 1 against 8 is bit-identical.
- Chunks: 60 against automatic agrees to 1e-9, and 20 to 1.4e-7. The body says "identical for 13 to 106 chunks"; "to about 1e-7" is closer.
- Grid: a 3× change in
psi_accuracyeither way moves the Δ′ diagonal by 0.05–0.7% (1.2% on the q₀ = 0.9 deck's q = 2 entry) andet[1]by 1e-5 to 1e-4.
So the integrator's own error (crossing, chunks, threads) now sits four or more decades below the grid's. The 0.1% knot move in the release note is inside that grid band, so it isn't a concern. It does mean Δ′ is grid-limited at the 0.1–1% level on the default psi_accuracy. A line in the stability docs saying so, and that varying psi_accuracy is the convergence check, would stop people reading the 3e-8 Forward–Riccati agreement as Δ′ accuracy. Not blocking.
Related: with the fixed start now the default and the ideal torque at round-off, #464 only concerns the opt-in Frobenius start. Worth retitling or narrowing it when this lands.
|
I love that we are arguing 1e-7 and 0.1-1% errors on these automated approaches rather than 100% wildness a on manual shots in the dark. Speaking of shots in the dark... @jhalpern30 just touched up vacuum accuracy that was spline limited. Any insights to bring back to our fundamental plasma equilibrium and profile splines that might help knock out this final 1%? |
Honestly, could be something there. I don't know if its worth waiting holding up this PR, since I can't get to it this week. Anthropic just further tanked their weekly limits so I barely have enough left to get my normal work done on Pro. But I do have a banked usage reset I'm going to use after Thanksgiving so I can definitely look into it then. The unreliability of the splines/equilibria has actually come up a few times in semi-unrelated contexts. I remember also when implementing stellarator symmetry, the nominal Solovev boundary directly from examples was only stellarator (up-down) symmetric to like 1e-3 so I had to manually clean it up. |
|
@jhalpern30 any rabbit holes you go down regarding equilibria definitely also take a look at using Stuart's tokamaker I-file setup. Not sure if what you're referring to has to do with the equilibrium splining in GPEC or if it is how the equilibrium is represented outside but the I-files are far better for Delta' convergence for example |
…single-pass Conflict in src/Precompile.jl: develop's workload now loops over Riccati, Forward and Galerkin; keep that loop and drop renorm_threshold, which [Riccati] no longer accepts.
|
Sweet. Yeah, no need to hold this pr but it would be great if you could flag this on your back burner and see what transfers at some point when you have a breather |
logan-nc
left a comment
There was a problem hiding this comment.
This is great. Let's start closing some of these prs
Human note, please read: the Riccati integrator integrated the entire domain in multiple passes before, IMO most likely as an artifact of layers of vibe coding. The main energy result from riccati was previously coming from a full forward pass that was happening inside of Riccati (!!!) which also took up a huge portion of the runtime as it was entirely serial. This dated back to when Riccati was first implemented in February.
This PR achieves several things, the highlights of which are:
Enjoy!
Release note
singfac_mindefault changed for every integrator. Energies: Forward 4e-5 or less (0.94% onlar_reversed_shear_n1, 0.50% onsolovev_n1), Riccati 0.1–0.9%. Δ′ diagonal up to 0.10%, Δ_EF up to 0.27%, SLAYER growth rates up to 0.87%, resonant fields and island widths 0.01% or less (harness @ 9a2f3f7)singfac_mindefaults to 5e-4 (was 1e-4), and to 1e-5 for a run with a kinetic source.[Riccati]eulerlagrange_tolerancedefaults to 1e-10 (was 1e-8). Removerenorm_threshold,numsteps_initandnumunorms_initfrom[Riccati].extended_precision_bvpdefaults tofalse. In scripts:ffs.galerkin.solution→ffs.basis,:gal_native→:unit_edge,PlasmaResponse.odet_from_gal→unit_edge_basis. Ingpec.h5: matched ξ moved fromForceFreeStates/Solutions/GalerkinIntegration/toForceFreeStates/Solutions/Match/.Both ODE integrators now cross rational surfaces through the asymptotic series, so energies no longer depend on
singfac_minand Forward and Riccati agree. Riccati integrates each chunk once: 0.9 s instead of 7.5 s on the DIII-D-like example at 16 threads. Against Forward it is faster from about 8 threads, level at 4, and about twice as slow on one.Figures: https://claude.ai/artifact/QdkZdvShvLLmEJBGcMFhAS
Regression report
Base
feature/analysis-plots-overhaul@ 9880101, on ITER's SDCC cluster, run at9a2f3f750after develop (with #650 and the larger precompile workload of #678) was merged up the stack. 29 cases: 9 unchanged, 20 changed. Every row matches the run at8e2c8db12on the same node type to within 0.005%. That run used a different node type of the cluster than the one atb3a2ad134, and the absolute values move with it in both branches. Energy and Δ′-diagonal differences are as before; root-found and near-tolerance quantities differ: SLAYER coupled γ 0.87% (was 0.33%), Δ_EF ondiiid_n1_riccati_q10.27% (was 0.10%), CRF Q_peak ondiiid_slayer_n1_chi_perp_e0.28% (was 0.06%), and the NTV torque intj_kinetic_ntv_ratesnow just exceeds its tolerance (1.3e-8).Cases and every quantity that moved
Notes for reviewers
What changed
src/ForceFreeStates/Riccatigoes from 1511 to 803 lines.Surfaces/Crossing.jl.singfac_min= 5e-4 everywhere: it no longer sets an error, only where the series takes over.crossing_fill_points,crossing_fill_min).ffs.basisfor[Match].Free-boundary
et[1], DIII-D-like Riccati examplesingfac_minThe two integrators agree to 3e-8 on ten example decks. Riccati results are identical for 13 to 106 chunks and for 1 and 16 threads.
Known limits
singfac_min.singfac_min= 1e-5.Left for #666:
plasma_responseon a Riccati result, and the fixed-edge Δ′ for matching.Issues: closes #669, closes #671, closes #481, closes #370, closes #401, closes #333, closes #253, closes #648 (by hand, since this PR is stacked). Not run from #669's list: a crossing of a Mercier-unstable surface. Supersedes the Riccati half of #668. Stacked on #658; #666 sits on top.
Tests: 58 of 60 test files pass on ITER's SDCC cluster. The other two are plot files that need CairoMakie there.
Details and caveats
Commits
f17055d37restructures the Riccati integrator.ecac988fcpublishes ξ profiles from a Riccati result (first part of ForceFreeStates.Riccati - Reconstruct ξ profiles from the Δ′ BVP solution #671).341814b43shares the outer solutions with Galerkin (second part of ForceFreeStates.Riccati - Reconstruct ξ profiles from the Δ′ BVP solution #671).d0f04565dgives Forward the same crossing and setssingfac_minto 5e-4 (ForceFreeStates - FEATURE! - Cross ideal singular surfaces with a Frobenius-basis jump #669).8948627bdfills the stored solutions and moves the shared crossing code into one file.07cf80d5dis the result of a timing audit: scheduling, threading of two shared loops, and fewer copies.8fc6c5c3eis the follow-up to review: the two new defaults, a warning where Δ′ is unresolved, a bracketed root-find in the edge scan, and tighter tests.Timing audit (DIII-D-like Riccati example on ITER's SDCC cluster, whole integration, best of three)
07cf80d5d@threadsschedule left the cores 65–75% busy on the chunk loop (45% at 107 harmonics); the greedy schedule keeps them above 90%.mats.07cf80d5dis bit-for-bit neutral with one BLAS thread and identical at 1 and 16 Julia threads. Against a run with several BLAS threads, the edge-scan energies differ by up to 7e-10 (relative) and Forward's stored criterion by up to 7e-9.Riccati against Forward (integration alone, best of three, same deck and cluster; both give the same
et[1]to eight digits)Issues this closes
et[1]is 0.04485452 for both integrators at everysingfac_minfrom 1e-3 to 1e-5; on the base Riccati gave 0.08427, 0.06561, 0.04933 and 0.04533 over the same range, 10% high at 1e-4.Why 5e-4 (integration tolerance 1e-12)
Why the fill matters downstream
diiid_multi_nthose rows moved by up to 13% (resonant field) and 26% (forcing-driven jump) without the fill, and 0.01% or less with it.Checks without a reference integrator (ten decks, a truncated run, two runs with q = 1 inside)
Caveats
diiid_n1_riccati_q1the change is all knots: moving them alone changes the q = 1 and q = 2 entries by 6.7e-3 and 6.1e-3, and changing the crossing distance alone by 4e-6 or less.tj_n1reports a change of 3.4 in the per-mode plasma and vacuum energies that cancels in the total (3e-4).Im(et[1])and the perturbed-equilibrium torque of ideal runs fall from 1e-6 to round-off.truncate_at_dW_peakthe two integrators can pick slightly different edges (0.995142 and 0.995116 on the six-surface DIII-D deck).singfac_minscan is a test on the Solovev fixture and the table above, not a harness case.🤖 Generated with Claude Code