Hi everyone,
I’m trying to solve the axisymetric Berman’s equation (see here) with DifferentialEquations.jl. This is a fourth order BVP :
with the associated boundary conditions:
R is a constant parameter corresponding to the flow Reynolds number. The solution is very close to F(r) = sin(\pi/2 r^2), especially when R \rightarrow +\infty.
I used to solve this equation using MATLAB bvp4c function. I am know trying DifferentialEquations.jl. I can recover the correct solution but as soon as I ask for a “fine” mesh, i.e \Delta r = 0.001, the computation time is very high (more than 10 minutes on my laptop) whereas it was 60s maximum for MATLAB bvp4c.
I think a clever initialization could help, but I didn’t find out how to specify the \sin(\pi/2r^2) solution as an initial solution.
Could anybody look at my implementation and give me some advice please? Especially:
- what should look like the init. vector?
- how to deal with the jacobian singularity in r=0?
Here is my code:
function f!(du,u,p,r)
F0 = u[1]
F1 = u[2]
F2 = u[3]
F3 = u[4]
if (r < p.myeps)
du .= [
F1
F2
F3
0.
]
else
du .= [
F1
F2
F3
1/r*( 2*F3-3*F2/r + 3*F1/(r*r) ) - p.Rey/r*( -F1*F2+F0*F3 -3*F0*F2/r + F1*F1/r +3*F0*F1/(r*r) )
]
end
end
function bc!(residual, u, p, r)
uleft = u[1]
uright = u[end]
residual .= [
uright[1] - 1.
uright[2]
uleft[1]
uleft[2]
]
end
rspan = (0.,1.)
p = (Rey = Rey, myeps = 1e-20)
u0 = [0., 0., 0., 0.] # I don't know how to use the init function
bvp = TwoPointBVProblem(f!, bc!, u0, rspan, p)
sol = solve(bvp, MIRK4(), dt=dt) # we need to use the MIRK4 solver for TwoPointBVProblem