Skip to content

GPEC - DEPRECATION - deprecating mat_flag, ode_flag, cyl_flag - #342

Merged
github-actions[bot] merged 5 commits into
developfrom
deprecate_flags
Jul 30, 2026
Merged

GPEC - DEPRECATION - deprecating mat_flag, ode_flag, cyl_flag#342
github-actions[bot] merged 5 commits into
developfrom
deprecate_flags

Conversation

@jhalpern30

@jhalpern30 jhalpern30 commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Deprecating some flags that have stuck around for a while and should be removed before cleanups start for GPEC 2.0.

  • ode_flag: a trivial flag that ran the ODE. I can't think of a reason why you'd ever want to not run it
  • cyl_flag: centered the m grid around 0, I don't think anyone used this
  • mat_flag: this was determining whether or not to dump the matrices to HDF5. While I think this is potentially useful, it shouldn't be in control and should be in some sort of DEBUG namelist once we get that up and running

I added all deprecated parameters to the deprecated keys list.

Note that for some of the benchmarks, the formatter wasn't run on them so the diff is massive - all I did was remove ode/mat_flags.

@jhalpern30 jhalpern30 added this to the GPEC v2.0.0 milestone Jul 30, 2026
@jhalpern30 jhalpern30 self-assigned this Jul 30, 2026
@jhalpern30

Copy link
Copy Markdown
Collaborator Author

@claude review

@claude

claude Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review

Reviewed the flag-removal logic in src/GeneralizedPerturbedEquilibrium.jl, src/ForceFreeStates/{ForceFreeStatesStructs,Free,Kinetic}.jl, and the touched gpec.toml files.

Behavior change worth a second look

Removing mat_flag doesn't just delete an unused knob — it makes the fundamental-matrix HDF5 dump unconditional. Before this PR the default was mat_flag::Bool = false, and several kinetic regression configs (regression_solovev_kinetic_{example,multi_n,calculated,nuzero}, Solovev_kinetic_calculated_example) explicitly set mat_flag = false while keeping ode_flag = true — i.e. they deliberately ran the ODE without dumping A/B/C/D/E/H/F/K/G (and, when kinetic_factor>0, the kinetic A/B/C/f0/K/G) matrices to gpec.h5. After this change, write_outputs_to_HDF5 writes them for every run (if ffit !== nothing), with no way to opt out short of editing source.

This seems to cut against the PR description's own reasoning — "it shouldn't be in control and should be in some sort of DEBUG namelist" suggests the intent was to keep this off by default until that namelist exists, but the code as written turns it permanently on instead. Given output size/write-time is the concern, worth deciding explicitly: keep it off by default (or gate behind a temporary internal toggle) rather than always-on, until the debug namelist lands.

Other notes

  • ode_flag/cyl_flag removal and the _DEPRECATED_FFS_KEYS update look correct — checked for stray references across src/, test/, benchmarks/, examples/, and docs/; nothing else constructs ForceFreeStatesControl with these keys, so nothing else breaks. The stale (requires mat_flag = true) comment on gal_flag in the two gal_resistive* example tomls was correctly updated too.
  • benchmarks/benchmark_against_fortran_run.jl picked up a large amount of unrelated JuliaFormatter churn (313+/270-) for what's functionally a 2-line change (dropping the mat_flag/ode_flag println calls). Understood this follows the repo's pre-commit formatting policy, but it makes the actual diff hard to spot — worth calling out in the PR description, or splitting pure-formatting drive-bys into their own commit next time.
  • No test exercises _drop_deprecated_keys! for a legacy gpec.toml containing mat_flag/ode_flag/cyl_flag (this gap predates the PR — the same is true for mer_flag/force_wv_symmetry — but the deprecated-keys list keeps growing without any coverage confirming old configs still parse).
  • Per CLAUDE.md policy, please run/attach the regression harness report before merging — this change alters default HDF5 output content for kinetic cases, which is exactly the kind of thing the harness should confirm doesn't silently move tracked quantities (checksums, etc.) or blow up output size.

Core control-flow changes (the cyl_flag/sing_start branch collapse, unwrapping the mat_flag || ode_flag block, unconditional ODE integration) look logically sound and consistent with the stated goal.

@jhalpern30
jhalpern30 marked this pull request as ready for review July 30, 2026 13:53
@jhalpern30
jhalpern30 requested a review from matt-pharr July 30, 2026 13:53
@jhalpern30

Copy link
Copy Markdown
Collaborator Author

@claude review

@claude

claude Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review

