147147
148148"""
149149 compute_bounce_data(psi, n, l, q, bo, bmax, bmin, theta_bmax,
150- tspl, B_extrap , mfac, chi1, ro, dbob_m_f, divx_m_f,
150+ tspl, B_vpar , mfac, chi1, ro, dbob_m_f, divx_m_f,
151151 divxfac, wdfac, mass, chrg, T_s, method;
152152 nlmda=128, ntheta=128,
153153 smat=nothing, tmat=nothing, xmat=nothing,
@@ -168,8 +168,8 @@ Ports Fortran torque.F90 lines 530-816 (GAR branch).
168168- `bmax, bmin`: Max/min of B(θ) at this ψ
169169- `theta_bmax`: θ location of Bmax (nodal knot; the passing-transit start)
170170- `tspl`: Periodic poloidal interpolant: tspl(θ) → [B, dB/dψ, dB/dθ, J, dJ/dψ]
171- - `B_extrap `: Endpoint-fit (non-periodic) cubic of B(θ) used for v_par and the
172- bounce-point roots (the Fortran `vspl` equivalent)
171+ - `B_vpar `: Periodic cubic of B(θ) used for v_par and the bounce-point roots
172+ (the Fortran `vspl` equivalent)
173173- `mfac`: Poloidal mode numbers [mlow:mhigh]
174174- `chi1`: 2π·ψ₀ flux normalization
175175- `ro`: Major radius [m]
@@ -190,7 +190,7 @@ function compute_bounce_data(
190190 psi:: Float64 , n:: Int , l:: Int , q:: Float64 ,
191191 bo:: Float64 , bmax:: Float64 , bmin:: Float64 ,
192192 theta_bmax:: Float64 ,
193- tspl, B_extrap , mfac:: Vector{Int} , chi1:: Float64 , ro:: Float64 ,
193+ tspl, B_vpar , mfac:: Vector{Int} , chi1:: Float64 , ro:: Float64 ,
194194 dbob_m_f:: Vector{ComplexF64} , divx_m_f:: Vector{ComplexF64} ,
195195 divxfac:: Float64 , wdfac:: Float64 ,
196196 mass:: Float64 , chrg:: Float64 ,
@@ -241,12 +241,12 @@ function compute_bounce_data(
241241
242242 # Find bounce points and build θ sub-grid
243243 _, _, tdt_pts, tdt_wts = _find_bounce_points_and_grid (
244- lmda, bo, sigma, B_extrap , theta_bmax, psi, ntheta)
244+ lmda, bo, sigma, B_vpar , theta_bmax, psi, ntheta)
245245
246246 # Bounce integrals over θ (Fortran lines 674-735)
247247 wbbar, wdbar, dJdJ_val, wmats_lmda = _bounce_integrate (
248248 tdt_pts, tdt_wts, lmda, lnq, sigma, n, q, bo,
249- tspl, B_extrap , chi1, ro, mfac, dbob_m_f, divx_m_f, divxfac, wdfac,
249+ tspl, B_vpar , chi1, ro, mfac, dbob_m_f, divx_m_f, divxfac, wdfac,
250250 do_matrices, mpert, smat, tmat, xmat, ymat, zmat, scr)
251251
252252 # Physical frequencies (Fortran lines 744-745)
@@ -409,12 +409,12 @@ end
409409
410410
411411"""
412- Parallel-velocity factor `v_par = 1 − (λ/bo)·B(θ)` from the endpoint-fit cubic of B
413- (`B_extrap `, built where the surface interpolants are constructed), keeping v_par
412+ Parallel-velocity factor `v_par = 1 − (λ/bo)·B(θ)` from the periodic cubic of B
413+ (`B_vpar `, built where the surface interpolants are constructed), keeping v_par
414414consistent with the bounce-point roots as in Fortran's `vspl`.
415415"""
416- @inline _vpar_from_extrap (B_extrap , lmda:: Float64 , bo:: Float64 , θ:: Float64 ) =
417- 1.0 - (lmda / bo) * B_extrap (mod (θ, 1.0 ))
416+ @inline _vpar_from_spline (B_vpar , lmda:: Float64 , bo:: Float64 , θ:: Float64 ) =
417+ 1.0 - (lmda / bo) * B_vpar (mod (θ, 1.0 ))
418418
419419
420420"""
@@ -423,14 +423,14 @@ Returns (t1, t2, theta_points, theta_weights).
423423"""
424424function _find_bounce_points_and_grid (
425425 lmda:: Float64 , bo:: Float64 , sigma:: Int ,
426- B_extrap , theta_bmax:: Float64 , psi:: Float64 ,
426+ B_vpar , theta_bmax:: Float64 , psi:: Float64 ,
427427 ntheta:: Int
428428)
429429 if sigma == 0 # trapped
430- # Bounce points: all roots of v_par(θ) = 1 − (λ/bo)·B_extrap (θ) in (0,1),
430+ # Bounce points: all roots of v_par(θ) = 1 − (λ/bo)·B_vpar (θ) in (0,1),
431431 # sorted descending — the same order as Fortran spline_roots, which the
432432 # marginally-trapped and deepest-well wrap logic below assume.
433- vpar_fn = θ -> _vpar_from_extrap (B_extrap , lmda, bo, θ)
433+ vpar_fn = θ -> _vpar_from_spline (B_vpar , lmda, bo, θ)
434434 bpts = sort! (Roots. find_zeros (vpar_fn, 0.0 , 1.0 ); rev= true )
435435
436436 nbpts = length (bpts)
@@ -443,7 +443,7 @@ function _find_bounce_points_and_grid(
443443 t1 = bpts[1 ]
444444 t2 = bpts[1 ] + 1.0
445445 else
446- t1, t2 = _find_deepest_well (bpts, B_extrap , lmda, bo)
446+ t1, t2 = _find_deepest_well (bpts, B_vpar , lmda, bo)
447447 end
448448
449449 # Power-law grid refined near bounce points
463463Find the deepest potential well (largest midpoint v_par) among bounce-point pairs,
464464handling pairs that wrap through θ = 0/1.
465465"""
466- function _find_deepest_well (bpts:: Vector{Float64} , B_extrap , lmda:: Float64 , bo:: Float64 )
466+ function _find_deepest_well (bpts:: Vector{Float64} , B_vpar , lmda:: Float64 , bo:: Float64 )
467467 nbpts = length (bpts)
468468 best_vpar = 0.0
469469 best_t1 = 0.0
@@ -477,7 +477,7 @@ function _find_deepest_well(bpts::Vector{Float64}, B_extrap, lmda::Float64, bo::
477477 else
478478 θmid = 0.5 * (bpts[i] + bpts[j])
479479 end
480- vpar_mid = _vpar_from_extrap (B_extrap , lmda, bo, θmid)
480+ vpar_mid = _vpar_from_spline (B_vpar , lmda, bo, θmid)
481481 if vpar_mid > best_vpar
482482 best_t1 = bpts[i]
483483 best_t2 = bpts[j]
@@ -506,7 +506,7 @@ Ports Fortran torque.F90 lines 674-793.
506506function _bounce_integrate (
507507 tdt_pts:: Vector{Float64} , tdt_wts:: Vector{Float64} ,
508508 lmda:: Float64 , lnq:: Float64 , sigma:: Int , n:: Int , q:: Float64 , bo:: Float64 ,
509- tspl, B_extrap , chi1:: Float64 , ro:: Float64 ,
509+ tspl, B_vpar , chi1:: Float64 , ro:: Float64 ,
510510 mfac:: Vector{Int} , dbob_m_f:: Vector{ComplexF64} , divx_m_f:: Vector{ComplexF64} ,
511511 divxfac:: Float64 , wdfac:: Float64 ,
512512 do_matrices:: Bool , mpert:: Int ,
@@ -550,9 +550,9 @@ function _bounce_integrate(
550550 jac = tspl_f[4 ]
551551 djdpsi = tspl_f[5 ]
552552
553- # v_par from the endpoint-fit cubic (consistent with the bounce points);
553+ # v_par from the periodic cubic (consistent with the bounce points);
554554 # the periodic tspl B_val remains the numerator field in the integrands.
555- vpar = 1.0 - (lmda / bo) * B_extrap (θmod)
555+ vpar = 1.0 - (lmda / bo) * B_vpar (θmod)
556556
557557 if vpar <= 0
558558 # Negative v_par near a bounce point: same fill rules as the Fortran bounce loop.
0 commit comments