From 171d05979205c62e7071098459f4579665e0b962 Mon Sep 17 00:00:00 2001 From: Brendan Lyons Date: Wed, 23 Aug 2023 16:31:35 -0700 Subject: [PATCH] Remove internal function call from Pprime --- src/shot.jl | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/shot.jl b/src/shot.jl index d015ecd..9e656d5 100644 --- a/src/shot.jl +++ b/src/shot.jl @@ -490,18 +490,16 @@ end Pprime(shot::Shot, P::Nothing, dP_dψ) = dP_dψ -function Pprime(shot::Shot, P, dP_dψ::Nothing) - function dp(x) - if x == 0.0 - ϵ = 1e-6 - dp1 = dp(ϵ) - dp2 = dp(2ϵ) - return 2.0 * dp1 - dp2 - end - return D(shot.P, x) / dψ_dρ(shot, x) +function _dp(x, shot) + if x == 0.0 + ϵ = 1e-6 + dp1 = _dp(ϵ, shot) + dp2 = _dp(2ϵ, shot) + return 2.0 * dp1 - dp2 end - return dp + return D(shot.P, x) / dψ_dρ(shot, x) end +Pprime(shot::Shot, P, dP_dψ::Nothing) = (x -> _dp(x, shot)) function MXHEquilibrium.pressure_gradient(shot::Shot, psi) rho = ρ(shot, psi)