Hello everyone,
I am trying to define an equation that return a time value for a certain auxiliary variable value. I'll explain with an exemple : calculation of an evaporation time.
We want to know how long it takes for rainwater into a container to evaporate. At time=0, there is no water in the container. At time=40, the container begins to fill with water.
We define two variables A and B, respectfully the time when the container water level became positive and the first time after emptying (water level=0).
We can define the emptying time as B-A.
My question is : Is there a function to define those two variables ?
I checked Vensim's help, it seems that it doesn't exist but I may probably be wrong. I precise that I'm working on PLE+ .
Thank you all,
J.
Returning time value for a certain variable value ?
-
- Super Administrator
- Posts: 4865
- Joined: Wed Mar 05, 2003 3:10 am
Re: Returning time value for a certain variable value ?
Try the SAMPLE IF TRUE function, that should do what you need.
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: Returning time value for a certain variable value ?
SAMPLE IF TRUE solves this problem for advanced versions - I can't remember if it's available in PLE+, but I don't think so.
However, you can use a stock to keep track of times. Something like:
However, you can use a stock to keep track of times. Something like:
/*
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: Returning time value for a certain variable value ?
SAMPLE IF TRUE is available on PLE+ version, but I don't see how it can solve the problem.
Let's say A=SAMPLE IF TRUE (Container water volume>0, Time, 0), it will not give me the time corresponding to the first positive value for "Container water volume".
Is there a function that formalize that type of equantion : WHEN Container water volume>0, DO A=TIME(first value of "Container water volume">0) ?
J.
Let's say A=SAMPLE IF TRUE (Container water volume>0, Time, 0), it will not give me the time corresponding to the first positive value for "Container water volume".
Is there a function that formalize that type of equantion : WHEN Container water volume>0, DO A=TIME(first value of "Container water volume">0) ?
J.
Re: Returning time value for a certain variable value ?
See the third example in the SAMPLE IF TRUE help:
https://www.vensim.com/documentation/in ... f_true.htm
The key is to make the condition for updating the sample contingent on:
(a) input>0
(b) sample not yet taken
https://www.vensim.com/documentation/in ... f_true.htm
The key is to make the condition for updating the sample contingent on:
(a) input>0
(b) sample not yet taken
/*
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: Returning time value for a certain variable value ?
Thank you all for your answers, it really helps me !
Indeed, I used the third example for my model. I noticed the logical operator :NOT: prevent the variable to give strange results. I'm wondering how it can be so different by defining ":NOT: defined variable" as a first condition ?
Regards,
J.
Indeed, I used the third example for my model. I noticed the logical operator :NOT: prevent the variable to give strange results. I'm wondering how it can be so different by defining ":NOT: defined variable" as a first condition ?
Regards,
J.
Re: Returning time value for a certain variable value ?
If you don't include the :NOT: statement, the SAMPLE will update every time the condition is true, so you get the time of the most recent event, not the time of the first event. The logic is essentially the same as in the stock-flow version of the model that I posted.
Incidentally, Vensim uses C-style boolean logic. So, if you use a variable X as the condition in an IF THEN ELSE or SAMPLE IF TRUE, without a comparison like X=0, the condition is false if X=0 and true otherwise. That means that the :NOT: starting time expression only works if starting time is initialized to 0, as it is in the example.
Incidentally, Vensim uses C-style boolean logic. So, if you use a variable X as the condition in an IF THEN ELSE or SAMPLE IF TRUE, without a comparison like X=0, the condition is false if X=0 and true otherwise. That means that the :NOT: starting time expression only works if starting time is initialized to 0, as it is in the example.
/*
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
*/