필터 지우기
필터 지우기

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 Community

카테고리

Help CenterFile Exchange에서 Perform Sensitivity Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by