Catalyst.jl
Catalyst.jl copied to clipboard
Allowing units via the DSL
Now that ModelingToolkit and ReactionSystem
s support units, do we want to expand @reaction_network
to allow users to input units for species and parameters too?
Would it be possible, at least for standard cases, to autogenerate units for parameters? Even in the Gillespie case, the units should just be copy numbers for each species, right? It seems it would be possible to allow quite a lot to happen automatically (but an option to specify would also be good).
We’d at least need a base unit specified for time and amount of a species. But the usefulness of units currently is we can check combinations of parameters don’t give an inconsistent rate law. The units are ultimately dropped when simulating ODEs or jumps. So for now they are just a potentially useful check on model correctness. If one isn’t going to give them manually I’m not sure what would be gained by us attaching default units internally.
Given the @parameters
option, one can do:
using Catalyst
rn = @reaction_network begin
@parameters Y [isconstantspecies=true]
k, X + Y --> 0
end
It seems like a sensible approach to similarly set species (and parameter) units like
rn = @reaction_network begin
@species X(t) [unit=µM]
k, X --> 0
end
The ModelingToolkit interface should just work: https://docs.sciml.ai/ModelingToolkit/stable/basics/Validation/
however, we need the @variables
macro in the DSL so t
can be specified with units by a user. Otherwise an incompatible units error will be given.
sounds good. When I add the @variables
macro option (probably this week) I will also add some tests to ensure that this works.
Close by https://github.com/SciML/Catalyst.jl/pull/623