Repository navigation
Equilibrium - FEATURE - Read inverse i-files (ldp_i) such as TokaMaker save_ifile output - #511
Conversation
…r save_ifile output Port of Fortran read_eq_ldp_i. eq_type = "ldp_i" (alias "ifile") reads the sequential unformatted i-file (real*8 or real*4) into an InverseRunInput. The optional trailing FF′ and p′ records feed profile_source = "derivatives" via file_profiles, as for g-files; without them the tabulated F and P are used. equilibrium_gse! now returns its residual arrays and the θ-integrated residual per surface, so the Grad-Shafranov error can be checked programmatically. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Checks i-file vs g-file agreement from one TokaMaker solve, GS residual, real*4 vs real*8, the "ifile" alias, and the profile_source fallback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@StuartBenjamin I am working on a code review for this, but in the mean time, this is a significant feature addition. In order to make sure everything is working well (and this should be cheap because the code is reasonably fast) I would really love to see some convergence scans showing convergence of n=1 delta W between gfiles and ifiles, or something similar you can use to convince us that this feature works properly. Furthermore, this ifile_snap thing seems important! Hopefully we can get that merged into Tokamaker soon |
…heir field-line integral The inverse solver kept the i-file's tabulated q, splined in psi, while the SFL angle nu and the metric are built from the field-line q of the interpolated geometry. Where the input surfaces are coarse near the edge (q ~ log(1-psi)) the two disagree (q up to +0.7 at psi_N 0.9985 on a uniform 129-surface file), which moves psilim and spoils Delta' (2/1: 6.39 vs 8.28 for RDCON). ldp_i/ifile now use the field-line q, as Fortran inverse_run does; LAR, CHEASE and efit_by_inversion keep their input q. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ker i-files read_ldp_i tells the optional records apart by length: FF' and p' (npsi each), then [psi_axis, psi_LCFS] (2). With the bounds, psi_N and psio are normalised to the true LCFS, so the padded last surface sits below 1; psihigh is clamped to the outermost input surface for inverse inputs (resolve_psihigh!), on the reader and rerun paths alike. Files without the record read unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…q and profile docs
LDP_I_KINDS replaces the two hard-coded ("ldp_i", "ifile") lists, so the inverse solver does not
repeat the reader's kinds. One comment at q_from_geometry explains both q sources. The profile
docstrings no longer say direct-only or x = 1 at the boundary, since the i-file reader calls them
with its last node at 1 - pad. psihigh_resolved's docstring says the clamp applies to i-files and reruns.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… it to the g-file's The ratio to the g-file residual held only because FastInterpolations' periodic spline is wrong on non-uniform θ grids (FastInterpolations.jl#220), which inflates the direct refit's residual. With the fix the g-file residual is 6e-6 on this data, below the i-file's 1e-4, so the ratio check would fail once the fix is released. The absolute bound stays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@matt-pharr here is the g-file vs i-file scan you asked for. Setup
δW, kinked profiles (values; mtheta 512)
ifile_snap. No longer needed. OFT #364's cut-cell writer puts every i-file point on the FE flux surface to ~1e-14 of the flux range, with no field-line tracing. OFT #357 (which had the snap) is closed. What changed in this PR since you looked:
Scripts and data are available if you want to rerun any of it. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s" stays an option Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Release note
"values"default, diiid_n1 and solovev_n1 are identical (harness @ 88f6ecc)GPEC can now read inverse i-files (
eq_type = "ldp_i"or"ifile"), such as OpenFUSIONToolkit TokaMaker'ssave_ifileoutput. This is a port of the Fortranread_eq_ldp_i.profile_source(added by #506) now defaults to"values", the tabulated F and P;"derivatives"stays an option.Regression report
regress --cases diiid_n1,solovev_n1 --refs 0e68a0553,88f6ecc96(the develop commit #506 branches from vs this head; julia 1.11.7, pinned manifest, 2 threads): diiid_n1 53 unchanged, solovev_n1 22 unchanged. Against #506 itself (b3f412f), diiid_n1 changes (44 of 53 quantities), because #506 reads the g-file with"derivatives"; this also makes the STRIDE Δ′ check inruntests_parallel_integration.jlthat #506 fails pass again (94/94). No harness case reads an i-file; the unit tests cover the reader.Full report
Notes for reviewers
GPEC had no reader for the i-file, the inverse format TokaMaker's
save_ifilewrites. An i-file stores the flux surfaces themselves, so the equilibrium does not depend on a g-file's R,Z grid.Changes
read_ldp_i(ReadEquilibrium.jl) builds the sameInverseRunInputandInverseIngest(forgpec.h5reruns) as the CHEASE readers. Reals may be real8 or real4 (the Fortran reader takes only real*8).profile_sourcethroughfile_profiles, as in the g-file reader;[ψ_axis, ψ_LCFS](save_ifile(psi_bounds=True), ALL - IMPROVEMENT - Self-describing HDF5 metadata (issue #226, PR B) #364) normalizes ψ_N to the true LCFS.resolve_psihigh!clampspsihighto the outermost file surface, for i-files and on the inverse rerun path.inverse_rundoes; the tabulated q, splined in ψ, is inaccurate where edge surfaces are coarse. Other inverse inputs keep their input q.equilibrium_gse!returns its residual arrays (HDF5 output unchanged).Results (one TokaMaker DIII-D-like H-mode solve, written by
save_ifileandsave_eqdsk;grid_type = "ldp",psihigh = 0.995, Hamada)Tests: two testsets in
test/runtests_equil.jlon 137 KB of data from the same solve (test/test_data/TokaMaker_ifile/);runtests_equil.jl329/329. Scripts: read_ifiles_scripts.zip. The δW scan requested in review is in this comment.Dependencies: stacked on #506 (this PR's base), which adds
profile_sourceandfile_profiles; merge after it. This PR changes #506's default from"derivatives"to"values".🤖 Generated with Claude Code