Skip to content

Resistive singular coupling#210

Open
matt-pharr wants to merge 35 commits intodevelopfrom
RDCON_singcoup
Open

Resistive singular coupling#210
matt-pharr wants to merge 35 commits intodevelopfrom
RDCON_singcoup

Conversation

@matt-pharr
Copy link
Collaborator

Changes related to adding scientifically robust singular coupling to the RDCON -> GPEC workflow. WIP.

@matt-pharr matt-pharr marked this pull request as draft June 17, 2025 19:48
@matt-pharr
Copy link
Collaborator Author

This is what was accomplished by adding the resolution option for the inner layer (was previously limited to 3 points):

image

The plot on the bottom has 60 points in each resonant and extension cell instead of 3. This does not affect asymptotic matching, but does make plots of xi/Jbgradpsi look better.

@matt-pharr
Copy link
Collaborator Author

A scan of resistivities using a LAR equilibrium with only a q=2 surface shows interesting behaviors in xi. The direction of the interchange switches at eta=8e-8, or in this case for lundquist numbers lower than about 10^6.

image

Scan of higher lundquist numbers should be done.

@matt-pharr matt-pharr linked an issue Jul 14, 2025 that may be closed by this pull request
@matt-pharr
Copy link
Collaborator Author

Choosing sing_spot based on the first plot posted in this pull request (which puts it just outside of the resonant layer using default rdcon dx/layer width values) metrics in a single-surface LAR case are relatively well-behaved.

image

B_pen is far more dependent on the resistivity / lundquist number in this case.

image

@matt-pharr
Copy link
Collaborator Author

@StuartBenjamin you are one of the few who knows the guts of RMATCH... can you take a very brief look at these comments (in f27f665) and let me know if there should be any changes/if you know what some of the 'unknown's are?

Copy link
Collaborator

@StuartBenjamin StuartBenjamin left a comment

Choose a reason for hiding this comment

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

Remembered a few of the extra terms!

@matt-pharr matt-pharr linked an issue Oct 1, 2025 that may be closed by this pull request
…into gpec as a diagnositc; fixed a breaking bug where match.f would dump too many psi points into galsol.bin, leading to the inner layer looking broken and being incorrect; Added xdraw files for RPEC solutions; improved a couple of rmatch numerical factors, including scaling the number of inner layer grid points by its width to keep the physical resolution consistent, as well as moving the resonant cell widths outside of this scaling to keep their widths consistent regardless of inner layer width.
@matt-pharr
Copy link
Collaborator Author

matt-pharr commented Oct 13, 2025

A little before and after here on the recent bug fix:

image image

3D field penetration does actually happen at the flux surface now! The issue that was causing this to not work was that rmatch was outputting a different number of solution points vs psis, and so every singular surface we would skip an x value but still have a zero added in from the (m-nq) term. This freaky zero was messing with the splines, I suspect. Now we just exclude only the singular point on the rational surface, like RMATCH does. This also enables intra-inner-layer scans of resonant quantities.

…ated written vacuum file to equil.f to avoid repeating code with multiple confusing variables of the same name in different namelists
…dth and interpolation scaling; updated related functions to utilize these parameters
…ut; refactored equil.f to separate loading of namelists; modified global.f to enable vacuum memory; adjusted makefile dependencies
…atch.f to reduce write overhead; added new variables for sweet spots and Lundquist Number in gpec profile netcdfs
…t minimum; fixed real -> complex eigenvalue from RMATCH io
…merics, modernized some namelist options, setup final resistive spot size logic.
@matt-pharr matt-pharr requested a review from logan-nc February 2, 2026 22:02
@matt-pharr
Copy link
Collaborator Author

@logan-nc I had to disable @StuartBenjamin's logic for setting psihigh for RDCON in order for RPEC to continue working -- it remains a mystery to me as to why this was a problem.

@matt-pharr matt-pharr marked this pull request as ready for review February 2, 2026 22:03
@matt-pharr
Copy link
Collaborator Author

matt-pharr commented Feb 6, 2026

@logan-nc The problems wound up being that the way rdcon was regridding was cutting off at a different psilim than I expected, resulting in the poorly conditioned solution set that we know occurs at some psi cutoff values. I haven't run it yet, but I think I should be able to get it to work nicely with Stuart's regridding contributions. Hopefully I'm not dooming it by speaking too soon!

@matt-pharr
Copy link
Collaborator Author

@claude Please briefly summarize this PR.

@claude
Copy link

claude bot commented Feb 13, 2026

Claude finished @matt-pharr's task in 1m 9s —— View job


Summary of PR #210: Resistive Singular Coupling

This PR enhances GPEC's resistive MHD analysis capabilities by implementing scientifically robust singular coupling between RDCON (resistive stability) and GPEC (perturbed equilibrium) codes. The work enables accurate 3D field penetration calculations at rational surfaces where resistive effects dominate.

Key Improvements

1. Inner Layer Resolution Enhancement

  • Previously limited to 3 grid points in resonant layers, now supports configurable resolution (e.g., 60 points)
  • Improves visualization quality of ξ/J·∇ψ profiles near singular surfaces
  • Physical resolution maintained consistently through width-aware grid scaling

2. Resistive Layer Coupling

  • Fixed critical bug where RMATCH output mismatched psi points and solution points, causing spurious zeros in spline interpolation
  • Now properly excludes only the singular point at rational surfaces (matching RMATCH behavior)
  • Enables intra-inner-layer scanning of resonant quantities

3. Field Penetration Physics

  • Demonstrated actual 3D field penetration at flux surfaces (previously broken)
  • Resistivity scans show physically meaningful behavior: interchange direction switches at η≈8×10⁻⁸ (Lundquist number ~10⁶)
  • B_pen (penetrated field) shows expected strong dependence on resistivity/Lundquist number

4. Singular Spot Positioning

  • Implemented logic for choosing sing_spot (interpolation point outside resonant layer)
  • Well-behaved metrics achieved when positioned just outside default RDCON layer widths

5. Code Infrastructure

  • Refactored RDCON/RMATCH I/O to reduce write overhead and improve data handling
  • Added NetCDF outputs for resistive quantities, Lundquist number, and sweet spot metrics
  • Improved RMATCH parameter documentation (with help from @StuartBenjamin)
  • Separated equilibrium namelist loading for cleaner code organization
  • Added XDRAW visualization files for RPEC (resistive perturbed equilibrium) solutions

6. Numerical Robustness

  • Resolved regridding issues with psihigh that were causing poorly conditioned solution sets
  • Improved deltac numerics and cubic Hermite finite element method parameters
  • Fixed real→complex eigenvalue conversion from RMATCH

Files Changed

100 files modified across RDCON, RMATCH, GPEC, EQUIL, and example input files (+2613/-1894 lines)

Status

Work-in-progress with ongoing refinements to resistive layer width logic and interpolation scaling. Recent commits focused on finalizing parameters for resistive metrics publication.

--- | Branch: RDCON_singcoup

@logan-nc
Copy link
Contributor

@matt-pharr can you confirm the truncation issue is fixed and this is ready for full review? Last message from you to me ended on a cliff hanger, "Hopefully I'm not dooming it by speaking too soon!"

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