Skip to content

Reaction kinetics: split setRate into rate/probability/binding_radius properties#161

Open
dilawar wants to merge 2 commits into
unit-tests-and-fixesfrom
reaction-kinetics-properties
Open

Reaction kinetics: split setRate into rate/probability/binding_radius properties#161
dilawar wants to merge 2 commits into
unit-tests-and-fixesfrom
reaction-kinetics-properties

Conversation

@dilawar

@dilawar dilawar commented May 23, 2026

Copy link
Copy Markdown
Collaborator

Stack

  1. More unit tests and some fixes #160 — More unit tests and some fixes (base)
  2. Reaction kinetics: split setRate into rate/probability/binding_radius properties #161 (this PR) — Reaction kinetics property refactor

⚠ Stacked on #160. Review and merge #160 first; this PR's diff against master will look noisier until then.

Summary

The Python wrapper's Reaction.setRate(rate, reaction_probability, binding_radius) was a single method doing three jobs, dispatched via a rate < 0 sentinel — mirroring libsmoldyn's overloaded smolSetReactionRate(..., isinternal). This PR splits the Python surface into three single-purpose property setters:

Property Underlying C call
r.rate smolSetReactionRate(..., isinternal=0)
r.reaction_probability smolSetReactionRate(..., isinternal=1) (unimol) or 2 (bimol)
r.binding_radius smolSetReactionRate(..., isinternal=1) (bimol only, asserted)

smolSetReactionRate is unchanged — the C API stays as-is, the wrapper just stops exposing its polymorphic shape.

Notes

  • setRate remains as a back-compat shim that emits DeprecationWarning. The old rate < 0 sentinel semantics are preserved inside the shim.
  • reaction_probability and binding_radius have no C-side getter (libsmoldyn exposes no smolGetReactionProbability or smolGetReactionBindingRadius), so their property getters return last-set values cached on the instance.
  • Builds on the smolGetReactionRate C function and getReactionRate pybind11 binding that land in More unit tests and some fixes #160.

Test plan

dilawar added 2 commits May 23, 2026 21:38
…properties

Reaction.setRate was a single method doing three jobs based on a rate<0
sentinel, mirroring libsmoldyn's overloaded smolSetReactionRate(...,
isinternal). Replace it with three property setters, one per kinetic
quantity, each routing to setReactionRate with the correct isinternal
value:

  - .rate                  -> isinternal=0 (macroscopic rate)
  - .reaction_probability  -> isinternal=1 (unimol) or 2 (bimol)
  - .binding_radius        -> isinternal=1 (bimolecular only)

probability and binding_radius have no C-side getter (libsmoldyn
exposes no smolGetReactionProbability or smolGetReactionBindingRadius),
so their property getters return last-set values cached on the
instance.

setRate stays as a deprecated shim with the old sentinel semantics
preserved, so back-compat callers still work but get a
DeprecationWarning. Reaction.__init__ now uses the properties directly
rather than setRate.
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