PENTRC: preserve periodicity in parallel-velocity spline - #284
Conversation
|
@claude review this pr, paying special attention to if the spline endpoints are correctly inclusive or exclusive for what the periodic boundary condition expects |
|
Claude finished @logan-nc's task in 2m 0s —— View job Review: PENTRC periodic v‖ spline
Verdict: the fix is correct, and the endpoints are handled correctly. Why the endpoints line up
Previously, Other observations (non-blocking)
No changes requested. |
|
@claude fix the bug that xs(0) and xs(1) can't both be acceptable root solutions for periodic splines |
|
Claude finished @logan-nc's task in 4m 29s —— View job Fixed: duplicate root at periodic spline wrap-around point
Root cause
This directly matches the case this PR is fixing: FixIn INTEGER:: ix, jroot, lx, nzvalid, ir, ir0, irmx
...
nroots = jroot
+ ! periodic splines duplicate the wrap-around point: xs(0) and
+ ! xs(mx) are the same physical location, so at most one may
+ ! survive as a root
+ IF(spl%periodic .AND. nroots>1)THEN
+ tol = eps*(spl%xs(1)-spl%xs(0))
+ ir0 = 0
+ DO ir=1,nroots
+ IF(ABS(roots(ir)-spl%xs(0))<tol)THEN
+ ir0 = ir
+ EXIT
+ ENDIF
+ ENDDO
+ tol = eps*(spl%xs(spl%mx)-spl%xs(spl%mx-1))
+ irmx = 0
+ DO ir=1,nroots
+ IF(ir/=ir0 .AND.
+ $ ABS(roots(ir)-spl%xs(spl%mx))<tol)THEN
+ irmx = ir
+ EXIT
+ ENDIF
+ ENDDO
+ IF(ir0>0 .AND. irmx>0)THEN
+ roots(irmx:nroots-1) = roots(irmx+1:nroots)
+ nroots = nroots - 1
+ ENDIF
+ ENDIF
! sort the roots lowest to highestAll added/modified lines stay within the 72-column fixed-format limit (verified with a regex check for lines ≥73 characters — only pre-existing long comments remain). Note on verificationThis sandbox's |
Verification of the periodic root dedup (
|
What changed
Fit both PENTRC parallel-velocity root splines with periodic rather than
extrapolating endpoint conditions.
Root cause
The sampled quantity,
is periodic on the closed normalized poloidal-angle interval. The equilibrium
B(theta)spline immediately upstream is periodic, but the derived root splinewas fitted with nonperiodic extrapolation conditions. In the TC24
phiI010L5 case the resulting seam corrupted bounce roots, produced non-finite
omega_bandomega_D, and reached LSODE asISTATE=-5.Validation
develop:make -C install -j16 FC=gfortran CC=gcc OPENBLASHOME=/usr NETCDFHOME=/usr pentrcphiI010L5 input now terminates normallywithout an LSODE or non-finite-frequency failure.
for
pentrc_tgar_ell_n3.out,pentrc_pgar_ell_n3.out,pentrc_tgar_n3.out,pentrc_pgar_n3.out, andpentrc_output_n3.nc.phiI000andphiI010L0/L5 productionmatrix.
This changes only the spline boundary condition. It does not change a
frequency, torque, helicity, or profile sign.