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

基于TemplateMedium创建粘性油介质时的NFCeval内部错误排查

问题解决步骤

1. 修正PartialMedium继承参数

你的介质是定密度、仅温度依赖粘度的不可压缩流体,属于单状态介质,需修改PartialMedium的核心参数:

  • 将final singleState=false改为final singleState=true
  • 保留final reducedX=true和final fixedX=true(单组分介质无需组分变量)

修改后的继承代码:

extends Modelica.Media.Interfaces.PartialMedium(
    final mediumName="viscOil",
    final substanceNames={mediumName},
    final singleState=true,  // 关键修改:标记为单状态介质
    final reducedX=true,
    final fixedX=true,
    Temperature(
      min=-54,
      max=473,
      start=293));

2. 调整热力学状态记录

单状态不可压缩介质的热力学状态仅由温度T决定(密度恒定,压力不影响状态),因此精简ThermodynamicState:

redeclare replaceable record ThermodynamicState
  "A selection of variables that uniquely defines the thermodynamic state"
  extends Modelica.Icons.Record;
  Temperature T "Temperature of medium";  // 仅保留温度变量,移除压力p
end ThermodynamicState;

3. 修正BaseProperties方程

由于状态变量只剩温度,调整BaseProperties中的状态关联逻辑,移除压力相关的状态赋值:

redeclare model extends BaseProperties(final standardOrderComponents=true)
  "Base properties of medium"
equation
  d = 1003.5;
  h = cp_const*T;
  u = h - p/d;
  MM = 0.024;
  R_s = Modelica.Constants.R/MM;
  state.T = T;  // 仅将温度关联到热力学状态
end BaseProperties;

4. 完善物理属性函数

当前部分函数返回0会导致仿真错误,需根据不可压缩介质特性补全:

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 := cp_const;  // 不可压缩流体cv≈cp
end specificHeatCapacityCv;

redeclare function extends thermalConductivity
  "Return thermal conductivity"
algorithm
  lambda := 0.14;  // 设置合理的导热系数(典型导热油取值)
end thermalConductivity;

错误根源说明

原错误是因为你声明了singleState=false(多状态介质),但实际介质是不可压缩定密度的单状态类型,导致热力学状态变量的预设选择(dTX)与介质定义不匹配。Modelica.Media要求单状态介质的热力学状态只能由一个变量(通常为温度)定义,多状态介质才需要压力+温度/密度的组合。

内容的提问来源于stack exchange,提问作者Sampath Rachakonda

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.15 00:12:37