OpenModelica建模求助:活塞内部压力无变化问题排查
OpenModelica模型故障排查:SweptVolume内部压力无变化问题
我正在创建一个OpenModelica模型,结构为定容气源→管道→SweptVolume(扫容积)→质量块,介质为N₂,预期活塞能在特定压力下推动质量块,但实际运行后发现SweptVolume内部压力完全没有变化。
模型代码如下:
model Test inner Modelica.Fluid.System system(p_ambient = 101325) annotation( Placement(visible = true, transformation(origin = {-68, 74}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Fluid.Vessels.ClosedVolume volume( redeclare package Medium = Modelica.Media.IdealGases.SingleGases.N2, V = 0.6e-3, use_portsData = false, nPorts = 1) annotation( Placement(visible = true, transformation(origin = {66, 0}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); Modelica.Fluid.Pipes.StaticPipe pipe(redeclare package Medium = Modelica.Media.IdealGases.SingleGases.N2,diameter = 0.002, length = 0.005) annotation( Placement(visible = true, transformation(origin = {30, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 180))); Modelica.Fluid.Machines.SweptVolume sweptVolume( redeclare package Medium = Modelica.Media.IdealGases.SingleGases.N2,T_start = 293.15, clearance = 7.696902001e-4, nPorts = 1, p_start = 1e5, pistonCrossArea = 0.003848451, use_T_start = true, use_portsData = false) annotation( Placement(visible = true, transformation(origin = {-8, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 90))); Modelica.Mechanics.Translational.Components.Mass mass(m = 600) annotation( Placement(visible = true, transformation(origin = {-50, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 180))); equation connect(pipe.port_a, sweptVolume.ports[1]) annotation( Line(points = {{40, 0}, {2, 0}}, color = {0, 127, 255})); connect(mass.flange_a, sweptVolume.flange) annotation( Line(points = {{-40, 0}, {-18, 0}}, color = {0, 127, 0})); connect(pipe.port_a, volume.ports[1]) annotation( Line(points = {{40, 0}, {56, 0}}, color = {0, 127, 255})); annotation( uses(Modelica(version = "4.0.0"))); end Test;
问题排查与修正方案
1. 核心连接错误
代码中pipe.port_a同时连接了volume.ports[1](气源)与sweptVolume.ports[1](活塞腔),相当于把气源和活塞腔直接并联在管道的同一个端口,气体没有形成从气源到活塞腔的有效流动通路,导致活塞腔压力无法变化。
2. 气源初始状态缺失
ClosedVolume仅设置了容积V,未指定初始压力p_start和温度T_start,默认状态与环境压力一致,即使通路正确,也没有压力差驱动气体流动。
修正后的代码
model Test inner Modelica.Fluid.System system(p_ambient = 101325) annotation( Placement(visible = true, transformation(origin = {-68, 74}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Fluid.Vessels.ClosedVolume volume( redeclare package Medium = Modelica.Media.IdealGases.SingleGases.N2, V = 0.6e-3, use_portsData = false, nPorts = 1, p_start = 5e5, // 设置初始高压,高于活塞腔初始压力 T_start = 293.15) annotation( Placement(visible = true, transformation(origin = {66, 0}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); Modelica.Fluid.Pipes.StaticPipe pipe( redeclare package Medium = Modelica.Media.IdealGases.SingleGases.N2, diameter = 0.002, length = 0.005) annotation( Placement(visible = true, transformation(origin = {30, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 180))); Modelica.Fluid.Machines.SweptVolume sweptVolume( redeclare package Medium = Modelica.Media.IdealGases.SingleGases.N2, T_start = 293.15, clearance = 7.696902001e-4, nPorts = 1, p_start = 1e5, pistonCrossArea = 0.003848451, use_T_start = true, use_portsData = false) annotation( Placement(visible = true, transformation(origin = {-8, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 90))); Modelica.Mechanics.Translational.Components.Mass mass(m = 600) annotation( Placement(visible = true, transformation(origin = {-50, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 180))); equation connect(pipe.port_b, sweptVolume.ports[1]) annotation( // 管道出口连接活塞腔 Line(points = {{20, 0}, {2, 0}}, color = {0, 127, 255})); connect(mass.flange_a, sweptVolume.flange) annotation( Line(points = {{-40, 0}, {-18, 0}}, color = {0, 127, 0})); connect(pipe.port_a, volume.ports[1]) annotation( // 管道入口连接气源 Line(points = {{40, 0}, {56, 0}}, color = {0, 127, 255})); annotation( uses(Modelica(version = "4.0.0"))); end Test;
修正说明
- 调整管道连接:让
pipe.port_a连接气源,pipe.port_b连接SweptVolume,建立从气源到活塞腔的单向流动通路。 - 给
ClosedVolume添加p_start=5e5和T_start=293.15,确保初始压力高于活塞腔的初始压力(1e5),形成压力差驱动气体流入活塞腔。 - 运行修正后的模型,活塞腔压力会逐渐上升,当压力产生的推力大于质量块的惯性力时,活塞将推动质量块运动。
内容的提问来源于stack exchange,提问作者Emma
相关产品推荐
相关产品推荐

