如何解决与不在OpenModelica模型内的变量有关的错误?

时间:2019-03-29 20:06:44

标签: modelica openmodelica

我目前正在构建热能回收蒸汽发生器,刚刚从ThermoPower库开始构建并将蒸发器连接到节能器。 尝试模拟时,OMEdit Simulator中发生错误:

在时间0处被零除(a = -458389.9207317767)/(b = 0),其中除数b表达式为:8.75988806777792 * Economizer.metalTube.Am * Economizer.metalTube.rhomcm * / 实数 /((Economizer.metalTube.Nt)

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

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

[1] 11:46:14翻译错误 [ThermoPower_HRSG_Econ_Evap:68:3-92:112]:可变节能器:在修饰符(Nt = 3)中,未在中找到类或组件Nt。

如果您有任何建议和/或建议,请在下面发表评论!

/// UPDATE:在我从别人那里学到东西并落实他们的建议之后,继续前进。///

阅读了您和其他人对我在OpenModelica上的问题所发表的看法后,我对情况有了更好的了解。但是,对于继续调试模型的最佳方法,我仍然感到困惑。

因此,我的“节能器”模型或ThermoPower.Examples.RankineCycles.Models.HE中的换热器出现与除数“ b = 0”相关的错误。

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

(L/Nw*Nt)*rhomcm*Am*der(Tvol) = int.Q + ext.Q "Energy balance";

此代码行也在Economizer 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类的Economizer.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>.

从本质上讲,导致分频器“ b = 0”的错误位于我正在使用的节能器的基类中。但是,由于在我的Economizer.mo模型中缺少或无法定义这些所需变量,因此方程式:

(L/Nw*Nt)*rhomcm*Am*der(Tvol) = int.Q + ext.Q "Energy balance";

现在被违反了。如何正确解决此问题?

///更新:代码位于下面////

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;

0 个答案:

没有答案