Skip to content

Support Jump-ODE models #1121

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

Merged
merged 34 commits into from
Apr 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
db07253
start on supporting hybrid jump systems
isaacsas Nov 11, 2024
ea18019
only build docs in pages.jl
isaacsas Nov 13, 2024
e33aa23
revert
isaacsas Nov 13, 2024
98797d2
Merge remote-tracking branch 'origin/master' into pdmps
isaacsas Nov 15, 2024
1f29769
fix project file
isaacsas Nov 15, 2024
27c8856
reshuffle
isaacsas Nov 15, 2024
5924139
refactor
isaacsas Nov 15, 2024
8d09594
typo
isaacsas Nov 15, 2024
98cc3ed
tweak project
isaacsas Nov 15, 2024
1e743a3
construct pdmps
isaacsas Nov 15, 2024
784f754
start on tests
isaacsas Nov 16, 2024
518e54f
more tests
isaacsas Nov 16, 2024
4d1f572
Merge branch 'master' into pdmps
isaacsas Jan 17, 2025
b3b471c
drop some older deps
isaacsas Jan 17, 2025
93220f3
update tests
isaacsas Jan 17, 2025
3507344
update dep vers
isaacsas Jan 17, 2025
7505201
update test
isaacsas Jan 17, 2025
b89c3db
test fix
isaacsas Jan 17, 2025
d758f63
update tests
isaacsas Jan 21, 2025
06cf8b8
update tests
isaacsas Jan 21, 2025
3b8597d
add back older extension versions due to Bifkit restrictions
isaacsas Jan 21, 2025
98decab
add dsl tests
isaacsas Jan 21, 2025
0d8dda1
updates
isaacsas Apr 15, 2025
f466eb9
merge master
isaacsas Apr 15, 2025
7ff2e91
test fixes
isaacsas Apr 15, 2025
ec07930
test fix
isaacsas Apr 15, 2025
1fee862
ensure full set of ODEs
isaacsas Apr 15, 2025
1a5f21d
add 4 test blocks
TorkelE Apr 17, 2025
dc25f1a
add deprecation warnings
isaacsas Apr 17, 2025
800e2e8
fixes
isaacsas Apr 17, 2025
2b87e41
add correctness test
isaacsas Apr 18, 2025
cc626b8
add hybrid tests
isaacsas Apr 18, 2025
2c3371c
add group
isaacsas Apr 18, 2025
4deb44b
text fix
isaacsas Apr 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
- "pre"
group:
- Core
- Hybrid
- IO
- Spatial
- Extensions
Expand Down
7 changes: 4 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
DynamicPolynomials = "7c1d4256-1411-5781-91ec-d7bc3513ac07"
DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821"
EnumX = "4e289a0a-7415-4d19-859d-a7e5c4648b56"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
JumpProcesses = "ccbc3e58-028d-4f4c-8cd5-9ae44345cda5"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Expand Down Expand Up @@ -51,8 +52,8 @@ Combinatorics = "1.0.2"
DataStructures = "0.18"
DiffEqBase = "6.165.0"
DocStringExtensions = "0.8, 0.9"
DynamicPolynomials = "0.5, 0.6"
DynamicQuantities = "0.13.2, 1"
DynamicPolynomials = "0.6"
DynamicQuantities = "1"
GraphMakie = "0.5"
Graphs = "1.4"
HomotopyContinuation = "2.9"
Expand All @@ -64,7 +65,7 @@ Makie = "0.22.1"
ModelingToolkit = "9.69"
NetworkLayout = "0.4.7"
Parameters = "0.12"
Reexport = "0.2, 1.0"
Reexport = "1.0"
Requires = "1.0"
RuntimeGeneratedFunctions = "0.5.12"
SciMLBase = "2.77"
Expand Down
9 changes: 6 additions & 3 deletions src/Catalyst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $(DocStringExtensions.README)
module Catalyst

using DocStringExtensions
using SparseArrays, DiffEqBase, Reexport, Setfield
using SparseArrays, DiffEqBase, Reexport, Setfield, EnumX
using LaTeXStrings, Latexify, Requires
using LinearAlgebra, Combinatorics
using JumpProcesses: JumpProcesses, JumpProblem,
Expand All @@ -14,7 +14,7 @@ using JumpProcesses: JumpProcesses, JumpProblem,
# ModelingToolkit imports and convenience functions we use
using ModelingToolkit
const MT = ModelingToolkit
using DynamicQuantities#, Unitful # Having Unitful here as well currently gives an error.
using DynamicQuantities #, Unitful # Having Unitful here as well currently gives an error.

@reexport using ModelingToolkit
using Symbolics
Expand Down Expand Up @@ -78,7 +78,10 @@ const forbidden_symbols_error = union(Set([:im, :nothing, CONSERVED_CONSTANT_SYM
# The `Reaction` structure and its functions.
include("reaction.jl")
export isspecies
export Reaction
export Reaction, PhysicalScale

# Union type for `Reaction`s and `Equation`s.
const CatalystEqType = Union{Reaction, Equation}

# The `ReactionSystem` structure and its functions.
include("reactionsystem.jl")
Expand Down
45 changes: 42 additions & 3 deletions src/reaction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,6 @@ function Reaction(rate, subs, prods; kwargs...)
Reaction(rate, subs, prods, sstoich, pstoich; kwargs...)
end

# Union type for `Reaction`s and `Equation`s.
const CatalystEqType = Union{Reaction, Equation}

### Base Function Dispatches ###

# Used by `Base.show`.
Expand Down Expand Up @@ -679,6 +676,48 @@ function getmisc(reaction::Reaction)
end
end

############## Metadata for the mathematical type of a reaction ##############

"""
@enumx PhysicalScale

EnumX instance representing the physical scale of a reaction.

Notes: The following values are possible:
- `Auto`: (DEFAULT) Lets Catalyst decide at the time of system conversion and/or
problem generation at what physical scale to represent the reaction.
- `ODE`: The reaction is to be treated via an ordinary differential equation term.
- `SDE`: The reaction is to be treated via a stochastic differential equation (CLE) term.
- `Jump`: The reaction is to be treated via a jump process (stochastic chemical kinetics)
term, letting Catalyst decide the specific jump type.
- `VariableRateJump`: The reaction is to be treated as a jump process (stochastic chemical
kinetics) term, specifically assigning it to a VariableRateJump.
"""
@enumx PhysicalScale begin
Auto # the default that lets Catalyst decide
ODE
SDE
Jump # lets Catalyst decide the jump type
VariableRateJump # forces a VariableRateJump
end

const JUMP_SCALES = (PhysicalScale.Jump, PhysicalScale.VariableRateJump)
const NON_CONSTANT_JUMP_SCALES = (PhysicalScale.ODE, PhysicalScale.SDE, PhysicalScale.VariableRateJump)

"""
has_physical_scale(rx::Reaction)

Returns `true` if the input reaction has the `physical_scale` metadata field assigned,
else `false`.
"""
function has_physical_scale(rx::Reaction)
return hasmetadata(rx, :physical_scale)
end

function get_physical_scale(rx::Reaction)
return has_physical_scale(rx) ? getmetadata(rx, :physical_scale) : PhysicalScale.Auto
end

### Units Handling ###

"""
Expand Down
10 changes: 10 additions & 0 deletions src/reactionsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,16 @@ function numreactions(network)
nr
end

"""
has_nonreactions(network)

Check if the given `network` has any non-reaction equations such as ODEs or algebraic
equations.
"""
function has_nonreactions(network)
numreactions(network) != length(equations(network))
end

"""
nonreactions(network)

Expand Down
Loading
Loading