An acausal modeling framework for automatically parallelized scientific machine learning (SciML) in Julia. A computer algebra system for integrated symbolics for physics-informed machine learning and automated transformations of differential equations
I am trying to introduce a time-varying parameter following an SDE into an SDESystem obtained from Catalyst.jl ReactionSystem.
However, when I want to create an SDEProblem from the composed SDESystem, I get some error about mismatching dimensions.
I created an MWE using a simple SIR-Model.
First, doing it in terms of ODEs works fine.
using DifferentialEquations
using ModelingToolkit
using Catalyst
using Plots
using StatsPlots
import ModelingToolkit: t_nounits as t, D_nounits as D
@variables begin
β(t) = 0.01
end
@parameters begin
γ = 0.1
end
@species begin
S(t) = 100
I(t) = 1
R(t) = 0
end
rxs = [Reaction(β, [S,I], [I], [1,1],[2]),
Reaction(γ, [I], [R])]
@named sir_simple = ReactionSystem(rxs, t)
sir_simple=complete(sir_simple)
sir_simple_ode = convert(ODESystem, sir_simple)
@parameters begin
betak = 1.0
betamu = 0.01
betaeps = 0.5
end
connect_ode_sys = compose(
ODESystem([D(sir_simple_ode.β) ~ betak * (betamu - sir_simple_ode.β)],
t,
name = :connect_ode_sys),
sir_simple_ode)
connect_ode_prob = ODEProblem(complete(connect_ode_sys), [], (0.0, 10.0), [])
ode_sol = solve(connect_ode_prob, Tsit5())
plot(ode_sol,
idxs=[sir_simple_ode.S sir_simple_ode.I sir_simple_ode.R],)
with expected output plot
However, doing the same in terms of SDESystem produces the following error.
Unfortunately, from the error messages I could not really deduce the problem.
Would appreciate any help and tips, whether this is the correct way to compose such two SDESystems to have a parameter folowing an SDE.
I am aware of the workaround in #2085, but my original system is a rather large reaction network consisting of a composition of several network_components built in Catalyst. So I do not want to write down all the equations by hand and adding diffusion terms and Brownian Motions to it by hand.
PS: Also structural_simplify does not work on the composed system and would produce the following
I am trying to introduce a time-varying parameter following an SDE into an
SDESystem
obtained from Catalyst.jlReactionSystem
. However, when I want to create anSDEProblem
from the composedSDESystem
, I get some error about mismatching dimensions.I created an MWE using a simple SIR-Model.
First, doing it in terms of ODEs works fine.
with expected output plot
However, doing the same in terms of
SDESystem
produces the following error.Unfortunately, from the error messages I could not really deduce the problem.
Would appreciate any help and tips, whether this is the correct way to compose such two
SDESystems
to have a parameter folowing an SDE.I am aware of the workaround in #2085, but my original system is a rather large reaction network consisting of a composition of several
network_components
built in Catalyst. So I do not want to write down all the equations by hand and adding diffusion terms and Brownian Motions to it by hand.PS: Also
structural_simplify
does not work on the composed system and would produce the followingEnvironment:
I used the following package versions and julia 1.10.4