我试图通过使用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)
| 归档时间: |
|
| 查看次数: |
65 次 |
| 最近记录: |