Skip to content

ForcingTerms - FEATURE! - Refactor ForcingTerms naming and add capability to model magnetic materials at saturation magnetization in the direction of equilibrium fields - #672

Draft
matt-pharr wants to merge 40 commits into
developfrom
feature/ferritic-forcing
Draft

matt-pharr wants to merge 40 commits into
developfrom
feature/ferritic-forcing

Conversation

@matt-pharr

Copy link
Copy Markdown
Collaborator

Release note

  • Audience: users | developers
  • Numerical impact: none | (harness @ )
  • Migration: none |

<One to three sentences a user of GPEC would understand: what you can now do, or what was wrong.>

Regression report

Notes for reviewers


Set an assignee and at least one human reviewer; if you are not ready to name them, open this as a draft. Lead developers to ask are listed in docs/development/contributors.md. Labels are applied automatically from the title.

…ner-layer matching and publish their plasma response

Groundwork for Galerkin inner-layer matching for PE, with the abstraction changes it needs on the Galerkin,
Δ′ and matching side. Galerkin results now carry the solution, plasma energy matrix and free-boundary
energies a Forward result does, and drive the perturbed-equilibrium response.

Galerkin plasma response
- The solve records edge_response, the edge momentum FΞ′ + KΞ of every solution column, from the edge
  rows of the stiffness before the boundary conditions replace them. On the error-field (EF) columns
  (a unit edge displacement per mode, no big-solution drive) it is W_P·ψ₀² [Glasser 2016, Eq. 66];
  it agrees with Forward and Riccati to 2e-7 and converges at fourth order in nx.
- With error_field_response (renamed from rpec_flag) the EF columns are published as the ideal-closed
  solution and wp, and with vac_flag the free-boundary energies, so plasma_response accepts the result.
  Both flags now default to true. MatchProblem's ideal keyword and the [Match] ideal key are removed: the
  Galerkin solve is itself the ideal solution.
- A matched Galerkin result publishes its complex edge response W_eff = (F_EF + F_plasma·cout)/ψ₀² and
  its free-boundary energies; the anti-Hermitian part is the torque absorbed in the inner layers.
  plasma_response refuses every :matched result until matched singular coupling is defined.
- free_run takes the plasma energy matrix wp, so Forward, Galerkin and matched results share it, and
  FreeBoundaryStability/W_plasma is written from result.wp.

Δ′ payload
- DeltaPrimeData has one meaning per field: raw_freeboundary, raw_fixedboundary, ef (Δ_EF, the
  response to a unit edge displacement with the edge otherwise fixed) and the PEST-3 blocks of both
  boundaries (PEST3Blocks, from pest3_decompose). Consumers read fields, not the integrator.
- Galerkin and Riccati both compute both boundaries. Galerkin re-solves its big-solution columns with
  the vacuum edge for the free-boundary Δ′ (free_boundary_delta_prime, default true); Riccati takes the
  fixed-boundary Δ′ and Δ_EF from one Dirichlet-edge BVP and gains the same error_field_response flag.
- With error_field_response the Galerkin tearing Δ′ was the fixed-boundary one; it is now free-boundary.
- Matching pairs Δ_EF with raw_fixedboundary. Riccati paired it with its free-boundary Δ′, which gave
  matched coefficients and bpen wrong by order one at low rotation (4% at 1 kHz on the LAR deck); they
  now agree with Galerkin to ~1e-3. The [Match] deck guard checks error_field_response alone.
- TearingProblem takes fixed_boundary=true for the fixed-boundary Δ′ (a conformal wall on the plasma);
  tearing refuses a result that lacks the requested boundary instead of falling back to a stub.

Renames (clean break)
- [Galerkin] rpec_flag → error_field_response; Delta_coil → Delta_EF (DeltaPrimeData.ef,
  SingularSurfaces/Delta_EF); MatchResult.rpec_eig → forced_eigenvalue (Match/forced_eigenvalue).
- SingularSurfaces/Delta_prime_raw → Delta_prime_raw_freeboundary, plus Delta_prime_raw_fixedboundary
  and the *_fixedboundary PEST-3 blocks; Riccati now also writes pest3_A/B/Gamma.
- Harness cases diiid_n1_riccati and gal_resistive_diiid follow the new paths and track the
  fixed-boundary Δ′ diagonal.
…e least stable eigenmode of a Galerkin solve
@github-actions github-actions Bot added changed-results Results move or an interface breaks - read before upgrading feature New capability labels Nov 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request is missing an assignee and a reviewer.

If you are not ready to name them, mark this pull request as a draft.
docs/development/contributors.md suggests lead developers to ask.
Merging is not blocked here, but no pull request may be merged without human review.

@matt-pharr matt-pharr changed the title ForcingTerms - FEATURE! - Refactor ForcingTerms naming and add capability to model ferritic elements at saturation magnetization in the direction of equilibrium fields ForcingTerms - FEATURE! - Refactor ForcingTerms naming and add capability to model magnetic materials at saturation magnetization in the direction of equilibrium fields Nov 13, 2026
@matt-pharr matt-pharr added this to the GPEC v2.1.0 milestone Nov 13, 2026
matt-pharr and others added 18 commits November 16, 2026 14:36
…mptotic basis in Forward and default singfac_min to 5e-4
…d thread the edge-scan vacuum matrices and the fixed-boundary criterion
…a-energy

