pre 代码生成中的内部错误

Mar*_*vel 0 modelica dymola

我试图通过使用pre运算符来避免 Modelica 中的代数循环,但是当我使用类似的东西时pre(x>0.5),会出现Internal error in code generation for pre. 如果我使用pre(cond), wherecond是一个布尔类型变量,就不会有任何错误。

我的问题是:是否有一些pre运算符规定要求我不能在pre运算符中使用表达式。

下面是代码和截图:

model WithAlgebraicLoop_Wrong2
  "Demonstration of how to avoid generating algebraic loop,
  but end up with internal error in code generation for pre"
  Real x,y(start=1,fixed=true);
equation 
  when pre(x>0.5) then
    y=1*time;
  end when;
  x=sin(y*10*time);
end WithAlgebraicLoop_Wrong2;
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

model WithAlgebraicLoop_Right "Demonstration of how to avoid generating algebraic loop"
  Real x,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)

在此处输入图片说明

tbe*_*beu 7

您可以在 Modelica 语言规范(关于事件相关运算符的第 3.7.3 节-> 表)中读到,参数pre需要是一个变量,而不是一个表达式。