Page 1 of 1

Death by Subscript

Posted: Sat Apr 20, 2024 10:30 pm
by geo_curious
Hi,
As usual, I have no idea where to find coherent documentation on subscripts in the Vensim manual. I am trying to use the SUM() function for the equation shown. Pretty straightforward in reality. In Vensim it is like pulling teeth.
picture.png
picture.png (2.25 KiB) Viewed 556 times
Shown is what I have input into the variable:
picture2.png
picture2.png (7.31 KiB) Viewed 556 times
Shown is the function editor for the ground function:
picture3.png
picture3.png (503.32 KiB) Viewed 556 times
The SUBSCRIPTS error reads:
1. Unspecified subscript equation for -h
2. Subscript 1 of variable -ground function- is a member of the -h- family when it should be a member of the -pressure number- family.

Any thoughts on this? Please don't bother responding "impossible to tell without looking at the model."

Re: Death by Subscript

Posted: Sat Apr 20, 2024 11:27 pm
by tomfid
Looking at the model may not be required, but I'm not sure an answer can be given from the material here. What you're showing seems syntactically valid, so the problem may be somewhere else.

What are the definitions of h and pressure number?

What is on the left side of the sum expression?

Is h the equivalent of n in the equation png, which presumably defines the ground function? In that case why does it not appear on the right side of the equation?

Re: Death by Subscript

Posted: Sun Apr 21, 2024 1:17 am
by geo_curious
I need to counter this by asking what the SUM() function is. It does not appear that it is a large operator, upper case sigma. If it was, it would not need subscripts at all. h does nothing. It is a formality in an attempt to get SUM() to work like a sum. In the manual and in the program I cannot simply have SUM(ground function), I need to have SUM(ground function[pointless exclamation!]).

So, what does SUM() actually do as a mathematical use case?

Re: Death by Subscript

Posted: Sun Apr 21, 2024 8:02 am
by Administrator
The SUM function is used over a subscript range, and you can think of subscripts as an array.

Looking at the equation you are trying to implement, there is a sum over "n". So you would define the subscript range as
n : (n1-n2). But I cannot see "n" in the equation you've entered in Vensim, so I'm not sure what "n" actually is.

Re: Death by Subscript

Posted: Sun Apr 21, 2024 9:03 am
by LAUJJL
do the errors disappear if you suppress the sum function in the model, and is the ground function calculated? In that case the ground function does not look like depending on the subscript n and you should replace the sum function by ground function * elmcount'n). the answer to your question is in the model and you should show it!

Re: Death by Subscript

Posted: Sun Apr 21, 2024 1:12 pm
by tomfid
SUM is definitely the summation operator Sigma. The exclamation point is not useless; it is necessary in cases where you'd like to sum over a subset of the dimensions belonging to the right side.

I would write the equation in your image with something like the following:

n : n1, n2
s : <something>
amp : <something>

number[n] = INITIAL( n )
The subscript values for n will be an integer sequence starting with 1; you could also write something like,
number[n] = 1,2
to initialize to arbitrary constant values.

F[s,amp] = SUM( EXP(-z*SQRT(number[n!]*pi/stuff)*T[s,amp,n!] )

Re: Death by Subscript

Posted: Wed May 08, 2024 12:48 am
by geo_curious
Hi Tom,

Your last explanation made sense. I am not showing the model because I have already had my previous work copied and claimed by many other people.

In reflecting on this, I do not need the SUM() at all, since I can simply write in constants for this particular equation, which makes it all relatively pointless to pursue variations on n. N is simply the number of harmonics between 1 and 2 with all other values apparently linked to tabular field data. These values for T[s,amp,n] cannot be known without prior field measurements. There is also some phase lag in here, which is not reflected in the original post.

I could simply plug in a bunch of parameters to this equation and produce a curve. Relatively uninteresting in the end. I am still not confident with these subscripts, however. I really do think the documentation needs a full rewrite on this.