-
-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathalgorithms.jl
More file actions
129 lines (107 loc) · 5.59 KB
/
Copy pathalgorithms.jl
File metadata and controls
129 lines (107 loc) · 5.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Algorithms
abstract type AbstractMIRK <: AbstractBoundaryValueDiffEqAlgorithm end
for order in (2, 3, 4, 5, 6)
alg = Symbol("MIRK$(order)")
@eval begin
"""
$($alg)(; nlsolve = NewtonRaphson(), jac_alg = BVPJacobianAlgorithm(), platform = CPU(),
defect_threshold = 0.1, max_num_subintervals = 3000)
$($order)th order Monotonic Implicit Runge Kutta method.
## Keyword Arguments
- `nlsolve`: Internal Nonlinear solver. Any solver which conforms to the SciML
`NonlinearProblem` interface can be used. Note that any autodiff argument for
the solver will be ignored and a custom jacobian algorithm will be used.
- `optimize`: Internal Optimization solver. Any solver which conforms to the SciML
`OptimizationProblem` interface can be used. Note that any autodiff argument for
the solver will be ignored and a custom jacobian algorithm will be used. Optimization
solvers should first be loaded to allow this functionality.
- `jac_alg`: Jacobian Algorithm used for the nonlinear solver. Defaults to
`BVPJacobianAlgorithm()`, which automatically decides the best algorithm to
use based on the input types and problem type.
+ For `TwoPointBVProblem`, only `diffmode` is used (defaults to
`AutoSparse(AutoForwardDiff())` if possible else `AutoSparse(AutoFiniteDiff())`).
+ For `BVProblem`, `bc_diffmode` and `nonbc_diffmode` are used. For
`nonbc_diffmode` defaults to `AutoSparse(AutoForwardDiff())` if possible else
`AutoSparse(AutoFiniteDiff())`. For `bc_diffmode`, defaults to `AutoForwardDiff` if
possible else `AutoFiniteDiff`.
- `platform`: KernelAbstractions backend used to evaluate the collocation
equations. Defaults to `CPU()`.
- `defect_threshold`: Threshold for defect control.
- `max_num_subintervals`: Number of maximal subintervals, default as 3000.
!!! note
For type-stability, the chunksizes for ForwardDiff ADTypes in
`BVPJacobianAlgorithm` must be provided.
## References
```bibtex
@article{Enright1996RungeKuttaSW,
title={Runge-Kutta Software with Defect Control for Boundary Value ODEs},
author={Wayne H. Enright and Paul H. Muir},
journal={SIAM J. Sci. Comput.},
year={1996},
volume={17},
pages={479-497}
}
```
"""
@kwdef struct $(alg){N, O, J <: BVPJacobianAlgorithm, P <: Backend, T} <: AbstractMIRK
nlsolve::N = nothing
optimize::O = nothing
jac_alg::J = BVPJacobianAlgorithm()
platform::P = CPU()
defect_threshold::T = 0.1
max_num_subintervals::Int = 3000
end
end
end
for order in (6)
alg = Symbol("MIRK$(order)I")
@eval begin
"""
$($alg)(; nlsolve = NewtonRaphson(), jac_alg = BVPJacobianAlgorithm(), platform = CPU(),
defect_threshold = 0.1, max_num_subintervals = 3000)
$($order)th order Monotonic Implicit Runge Kutta method.
## Keyword Arguments
- `nlsolve`: Internal Nonlinear solver. Any solver which conforms to the SciML
`NonlinearProblem` interface can be used. Note that any autodiff argument for
the solver will be ignored and a custom jacobian algorithm will be used.
- `optimize`: Internal Optimization solver. Any solver which conforms to the SciML
`OptimizationProblem` interface can be used. Note that any autodiff argument for
the solver will be ignored and a custom jacobian algorithm will be used.
- `jac_alg`: Jacobian Algorithm used for the nonlinear solver. Defaults to
`BVPJacobianAlgorithm()`, which automatically decides the best algorithm to
use based on the input types and problem type.
+ For `TwoPointBVProblem`, only `diffmode` is used (defaults to
`AutoSparse(AutoForwardDiff())` if possible else `AutoSparse(AutoFiniteDiff())`).
+ For `BVProblem`, `bc_diffmode` and `nonbc_diffmode` are used. For
`nonbc_diffmode` defaults to `AutoSparse(AutoForwardDiff())` if possible else
`AutoSparse(AutoFiniteDiff())`. For `bc_diffmode`, defaults to `AutoForwardDiff` if
possible else `AutoFiniteDiff`.
- `platform`: KernelAbstractions backend used to evaluate the collocation
equations. Defaults to `CPU()`.
- `defect_threshold`: Threshold for defect control.
- `max_num_subintervals`: Number of maximal subintervals, default as 3000.
!!! note
For type-stability, the chunksizes for ForwardDiff ADTypes in
`BVPJacobianAlgorithm` must be provided.
## References
```bibtex
@article{Enright1996RungeKuttaSW,
title={Runge-Kutta Software with Defect Control for Boundary Value ODEs},
author={Wayne H. Enright and Paul H. Muir},
journal={SIAM J. Sci. Comput.},
year={1996},
volume={17},
pages={479-497}
}
```
"""
@kwdef struct $(alg){N, O, J <: BVPJacobianAlgorithm, P <: Backend, T} <: AbstractMIRK
nlsolve::N = nothing
optimize::O = nothing
jac_alg::J = BVPJacobianAlgorithm()
platform::P = CPU()
defect_threshold::T = 0.1
max_num_subintervals::Int = 3000
end
end
end