How to assign a transfer rate which changes with time in Simbiology?

2 Ansichten (letzte 30 Tage)
I need to connect between two species in Simbiology. The transfer rate (k) in the reaction is an equation which depends on time such as k = exp(-bt). How can I implement this in Simbiology?

Akzeptierte Antwort

Jeremy Huard
Jeremy Huard am 9 Jan. 2023
Hi,
you can use a reaction with mass action kinetics with rate constant k, where k will be defined in a repeated assignment such as k = exp(-b*time).
Best,
Jérémy
  4 Kommentare
Jeremy Huard
Jeremy Huard am 14 Mär. 2023
Hi,
Let me start to answer your question about this specific error. Then, we will discuss the issue with the event idea more broadly.
The error you get states that the event function produces an error, albeit is not valid. This is because you use Time instead of time. time is a keyword in SimBiology and must be written in lower case. If you write Time, SimBiology looks for model component with that name that does not exist.
Now, from the event function you would like to use, it sounds like you want a repeated assignment to be active only after a specific event. This cannot be achieved with the event you defined because event functions are only evaluated once at the time the event is triggered.
This means that the value of x will be set to k*time at the time the event is triggered.
Instead, I suggest to use a flag that you set in an event. Here is an example derived from the following doc page https://www.mathworks.com/help/simbio/ug/deterministic-simulation-of-a-model-containing-a-discontinuity.html
m = sbiomodel('test');
c1 = addcompartment(m, 'comp');
addspecies(c1, 'x',10);
addspecies(c1, 'y',0);
addparameter(m, 'k',0.1);
addparameter(m, 'mode',0,Constant=false);
addparameter(m, 'y0',0,Constant=false);
addparameter(m, 't_modechange',0,Constant=false);
% Add dummy reaction to model because SimBiology model needs at least one ODE
r1 = addreaction(m, 'x -> null');
addkineticlaw(r1,'MassAction');
r1.KineticLaw.ParameterVariableNames = {'k'};
% add repeated assignment for y
addrule(m, 'y = (1-mode)*exp(2e-1*time) + mode*(k*(time-t_modechange)+y0)','repeatedAssignment');
% Add event to model.
addevent(m, 'y>=3', {'mode = 1';'y0 = y';'t_modechange = time'});
verify(m);
cs = getconfigset(m);
cs.SolverOptions.MaxStep = 0.1;
sd = sbiosimulate(m);
sd_y = selectbyname(sd,'y');
sd_tc = selectbyname(sd,'t_modechange');
sbioplot(sd_y);
xline(sd_tc.Data(end),DisplayName='time of mode change');
I hope this helps.
Day
Day am 21 Mär. 2023
Thank you that is very helpful

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Communitys

Weitere Antworten in  SimBiology Community

Kategorien

Mehr zu Extend Modeling Environment finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by