Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Localize kinetic reaction rates.#1232

Merged
1uc merged 6 commits into
masterfrom
1uc/kinetic_local_variables
Apr 9, 2024
Merged

Localize kinetic reaction rates.#1232
1uc merged 6 commits into
masterfrom
1uc/kinetic_local_variables

Conversation

@1uc

@1uc 1uc commented Apr 4, 2024

Copy link
Copy Markdown
Collaborator

If assignments and reaction equations are interspersed the ODE might use incorrect reaction rates. Example:

rate = 42.0
~ a <-> b (1.0*rate, 2.0*rate)
rate = 43.0
~ c <-> d (3.0*rate, 4.0*rate)

was equivalent to:

rate = 42.0
rate = 43.0
~ a <-> b (1.0*rate, 2.0*rate)
~ c <-> d (3.0*rate, 4.0*rate)

This PR solves the issue by localizing the rates, i.e. it'll produce:

LOCAL kf0_, kb0_, kf1_, kb1_
rate = 42.0
kf0_ = 1.0*rate
kb0_ = 2.0*rate
~ a <-> b (kf0_, kb0_)
rate = 43.0
kf1_ = 3.0*rate
kb1_ = 4.0*rate
~ c <-> d (kf1_, kb1_)

Which can then be safely shuffled into:

LOCAL kf0_, kb0_, kf1_, kb1_
rate = 42.0
kf0_ = 1.0*rate
kb0_ = 2.0*rate

rate = 43.0
kf1_ = 3.0*rate
kb1_ = 4.0*rate

~ a <-> b (kf0_, kb0_)
~ c <-> d (kf1_, kb1_)

and from there transformed as usual.

@bbpbuildbot

This comment has been minimized.

@codecov-commenter

codecov-commenter commented Apr 5, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 96.20253% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 86.65%. Comparing base (98e6df2) to head (8483416).
Report is 1 commits behind head on master.

❗ Current head 8483416 differs from pull request most recent head b8ebe7f. Consider uploading reports for the commit b8ebe7f to get more accurate results

Files Patch % Lines
src/visitors/kinetic_block_visitor.cpp 96.20% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1232      +/-   ##
==========================================
+ Coverage   86.59%   86.65%   +0.05%     
==========================================
  Files         176      176              
  Lines       13053    13132      +79     
==========================================
+ Hits        11303    11379      +76     
- Misses       1750     1753       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@1uc 1uc force-pushed the 1uc/kinetic_local_variables branch from 30727b1 to 8bd19d9 Compare April 5, 2024 08:59
@bbpbuildbot

This comment has been minimized.

@1uc 1uc marked this pull request as ready for review April 5, 2024 12:38
@1uc 1uc force-pushed the 1uc/kinetic_local_variables branch from 8bd19d9 to 8483416 Compare April 5, 2024 12:39
@bbpbuildbot

This comment has been minimized.

@pramodk pramodk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor suggestions. It's done nicely! With the tests, it quite clear! 👌

Comment thread src/visitors/kinetic_block_visitor.cpp
Comment thread src/visitors/kinetic_block_visitor.cpp
@bbpbuildbot

Copy link
Copy Markdown
Collaborator

Logfiles from GitLab pipeline #203899 (:white_check_mark:) have been uploaded here!

Status and direct links:

Comment thread test/unit/visitor/kinetic_block.cpp
Comment thread src/visitors/kinetic_block_visitor.cpp
@1uc 1uc merged commit 868ce13 into master Apr 9, 2024
@1uc 1uc deleted the 1uc/kinetic_local_variables branch April 9, 2024 15:10
JCGoran pushed a commit to neuronsimulator/nrn that referenced this pull request Mar 12, 2025
Store the forward and reverse rates in local variables, e.g.:
```
rate = 42.0
~ a <-> b (1.0*rate, 2.0*rate)
```
is converted to:
```
LOCAL kf0_, kb0_
rate = 42.0
kf0_ = 1.0*rate
kb0_ = 2.0*rate
~ a <-> b (kf0_, kb0_)
```

This solves a bug that assigning to `rate` between two reaction equation statements would mean the first line sees the value meant for the second line.

NMODL Repo SHA: BlueBrain/nmodl@868ce13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants