Page 1 of 1

Powersim arrays- Vensim subscripts?

Posted: Mon Feb 12, 2007 7:19 am
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?

Posted: Mon Feb 12, 2007 8:11 am
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.

More subscripts

Posted: Tue Feb 20, 2007 10:48 am
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.

Posted: Tue Feb 20, 2007 12:11 pm
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.

Posted: Wed Feb 21, 2007 8:23 am
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….

Posted: Wed Feb 21, 2007 11:49 am
by Administrator
Does modifiying the equation for lowtub to the following do what you want?

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

Tony.