Bernard is bumping up against some current limitations with dimensional analysis and unit conversion in SimBiology. I've sent him a model that shows a couple of workarounds, but I wanted to describe the issues and workarounds here in case anyone else encounters similar problems.
SimBiology's dimensional analysis should fully support the arithmetic operations +, -, *, and /. The case of ^ is a bit trickier to handle, because of the possibility of generating units raised to fractional powers. In this case, SimBiology explicitly disallows fractional exponents and will error if you try to simulate a model containing such expressions.
SimBiology is also currently unable to do dimensional analysis on expressions that involve other arbitrary functions (including sin, exp, log, or any user-defined function). However, when SimBiology encounters such an expression, it will warn the user but will continue to simulate. This provides a couple of possible workarounds for implementing Hill kinetics while enabling dimensional analysis and unit conversion on parts of the model.
For both options, create a MATLAB function in a file, such as HillFactor.m that is defined something like this:
function factor = HillFactor(K, S, n)
% Note: in this implementation, K and S must have dimensionally consistent units,
% and n must be dimensionless.
factor = S^n / (K^n + S^n);
Option 1: Create a reaction with the rate set to something like "V1*HillFactor(K1, S1, n1)". You will receive a warning that this rate expression will not be checked for dimensional consistency, but you be able to simulate. However, you are then responsible for ensuring that V1 has the appropriate units.
Option 2: Create a non-constant parameter "factor" with dimensionless units (such as "second/second") and assign it the following value via a repeatedAssignment rule: "factor1 = HillFactor(K1, S1, n1)". Then, create a reaction with the rate set to "V1*factor1". Although SimBiology will not do dimensional analysis on the repeatedAssignment rule, it will do dimension analysis on the rate and ensure that V1 has the correct units.
-Arthur
[snip]
> For both options, create a MATLAB function in a file, such as HillFactor.m that is defined something like this:
>
> function factor = HillFactor(K, S, n)
> % Note: in this implementation, K and S must have dimensionally consistent units,
> % and n must be dimensionless.
> factor = S^n / (K^n + S^n);
>
> Option 1: Create a reaction with the rate set to something like "V1*HillFactor(K1, S1, n1)". You will receive a warning that this rate expression will not be checked for dimensional consistency, but you be able to simulate. However, you are then responsible for ensuring that V1 has the appropriate units.
>
> Option 2: Create a non-constant parameter "factor" with dimensionless units (such as "second/second") and assign it the following value via a repeatedAssignment rule: "factor1 = HillFactor(K1, S1, n1)". Then, create a reaction with the rate set to "V1*factor1". Although SimBiology will not do dimensional analysis on the repeatedAssignment rule, it will do dimension analysis on the rate and ensure that V1 has the correct units.
>
> -Arthur
Arthur, thank you very much. Both those options work well and allow me to continue to use DimensionalAnalysis and UnitConversion. The Hill slope doesn't have to be an integer which is great. Your reply also alerted me to the fact that you can use an external m-code user function in a SimBiology model (while being careful about dimensions and units). I wasn't aware of this (although it is mentioned in the User Guide) and it is a nice option if Rules-based functions are too restricting.
Thanks very much for your prompt and helpful reply.
Bernard