在PedanticMode中通过Dymola中的连接进行条件声明和反馈

时间:2014-10-21 15:12:57

标签: conditional declaration modelica

我有条件地声明如下所述的组件:conditional component decleration and a following if equation
在主模型中,我想使用在组件中计算的变量。虽然可以使用条件声明来完成对组件的输入,但只能通过连接返回值,如果未声明组件,则会删除该连接。在DYMOLA中,自动删除会发出警告,这是迂腐代码检查模式中的错误 随着
    Advanced.PedanticModelica:=真
如何使以下示例有效?

model conditionalComponent
//  parameter Boolean useVar=true;
  parameter Boolean useVar=false;

  yConnector conn;
  component props(x = 5) if useVar;

  connector yConnector
    Real y;
  end yConnector;

  model component
    input Real x;
    yConnector conn;
  equation 
    conn.y = 2*x;
  end component;

  Real y;
equation 
  connect(conn,props.conn);
  if useVar then
    y=conn.y;
  else
    y=0;
  end if;
end conditionalComponent;

1 个答案:

答案 0 :(得分:3)

对我来说,它甚至在迂腐模式下也能在Dymola中奏效。我得到的唯一消息(不是警告)是“假设与非物理连接器的连接施加了适当的约束”。这是因为只包含潜在变量且没有流量的连接器不是物理连接器。