From fe9f21e0c7330df5fd99e4f05a8d8ffc984b07f0 Mon Sep 17 00:00:00 2001 From: Orso Meneghini Date: Mon, 21 Oct 2024 20:48:44 -0700 Subject: [PATCH] =?UTF-8?q?add=20complexity=20cost=20to=20optimal=5F=CE=BB?= =?UTF-8?q?=5Fregularize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fixed2free.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/fixed2free.jl b/src/fixed2free.jl index 33bb7e9..9c874b0 100644 --- a/src/fixed2free.jl +++ b/src/fixed2free.jl @@ -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 # *************************************************** @@ -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,