Units checking is most useful for blocks with expressions that combine variables that
involve many different kinds of units that are often incommensurate. It is not uncommon to
find a BREAKPOINT, INITIAL, DERIVATIVE, or KINETIC block in which some variables
or parameters have length in um, others have area in cm2, and yet others have volume in
liters; variables with concentrations in micro- or nanomoles/liter side by side with others
in millimoles/liter; currents in nano- or picoamperes alongside currents in micro- or
milliamperes, etc.. That's when automated units checking is essential.
Units checking is not generally needed for FUNCTION blocks that compute voltage-
dependent time constants and steady state values, because the expressions tend to
be simpler, stereotyped, and involve variables and parameters that have commensurate
units. This makes it easy to detect and fix any inconsistencies manually. Testing such
FUNCTION blocks with automated units checking tends to generate a lot of "nuisance"
error messages becuase automated testing is so fastidious about syntax, especially
of arguments and returned values.
In your particular example, I suspect the complaint arises because you have not
specified the units of the numeric arguments 0.1, 10, and 35. They should be ms-1, mv,
and mv, respectively (assuming you have defined ms and mv in the UNITS block), but
unless you add special notation, modlunit interprets them all as dimensionless.
You may well ask "Why don't I just insert the extra notation?"
Fine. Do you like this better?
Code: Select all
malpha = SafeExp(0.1(/ms),10(mv),-(v+35(mv)))
Most programmers prefer not to destroy the (human) readability of their code, which
complicates debugging and code maintenance, even if it makes modlunit happy.
So it's a common practice to disable units checking in such FUNCTION blocks by
surrounding them with UNITSOFF . . . UNITSON, e.g.
Code: Select all
UNITSOFF
. . . function blocks go here . . .
UNITSON