Render FunctionProduct rate-law type in resolve_ratelaw#82
Open
wshlavacek wants to merge 1 commit intoRuleWorld:mainfrom
Open
Render FunctionProduct rate-law type in resolve_ratelaw#82wshlavacek wants to merge 1 commit intoRuleWorld:mainfrom
FunctionProduct rate-law type in resolve_ratelaw#82wshlavacek wants to merge 1 commit intoRuleWorld:mainfrom
Conversation
`RuleBlockXML.resolve_ratelaw` and `PopulationMapBlockXML.resolve_ratelaw`
recognize Ele/Function/MM/Sat/Hill/Arrhenius but fall through to a
silent `print("don't recognize rate law type")` for FunctionProduct,
which then surfaces as the wrong rate constant in the regenerated BNGL.
FunctionProduct is a real BNG2.pl rate-law modifier
(`Perl2/RateLaw.pm:105`, `:137`, `:670`) used when a rule's rate is the
product of two local functions evaluated in different reactant-pattern
contexts (e.g. `mobility_factor(x) * mobility_factor(y)` in the
BLBR_immobilization model family). Vanilla NFsim already supports it
(`NFinput/NFinput.cpp:2251`), so the only thing standing between these
models and a successful round-trip is the parser refusing the shape.
Fix: add a FunctionProduct branch that emits
FunctionProduct("name1(args1)","name2(args2)")
mirroring BNG2.pl's own serializer at `Perl2/RateLaw.pm:670-677`. New
helper `_ratelaw_arg_ids` accepts both single-Argument (dict) and
multi-Argument (list) shapes the same way the existing MM/Sat handler
does.
Patched in both `RuleBlockXML` and `PopulationMapBlockXML` since both
classes carry their own copy of `resolve_ratelaw`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
`RuleBlockXML.resolve_ratelaw` and `PopulationMapBlockXML.resolve_ratelaw` recognize Ele / Function / MM / Sat / Hill / Arrhenius but fall through to a silent `print("don't recognize rate law type")` for `FunctionProduct`, which then surfaces as the wrong rate constant in the regenerated BNGL.
`FunctionProduct` is a real BNG2.pl rate-law modifier (`Perl2/RateLaw.pm:105`, `:137`, `:670`) used when a rule's rate is the product of two local functions evaluated in different reactant-pattern contexts (e.g. `mobility_factor(x) * mobility_factor(y)` in the `BLBR_immobilization` model family). Vanilla NFsim already supports it (`NFinput/NFinput.cpp:2251`), so the only thing standing between these models and a successful round-trip is the parser refusing the shape.
Fix
Add a `FunctionProduct` branch that emits:
```
FunctionProduct("name1(args1)","name2(args2)")
```
mirroring BNG2.pl's own serializer at `Perl2/RateLaw.pm:670-677`. New helper `_ratelaw_arg_ids` accepts both single-`Argument` (dict) and multi-`Argument` (list) shapes the same way the existing MM/Sat handler does.
Patched in both `RuleBlockXML` and `PopulationMapBlockXML` since both classes carry their own copy of `resolve_ratelaw`.
Test plan