How can I get the input and output causality of connectors in the flattened model?

5 posts / 0 new
Last post
baharev
Offline
Joined: 2011-09-16
How can I get the input and output causality of connectors in the flattened model?

I am trying to get the topological information of Modelica models (connections of the components, how the components are nested hierarchically, etc). It turns out that almost everything can be fairly easily reconstructed from the modelDescription.xml; I already have a Python prototype that works reasonably well for easier models.

All my models are causal. The difficulty is that the input and output information on the connectors seem to be lost.

I have attached a simple model; the commands that I used for flattening are at the bottom of the model in comments. I expected the causality attributes in the modelDescription.xml to be "input" and "output" accordingly but they are "internal".

Am I doing something wrong?

Would it be possible to somehow tell the JModelica compiler to write this information (input or output on connectors) to the modelDescription.xml?

A quite hackish workaround is to manually tag the connectors in the .mo file with "in" and "out" (see the attached file); then I get these strings in the description attribute. This gives me a workaround for the time being but it is obviously not a solution.

Many thanks,

Ali

jmattsson
Offline
Joined: 2009-10-18
Not possible

Hi Ali,

I'm sorry, but that isn't possible. The contents of the modelDescription.xml file is defined by the FMI standard, and the causality attribute of the variable declarations is defined to be the causality with respect to the FMU, not to the components in the original Modelica code.

The compiler actually discards the input/output prefixes right after error checking for all variables that will not become inputs/outputs of the FMU.

Jesper

baharev
Offline
Joined: 2011-09-16
Vendor specific extensions?

Hi Jesper,

That sounds quite disappointing. To make things even worse, it turns out that I would actually need even more information.

For example, given the identifier "condenser.reflux.f[2]", I would like to somehow magically know that in the original Modelica model (before flattening) "reflux" was of connector type and it also had an output prefix.

I understand that the FMI standard does not require that one can recover such a piece of information, but I guess the standard doesn't forbid it either that some additional (perhaps vendor specific) information is written into the XML file that makes it possible.

If one can recover this structural information that I am looking for, then it is also possible to identify good variables for tearing and to do an astonshing reduction with tearing.

It would be a very useful feature: Good tearings would be beneficial for the whole community.

Thanks,

Ali

jmattsson
Offline
Joined: 2009-10-18
Interfacing with compiler

Hi Ali,

 Vendor specific annotations would be a possible way of adding such information to the FMU, yes. I'm afraid I misunderstood your original request - the causality attribute must be set in the way that we currently do. All structural information is removed after the model is flattened, so we do not currently have any facilities to generate such information in the FMU.

Such structural information is however available by interfacing directly with the compiler. This can be done from Python with Jpype (one of the required Python packages for JModelica.org), or with a Java program. Some basic information on how to do this is in chapter 11 of the User's manual. As for what methods to call to get the required information, you'll need to refer to the source code. The things you already mentioned should be covered by isConnector(), isInput() and isOutput() on InstComponentDecl.

Jesper

 

baharev
Offline
Joined: 2011-09-16
Re: Interfacing with compiler

Hi Jesper,

Great, thanks for the info! I will look into that and get back to you if I still have questions.

Ali

Login or register to post comments