From b049203069c4b8835268fd68cea327184f957250 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Tue, 30 Jul 2024 15:16:37 -0400 Subject: [PATCH 1/5] use full_equations so ovservables work --- ext/MTKBifurcationKitExt.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/MTKBifurcationKitExt.jl b/ext/MTKBifurcationKitExt.jl index b709b2eec0..ca161d8c04 100644 --- a/ext/MTKBifurcationKitExt.jl +++ b/ext/MTKBifurcationKitExt.jl @@ -144,7 +144,7 @@ function BifurcationKit.BifurcationProblem(osys::ODESystem, args...; kwargs...) if !ModelingToolkit.iscomplete(osys) error("A completed `ODESystem` is required. Call `complete` or `structural_simplify` on the system before creating a `BifurcationProblem`") end - nsys = NonlinearSystem([0 ~ eq.rhs for eq in equations(osys)], + nsys = NonlinearSystem([0 ~ eq.rhs for eq in full_equations(osys)], unknowns(osys), parameters(osys); name = nameof(osys)) From 06de5949c7eec64524e4cd1558de83389d6202fe Mon Sep 17 00:00:00 2001 From: jClugstor Date: Thu, 1 Aug 2024 13:15:48 -0400 Subject: [PATCH 2/5] add observed to NonlinearSystem --- ext/MTKBifurcationKitExt.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/MTKBifurcationKitExt.jl b/ext/MTKBifurcationKitExt.jl index ca161d8c04..6bc536958f 100644 --- a/ext/MTKBifurcationKitExt.jl +++ b/ext/MTKBifurcationKitExt.jl @@ -147,6 +147,7 @@ function BifurcationKit.BifurcationProblem(osys::ODESystem, args...; kwargs...) nsys = NonlinearSystem([0 ~ eq.rhs for eq in full_equations(osys)], unknowns(osys), parameters(osys); + observed = observed(osys), name = nameof(osys)) return BifurcationKit.BifurcationProblem(complete(nsys), args...; kwargs...) end From 85618710133284bd5205d47bf8420881e33b5d45 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Tue, 6 Aug 2024 16:21:06 -0400 Subject: [PATCH 3/5] add test --- test/extensions/bifurcationkit.jl | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/extensions/bifurcationkit.jl b/test/extensions/bifurcationkit.jl index 861d8f45f9..9581a9b17e 100644 --- a/test/extensions/bifurcationkit.jl +++ b/test/extensions/bifurcationkit.jl @@ -133,3 +133,35 @@ let @test length(fold_points) == 2 @test fold_points ≈ [-1.1851851706940317, -5.6734983580551894e-6] # test that they occur at the correct parameter values). end + +let + + @mtkmodel FOL begin + @parameters begin + τ # parameters + end + @variables begin + x(t) # dependent variables + RHS(t) + end + @equations begin + RHS ~ τ + x^2 - 0.1 + D(x) ~ RHS + end + end + + @mtkbuild fol = FOL() + + par = [fol.τ => 0.0] + u0 = [fol.x => -1.0] + #prob = ODEProblem(fol, u0, (0.0, 1.), par) + + bif_par = fol.τ + bp = BifurcationProblem(fol, u0, par, bif_par) + opts_br = ContinuationPar(p_min = -1.0, + p_max = 1.0) + bf = bifurcationdiagram(bp, PALC(), 2, opts_br).γ.specialpoint[1] ≈ 0.1 + + @test bf.γ.specialpoint[1].param≈0.1 atol=1e-4 rtol=1e-4 + +end \ No newline at end of file From 088185eac22ded899360f5f0b0c73517d792c10d Mon Sep 17 00:00:00 2001 From: jClugstor Date: Tue, 13 Aug 2024 12:02:00 -0400 Subject: [PATCH 4/5] fix test --- test/extensions/bifurcationkit.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/extensions/bifurcationkit.jl b/test/extensions/bifurcationkit.jl index 9581a9b17e..efba8e68fc 100644 --- a/test/extensions/bifurcationkit.jl +++ b/test/extensions/bifurcationkit.jl @@ -160,7 +160,7 @@ let bp = BifurcationProblem(fol, u0, par, bif_par) opts_br = ContinuationPar(p_min = -1.0, p_max = 1.0) - bf = bifurcationdiagram(bp, PALC(), 2, opts_br).γ.specialpoint[1] ≈ 0.1 + bf = bifurcationdiagram(bp, PALC(), 2, opts_br) @test bf.γ.specialpoint[1].param≈0.1 atol=1e-4 rtol=1e-4 From d4899bc206bdd1544c567d259215e1c278afba12 Mon Sep 17 00:00:00 2001 From: jClugstor Date: Tue, 13 Aug 2024 12:06:23 -0400 Subject: [PATCH 5/5] format --- test/extensions/bifurcationkit.jl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/extensions/bifurcationkit.jl b/test/extensions/bifurcationkit.jl index efba8e68fc..698dd085c8 100644 --- a/test/extensions/bifurcationkit.jl +++ b/test/extensions/bifurcationkit.jl @@ -134,8 +134,7 @@ let @test fold_points ≈ [-1.1851851706940317, -5.6734983580551894e-6] # test that they occur at the correct parameter values). end -let - +let @mtkmodel FOL begin @parameters begin τ # parameters @@ -163,5 +162,4 @@ let bf = bifurcationdiagram(bp, PALC(), 2, opts_br) @test bf.γ.specialpoint[1].param≈0.1 atol=1e-4 rtol=1e-4 - -end \ No newline at end of file +end