Relaxed shooting discontinuity check

This commit is contained in:
Nuwan Yapa 2024-11-25 12:43:25 -05:00
parent 00a5f66418
commit df833235c8
1 changed files with 6 additions and 4 deletions

View File

@ -43,10 +43,12 @@ function solveWf(κ, p, E, Φ0, W0, B0, A0, r_max, divs; shooting=true, normaliz
wf = hcat(sol.u...) wf = hcat(sol.u...)
if shooting # join two segments if shooting # join two segments
rescale_factor = wf[1, end] / wf_right[1, 1] rescale_factor_g = wf[1, end] / wf_right[1, 1]
rescale_factor wf[2, end] / wf_right[2, 1] || @warn "Shooting method joint has a discontinuity" rescale_factor_f = wf[2, end] / wf_right[2, 1]
rescale_factor = isfinite(rescale_factor) ? rescale_factor : 1 @assert isfinite(rescale_factor_g) && isfinite(rescale_factor_f) "Cannot rescale the right partition"
wf = hcat(wf[:, 1:(end - 1)], wf_right .* rescale_factor) isapprox(rescale_factor_g, rescale_factor_f; rtol=0.03) || @warn "Discontinuity between two partitions"
wf_right_rescaled = wf_right .* ((rescale_factor_g + rescale_factor_f) / 2)
wf = hcat(wf[:, 1:(end - 1)], wf_right_rescaled)
end end
if normalize if normalize