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

1 回表示 (過去 30 日間)
Day
Day 2023 年 1 月 9 日
コメント済み: Day 2023 年 3 月 21 日
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?

採用された回答

Jeremy Huard
Jeremy Huard 2023 年 1 月 9 日
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 件のコメント
Jeremy Huard
Jeremy Huard 2023 年 3 月 14 日
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 2023 年 3 月 21 日
Thank you that is very helpful

サインインしてコメントする。

その他の回答 (0 件)

コミュニティ

その他の回答  SimBiology コミュニティ

カテゴリ

Help Center および File ExchangePerform Sensitivity Analysis についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by