Modelica评估单 [英] Modelica Evaluation Order

查看:111
本文介绍了Modelica评估单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Modelica规范中我真的找不到任何答案,请病态的你们问.规范指出 A tool is free to solve equations, reorder expressions and to not evaluate expressions if their values do not influence the result (e.g. short-circuit evaluation of Boolean expressions). If-statements and if-expressions guarantee that their clauses are only evaluated if the appropriate condition is true, but relational operators generating state or time events will during continuous integration have the value from the most recent event. If a numeric operation overflows the result is undefined. For literals it is recommended to automatically convert the number to another type with greater precision. 现在,我想知道,该工具是否可以选择在积分器步骤中多次评估表达式?例如(可能不是一个有效的例子,只是为了让大家知道我在想什么:))

I can't really find any answer in the Modelica specification so ill ask you guys. The specification states that A tool is free to solve equations, reorder expressions and to not evaluate expressions if their values do not influence the result (e.g. short-circuit evaluation of Boolean expressions). If-statements and if-expressions guarantee that their clauses are only evaluated if the appropriate condition is true, but relational operators generating state or time events will during continuous integration have the value from the most recent event. If a numeric operation overflows the result is undefined. For literals it is recommended to automatically convert the number to another type with greater precision. Now, I wonder, can the tool choose to evaluate an expression several time in an integrator step? For example (probably not an valid example, just to give you guys an idea of what I was wondering :) )

Real x;

equation
  der(x) = -t;
  Modelica.Utilities.Streams.print(String(time));

这将同时打印几次,所以我发现正在进行某种迭代.但是我真的很想得到一些消息来源的确认.

This will print the same time for several times, so I figured that there is some kind of iteration going on. But I would really like to have it confirmed by some source.

推荐答案

那是正常的. 可变步长求解器(如dassl)可以返回 及时找到曲线的方向. 另外,如果您有事件,则可以生成更多值 同时.

That is normal. Variable step size solvers (like dassl) can go back and forth in time to find the direction of the curve. Also, if you have events more values can be generated at the same time.

如果您想仅在精确的时间点打印时间或值,则需要在方程式时:

If you want to print time or values just at exact time instants you need when equations:

when sample(0, 1) then
  Modelica.Utilities.Streams.print(String(time));
end when;

在Modelica Spec中了解有关示例的更多信息.

Read more in the Modelica Spec about sample.

还可以使用诸如Euler之类的固定步长求解器.

Is also possible to use fixed step size solvers like Euler or so.

这篇关于Modelica评估单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