Borrar filtros
Borrar filtros

Best way to use compartment capacity as reaction parameter.

1 visualización (últimos 30 días)
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.

Respuesta aceptada

Arthur Goldsipe
Arthur Goldsipe el 11 de Jun. de 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 comentario
Colin Phipps
Colin Phipps el 11 de Jun. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Comunidades de usuarios

Más respuestas en  SimBiology Community

Categorías

Más información sobre Extend Modeling Environment en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by