|
| 1 | +# Solve Overdetermined and Underdetermined BVP |
| 2 | + |
| 3 | +When there are more or less boundary conditions than the states in a boundary value problem, the BVP would become an overdetermined or underdetermined boundary value problem. As for these kinds of special BVPs, the solving workflow are similar with solving standard BVPs in BoundaryValueDiffEq.jl, but we need to specify the prototype of boundary conditions to tell BoundaryValueDiffEq.jl the structure of our boundary conditions with `bcresid_prototype` in `BVPFunction`. |
| 4 | + |
| 5 | +## Solve Overdetermined BVP |
| 6 | + |
| 7 | +For example, consider an overdetermined BVP given by the system of differential equations |
| 8 | + |
| 9 | +```math |
| 10 | +y_1'=y_2\\ |
| 11 | +y_2'=-y_1 |
| 12 | +``` |
| 13 | + |
| 14 | +with boundary conditions of |
| 15 | + |
| 16 | +```math |
| 17 | +y_1(0)=0, y_1(100)=1, y_2(100) = -1.729109 |
| 18 | +``` |
| 19 | + |
| 20 | +The test BVP has two state variables but three boundary conditions, which means there are additional constraints on the solution. |
| 21 | + |
| 22 | +```@example nlls_overdetermined |
| 23 | +using BoundaryValueDiffEq, Plots |
| 24 | +function f!(du, u, p, t) |
| 25 | + du[1] = u[2] |
| 26 | + du[2] = -u[1] |
| 27 | +end |
| 28 | +function bc!(resid, sol, p, t) |
| 29 | + solₜ₁ = sol(0.0) |
| 30 | + solₜ₂ = sol(100.0) |
| 31 | + resid[1] = solₜ₁[1] |
| 32 | + resid[2] = solₜ₂[1] - 1 |
| 33 | + resid[3] = solₜ₂[2] + 1.729109 |
| 34 | +end |
| 35 | +tspan = (0.0, 100.0) |
| 36 | +u0 = [0.0, 1.0] |
| 37 | +prob = BVProblem(BVPFunction(f!, bc!; bcresid_prototype = zeros(3)), u0, tspan) |
| 38 | +sol = solve(prob, MIRK4(), dt = 0.01) |
| 39 | +plot(sol) |
| 40 | +``` |
| 41 | + |
| 42 | +Since this BVP imposes constaints only at the two endpoints, we can use `TwoPointBVProlem` to handle such cases. |
| 43 | + |
| 44 | +```@example nlls_overdetermined |
| 45 | +function f!(du, u, p, t) |
| 46 | + du[1] = u[2] |
| 47 | + du[2] = -u[1] |
| 48 | +end |
| 49 | +bca!(resid, ua, p) = (resid[1] = ua[1]) |
| 50 | +bcb!(resid, ub, p) = (resid[1] = ub[1] - 1; resid[2] = ub[2] + 1.729109) |
| 51 | +prob = TwoPointBVProblem( |
| 52 | + BVPFunction( |
| 53 | + f!, (bca!, bcb!); twopoint = Val(true), bcresid_prototype = (zeros(1), zeros(2))), |
| 54 | + u0, |
| 55 | + tspan) |
| 56 | +``` |
| 57 | + |
| 58 | +## Solve Underdetermined BVP |
| 59 | + |
| 60 | +Let's see an example of underdetermined BVP, consider an horizontal metal beam of length $L$ subject to a vertical load $q(x)$ per unit length, the resulting beam displacement satisfies the differential equation |
| 61 | + |
| 62 | +```math |
| 63 | +EIy'(x)=q(x) |
| 64 | +``` |
| 65 | + |
| 66 | +with boundary condition $y(0)=y(L)=0$, $E$ is the Young's modulus and $I$ is the moment of inertia of the beam's cross section. Here we consider the simplified version and transform this BVP into a first order BVP system: |
| 67 | + |
| 68 | +```math |
| 69 | +y_1'=y_2\\ |
| 70 | +y_2'=y_3\\ |
| 71 | +y_3'=y_4\\ |
| 72 | +y_4'=0 |
| 73 | +``` |
| 74 | + |
| 75 | +```@example nlls_underdetermined |
| 76 | +using BoundaryValueDiffEq, Plots |
| 77 | +function f!(du, u, p, t) |
| 78 | + du[1] = u[2] |
| 79 | + du[2] = u[3] |
| 80 | + du[3] = u[4] |
| 81 | + du[4] = 0 |
| 82 | +end |
| 83 | +function bc!(resid, sol, p, t) |
| 84 | + solₜ₁ = sol(0.0) |
| 85 | + solₜ₂ = sol(1.0) |
| 86 | + resid[1] = solₜ₁[1] |
| 87 | + resid[2] = solₜ₂[1] |
| 88 | +end |
| 89 | +xspan = (0.0, 1.0) |
| 90 | +u0 = [0.0, 1.0, 0.0, 1.0] |
| 91 | +prob = BVProblem(BVPFunction(f!, bc!; bcresid_prototype = zeros(2)), u0, xspan) |
| 92 | +sol = solve(prob, MIRK4(), dt = 0.01) |
| 93 | +plot(sol) |
| 94 | +``` |
| 95 | + |
| 96 | +Since this problem has less constraints than the state variables, so there would be infinitely many solutions with different `u0` specified. |
| 97 | + |
| 98 | +The above underdetermined is also being able to reformulated as `TwoPointBVProblem` |
| 99 | + |
| 100 | +```@example nlls_underdetermined |
| 101 | +function f!(du, u, p, t) |
| 102 | + du[1] = u[2] |
| 103 | + du[2] = u[3] |
| 104 | + du[3] = u[4] |
| 105 | + du[4] = 0 |
| 106 | +end |
| 107 | +bca!(resid, ua, p) = (resid[1] = ua[1]) |
| 108 | +bcb!(resid, ub, p) = (resid[1] = ub[1]) |
| 109 | +xspan = (0.0, 1.0) |
| 110 | +u0 = [0.0, 1.0, 0.0, 1.0] |
| 111 | +prob = TwoPointBVProblem( |
| 112 | + BVPFunction( |
| 113 | + f!, (bca!, bcb!); twopoint = Val(true), bcresid_prototype = (zeros(1), zeros(1))), |
| 114 | + u0, |
| 115 | + xspan) |
| 116 | +``` |
0 commit comments