Handle very close ODE stop times safely - #345
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #345 +/- ##
==========================================
+ Coverage 83.82% 83.92% +0.10%
==========================================
Files 82 82
Lines 33983 34041 +58
==========================================
+ Hits 28486 28569 +83
+ Misses 5497 5472 -25
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR hardens the ODE event loop around solver stop times that land extremely close (within floating-point roundoff) to bolus/infusion boundaries, ensuring the logical simulation time and RHS are consistent after discontinuities across both closure-based and DSL/JIT models.
Changes:
- Snap solver logical time to the requested
stop_timewhen a stop is reached but the internal solver time differs by a few ULPs, triggering a safe restart when needed. - When
StopTimeAtCurrentTimeoccurs, coalesce very-close forward stops after verifying the omitted infusion amount is below tolerance; otherwise return an error. - Add regression tests covering bolus history restarts and infusion boundary behavior across all supported ODE solvers (and compiled/JIT models behind
dsl-jit).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/bolus_reinit_stop_time.rs | Adds regression tests for near-stop-time discontinuities (bolus and infusion) across solvers and (optionally) DSL/JIT. |
| src/simulator/equation/ode/mod.rs | Updates the closure-based ODE event loop to safely align time at reached stops, restart correctly, and validate coalesced infusion input. |
| src/simulator/equation/ode/closure.rs | Introduces an infusion “amount between times” helper used to detect material skipped input when coalescing stops. |
| src/dsl/native.rs | Mirrors the updated stop/coalescing behavior in the DSL/native ODE path and makes the compiled function call explicitly unsafe. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
| Project | pharmsol |
| Branch | fix/ode-stop-times |
| Testbed | mhovd-pgx |
⚠️ WARNING: Truncated view!The full continuous benchmarking report exceeds the maximum length allowed on this platform.
What changed
Testing
Tested all four ODE solvers, including the complete 100-cycle Pmetrics example.