62
62
63
63
"""
64
64
MultipleShooting(nshoots::Int, ode_alg; nlsolve = NewtonRaphson(),
65
- grid_coarsening = true, jac_alg = BVPJacobianAlgorithm())
65
+ grid_coarsening = true, jac_alg = BVPJacobianAlgorithm(),
66
+ static_auto_nodes::Val = Val(false))
66
67
67
68
Multiple Shooting method, reduces BVP to an initial value problem and solves the IVP.
68
69
Significantly more stable than Single Shooting.
@@ -97,22 +98,25 @@ Significantly more stable than Single Shooting.
97
98
- `Function`: Takes the current number of shooting points and returns the next number
98
99
of shooting points. For example, if `nshoots = 10` and
99
100
`grid_coarsening = n -> n ÷ 2`, then the grid will be coarsened to `[5, 2]`.
101
+ - `static_auto_nodes`: Automatically detect the timepoints used in the boundary condition
102
+ and use a faster version of the algorithm! This particular keyword argument should be
103
+ considered experimental and should be used with care!
100
104
101
105
!!! note
102
106
For type-stability, the chunksizes for ForwardDiff ADTypes in `BVPJacobianAlgorithm`
103
107
must be provided.
104
108
"""
105
- @concrete struct MultipleShooting{J <: BVPJacobianAlgorithm }
109
+ @concrete struct MultipleShooting{S, J <: BVPJacobianAlgorithm }
106
110
ode_alg
107
111
nlsolve
108
112
jac_alg:: J
109
113
nshoots:: Int
110
114
grid_coarsening
111
115
end
112
116
113
- function concretize_jacobian_algorithm (alg:: MultipleShooting , prob)
117
+ function concretize_jacobian_algorithm (alg:: MultipleShooting{S} , prob) where {S}
114
118
jac_alg = concrete_jacobian_algorithm (alg. jac_alg, prob, alg)
115
- return MultipleShooting (alg. ode_alg, alg. nlsolve, jac_alg, alg. nshoots,
119
+ return MultipleShooting {S} (alg. ode_alg, alg. nlsolve, jac_alg, alg. nshoots,
116
120
alg. grid_coarsening)
117
121
end
118
122
@@ -122,16 +126,18 @@ function update_nshoots(alg::MultipleShooting, nshoots::Int)
122
126
end
123
127
124
128
function MultipleShooting (nshoots:: Int , ode_alg; nlsolve = NewtonRaphson (),
125
- grid_coarsening = true , jac_alg = BVPJacobianAlgorithm ())
129
+ grid_coarsening = true , jac_alg = BVPJacobianAlgorithm (),
130
+ static_auto_nodes:: Val{S} = Val (false )) where {S}
126
131
@assert grid_coarsening isa Bool || grid_coarsening isa Function ||
127
132
grid_coarsening isa AbstractVector{<: Integer } ||
128
133
grid_coarsening isa NTuple{N, <: Integer } where {N}
134
+ @assert S isa Bool
129
135
grid_coarsening isa Tuple && (grid_coarsening = Vector (grid_coarsening... ))
130
136
if grid_coarsening isa AbstractVector
131
137
sort! (grid_coarsening; rev = true )
132
138
@assert all (grid_coarsening .> 0 ) && 1 ∉ grid_coarsening
133
139
end
134
- return MultipleShooting (ode_alg, nlsolve, jac_alg, nshoots, grid_coarsening)
140
+ return MultipleShooting {S} (ode_alg, nlsolve, jac_alg, nshoots, grid_coarsening)
135
141
end
136
142
137
143
for order in (2 , 3 , 4 , 5 , 6 )
0 commit comments