Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bifurcation kit extension #707

Merged
merged 35 commits into from
Dec 4, 2023
Merged

Bifurcation kit extension #707

merged 35 commits into from
Dec 4, 2023

Conversation

TorkelE
Copy link
Member

@TorkelE TorkelE commented Oct 28, 2023

Enables BifurcationKit BifurcationProblems to be created from ReactionSystems.

Example workflow:

using Catalyst
wilhelm_2009_model = @reaction_network begin
    k1, Y --> 2X
    k2, 2X --> X + Y
    k3, X + Y --> Y
    k4, X --> 0
    k5, 0 --> X
end

using BifurcationKit
bif_par = :k1
u_guess = [:X => 5.0, :Y => 2.0]
p_start = [:k1 => 4.0, :k2 => 1.0, :k3 => 1.0, :k4 => 1.5, :k5 => 1.25]
plot_var = :X
bprob = BifurcationProblem(wilhelm_2009_model, u_guess, p_start, bif_par; plot_var=plot_var)

p_span = (2.0, 20.0)
opts_br = ContinuationPar(p_min = p_span[1], p_max = p_span[2], max_steps=1000)

bif_dia = bifurcationdiagram(bprob, PALC(), 2, (args...) -> opts_br; bothside=true)

using Plots
plot(bif_dia; xguide="k1", yguide="X")

@TorkelE
Copy link
Member Author

TorkelE commented Nov 1, 2023

Functionality is there (just need to add an error check), needs tests and docs. Requires SciML/ModelingToolkit.jl#2337 to merge to handle cases with conservation laws

@TorkelE
Copy link
Member Author

TorkelE commented Nov 8, 2023

The required MTK PR have now been merged. However, I think we still would need to wait for a new release to take advantage of it.

@@ -1456,7 +1461,7 @@ function Base.convert(::Type{<:JumpSystem}, rs::ReactionSystem; name = nameof(rs
JumpSystem(eqs, get_iv(flatrs), sts, ps;
observed = MT.observed(flatrs),
name,
defaults = MT.defaults(flatrs),
defaults = _merge(defaults,MT.defaults(flatrs)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does merging after flattening give the correct namespacing of parameters and variables? This seems like it is going to cause problems. Merging probably needs to happen before flattening.

Copy link
Member Author

@TorkelE TorkelE Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not, that is a good point. I just used the current order of things, but if you suggest changing than that is be better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test to check this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean providing defaults to a convert for a system with sub-systems, which got defaults?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Member

@isaacsas isaacsas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check this works with coupled ODEs and add a corresponding test? (Do we want to allow coupled algebraic equations here too? If not, we probably need a check that any coupled equations are just ODEs.)

@TorkelE
Copy link
Member Author

TorkelE commented Nov 14, 2023

We cannot actually couple to ODEs: #727

I will couple to another ReactionSystem, should be enough.

@TorkelE TorkelE closed this Nov 14, 2023
@TorkelE TorkelE reopened this Nov 14, 2023
@TorkelE TorkelE closed this Nov 14, 2023
@TorkelE TorkelE reopened this Nov 14, 2023
@TorkelE TorkelE closed this Nov 14, 2023
@TorkelE TorkelE reopened this Nov 14, 2023
@TorkelE TorkelE closed this Nov 14, 2023
@TorkelE TorkelE reopened this Nov 14, 2023
@TorkelE
Copy link
Member Author

TorkelE commented Nov 14, 2023

This should be ready now. Unfortnatley the CI seems bugged out, keep giving stuff like:

[2048] signal (2): Interrupt
in expression starting at /home/runner/work/_temp/6799a5b3-ac8d-4e0e-a488-c620d88596be:24
epoll_wait at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
uv__io_poll at /workspace/srcdir/libuv/src/unix/epoll.c:236
uv_run at /workspace/srcdir/libuv/src/unix/core.c:400
ijl_task_get_next at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/partr.c:390
poptask at ./task.jl:974
wait at ./task.jl:983
task_done_hook at ./task.jl:672
jfptr_task_done_hook_27081.clone_1 at /opt/hostedtoolcache/julia/1.9.4/x64/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/julia.h:1880 [inlined]
jl_finish_task at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/task.c:320
start_task at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/task.c:1103
unknown function (ip: (nil))
Allocations: 10537356 (Pool: 10521420; Big: 15936); GC: 22
Error: The operation was canceled.

in various places, and I have no idea why.

@TorkelE TorkelE closed this Nov 14, 2023
@TorkelE TorkelE reopened this Nov 14, 2023
@TorkelE
Copy link
Member Author

TorkelE commented Nov 16, 2023

CI works on my computer, but keeps failing for reasons here. I the PR is done. I think if I rebase on the right stuff it should be good, just tell me when we can merge this one and I will rebase and it should hopefully work.
(I just want to avoid having to rebase this one 8 times over the next week or 2, each time potentially doing some git wrong)

Copy link
Member

@isaacsas isaacsas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this working with composed systems too. I think it should just require manually flattening in the BifurcationProblem before you start making checks and calculating conservation laws.

Project.toml Show resolved Hide resolved
docs/src/catalyst_applications/bifurcation_diagrams.md Outdated Show resolved Hide resolved
docs/src/catalyst_applications/bifurcation_diagrams.md Outdated Show resolved Hide resolved
docs/src/catalyst_applications/bifurcation_diagrams.md Outdated Show resolved Hide resolved
docs/src/catalyst_applications/bifurcation_diagrams.md Outdated Show resolved Hide resolved
docs/src/catalyst_applications/bifurcation_diagrams.md Outdated Show resolved Hide resolved
docs/src/catalyst_applications/bifurcation_diagrams.md Outdated Show resolved Hide resolved
docs/src/catalyst_applications/bifurcation_diagrams.md Outdated Show resolved Hide resolved
src/miscellaneous.jl Outdated Show resolved Hide resolved
test/runtests.jl Outdated Show resolved Hide resolved
@isaacsas
Copy link
Member

isaacsas commented Dec 3, 2023

@TorkelE what is the status on this? I see doc build failures currently?

@TorkelE
Copy link
Member Author

TorkelE commented Dec 3, 2023

this is ready, think the doc failure has appeared recently though. I will rebase on master and if docs still fail fixing it should be relatively straightforward.

TorkelE and others added 18 commits December 3, 2023 17:34
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
TorkelE and others added 5 commits December 3, 2023 17:45
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
@TorkelE TorkelE merged commit 847077b into master Dec 4, 2023
6 of 9 checks passed
@TorkelE TorkelE deleted the BifurcationKitExtension branch June 8, 2024 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants