Powersim arrays- Vensim subscripts?

Use this forum to post Vensim related questions.
Post Reply
mruud
Member
Posts: 23
Joined: Fri Mar 28, 2003 7:19 am

Powersim arrays- Vensim subscripts?

Post by mruud »

I am working with transferring some old Powersim models to Vensim, and have run into a problem that I need some help with.

The simplified version of the problem is:
I have a model with an array of levels named Level and a array of rates named Rate. Between the levels there are flows going from Level(1) to Level(2) with size Rate(1), from Level(2) to Level(3) with size Rate(2) and so on.
In Powersim the array elements are identified by an index variable, in this case A. Then there will be a general equation in the Level-array:
-dt*(Rate(A) WHEN A<LAST(A) BUT 0)
+dt*(Rate(A-1) WHEN A>FIRST(A) BUT 0)
In Vensim I suppose I could use subscripts and create a unique equation for each level. But as the level array has a large number of elements this would be a bad solution. How could I inVensim have a general expression where you referee to array elements before and after the one you are working with?
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

There is a demo model in the

C:\Program Files\Vensim\models\sample\EXTRA

directory called TUBS.MDL.

This demonstrates subscript mapping, water flowing out from one tub flows into the next one. This should do what you need.

Tony.
mruud
Member
Posts: 23
Joined: Fri Mar 28, 2003 7:19 am

More subscripts

Post by mruud »

So far, so good. The next step is to have a bidirectional flow between the levels, and to control this flow with the gap between to levels. Se attached model sketch.
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

All flows in Vensim are bidirectional - they just depends on the sign on the rate. For example to equalize two levels

flow = (level 1 - level2)/time to equalize levels
level1 = INTEG(-flow,init level 1)
level2 = INTEF(flow,init level 2)

Similar with subscripts - though the details are a little messier.
mruud
Member
Posts: 23
Joined: Fri Mar 28, 2003 7:19 am

Post by mruud »

My problem is probably related to how to use subscripts. I continuously getting an error message referring to balancing equations left and right side. I have attached a modified version of the tub-model….
Attachments
TUBS_tst04_puls.MDL
(3.23 KiB) Downloaded 119 times
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

Does modifiying the equation for lowtub to the following do what you want?

lowtub : T2, T3, T4, T5 -> hightub

Tony.
Post Reply