Best way to use compartment capacity as reaction parameter.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Colin Phipps
il 10 Giu 2016
Commentato: Colin Phipps
il 11 Giu 2016
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.
0 Commenti
Risposta accettata
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.
-Arthur
Più risposte (0)
Community
Più risposte nel SimBiology Community
Vedere anche
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!