Page 1 of 1

Unit checking questions

Posted: Sat Feb 01, 2020 12:54 am
by MichaelEllis
New user here.

I built a model using the Buck equation for saturation vapor pressure of water in hectoPascals, with the RHS coded as follows.

Code: Select all

6.1121 * exp((18.678 - Water Temperature/234.5)*(Water Temperature/(257.14+Water Temperature)))
It's failing the unit check because Vensim believes the argument of exp is °C .

What's the right way to code the equation to tell Vensim the dimensions of the constants? I'd prefer not to have to include them in my Sketch.

Also, what's the right way to specify units as Percent, e.g.

Code: Select all

100 * a / b
where a and b have the same units? Do I have to resort to creating a constant var with units of Percent and a value of 100?

Thanks!
Mike

Re: Unit checking questions

Posted: Sat Feb 01, 2020 1:24 am
by tomfid
Embedded parameters like the 257.14 should be named as variables so that units can be assigned. This is also good practice because it exposes them to testing. If they're troublesome on the diagram, you can use the magic wand tool to hide them.

For percent, we typically do something like the following:

"100 percent" == 100 ~ percent ~ note that this is unchangeable, as indicated by the double equals
fractional discard rate = discard rate/"100 percent" ~ fraction/year
discard rate = 13 ~ percent/year

I generally just avoid percent and do everything in fractions though.

Re: Unit checking questions

Posted: Sat Feb 01, 2020 12:05 pm
by MichaelEllis
Thanks, Tom. I agree completely about the desirability of assigning units to the constants. I just wish the ones that are used in only one equation could be handled in a way analogous to local variables in a conventional programming language -- especially since there's no magic wand in the PLE editions.

BTW, Kudos for your work in climate simulation. I believe the En-ROADS simulator from Climate Interactive has the potential to make a real difference.

Re: Unit checking questions

Posted: Sun Feb 02, 2020 8:52 am
by LAUJJL
Hi

All Vensim versions have the possibility to set 'strict unit testing' at 'model settings unit equivalent'. I always use this option, because in some cases, if the option is not set, Vensim guesses the dimension from the equation if all the constants and variable have not their unit correctly set. Using this option makes everything clear and not ambiguous. If you are a beginner in Vensim, you should split your formulas into simpler one's (no more than 3 inputs). It will make all verifications easier (values and dimension) reading the equations and verifying their outputs with test runs (mandatory).
From my last PLE version, it is no possible to hide anything. But it is maybe possible in new versions.

Regards.

JJ