Azzera filtri
Azzera filtri

Best way to use compartment capacity as reaction parameter.

1 visualizzazione (ultimi 30 giorni)
Right now for inter-compartmental flow a simple model building script could look something like:
m=sbiomodel('model');
V=2;
addparameter(m,'Volume',V);
addparameter(m,'Q',3);
c1=addcompartment(m,'Comp1','Capacity',V);
addcompartment(m,'Comp2','Capacity',1);
addspecies(c1,'a',1);
addreaction(m, 'Comp1.a -> Comp2.a','ReactionRate','Q/Volume*Comp1.a');
sbiosaveproject('flow','m');
Now if someone opens flow.sbproj then so long as the Volume parameter and the Comp1 capacity aren't changed the model works fine, but if one of them is changed they're not linked for future model simulation. What's the cleanest way to ensure they're always equal using a script? Thanks for any guidance.

Risposta accettata

Arthur Goldsipe
Arthur Goldsipe il 11 Giu 2016
Hi Colin,
You don't need to create a parameter named Volume. You can refer to the capacity (that is, volume) of a compartment elsewhere in the model by using the compartment name. So just change the reaction rate to 'Q/Comp1*Comp1.a'.
However, to answer your original question, you can use rules to ensure that assignments get applied each time you simulate the model. If you only need to make the assignment at the beginning of the simulation, you can use an initial assignment rule. If you the assignment is an expression that dynamically changes throughout the simulation, you can use a repeated assignment.
As a practical example, let's say you wanted to set the volume of Comp1 to the sum of two parameters, c1 and c2. You can do this by adding a rule Comp1 = c1 + c2. If c1 and c2 are constant throughout the simulation, then you should use an initial assignment rule. If c1 and/or c2 vary throughout the simulation, and you want the compartment volume to be updated accordingly, then you should use a repeated assignment rule.
One additional detail is that by default, parameters and compartments are marked as Constant, so they cannot change throughout a simulation (meaning they cannot be modified by things like repeated assignment rules). Therefore, you will need to mark them as non-constant if you want to modify them with repeated assignment rules.
Finally, here are a couple of other modeling features of SimBiology that you may not know about: rate rules and events. You can directly implement differential equations using rate rules. Events allow you to make discrete changes to the model during the course of a simulation based on some condition. For example, you could use an event to double the concentration of species x when species y becomes greater than 10.
You can read more about rules here, and more about events here.
-Arthur
  1 Commento
Colin Phipps
Colin Phipps il 11 Giu 2016
Thanks Arthur, I was unaware of the fact in your first paragraph. That is a very easy solution! And if it was some other parameter I could use an initial assignment rule.

Accedi per commentare.

Più risposte (0)

Community

Più risposte nel  SimBiology Community

Categorie

Scopri di più su Extend Modeling Environment in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by