如何解决与OpenModelica模型中不存在的变量相关的错误?

如何解决与OpenModelica模型中不存在的变量相关的错误?,modelica,openmodelica,Modelica,Openmodelica,我目前正在建造一个热回收蒸汽发生器,刚刚从热电库开始建造,并将蒸发器连接到省煤器。 尝试模拟时,OMEdit模拟器内发生错误: 在时间0处除以零,(a=-458389.9207317767)/(b=0),其中除数b表达式为:8.7598880677792*省煤器.metalTube.Am*省煤器.metalTube.rhomcm*/Real/(省煤器.metalTube.Nt) 如果我无法定义或定位导致b=0的所需变量,如何准确地排除此错误? 请让我知道你对此的看法。非常感谢您的时间和精力 我并

我目前正在建造一个热回收蒸汽发生器,刚刚从热电库开始建造,并将蒸发器连接到省煤器。 尝试模拟时,OMEdit模拟器内发生错误:

在时间0处除以零,(a=-458389.9207317767)/(b=0),其中除数b表达式为:8.7598880677792*省煤器.metalTube.Am*省煤器.metalTube.rhomcm*/Real/(省煤器.metalTube.Nt)

如果我无法定义或定位导致b=0的所需变量,如何准确地排除此错误? 请让我知道你对此的看法。非常感谢您的时间和精力

我并不擅长调试我的模型,但我有一个想法,并且在解决这个问题时遇到了一些困惑。我最初的困惑是验证哪个变量导致了b=0。然而,在检查时,我注意到可变省煤器.metalTube.Nt、省煤器.metalTube.Am如何不存在于我的省煤器类中。我知道它必须通过扩展和分部类扎根到我的类中,并试图在我的省煤器模型的文本视图中定义这些“缺失”变量,但这只会导致一个错误,即:

[1] 11:46:14翻译错误 [火力发电余热锅炉经济蒸发量:68:3-92:112]:可变省煤器:在修改器(Nt=3)中,未找到等级或部件Nt

如果您有任何建议和/或建议,请在下面留言

///更新:在我从其他人那里学到的东西之后继续前进,并实施他们的建议///

在阅读了您和其他人对我在OpenModelica上的问题所说的话之后,我对这种情况有了更好的理解。然而,我仍然不清楚什么是调试模型的最佳方式

因此,我的“省煤器”模型,或位于ThermoPower.Examples.RankineCycles.Models.HE中的热交换器,存在与除数“b=0”相关的错误

调试时,错误将我超链接到包“thermal”,该包将我指向正在标记的代码行:

(L/Nw*Nt)*rhomcm*Am*der(Tvol) = int.Q + ext.Q "Energy balance";
这一行代码也用于经济器HE类(ThermoPower.Examples.RankineCycles.Models.HE)。在这里的HE.mo中,引起错误的热包代码的同一标记行也位于这里。使我的模型导致除法器“b=0”的是变量:L、Nw、Nt、Am和Tvol。在我定义系统参数时使用的模型中未定义/找到这些变量

作为OpenModelica用户,让我感到困惑的是,上述变量(L、Nw、Nt、Am和Tvol)是在ThermoPower.Examples.RankineCycles.Models.HE组件的文本视图中编码/定义的,但当我试图将它们定义/添加到属于ThermoPower.Examples.RankineCycles.Models.HE类的省煤器.mo中时,将触发以下错误:

[ThermoPower_HRSG_Econ_Evap: 69:3-94:112]: Variable Economizer: In modifier 
(Nt = 1), class or component Nt not found in 
<ThermoPower.Examples.RankineCycle.Models.HE$Economizer>.
现在被侵犯了。如何正确解决此问题

///更新:代码如下所示///

model ThermoPower_HRSG_Econ_Evap

