units for %
-
- Junior Member
- Posts: 5
- Joined: Mon Oct 21, 2024 12:07 pm
- Vensim version: PLE
units for %
Hi,
In my model I use a lot of 'share' or 'percentage' as variables, for example, the share of sewer load that runs through the seperated sewer, or the share of electric vehicles. However, Vensim does not seem to accept % as a unit. And therefore I have a lot of missing unit errors. Does anyone have any tips on how to overcome this?
Thank you!
In my model I use a lot of 'share' or 'percentage' as variables, for example, the share of sewer load that runs through the seperated sewer, or the share of electric vehicles. However, Vensim does not seem to accept % as a unit. And therefore I have a lot of missing unit errors. Does anyone have any tips on how to overcome this?
Thank you!
-
- Super Administrator
- Posts: 4701
- Joined: Wed Mar 05, 2003 3:10 am
Re: units for %
Use DMNL (dimensionless).
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: units for %
I use "fraction" if it's a share (0-1) and "percent" if it's really %, 0-100. I usually define a constant, like "hundred percent = 100 ~ percent" for converting between the two.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: units for %
I do something similar to Tom, including a constant model variable for conversion so the units pass the unit check.
To draw out something Tom eluded to, please name your model's variables appropriately. If the value is 0-1, then it should be "Fraction of Population that Loves Pizza". If is a 0-100, then "Percentage of Population that Loves Pizza". This is important so that others that look at your diagrams and try to use your model can make sense of it. I've used models that mix and match, or name valuables "Percentage of..." for values from 0-1, and I find that very confusing.
To draw out something Tom eluded to, please name your model's variables appropriately. If the value is 0-1, then it should be "Fraction of Population that Loves Pizza". If is a 0-100, then "Percentage of Population that Loves Pizza". This is important so that others that look at your diagrams and try to use your model can make sense of it. I've used models that mix and match, or name valuables "Percentage of..." for values from 0-1, and I find that very confusing.
Re: units for %
In this thread, there is a question of units. Are these strict or non-strict unit tests?
JJ
JJ
Re: units for %
I’m not sure I follow your question but I think “strict” is the answer. “Percent” is a unit like “dollar” and Vensim applies normal units checking.
Re: units for %
If you click on model settings and units, on the top of the window you can check use stict testing. i just wanted to know if you use strict testing or not.
JJ
JJ
Re: units for %
Oh, I didn't know about the setting. A quick spot check of my models shows that 'strict' is off, which I assume is the default.
-
- Junior Member
- Posts: 5
- Joined: Mon Oct 21, 2024 12:07 pm
- Vensim version: PLE
Re: units for %
Thank you all for the good advice! I like the idea of making a constant to refer to percentages.
I also didn't know about the strict unit setting. For me 'strict was also off.
I also didn't know about the strict unit setting. For me 'strict was also off.
Re: units for %
Hi
Not many Vensim users are familiar with this strict testing feature.
For example, if you add 5 to a variable and that variable has a dimension, e.g. people/year, Vensim assumes that 5 has a dimension equal to that of the variable, unless the strict test is on, in which case there is a unit error report.
The problem is that some unreported unit errors can hide a calculation error in an equation.
For example, in the world3 model joint, if you do the test in off mode, Vensim does not declare any errors. If you put the test on on, Vensim declares 9 errors, 3 of which are in the maturation of the aging population chain.
However, there is an error in the equation on maturation. If we simulate an epidemic in the cohort of children that causes half of the children to die in 6 months, by setting the mortality per year to 1. We notice that during the 6 months of the epidemic, no child passes into the next cohort, which is false. By studying the maturation equation closely, it is easy to understand where the error comes from.
I am attaching the corrected worldmodel3_corrected of the 3 maturation errors.
I also attach the worldmodel3_epidemic model which simulates an epidemic in the year 2020 for 6 months with the result file epidemic.vdfx.
See the thread viewtopic.php?t=7859
in same forum;
Best.
JJ
Not many Vensim users are familiar with this strict testing feature.
For example, if you add 5 to a variable and that variable has a dimension, e.g. people/year, Vensim assumes that 5 has a dimension equal to that of the variable, unless the strict test is on, in which case there is a unit error report.
The problem is that some unreported unit errors can hide a calculation error in an equation.
For example, in the world3 model joint, if you do the test in off mode, Vensim does not declare any errors. If you put the test on on, Vensim declares 9 errors, 3 of which are in the maturation of the aging population chain.
However, there is an error in the equation on maturation. If we simulate an epidemic in the cohort of children that causes half of the children to die in 6 months, by setting the mortality per year to 1. We notice that during the 6 months of the epidemic, no child passes into the next cohort, which is false. By studying the maturation equation closely, it is easy to understand where the error comes from.
I am attaching the corrected worldmodel3_corrected of the 3 maturation errors.
I also attach the worldmodel3_epidemic model which simulates an epidemic in the year 2020 for 6 months with the result file epidemic.vdfx.
See the thread viewtopic.php?t=7859
in same forum;
Best.
JJ
- Attachments
-
- wrld3-03_corrected.mdl
- (150.51 KiB) Downloaded 71 times
-
- wrld3-03_epidemic.mdl
- (149.46 KiB) Downloaded 71 times
-
- wrld3-03.mdl
- (149.08 KiB) Downloaded 67 times
Re: units for %
Hi
I notice that the attached files are regularly downloaded.
Unfortunately, this does not seem to awaken the slightest reaction from readers. What did they understand? Does this leave them indifferent? Are they afraid to make a remark? I would like to see a few remarks.
I also want to point out that I don't bite, especially across the ocean, at least not yet!
Yours truly.
JJ
I notice that the attached files are regularly downloaded.
Unfortunately, this does not seem to awaken the slightest reaction from readers. What did they understand? Does this leave them indifferent? Are they afraid to make a remark? I would like to see a few remarks.
I also want to point out that I don't bite, especially across the ocean, at least not yet!
Yours truly.
JJ
-
- Super Administrator
- Posts: 4701
- Joined: Wed Mar 05, 2003 3:10 am
Re: units for %
They might be downloaded by search bots.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: units for %
Also it was Thanksgiving holiday in the US.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: units for %
This is a very interesting discovery. The equations in question are:
(The second is the one modified for the pulse mortality test.)
In the 'maturation 14 to 15' equation, the obvious issue is that '15' is a hidden dimensioned parameter. One might argue that this instance is 'safe' because 15 years is definitionally the residence time of people in the 0 to 15 cohort - but I would still avoid this usage, and make the 15 yrs a named parameter, like "child cohort duration", with a corresponding name change to the stock. If nothing else, this would make the structure easier to reuse.
The sneaky bit here, revealed by JJ's test, is that the '1' in the term (1 - mortality 0 to 14) is not a benign dimensionless number, as we often assume in constructions like 1/(1+a*x). This 1 actually represents the maximum feasible stock outflow rate, in fraction/year, implying that a mortality rate of 1/yr, as in the test input, would consume the entire outflow, leaving no children alive to mature into the next cohort. This is incorrect, because the maximum feasible outflow rate is 1/TIME STEP, and TIME STEP = 0.5, so that 1 should really be 2 ~ frac/year. This is why maturation wrongly goes to 0 in JJ's experiment, where some children remain to age into the next cohort.
In addition, this construction means that the origin of units in the equation are incorrect - the '15' has to be assumed to be dimensionless for this to work. If we assign correct units to the inputs, we have a problem:
Obviously the left side of this equation, maturation, cannot be people/year/year.
JJ's correction is:
In this case, the '1' represents the maximum fraction of the population that can flow out in a time step, so it really is dimensionless. (mortality 0 to 14 * TIME STEP) represents the fractional outflow from mortality within the time step, so it too is properly dimensionless (1/year * year). You could also write this term as:
In this case you can see that the term is reducing maturation by the fraction of cohort residents who don't make it to the next age group. 1/TIME STEP represents the maximum feasible outflow, i.e. 2/year if TIME STEP = 0.5 year. In this form, it's easy to see that this term approaches 1 (no effect) in the continuous time limit as TIME STEP approaches 0.
Code: Select all
maturation 14 to 15 =
( ( Population 0 To 14 ) )
* ( 1
- mortality 0 to 14 )
/ 15
Units: Person/year
The fractional rate at which people aged 0-14 mature into the
next age cohort (MAT1#5).
**************************************************************
mortality 0 to 14=
IF THEN ELSE(Time = 2020 * one year, 1 / one year, mortality 0 to 14 table
( life expectancy/one year ) )
Units: 1/year
The fractional mortality rate for people aged 0-14 (M1#4).
**************************************************************
In the 'maturation 14 to 15' equation, the obvious issue is that '15' is a hidden dimensioned parameter. One might argue that this instance is 'safe' because 15 years is definitionally the residence time of people in the 0 to 15 cohort - but I would still avoid this usage, and make the 15 yrs a named parameter, like "child cohort duration", with a corresponding name change to the stock. If nothing else, this would make the structure easier to reuse.
The sneaky bit here, revealed by JJ's test, is that the '1' in the term (1 - mortality 0 to 14) is not a benign dimensionless number, as we often assume in constructions like 1/(1+a*x). This 1 actually represents the maximum feasible stock outflow rate, in fraction/year, implying that a mortality rate of 1/yr, as in the test input, would consume the entire outflow, leaving no children alive to mature into the next cohort. This is incorrect, because the maximum feasible outflow rate is 1/TIME STEP, and TIME STEP = 0.5, so that 1 should really be 2 ~ frac/year. This is why maturation wrongly goes to 0 in JJ's experiment, where some children remain to age into the next cohort.
In addition, this construction means that the origin of units in the equation are incorrect - the '15' has to be assumed to be dimensionless for this to work. If we assign correct units to the inputs, we have a problem:
Code: Select all
maturation 14 to 15 = ~ people/year/year
( ( Population 0 To 14 ) ) ~ people
* ( 1 - mortality 0 to 14 ) ~ fraction/year
/ 15 ~ 1/year
JJ's correction is:
Code: Select all
maturation 14 to 15=
( ( Population 0 To 14 ) )
* ( 1 - (mortality 0 to 14 * TIME STEP))
/ size of the 0 to 14 population
Code: Select all
( 1/TIME STEP - mortality 0 to 14 ) / (1/TIME STEP)
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: units for %
Good catch BTW. I've copied to my blog (with credit): https://metasd.com/2024/12/case-strict-unit-testing/
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/