question

Use this forum to post Vensim related questions.
Post Reply
elhamdavoodi
Junior Member
Posts: 13
Joined: Thu Nov 09, 2017 6:57 pm
Vensim version: PLE

question

Post by elhamdavoodi »

hi all,
i am master student in water resource management
i have a question in vensim model
how can put this equation in this model?

if A>0 , X(i)=0
else A<0, X(i)=X(i-1)+B
thanks. :)
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: question

Post by tomfid »

I'd be wary of such an equation, but you could implement it as:

x previous = DELAY FIXED(x,interval,x)
y = IF THEN ELSE( A>0, 0, x previous+B )
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: question

Post by Administrator »

elhamdavoodi wrote:hi all,
i am master student in water resource management
i have a question in vensim model
how can put this equation in this model?

if A>0 , X(i)=0
else A<0, X(i)=X(i-1)+B
thanks. :)
It might be better if you explain what you are trying to do, maybe we can figure out the correct equation.
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
elhamdavoodi
Junior Member
Posts: 13
Joined: Thu Nov 09, 2017 6:57 pm
Vensim version: PLE

Re: question

Post by elhamdavoodi »

Hi
I am using Vensim PLE V. 6.4 in my thesis. I had to use below equation in vensim model.
APWL: is accumulated potential water loss.
When surface infiltration>0, APWL =0,
When surface infiltration<0, APWL(i)=APWL(i-1)+Surface Infiltration(i)
i-1 is refer to APWL in one month ago.
I attached the sample of this equation.
please help me.
thanks.
Elham
Attachments
APWL.jpg
APWL.jpg (98.74 KiB) Viewed 6788 times
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: question

Post by Administrator »

Have a look at the attached model, it does something like you need.
forum water example.mdl
(2.55 KiB) Downloaded 177 times
The only issue is that things are delayed by a month, but that makes sense as in the table you uploaded, "surface infiltration" is almost certainly measured over the whole month, but APWL must be the value at the end of the month. Reducing the time step would make this look much better.
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
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: question

Post by tomfid »

This is why I hate discrete time notation. It obscures stock-flow relationships. I think it's responsible for a lot of errors, especially in economics and social sciences.

I would rewrite this as an ordinary stock and flow:

AWPL stock = INTEG( loss rate, initial AWPL ) ~ units of something
loss rate = MAX(0, - infiltration) ~ units of something/time
elhamdavoodi
Junior Member
Posts: 13
Joined: Thu Nov 09, 2017 6:57 pm
Vensim version: PLE

Re: question

Post by elhamdavoodi »

thanks a lot for your reply
I am very happy that this problem has been resolved, but the value of APWL from this model not equal with excel value. I edited value and attached this model and APWL value in excel. Please in this case, guide me
Attachments
APWL.jpg
APWL.jpg (98.74 KiB) Viewed 6767 times
forum water example.mdl
(2.58 KiB) Downloaded 169 times
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: question

Post by tomfid »

I don't see the Excel attachment.
elhamdavoodi
Junior Member
Posts: 13
Joined: Thu Nov 09, 2017 6:57 pm
Vensim version: PLE

Re: question

Post by elhamdavoodi »

I mean this is APWL photo that attached
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: question

Post by tomfid »

Your data is misaligned. In your screenshot, infiltration = -26.6 happens at time 4, but in the model it's at time 5.

Is APWL and indicator rather than a physical stock?
elhamdavoodi
Junior Member
Posts: 13
Joined: Thu Nov 09, 2017 6:57 pm
Vensim version: PLE

Re: question

Post by elhamdavoodi »

this model created by Administrator
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: question

Post by tomfid »

In that case, there's no discrepancy, other than the input. It should work.
elhamdavoodi
Junior Member
Posts: 13
Joined: Thu Nov 09, 2017 6:57 pm
Vensim version: PLE

Re: question

Post by elhamdavoodi »

Administrator wrote:Have a look at the attached model, it does something like you need.
forum water example.mdl

The only issue is that things are delayed by a month, but that makes sense as in the table you uploaded, "surface infiltration" is almost certainly measured over the whole month, but APWL must be the value at the end of the month. Reducing the time step would make this look much better.

thanks a lot for your reply
I am very happy that this problem has been resolved, but the value of APWL from this model not equal with excel value. I edited value and attached this model and APWL value in excel. Please in this case, guide me
Attachments
forum water example.mdl
(2.6 KiB) Downloaded 161 times
APWL.jpg
APWL.jpg (98.74 KiB) Viewed 6757 times
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: question

Post by tomfid »

It's hard to diagnose "different" without having the Excel and Vensim models running on exactly the same infiltration data for comparison. The difference could be roundoff, or it could be a difference in inputs.
elhamdavoodi
Junior Member
Posts: 13
Joined: Thu Nov 09, 2017 6:57 pm
Vensim version: PLE

Re: question

Post by elhamdavoodi »

tomfid wrote:It's hard to diagnose "different" without having the Excel and Vensim models running on exactly the same infiltration data for comparison. The difference could be roundoff, or it could be a difference in inputs.
Hi
thanks for your reply
I attached excel data of surface infiltration and the APWL data Which should be calculated with vensim. The vensim mosel that created by Administerator is work very good and APWL value are correct but this value have a 1 month delay. How i can solve this problem?
Attachments
Surface infiltration.xlsx
(15.5 KiB) Downloaded 153 times
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: question

Post by tomfid »

I think you'll have to use my original solution instead. Admin's version is more physically motivated, but there's no way to get rid of the lag in reporting the integration (though of course you could simply ignore it).

APWL previous = DELAY FIXED(APWL,TIME STEP,0)
APWL = IF THEN ELSE( infiltration>0, 0, APWL previous+infiltration )
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: question

Post by tomfid »

But again, if this is a physical process, not just accounting, it would be better to model it as a continuous time integration with TIME STEP << 1.
elhamdavoodi
Junior Member
Posts: 13
Joined: Thu Nov 09, 2017 6:57 pm
Vensim version: PLE

Re: question

Post by elhamdavoodi »

tomfid wrote:I think you'll have to use my original solution instead. Admin's version is more physically motivated, but there's no way to get rid of the lag in reporting the integration (though of course you could simply ignore it).

APWL previous = DELAY FIXED(APWL,TIME STEP,0)
APWL = IF THEN ELSE( infiltration>0, 0, APWL previous+infiltration )
Hi
Thanks for your reply
This method worked well.
Thankful :D :D :D
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: question

Post by Administrator »

Do you want to model the physical process, or just replicate the results from the Excel table?
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
elhamdavoodi
Junior Member
Posts: 13
Joined: Thu Nov 09, 2017 6:57 pm
Vensim version: PLE

????

Post by elhamdavoodi »

Hi every one
I have a question about vensim:
I have use the condition function that if X in the time series=Max, then X+b, X
X is the number in the time step
How i can do this?
the attached pic my concept
thanks a lot
Attachments
Capture.JPG
Capture.JPG (37.56 KiB) Viewed 6525 times
tomfid
Administrator
Posts: 3804
Joined: Wed May 24, 2006 4:54 am

Re: question

Post by tomfid »

If N is a proxy for time here, there are two answers.

1. This is acausal, i.e. it implies knowledge of the future, which is impossible both in reality and in the model.

2. If what you mean by MAX is the largest value encountered so far at time t, then it's possible. You could do the following:

maximum x = SAMPLE IF TRUE( x > maximum x, x, x)
y = IF THEN ELSE( x >= maximum x, x+b, x )
Post Reply