Error or bug in SimBiology: creating custom kinetic laws.
3 views (last 30 days)
Show older comments
I am building a model that requires a user defined kinetic law. My code:
Mobj = sbiomodel('u_PA_parameter_generation'); %create model object
comp_obj = addcompartment(Mobj, 'plasma'); %create compartment object
Robj2 = addreaction(Mobj, 'PLS + Pro_u_PA -> PLS + u_PA'); %create reaction object
abskineticlawObj2 = sbioabstractkineticlaw('reaction_2','PLS*Pro_u_PA^ci*keff_PLS'); %create kinetic law
sbioaddtolibrary(abskineticlawObj2) %add kinetic law to the library.
The last line above is the causing my problem. In the absence of sbioaddtolibrary function I get an error:
'Error using SimBiology.Reaction/addkineticlaw The kinetic law named 'abskineticlawObj2' does not exist in the user-defined library. Use SBIOADDTOLIBRARY to add to the library before using it.'
...and when I do as the error suggests (adding the sbioaddtolibrary line above) I get a different error:
'Error using SimBiology.Root/addtolibrary The kinetic law 'reaction_2' already exists as a user-defined. Rename by changing the Name property or re-create by using SBIOABSTRACTKINETICLAW.'
Since these errors are basically a paradox I was wondering if anyone knew if this is a problem with the software or is there a problem with my code. The rest of the reaction is listed below:
Kobj2= addkineticlaw(Robj2, 'abskineticlawObj2');
Pobj2a = addparameter(Kobj2, 'keff_PLS',40); %This rate needs a hill coefiscient!!!
Pobj2b = addparameter(Kobj2, 'ci',2);
set(Kobj2, 'ParameterVariableNames','keff_PLS');
set(Kobj2, 'ParameterVariableNames','ci')
Thanks
0 Comments
Accepted Answer
Arthur Goldsipe
on 8 Jan 2015
Hi Ciaran,
The problem is that you're passing the wrong name to addkineticlaw. Instead of 'abskineticlawobj2', use 'reaction_2' with addkineticlaw. (This is the difference between the MATLAB variable name and the Name property of the kinetic law.)
However, you probably don't need to add a kinetic law to the library in the first place. There are two ways of specifying reaction rates in SimBiology. As you've learned, one is by using a kinetic law. That approach lets you create a kinetic law that serves as a template, and then you fill in the species and variable names for each particular reaction. However, you can also just directly set the ReactionRate property of the reaction as follows:
Mobj = sbiomodel('u_PA_parameter_generation'); %create model object
comp_obj = addcompartment(Mobj, 'plasma'); %create compartment object
Robj2 = addreaction(Mobj, 'PLS + Pro_u_PA -> PLS + u_PA'); %create reaction object
Robj2.ReactionRate = 'PLS*Pro_u_PA^ci*keff_PLS'; % Set the reaction rate
Mobj.addparameter('ci', 1.5); % Create and set the value of ci
Mobj.addparameter('keff_PLS', 0.05); % Create and set the value of keff_PLS
The main reason to use a kinetic law instead of just setting the reaction rate is so that you can re-use sort of rate equation in multiple reactions. But in this case, it's probably not worth the extra effort.
-Arthur
More Answers (0)
Communities
More Answers in the SimBiology Community
See Also
Categories
Find more on Extend Modeling Environment in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!