Dimensional analysis with math functions flags a warning

4 views (last 30 days)
Jim Bosley
Jim Bosley on 24 May 2018
Commented: Jim Bosley on 26 Feb 2019
I'm getting a warning when I run with dimensional analysis.
_ Cannot perform dimensional analysis for rule 'rule_13' because of the function 'exp' in the rule. It is recommended that input and output arguments to functions be dimensionless to ensure correct results._
In my model, the argument to the exp referred to is dimensionless, and the entire rule is dimensionally consistent if I assume that the exp function has no dimension (that is, dimensionless). Is there any way to tell Simbiology "Hey, check my input arguments, and assume that the output is dimensionless", so that the warning will go away?
Put another way, even if I did get a warning like the following, it would be more useful (provided that the warning was true)
Rule 13 includes an exp() function. Dimensional analysis has checked the input argument and the rule itslf. The units of the argument to exp() is dimensionless. The rule is dimensionally consistent, assuming that the exp function is dimensionless.
I have a lot of functions in my model with exp, erf, and other functions that trigger this warning. DA would be most helpful if it did check the argument and the rule (under the assumption that the offending function is dimensioneless.
Or does DA already do this?

Accepted Answer

Arthur Goldsipe
Arthur Goldsipe on 24 May 2018
The short answer is that SimBiology does not currently confirm that the inputs to exp are dimensionless, but I agree that this would be a very useful enhancement.
This warning is meant to convey two important pieces of information:
  1. SimBiology is not doing any dimensional analysis on the input arguments to the function (exp in this case).
  2. It's safest to write function calls with dimensionless inputs, because SimBiology does not make guarantees about what units will be used when an input is not dimensionless and you enable unit conversion.
Let me talk a little more about point #2. Consider a case where the input to a function is a parameter for which you've set the units to millimeter. SimBiology might actually pass in the value of the parameter in meter. If that seems surprising, consider what units SimBiology should use if the input argument was the sum of two parameters, one with units of meter and another with units of millimeter. So, during a simulation, SimBiology converts all lengths to the same unit, if you enable unit conversion.
You might wonder why SimBiology doesn't check that the inputs to your function are dimensionless. Well, in the general case, we don't know whether the inputs to a function are expected to be dimensionless or not. In the case of exp, you and I know the inputs should be dimensionless. But it does get a little tricky, because MATLAB allows you to define your own version of exp that shadows the builtin exp and expects the input argument to have a particular unit. I can't imagine why anyone would actually do this with exp. Practically speaking, I think it would be better for our users if SimBiology did "proper" dimensional analysis on common mathematical functions like exp and erf. This is something that has been on my radar, but I'll make sure to add your comments to our database of enhancement requests.
Jim Bosley
Jim Bosley on 26 Feb 2019
Right now I get 14 warnings saying (for example) "cannot perform analysis for rule "rule_9" because of the function 'exp' in the rule. A simulation setting (radio button) that allows one to opt for
"Assume all functions are dimensionless"
Would be nice. It would also allow one to use unit conversions. Also a button to opt for
"Check to ensure that all function arguments are dimensionless"
would also be nice. This would then enforce good coding:
conc = base_conc * exp( - time*time_constant); %
where base_conc and time_constant have the units of conc, and 1/time, respectively.

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!