Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

double inclusion of a partial model via "extends"

double inclusion of a partial model via "extends"

Hello,

I noticed that the model DynamicPipe has via the extension of other models, the partial model PartialTwoPort two times in the declaration.
The definition of the model DynamicPipe reads

Code:

model DynamicPipe

   extends Modelica.Fluid.Pipes.BaseClasses.PartialStraightPipe
   ...
   extends BaseClasses.PartialTwoPortFlow
   ...

Thus PartialTwoPort is a first time via:
model DynamicPipe extends Modelica.Fluid.Pipes.BaseClasses.PartialStraightPipe ->
partial model  PartialStraightPipe extends Modelica.Fluid.Interfaces.PartialTwoPort

and a second time via:
model DynamicPipe extends extends BaseClasses.PartialTwoPortFlow ->
partial model PartialTwoPortFlow extends Modelica.Fluid.Interfaces.PartialTwoPort
present in the model.

Until now, I was not aware that such a construct would work. I must admit, that I have only little experience with modelica. In Fritzson's book OOMS with Modelica I could, however, not find an example discussing such a situation. If I want to write a new model MyDynamicPipe which is similar but not identical to DynamicPipe, do I have to pay attention, that the order of declaration is unchanged or something else?

al

Edited by: alberich - Jan-31-14 00:05:54

Re: double inclusion of a partial model via "extends"

The order of components matter for records and functions. Maybe connectors; I am not sure about those. In general order does not matter in Modelica. And this is why inheriting the same class twice works (as long as every modifier is the same; this is hard to guarantee so it is not recommended to abuse this pattern).

There are 0 guests and 0 other users also viewing this topic
You are here: