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
Continuation is a commonly used technique for solving numerically difficult boundary value problems, we exploit the priori knowledge of the solution as initial guess to accelerate the BVP solving by breaking up the difficult BVP into a sequence of simpler problems. For example, we use the problem from [ascher1995numerical](@Citet) in this tutorial:
for $\epsilon=10^{-4}$, on $t\in[-1,1]$ with two point boundary conditions $y(-1)=-2, y(1)=0$. With analitical solution of $y(x)=\cos(\pi x)+\text{erf}(\frac{x}{\sqrt{2\epsilon}})/\text{erf}(\frac{1}{\sqrt{2\epsilon}})$, this problem has a rapid transition layer at $x=0$, making it difficult to solve numerically. In this tutorial, we will showcase how to use continuation with BoundaryValueDiffEq.jl to solve this BVP.
10
+
11
+
We use the substitution to transform this problem into a first order BVP system:
Since this BVP would become difficult to solve when $0<\epsilon\ll 1$, we start the continuation with relatively bigger $\epsilon$ to first obtain a good initial guess for cases when $\epsilon$ are becoming extremely small. We can just use the previous solution from BVP solving as the initial guess `u0` when constructing a new `BVProblem`.
19
+
20
+
```@example continuation
21
+
using BoundaryValueDiffEq, Plots
22
+
function f!(du, u, p, t)
23
+
du[1] = u[2]
24
+
du[2] = -t / p * u[2] - pi^2 * cos(pi * t) - pi * t / p * sin(pi * t)
25
+
end
26
+
function bc!(res, u, p, t)
27
+
res[1] = u[1][1] + 2
28
+
res[2] = u[end][1]
29
+
end
30
+
tspan = (-1.0, 1.0)
31
+
sol = [1.0, 0.0]
32
+
e = 0.1
33
+
for i in 2:4
34
+
global e = e / 10
35
+
prob = BVProblem(f!, bc!, sol, tspan, e)
36
+
global sol = solve(prob, MIRK4(), dt = 0.01)
37
+
end
38
+
plot(sol, idxs = [1])
39
+
```
40
+
41
+
In the iterative solving, the intermediate solutions are each used as the initial guess for the next problem solving.
42
+
43
+
## On providing initial guess
44
+
45
+
There are several ways of providing initial guess in `BVProblem`/`TwoPointBVProblem`:
46
+
47
+
1. Solution from BVP/ODE solving from SciML packages with `ODESolution` type.
48
+
2.`VectorOfArray` from RecursiveArrayTools.jl.
49
+
3.`DiffEqArray` from RecursiveArrayTools.jl.
50
+
4. Function handle of the form `f(p, t)` for specifying initial guess on time span.
51
+
5.`AbstractArray` represent only the possible initial condition.
0 commit comments