diff --git a/Project.toml b/Project.toml index fc9095419a..bc74baeb23 100644 --- a/Project.toml +++ b/Project.toml @@ -62,7 +62,7 @@ LaTeXStrings = "1.3.0" Latexify = "0.16.6" MacroTools = "0.5.5" Makie = "0.22.1" -ModelingToolkit = "9.73" +ModelingToolkit = "10" NetworkLayout = "0.4.7" Parameters = "0.12" Reexport = "1.0" diff --git a/src/latexify_recipes.jl b/src/latexify_recipes.jl index 4759f76937..ed480b44f2 100644 --- a/src/latexify_recipes.jl +++ b/src/latexify_recipes.jl @@ -19,7 +19,7 @@ const LATEX_DEFS = CatalystLatexParams() return rs elseif form == :ode # Returns ODE system code. mult_symbol --> "" - return convert(ODESystem, rs) + return convert(System, rs) elseif form == :sde # Returns SDE system code. mult_symbol --> "" return convert(SDESystem, rs) diff --git a/src/reactionsystem.jl b/src/reactionsystem.jl index e35f308b4f..04eb6ae337 100644 --- a/src/reactionsystem.jl +++ b/src/reactionsystem.jl @@ -258,7 +258,7 @@ Continuing from the example in the [`Reaction`](@ref) definition: Keyword Arguments: - `observed::Vector{Equation}`, equations specifying observed variables. - `systems::Vector{AbstractSystems}`, vector of sub-systems. Can be `ReactionSystem`s, - `ODESystem`s, or `NonlinearSystem`s. + `System`s, or `NonlinearSystem`s. - `name::Symbol`, the name of the system (must be provided, or `@named` must be used). - `defaults::Dict`, a dictionary mapping parameters to their default values and species to their default initial values. @@ -545,7 +545,7 @@ function make_ReactionSystem_internal(rxs_and_eqs::Vector, iv, us_in, ps_in; # Extracts any species, variables, and parameters that occur in (non-reaction) equations. # Creates the new reactions + equations vector, `fulleqs` (sorted reactions first, equations next). if !isempty(eqs) - osys = ODESystem(eqs, iv; name = gensym()) + osys = System(eqs, iv; name = gensym()) fulleqs = CatalystEqType[rxs; equations(osys)] union!(us, unknowns(osys)) union!(ps, parameters(osys)) @@ -1399,7 +1399,7 @@ Notes: - All `Reaction`s within subsystems are namespaced and merged into the list of `Reactions` of `rs`. The merged list is then available as `reactions(rs)`. - All algebraic and differential equations are merged in the equations of `rs`. -- Currently only `ReactionSystem`s, `NonlinearSystem`s and `ODESystem`s are supported as +- Currently only `ReactionSystem`s, `NonlinearSystem`s and `System`s are supported as sub-systems when flattening. - `rs.networkproperties` is reset upon flattening. - The default value of `combinatoric_ratelaws` will be the logical or of all @@ -1408,11 +1408,11 @@ Notes: function MT.flatten(rs::ReactionSystem; name = nameof(rs)) isempty(get_systems(rs)) && return rs - # right now only NonlinearSystems and ODESystems can be handled as subsystems + # right now only NonlinearSystems and Systems can be handled as subsystems subsys_types = getsubsystypes(rs) - allowed_types = (ReactionSystem, NonlinearSystem, ODESystem) + allowed_types = (ReactionSystem, NonlinearSystem, System) all(T -> any(T .<: allowed_types), subsys_types) || - error("flattening is currently only supported for subsystems mixing ReactionSystems, NonlinearSystems and ODESystems.") + error("flattening is currently only supported for subsystems mixing ReactionSystems, NonlinearSystems and Systems.") ReactionSystem(equations(rs), get_iv(rs), unknowns(rs), parameters(rs); observed = MT.observed(rs), @@ -1440,7 +1440,7 @@ end Compose the indicated [`ReactionSystem`](@ref) with one or more `AbstractSystem`s. Notes: -- The `AbstractSystem` being added in must be an `ODESystem`, `NonlinearSystem`, +- The `AbstractSystem` being added in must be an `System`, `NonlinearSystem`, or `ReactionSystem` currently. - Returns a new `ReactionSystem` and does not modify `rs`. - By default, the new `ReactionSystem` will have the same name as `sys`. @@ -1479,7 +1479,7 @@ end Extends the indicated [`ReactionSystem`](@ref) with another `AbstractSystem`. Notes: -- The `AbstractSystem` being added in must be an `ODESystem`, `NonlinearSystem`, +- The `AbstractSystem` being added in must be an `System`, `NonlinearSystem`, or `ReactionSystem` currently. - Returns a new `ReactionSystem` and does not modify `rs`. - By default, the new `ReactionSystem` will have the same name as `sys`. @@ -1490,8 +1490,8 @@ function ModelingToolkit.extend(sys::MT.AbstractSystem, rs::ReactionSystem; complete_check(sys, "ModelingToolkit.extend") complete_check(rs, "ModelingToolkit.extend") - any(T -> sys isa T, (ReactionSystem, ODESystem, NonlinearSystem)) || - error("ReactionSystems can only be extended with ReactionSystems, ODESystems and NonlinearSystems currently. Received a $(typeof(sys)) system.") + any(T -> sys isa T, (ReactionSystem, System, NonlinearSystem)) || + error("ReactionSystems can only be extended with ReactionSystems, Systems and NonlinearSystems currently. Received a $(typeof(sys)) system.") t = get_iv(rs) if MT.has_iv(sys) diff --git a/src/reactionsystem_conversions.jl b/src/reactionsystem_conversions.jl index d4a69bd7f1..d366d153c6 100644 --- a/src/reactionsystem_conversions.jl +++ b/src/reactionsystem_conversions.jl @@ -466,7 +466,7 @@ function addconstraints!(eqs, rs::ReactionSystem, ists, ispcs; remove_conserved conservation laws. Catalyst does not check that the conserved equations still hold for the final coupled system of equations. Consider using `remove_conserved = false` and instead calling - ModelingToolkit.structural_simplify to simplify any generated ODESystem or + ModelingToolkit.structural_simplify to simplify any generated System or NonlinearSystem. """ end @@ -509,9 +509,9 @@ COMPLETENESS_ERROR = "A ReactionSystem must be complete before it can be convert """ ```julia -Base.convert(::Type{<:ODESystem},rs::ReactionSystem) +Base.convert(::Type{<:System},rs::ReactionSystem) ``` -Convert a [`ReactionSystem`](@ref) to an `ModelingToolkit.ODESystem`. +Convert a [`ReactionSystem`](@ref) to an `ModelingToolkit.System`. Keyword args and default values: - `combinatoric_ratelaws=true` uses factorial scaling factors in calculating the rate law, @@ -526,7 +526,7 @@ Keyword args and default values: with their rational function representation when converting to another system type. Set to `false`` to disable. """ -function Base.convert(::Type{<:ODESystem}, rs::ReactionSystem; name = nameof(rs), +function Base.convert(::Type{<:System}, rs::ReactionSystem; name = nameof(rs), combinatoric_ratelaws = get_combinatoric_ratelaws(rs), include_zero_odes = true, remove_conserved = false, checks = false, default_u0 = Dict(), default_p = Dict(), @@ -534,7 +534,7 @@ function Base.convert(::Type{<:ODESystem}, rs::ReactionSystem; name = nameof(rs) kwargs...) # Error checks. iscomplete(rs) || error(COMPLETENESS_ERROR) - spatial_convert_err(rs::ReactionSystem, ODESystem) + spatial_convert_err(rs::ReactionSystem, System) fullrs = Catalyst.flatten(rs) remove_conserved && conservationlaws(fullrs) @@ -543,7 +543,7 @@ function Base.convert(::Type{<:ODESystem}, rs::ReactionSystem; name = nameof(rs) include_zero_odes, expand_catalyst_funs) eqs, us, ps, obs, defs = addconstraints!(eqs, fullrs, ists, ispcs; remove_conserved) - ODESystem(eqs, get_iv(fullrs), us, ps; + System(eqs, get_iv(fullrs), us, ps; observed = obs, name, defaults = _merge(defaults, defs), @@ -828,7 +828,7 @@ function DiffEqBase.ODEProblem(rs::ReactionSystem, u0, tspan, combinatoric_ratelaws = get_combinatoric_ratelaws(rs), include_zero_odes = true, remove_conserved = false, checks = false, expand_catalyst_funs = true, structural_simplify = false, kwargs...) - osys = convert(ODESystem, rs; name, combinatoric_ratelaws, include_zero_odes, checks, + osys = convert(System, rs; name, combinatoric_ratelaws, include_zero_odes, checks, remove_conserved, expand_catalyst_funs) # Handles potential differential algebraic equations (which requires `structural_simplify`). @@ -1058,7 +1058,7 @@ function DiffEqBase.SteadyStateProblem(rs::ReactionSystem, u0, combinatoric_ratelaws = get_combinatoric_ratelaws(rs), remove_conserved = false, include_zero_odes = true, checks = false, expand_catalyst_funs = true, structural_simplify = false, kwargs...) - osys = convert(ODESystem, rs; name, combinatoric_ratelaws, include_zero_odes, checks, + osys = convert(System, rs; name, combinatoric_ratelaws, include_zero_odes, checks, remove_conserved, expand_catalyst_funs) # Handles potential differential algebraic equations (which requires `structural_simplify`). diff --git a/src/reactionsystem_serialisation/serialise_reactionsystem.jl b/src/reactionsystem_serialisation/serialise_reactionsystem.jl index 8d9ab5dffe..8b4933d694 100644 --- a/src/reactionsystem_serialisation/serialise_reactionsystem.jl +++ b/src/reactionsystem_serialisation/serialise_reactionsystem.jl @@ -28,7 +28,7 @@ rn = include("rn.jls") Notes: - `ReactionSystem`s with the `connection_type` field has this ignored (saving of this field has not been implemented yet). -- `ReactionSystem`s with non-`ReactionSystem` sub-systems (e.g. `ODESystem`s) cannot be saved. +- `ReactionSystem`s with non-`ReactionSystem` sub-systems (e.g. `System`s) cannot be saved. - Reaction systems with components that have units cannot currently be saved. - The `ReactionSystem` is saved using *programmatic* (not DSL) format for model creation. """ diff --git a/src/spatial_reaction_systems/lattice_sim_struct_interfacing.jl b/src/spatial_reaction_systems/lattice_sim_struct_interfacing.jl index 4d176bae59..e80700790c 100644 --- a/src/spatial_reaction_systems/lattice_sim_struct_interfacing.jl +++ b/src/spatial_reaction_systems/lattice_sim_struct_interfacing.jl @@ -455,7 +455,7 @@ function rebuild_lat_internals!(lt_ofun::LatticeTransportODEFunction, ps_new, # Updating the `MTKParameters` structure is a bit more complicated. p_dict = Dict(ps_new) - osys = complete(convert(ODESystem, reactionsystem(lrs))) + osys = complete(convert(System, reactionsystem(lrs))) for p in parameters(osys) MT.setp(osys, p)(lt_ofun.mtk_ps, (p_dict[p] isa Number) ? p_dict[p] : p_dict[p][1]) end diff --git a/src/spatial_reaction_systems/spatial_ODE_systems.jl b/src/spatial_reaction_systems/spatial_ODE_systems.jl index 2e3a6d46f2..228a69a86f 100644 --- a/src/spatial_reaction_systems/spatial_ODE_systems.jl +++ b/src/spatial_reaction_systems/spatial_ODE_systems.jl @@ -95,7 +95,7 @@ end # the vertex parameter values during the simulations). function make_mtk_ps_structs(ps, lrs, heterogeneous_vert_p_idxs) p_dict = Dict(ps) - nonspatial_osys = complete(convert(ODESystem, reactionsystem(lrs))) + nonspatial_osys = complete(convert(System, reactionsystem(lrs))) p_init = [p => p_dict[p][1] for p in parameters(nonspatial_osys)] mtk_ps = MT.MTKParameters(nonspatial_osys, p_init) p_setters = [MT.setp(nonspatial_osys, p) @@ -220,7 +220,7 @@ function build_odefunction(lrs::LatticeReactionSystem, vert_ps::Vector{Pair{R, V end # Prepares the inputs to the `LatticeTransportODEFunction` functor. - osys = complete(convert(ODESystem, reactionsystem(lrs); + osys = complete(convert(System, reactionsystem(lrs); name, combinatoric_ratelaws, include_zero_odes, checks)) ofunc_dense = ODEFunction(osys; jac = true, sparse = false) ofunc_sparse = ODEFunction(osys; jac = true, sparse = true)