Modelica 初始化期间的非致命迭代错误
Modelica流体库试图具有能够从温度或焓初始化的有用属性。然而,在模拟日志中显示了一些有点神秘的错误 记录的错误似乎不会影响模拟,但它们不应出现,因为:Modelica 初始化期间的非致命迭代错误,modelica,Modelica,Modelica流体库试图具有能够从温度或焓初始化的有用属性。然而,在模拟日志中显示了一些有点神秘的错误 记录的错误似乎不会影响模拟,但它们不应出现,因为: 传递给temperature_phX的值应有效 使用\u T\u start=true,因此不应运行导致错误的“else”选项 下面是一段代码,当您运行“RunMe”时,该代码会复制错误,同时还有一个不会产生错误的选项。代表性错误在底部 任何关于如何解决这个问题的见解都将不胜感激 model InitialValuesSimplified
model InitialValuesSimplified
outer Modelica.Fluid.System system "System wide properties";
replaceable package Medium =
Modelica.Media.Water.StandardWater "Medium in the component";
parameter Medium.AbsolutePressure p_a_start=system.p_start
"Pressure at port a";
parameter Boolean use_T_start=true "Use T_start if true, otherwise h_start";
// Creates error log
parameter Medium.Temperature T_a_start=
if use_T_start then
system.T_start
else
Medium.temperature_phX(p_a_start,h_a_start,X_start)
"Temperature at port a";
// No error log
// parameter Medium.Temperature T_a_start=
// if use_T_start then
// system.T_start
// else
// system.T_start
// "Temperature at port a";
parameter Modelica.Media.Interfaces.Types.MassFraction X_start[Medium.nX]=
Medium.X_default "Mass fractions m_i/m";
parameter Medium.SpecificEnthalpy h_a_start=
if use_T_start then
Medium.specificEnthalpy_pTX(p_a_start,T_a_start,X_start)
else
1e5 "Specific enthalpy at port a";
end InitialValuesSimplified;
要运行代码段的代码:
model RunMe
InitialValuesSimplified initialValuesSimplified;
inner Modelica.Fluid.System system;
end RunMe;
错误代码示例:
Log-file of program ./dymosim
(generated: Mon Sep 12 17:15:19 2016)
dymosim started
... "dsin.txt" loading (dymosim input file)
T >= 273.15
The following error was detected at time: 0
IF97 medium function g1: the temperature (= 86.3 K) is lower than 273.15 K!
The stack of functions is:
Modelica.Media.Water.IF97_Utilities.BaseIF97.Basic.g1
Modelica.Media.Water.IF97_Utilities.waterBaseProp_pT
Modelica.Media.Water.IF97_Utilities.h_props_pT(
initialValuesSimplified.p_a_start,
initialValuesSimplified.T_a_start,
Modelica.Media.Water.IF97_Utilities.waterBaseProp_pT(initialValuesSimplified.p_a_start, initialValuesSimplified.T_a_start, 0))
Non-linear solver will attempt to handle this problem.
问题在于组合:
parameter Real T_start=if use_T then system.T_start else foo(3,h_start);
parameter Real h_start=if use_T then bar(4,T_start) else 2;
没有象征性地处理两种不同的情况(使用和不使用),因为这可能导致组合爆炸。相反,它被视为非线性方程-计算h_开始,但不影响结果t_开始
如果您不打算更改这些参数,可以将其设置为最终值,并在第一个等式中用合适的默认值替换h_start。
否则,解决方案是为T_a_start提供更好的开始值:
parameter Real T_start(start=300)=if use_T then system.T_start else foo(3,h_start);
请注意,问题不是缺少起始值,而是默认起始值(500K)太远,解算器会进行过度补偿,并在收敛到293.15K之前达到86K。(非线性解算器可能会得到改进,以避免过度补偿。)