ThermoPower.Gas.SourceMassFlow Source_FlueGas(
redeclare package Medium = ThermoPower.Media.FlueGas, 
T = 331.59 + 273.15, 
p0 = 101325, 
w0 = 169.755)  annotation(
Placement(visible = true, transformation(origin = {-92, 30}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Water.SourceMassFlow Source_Steam(
T = 46.45 + 273.15, 
h = 203.22e3, 
p0 = 80e5, 
use_T = true, 
w0 = 21.5)  annotation(
Placement(visible = true, transformation(origin = {-10, 90}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Water.SensT sensT_WaterIn_Econ annotation(
Placement(visible = true, transformation(origin = {4, 60}, extent = {{-10, 
-10}, {10, 10}}, rotation = -90)));

ThermoPower.Water.SensT sensT_WaterOut_Econ annotation(
Placement(visible = true, transformation(origin = {4, 0}, extent = {{-10, 
-10}, {10, 10}}, rotation = -90)));

ThermoPower.Gas.SensT sensT_ExhaustIn_Econ(
redeclare package Medium = ThermoPower.Media.FlueGas)  annotation(
Placement(visible = true, transformation(origin = {-50, 34}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Gas.SensT sensT_ExhaustOut_Econ(
redeclare package Medium = ThermoPower.Media.FlueGas)  annotation(
Placement(visible = true, transformation(origin = {50, 34}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

inner ThermoPower.System system annotation(
Placement(visible = true, transformation(origin = {-90, 90}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Gas.SinkPressure Sink_FlueGas(
redeclare package Medium = ThermoPower.Media.FlueGas, 
p0 = 101325)  annotation(
Placement(visible = true, transformation(origin = {94, -70}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Water.SinkPressure Sink_Steam(
p0 = 80e5)  annotation(
Placement(visible = true, transformation(origin = {10, -90}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Examples.HRB.Models.Evaporator Evaporator(
cm = 480,
exchSurface = 2.752, 
fluidNomFlowRate = 21.5, 
fluidNomPressure = 8e+06, 
fluidVol = 0.01376, 
gamma = 85, 
gasNomFlowRate = 169.755, 
gasNomPressure = 101325, 
gasVol = 0.01376, 
metalVol = 0.01376, 
rhom(displayUnit = "kg/m3") = 8055, 
rhonom_G = 1)  annotation(
Placement(visible = true, transformation(origin = {0, -50}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Gas.SensT sensT_ExhaustOut_Evap(
redeclare package Medium = ThermoPower.Media.FlueGas)  annotation(
Placement(visible = true, transformation(origin = {50, -66}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

Modelica.Blocks.Continuous.FirstOrder VoidFractionSensor annotation(
Placement(visible = true, transformation(origin = {53, -43}, extent = 
{{-5, -5}, {5, 5}}, rotation = 0)));

Modelica.Blocks.Interfaces.RealOutput VoidFraction annotation(
Placement(visible = true, transformation(origin = {110, -42}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 
-42}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Examples.RankineCycle.Models.HE Economizer(
FFtype_G = ThermoPower.Choices.Flow1D.FFtypes.OpPoint,
FluidPhaseStart = ThermoPower.Choices.FluidPhase.FluidPhases.Liquid,
N_F = 6, 
N_G = 6,
Tstart_G = 604.74, 
Tstart_M = 573.15, counterCurrent = true, 
exchSurface_F = 2.752, 
exchSurface_G = 2.752, 
extSurfaceTub = 5.504, 
fluidNomFlowRate = 21.5, 
fluidNomPressure = 8e+06, 
fluidVol = 0.01376, 
gamma_F = 3000, 
gamma_G = 30, 
gasNomFlowRate = 169.755, 
gasNomPressure = 101325, 
gasVol = 0.01376, 
lambda = 19.8, 
metalVol = 0.01376, 
rhomcm = 8055 * 480, 
rhonom_F(displayUnit = "kg/m3") = 997, 
rhonom_G = 1)  annotation(
Placement(visible = true, transformation(origin = {0, 30}, extent = {{-10, 
-10}, {10, 10}}, rotation = 0)));

equation
connect(Economizer.gasOut, sensT_ExhaustOut_Econ.inlet) annotation(
Line(points = {{10, 30}, {44, 30}, {44, 30}, {44, 30}}, color = {159, 159, 
223}));
connect(sensT_ExhaustIn_Econ.outlet, Economizer.gasIn) annotation(
Line(points = {{-44, 30}, {-10, 30}, {-10, 30}, {-10, 30}}, color = {159, 
159, 223}));
connect(Economizer.waterOut, sensT_WaterOut_Econ.inlet) annotation(
Line(points = {{0, 20}, {0, 20}, {0, 6}, {0, 6}}, color = {0, 0, 255}));
connect(sensT_WaterIn_Econ.outlet, Economizer.waterIn) annotation(
Line(points = {{0, 54}, {0, 54}, {0, 40}, {0, 40}}, color = {0, 0, 255}));
connect(VoidFractionSensor.y, VoidFraction) annotation(
Line(points = {{58, -42}, {104, -42}, {104, -42}, {110, -42}}, color = {0, 
0, 127}));
connect(Evaporator.voidFraction, VoidFractionSensor.u) annotation(
Line(points = {{10, -44}, {46, -44}, {46, -42}, {46, -42}}, color = {0, 0, 
127}));
connect(sensT_ExhaustOut_Evap.outlet, Sink_FlueGas.flange) annotation(
Line(points = {{56, -70}, {70, -70}, {70, -70}, {84, -70}, {84, -70}, {84, 
-70}}, color = {159, 159, 223}));
connect(Evaporator.gasOut, sensT_ExhaustOut_Evap.inlet) annotation(
Line(points = {{10, -50}, {26, -50}, {26, -70}, {44, -70}}, color = {159, 
159, 223}));
connect(sensT_ExhaustOut_Econ.outlet, Evaporator.gasIn) annotation(
Line(points = {{56, 30}, {68, 30}, {68, -20}, {-50, -20}, {-50, -20}, 
{-70, -20}, {-70, -50}, {-10, -50}, {-10, -50}}, color = {159, 159, 
223}));
connect(sensT_WaterOut_Econ.outlet, Evaporator.waterIn) annotation(
Line(points = {{0, -6}, {0, -40}}, color = {0, 0, 255}));
connect(Evaporator.waterOut, Sink_Steam.flange) annotation(
Line(points = {{0, -60}, {0, -90}}, color = {0, 0, 255}));
connect(Source_FlueGas.flange, sensT_ExhaustIn_Econ.inlet) annotation(
Line(points = {{-82, 30}, {-56, 30}}, color = {159, 159, 223}));
connect(Source_Steam.flange, sensT_WaterIn_Econ.inlet) annotation(
Line(points = {{0, 90}, {0, 66}}, color = {0, 0, 255}));
annotation(
uses(ThermoPower(version = "3.1"), Modelica(version = "3.2.3")));end 
ThermoPower_HRSG_Econ_Evap;

如果错误消息中提到的变量不直接存在于省煤器类中,则必须在省煤器类扩展的一个类中定义该变量。查找关键字extends,然后还检入那些分部/基类。如果您没有自己编写模型,很容易迷失方向,因此请为它预留一些时间,但您将在途中了解更多关于模型的信息!试着用笔和纸画一个节能器类的UML图,显示哪些参数/变量被添加到哪个继承级别。我想你也可以先看看“扁平化”模型的来源,试着追踪这些变量来自哪里。@matth,识别省煤器组件扩展的基类有什么意义。。。如果在实例化省煤器类后未识别或找到“econover.metalTube.Nt&econover.metalTube.Am”变量的声明?在另一个Modelica论坛上,建议在省煤器部件上添加一个修饰符,以识别“b”中的变量,从而使表达式等于零。这是有意义的还是与您在OpenModelica中的体验相反?@Christoph您如何访问Modelica中的“扁平化”模型?我认为由“econover.metalTube.Nt&econover.metalTube.Am”引起的错误首先阻止了模型的展平。啊,对不起,在展平阶段之前没有意识到您的模型错误。我指的是“实例化模型”按钮。是的,我认为在这一点上,一些代码或简化的例子会很有用。
model ThermoPower_HRSG_Econ_Evap

ThermoPower.Gas.SourceMassFlow Source_FlueGas(
redeclare package Medium = ThermoPower.Media.FlueGas, 
T = 331.59 + 273.15, 
p0 = 101325, 
w0 = 169.755)  annotation(
Placement(visible = true, transformation(origin = {-92, 30}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Water.SourceMassFlow Source_Steam(
T = 46.45 + 273.15, 
h = 203.22e3, 
p0 = 80e5, 
use_T = true, 
w0 = 21.5)  annotation(
Placement(visible = true, transformation(origin = {-10, 90}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Water.SensT sensT_WaterIn_Econ annotation(
Placement(visible = true, transformation(origin = {4, 60}, extent = {{-10, 
-10}, {10, 10}}, rotation = -90)));

ThermoPower.Water.SensT sensT_WaterOut_Econ annotation(
Placement(visible = true, transformation(origin = {4, 0}, extent = {{-10, 
-10}, {10, 10}}, rotation = -90)));

ThermoPower.Gas.SensT sensT_ExhaustIn_Econ(
redeclare package Medium = ThermoPower.Media.FlueGas)  annotation(
Placement(visible = true, transformation(origin = {-50, 34}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Gas.SensT sensT_ExhaustOut_Econ(
redeclare package Medium = ThermoPower.Media.FlueGas)  annotation(
Placement(visible = true, transformation(origin = {50, 34}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

inner ThermoPower.System system annotation(
Placement(visible = true, transformation(origin = {-90, 90}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Gas.SinkPressure Sink_FlueGas(
redeclare package Medium = ThermoPower.Media.FlueGas, 
p0 = 101325)  annotation(
Placement(visible = true, transformation(origin = {94, -70}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Water.SinkPressure Sink_Steam(
p0 = 80e5)  annotation(
Placement(visible = true, transformation(origin = {10, -90}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Examples.HRB.Models.Evaporator Evaporator(
cm = 480,
exchSurface = 2.752, 
fluidNomFlowRate = 21.5, 
fluidNomPressure = 8e+06, 
fluidVol = 0.01376, 
gamma = 85, 
gasNomFlowRate = 169.755, 
gasNomPressure = 101325, 
gasVol = 0.01376, 
metalVol = 0.01376, 
rhom(displayUnit = "kg/m3") = 8055, 
rhonom_G = 1)  annotation(
Placement(visible = true, transformation(origin = {0, -50}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Gas.SensT sensT_ExhaustOut_Evap(
redeclare package Medium = ThermoPower.Media.FlueGas)  annotation(
Placement(visible = true, transformation(origin = {50, -66}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

Modelica.Blocks.Continuous.FirstOrder VoidFractionSensor annotation(
Placement(visible = true, transformation(origin = {53, -43}, extent = 
{{-5, -5}, {5, 5}}, rotation = 0)));

Modelica.Blocks.Interfaces.RealOutput VoidFraction annotation(
Placement(visible = true, transformation(origin = {110, -42}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 
-42}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Examples.RankineCycle.Models.HE Economizer(
FFtype_G = ThermoPower.Choices.Flow1D.FFtypes.OpPoint,
FluidPhaseStart = ThermoPower.Choices.FluidPhase.FluidPhases.Liquid,
N_F = 6, 
N_G = 6,
Tstart_G = 604.74, 
Tstart_M = 573.15, counterCurrent = true, 
exchSurface_F = 2.752, 
exchSurface_G = 2.752, 
extSurfaceTub = 5.504, 
fluidNomFlowRate = 21.5, 
fluidNomPressure = 8e+06, 
fluidVol = 0.01376, 
gamma_F = 3000, 
gamma_G = 30, 
gasNomFlowRate = 169.755, 
gasNomPressure = 101325, 
gasVol = 0.01376, 
lambda = 19.8, 
metalVol = 0.01376, 
rhomcm = 8055 * 480, 
rhonom_F(displayUnit = "kg/m3") = 997, 
rhonom_G = 1)  annotation(
Placement(visible = true, transformation(origin = {0, 30}, extent = {{-10, 
-10}, {10, 10}}, rotation = 0)));

equation
connect(Economizer.gasOut, sensT_ExhaustOut_Econ.inlet) annotation(
Line(points = {{10, 30}, {44, 30}, {44, 30}, {44, 30}}, color = {159, 159, 
223}));
connect(sensT_ExhaustIn_Econ.outlet, Economizer.gasIn) annotation(
Line(points = {{-44, 30}, {-10, 30}, {-10, 30}, {-10, 30}}, color = {159, 
159, 223}));
connect(Economizer.waterOut, sensT_WaterOut_Econ.inlet) annotation(
Line(points = {{0, 20}, {0, 20}, {0, 6}, {0, 6}}, color = {0, 0, 255}));
connect(sensT_WaterIn_Econ.outlet, Economizer.waterIn) annotation(
Line(points = {{0, 54}, {0, 54}, {0, 40}, {0, 40}}, color = {0, 0, 255}));
connect(VoidFractionSensor.y, VoidFraction) annotation(
Line(points = {{58, -42}, {104, -42}, {104, -42}, {110, -42}}, color = {0, 
0, 127}));
connect(Evaporator.voidFraction, VoidFractionSensor.u) annotation(
Line(points = {{10, -44}, {46, -44}, {46, -42}, {46, -42}}, color = {0, 0, 
127}));
connect(sensT_ExhaustOut_Evap.outlet, Sink_FlueGas.flange) annotation(
Line(points = {{56, -70}, {70, -70}, {70, -70}, {84, -70}, {84, -70}, {84, 
-70}}, color = {159, 159, 223}));
connect(Evaporator.gasOut, sensT_ExhaustOut_Evap.inlet) annotation(
Line(points = {{10, -50}, {26, -50}, {26, -70}, {44, -70}}, color = {159, 
159, 223}));
connect(sensT_ExhaustOut_Econ.outlet, Evaporator.gasIn) annotation(
Line(points = {{56, 30}, {68, 30}, {68, -20}, {-50, -20}, {-50, -20}, 
{-70, -20}, {-70, -50}, {-10, -50}, {-10, -50}}, color = {159, 159, 
223}));
connect(sensT_WaterOut_Econ.outlet, Evaporator.waterIn) annotation(
Line(points = {{0, -6}, {0, -40}}, color = {0, 0, 255}));
connect(Evaporator.waterOut, Sink_Steam.flange) annotation(
Line(points = {{0, -60}, {0, -90}}, color = {0, 0, 255}));
connect(Source_FlueGas.flange, sensT_ExhaustIn_Econ.inlet) annotation(
Line(points = {{-82, 30}, {-56, 30}}, color = {159, 159, 223}));
connect(Source_Steam.flange, sensT_WaterIn_Econ.inlet) annotation(
Line(points = {{0, 90}, {0, 66}}, color = {0, 0, 255}));
annotation(
uses(ThermoPower(version = "3.1"), Modelica(version = "3.2.3")));end 
ThermoPower_HRSG_Econ_Evap;