You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

开发二维对流扩散传质Modelica组件的模拟问题求助

平推流反应器Modelica模型问题排查

更新说明

我按照Markus的建议做了修改,核心是在侧端口间添加了动量平衡,实现了部分元件并行连接,且能根据长度等参数分配流量,这符合预期需求。但模拟成功率高度依赖输入的质量流量(即simulationInputs记录中的m),当前使用2.5e-5 kg/s流量时模拟效果很差;低质量流量下模拟能运行,但进出口速度等变量的时间变化行为异常。

另外,我不得不实现伯努利原理,但对当前的实现方式并不满意。

问题背景

我正在开发平推流反应器模型,流体单向流动(假设从下到上),同时通过侧面与相邻组件进行扩散传质。单独连接边界条件组件时模型运行正常,但尝试将反应器离散化以观察不同位置(如边界附近与反应器中心)的浓度变化时,遇到了问题。

连接器定义

connector Port
  Modelica.Units.SI.Pressure p;
  flow Modelica.Units.SI.MassFlowRate m;
  stream Modelica.Units.SI.Concentration c;
end Port;

主元件模型代码

model BasicElement
  Port north;
  Port south;
  Port west;
  Port east;
// "Made-up" variables
  Modelica.Units.SI.Mass m_cv;
  Modelica.Units.SI.Concentration c;
  Modelica.Units.SI.MassFlowRate m_dot_c;
  Modelica.Units.SI.Density rho_in, rho_c, rho_out;
  Modelica.Units.SI.Velocity v_in, v_c, v_out;
  Real dp_cl(unit = "Pa/m");
  
  parameter Modelica.Units.SI.Length l=1, w=1, d=1;
  parameter Real G = 0.005;                                  // Generation term
protected
  parameter Modelica.Units.SI.Area a_N = 1, a_S = 1, a_W = 1, a_E = 1;
  parameter Modelica.Units.SI.Volume V = l*w*d;
  parameter Modelica.Units.SI.DiffusionCoefficient diff = 1e-9;
  constant Modelica.Units.SI.MolarMass MM = 1/1000;
  constant Modelica.Units.SI.Acceleration g = 9.81;
  public
equation
//// ASSIGNMENTS TO "MADE-UP" VARIABLES ////
  rho_in = inStream(south.c)*MM;                    // densities
  rho_c = c*MM;
  rho_out = north.c*MM;

  m_dot_c = (south.m - north.m)/2;                 // mass flow

  v_c = m_dot_c/c/a_S/MM;                          // velocities
  v_in = south.m/inStream(south.c)/a_S/MM;

  dp_cl = (1/d)*(rho_c*(v_c^2)/2);                 // pressure loss

//// EQUATIONS ////
// Species conservation
  der(c) = (south.m/MM/a_S + north.m/MM/a_N)/l + (west.m/MM/a_W + east.m/MM/a_E)/w + G/MM/a_E/l;
// Mass conservation
  der(m_cv) = (south.m + north.m + west.m + east.m) + G;
// Mass flows
  north.m = -v_out*north.c*a_N*MM;
  east.m = -diff*(c - east.c)/(w/2)*a_E*MM;
  west.m = -diff*(west.c - c)/(w/2)*a_W*MM;
// MOMENTUM CONSERVATION
  l*der(m_dot_c) = (rho_in*a_S*v_in^2 - rho_out*a_N*v_out^2) - (north.p*a_N - south.p*a_S) - rho_c*g*l*((a_N + a_S)/2) - dp_cl*l*((a_N + a_S)/2);
// PRESSURE
  (south.p - north.p) = (m_dot_c^2)*l*dp_cl/((a_S^2)*(v_c^2))/(rho_c^2);
  west.p = north.p;
  east.p = north.p;
  c = (south.c + north.c)/2;
  south.c = inStream(south.c);
end BasicElement;

我实现了物种守恒、质量守恒,定义了质量流量,并参考动量平衡相关说明实现了动量守恒;为简化模型,设置侧连接的压力等于出口压力。

我制作了三个测试案例:

  • 第一个测试:单个元件在输入、输出及侧面边界条件下的行为,运行正常
  • 第二个测试:两个基础元件并排连接,出现结构奇异错误
  • 第三个测试:流量可在两个组件间正确分配,但每个组件必须在侧面设置边界条件,不符合需求

错误信息

[4] 15:58:18 Symbolic Error
Model is structurally singular, error found sorting equations
36: 0.0 = 0.0
for variables
6: basicElement1.rho_c:VARIABLE(min = 0.0 unit = "kg/m3" ) type: Real

[5] 15:58:18 Translation Error
Internal error Transformation Module PFPlusExt index Reduction Method Pantelides failed!

核心疑问

  • 模拟效果依赖质量流量,2.5e-5 kg/s下效果差,低流量时变量行为异常的原因是什么?
  • 如何优化伯努利原理的实现方式?
  • 解决两个元件并行连接时出现的结构奇异错误的方法是什么?

内容的提问来源于stack exchange,提问作者Vicente OG

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 09:00:07