Skip to content

Commit e760b8d

Browse files
authored
Merge pull request #134 from avik-pal/ap/docs
2 parents c2e7dc9 + ab4e714 commit e760b8d

File tree

4 files changed

+79
-10
lines changed

4 files changed

+79
-10
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: 8 additions & 8 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
@@ -45,17 +45,17 @@ For the list of available solvers, please refer to the [DifferentialEquations.jl
4545

4646
Precompilation can be controlled via `Preferences.jl`
4747

48-
- `PrecompileMIRK` -- Precompile the MIRK2 - MIRK6 algorithms (default: `true`).
49-
- `PrecompileShooting` -- Precompile the single shooting algorithms (default: `true`). This is triggered when `OrdinaryDiffEq` is loaded.
50-
- `PrecompileMultipleShooting` -- Precompile the multiple shooting algorithms (default: `true`). This is triggered when `OrdinaryDiffEq` is loaded.
51-
- `PrecompileMIRKNLLS` -- Precompile the MIRK2 - MIRK6 algorithms for under-determined and over-determined BVPs (default: `true` on Julia Version 1.10 and above).
52-
- `PrecompileShootingNLLS` -- Precompile the single shooting algorithms for under-determined and over-determined BVPs (default: `true` on Julia Version 1.10 and above). This is triggered when `OrdinaryDiffEq` is loaded.
53-
- `PrecompileMultipleShootingNLLS` -- Precompile the multiple shooting algorithms for under-determined and over-determined BVPs (default: `true` on Julia Version 1.10 and above). This is triggered when `OrdinaryDiffEq` is loaded.
48+
- `PrecompileMIRK` -- Precompile the MIRK2 - MIRK6 algorithms (default: `true`).
49+
- `PrecompileShooting` -- Precompile the single shooting algorithms (default: `true`). This is triggered when `OrdinaryDiffEq` is loaded.
50+
- `PrecompileMultipleShooting` -- Precompile the multiple shooting algorithms (default: `true`). This is triggered when `OrdinaryDiffEq` is loaded.
51+
- `PrecompileMIRKNLLS` -- Precompile the MIRK2 - MIRK6 algorithms for under-determined and over-determined BVPs (default: `true` on Julia Version 1.10 and above).
52+
- `PrecompileShootingNLLS` -- Precompile the single shooting algorithms for under-determined and over-determined BVPs (default: `true` on Julia Version 1.10 and above). This is triggered when `OrdinaryDiffEq` is loaded.
53+
- `PrecompileMultipleShootingNLLS` -- Precompile the multiple shooting algorithms for under-determined and over-determined BVPs (default: `true` on Julia Version 1.10 and above). This is triggered when `OrdinaryDiffEq` is loaded.
5454

5555
To set these preferences before loading the package, do the following (replacing `PrecompileShooting` with the preference you want to set, or pass in multiple pairs to set them together):
5656

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: 70 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 solver which conforms to the
13+
SciML `ODEProblem` interface can be used!
14+
15+
## Keyword Arguments
16+
17+
- `nlsolve`: Internal Nonlinear solver. Any solver which conforms to the SciML
18+
`NonlinearProblem` interface 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,45 @@ 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 solver which conforms to the
43+
SciML `ODEProblem` interface can be used!
44+
45+
## Keyword Arguments
46+
47+
- `nlsolve`: Internal Nonlinear solver. Any solver which conforms to the SciML
48+
`NonlinearProblem` interface can be used. Note that any autodiff argument for the solver
49+
will be ignored and a custom jacobian algorithm will be used.
50+
- `jac_alg`: Jacobian Algorithm used for the nonlinear solver. Defaults to
51+
`BVPJacobianAlgorithm()`, which automatically decides the best algorithm to use based
52+
on the input types and problem type.
53+
- For `TwoPointBVProblem`, only `diffmode` is used (defaults to
54+
`AutoSparseForwardDiff` if possible else `AutoSparseFiniteDiff`).
55+
- For `BVProblem`, `bc_diffmode` and `nonbc_diffmode` are used. For `nonbc_diffmode`
56+
defaults to `AutoSparseForwardDiff` if possible else `AutoSparseFiniteDiff`. For
57+
`bc_diffmode`, defaults to `AutoForwardDiff` if possible else `AutoFiniteDiff`.
58+
- `grid_coarsening`: Coarsening the multiple-shooting grid to generate a stable IVP
59+
solution. Possible Choices:
60+
- `true`: Halve the grid size, till we reach a grid size of 1.
61+
- `false`: Do not coarsen the grid. Solve a Multiple Shooting Problem and finally
62+
solve a Single Shooting Problem.
63+
- `AbstractVector{<:Int}` or `Ntuple{N, <:Integer}`: Use the provided grid coarsening.
64+
For example, if `nshoots = 10` and `grid_coarsening = [5, 2]`, then the grid will be
65+
coarsened to `[5, 2]`. Note that `1` should not be present in the grid coarsening.
66+
- `Function`: Takes the current number of shooting points and returns the next number
67+
of shooting points. For example, if `nshoots = 10` and
68+
`grid_coarsening = n -> n ÷ 2`, then the grid will be coarsened to `[5, 2]`.
69+
70+
!!! note
71+
For type-stability, the chunksizes for ForwardDiff ADTypes in `BVPJacobianAlgorithm`
72+
must be provided.
2373
"""
2474
@concrete struct MultipleShooting{J <: BVPJacobianAlgorithm}
2575
ode_alg
@@ -62,6 +112,25 @@ for order in (2, 3, 4, 5, 6)
62112
63113
$($order)th order Monotonic Implicit Runge Kutta method, with Newton Raphson nonlinear solver as default.
64114
115+
## Keyword Arguments
116+
117+
- `nlsolve`: Internal Nonlinear solver. Any solver which conforms to the SciML
118+
`NonlinearProblem` interface can be used. Note that any autodiff argument for
119+
the solver will be ignored and a custom jacobian algorithm will be used.
120+
- `jac_alg`: Jacobian Algorithm used for the nonlinear solver. Defaults to
121+
`BVPJacobianAlgorithm()`, which automatically decides the best algorithm to
122+
use based on the input types and problem type.
123+
- For `TwoPointBVProblem`, only `diffmode` is used (defaults to
124+
`AutoSparseForwardDiff` if possible else `AutoSparseFiniteDiff`).
125+
- For `BVProblem`, `bc_diffmode` and `nonbc_diffmode` are used. For
126+
`nonbc_diffmode` defaults to `AutoSparseForwardDiff` if possible else
127+
`AutoSparseFiniteDiff`. For `bc_diffmode`, defaults to `AutoForwardDiff` if
128+
possible else `AutoFiniteDiff`.
129+
130+
!!! note
131+
For type-stability, the chunksizes for ForwardDiff ADTypes in
132+
`BVPJacobianAlgorithm` must be provided.
133+
65134
## References
66135
67136
@article{Enright1996RungeKuttaSW,

0 commit comments

Comments
 (0)