Hi,
Relating to viewtopic.php?p=33432, I would like to take an output from an auxiliary variable that has a subscript dependency, placing it into a subsequent function without requiring the subsequent function to also be dependent on the subscript.
For example,
Where:
gfunction output[borehole array size] = gfunct subscript[borehole array size]
I would like to avoid subsequent dependency, using only the value of the output from the previous function, such as:
wall temperature = initial temp+temp change+((q/(2*pi*k)*gfunction output))
This does not appear to be possible without inheriting a subscript error. Is there a work around? I have so many dependencies, that I do not want to introduce an erroneous subscript requirement for each of many auxiliary variables such as the one shown here.
Eliminating Subscript Dependency in Subsequent Equations
-
- Senior Member
- Posts: 139
- Joined: Tue Mar 14, 2023 2:05 am
- Vensim version: DSS
Re: Eliminating Subscript Dependency in Subsequent Equations
You can use VECTOR SELECT or SUM for this, combined with an indicator variable that shows which of the RHS elements to select.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Eliminating Subscript Dependency in Subsequent Equations
k : k1-k10
y[k] = x[k]
y active[k] = IF THEN ELSE( k=3, 1, 0)
y out = SUM( y[k!]*y active[k!] )
Another option for picking a single value would be,
y out = VECTOR ELM MAP( y[k1], offset )
where offset is the index of the value you want as a 0-based offset from k1.
y[k] = x[k]
y active[k] = IF THEN ELSE( k=3, 1, 0)
y out = SUM( y[k!]*y active[k!] )
Another option for picking a single value would be,
y out = VECTOR ELM MAP( y[k1], offset )
where offset is the index of the value you want as a 0-based offset from k1.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
-
- Senior Member
- Posts: 139
- Joined: Tue Mar 14, 2023 2:05 am
- Vensim version: DSS
Re: Eliminating Subscript Dependency in Subsequent Equations
So far as I can tell, it is not true that SUM() prevents the propagation of subscripts in subsequent equations. I cannot get anything to run, whatever the case, but here is one example where SUM() is doing nothing to prevent propagation of subscripts:
Gives "incorrect number of subscripts for gfunct subscript" error:
gfunct selected[borehole array size, Interval,Instance]= INITIAL(
sum(
IF THEN ELSE ( array size selected = array size[borehole array size!]
,gfunct subscript[borehole array size!, Interval!, Instance!]
,0)
))
~ Dmnl
~ |
Still requires (depends on) subscripts from gfunct selected and will not run:
borehole wall temp Tb[borehole array size,Interval,Instance]=
initial production temperature
+sum(gfunct selected*diff dQ[Interval!,Instance!])
*c0
~ Celsius
~ |
Also, it is a bit excruciating to have to come back to the forum every time there is an error with subscripts. The error handling message should read what the problem is specifically - like the number of subscripts expected or why else something is wrong, etc. That is a suggestion!
Gives "incorrect number of subscripts for gfunct subscript" error:
gfunct selected[borehole array size, Interval,Instance]= INITIAL(
sum(
IF THEN ELSE ( array size selected = array size[borehole array size!]
,gfunct subscript[borehole array size!, Interval!, Instance!]
,0)
))
~ Dmnl
~ |
Still requires (depends on) subscripts from gfunct selected and will not run:
borehole wall temp Tb[borehole array size,Interval,Instance]=
initial production temperature
+sum(gfunct selected*diff dQ[Interval!,Instance!])
*c0
~ Celsius
~ |
Also, it is a bit excruciating to have to come back to the forum every time there is an error with subscripts. The error handling message should read what the problem is specifically - like the number of subscripts expected or why else something is wrong, etc. That is a suggestion!
-
- Super Administrator
- Posts: 4845
- Joined: Wed Mar 05, 2003 3:10 am
Re: Eliminating Subscript Dependency in Subsequent Equations
Try removing the @"[borehole array size, Interval,Instance]" from the left hand side of the equation for "gfunct selected".
gfunct selected= INITIAL(
sum(
IF THEN ELSE ( array size selected = array size[borehole array size!]
,gfunct subscript[borehole array size!, Interval!, Instance!]
,0)
))
gfunct selected= INITIAL(
sum(
IF THEN ELSE ( array size selected = array size[borehole array size!]
,gfunct subscript[borehole array size!, Interval!, Instance!]
,0)
))
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
-
- Senior Member
- Posts: 139
- Joined: Tue Mar 14, 2023 2:05 am
- Vensim version: DSS
Re: Eliminating Subscript Dependency in Subsequent Equations
Removing the subscripts from the left hand side did not prevent the error. The equation still returns "Incorrect number of subscripts for -gfunct subscript-."
I am posting a smaller version of this model to troubleshoot here. A change from some posts that Tom had previously helped me work through is that this model is trying to select a borehole array size from table data, instead of using a fixed lookup. With that change I have the addition of one more subscript (array size), and now another error to figure out. Thank you for any assistance you might offer here.
I am posting a smaller version of this model to troubleshoot here. A change from some posts that Tom had previously helped me work through is that this model is trying to select a borehole array size from table data, instead of using a fixed lookup. With that change I have the addition of one more subscript (array size), and now another error to figure out. Thank you for any assistance you might offer here.
-
- Senior Member
- Posts: 139
- Joined: Tue Mar 14, 2023 2:05 am
- Vensim version: DSS
Re: Eliminating Subscript Dependency in Subsequent Equations
Ok, I solved my own problem. The starting point of the subscript use needed to be added to the Excel data variable. I also omitted a few subequations in the first posting of the mdl. Here is the corrected .mdl, that will run.