Skip to content

Render FunctionProduct rate-law type in resolve_ratelaw#82

Open
wshlavacek wants to merge 1 commit intoRuleWorld:mainfrom
wshlavacek:modelapi-b10-functionproduct-ratelaw
Open

Render FunctionProduct rate-law type in resolve_ratelaw#82
wshlavacek wants to merge 1 commit intoRuleWorld:mainfrom
wshlavacek:modelapi-b10-functionproduct-ratelaw

Conversation

@wshlavacek
Copy link
Copy Markdown

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

  • Existing CI passes
  • A model that uses `FunctionProduct` in a rule rate (e.g. `BLBR_immobilization_simple`) round-trips through XML and produces a BNG2.pl-loadable `.bngl`

`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`.
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

Successfully merging this pull request may close these issues.

1 participant