Skip to content

Commit

Permalink
add complexity cost to optimal_λ_regularize
Browse files Browse the repository at this point in the history
  • Loading branch information
orso82 committed Oct 22, 2024
1 parent 65a2bf6 commit fe9f21e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/fixed2free.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ function optimal_λ_regularize(
iso_cps::Vector{<:IsoControlPoint}=IsoControlPoint{Float64}[],
ψbound::Real=0.0,
fixed_coils::AbstractVector{<:AbstractCoil}=PointCoil{Float64,Float64}[],
min_exp::Integer=-20, max_exp::Integer=-10,
min_exp::Integer=-30,
max_exp::Integer=-10,
Sb::MXHEquilibrium.Boundary=plasma_boundary_psi_w_fallback(EQ)[1])

λ_range_exp = min_exp:0.5:max_exp
cost_λ = λ -> cost_λ_regularize(λ, coils, EQ, image; flux_cps, saddle_cps, iso_cps, ψbound, fixed_coils, Sb)
return 10^λ_range_exp[argmin(cost_λ(λ) for λ in λ_range_exp)]
end

costs = log10.([cost_λ(λ) for λ in λ_range_exp])
costs = costs .- minimum(costs)
costs = costs .+ λ_range_exp ./ max_exp .* maximum(costs) * 0.01
opti_λ = λ_range_exp[argmin(costs)]
return 10^opti_λ
end

# ***************************************************
Expand All @@ -76,6 +79,7 @@ plasma_boundary_psi_w_fallback(shot::TEQUILA.Shot, args...) = MXHEquilibrium.Bou
kwargs...) where {T<:Real}
Convert the flux of a fixed-boundary equilibrium `EQfixed` to a free-boundary representation on an `(R,Z)` grid,
using the flux from `coils` with currents satisfying given control points
"""
function fixed2free(
EQfixed::MXHEquilibrium.AbstractEquilibrium,
Expand Down

0 comments on commit fe9f21e

Please sign in to comment.