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
Solves the BVP defined by `prob` using the algorithm `alg`. All algorithms except `Shooting` methods should specify a `dt` which is the step size for the discretized mesh.
10
+
Solves the BVP defined by `prob` using the algorithm `alg`. All algorithms except `Shooting`and `MultipleShooting`methods should specify a `dt` which is the step size for the discretized mesh.
6
11
7
12
## Recommended Methods
8
13
@@ -34,24 +39,50 @@ off via the keyword argument `adaptive = false`.
34
39
Similar to `MIRK` methods, fully implicit Runge-Kutta methods construct nonlinear problems from the collocation equations of a BVP and solve such nonlinear systems to obtain numerical solutions of BVP. When solving large boundary value problems, choose a nested NonlinearSolve.jl solver by setting `nested_nlsolve=true` in FIRK solvers can achieve better performance.
35
40
36
41
-`LobattoIIIa2` - A 2nd stage LobattoIIIa collocation method.
37
-
38
42
-`LobattoIIIa3` - A 3rd stage LobattoIIIa collocation method.
39
43
-`LobattoIIIa4` - A 4th stage LobattoIIIa collocation method.
40
44
-`LobattoIIIa5` - A 5th stage LobattoIIIa collocation method.
45
+
41
46
-`LobattoIIIb2` - A 2nd stage LobattoIIIa collocation method, doesn't support defect control adaptivity.
42
47
-`LobattoIIIb3` - A 3rd stage LobattoIIIa collocation method.
43
48
-`LobattoIIIb4` - A 4th stage LobattoIIIa collocation method.
44
49
-`LobattoIIIb5` - A 5th stage LobattoIIIa collocation method.
50
+
45
51
-`LobattoIIIc2` - A 2nd stage LobattoIIIa collocation method, doesn't support defect control adaptivity.
46
52
-`LobattoIIIc3` - A 3rd stage LobattoIIIa collocation method.
47
53
-`LobattoIIIc4` - A 4th stage LobattoIIIa collocation method.
48
54
-`LobattoIIIc5` - A 5th stage LobattoIIIa collocation method.
55
+
49
56
-`RadauIIa1` - A 1st stage Radau collocation method, doesn't support defect control adaptivity.
50
57
-`RadauIIa2` - A 2nd stage Radau collocation method.
51
58
-`RadauIIa3` - A 3rd stage Radau collocation method.
52
59
-`RadauIIa5` - A 5th stage Radau collocation method.
53
60
-`RadauIIa7` - A 7th stage Radau collocation method.
54
61
62
+
#### Gauss Legendre collocation methods
63
+
64
+
The `Ascher` collocation methods are similar with `MIRK` and `FIRK` methods but have extension for BVDAE prblem solving, the error control is based on instead of defect control adaptivity.
65
+
66
+
-`Ascher1` - A 1st stage Gauss Legendre collocation method with Ascher's error control adaptivity.
67
+
-`Ascher2` - A 2nd stage Gauss Legendre collocation method with Ascher's error control adaptivity.
68
+
-`Ascher3` - A 3rd stage Gauss Legendre collocation method with Ascher's error control adaptivity.
69
+
-`Ascher4` - A 4th stage Gauss Legendre collocation method with Ascher's error control adaptivity.
70
+
-`Ascher5` - A 5th stage Gauss Legendre collocation method with Ascher's error control adaptivity.
71
+
-`Ascher6` - A 6th stage Gauss Legendre collocation method with Ascher's error control adaptivity.
72
+
-`Ascher7` - A 7th stage Gauss Legendre collocation method with Ascher's error control adaptivity.
-`MIRKN4` - A 4th order collocation method using an implicit Runge-Kutta-Nyström tableau without defect control adaptivity.
77
+
-`MIRKN6` - A 6th order collocation method using an implicit Runge-Kutta-Nyström tableau without defect control adaptivity.
78
+
79
+
### SimpleBoundaryValueDiffEq.jl
80
+
81
+
-`SimpleMIRK4` - A simplified 4th order collocation method using an implicit Runge-Kutta tableau.
82
+
-`SimpleMIRK5` - A simplified 5th order collocation method using an implicit Runge-Kutta tableau.
83
+
-`SimpleMIRK6` - A simplified 6th order collocation method using an implicit Runge-Kutta tableau.
84
+
-`SimpleShooting` - A simplified single Shooting method.
85
+
55
86
### ODEInterface.jl
56
87
57
88
ODEInterface.jl can be used seamlessly with BoundaryValueDiffEq.jl, after we define our model using `BVProblem` or `TwoPointBVProblem`, we can directly call the solvers from ODEInterface.jl.
Copy file name to clipboardExpand all lines: docs/src/tutorials/bvp_example.md
+91-17Lines changed: 91 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,32 +31,26 @@ function simplependulum!(du, u, p, t)
31
31
end
32
32
```
33
33
34
-
### Boundary Condition
35
-
36
34
There are two problem types available:
37
35
38
-
- A problem type for general boundary conditions `BVProblem` (including conditions that may be anywhere/ everywhere on the integration interval).
39
-
- A problem type for boundaries that are specified at the beginning and the end of the integration interval `TwoPointBVProblem`
40
-
41
-
#### `BVProblem`
36
+
- A problem type for general boundary conditions `BVProblem` (including conditions that may be anywhere/ everywhere on the integration interval, aka multi-points BVP).
37
+
- A problem type for boundaries that are specified at the beginning and the end of the integration interval `TwoPointBVProblem`(aka two-points BVP)
42
38
43
39
The boundary conditions are specified by a function that calculates the residual in-place from the problem solution, such that the residual is $\vec{0}$ when the boundary condition is satisfied.
44
40
45
41
```@example bvp
46
42
function bc1!(residual, u, p, t)
47
-
residual[1] = u[end ÷ 2][1] + pi / 2 # the solution at the middle of the time span should be -pi/2
48
-
residual[2] = u[end][1] - pi / 2 # the solution at the end of the time span should be pi/2
43
+
residual[1] = u(pi/4)[1] + pi / 2 # the solution at the middle of the time span should be -pi/2
44
+
residual[2] = u(pi/2)[1] - pi / 2 # the solution at the end of the time span should be pi/2
The third argument of `BVProblem`is the initial guess of the solution, which is constant in this example.
51
+
The third argument of `BVProblem`or `TwoPointBVProblem`is the initial guess of the solution, which can be specified as a `Vector`, a `Function` of `t` or solution object from previous solving, in this example the initial guess is setted as a `Vector`.
56
52
57
-
<!-- add examples of more general initial conditions -->
58
-
We need to use `MIRK4` or `Shooting` methods to solve `BVProblem`. `MIRK4` is a collocation method, whereas `Shooting` treats the problem as an IVP and varies the initial conditions until the boundary conditions are met.
59
-
If you can have a good initial guess, `Shooting` method works very well.
53
+
There are collocation and shooting methods for addressing boundary value problems in DifferentialEquations.jl. We need to use appropriate [available BVP solvers](@ref bvp_solve) to solve `BVProblem`. In this example, we use `MIRK4` to solve the simple pendulum example.
The initial guess can also be supplied via a function of `t` or a previous solution type, this is especially handy for parameter analysis.
73
-
We changed `u` to `sol` to emphasize the fact that in this case, the boundary condition can be written on the solution object. Thus, all the features on the solution type such as interpolations are available when using the `Shooting`method. (i.e. you can have a boundary condition saying that the maximum over the interval is `1` using an optimization function on the continuous output). Note that user has to import the IVP solver before it can be used. Any common interface ODE solver is acceptable.
67
+
We changed `u` to `sol` to emphasize the fact that in this case, the boundary condition can be written on the solution object. Thus, all the features on the solution type such as interpolations are available when using both collocation nd shooting method. (i.e. you can have a boundary condition saying that the maximum over the interval is `1` using an optimization function on the continuous output).
74
68
75
69
```@example bvp
76
70
plot(sol3)
77
71
```
78
72
79
-
#### `TwoPointBVProblem`
80
-
81
73
`TwoPointBVProblem` is operationally the same as `BVProblem` but allows for the solver
82
74
to specialize on the common form of being a two-point BVP, i.e. a BVP which only has
83
75
boundary conditions at the start and the finish of the time interval.
@@ -99,5 +91,87 @@ plot(sol2)
99
91
Note here that `bc2a!` is a boundary condition for the first time point, and `bc2b!` is a boundary condition
100
92
for the final time point. `bcresid_prototype` is a prototype array which is passed in order to know the size of
101
93
`resid_a` and `resid_b`. In this case, we have one residual term for the start and one for the final time point,
102
-
and thus we have `bcresid_prototype = (zeros(1), zeros(1))`. If we wanted to only have boundary conditions at the
103
-
final time, we could instead have done `bcresid_prototype = (zeros(0), zeros(2))`.
94
+
and thus we have `bcresid_prototype = (zeros(1), zeros(1))`.
95
+
96
+
## Example 2: Directly Solving with Second Order BVP
97
+
98
+
Suppose we want to solve the second order BVP system which can be formulated as
The common way of solving the second order BVP is to define intermidiate variables and transform the second order system into first order one, however, DifferentialEquations.jl allows the direct solving of second order BVP system to achieve more efficiency and higher continuity of the numerical solution.
116
+
117
+
```@example bvp
118
+
function f!(ddu, du, u, p, t)
119
+
ϵ = 0.1
120
+
ddu[1] = u[2]
121
+
ddu[2] = (-u[1] * du[2] - u[3] * du[3]) / ϵ
122
+
ddu[3] = (du[1] * u[3] - u[1] * du[3]) / ϵ
123
+
end
124
+
function bc!(res, du, u, p, t)
125
+
res[1] = u(0.0)[1]
126
+
res[2] = u(1.0)[1]
127
+
res[3] = u(0.0)[3] + 1
128
+
res[4] = u(1.0)[3] - 1
129
+
res[5] = du(0.0)[1]
130
+
res[6] = du(1.0)[1]
131
+
end
132
+
u0 = [1.0, 1.0, 1.0]
133
+
tspan = (0.0, 1.0)
134
+
prob = SecondOrderBVProblem(f!, bc!, u0, tspan)
135
+
sol = solve(prob, MIRKN4(), dt = 0.01)
136
+
```
137
+
138
+
## Example 3: Semi-Explicit Boundary Value Differential-Algebraic Equations
139
+
140
+
Consider a semi-explicit boundary value differential-algebraic equation formulated as
141
+
142
+
```math
143
+
\begin{cases}
144
+
x_1'=(\epsilon+x_2-p_2(t))y+p_1'(t) \\
145
+
x_2'=p_2'(t) \\
146
+
x_3'=y \\
147
+
0=(x_1-p_1(t))(y-e^t)
148
+
\end{cases}
149
+
```
150
+
151
+
with boundary conditions
152
+
153
+
```math
154
+
x_1(0)=0,x_3(0)=1,x_2(1)=\sin(1)
155
+
```
156
+
157
+
We need to choose the Ascher methods for solving BVDAEs.
0 commit comments