Skip to content

Support <rateRule> on constant=false parameters (promote to state) - #33

Merged
jeliason merged 1 commit into
mainfrom
feature/rate-rule-support
Jun 24, 2026
Merged

Support <rateRule> on constant=false parameters (promote to state)#33
jeliason merged 1 commit into
mainfrom
feature/rate-rule-support

Conversation

@jeliason

Copy link
Copy Markdown
Member

Adds codegen support for SBML <rateRule> on constant=false parameters by promoting them to integrated state variables. The PDAC model depends on this (its SBML has a rateRule on a constant=false parameter), but requirements.txt pins qsp-codegen@main, which lacks it — so this needs to land on main for fresh PDAC codegen builds (local + HPC) to be correct.

SimBiology emits an abstract non-physical state (e.g. a dimensionless niche
fraction) as a parameter with ConstantValue=false plus a rate rule, rather
than as a species. The generator only parsed <assignmentRule>, so a <rateRule>
targeting a parameter was silently dropped: the parameter stayed frozen at its
initial value with no derivative emitted, and any downstream coupling to it
evaluated against a constant.

_parse_rate_rules promotes each such parameter to an amount-tracked
pseudo-species (state slot + SP_ enum + initial value) and injects one
synthetic production reaction whose rate law IS the rate-rule expression
(d(var)/dt = expr). The existing stoichiometry -> ydot -> Jacobian -> RHS
machinery then evolves it like any other state, with no special-casing
downstream. Rate rules whose target is a species (already a state) are left to
the normal reaction path.

Verified on a PDAC model whose TLA niche fraction is the model's only rateRule:
the state now integrates and its H_CXCL13-driven formation + decay are wired
into both the RHS and the analytical Jacobian.
@jeliason
jeliason merged commit fb8e13d into main Jun 24, 2026
2 checks passed
@jeliason
jeliason deleted the feature/rate-rule-support branch June 24, 2026 21:41
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