Skip to content

Commit b0ffbdc

Browse files
committed
Fix some dimension issues
1 parent b07b168 commit b0ffbdc

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/algorithms.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ function concretize_jacobian_algorithm(alg::Shooting, prob)
3939
return Shooting(alg.ode_alg, alg.nlsolve, BVPJacobianAlgorithm(diffmode))
4040
end
4141

42+
function Shooting(ode_alg, nlsolve; jac_alg = BVPJacobianAlgorithm())
43+
return Shooting(ode_alg, nlsolve, jac_alg)
44+
end
45+
4246
function Shooting(ode_alg; nlsolve = NewtonRaphson(), jac_alg = BVPJacobianAlgorithm())
4347
return Shooting(ode_alg, nlsolve, jac_alg)
4448
end

src/solve/multiple_shooting.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ function __multiple_shooting_init_jacobian_odecache(ensemblealg, prob, jac_cache
204204
end
205205

206206
function __multiple_shooting_init_jacobian_odecache(ensemblealg, prob, jac_cache,
207-
::Union{AutoForwardDiff, AutoSparseForwardDiff}, alg, nshoots, u;
208-
kwargs...)
207+
::Union{AutoForwardDiff, AutoSparseForwardDiff}, alg, nshoots, u; kwargs...)
209208
cache = jac_cache.cache
210209
if cache isa ForwardDiff.JacobianConfig
211210
xduals = reshape(cache.duals[2][1:length(u)], size(u))
@@ -390,9 +389,9 @@ end
390389
sol = solve!(odecache)
391390

392391
if SciMLBase.successful_retcode(sol)
393-
u_at_nodes[1:N] .= vec(sol.u[1])
394-
for i in 2:(nshoots + 1)
395-
u_at_nodes[(N + (i - 2) * N) .+ (1:N)] .= vec(sol.u[i])
392+
res = sol(nodes).u
393+
for i in 1:length(nodes)
394+
u_at_nodes[(i - 1) * N .+ (1:N)] .= vec(res[i])
396395
end
397396
else
398397
@warn "Initialization using odesolve failed. Initializing using 0s. It is \

src/solve/single_shooting.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function __solve(prob::BVProblem, alg_::Shooting; odesolve_kwargs = (;),
3838
end
3939

4040
ode_cache_jac_fn = __single_shooting_jacobian_ode_cache(internal_prob, jac_cache,
41-
alg.jac_alg.diffmode, vec(u0), alg.ode_alg; ode_kwargs...)
41+
alg.jac_alg.diffmode, u0, alg.ode_alg; ode_kwargs...)
4242

4343
jac_prototype = init_jacobian(jac_cache)
4444

@@ -131,6 +131,6 @@ function __single_shooting_jacobian_ode_cache(prob, jac_cache,
131131
xduals = cache.t
132132
end
133133
fill!(xduals, 0)
134-
prob_ = remake(prob; u0 = xduals)
134+
prob_ = remake(prob; u0 = reshape(xduals, size(u0)))
135135
return SciMLBase.__init(prob_, ode_alg; kwargs...)
136136
end

0 commit comments

Comments
 (0)