The internal error shown is also preventing SystemModelSimulate[ ]
from running a model that contains a simultaneous inner outer
declaration (WSM will simulate a model despite an internal error message). Good to know, that it will be addressed as a Bug.
As far as I understand it now, the behavior for TestingInnerOuter_3 makes sense:
- Inside the local scope of
Submodel
the outer
definition is used which references the inner
declaration of an enclosing scope (e.g. the positive values declared in the MainModel).
- Any
outer
declaration in the scopes below Submodel (e.g. "Sub-Submodels") will then use the inner
declaration which has been modified or rather been given a declaration equation (so then the negative values will apply).
To make this clearer:
package TestInnerOuter
block Submodel
inner outer parameter Integer x = -1;
output Integer y;
Subsubmodel ssm;
equation
y = x;
end Submodel;
block Subsubmodel
outer parameter Integer x;
output Integer y;
equation
y = x;
end Subsubmodel;
model MainModel
inner parameter Integer x = 1;
Submodel sm;
end MainModel;
end TestInnerOuter;
Running the model reveals, that sm.y = 1
(e.g. it uses the global inner
declaration for x
via the outer
part of the inner outer
declaration inside of sm
).
The declaration equation inside of Submodel sm
changes the inner
declaration for sm.x
which is then referenced by the outer
declaration in the nested Subsubmodel ssm
.
Accordingly ssm.y = -1
.
It is rather tricky business and my intended use case was a different one, as I had though that the declaration equation for an inner outer
variable would be overridden by the enclosing inner declaration. But, as shown, that is not the case:
A declaration equation for a simultaneous inner outer
variable will override enclosing inner definitions and will serve as a modified inner
declaration referenced by corresponding outer
declarations in nested (inside) scopes.
Regards.
Guido