理解 dymola 错误消息的问题 [英] Problems understanding a dymola error message

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

问题描述

谁能给我一个提示代数环"是什么意思——以及我应该如何通过添加预"运算符来应对这种情况?我真的不明白...

Can anyone give me a hint what "algebraic loop" means -- and how I am supposed to cope with this situation by adding "pre"-operators? I'm seriously not getting it...

Error: Failed to generate code for an algebraic loop
involving when equations or algorithms with when parts.
Unknowns:
  pump.Hb_flow
  pump.medium.d
  pump.medium.h
  pump.medium.state.melting
  pump.medium.state.T
  pump.V_flow
  pump.V_flow_single
  pump.W_single

Equations:
  algorithm 
    when Modelica.SIunits.Conversions.to_degC(pump.medium.state.T) < 13.9 then
      pump.medium.state.melting := true;
    elsewhen Modelica.SIunits.Conversions.to_degC(pump.medium.state.T) > 32.8       then
      pump.medium.state.melting := false;
    end when;
  // [removed set of equations that contained no "when"]

You may be able to cut the loop 
by putting 'pre' around some of the references to
unknown continuous time variables in when parts or when conditions.

提前致谢,最好的问候

蒂莫.

推荐答案

这个问题通常是因为 when 子句中的方程会影响触发它们的条件语句.

This problem is, in general, because the equations within the when clause impact the conditional statement that triggers them.

您需要了解 Modelica 的一点是,求解器将使用候选解"作为模拟过程的一部分来评估方程.这些不一定是它最终会选择的解决方案,但它仍然需要在接近最终解决方案时对其进行评估.

The thing that you need to understand with Modelica is that a solver will evaluate equations using "candidate solutions" as part of the simulation process. These are not necessarily the solution it will eventually choose, but it nevertheless needs to evaluate them as it approaches the eventual solution.

这有什么关系?好吧,在您的情况下,我看到您正在更改熔化"变量的值.但是,如果该值随后影响介质温度(触发熔化"值的变化),则该工具将检测到方程组中的不一致.一个工具可能能够通过迭代找到一致的候选解决方案,但 Dymola 只是踢"并说它不支持这种情况.

How is this related? Well in your case I see that you are changing the value of a "melting" variable. But if that value then influences the medium temperature (which triggered the change in the value of "melting") then the tool will detect an inconsistency in the system of equations. A tool might be able to iterate to find a consistent candidate solution, but Dymola just "punts" and says it doesn't support such situations.

现在,这里要了解的重要一点是,基本上这通常都是无关.为什么?因为在大多数情况下,用户真的不希望在这种情况下使用 when 子句的默认语义.大多数用户想要的是将 when 子句中的条件视为原因",将 when 子句中的等式视为结果".从这个意义上说,它们是连续的,结果不应该反过来影响原因(尽管白色条纹写了一首关于这种情况的好歌;-)).

Now, the important thing to understand here is that basically this is usually all irrelevant. Why? Because for the most part user's really don't want the default semantics of when clauses in such cases. What most users want is to treat the condition in the when clause as a "cause" and the equations inside the when clause as an "effect". In this sense, they are sequential and the effect should not turn around and affect the cause (although the White Stripes wrote a great song about such situations ;-)).

这里的一般模式是隔离条件,然后在 when 子句中添加一个pre"运算符.如果原始模型如下所示:

The general pattern here is to isolate the condition and then add a "pre" operator around it in the when clause. If the original model looked like this:

model Test
...
equation
  when x>12.5 then
    // equations involving y
  end when;
  // equations coupling x to y
end Test;

您只需要将模型重构为如下所示:

You just need to refactor the model into something like this:

model Test2
...
  Boolean cond;
equation
  cond = x>12.5;
  when pre(cond) then
    // equations involving y
  end when;
  // equations coupling x to y
end Test;

这里的本质是涉及 y 的方程只出现在之后条件为真.在这种情况下,'pre' 基本上是说,如果在当前时间减去一些 epsilon,条件 的值 为真,那么(作为响应)when 子句中的等式就会启动.

The essential thing here is that the equations involving y only come after the condition is true. The 'pre' in this case basically says that if, at current time minus some epsilon, the value of condition was true then (in response) the equations in the when clause kick in.

这种情况会导致一种称为喋喋不休"的情况,其中条件的值随着时间的每一个epsilon"而翻转,但这意味着问题没有很好地提出.

Such situations can lead to a condition called "chattering" where the value of the condition flips for every "epsilon" of time that passes, but this means that the problem is not well posed.

我希望这是有道理的.我承认在复杂的情况下,很难准确地检测到代数环存在的位置(尽管 Dymola 试图为您提供一些诊断).此外,在某些情况下,您确实需要 Modelica 的默认行为,因此您并不总是想要添加无偿的预"限定符.

I hope this makes some sense. I admit that in complex cases, it can be hard to detect exactly where the algebraic loops exist (although Dymola tries to give you some diagnostics). Also, in some cases you do want the default behavior of Modelica so you don't always want to add gratuitous 'pre' qualifiers.

如果您对此解释有任何疑问,请告诉我.

Let me know if you have any questions on this explanation.

这篇关于理解 dymola 错误消息的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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