OF4中thermophysicalProperties的设置以及多组分的气体的设置 发表于 2026-03-27 | 更新于 2026-03-27
| 浏览量:
今天在搞一个项目中的关于气体成分的设置
Gas composition
H2
Vol%
31.48
N2
Vol%
0.15
CH4
Vol%
3.2
CO2
Vol%
18.80
CO
Vol%
46.1
C2H6
Vol%
0.1
C2H2
Vol%
0.14
C3H8
Vol%
0.03
Gas yield
Nm3/h
25
Density
kg/m3
0.94
下面是在REFPROP中按照当前的组分设置的混合物的到的热物性,用作参考和对比。
thermophysicalProperties文件的设置 根据你的solver支持的情况,可以使用banana大法,看一下你的ThermoType都支持什么配置。我支持如下配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 type mixture transport thermo equationOfState specie energy heRhoThermo homogeneousMixture const hConst incompressiblePerfectGas specie sensibleEnthalpy heRhoThermo homogeneousMixture const hConst perfectGas specie sensibleEnthalpy heRhoThermo homogeneousMixture sutherland janaf incompressiblePerfectGas specie sensibleEnthalpy heRhoThermo homogeneousMixture sutherland janaf perfectGas specie sensibleEnthalpy heRhoThermo inhomogeneousMixture const hConst incompressiblePerfectGas specie sensibleEnthalpy heRhoThermo inhomogeneousMixture const hConst perfectGas specie sensibleEnthalpy heRhoThermo inhomogeneousMixture sutherland janaf incompressiblePerfectGas specie sensibleEnthalpy heRhoThermo inhomogeneousMixture sutherland janaf perfectGas specie sensibleEnthalpy heRhoThermo multiComponentMixture const hConst incompressiblePerfectGas specie sensibleEnthalpy heRhoThermo multiComponentMixture const hConst incompressiblePerfectGas specie sensibleInternalEnergy heRhoThermo multiComponentMixture const hConst perfectGas specie sensibleEnthalpy heRhoThermo multiComponentMixture const hConst perfectGas specie sensibleInternalEnergy heRhoThermo multiComponentMixture polynomial hPolynomial icoPolynomial specie sensibleEnthalpy heRhoThermo multiComponentMixture polynomial hPolynomial icoPolynomial specie sensibleInternalEnergy heRhoThermo multiComponentMixture sutherland janaf incompressiblePerfectGas specie sensibleEnthalpy heRhoThermo multiComponentMixture sutherland janaf incompressiblePerfectGas specie sensibleInternalEnergy heRhoThermo multiComponentMixture sutherland janaf perfectGas specie sensibleEnthalpy heRhoThermo multiComponentMixture sutherland janaf perfectGas specie sensibleInternalEnergy heRhoThermo reactingMixture const hConst incompressiblePerfectGas specie sensibleEnthalpy heRhoThermo reactingMixture const hConst incompressiblePerfectGas specie sensibleInternalEnergy heRhoThermo reactingMixture const hConst perfectGas specie sensibleEnthalpy heRhoThermo reactingMixture const hConst perfectGas specie sensibleInternalEnergy heRhoThermo reactingMixture polynomial hPolynomial icoPolynomial specie sensibleEnthalpy heRhoThermo reactingMixture polynomial hPolynomial icoPolynomial specie sensibleInternalEnergy heRhoThermo reactingMixture sutherland janaf incompressiblePerfectGas specie sensibleEnthalpy heRhoThermo reactingMixture sutherland janaf incompressiblePerfectGas specie sensibleInternalEnergy heRhoThermo reactingMixture sutherland janaf perfectGas specie sensibleEnthalpy heRhoThermo reactingMixture sutherland janaf perfectGas specie sensibleInternalEnergy heRhoThermo singleStepReactingMixture sutherland janaf perfectGas specie sensibleEnthalpy heRhoThermo singleStepReactingMixture sutherland janaf perfectGas specie sensibleInternalEnergy heRhoThermo veryInhomogeneousMixture const hConst incompressiblePerfectGas specie sensibleEnthalpy heRhoThermo veryInhomogeneousMixture const hConst perfectGas specie sensibleEnthalpy heRhoThermo veryInhomogeneousMixture sutherland janaf incompressiblePerfectGas specie sensibleEnthalpy heRhoThermo veryInhomogeneousMixture sutherland janaf perfectGas specie sensibleEnthalpy
每一个配置都是代表了什么具体可以去User Guide中查询
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 FoamFile { version 2.0 ; format ascii; class dictionary ; location "constant" ; object thermophysicalProperties; } thermoType { type heRhoThermo; mixture reactingMixture; transport sutherland; thermo janaf; energy sensibleEnthalpy; equationOfState perfectGas; specie specie; } dpdt no; chemistryReader foamChemistryReader; foamChemistryFile "$FOAM_CASE/constant/reactions" ; foamChemistryThermoFile "$FOAM_CASE/constant/thermo.incompressiblePoly" ; inertSpecie CO; liquids { } solids { }
然后我选择的是这个配置。为什么选择这个配置呢,因为每个transport 和thermo的计算方法都需要配置对应的foamChemistryThermoFile, OF的tutorial中只有部分气体或者液体的热物性配置而且使用的transport和thermo的方式也都不对应,这个困扰了我很久。然后我发现了下面这个库。这里面是通过chemkinToFoam 转换其他数据库到OF的格式的。所以我就直接在其中搜寻了我需要的气体的配置,然后就套在了我的模拟中。
1 https://github.com/ZhangYanTJU/chemicalMechanisms
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 H2 { specie { nMoles 1 ; molWeight 2.01594 ; } thermodynamics { Tlow 200 ; Thigh 3500 ; Tcommon 1000 ; highCpCoeffs ( 3.3372792 -4.94024731e-05 4.99456778e-07 -1.79566394e-10 2.00255376e-14 -950.158922 -3.20502331 ); lowCpCoeffs ( 2.34433112 0.00798052075 -1.9478151e-05 2.01572094e-08 -7.37611761e-12 -917.935173 0.683010238 ); } transport { As 6.362e-07 ; Ts 72 ; } elements { H 2 ; } } N2 { specie { nMoles 1 ; molWeight 28.0134 ; } thermodynamics { Tlow 200 ; Thigh 5000 ; Tcommon 1000 ; highCpCoeffs ( 2.92664 0.001487977 -5.684761e-07 1.009704e-10 -6.753351e-15 -922.7977 5.980528 ); lowCpCoeffs ( 3.298677 0.00140824 -3.963222e-06 5.641515e-09 -2.444855e-12 -1020.9 3.950372 ); } transport { As 1.512e-06 ; Ts 120 ; } elements { N 2 ; } } CH4 { specie { nMoles 1 ; molWeight 16.04303 ; } thermodynamics { Tlow 200 ; Thigh 3500 ; Tcommon 1000 ; highCpCoeffs ( 0.074851495 0.0133909467 -5.73285809e-06 1.22292535e-09 -1.0181523e-13 -9468.34459 18.437318 ); lowCpCoeffs ( 5.14987613 -0.0136709788 4.91800599e-05 -4.84743026e-08 1.66693956e-11 -10246.6476 -4.64130376 ); } transport { As 1.512e-06 ; Ts 120 ; } elements { C 1 ; H 4 ; } } CO2 { specie { nMoles 1 ; molWeight 44.00995 ; } thermodynamics { Tlow 200 ; Thigh 3500 ; Tcommon 1000 ; highCpCoeffs ( 3.85746029 0.00441437026 -2.21481404e-06 5.23490188e-10 -4.72084164e-14 -48759.166 2.27163806 ); lowCpCoeffs ( 2.35677352 0.00898459677 -7.12356269e-06 2.45919022e-09 -1.43699548e-13 -48371.9697 9.90105222 ); } transport { As 1.572e-06 ; Ts 240 ; } elements { C 1 ; O 2 ; } } CO { specie { nMoles 1 ; molWeight 28.01055 ; } thermodynamics { Tlow 200 ; Thigh 3500 ; Tcommon 1000 ; highCpCoeffs ( 2.71518561 0.00206252743 -9.98825771e-07 2.30053008e-10 -2.03647716e-14 -14151.8724 7.81868772 ); lowCpCoeffs ( 3.57953347 -0.00061035368 1.01681433e-06 9.07005884e-10 -9.04424499e-13 -14344.086 3.50840928 ); } transport { As 1.512e-06 ; Ts 120 ; } elements { C 1 ; O 1 ; } } C2H6 { specie { nMoles 1 ; molWeight 30.07012 ; } thermodynamics { Tlow 200 ; Thigh 3500 ; Tcommon 1000 ; highCpCoeffs ( 1.0718815 0.0216852677 -1.00256067e-05 2.21412001e-09 -1.9000289e-13 -11426.3932 15.1156107 ); lowCpCoeffs ( 4.29142492 -0.0055015427 5.99438288e-05 -7.08466285e-08 2.68685771e-11 -11522.2055 2.66682316 ); } transport { As 1.512e-06 ; Ts 120 ; } elements { C 2 ; H 6 ; } } C2H2 { specie { nMoles 1 ; molWeight 26.03824 ; } thermodynamics { Tlow 200 ; Thigh 3500 ; Tcommon 1000 ; highCpCoeffs ( 4.14756964 0.00596166664 -2.37294852e-06 4.67412171e-10 -3.61235213e-14 25935.9992 -1.23028121 ); lowCpCoeffs ( 0.808681094 0.0233615629 -3.55171815e-05 2.80152437e-08 -8.50072974e-12 26428.9807 13.9397051 ); } transport { As 1.512e-06 ; Ts 120 ; } elements { C 2 ; H 2 ; } } C3H8 { specie { nMoles 1 ; molWeight 44.09721 ; } thermodynamics { Tlow 200 ; Thigh 5000 ; Tcommon 1000 ; highCpCoeffs ( 7.525217 0.01889034 -6.283924e-06 9.179373e-10 -4.81241e-14 -16464.55 -17.8439 ); lowCpCoeffs ( 0.8969208 0.02668986 5.431425e-06 -2.126001e-08 9.24333e-12 -13954.92 19.35533 ); } transport { As 1.512e-06 ; Ts 120 ; } elements { C 3 ; H 8 ; } }
inertSpecie 是用来归一化使用的,如果你的组分总和<1的话,会使用你设置的这个组分来填补剩下的部分,我这个case就是用CO来填补。
在reaction 文件中,你要设置参与模拟的species,例如我的情况:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 species ( air H2 N2 CH4 CO2 CO C2H6 C2H2 C3H8 ); reactions {}
0文件夹中要添加的文件
Ydefault field,具体原因还没有搞清
其余气体都要创建一个scalar field。
在第2步的情况有个坑!这里面每个组分的比例使用的并不是体积百分比,也不是摩尔比,而是质量比!
下面部分再次是用AI生成的
在你的 thermoType 设置中,密度的计算逻辑主要由 heRhoThermo 和 perfectGas 这两个关键字决定。
以下是 OpenFOAM 内部处理密度的具体机制:
1. 计算核心:perfectGas (状态方程) 当你指定了 equationOfState perfectGas; 时,OpenFOAM 会在代码层面调用理想气体状态方程。对于混合气体,每一单元格的密度 $\rho$ 计算公式如下:
$$\rho = \frac{p}{R_{mix} T}$$
其中:
$p$ : 该网格的瞬时压力。
$T$ : 该网格的瞬时温度。
$R_{mix}$ : 混合气体的比气体常数。
2. $R_{mix}$ 的来源 (组分耦合) 由于你使用的是 reactingMixture,OpenFOAM 会根据各个组分($H_2, CO, CO_2$ 等)的实时质量分数 ($Y_i$) 来计算混合物的比气体常数:
$$R_{mix} = \sum_{i} (Y_i \cdot R_i) = \sum_{i} \left( Y_i \cdot \frac{R_{u}}{M_i} \right)$$
$R_{u}$ : 通用气体常数 ($8.31446 \text{ J/(mol}\cdot\text{K)}$)。
$M_i$ : 组分 $i$ 的摩尔质量(即你在 chemkin/therm.dat 或 thermophysicalProperties 中定义的 molWeight)。
3. heRhoThermo 的特殊性 你选择的 type 是 heRhoThermo :
这种模型通常用于可压缩流动 。
它直接将密度 $\rho$ 作为基本热物理变量进行更新(相对于 hePsiThermo 使用压缩性系数 $\psi$)。
在求解器(如 reactingFoam)的每个时间步中,程序会先根据能量方程解出温度 $T$,然后立即调用 equationOfState(即上面的公式)来更新 $\rho$。
在 OpenFOAM 中,组分的密度并不是在一个单一的“地方”简单定义的,而是通过热物理模型库 (Thermophysical Models) 及其关联的状态方程 (Equation of State) 动态计算出来的。
具体到你的情况(多组分气体),密度的计算逻辑如下:
1. 核心计算位置:状态方程 (Equation of State) OpenFOAM 通过 src/thermophysicalModels 文件夹下的代码执行计算。对于气体,最常用的模型是 perfectGas(理想气体状态方程):
$$p = \rho R T$$
在代码层面,每一层(Cell)的密度 $\rho$ 是由该网格当前的压力 $p$、温度 $T$ 以及该网格内混合气体的气体常数 $R$ 计算得出的。
2. 关键参数:混合气体的 $R$ (Gas Constant) 这是你之前结果出错的症结所在。混合气体的 $R$ 是根据各组分的质量分数 ($Y_i$) 加权平均计算的:
$$R_{mix} = \sum (Y_i \cdot R_i) = \sum \left( Y_i \cdot \frac{R_{universal}}{M_i} \right)$$
其中 $M_i$ 是各组分的摩尔质量(分子量)。
如果你输错了 $Y_i$(比如把体积比当成质量比) :$R_{mix}$ 就会算错。
计算链条 :输入 $Y_i \rightarrow$ 计算 $R_{mix} \rightarrow$ 结合 $P, T \rightarrow$ 计算 $\rho$。