sys-bio / roadrunner

libRoadRunner: A high-performance SBML simulator
http://libroadrunner.org/
Other
39 stars 24 forks source link

Piecewise not interpreted correctly #1023

Closed luciansmith closed 7 months ago

luciansmith commented 2 years ago

From Michael Kochen:

Possible issue with piecewise functions and intervals with an endpoint of 0. Below are two very slight variations of the same model (interval endpoint of 0.000 vs 0.0001) and their output. The second one is correct. r = te.loada('''

J1: S1 -> P; rate

rate := piecewise(0, e < v1/k, k*e - v1, S1 > 0.000, 0)

k = .2; Km = 800 v1 = 15;

S1 = 10; P = 0 e = 70;

at (time > 0): e = 800

''')

r.selections = ["time", "[S1]", "[P]", "J1"] r.simulate(-1, 2, 1000) r.plot()

P and S1 continue to change after the interval endpoint for S1 is exceeded. The rate is zero, and the effective rate is not even one of the options!

luciansmith commented 7 months ago

This is now fixed with #1180! It'll be part of the roadrunner 2.6.0 release.

The trick was that the CVODE integrator wasn't noticing when some piecewise transitions happened. So, like events, roadrunner now tells it to do rootfinding for those transition points.

luciansmith commented 7 months ago

New result of above code:

image