Open matthiaskoenig opened 2 months ago
remember that the event also has a flag that can be checked, so that the event will trigger at initial time. Maybe that would take care of it for you.
As for COPASI, there you can specify the models initial time explicitly (though of course that is 0 when importing SBML models). So you could say my current model time is -50, and then simulate for a duration of X. You can then additionally narrow the interval you would like to collect data from, so if you run for a duration of 100, but only want to collect data from 10..50, you could do that.
I think if SBML had a way to specify the models initial time explicitly all those issues would go away.
@fbergmann In the COPASI UI I cannot provide a start time. If I add negative values in the "Output Time Points" of the Time Course the negative values are just dropped from the output. I.e. I get the following for -20, -10, 0, 10, 20
Time-Course Task
Problem Description:
AutomaticStepSize: 0
StepNumber: 100
StepSize: 0.01
Duration: 1
TimeSeriesRequested: 1
OutputStartTime: 0
Output Event: 0
Start in Steady State: 0
Use Values: 1
Values: -20, -10, 0, 10, 20
Method: Deterministic (LSODA)
Integrate Reduced Model: 0
Relative Tolerance: 1e-06
Absolute Tolerance: 1e-12
Max Internal Steps: 100000
Max Internal Step Size: 0
Time-Course Result:
# Time S_ia Values[model_time]
0 20 0
10 18.0967 10
20 16.3746 20
I.e. COPASI just drops the negative values
@matthiaskoenig here is how to do it in COPASI:
Following the discussion today at HARMONY I was trying a few examples to see where I had issues with models with negative start times. One example are events which are triggered based on
time>=0
. But the problems is basically all math which depends on the csymbol time, which is the relative time to the start of the simulation. The SBML specification states:The specification even states that the only way to handle this is to do a time_offset (as mentioned today).
I.e. the initial time is 0 in a simulation and an event with trigger
time>=0
must be triggered at the first simulation point. Same for all triggers and expressions containing the csymbol time; they all refer to the values relative to the start time. This is not the case, but when starting with negative times the event is only triggered if the model time crosses zero.Example model with an Event:
i.e. at time>=10 the S_event is set. This should happen at 10 after the start time. Another example showing the issue is the
model_time
which just shows the csymbol time which is by SBML specification 0 at the beginning, but not in the results.model_t0.zip
Results in:
The
[S_event]
should be identical for both simulations, as should bemodel_time
.The correct way of simulation according to the SBML specification is to simulate with start time 0 and time shift the results afterwards. I.e. to simulate
the correct way is to do
internally. This is basically what is happening in some implementations of SBML solvers, i.e. they just simulate relative to the start time and setting the csymbol time at the beginning to tstart, but this is incorrect. This is why I implemented my simulations all as starting from zero with a timeshift at the end to the desired start time.
COPASI does not even allow to set the start time for a simulation, which is the correct way to do it. Because
start
is always 0 for SBML models. I.e. the argument:start
to r.simulate is incorrect and should probably be renamed tooffset
ortime_shift
.This is also affecting positive start times. I.e. all simulations with start!=0 report incorrect values of the csymbol time.