You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法在Dymola中添加匹配所有选项的选择器问题求助

问题:无法添加继承模型的框式选择器

我正在学习部分模型(partial model)和扩展模型(extended model)的相关内容,已经能从父级(部分)模型创建继承(扩展)模型,也能在兄弟类之间切换,但无法添加教程中所示的针对所有兄弟类的框式选择器。以下是我的代码:

Model 'a'

partial model a
  Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a port_a annotation (
      Placement(transformation(rotation=0, extent={{-110,-10},{-90,10}})));
  Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_b port_b annotation (
      Placement(transformation(rotation=0, extent={{90,-10},{110,10}})));
  annotation (uses(Modelica(version="3.2.3")), Icon(graphics={Text(
          extent={{-100,102},{98,-98}},
          lineColor={28,108,200},
          textString="A")}));
end a;

Model 'b'

model b
  extends a;

  Modelica.Thermal.HeatTransfer.Components.ThermalResistor thermalResistor(R=3)
    annotation (Placement(transformation(extent={{-10,-10},{10,10}})));

equation 
  connect(port_a, thermalResistor.port_a)
    annotation (Line(points={{-100,0},{-10,0}}, color={191,0,0}));
  connect(port_b, thermalResistor.port_b)
    annotation (Line(points={{100,0},{10,0}}, color={191,0,0}));


  annotation (Icon(graphics={Text(
          extent={{26,96},{98,12}},
          lineColor={28,108,200},
          textString="B")}));
end b;

Model 'assembly'

model assembly
  Modelica.Thermal.HeatTransfer.Sources.FixedTemperature fixedTemperature(T=274.15)
    annotation (Placement(transformation(extent={{-60,40},{-40,60}})));
  Modelica.Thermal.HeatTransfer.Sources.FixedTemperature fixedTemperature1(T=275.15)
    annotation (Placement(transformation(extent={{40,40},{20,60}})));
  replaceable b a1 constrainedby a annotation (choicesAllMatching=true, Placement(transformation(extent={
            {-20,40},{0,60}})));
equation 
  connect(fixedTemperature.port, a1.port_a)
    annotation (Line(points={{-40,50},{-20,50}}, color={191,0,0}));
  connect(a1.port_b, fixedTemperature1.port)
    annotation (Line(points={{0,50},{20,50}}, color={191,0,0}));
  annotation (uses(Modelica(version="3.2.3")));
end assembly;

实现与教程的差异分析

  • 模型数量与组织:教程中应该包含多个继承自a的子模型(比如b、c等),且所有父模型、子模型都放在同一个Package(包)下。你目前仅定义了b一个子模型,Dymola没有可切换的其他选项,自然不会显示框式选择器。
  • Dymola功能设置:需检查Dymola的选项配置,确保开启了显示可替换组件选择器的功能(路径大致为:Options > Settings > Modelica,勾选类似Show replaceable components as selectors的选项,不同版本名称略有差异)。
  • 匹配机制触发:choicesAllMatching=true的作用是自动扫描所有符合constrainedby a的模型,但如果没有多个同包的子模型,或者模型组织不符合规则,这个机制无法生成可选择的列表。

内容的提问来源于stack exchange,提问作者Gustavo Exel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 23:00:26