Skip to content

Commit e9cfdc6

Browse files
committed
Add documentation about the solvers
1 parent c2e7dc9 commit e9cfdc6

File tree

4 files changed

+74
-4
lines changed

4 files changed

+74
-4
lines changed

.JuliaFormatter.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
style = "sciml"
22
annotate_untyped_fields_with_any = false
3+
format_markdown = true

LICENSE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ The BoundaryValueDiffEq.jl package is licensed under the MIT "Expat" License:
1919
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
> SOFTWARE.
22-
>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![Package Downloads](https://shields.io/endpoint?url=https://pkgs.genieframework.com/api/v1/badge/BoundaryValueDiffEq)](https://pkgs.genieframework.com?packages=BoundaryValueDiffEq)
99
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
1010

11-
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
11+
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor%27s%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
1212
[![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle)
1313

1414
BoundaryValueDiffEq.jl is a component package in the DifferentialEquations ecosystem. It holds the
@@ -57,5 +57,5 @@ To set these preferences before loading the package, do the following (replacing
5757
```julia
5858
using Preferences, UUIDs
5959
Preferences.set_preferences!(UUID("764a87c0-6b3e-53db-9096-fe964310641d"),
60-
"PrecompileShooting" => false)
60+
"PrecompileShooting" => false)
6161
```

src/algorithms.jl

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ abstract type AbstractMIRK <: BoundaryValueDiffEqAlgorithm end
66
Shooting(ode_alg; nlsolve = NewtonRaphson())
77
88
Single shooting method, reduces BVP to an initial value problem and solves the IVP.
9+
10+
## Arguments
11+
12+
- `ode_alg`: ODE algorithm to use for solving the IVP. Any `OrdinaryDiffEq.jl` or solvers
13+
that work with `SciMLBase.__solve(::ODEProblem, alg, args...; kwargs...)` can be used!
14+
15+
## Keyword Arguments
16+
17+
- `nlsolve`: Internal Nonlinear solver. Any `NonlinearSolve.jl` solver or solvers that
18+
work with `SciMLBase.__solve(::NonlinearProblem, alg, args...; kwargs...)` can be used!
19+
20+
!!! note
21+
For type-stability, you need to specify the chunksize for autodiff. This can be done
22+
via `NewtonRaphson(; autodiff = AutoForwardDiff(; chunksize = <chunksize>))`.
23+
Alternatively, you can use other ADTypes!
924
"""
1025
struct Shooting{O, N} <: BoundaryValueDiffEqAlgorithm
1126
ode_alg::O
@@ -16,10 +31,46 @@ Shooting(ode_alg; nlsolve = NewtonRaphson()) = Shooting(ode_alg, nlsolve)
1631

1732
"""
1833
MultipleShooting(nshoots::Int, ode_alg; nlsolve = NewtonRaphson(),
19-
grid_coarsening = true)
34+
grid_coarsening = true, jac_alg = BVPJacobianAlgorithm())
2035
2136
Multiple Shooting method, reduces BVP to an initial value problem and solves the IVP.
2237
Significantly more stable than Single Shooting.
38+
39+
## Arguments
40+
41+
- `nshoots`: Number of shooting points.
42+
- `ode_alg`: ODE algorithm to use for solving the IVP. Any `OrdinaryDiffEq.jl` or solvers
43+
that work with `SciMLBase.__solve(::ODEProblem, alg, args...; kwargs...)` can be used!
44+
45+
## Keyword Arguments
46+
47+
- `nlsolve`: Internal Nonlinear solver. Any `NonlinearSolve.jl` solver or solvers that
48+
work with `SciMLBase.__solve(::NonlinearProblem, alg, args...; kwargs...)` can be used!
49+
Note that any autodiff argument for the solver will be ignored and a custom jacobian
50+
algorithm will be used.
51+
- `jac_alg`: Jacobian Algorithm used for the nonlinear solver. Defaults to
52+
`BVPJacobianAlgorithm()`, which automatically decides the best algorithm to use based
53+
on the input types and problem type.
54+
- For `TwoPointBVProblem`, only `diffmode` is used (defaults to
55+
`AutoSparseForwardDiff` if possible else `AutoSparseFiniteDiff`).
56+
- For `BVProblem`, `bc_diffmode` and `nonbc_diffmode` are used. For `nonbc_diffmode`
57+
defaults to `AutoSparseForwardDiff` if possible else `AutoSparseFiniteDiff`. For
58+
`bc_diffmode`, defaults to `AutoForwardDiff` if possible else `AutoFiniteDiff`.
59+
- `grid_coarsening`: Coarsening the multiple-shooting grid to generate a stable IVP
60+
solution. Possible Choices:
61+
- `true`: Halve the grid size, till we reach a grid size of 1.
62+
- `false`: Do not coarsen the grid. Solve a Multiple Shooting Problem and finally
63+
solve a Single Shooting Problem.
64+
- `AbstractVector{<:Int}` or `Ntuple{N, <:Integer}`: Use the provided grid coarsening.
65+
For example, if `nshoots = 10` and `grid_coarsening = [5, 2]`, then the grid will be
66+
coarsened to `[5, 2]`. Note that `1` should not be present in the grid coarsening.
67+
- `Function`: Takes the current number of shooting points and returns the next number
68+
of shooting points. For example, if `nshoots = 10` and
69+
`grid_coarsening = n -> n ÷ 2`, then the grid will be coarsened to `[5, 2]`.
70+
71+
!!! note
72+
For type-stability, the chunksizes for ForwardDiff ADTypes in `BVPJacobianAlgorithm`
73+
must be provided.
2374
"""
2475
@concrete struct MultipleShooting{J <: BVPJacobianAlgorithm}
2576
ode_alg
@@ -62,6 +113,25 @@ for order in (2, 3, 4, 5, 6)
62113
63114
$($order)th order Monotonic Implicit Runge Kutta method, with Newton Raphson nonlinear solver as default.
64115
116+
## Keyword Arguments
117+
118+
- `nlsolve`: Internal Nonlinear solver. Any `NonlinearSolve.jl` solver or
119+
solvers that work with
120+
`SciMLBase.__solve(::NonlinearProblem, alg, args...; kwargs...)` can be used!
121+
- `jac_alg`: Jacobian Algorithm used for the nonlinear solver. Defaults to
122+
`BVPJacobianAlgorithm()`, which automatically decides the best algorithm to
123+
use based on the input types and problem type.
124+
- For `TwoPointBVProblem`, only `diffmode` is used (defaults to
125+
`AutoSparseForwardDiff` if possible else `AutoSparseFiniteDiff`).
126+
- For `BVProblem`, `bc_diffmode` and `nonbc_diffmode` are used. For
127+
`nonbc_diffmode` defaults to `AutoSparseForwardDiff` if possible else
128+
`AutoSparseFiniteDiff`. For `bc_diffmode`, defaults to `AutoForwardDiff` if
129+
possible else `AutoFiniteDiff`.
130+
131+
!!! note
132+
For type-stability, the chunksizes for ForwardDiff ADTypes in
133+
`BVPJacobianAlgorithm` must be provided.
134+
65135
## References
66136
67137
@article{Enright1996RungeKuttaSW,

0 commit comments

Comments
 (0)