This example shows how to create a rate rule where a species from one reaction can determine the rate of another reaction if it is in the second reaction rate equation. Similarly, a species from a reaction can determine the rate of another species if it is in the rate rule that defines that other species. Suppose you have a SimBiology model with three species (
c), one reaction (
a -> b), and two parameters (
k2). The rate equation is defined as , and rate rule is . The solution for the species in the reaction are:
Since the rate rule is dependent on the reaction, . The solution is:
Enter the following commands to set up a SimBiology model accordingly and simulate it.
m = sbiomodel('m'); c = addcompartment(m,'comp'); s1 = addspecies(m,'a','InitialAmount',10,'InitialAmountUnits','mole'); s2 = addspecies(m,'b','InitialAmount',0,'InitialAmountUnits','mole'); s3 = addspecies(m,'c','InitialAmount',5,'InitialAmountUnits','mole'); rxn = addreaction(m,'a -> b'); kl = addkineticlaw(rxn,'MassAction'); p1 = addparameter(kl,'k1','Value',1,'ValueUnits','1/second'); rule = addrule(m,'c = k2 * a','RuleType','rate'); kl.ParameterVariableNames = 'k1'; p2 = addparameter(m,'k2','Value',1,'ValueUnits','1/second'); [t,sd,species] = sbiosimulate(m); plot(t,sd); legend(species); xlabel('Time'); ylabel('Species Amount');