Catalyst.jl
Catalyst.jl copied to clipboard
Enable chain of reactions in macro
Just an idea, could be fun, and shouldn't affect current functionality. Enable stuff like:
@reaction_network begin
(k1,k2), X1 -> X2 -> X3
(k1,k2,k3), X <--> Y --> Z
(k1,k2,k3,k4), A <--> B <--> C
end k1 k2 k3 k4
which would be equivalent to:
@reaction_network begin
k1, X1 -> X2
k2, X2 -> X3
(k1,k2), X <--> Y
k3, Y --> Z
(k1,k2), A <--> B
(k3,k4), B <--> C
end k1 k2 k3 k4
might require some extra thought when implementing batched reactions, e.g.
@reaction_network begin
((k1,k2),l1), (X1,X2) -> Y -> Z
end k1 k2 l1
equivalent to
@reaction_network begin
(k1,k2), (X1,X2) -> Y
l1, Y -> Z
end k1 k2 l1
but should be fine.
Yeah, as long as it isn't breaking this would be nice to add.
I think this proposed notation would compete with the proposed notation for adding metadata/options to reactions, e.g.
@reaction_network begin
d, X --> 0, [noise_scaling_parameter=ns]
end
It would still be possible to combine by nesting reaction metadata, but would produce some potentially really messy expressions. Might make sense to support both (and people or unlikely to use both simultaneously).
Also, I had a look at it, an while stuff like
(X1,X2) -> Y -> Z
is valid Julai expressions, they do get nested, which makes it really messy to parse them.
Basically, this would be nice, is possible, wouldn't be breaking, but will definitely be a mess to implement. I have no plan to look at it any time soon.