自定义Modelica介质接入MSL阀门初始化时出现负压高温问题
自定义介质在DynamicPipe+阀门流系统中的初始化异常问题
我基于MSL库的PartialMedium构建了燃料输送系统的自定义介质,已通过介质示例工具及3000bar压力测试。但在流系统中加入阀门后,介质初始化时出现压力负值(-2.3977e+08 Pa)、温度异常升高(192190 K),触发断言错误。
已完成的测试
- 使用
StandardWater介质时,含阀门的简单测试模型运行正常; - 尝试多种额定质量流量和压差参数;
- 不含阀门的简单流模型运行符合预期;
- 切换比热容符号;
- 设置阀门为常开状态。
后续排查结果
替换为Modelica.Fluid.Pipes.StaticPipe模型可正常运行,但我的目标是构建燃油喷射系统,必须用DynamicPipe精准捕捉压力变化,调整动态管道结构无效。进一步测试确认问题源于介质定义,改用PartialLinearFluid扩展介质后仿真可启动但速度极慢。
附相关Modelica代码
package SO package MyMedia_v5 "Template for media models" extends Modelica.Media.Interfaces.PartialMedium(final mediumName = "MyLiquid", final substanceNames = {mediumName}, final singleState = false, final reducedX = true, final fixedX = true, Temperature(min = 273, max = 373, start = 298), p_default = 1e5, reference_p = 1e5, reference_T = 298, reference_X = {1}, AbsolutePressure(min = 1e-6, max = 3e8, start = 1e5), ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.pT); // Provide medium constants here constant SpecificHeatCapacity cp_const = 1250 "Constant specific heat capacity at constant pressure"; constant SpecificHeatCapacity cv_const = 1100 "Constant specific heat capacity at constant volume"; constant Temperature T0 = reference_T "Zero enthalpy temperature"; constant MolarMass MM_const = 12 "Molar mass"; constant DynamicViscosity eta_const = 0.05 "Constant dynamic viscosity"; constant ThermalConductivity lambda_const = 0.1 "Constant thermal conductivity"; constant VelocityOfSound a_const = 1300 "Constant velocity of sound"; redeclare model extends BaseProperties(final standardOrderComponents = true) "Base properties of medium" equation d = density(state); h = specificEnthalpy(state); u = h - p/d; MM = 0.025; R_s = 0; state.p = p; state.T = T; end BaseProperties; redeclare replaceable record ThermodynamicState "A selection of variables that uniquely defines the thermodynamic state" extends Modelica.Icons.Record; AbsolutePressure p "Absolute pressure of medium"; Temperature T "Temperature of medium"; annotation( Documentation(info = "<html> </html>")); end ThermodynamicState; redeclare function extends setState_pTX "Return thermodynamic state as function of p, T and composition X or Xi" extends Modelica.Icons.Function; algorithm state := ThermodynamicState(p = p, T = T); annotation( Inline = true); end setState_pTX; redeclare function setState_phX "Return thermodynamic state from p, h, and X or Xi" extends Modelica.Icons.Function; input AbsolutePressure p "Pressure"; input SpecificEnthalpy h "Specific enthalpy"; input MassFraction X[:] = reference_X "Mass fractions"; output ThermodynamicState state "Thermodynamic state record"; algorithm state := ThermodynamicState(p = p, T = T0 + h/cp_const); end setState_phX; redeclare function setState_dTX "Return thermodynamic state from p, h, and X or Xi" extends Modelica.Icons.Function; input Density d "Density"; input SpecificEnthalpy h "Specific enthalpy"; input MassFraction X[:] = reference_X "Mass fractions"; output ThermodynamicState state "Thermodynamic state record"; protected constant Real d_init = 892.2; constant Real p_init = 200; constant Real a1 = 4.0654; constant Real a2 = 10130; Real p_bar = state.p*1e-5; algorithm state := ThermodynamicState(p = 1e5*(Modelica.Math.log(d/d_init)*a2 + p_init)/(1 - Modelica.Math.log(d/d_init)), T = T); end setState_dTX; redeclare function extends specificEnthalpy "Return specific enthalpy" algorithm h := cp_const*(state.T - T0); end specificEnthalpy; redeclare function extends pressure "Return the Pressure" algorithm p := state.p; end pressure; redeclare function extends specificHeatCapacityCp "Return specific heat capacity at constant pressure" algorithm cp := cp_const; end specificHeatCapacityCp; redeclare function extends specificHeatCapacityCv "Return specific heat capacity at constant volume" algorithm cv := cv_const; end specificHeatCapacityCv; redeclare function extends density "Return the density" input ThermodynamicState state; output Density d; protected constant Real d_init = 892.2; constant Real p_init = 200; constant Real a1 = 4.0654; constant Real a2 = 10130; Real p_bar = state.p*1e-5; algorithm d := d_init*Modelica.Math.exp((p_bar - p_init)/(a1*p_bar + a2)); annotation( smoothOrder = 1, Inline = true); end density; redeclare function extends temperature "Return temperature" input ThermodynamicState state "Thermodynamic state record"; output Temperature T "Temperature"; algorithm T := state.T; end temperature; redeclare function extends dynamicViscosity "Return dynamic viscosity" algorithm eta := eta_const; annotation( Documentation(info = "<html> </html>")); end dynamicViscosity; redeclare function extends thermalConductivity "Return thermal conductivity" algorithm lambda := 0.1; annotation( Documentation(info = "<html> </html>")); end thermalConductivity; redeclare function extends isentropicExponent "Return isentropic exponent" extends Modelica.Icons.Function; algorithm gamma := 1.16; annotation( Documentation(info = "<html> </html>")); end isentropicExponent; redeclare function extends velocityOfSound "Return velocity of sound" extends Modelica.Icons.Function; algorithm a := 1100; annotation( Documentation(info = "<html> </html>")); end velocityOfSound; end MyMedia_v5; model TestOfMyMedium5 replaceable package Medium = MyMedia_v4 "Medium in the component" annotation( choicesAllMatching = true); Modelica.Fluid.Sources.Boundary_pT boundary(nPorts = 1, redeclare package Medium = Medium, p = 1e5) annotation( Placement(transformation(origin = {90, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 180))); Modelica.Fluid.Pipes.DynamicPipe pipe(redeclare package Medium = Medium, length = 0.1, diameter = 0.1) annotation( Placement(transformation(origin = {-50, 0}, extent = {{-10, -10}, {10, 10}}))); Modelica.Blocks.Sources.Ramp ramp(duration = 0.8, startTime = 0.1, height = 0.1, offset = 0.9) annotation( Placement(transformation(origin = {-36, 42}, extent = {{-10, -10}, {10, 10}}))); Modelica.Fluid.Pipes.DynamicPipe pipe1(redeclare package Medium = Medium, diameter = 0.1, length = 0.1) annotation( Placement(transformation(origin = {42, 0}, extent = {{-10, -10}, {10, 10}}))); inner Modelica.Fluid.System system(use_eps_Re = true) annotation( Placement(transformation(origin = {-86, 86}, extent = {{-10, -10}, {10, 10}}))); Modelica.Fluid.Valves.ValveLinear valveLinear(redeclare package Medium = Medium, dp_nominal = 1e4, m_flow_nominal = 1) annotation( Placement(transformation(extent = {{-10, -10}, {10, 10}}))); Modelica.Fluid.Sources.Boundary_pT boundaryIn(redeclare package Medium = Medium, nPorts = 1, p = 5e5) annotation( Placement(transformation(origin = {-90, 0}, extent = {{-10, -10}, {10, 10}}))); Modelica.Blocks.Sources.Constant const(k = 1) annotation( Placement(transformation(origin = {-18, 90}, extent = {{-10, -10}, {10, 10}}))); equation connect(pipe1.port_b, boundary.ports[1]) annotation( Line(points = {{52, 0}, {80, 0}}, color = {0, 127, 255})); connect(pipe.port_b, valveLinear.port_a) annotation( Line(points = {{-40, 0}, {-10, 0}}, color = {0, 127, 255}, thickness = 0.5)); connect(valveLinear.port_b, pipe1.port_a) annotation( Line(points = {{10, 0}, {32, 0}}, color = {0, 127, 255})); connect(boundaryIn.ports[1], pipe.port_a) annotation( Line(points = {{-80, 0}, {-60, 0}}, color = {0, 127, 255}, thickness = 0.5)); connect(ramp.y, valveLinear.opening) annotation( Line(points = {{-25, 42}, {0, 42}, {0, 8}}, color = {0, 0, 127})); end TestOfMyMedium5; end SO;
内容的提问来源于stack exchange,提问作者quaternio
相关产品推荐
相关产品推荐

