Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reversible reaction #198

Closed
metma99 opened this issue Jun 26, 2020 · 18 comments
Closed

reversible reaction #198

metma99 opened this issue Jun 26, 2020 · 18 comments

Comments

@metma99
Copy link

metma99 commented Jun 26, 2020

Quick question if I may:
I tried to use <>, <->, and <--> for representing reversible reactions without success. Errors are ">" is not a unary operator, invalid identifier name "->".
Because of technical reasons I cannot use the double arrow used in the examples.
Is the double arrow in the examples the only way to represent equilibrium reactions?
Markus

@ChrisRackauckas
Copy link
Member

inside of the macro?

@metma99
Copy link
Author

metma99 commented Jun 26, 2020

That is what I am trying:
rxn = #reaction_network begin
2.0, X + Y <> XY
end

@ChrisRackauckas
Copy link
Member

rxn = @reaction_network begin
2.0, X + Y <> XY
end

?

@metma99
Copy link
Author

metma99 commented Jun 26, 2020

It does not work. I showed to you the code, and the error messages.
I tried <> because you mention that > is ok for irreversible reaction.
Not sure what else to tell you.

@metma99
Copy link
Author

metma99 commented Jun 26, 2020

Go you. My mistake. It is a typo.
I of course used @. Sorry

@ChrisRackauckas
Copy link
Member

Does

rxn = @reaction_network begin
2.0, X + Y <-> XY
end

work? I think it might need a - in there. I know that the unicode ↔ works. Pinging @TorkelE @isaacsas

@metma99
Copy link
Author

metma99 commented Jun 26, 2020

This throws the error:
syntax: invalid identifier name "->"

@ChrisRackauckas
Copy link
Member

What version of Julia? v1.4.2 with DiffEqBio v4.3?

@metma99
Copy link
Author

metma99 commented Jun 26, 2020

Juliav1.4.2
DiffEqBiov4.3.0

@isaacsas
Copy link
Member

These seem to be the valid arrow symbols:

double_arrows = Set{Symbol}([:↔, :⟷, :⇄, :⇆, :⇔, :⟺])

I’m not sure about the text representation of some of them, maybe you need <—>? (I.e. using two dashes?) I’ve never used a non-Unicode reversible arrow.

@isaacsas
Copy link
Member

Never mind, I see that didn’t work either for you.

You may have to just define it as two separate reactions. Internally it should lead to no changes in the models that are generated.

@ChrisRackauckas
Copy link
Member

Let's move this issue over to DEBio, but not address it until after the change to MTK (which is almost done!)

@ChrisRackauckas ChrisRackauckas transferred this issue from SciML/DiffEqDocs.jl Jun 26, 2020
@TorkelE
Copy link
Member

TorkelE commented Jun 26, 2020

This basically has to do with the parsing of expressions in Julia. When creating expressions I think neither one of

rxn = @reaction_network begin
2.0, X + Y <--> XY
2.0, X + Y <-> XY
2.0, X + Y <> XY
end

yields working code. Similar limitations for how expressions are parsed makes it so we cannot use X + Y -> XY, but have to use X + Y --> XY.

This leaves us with only various one character symbols as possible separators for reversible reactions (↔, ⟷, ⇄, ⇆, ⇔, ⟺ added currently). If someone came up with a way of using <-->, <->, <> that would be good. But I simply don't think this is possible, given the current way expressions work in julia.

For your problem specifically, it would be interesting to know why you cannot use those arrows? And what alternative symbols you have available? More practically, what you will have to do here, is to simply write out both reactions:

rxn = @reaction_network begin
2.0, X + Y --> XY
2.0, XY --> X + Y
end

@ChrisRackauckas
Copy link
Member

This leaves us with only various one character symbols as possible separators for reversible reactions (↔, ⟷, ⇄, ⇆, ⇔, ⟺ added currently). If someone came up with a way of using <-->, <->, <> that would be good. But I simply don't think this is possible, given the current way expressions work in julia.

Some of the arrows parse in the parser, like -->. I thought bidirectional arrows were in the list?

@TorkelE
Copy link
Member

TorkelE commented Jun 26, 2020

--> is the only exception we have currently. Basically everything that is just counted as a symbol makes
X ... Y and vector with the elements X, ... and Y. Here ... can be one of all the different arrows we have added to our list (, etc.).

I'm not really sure what kind of operation --> is, but X --> Y is a valid expression, and since it is a natural way to write things we have a special check to parse this. If you, however, try to write something like

ex = :(X <> Y)
ex = :(X <-> Y)
ex = :(X <--> Y)

you will get an error (syntax: invalid identifier name "->"), so we cannot even create some kind of exception to handle them specifically. I think these are interpreted as X, followed by a <, followed by a >, or ->, or -->, and Julia don't know how to make sense of that.

@isaacsas
Copy link
Member

isaacsas commented Jul 18, 2020

@metma99 So Julia will add the ability to parse reversible reaction arrows, which in turn will (eventually) allow us to use them here. I assume this won't be available until at least 1.6 though. See JuliaLang/julia#36666

@metma99 metma99 closed this as completed Aug 23, 2020
@metma99
Copy link
Author

metma99 commented Aug 23, 2020

Thank you very much!

@isaacsas
Copy link
Member

This works now with version 6.11 and Julia 1.6!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants