使用内/外传播包

时间:2014-06-13 14:21:36

标签: modelica

我想在我的模拟中放置一个“系统”组件(类似于Modelica.Fluid.SystemModelica.Mechanics.MultiBody.World),所有其他组件都可以从中访问Medium包,以便设置整个流程图只能使用一次工作液。我的System定义如下:

model System  annotation(defaultAttributes="inner");
    replaceable package Medium = Modelica.Media.Interfaces.PartialMedium 
        annotation(choicesAllMatching=true);
    parameter Modelica.SIunits.Temperature T_amb=293.15;
    // ...
equation
    // empty
end System;

我使用System在其他组件中引用了outer System system;,因此我可以访问其中包含的所有变量/参数,例如system.T_amb。但是,试图像这样拉Medium包不起作用:

model MixingVolume
    outer System system;
    package Medium = system.Medium;
    // ...
equation
    // ...
end MixingVolume;

我收到一条消息,说基类“system.Medium”丢失了。 (这是从CATIA V6的Modelica环境中极其糟糕的德语翻译中重新翻译出来的,我注定要使用它 - 也许原始信息会提供更多信息。)我做错了什么?我很困惑,因为这......

model MixingVolume
    outer System system;
    Constant Integer nXi = system.Medium.nXi; // number of independent mass fractions
    // ...
equation
    // ...
end MixingVolume;

...工作正常,因此MixingVolume 看到system.Medium组件。有线索吗?非常感谢您的帮助。

1 个答案:

答案 0 :(得分:6)

您无法通过点表示法访问组件内的包。

如果第一个名称是仅在点组件之后的组件引用 参考或功能可以遵循。阅读Modelica规范: https://www.modelica.org/documents/ModelicaSpec32Revision2.pdf

如果允许使用system.Medium.nXi,则可能是该工具中的错误。