Brings in the timing-audit commit (07cf80d): greedy scheduling of the
Riccati chunk loops, the edge scan's vacuum matrices and the
fixed-boundary criterion in parallel, and fewer copies in the fill and
the outer basis. No conflicts.
…istance and Riccati to a 1e-10 tolerance, warn where Δ′ is unresolved, and bracket the edge-scan root-find
…a-energy

Conflict in test/runtests_solve_api.jl: the base tightened the chunked-Riccati Δ′ comparison to rtol = 1e-6 at the default crossing distance; kept that with this branch's delta_prime.freeboundary.Delta field names.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…a-energy

Brings in develop through #654 (CCC inner layer, ToroidalLayer library, NTV species sum, torque quadrature start). Six conflicts, each this branch's Δ_EF / forced_eigenvalue / fixed-or-free-boundary Δ′ changes against develop's generalization from GGJ to toroidal layer models; both sides kept: MatchProblem.jl, ResonantMatch.jl, Tearing/GGJTearing.jl, Tearing/HDF5Output.jl, Tearing/TearingProblem.jl, docs/src/workflow.md.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e asymptotic singular-coupling metrics, and require a free-boundary result
matt-pharr and others added 12 commits November 23, 2026 16:53
…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.
…amples with the C-coil and track their resonant metrics
…oupling set, and draw penetrated over effective islands
…outside the plasma

equilibrium_field(equil, R, Z) returns (B_R, B_phi, B_Z) in T in the
right-handed (R, phi, Z) frame of the source file, and the normalized
flux, at arrays of machine coordinates. It works from the g-file or IMAS
flux map psi(R, Z), rescaled to the axis as the solver does, with
B_pol signed by the plasma current and B_phi = bt_sign F / R. F follows
the profile inside the last closed flux surface and is the edge value
outside it, including the private-flux region below an X-point.

It errors for equilibria without a flux map outside the plasma and for
points outside the flux grid, asking for a re-export on a larger grid.

Tests check the flux and |B| on the outermost traced surface, Ampere's
law against the g-file current, the sign against a coil hoop through
the Biot-Savart kernel, sign reversal, F inside and outside the
plasma, and both errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oints

With nzeta_coil = 0 the boundary grid used 32|n| toroidal points. A
source close to the plasma carries toroidal structure of its own, and
at n = 1 those 32 points alias it into the spectrum: for the ITER
ferritic inserts on the control surface, n = 31-35 folds onto n = 1
and moves its spectrum by 16%, against 2e-5 with 64 points.

The default is now 32(|n| + 1): the 32 points per period that helical
windings need, plus one more period's worth for the source's own
structure. n = 1 gets 64 points, n = 2 gets 96.

The DIII-D-like example decks and the coil docs no longer set
nzeta_coil = 32, so they use the default. Cases run from those decks
move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed magnetic material

ForcingField(materials) and [[ForcingTerms.magnetic_material]] blocks
(name, h5_file, saturation_field, fill_fraction) add a
ForcingMagneticMaterial leaf to the forcing sum. When materialized,
every element is saturated along the equilibrium field at its
centroid, M = f mu0Ms B0_hat / mu0 (saturated_magnetization), and its
exact field is sampled on the mtheta_coil x nzeta_coil control-surface
grid, projected onto the normal flux and Fourier decomposed per n
(material_forcing_modes).

Every vertex must lie inside the equilibrium's flux grid and outside
the separatrix (psi_N >= 1, below an X-point too), and the field kernel
errors on a control-surface point inside an element. A replay runs from
the recorded forcing modes and drops the material blocks; [ErrorFields]
refuses a deck with material.

Tests check the magnitude and direction of M, the three guards, that
a ring of identical elements drives only multiples of its count, that
a broken ring drives n = 1, and the leaf from the API and from a deck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@matt-pharr
matt-pharr force-pushed the feature/ferritic-forcing branch from 0410eb8 to 1c6743a Compare November 26, 2026 10:52
matt-pharr and others added 2 commits November 26, 2026 16:04
…l-surface field and dominant-mode overlap

A perturbed equilibrium now keeps every forcing source's contribution
beside the total. A source is a coil set, a forcing file (named after
it), a spectrum literal or a magnetic material set; a new optional
`group` key on [[ForcingTerms.coil_set]] and
[[ForcingTerms.magnetic_material]] blocks, and ForcingField(materials;
groups), reports sets sharing a label as one source named by it.
Repeated names get a numeric suffix.

Materialization returns each source's spectrum and the total is their
sum. Each source's root-area-weighted field b̃ and its overlap with the
dominant modes are written to PerturbedEquilibrium/ForcingSources/
(source_name, forcing_b_root_area on (mode, source),
dominant_forcing_overlap on (rank, source)), and their columns sum to
forcing_b_root_area and DominantMode/forcing_overlap. The torque
response's T_source uses the same sources, so a magnetic material or a
sum gets one column per source rather than one for the whole forcing,
and coil runs no longer evaluate Biot-Savart a second time for it
(coil_flux_spectra is removed).

Tests check each coil set's b̃ against an independent build, T_source
for separate and grouped coil sets, a forcing file as one source, the
HDF5 round trip, group parsing from deck blocks and the API, and the
grouping, naming and summing of sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from feature/analysis-plots-overhaul to develop November 26, 2026 21:28

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changed-results Results move or an interface breaks - read before upgrading feature New capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant