【问题标题】:Am I incorporating this nested Function properly on OpenModelica?我是否在 OpenModelica 上正确合并了这个嵌套函数?
【发布时间】:2019-03-05 23:24:54
【问题描述】:

注意:此问题参考位于 ThermoPower.Examples.RankineCycle.Models.PrescribedSpeedPump 的 PrescribedSpeedPump.mo

我正在尝试简单泵模型,因为我构建的所有包含此泵的模型总是产生相同的错误消息:

[1] 16:02:01 翻译错误 [ThermoPower.PowerPlants:2071:95-2071:108]:在 ThermoPower.PowerPlants.HRSG.Components 范围内找不到变量 q_nom。

[2] 16:02:01 翻译错误 [ThermoPower.PowerPlants: 2076:84-2076:132]:在范围内找到循环相关的常量或参数:{q_nom}、{head_nom}(使用 -d=ignoreCycles 忽略)。

在检查这个 PrescribedSpeedPump 后,它由两个类组成:“FluidMedium”和“flowCharacteristic”。导致错误的是函数 - “FlowCharacteristic”。

为什么我感到困惑: 该错误表明它无法在 ThermoPower.PowerPlants.HRSG.Components 的路径中找到变量 q_nom。好吧,前面提到过,我说它位于 ThermoPower 库的示例包中。

我对这种情况感到困惑的另一个原因是,我能够手动输入 q_nom 和 head_nom 的参数值。他们都被赋予了 {1,2,3} 的虚拟值。尽管如此,变量“找不到”。

最后,我尝试自己手动编辑“flowCharacteristic”函数,然后尝试检查我的模型。仍然出现相同的错误。我现在真的不知道如何解决这个错误,并尝试了我能想到的。

如果您有任何见解或建议,请随时在下面发表评论!感谢您阅读本文,感谢您花时间和精力帮助社区中的其他人。下面我已将代码复制到我的泵模型中。

代码更新:

model Pump_Verified


function flowCharacteristic =
ThermoPower.Functions.PumpCharacteristics.quadraticFlow (
q_nom = q_nom, head_nom = head_nom);

ThermoPower.PowerPlants.HRSG.Components.PrescribedSpeedPump
prescribedSpeedPump1(
redeclare package WaterMedium = ThermoPower.Water.StandardWater,
Np0 = 1,
V = 20,
head_nom = {1, 2, 3},
hstart = 451024,
n0 = 1200,
nominalFlow = 142.512,
nominalInletPressure=132000,
nominalOutletPressure=8581000,
q_nom = {1, 2, 3},
rho0=1000)
          annotation (
Placement(visible = true, transformation(origin = {2, 0}, extent = {{-10,
-10}, {10, 10}}, rotation = 0)));

ThermoPower.Examples.RankineCycle.Models.PrescribedPressureCondenser
Condenser(
Vtot = 50,
p = 132000)  annotation (
Placement(visible = true, transformation(origin = {-50, 40}, extent = 
{{-10,
-10}, {10, 10}}, rotation = 0)));

ThermoPower.PowerPlants.SteamTurbineGroup.Components.StateReader_water
stateReader_water1 annotation (
Placement(visible = true, transformation(origin = {-50, 70}, extent = 
{{-10,
-10}, {10, 10}}, rotation = -90)));

ThermoPower.PowerPlants.SteamTurbineGroup.Components.StateReader_water
stateReader_water2 annotation (
Placement(visible = true, transformation(origin = {-50, 10}, extent = 
{{-10,
-10}, {10, 10}}, rotation = -90)));

ThermoPower.Water.SourceMassFlow SourceSteamFlow(
T = 380.561 - 273,
h = 931235,
p0 = 1.32e5,
w0 = 142.512)  annotation (
Placement(visible = true, transformation(origin = {-72, 84}, extent = 
{{-10,
-10}, {10, 10}}, rotation = 0)));

ThermoPower.Water.SinkMassFlow SinkWaterFlow annotation (
Placement(visible = true, transformation(origin = {52, 0}, extent = {{-10,
-10}, {10, 10}}, rotation = 0)));

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

ThermoPower.Water.SensP sensP_Inlet annotation(
Placement(visible = true, transformation(origin = {-32, 4}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

ThermoPower.Water.SensP sensP_Outlet annotation(
Placement(visible = true, transformation(origin = {26, 4}, extent = {{-10, 
-10}, {10, 10}}, rotation = 0)));

Modelica.Blocks.Sources.Constant const(k = 1200)  annotation(
Placement(visible = true, transformation(origin = {-10, 66}, extent = 
{{-10, -10}, {10, 10}}, rotation = 0)));

equation
connect(const.y, prescribedSpeedPump1.pumpSpeed_rpm) annotation(
Line(points = {{2, 66}, {10, 66}, {10, 30}, {-18, 30}, {-18, 6}, {-6, 6}, 
{-6, 6}}, color = {0, 0, 127}));
connect(sensP_Outlet.flange, SinkWaterFlow.flange) annotation(
Line(points = {{26, 0}, {42, 0}, {42, 0}, {42, 0}}, color = {0, 0, 255}));
connect(prescribedSpeedPump1.outlet, sensP_Outlet.flange) annotation(
Line(points = {{12, 0}, {26, 0}, {26, 0}, {26, 0}}, color = {0, 0, 255}));
connect(sensP_Inlet.flange, prescribedSpeedPump1.inlet) annotation(
Line(points = {{-32, 0}, {-8, 0}, {-8, 0}, {-8, 0}}, color = {0, 0, 
255}));
connect(stateReader_water2.outlet, sensP_Inlet.flange) annotation(
Line(points = {{-50, 4}, {-50, 4}, {-50, 0}, {-32, 0}, {-32, 0}}, color = 
{0, 0, 255}));
connect(Condenser.waterOut, stateReader_water2.inlet) annotation(
Line(points = {{-50, 30}, {-50, 16}}, color = {0, 0, 255}));
connect(stateReader_water1.outlet, Condenser.steamIn) annotation(
Line(points = {{-50, 64}, {-50, 50}}, color = {0, 0, 255}));
connect(SourceSteamFlow.flange, stateReader_water1.inlet) annotation(
Line(points = {{-62, 84}, {-50, 84}, {-50, 76}, {-50, 76}, {-50, 76}}, 
color = {0, 0, 255}));
annotation (
uses(ThermoPower(version = "3.1"), Modelica(version="3.2.2")));

end Pump_Verified;

【问题讨论】:

    标签: modelica dymola openmodelica jmodelica


    【解决方案1】:

    您正在使用 ThermoPower.PowerPlants.HRSG.Components.PrescribedSpeedPump,但您似乎想要修改它,特别是:

    • 该模型中已经存在函数 flowCharacteristic - 但 不可更换,所以你不能改变它,你也可以不 在重新声明中使用模型中的 q_nom。但由于它已经是二次方,因此无需更改。
    • 没有为此组件指定媒体 (假设我使用了正确的 ThermoPower 版本)。
    • 规定的speedpump 有一个未连接的输入。

    如果你只是想使用它:

    • 移除函数flowCharacteristic
    • 重新声明介质
    • 将一些信号连接到泵

    以下至少在 Dymola 中有效:

    model Pump_Check
    
    function flowCharacteristic =
    ThermoPower.Functions.PumpCharacteristics.quadraticFlow (
    q_nom = q_nom, head_nom = head_nom);
    
    ThermoPower.PowerPlants.HRSG.Components.PrescribedSpeedPump
    prescribedSpeedPump1(
        redeclare package WaterMedium = ThermoPower.Water.StandardWater,
    Np0 = 1,
    V = 20,
    head_nom = {1, 2, 3},
    hstart = 451024,
    n0 = 1200,
    nominalFlow = 142.512,
        nominalInletPressure=132000,
        nominalOutletPressure=8581000,
    q_nom = {1, 2, 3},
        rho0=1000)
                  annotation (
    Placement(visible = true, transformation(origin = {2, 0}, extent = {{-10,
    -10}, {10, 10}}, rotation = 0)));
    
    ThermoPower.Examples.RankineCycle.Models.PrescribedPressureCondenser
    Condenser(
    Vtot = 50,
    p = 132000)  annotation (
    Placement(visible = true, transformation(origin = {-50, 40}, extent = {{-10,
    -10}, {10, 10}}, rotation = 0)));
    
    ThermoPower.PowerPlants.SteamTurbineGroup.Components.StateReader_water
    stateReader_water1 annotation (
    Placement(visible = true, transformation(origin = {-50, 70}, extent = {{-10,
    -10}, {10, 10}}, rotation = -90)));
    
    ThermoPower.PowerPlants.SteamTurbineGroup.Components.StateReader_water
    stateReader_water2 annotation (
    Placement(visible = true, transformation(origin = {-50, 10}, extent = {{-10,
    -10}, {10, 10}}, rotation = -90)));
    
    ThermoPower.Water.SourceMassFlow SourceSteamFlow(
    T = 380.561 - 273,
    h = 931235,
    p0 = 1.32e5,
    w0 = 142.512)  annotation (
    Placement(visible = true, transformation(origin = {-72, 84}, extent = {{-10,
    -10}, {10, 10}}, rotation = 0)));
    
    ThermoPower.Water.SinkMassFlow SinkWaterFlow annotation (
    Placement(visible = true, transformation(origin = {52, 0}, extent = {{-10,
    -10}, {10, 10}}, rotation = 0)));
    inner ThermoPower.System system annotation (
    Placement(visible = true, transformation(origin = {90, 88}, extent = {{-10,
    -10}, {10, 10}}, rotation = 0)));
      Modelica.Blocks.Interfaces.RealInput pumpSpeed_rpm1
        annotation (Placement(transformation(extent={{-46,66},{-6,106}})));
    equation 
    connect(prescribedSpeedPump1.outlet, SinkWaterFlow.flange) annotation (
    Line(points = {{12, 0}, {42, 0}, {42, 0}, {42, 0}}, color = {0, 0, 255}));
    connect(stateReader_water2.outlet, prescribedSpeedPump1.inlet) annotation (
    Line(points = {{-50, 4}, {-50, 4}, {-50, 0}, {-8, 0}, {-8, 0}}, color = {0,
    0, 255}));
    connect(Condenser.waterOut, stateReader_water2.inlet) annotation (
    Line(points={{-50,30},{-50,16}},                            color = {0, 0,
    255}));
    connect(stateReader_water1.outlet, Condenser.steamIn) annotation (
    Line(points={{-50,64},{-50,50}},                            color = {0, 0,
    255}));
    connect(SourceSteamFlow.flange, stateReader_water1.inlet) annotation (
    Line(points = {{-62, 84}, {-50, 84}, {-50, 76}, {-50, 76}, {-50, 76}}, color=
      {0, 0, 255}));
    
      connect(prescribedSpeedPump1.pumpSpeed_rpm, pumpSpeed_rpm1) annotation (Line(
            points={{-5.2,6},{-16,6},{-16,86},{-26,86}}, color={0,0,127}));
    annotation (
    uses(ThermoPower(version = "3.1"), Modelica(version="3.2.2")));
    end Pump_Check;
    

    【讨论】:

    • 嘿@HansOlsson ,只是想让您知道您提供的代码确实导致了检查模型,它实例化和模拟。谢谢!尽管我仍然遇到与前面提到的相同的错误,但它最终起作用了,我很感激。但是,在模拟时,出口压力不会改变为 I 指定的值,并且相对于入口压力保持恒定。您对如何解决此问题有任何想法吗?这是通过在泵的入口和出口添加“SensP”或压力传感器来确定的。让我知道你的想法!谢谢!
    • 首先显而易见的是:您是否将正常信号(如斜坡)连接到泵。我相信 0 值用于此类输入,效果不佳。
    • 最初,我没有用任何正常的信号连接进行模拟。我将使用您之前在此线程中复制的代码运行模拟。
    • 最初,我没有用任何正常的信号连接进行模拟。我只是从你在这个线程中复制的代码运行模拟。即使没有信号输入,该模拟也会运行。
    • 但是,我对如何将输入信号连接到 RealInput 组件感到困惑。这是因为您在上面发布的代码在 Modelica.Blocks.Interfaces.RealInput 和指定SpeedPump 的 pumpSpeed_rpm 之间的连接来自三角形后面而不是点。我的第一直觉是使用输入信号为 RealInput 组件提供源,然后 RealInput 组件将输入到指定的SpeedPump 速度输入中。让我知道你的想法。再次感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-07
    • 2012-06-13
    相关资源
    最近更新 更多