- Index
- » Programming
- » Modelica Language
- » double inclusion of a partial model...
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
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).
- sjoelund.se
- 1700 Posts
- Index
- » Programming
- » Modelica Language
- » double inclusion of a partial model...