MATLAB Answers

setting of initial conditions simbiology

13 views (last 30 days)
Hi, I'm learning the way of creating PKPD model with simbiology
In the example of bacterial PKPD model, there is the discription of "initial conditions" for simulation
But, i was not able to figure out how to set the initial conditions
Initial conditions didn't show up with the MODEL>Tools>Program Initial Conditions Options
It is very helpful to teach me how to manage this !
Thanks,

Accepted Answer

Kazutaka Sekiguchi
Kazutaka Sekiguchi on 13 Jul 2020
Thank you so much, Jérémy
I was following this example https://www.mathworks.com/help/simbio/ug/model-views.html with simbiology app
In this example, variant column and initial conditions seems to be separate
I created the variant for vancomycin, but I was not able to create the column for the initial conditions
what is the difference between "variant" and "initial conditions"?
and, is it difficult to create initial conditions when I use simbiology app?
Best regards,
Kazutaka
  4 Comments
Kazutaka Sekiguchi
Kazutaka Sekiguchi on 20 Jul 2020
Hi Jeremy
Thank you for your reply
I understood the meaning of program!!

Sign in to comment.

More Answers (1)

Jeremy Huard
Jeremy Huard on 13 Jul 2020
Edited: Jeremy Huard on 13 Jul 2020
Dear Kazutaka,
If so, in this example initial conditions are the ones defined in the model m1 and they are not modified. If you run the script (especially the command sbioloadproject('AntibacterialPKPD.sbproj', 'm1') ), the model will be loaded. Then, if you type in the Command window of MATLAB:
m1.Species
you will see the list of state variables and their initial conditions. Species Growing in compartment [Bacterial Growth Model] is set to 1e7 molecule/milliliter (=CFU/ml) which corresponds to the severe infection case.
If you want to simulate different conditions, you could use one of the following methods:
  1. Modify the value in the model itself: After line 62 of the script where the model is loaded, you could add the following lines:
specObj = sbioselect(m1,'Type','Species','Name','Growing');
specObj.InitialAmount = 1e4; % Moderate infection
If you are using the SimBiology App, you can open the Model Browser and edit the values there.
The drawback of this method is that the value of Growing is changed in the model itself. So, you will need to remember this to make sure you are simulating the right initial conditions.
2. Use a variant: Variants are constructs that store alternate values of model parameters and initial conditions and are applied at simulation time. Using variant gives you a lot of flexibility and might be easier to keep track of the parameter values and initial conditions used for simulation.
Typically, you would create variants in the SimBiology App with one of the following methods:
a. drag and drop the variant icon into the list of model components in the Model Browser.
b. or open the list of Variants from the 'Open' menu in the 'Model' tab
But you could also define them programmatically:
variant = addvariant(m1, 'Moderate infection');
addcontent(variant, {'species', 'Growing', 'InitialAmount', 1e4});
In this example, you could then use this variant as baseline of the SimFunction:
simfunc = createSimFunction(m1,params,observables,tempdose,variant,'UseParallel',true); % line 239
3. Define this initial value as input of the SimFunction: In the previous methods, the new initial condition will be used for all simulations. But if you wish to be able to change the initial condition for every simulation, it might be better to define the initial amount of the species Growing as input of the SimFunction. SimFunctions are function-like interface to execute SimBiology models with a predefined list of inputs (initial conditions or parameter values) and a predefined list of outputs (e.g. timecourse of some state variables). To implement it you will need to modify line 221 to define the species initial amount as input:
params = {'Central', 'k12', 'k21', 'CL', 'k1', 'k2', 'Kmax', 'KC50','[Bacterial Growth Model].Growing'};
Then, you would need to add the new values of Growing in phi (the matrix containing all values to use for simulation). For instance, if you want to use the same values for all simulations:
iniInfection = 1e4; % new initial condition for species Growing
phi = cell(1,nDoseGrps);
for i = 1:nDoseGrps
phi{i} = [Central(:,i),k12(:,i),k21(:,i), ...
CL(:,i), k1(:,i), k2(:,i), ...
Kmax(:,i), KC50(:,i), iniInfection];
end
But again, this method will be more useful if the the value of Growing differs for the different simulations.
This turned out to be a long answer but I hope it gives you a good overview on how to change initial conditions.
Best regards,
Jérémy

Communities

More Answers in the  SimBiology Community

Community Treasure Hunt

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

Start Hunting!

Translated by