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

Adding events macro to reaction network DSL #694

Closed
tstrey opened this issue Sep 27, 2023 · 3 comments
Closed

Adding events macro to reaction network DSL #694

tstrey opened this issue Sep 27, 2023 · 3 comments

Comments

@tstrey
Copy link
Contributor

tstrey commented Sep 27, 2023

One possible way of doing this is the following:

rn = @reaction_network rxs begin
     @variables t
     @parameters k
     @species A(t) B(t)

     k, A --> B
     @discrete_events begin
          (t == switch_time) => [B ~ 0.0]
     end
     @continuous_events begin
          (A < switch_time) => [B ~ 3.0]
     end
end

However, I think by having the macro inside @reaction_network you loose some flexibility. For example, if you wanted to use rn with different events. It could also be argued that conceptually a reaction network is how the species interact with each other but, the events, being external added boundary conditions, merging the two would not be a good idea.

@isaacsas
Copy link
Member

I think this looks good. Can't one have multiple events within the begin/end blocks? Or by "different events" do you mean if you want to change the events in an already created system?

The general design, which we admittedly don't always adhere to, is that systems should be immutable. So if you want to change something in a system you need to generate a new system with the desired properties. ReactionSystems right now, encompass a full model for a system that involves reactions. This includes coupled events, algebraic equations, and differential equations (along with variables that might not represent chemical species). So they are more a container for a model than just reactions.

Even from the current symbolic interface, where events are created as kwargs to ReactionSystem, you can't really change them once the system is created.

But maybe I've misunderstood your point?

@isaacsas
Copy link
Member

Also, one can always create a rn without events, and then extend it with a system that has the desired events to generate a merged system of reactions and events. So in that way you can keep around an event-free ReactionSystem.

@TorkelE
Copy link
Member

TorkelE commented Jun 4, 2024

now works on master

@TorkelE TorkelE closed this as completed Jun 4, 2024
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