How to assign a transfer rate which changes with time in Simbiology?
조회 수: 1 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
채택된 답변
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
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.
추가 답변 (0개)
커뮤니티
더 많은 답변 보기: SimBiology Community
참고 항목
카테고리
Help Center 및 File Exchange에서 Extend Modeling Environment에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!