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?
Powersim arrays- Vensim subscripts?
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
More subscripts
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.
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
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.
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.
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
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am