Group Abstract Group Abstract

Message Boards Message Boards

1
|
16.6K 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

Malte,

that remark pertains to my experience from the library I am building where Simulation Center indeed does surprise me with building a simulation despite the internal error being reported upon validation (I have a block-based class there, that I can test without problems in Simulation Center but not via SystemModelSimulate which is my preferred way of testing using VerficationTest to build a battery of unit tests).

I will try to come up with a "minimal example" for this behavior shortly and accordingly update this post.

Guido

UPDATE

Ok, while I cannot quickly come up with a minimal example, I have checked now and I must make my statement more precise.

I have a "converter" (block) that models an n-th order exponential (information-) delay called SmoothN. Validating this component will give the internal error (i.e. hd Check failed). The error will not be given if the inner outer declaration for a parameter in some subcomponent of that class is changed to a mere outer declaration.

I have instantiated this component in a model that has a corresponding inner declaration in the outside scope and then everything will work fine in Simulation Center. But I have no chance to run the model using SystemModelSimulate: apparantly the missing inner declaration in the outer scope prevents the model to run.

I can provide the library with the full example if you want by Mail.

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

In the example TestingInnerOuter2, my understanding is that when declaring an “inner outer” component it behaves as an outer in its scope, but as inner for its subcomponents. Seems like the problem here is that the modelica compiler is expecting to receive a binding for the outer part of the component. That’s why your example TestingInnerOuter3 works.

In example TestingInnerOuter_3, it’s not clear to me what’s the value that submodel.x and submodes.y should display. To any submodel containing an outer the values seen should be the negative, but in its own context they should be the positive. Seems like the SimulationCenter is picking the first case.

Regarding your Update 1, every time that there’s a component declared as outer (no matter if it’s inner as well), when a matching inner is not found, the warning is displayed.

Your Update 2 example seems to be a bug because is reported as an Internal Error. I’m not sure why this is happening.

All your examples have been sent to the developers.

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