Skip to content

VAC - REFACTOR - Give the Vacuum module its own output struct - #358

Merged
matt-pharr merged 8 commits into
developfrom
refactor/vacuum-response-struct
Aug 14, 2026
Merged

VAC - REFACTOR - Give the Vacuum module its own output struct#358
matt-pharr merged 8 commits into
developfrom
refactor/vacuum-response-struct

Conversation

@jhalpern30

@jhalpern30jhalpern30 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Follow-on to #355 (branched off it, so this diff also contains #355's commits until that merges).

What

VacuumData lived in ForceFreeStates and was passed into the Vacuum module as an untyped output buffer — Vacuum.jl said so outright: "designed to work with ForceFreeStates.VacuumData but does not depend on its concrete type (duck-typed on field names only)." Vacuum sits below ForceFreeStates in the dependency graph, so it could not name the type it wrote to. Its 14 fields mixed three unrelated groups: vacuum outputs, free-boundary energies computed in Free.jl, and sizing scratch.

Split into two focused immutable structs:

  • Vacuum.VacuumResponse (src/Vacuum/DataTypes.jl) — what the Vacuum module actually computes: wv, grri, grre, plasma_pts, wall_pts, mtheta, nzeta. compute_vacuum_response returns it instead of a positional 5-tuple that every caller partly discarded (wv, _, _, _, _ / _, grri, grre, _, _), and compute_vacuum_response! is now typed rather than duck-typed on field names.
  • ForceFreeStates.FreeBoundaryResult — the energy decomposition, constructed once at the end of free_run instead of being mutated in place across 40 lines.

Dead weight removed

  • grri/grre were write-only on this path: Vacuum filled them, nothing ever read vac_data.grri/.grre, and Response.jl/SingularCoupling.jl each call compute_vacuum_response again with their own inputs. They are no longer retained past free_run — roughly 2 MB of live allocation per run at mthvac=512, mpert≈65.
  • numpoints, numpert_total, and mthvac had zero readers and are gone.

Consumers narrowed (issue #139 principle 1)

  • galerkin_solve read only .wv → takes wv.
  • compute_perturbed_equilibrium read only .wt0 and .mthvac → takes those two, and no longer imports a ForceFreeStates struct at all.
  • build_flux_matrix took a vac_data it never used → parameter dropped.

Verification

No intended numerical change — no arithmetic was moved.

Regression harness, run against a0cad260 (the exact develop commit merged here, so the comparison isolates only this branch's changes):

CaseResult
diiid_n148 unchanged, 0 changed
gal_resistive_diiid10 unchanged
gal_resistive_pe4 unchanged, 4 N/A on both sides
solovev_n121 unchanged
solovev_multi_n15 unchanged

Suites: runtests_vacuum.jl 273/273 · runtests_fullruns.jl 17/17 · runtests_sing.jl 75/75 · runtests_imas.jl 24/24 · runtests_resist_eval.jl 63/63 · runtests_coordinate_invariant.jl · runtests_rerun_from_h5.jl.

Notes for the reviewer

🤖 Generated with Claude Code

jhalpern30and others added 2 commits August 12, 2026 15:58
VacuumData lived in ForceFreeStates and was passed into Vacuum as an untyped
output buffer, so the Vacuum module could not name the type it wrote to. Its 14
fields mixed vacuum outputs, free-boundary energies computed in Free.jl, and
sizing scratch.
Split into two focused immutable structs:
- Vacuum.VacuumResponse (src/Vacuum/DataTypes.jl) holds what the Vacuum module
computes: wv, grri, grre, plasma_pts, wall_pts, mtheta, nzeta.
compute_vacuum_response returns it instead of a positional 5-tuple that every
caller partly discarded, and compute_vacuum_response! is typed rather than
duck-typed on field names.
- ForceFreeStates.FreeBoundaryResult holds the energy decomposition, built once
at the end of free_run instead of being mutated in place across 40 lines.
grri/grre are no longer retained past free_run: nothing read them there, and
downstream consumers recompute their own. Drops ~2 MB of live allocation per run
at mthvac=512. The dead numpoints/numpert_total/mthvac fields are gone too.
Consumers narrowed to what they actually read (issue #139 principle 1):
galerkin_solve takes wv, compute_perturbed_equilibrium takes wt0 and mthvac and
no longer imports a ForceFreeStates struct at all, and build_flux_matrix loses a
parameter it never used.
No intended numerical change.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Conflicts resolved by combining both sides:
- ForceFreeStatesStructs.jl / Riccati.jl: develop's du_store / xi_s_store store
renames applied to this branch's condensed docstrings and free_run rename.
- Free.jl: normalize_eigenfunctions! docstring keeps its own description with
develop's accurate store list.
- PerturbedEquilibrium.jl: develop's new ffit argument to
compute_singular_coupling_metrics! combined with this branch's vac_data -> mthvac
narrowing.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jhalpern30

Copy link
Copy Markdown
CollaboratorAuthor

As part of this, I also extracted normalized_eigenfunctions from free_run! since it was the only thing modifying odet in place, making the function modify nothing such that it can be free_run. This was also in the spirit of #139

@jhalpern30jhalpern30 added the refactor Behavior-preserving restructuring label Aug 12, 2026

@matt-pharrmatt-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.

@matt-pharr
matt-pharr merged commit 1930752 into developAug 14, 2026
7 checks passed
@matt-pharr
matt-pharr deleted the refactor/vacuum-response-struct branch August 14, 2026 18:19
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactorBehavior-preserving restructuring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@jhalpern30@matt-pharr