I have a BVP that I’m trying to solve with TwoPointBVProblem, and having a very hard time debugging it. is there a good way to get output detailing why a problem is unstable?
for example, I initially had a z′/r which is sometimes 0/0, so I had to replace it with the actual value using l’hopital when it’s too small; but it took me a very long time to even realize that that was even the problem.
what I’m actually trying to do is trying to write
in julia, and what I have currently works only when Π is zero (e.g., interface.(0, 0, 1:179) all look like how I’d expect):
using BoundaryValueDiffEq
function capillary!(res, (r′, r, z′, z, V, c, c₂), (;ρ, ω, g, σ), ξ)
Π = ω^2*r^2/2 - g*z
z′_r = abs(r) < 1e-6 ? (ρ/σ*Π+c)/2c₂ : z′/r # l'hopital
r′′ = -z′/c₂ * (ρ/σ*Π + c - c₂*z′_r)
z′′ = r′/c₂ * (ρ/σ*Π + c - c₂*z′_r)
V′ = 2π*r*r′*z
res .= [r′′, r′, z′′, z′, V′, 0., 0.]
end
function start!(res, (r′, r, z′, z, V, c, c₂), p)
res[1] = r
res[2] = r′ - 1/c₂
res[3] = z′
res[4] = V
end
function end!(res, (r′, r, z′, z, V, c, c₂), (;θ, V₀, R))
res[1] = z′ - r′*cotd(θ)
res[2] = V - V₀
res[3] = r - R(z)
end
wall(z) = 1
function interface(g, ω, θ; V₀ = 1, R = wall, ρ = 903.5, σ = 0.028)
u0 = [0., 0., 0., 0., V₀/2, -ρ/σ*(ω^2/6-g), 1.] # threw some random stuff in here to see if it would help, hasn't done anything yet but idk
p = (;ρ, σ, g, ω, θ, V₀, R)
prob = TwoPointBVProblem(capillary!, (start!, end!), u0, (0., 1.), p;
bcresid_prototype=(zeros(4), zeros(3)))
solve(prob, MIRK4(); dt = 1 / 50)
end