You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allows users to calculate the critical resonant field required for tearing at a rational surface. The model is based on the simple torque balance model in Cole and Fitzpatrick PoP 2006. Resolves issue #371. Main user input not already present in a Tearing.jl run is supplying viscosity information. This can be done either as angular momentum diffusivity or a direct magnetic Prandtl number. Other improvements in progress: #416
Ref 1: develop @ c42d558 (2026-08-20)
env: julia 1.12.6, arm64-apple-darwin24.0.0, manifest 42ffd010 (pinned), 5 threads/5 BLAS
Ref 2: local @ local (2026-08-20)
env: julia 1.12.6, arm64-apple-darwin24.0.0, manifest 42ffd010 (pinned), 5 threads/5 BLAS
Quantity develop local Diff Status
total energy Re(et[1]) 8.013943e-01 8.013943e-01 0.0e+00 OK
total energy Im(et[1]) 1.233500e-04 1.233500e-04 0.0e+00 OK
plasma energy Re(ep[1]) -1.348114e+00 -1.348114e+00 0.0e+00 OK
vacuum energy Re(ev[1]) 2.149508e+00 2.149508e+00 0.0e+00 OK
vacuum matrix min eigenvalue 1.873975e-01 1.873975e-01 0.0e+00 OK
plasma energy (all) [35 elem] [35 elem] 0.0e+00 OK
vacuum energy (all) [35 elem] [35 elem] 0.0e+00 OK
total energy (all) [35 elem] [35 elem] 0.0e+00 OK
ODE steps (saved) 2655 2655 0.0e+00 OK
ODE steps (total) 4738 4738 0.0e+00 OK
q0 1.204212e+00 1.204212e+00 0.0e+00 OK
q95 4.781723e+00 4.781723e+00 0.0e+00 OK
beta_t 1.327024e-02 1.327024e-02 0.0e+00 OK
beta_n 1.372511e+00 1.372511e+00 0.0e+00 OK
internal inductance li1 8.842230e-01 8.842230e-01 0.0e+00 OK
internal inductance li2 7.080727e-01 7.080727e-01 0.0e+00 OK
internal inductance li3 7.304309e-01 7.304309e-01 0.0e+00 OK
poloidal beta betap1 6.680738e-01 6.680738e-01 0.0e+00 OK
poloidal beta betap2 5.349836e-01 5.349836e-01 0.0e+00 OK
poloidal beta betap3 5.518763e-01 5.518763e-01 0.0e+00 OK
singular surfaces 5 5 0.0e+00 OK
singular psi locations [5 elem] [5 elem] 0.0e+00 OK
singular q values [5 elem] [5 elem] 0.0e+00 OK
current beta betaj 4.236479e-01 4.236479e-01 0.0e+00 OK
plasma volume 1.829472e+01 1.829472e+01 0.0e+00 OK
plasma current 1.152130e+00 1.152130e+00 0.0e+00 OK
mpert 35 35 0.0e+00 OK
npert 1 1 0.0e+00 OK
toroidal field bt0 2.006573e+00 2.006573e+00 0.0e+00 OK
wall field bwall 3.880145e-01 3.880145e-01 0.0e+00 OK
aspect ratio 2.845746e+00 2.845746e+00 0.0e+00 OK
elongation kappa 1.708322e+00 1.708322e+00 0.0e+00 OK
q profile (checksum) ed7c21fd61df... ed7c21fd61df... identical OK
pressure profile (checksum) e15550827bf1... e15550827bf1... identical OK
Mercier D_I profile (checksum) 5a6fcb1c3a97... 5a6fcb1c3a97... identical OK
resistive interchange D_R profile (checksum) 6284a4c9a75a... 6284a4c9a75a... identical OK
ballooning Delta' profile (checksum) 44bf968c25d5... 44bf968c25d5... identical OK
island half-widths [5 elem] [5 elem] 0.0e+00 OK
Chirikov parameter [5 elem] [5 elem] 0.0e+00 OK
||resonant area-weighted field|| 5.207739e-04 5.207739e-04 0.0e+00 OK
PE plasma energy 3.422586e+00 3.422586e+00 0.0e+00 OK
PE vacuum energy 3.174509e+00 3.174509e+00 0.0e+00 OK
PE surface energy 5.841099e+00 5.841099e+00 0.0e+00 OK
PE toroidal torque -5.062793e-02 -5.062793e-02 0.0e+00 OK
NTV torque FGAR [N·m] 5.587060e-01 5.587060e-01 0.0e+00 OK
NTV kinetic energy dW FGAR [J] 6.903492e-02 6.903492e-02 0.0e+00 OK
Runtime (s) 242.4s 357.4s --
resonant area-weighted field b^r [5 elem] [5 elem] 0.0e+00 OK
Summary: 47 unchanged
Julia Torque Balance Output
Similar Fortran Torque Balance Output
ebursch
changed the title
TEARING - NEW FEATURE - Add critical resonant field calculations to the tearing workflow
TEARING - FEATURE - Add critical resonant field calculations to the tearing workflow
Aug 20, 2026
ebursch
changed the title
TEARING - FEATURE - Add critical resonant field calculations to the tearing workflow
Tearing - Feature - Add critical resonant field calculations to the tearing workflow
Aug 20, 2026
ebursch
changed the title
Tearing - Feature - Add critical resonant field calculations to the tearing workflow
Tearing - FEATURE - Add critical resonant field calculations to the tearing workflow
Aug 20, 2026
Currently takes either an array or a scalar for all surfaces but will easily be updated to a true profile once I have angular momentum diffusivity profile data on hand to test with.
Sounds like this should be marked draft until this is done
This should perform as well as or better than the Fortran implementation.
"Should" is scary - benchmark it! There is a benchmark script for comparing to fortran - modify that for your needs (using scratch scripts - no need to commit run scripts)
Other improvements to the model and the numerical methods are in progress, but I wanted to have a working version available to users.
Mark this as draft until the IO and benchmarks are done then ping us for reviews. You can make a "Task" type issue describing future plans (and assign yourself) so we have it on record as work in progress.
@logan-nc@d-burg Should be ready for review now. Added profile inputs and a Fortran comparison plot.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Release note
Allows users to calculate the critical resonant field required for tearing at a rational surface. The model is based on the simple torque balance model in Cole and Fitzpatrick PoP 2006. Resolves issue #371. Main user input not already present in a Tearing.jl run is supplying viscosity information. This can be done either as angular momentum diffusivity or a direct magnetic Prandtl number. Other improvements in progress: #416
Regression report
================================================================
Case: diiid_n1 — DIII-D-like equilibrium, n=1, ideal + perturbed equilibrium
Regression Report: diiid_n1
Ref 1: develop @ c42d558 (2026-08-20)
env: julia 1.12.6, arm64-apple-darwin24.0.0, manifest 42ffd010 (pinned), 5 threads/5 BLAS
Ref 2: local @ local (2026-08-20)
env: julia 1.12.6, arm64-apple-darwin24.0.0, manifest 42ffd010 (pinned), 5 threads/5 BLAS
Quantity develop local Diff Status
total energy Re(et[1]) 8.013943e-01 8.013943e-01 0.0e+00 OK
total energy Im(et[1]) 1.233500e-04 1.233500e-04 0.0e+00 OK
plasma energy Re(ep[1]) -1.348114e+00 -1.348114e+00 0.0e+00 OK
vacuum energy Re(ev[1]) 2.149508e+00 2.149508e+00 0.0e+00 OK
vacuum matrix min eigenvalue 1.873975e-01 1.873975e-01 0.0e+00 OK
plasma energy (all) [35 elem] [35 elem] 0.0e+00 OK
vacuum energy (all) [35 elem] [35 elem] 0.0e+00 OK
total energy (all) [35 elem] [35 elem] 0.0e+00 OK
ODE steps (saved) 2655 2655 0.0e+00 OK
ODE steps (total) 4738 4738 0.0e+00 OK
q0 1.204212e+00 1.204212e+00 0.0e+00 OK
q95 4.781723e+00 4.781723e+00 0.0e+00 OK
beta_t 1.327024e-02 1.327024e-02 0.0e+00 OK
beta_n 1.372511e+00 1.372511e+00 0.0e+00 OK
internal inductance li1 8.842230e-01 8.842230e-01 0.0e+00 OK
internal inductance li2 7.080727e-01 7.080727e-01 0.0e+00 OK
internal inductance li3 7.304309e-01 7.304309e-01 0.0e+00 OK
poloidal beta betap1 6.680738e-01 6.680738e-01 0.0e+00 OK
poloidal beta betap2 5.349836e-01 5.349836e-01 0.0e+00 OK
poloidal beta betap3 5.518763e-01 5.518763e-01 0.0e+00 OK
singular surfaces 5 5 0.0e+00 OK
singular psi locations [5 elem] [5 elem] 0.0e+00 OK
singular q values [5 elem] [5 elem] 0.0e+00 OK
current beta betaj 4.236479e-01 4.236479e-01 0.0e+00 OK
plasma volume 1.829472e+01 1.829472e+01 0.0e+00 OK
plasma current 1.152130e+00 1.152130e+00 0.0e+00 OK
mpert 35 35 0.0e+00 OK
npert 1 1 0.0e+00 OK
toroidal field bt0 2.006573e+00 2.006573e+00 0.0e+00 OK
wall field bwall 3.880145e-01 3.880145e-01 0.0e+00 OK
aspect ratio 2.845746e+00 2.845746e+00 0.0e+00 OK
elongation kappa 1.708322e+00 1.708322e+00 0.0e+00 OK
q profile (checksum) ed7c21fd61df... ed7c21fd61df... identical OK
pressure profile (checksum) e15550827bf1... e15550827bf1... identical OK
Mercier D_I profile (checksum) 5a6fcb1c3a97... 5a6fcb1c3a97... identical OK
resistive interchange D_R profile (checksum) 6284a4c9a75a... 6284a4c9a75a... identical OK
ballooning Delta' profile (checksum) 44bf968c25d5... 44bf968c25d5... identical OK
island half-widths [5 elem] [5 elem] 0.0e+00 OK
Chirikov parameter [5 elem] [5 elem] 0.0e+00 OK
||resonant area-weighted field|| 5.207739e-04 5.207739e-04 0.0e+00 OK
PE plasma energy 3.422586e+00 3.422586e+00 0.0e+00 OK
PE vacuum energy 3.174509e+00 3.174509e+00 0.0e+00 OK
PE surface energy 5.841099e+00 5.841099e+00 0.0e+00 OK
PE toroidal torque -5.062793e-02 -5.062793e-02 0.0e+00 OK
NTV torque FGAR [N·m] 5.587060e-01 5.587060e-01 0.0e+00 OK
NTV kinetic energy dW FGAR [J] 6.903492e-02 6.903492e-02 0.0e+00 OK
Runtime (s) 242.4s 357.4s --
resonant area-weighted field b^r [5 elem] [5 elem] 0.0e+00 OK
Summary: 47 unchanged
Julia Torque Balance Output


Similar Fortran Torque Balance Output