Message Boards Message Boards

1
|
12261 Views
|
5 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How to use inner and outer correctly?

5 Replies

Hi Guido,

thanks for your update, this sounds like a known bug in the product where we fail to add the automatic inner declaration to a inner outer declaration.

I have added you to the list of reporter so that we can contact you when it is fixed.

As you pointed out, a workaround is to add by hand the missing inner declaration at the top level of your model.

Quentin

POSTED BY: Quentin Lambert

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).

Which example are you referring to here? The InnerOuterTest.UsesComponentWithInnerOuterParameter in your Update 2 doesn't build for me in Simulation Center either (which is expected when there is an internal error).

POSTED BY: Malte Lenz

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

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract