Dymola 中的初始化警告

Mar*_*vel 0 modelica dymola

在我的模型中,我对为什么没有完全指定初始条件感到困惑。

下面是代码和截图:

model WithAlgebraicLoop_Right
  extends Modelica.Icons.Example;
  Real x;
  Real y(start=1, fixed=true);
  Boolean cond;
equation 
  cond = x > 0.5;
  when pre(cond) then
    y = 1*time;
  end when;
  x = sin(y*10*time);
end WithAlgebraicLoop_Right;

Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

我认为在初始化期间,x可以从 计算y,所以cond可以从 计算x,那么为什么 Dymola 没有像我想的那样做呢?

tbe*_*beu 7

当然,离散时间变量cond可以根据给定的方程进行计算。但是,它在初始化时事件迭代的预值是未知的,必须通过设置固定的起始值或初始方程来设置,无论您喜欢什么。

model WithAlgebraicLoop_Right1
  Real x;
  Real y(start=1, fixed=true);
  Boolean cond(start=false, fixed=true);
equation 
  cond = x > 0.5;
  when pre(cond) then
    y = 1*time;
  end when;
  x = sin(y*10*time);
end WithAlgebraicLoop_Right1;
Run Code Online (Sandbox Code Playgroud)

或者

model WithAlgebraicLoop_Right2
  Real x;
  Real y(start=1, fixed=true);
  Boolean cond;
initial equation
  pre(cond) = false;
equation 
  cond = x > 0.5;
  when pre(cond) then
    y = 1*time;
  end when;
  x = sin(y*10*time);
end WithAlgebraicLoop_Right2;
Run Code Online (Sandbox Code Playgroud)

  • 顺便说一句,我更喜欢固定的起始值,因为您可以轻松地在组件中修改它们,而初始方程则不然。有关更多背景信息,请参阅此讨论:https://github.com/mtiller/ModelicaBook/issues/133 (3认同)