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
When dealing with scenarios that boundary conditions are stronger than just explicit values at specific points—such as inequality boundary conditions, where the solution must satisfy constraints like staying within upper and lower bounds—we need a more flexible approach. In such cases, we can use the `maxsol` and `minsol` functions provided by BoundaryValueDiffEq.jl to specify such inequality conditions.
4
+
5
+
Let's walk through this functionlity with an intuitive example. We still revisit the simple pendulum example here, but this time, we’ll impose upper and lower bound constraints on the solution, specified as:
6
+
7
+
```math
8
+
lb \leq u \leq ub
9
+
```
10
+
11
+
where `lb=-4.8161991710010925` and `ub=5.0496477654230745`. So the states must be bigger than `lb` but smaller than `ub`. To solve such problems, we can simply use the `minsol` and `maxsol` functions when defining the boundary value problem in BoundaryValueDiffEq.jl.
12
+
13
+
```@example inequality
14
+
tspan = (0.0, pi / 2)
15
+
function simplependulum!(du, u, p, t)
16
+
θ = u[1]
17
+
dθ = u[2]
18
+
du[1] = dθ
19
+
du[2] = -9.81 * sin(θ)
20
+
end
21
+
function bc!(residual, u, p, t)
22
+
residual[1] = maxsol(u, (0.0, pi / 2)) - 5.0496477654230745
23
+
residual[2] = minsol(u, (0.0, pi / 2)) + 4.8161991710010925
0 commit comments