You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to solve a two point boundary value problem via continuation but I am encountering an error. I replicate the problem using the example problem.
I first solve the problem from the end point to the middle of the time span:
using BoundaryValueDiffEq
using Plots
const g = 9.81
L = 1.0
tspan = (0.0, pi / 2)
function simplependulum!(du, u, p, t)
θ = u[1]
dθ = u[2]
du[1] = dθ
du[2] = -(g / L) * sin(θ)
end
function bc2a!(resid_a, u_a, p) # u_a is at the beginning of the time span
x0 = p
resid_a[1] = u_a[1] - x0 # the solution at the beginning of the time span should be -pi/2
end
function bc2b!(resid_b, u_b, p) # u_b is at the ending of the time span
x0 = p
resid_b[1] = u_b[1] - pi / 2 # the solution at the end of the time span should be pi/2
end
bvp3 = TwoPointBVProblem(simplependulum!, (bc2a!, bc2b!), [pi / 2, pi / 2], (pi / 4, pi / 2), -pi / 2;
bcresid_prototype=(zeros(1), zeros(1)))
sol3 = solve(bvp3, MIRK4(), dt=0.05)
which yields the correct solution
I then try to solve the problem over the original time span using the previous solution as the initial guess
bvp4 = TwoPointBVProblem(simplependulum!, (bc2a!, bc2b!), sol3, (0, pi / 2), pi / 2;
bcresid_prototype=(zeros(1), zeros(1)))
sol4 = solve(bvp4, MIRK4(), dt=0.05)
This is a SciMLBase fix that is needed here. AbstractDiffEq array is already supported inside MIRK (at least on #155), however, here a solution object is being passed to u0 which should be converted to a DiffEqArray during problem construction (I guess there could be some value in letting the solution type propagate so that we could use interpolation to initialize on an arbitrary mesh)
To add to Chris' solution, note that just passing sol3.u would make an implicit assumption that the initial guess mesh is uniform (which happens to be true in this case). But in general you would want to pass a DiffEqArray in most cases.
Hi,
I am trying to solve a two point boundary value problem via continuation but I am encountering an error. I replicate the problem using the example problem.
I first solve the problem from the end point to the middle of the time span:
which yields the correct solution
I then try to solve the problem over the original time span using the previous solution as the initial guess
This however yields an error
I am using Julia v1.10.0 and BoundaryValueDiffEq v5.6.1
Should the initial guess be provided differently?
Thank you!
The text was updated successfully, but these errors were encountered: