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