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

Support ODEs as equations in JumpSystem #3181

Merged
merged 22 commits into from
Nov 12, 2024

Conversation

isaacsas
Copy link
Member

@isaacsas isaacsas commented Nov 4, 2024

Note this assumes a user has properly classified their jumps (i.e. they haven't made something a constant rate jump that has a condition that depends on a variable rate jump variable and/or an ODE modified variable).

Comment on lines 493 to 500
osys = ODESystem(equations(sys).x[4], get_iv(sys), unknowns(sys), parameters(sys);
observed = observed(sys), name = nameof(sys), description = description(sys),
systems = get_systems(sys), defaults = defaults(sys),
discrete_events = discrete_events(sys),
parameter_dependencies = parameter_dependencies(sys),
metadata = get_metadata(sys), gui_metadata = get_gui_metadata(sys))
osys = complete(osys)
return ODEProblem(osys, u0map, tspan, parammap; check_length, kwargs...)
Copy link
Member Author

Choose a reason for hiding this comment

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

This seemed like the best way to handle generating the underlying ODEProblem, but happy to consider alternative approaches if anyone has feedback.

@isaacsas
Copy link
Member Author

isaacsas commented Nov 4, 2024

@ChrisRackauckas where should callbacks be handled here, the ODEProblem or the JumpProblem? (And actually, I'm not even sure in the lower-level interface what is supposed to be done within JumpProcesses -- are passing some callbacks to both problems and/or just the wrapped ODEProblem allowed and supposed to work?)

@isaacsas
Copy link
Member Author

isaacsas commented Nov 5, 2024

For now I've made it that continuous events are passed to the generated ODEProblem but discrete events go via the JumpProblem. This will need some tests to check that works consistently.

test/jumpsystem.jl Outdated Show resolved Hide resolved
@isaacsas isaacsas changed the title [WIP] - Support ODEs as equations in JumpSystem Support ODEs as equations in JumpSystem Nov 11, 2024
@isaacsas
Copy link
Member Author

@ChrisRackauckas assuming tests pass I think this is gtg.

test/jumpsystem.jl Outdated Show resolved Hide resolved
@isaacsas
Copy link
Member Author

@ChrisRackauckas I think the doc/extension/Catalyst failures here are all unrelated (they seem to be BifurcationKit related).

@ChrisRackauckas
Copy link
Member

Yeah they are, I assume @rveltz knows?

@ChrisRackauckas ChrisRackauckas merged commit 9cf859f into SciML:master Nov 12, 2024
30 of 39 checks passed
@rveltz
Copy link
Contributor

rveltz commented Nov 12, 2024

can you link me to the issue please?

@ChrisRackauckas
Copy link
Member

  Failed to precompile BifurcationKit [0f109fa4-8a5d-4b75-95aa-f515264e7665] to "/home/runner/.julia/compiled/v1.11/BifurcationKit/jl_n8vjZY".
  ERROR: LoadError: ArgumentError: invalid type for argument A in method definition for rmul! at /home/runner/.julia/packages/BifurcationKit/KwA2l/src/BorderedArrays.jl:69
  Stacktrace:
   [1] top-level scope
     @ ~/.julia/packages/BifurcationKit/KwA2l/src/BorderedArrays.jl:69
   [2] include(mod::Module, _path::String)
     @ Base ./Base.jl:557
   [3] include(x::String)
     @ BifurcationKit ~/.julia/packages/BifurcationKit/KwA2l/src/BifurcationKit.jl:1
   [4] top-level scope
     @ ~/.julia/packages/BifurcationKit/KwA2l/src/BifurcationKit.jl:24
   [5] include
     @ ./Base.jl:557 [inlined]
   [6] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
     @ Base ./loading.jl:2790
   [7] top-level scope
     @ stdin:5
  in expression starting at /home/runner/.julia/packages/BifurcationKit/KwA2l/src/BorderedArrays.jl:69
  in expression starting at /home/runner/.julia/packages/BifurcationKit/KwA2l/src/BifurcationKit.jl:1
  in expression starting at stdin:
  in expression starting at /home/runner/work/ModelingToolkit.jl/ModelingToolkit.jl/test/extensions/bifurcationkit.jl:1
Test Summary:                 | Error  Total  Time
BifurcationKit Extension Test |     1      1  4.4s

@ChrisRackauckas
Copy link
Member

I assume that will show in your CI tests as of about 2 days ago?

@rveltz
Copy link
Contributor

rveltz commented Nov 12, 2024

Yes that's a mistake from KrylovKit. I notified them

@isaacsas isaacsas deleted the add_odes_to_jumpsys branch November 13, 2024 12:41
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.

4 participants