Straightforward deprecation of mat_flag, ode_flag, cyl_flag. I traced every remaining reference to these three flags across src/, examples/, test/test_data/, and regression-harness/ and found none left dangling — the removal is complete and the _DEPRECATED_FFS_KEYS mechanism correctly warns and strips them so old gpec.toml files keep parsing. The gal_flag comment in the two gal_resistive examples that referenced mat_flag = true was also updated, and the stale "requires mat_flag=true" TODO/comment in GeneralizedPerturbedEquilibrium.jl was cleaned up along with the code it referred to.

Issues

  1. Formatter artifacts in examples/DIIID-like_ideal_example_IMAS/run_imas_example.jl (lines ~64-68, ~80-84): the reformatted do-block bodies now contain a stray bare ; on its own line:

    open(joinpath(tmpdir_imas, "gpec.toml"), "w") do io
        ;
        TOML.print(io, config_imas);
    end

    This is valid Julia (empty statement) but clearly not intentional — it's a leftover from collapsing the original one-liner do io; TOML.print(io, config_imas); end. Worth a manual pass to clean this up to:

    open(joinpath(tmpdir_imas, "gpec.toml"), "w") do io
        TOML.print(io, config_imas)
    end

    (same pattern appears twice in this file).

  2. No test exercises the deprecated-key path. _drop_deprecated_keys!/_DEPRECATED_FFS_KEYS now covers 5 keys but I couldn't find any test (unit or fixture) that loads a gpec.toml still containing one of these keys and checks it parses with a warning rather than erroring. Not a regression introduced by this PR (the mechanism already existed for mer_flag/force_wv_symmetry), but growing the list without ever testing the fallback path is worth closing at some point.

Minor / unrelated-diff noise

The description already flags this, but to confirm: the bulk of the diff in benchmarks/benchmark_against_fortran_run.jl and benchmarks/gal_validation/tokamaker_beta/gal_tok_worker.jl (splitting ;-joined statements, removing aligned = padding) is pre-existing formatter drift, not related to the flag removal itself. Since CLAUDE.md calls out that leaking formatting changes into unrelated files creates noisy diffs, it may be worth a separate docs/-or-refactor/-tagged PR that runs the formatter over benchmarks/ on its own, so future flag/logic PRs stay minimal-diff.

Regression harness

This PR removes conditionals in main_from_inputs that used to gate metric/matrix computation and the Euler-Lagrange ODE integration on ctrl.mat_flag/ctrl.ode_flag. Since every example/regression gpec.toml had these set to true already, behavior should be unchanged, but per CLAUDE.md this still needs a regress --cases <affected>,... --refs develop,local run recorded on the PR before merge, since it touches main_from_inputs control flow directly.

Per CLAUDE.md: this PR must not be merged into develop without human reviewer approval, regardless of CI status.

@matt-pharr matt-pharr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is overall good cleanup and I like getting rid of fortran flags. However, I should note just so you know @jhalpern30 that there exist a number of reasons someone might want to not run the ode integrator, like if they only want ballooning analysis, for example. We have a big suite with many capabilities now and not all of them require ode, so yeah.

There is also the matter of mat_flag being always on now, which as claude mentioned, will be cumbersome for big scans creating massive h5 files.

However, I think that both of these concerns are for now moot, because I want to restructure the code to work better in scripting form, e.g.

eq = Equilibrium("input.geqdsk")
basis, stability = ForceFreeStates(eq, :riccati, :ideal) <-- could also calculate plasma permittivity
rmp = RMPField("coils.dat", amplitude={1: 1000}) # set n=1 amplitude to 1kA
# or, rmp = RMPField(surfmn_output) / etc

perturbed = PerturbedEquilibrium(basis, rmp)
outputs = calculate_quantities(perturbed, ["C_xe", "delta_per_coil", "b_pen"])

When we have something like this calculate_quantities() function, these flags will be irrelevant and we will want to get rid of all of them anyways, so this is a good step towards that.

@jhalpern30

Copy link
Copy Markdown
Collaborator Author

@matt-pharr agreed - perhaps the better wording instead of "fully deprecate" is "remove vestigial Fortran debug flags to make room for our own implementations later on"

@jhalpern30 jhalpern30 added Cleanup and Clarifications auto-merge Automatically merge PR when CI passes labels Jul 30, 2026
@github-actions
github-actions Bot enabled auto-merge July 30, 2026 20:13
@github-actions
github-actions Bot merged commit 167ada7 into develop Jul 30, 2026
11 checks passed
@github-actions
github-actions Bot deleted the deprecate_flags branch July 30, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge Automatically merge PR when CI passes Cleanup and Clarifications

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants