Skip to content

Commit

Permalink
improved error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
orso82 committed Feb 10, 2025
1 parent 50db394 commit 430d4b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/physics/pedestal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ function blend_core_edge_Hmode(
z_targets::AbstractVector{<:Real},
rho_targets::AbstractVector{<:Real})

x = abs.(x)
profile_ped = Hmode_profiles(profile[end], ped_height, length(rho), x[1], x[2], ped_width)
expin = abs(x[1])
expout = abs(x[2])
profile_ped = Hmode_profiles(profile[end], ped_height, length(rho), expin, expout, ped_width)
z_ped = -calc_z(rho, profile_ped, :backward)
z_ped_values = interp1d(rho, z_ped).(rho_targets)
p_values = interp1d(rho, profile_ped).(rho_targets)
Expand All @@ -41,7 +42,8 @@ function blend_core_edge_Hmode(
return norm(z_targets .- z_ped_values) / sum(abs.(z_targets)) .+ norm(p_targets .- p_values) / sum(abs.(p_targets))
end

@assert 0.0 < ped_width < 1.0 "ped_width=($ped_width)"
@assert 0.0 < ped_height "invalid ped_height = $(ped_height)"
@assert 0.0 < ped_width < 1.0 "invalid ped_width = ($ped_width)"
@assert rho[end] == 1.0

z_profile = -calc_z(rho, profile, :backward)
Expand Down
10 changes: 5 additions & 5 deletions src/physics/profiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -723,11 +723,11 @@ end
NOTE: The core value is allowed to float
"""
function Hmode_profiles(edge::Real, ped::Real, ngrid::Int, expin::Real, expout::Real, width::Real)
@assert edge >= 0.0
@assert ped >= 0.0
@assert expin >= 0.0
@assert expout >= 0.0
@assert 0.0 < width < 1.0 "pedestal width cannot be $width"
@assert edge >= 0.0 "invalid edge = $edge"
@assert ped >= 0.0 "invalid ped = $ped"
@assert expin >= 0.0 "invalid expin = $expin"
@assert expout >= 0.0 "invalid expout = $expout"
@assert 0.0 < width < 1.0 "invalid width = $width"

xpsi = range(0.0, 1.0, ngrid)

Expand Down

0 comments on commit 430d4b2

Please sign in to comment.