Using simFunction Object in Simbiology when my stoichiometry depends on a model parameter
조회 수: 4 (최근 30일)
이전 댓글 표시
I have s SimBiology model in which the stochiometry of some equations depend on a model parameter called "DAR" as you can see below. I have DAR and some other paameters to change and see their effect on some observables. Once I change DAR and create a SimFunction, The stochiometry of equations do not change. Is there any way to use simFunction object and see the effect of DAR on the stchiometry. I can change the stochiometry in loop but I want it to be chnage as I use simFunction.
Thanks
reactionObj = addreaction(model,'Media.ADC_ext -> Media.Ab_ext + Media.PL_ext');
set (reactionObj, 'Stoichiometry', [-1 1 sbioselect(model,'Name','DAR').Value])
set (reactionObj, 'ReactionRate', 'kdec*Media.ADC_ext');
set (reactionObj, 'Notes', 'ADCs lose their payload, to produce unconjugated antibody and free payload');
set (reactionObj, 'Name', 'r1');
댓글 수: 0
채택된 답변
Jeremy Huard
2023년 3월 20일
Hi Mehdi,
the stoichiometry of reactions cannot be parametrized unfortunately.
But instead of using reactions you can use rate rules which will allow you to define stoichiometric coefficients as parameters.
Here is an example:
% model
model = sbiomodel("parstoich");
comp = addcompartment(model,"comp",1,Units="liter");
% species
addspecies(comp,"reactant",10,Units="milligram/liter");
addspecies(comp,"product",0,Units="milligram/liter");
% parameters including stoichiometric coeffs
n_r = addparameter(model,"n_r",3,Units="dimensionless");
addparameter(model,"n_p",2,Units="dimensionless");
addparameter(model,"k",1,Units="milligram/liter/hour");
addparameter(model,"mgperliter",1,Units="milligram/liter");
% ODEs
addrule(model,"reactant = -n_r*k*(reactant/mgperliter)^n_r","rate");
addrule(model,"product = n_p*k*(reactant/mgperliter)^n_r","rate");
% simulation with SimFunction
cs = getconfigset(model);
cs.TimeUnits = "hour";
cs.CompileOptions.UnitConversion = true;
equations = getequations(model)
simfun = createSimFunction(model,"n_p",["reactant","product"],[],AutoAccelerate=false);
np_values = [2;4];
stopTime = 2;
sd = simfun(np_values,stopTime);
% plot
figure;
tl = tiledlayout('flow');
ax = gobjects(numel(np_values),1);
for i=1:numel(np_values)
ax(i) = nexttile(tl);
plot(ax(i),sd(i).Time,sd(i).Data);
title(ax(i),"N_p = "+np_values(i))
end
lgd = legend(["reactant","product"]);
lgd.Layout.Tile = "east";
lgd.Box = "off";
xlabel(tl,"Time");
ylabel(tl,"mg/L");
set(ax,'XLimitMethod','padded','YLimitMethod','padded');
grid(ax,'on');
linkaxes(ax);
댓글 수: 3
Jeremy Huard
2023년 3월 20일
I understand this can be tedious and error-prone for larger models.
But you can implement it fairly easily with the following procedure:
- implement your model using reactions and some exemplary stoichiometric coefficients as you might have already done it
- get the equations generated by SimBiology with getequations (or in the SimBiology Model Builder App)
- create parameters for the stoichiometric coefficients
- create rate rules by copying the ODE which need to be parametrized you got from #2
- set the BoundaryCondition to true for the species that are now defined with rate rules
BoundaryCondition=true will have the species dynamics will be defined by the rate rule and not by the reactions.
You can set this property in Model Builder by selecting multiple species at once (by pressing Shift in Windows and clicking on the species) or in the command line with:
specs = sbioselect(model,"Type","species","Name",["reactant","product"]);
set(specs,"BoundaryCondition",true);
추가 답변 (1개)
Mehdi
2024년 3월 21일
댓글 수: 2
Arthur Goldsipe
2024년 3월 21일
The error you report is intended to communicate that SimBiology does not allow the following the following combination of conditions:
- A species is in concentration.
- The concentration of that species is determined by a rate rule.
- The compartment (that the species is in) is determined by a repeated assignment rule or an algebraic rule.
One fix would be the one mentioned at the end of the error message: Replace the repeated assignment rule or algebraic rule with a rate rule that gives equivalent behavior.
Another option would be to change the species units to amount instead of concentration and use (species amount)/(compartment volume) anywhere you need to reference the concentration.
Also, one request: If you have additional questions, please post them as a new questions on MATLAB Answers. You posted this question in the "answer" field, and it makes it a bit harder to keep track of each question and the associated best answer.
Arthur Goldsipe
2024년 3월 21일
Oh, right after I provided the above answer I saw that you did repost this as a separate question. I'll repost my answer there.
커뮤니티
더 많은 답변 보기: SimBiology Community
참고 항목
카테고리
Help Center 및 File Exchange에서 Perform Sensitivity Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!