Triggering Events In SimBiology toolbox

1 view (last 30 days)
I am wondering if it's possible to define time delay as an event for a trigger in simbiology. I want to define a duration of 2 hours for one stage of the system. For example, when species_1 gets a certain value (like species_1 == 5), I need the system to stay in this state for 2 hours and afterwards species_1 =0 and species_2 = 1 (while some other species are interacting with each other independent of this process). I defined a function as event and used "tic toc" to make a delay after trigger, but even though this provides a delay, the amount of corresponding species are changed at the beginning of delay not at the end! Can somebody help me with this? thanks

Accepted Answer

Ingrid Tigges
Ingrid Tigges on 2 Sep 2014
I have attached a .zip file which contains a .sbproj file with a small example. In this example species_1 is created with constant rate, than you have reversible reaction which creates species_2 and species_2 degenerated with constant rate. I have then also created a copy of this whole set. This copy should not be effected by stages while the species_1 and species_2 are.
The two stages are modelled using two events: The first event gets triggered if species_1 gets above a certain threshold. During a simulation it is unlikely that for example 5 is exactly hit, hence one uses >5. Then you have several event functions:
  • stage is used to ensure that the second event triggers at the correct time
  • stage_start_time stores the time the event is triggered. This is needed to calculate the time the second event should be started at the stage_start_time + the time the first stage takes
  • In order to keep species_1 and species_2 on there values you have to set the generating and removing kinetics to 0
  • The trigger for the second event is that stage=1 (meaning the first stage took place) and that the time is past stage_start_time+the time the first stage takes
Is this explanation understandable?
  4 Comments
al
al on 5 Sep 2014
Thank you so much again for your help and precise answers.
A: Regarding the question 2, I didn't get the point exactly. you added a parameter (eventTime) but never used it in the event! If you remember, in the model you made, there was a stage 1, which was triggered if species_1 crosses a certain threshold. And there was a fixed duration of 2 seconds. Now, I want this duration to be "2+ a small random number". But how?
B: Another question is that since you used 'randn", i am wondering if it is possible to change the type and the parameters of distribution we want (like normal distribution with mean of zero and the standard deviation of 0.1 or an exponential distribution with our interested parameters).
C: The last point is related to possibility of defining expressions like sig(t) and deg(t) in the following model (there is a model that has some ODEs and also, it has two strange equations which are not differential equations but they are used inside some other ODEs):
>>d(species_1)/dt = k1*species_2 - deg(t) *species_2*species_1
>> sig(t) = k2*exp(-k3*time)
>> deg(t) = k4 - k5*(sig(t) - k2*exp(-k6*k2*time))
>>k1=7e-2, k2=2e-3, k3=1e-8, k4=5.56e-2, k5=7.72e-1, k6=2e-2
species_1 and species_2 are two species in the system. the main thing here is that there is a signal, sig(t), which decays and another one, deg(t), that shows a sort of strange degradation that itself depends on sig(t). How can we write such a thing in Simbiology?
Thanks Again
Ingrid Tigges
Ingrid Tigges on 8 Sep 2014
Edited: Ingrid Tigges on 8 Sep 2014
Like before, let me answer your points separately:
A: Sorry, I made a typing mistake. It should have been nextEventTime rather than eventTime. After this small change you can use the code I have posted in my previous comment.
B: Yes, it is. You can use another MATLAB expression there as well
C: What you would like to have is something called rate rules, which is described here Rate rules
The following shows the example from the above mentioned page of the documentation and once the same example but with time as parameter, note how the slope changed
m = sbiomodel('m');
c = addcompartment(m,'comp');
s = addspecies(m,'x','InitialAmount',2);
p = addparameter(m,'k','Value',1);
r = addrule(m,'x = -k * x*time','RuleType','rate');
output=sbiosimulate(m);
m2=sbiomodel('m2');
c2 = addcompartment(m2,'comp');
s2 = addspecies(m2,'x','InitialAmount',2);
p2 = addparameter(m2,'k','Value',1);
r2 = addrule(m2,'x = -k * x','RuleType','rate');
m2output=sbiosimulate(m2);
figure(2) subplot(1,2,1) plot(output.Time,output.Data) ylim([0 2]) title('Time in rule') subplot(1,2,2) ylim([0 2]) title('Time not in rule') plot(m2output.Time,m2output.Data)
As a side note, if you have a completely new question, it helps the readability if you create a new post :-).

Sign in to comment.

More Answers (0)

Communities

More Answers in the  SimBiology Community

Categories

Find more on Perform Sensitivity Analysis in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!