draeger-lab / SBSCL

The Systems Biology Simulation Core Library (SBSCL) provides an efficient and exhaustive Java implementation of methods to interpret the content of models encoded in the Systems Biology Markup Language (SBML) and its numerical solution.
https://draeger-lab.github.io/SBSCL/
GNU Lesser General Public License v3.0
20 stars 13 forks source link

Event triggers before the mentioned condition #44

Open hemilpanchiwala opened 4 years ago

hemilpanchiwala commented 4 years ago

The issue occurs when the time csymbol is used in the condition to trigger an event.

While running the SBML L3V2 test case 1444 from the SBML Test Suite, I see that the event should trigger at the time t >= 5 but in results, the event is triggered at the time t = 4.

A similar issue occurs for test cases 1445, 1446, 1447, and 1448.

Here is the screenshot of the result from the SBML Test Runner (for test case 1444) Whenever the slope of the plot changes, at that time the event is triggered. (As per the model, it should trigger at t = 5)

Screenshot from 2020-06-14 23-52-26

Note: Left one is the predefined result from the SBML Test Suite while the right one is the SBSCL simulator's result.

matthiaskoenig commented 4 years ago

You should figure out where the events are evaluated in the code. I.e. somewhere it is checked in every integration step if the trigger conditions are fullfilled. Could you post the information on where to find this code then I can have a look what could go wrong.

hemilpanchiwala commented 4 years ago

@matthiaskoenig, Are you talking about this method? Link: https://github.com/hemilpanchiwala/SBSCL/blob/testrunner/src/main/java/org/simulator/math/odes/AbstractDESSolver.java#L731

shalinshah1993 commented 4 years ago

I think AbsrtactDESSolver simply runs it. Where in the code does the test make a call to the solver? What params are passed? I'm guessing that the params passed or the way it is called has something to do with it. It should be interesting to note that the test starts at t = 4 and not t = 0. May be the parameter you passed need t+1?

hemilpanchiwala commented 4 years ago

@shalinshah1993, this is the link where params are passed to the solver. But, instead, I think there can be a problem in giving time in AbstractDESSolver whenever processEvents is called. Link to the solver method in AbstractDESSolver: https://github.com/hemilpanchiwala/SBSCL/blob/ff1aa32336ca7352f9964fe5b340f0ec756058ac/src/main/java/org/simulator/math/odes/AbstractDESSolver.java#L903