我试图了解何时在 Modelica 中生成事件。在函数的上下文中,我注意到了我没想到的行为:函数似乎抑制了事件生成。
我很惊讶,据我所知,Modelica 参考文献中没有明确说明这一点。例如,如果我在 OpenModelica 1.17.0 的 OMEdit 中运行此模型
model timeEventTest
Real z(start=0);
Real dummy(start=0);
equation
der(z) = dummy;
algorithm
if time > 10 then
dummy := 1;
else
dummy := -1.;
end if;
end timeEventTest;
Run Code Online (Sandbox Code Playgroud)
我在 OMEdit 的求解器窗口中得到以下输出
### STATISTICS ###
timer
events
1 state events
0 time events
solver: dassl
46 steps taken
46 calls of functionODE
44 evaluations of jacobian
0 error test failures
0 convergence test failures
0.000122251s time of jacobian evaluation
The simulation finished …Run Code Online (Sandbox Code Playgroud)