当我在Wolfram Systemmodeler中尝试这个简单的modelica代码时:
model bug
Integer y(start = 1);
equation
when time > 0.2 then
y = 5 "y = 2";
elsewhen time > 0.4 then
y = 4 "y = 3";
elsewhen time > 0.6 then
y = 3 "y = 4";
elsewhen time > 0.8 then
y = 2 "y = 5";
end when;
end bug;
结果是1,2,3,4,5,如下所示:Model bug simulatiom。时间方程似乎以相反的顺序激活。
另一方面,改变"等式"到"算法"和(当然)" ="到":="代码变成了:
model nobug
Integer y(start = 1);
algorithm
when time > 0.2 then
y := 5;
elsewhen time > 0.4 then
y := 4;
elsewhen time > 0.6 then
y := 3;
elsewhen time > 0.8 then
y := 2;
end when;
end nobug;
,结果如预期的那样,1,5,4,3,2,如下所示:Model nobug simulation
这是Wolfram SystemModeler实现中的一个相对基本的问题,还是有其他我看不到的东西?