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

Reaction expression parser #330

Closed
thevolatilebit opened this issue May 3, 2021 · 4 comments
Closed

Reaction expression parser #330

thevolatilebit opened this issue May 3, 2021 · 4 comments

Comments

@thevolatilebit
Copy link

It'd be nice to isolate the reaction expression parser for use in, e.g., loading reactions from a file. This is simple to do: One can overload get_reactions as in get_reactions(exs::Vector{Expr}, reactions = Vector{ReactionStruct}(undef,0)) (where the exs are the reaction expressions as supplied in @reaction_network.).

I'd be grateful to know if there's a more generic / elegant approach / you've some ideas on this that I'd implement and push.

@isaacsas
Copy link
Member

isaacsas commented May 3, 2021

If you want to put in a PR that makes the parsing code more modular that would be great and appreciated! It would need some work to generate Reactions from one reaction line I think since the parser needs to know and define parameter and species variables too before making a reaction.

You could always also just build a string with the macro wrapping the reactions, and then eval it. While that’s not recommended for loading other people’s code it would be fine for your own files.

@Leticia-maria
Copy link

Could I submit a PR for it? I did something that would fit.

@isaacsas
Copy link
Member

Certainly! Making it more modular would be great. We've also recently discussed adding a

rx = @reaction k, A --> B

type macro, so having a standalone parser for such expressions would be good. The plan was to make it default to having k be a parameter and anything in the reaction part (i.e. A --> B) be a species, with users being able to override this default behavior by predeclaring a symbol with ModelingToolkit's @parameters and @variables macros.

@isaacsas
Copy link
Member

We support serialization now, so I think that should cover this.

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

3 participants