Elegant method to attach two partitions
This commit is contained in:
parent
9f8cea12a3
commit
a143edb496
21
nucleons.jl
21
nucleons.jl
|
|
@ -1,4 +1,4 @@
|
||||||
using DifferentialEquations, Interpolations
|
using LinearAlgebra, DifferentialEquations, Interpolations
|
||||||
include("bisection.jl")
|
include("bisection.jl")
|
||||||
include("common.jl")
|
include("common.jl")
|
||||||
include("system.jl")
|
include("system.jl")
|
||||||
|
|
@ -73,17 +73,20 @@ function solveNucleonWf(κ, p::Bool, E, s::system; shooting=true, normalize=true
|
||||||
wf = hcat(sol.u...)
|
wf = hcat(sol.u...)
|
||||||
|
|
||||||
if shooting # join two segments
|
if shooting # join two segments
|
||||||
rescale_factor_g = wf[1, end] / wf_right[1, 1]
|
u1 = wf[:, end]
|
||||||
rescale_factor_f = wf[2, end] / wf_right[2, 1]
|
u2 = wf_right[:, 1]
|
||||||
@assert isfinite(rescale_factor_g) && isfinite(rescale_factor_f) "Cannot rescale the right partition"
|
if norm(u2) < 1e-10
|
||||||
isapprox(rescale_factor_g, rescale_factor_f; rtol=0.03) || @warn "Discontinuity between two partitions"
|
@warn "Right partition too small to rescale, setting to zero"
|
||||||
wf_right_rescaled = wf_right .* ((rescale_factor_g + rescale_factor_f) / 2)
|
wf_right .= 0.0
|
||||||
wf = hcat(wf[:, 1:(end - 1)], wf_right_rescaled)
|
else
|
||||||
|
proj = only(u1' * u2) / norm(u2)^2
|
||||||
|
wf_right .*= proj
|
||||||
|
end
|
||||||
|
wf = hcat(wf[:, 1:(end - 1)], wf_right)
|
||||||
end
|
end
|
||||||
|
|
||||||
if normalize
|
if normalize
|
||||||
norm = sum(wf .* wf) * Δr(s) # integration by Reimann sum
|
wf ./= norm(wf) * Δr(s) # integration by Reimann sum
|
||||||
wf = wf ./ sqrt(norm)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return wf
|
return wf
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue