Skip to content

Commit 0151988

Browse files
fix: fix MTKBifurcationKitExt (hack)
1 parent 4a49486 commit 0151988

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

ext/MTKBifurcationKitExt.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct ObservableRecordFromSolution{S, T}
2727
plot_var,
2828
bif_idx,
2929
u0_vals,
30-
p_vals) where {S, T}
30+
p_vals)
3131
obs_eqs = observed(nsys)
3232
target_obs_idx = findfirst(isequal(plot_var, eq.lhs) for eq in observed(nsys))
3333
state_end_idxs = length(unknowns(nsys))
@@ -91,10 +91,18 @@ function BifurcationKit.BifurcationProblem(nsys::NonlinearSystem,
9191
if !ModelingToolkit.iscomplete(nsys)
9292
error("A completed `NonlinearSystem` is required. Call `complete` or `structural_simplify` on the system before creating a `BifurcationProblem`")
9393
end
94+
# ModelingToolkit.@set! nsys.index_cache = nothing
9495
# Creates F and J functions.
9596
ofun = NonlinearFunction(nsys; jac = jac)
96-
F = ofun.f
97-
J = jac ? ofun.jac : nothing
97+
F(u, p) = ofun.f(u, ModelingToolkit.MTKParameters(nsys, parameters(nsys) .=> p))
98+
F(u, p::ModelingToolkit.MTKParameters) = ofun.f(u, p)
99+
J = if jac
100+
_jac(u, p) = ofun.jac(u, ModelingToolkit.MTKParameters(nsys, parameters(nsys) .=> p))
101+
_jac(u, p::ModelingToolkit.MTKParameters) = ofun.jac(u, p)
102+
_jac
103+
else
104+
nothing
105+
end
98106

99107
# Converts the input state guess.
100108
u0_bif_vals = ModelingToolkit.varmap_to_vars(u0_bif,

0 commit comments

Comments
 (0)