Catalyst.jl icon indicating copy to clipboard operation
Catalyst.jl copied to clipboard

Enable chain of reactions in macro

Open TorkelE opened this issue 2 years ago • 1 comments

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.

TorkelE avatar Mar 26 '22 17:03 TorkelE

Yeah, as long as it isn't breaking this would be nice to add.

isaacsas avatar Mar 26 '22 22:03 isaacsas

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.

TorkelE avatar Dec 03 '23 00:12 TorkelE