Unit checking questions

Use this forum to post Vensim related questions.
Post Reply
MichaelEllis
Junior Member
Posts: 2
Joined: Fri Jan 31, 2020 3:30 pm
Vensim version: PLE

Unit checking questions

Post 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
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Unit checking questions

Post 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.
MichaelEllis
Junior Member
Posts: 2
Joined: Fri Jan 31, 2020 3:30 pm
Vensim version: PLE

Re: Unit checking questions

Post 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.
LAUJJL
Senior Member
Posts: 1427
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: Unit checking questions

Post 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
Post Reply