-
-
Notifications
You must be signed in to change notification settings - Fork 38
Add maxsol and minsol #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5de3119
Add maxsol and minsol
ErikQQY 697b367
Fix CI failings
ErikQQY 1a0fe09
Parent package export maxsol and minsol
ErikQQY f885af1
Dont forget Plots
ErikQQY 3954e34
Merge branch 'master' into qqy/max_min_sol
ErikQQY e279765
Merge branch 'master' into qqy/max_min_sol
ErikQQY 055e4f6
Actually extremum boundary conditions
ErikQQY File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Solve BVP with Inequality Boundary Conditions | ||
|
||
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. | ||
|
||
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: | ||
|
||
```math | ||
lb \leq u \leq ub | ||
``` | ||
|
||
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. | ||
|
||
```@example inequality | ||
using BoundaryValueDiffEq, Plots | ||
tspan = (0.0, pi / 2) | ||
function simplependulum!(du, u, p, t) | ||
θ = u[1] | ||
dθ = u[2] | ||
du[1] = dθ | ||
du[2] = -9.81 * sin(θ) | ||
end | ||
function bc!(residual, u, p, t) | ||
residual[1] = maxsol(u, (0.0, pi / 2)) - 5.0496477654230745 | ||
residual[2] = minsol(u, (0.0, pi / 2)) + 4.8161991710010925 | ||
end | ||
prob = BVProblem(simplependulum!, bc!, [pi / 2, pi / 2], tspan) | ||
sol = solve(prob, MIRK4(), dt = 0.05) | ||
plot(sol) | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,5 +160,6 @@ end | |
|
||
export MIRK2, MIRK3, MIRK4, MIRK5, MIRK6, MIRK6I | ||
export BVPJacobianAlgorithm | ||
export maxsol, minsol | ||
|
||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,6 @@ export BVPM2, BVPSOL, COLNEW # From ODEInterface.jl | |
|
||
export BVPJacobianAlgorithm | ||
|
||
export maxsol, minsol | ||
|
||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.