openFOAM combustion模块学习笔记——程序结构

基础资料

废话不多说,首先罗列一些笔者参考的资料

openFOAM的官方网站为:https://openfoam.org/
东岳流体网站:http://www.dyfluid.com/
本文使用的为openFOAM7版本,可以从网上下载到提前预装好的虚拟机,从而避免了安装的麻烦。
openFOAM7安装和虚拟机:http://www.dyfluid.com/docs/install.html
openFOAM7网页用户手册:https://cfd.direct/openfoam/user-guide/
另外openFOAM还对应了一本英文的算法书《The Finite Volume Method in Computational Fluid Dynamics》,而且用户手册在CSDN可以找到中文翻译版,其中一个版本主要为东岳流体翻译。
另外在b站也有很多线上的视频资料,这里不一一罗列。

combustion/chem文件夹

我们主要关注燃烧,即如下路径中的几个算例以及其拓展

~/OpenFOAM/OpenFOAM-7/tutorials/combustion/

这个模块中,包含如下部分:

dyfluid@dyfluid:~/OpenFOAM/OpenFOAM-7/tutorials/combustion$ ls
chemFoam        fireFoam  reactingFoam  XiFoam
coldEngineFoam  PDRFoam   XiEngineFoam

目前笔者正在阅读的是chemFoam,这里主要计算的是纯化学反应。

dyfluid@dyfluid:~/OpenFOAM/OpenFOAM-7/tutorials/combustion$ cd chemFoam/
dyfluid@dyfluid:~/OpenFOAM/OpenFOAM-7/tutorials/combustion/chemFoam$ ls
gri  h2  ic8h18  ic8h18_TDAC  nc7h16  README

代码还给我们准备了README文件,内容如下:

Stiff chemistry solver validation test cases

gri    : GRI-Mech 3.0. CH4 combustion, 53 species, 325 reactions
h2     : H2 combustion, 10 species, 27 reactions
nc7h16 : n-Heptane combustion, 544 species, 2446 reactions
ic8h18 : iso-Octane combustion, 874 species, 3796 reactions

Results interpreted in 'validation' sub-directory, where OpenFOAM results
are compared against those predicted by CHEMKIN II.

Overall the best performing ODE solver is seulex followed closely by rodas23.

即当前几个文件夹分别对应几个纯化学反应,用来验证刚性的化学反应求解器是否有效。并在validation中将当前结果与CHEMKIN II中的计算结果进行比较。结论是seulexrodas23这两个求解器性能较好。

h2算例的执行

我们参考OpenFOAM教程中的方法,首先将h2整个文件夹复制到如下路径:

dyfluid@dyfluid:~/OpenFOAM/dyfluid-7/run/h2/validation$ cd ~/OpenFOAM/OpenFOAM-7/tutorials/combustion/chemFoam/
dyfluid@dyfluid:~/OpenFOAM/OpenFOAM-7/tutorials/combustion/chemFoam$ cp -rf h2/ ~/OpenFOAM/dyfluid-7/run/

进入复制后的文件夹中,运行方式有两种,可以通过文件夹中的./Allrun./Allclean运行以及结果的删除,或者直接执行预设的命令chemFoam。注意两者的区别,前者为编译好的可执行文件,后者为一个预设的命令。从执行结果来看,前者将本来应该输出到终端的部分,保存在了一个日志文件log.ChemFoam中。

这里给出一部分执行输出:

dyfluid@dyfluid:~/OpenFOAM/dyfluid-7/run/h2$ chemFoam 
/*---------------------------------------------------------------------------*\\
  =========                 |
  \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\\\    /   O peration     | Website:  https://openfoam.org
    \\\\  /    A nd           | Version:  7
     \\\\/     M anipulation  |
\\*---------------------------------------------------------------------------*/
Build  : 7-f1e51ce8d094
Exec   : chemFoam
Date   : Jun 08 2020
Time   : 21:36:19
Host   : "dyfluid"
PID    : 4519
I/O    : uncollated
Case   : /home/dyfluid/OpenFOAM/dyfluid-7/run/h2
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Overriding DebugSwitches according to controlDict
    SolverPerformance 0;

Constructing single cell mesh

Reading initial conditions.

Creating base fields for time 0
Reading thermophysical properties

Selecting thermodynamics package 
{
    type            heRhoThermo;
    mixture         reactingMixture;
    transport       sutherland;
    thermo          janaf;
    energy          sensibleEnthalpy;
    equationOfState perfectGas;
    specie          specie;
}

Selecting chemistryReader chemkinReader
Selecting chemistry solver 
{
    solver          ode;
    method          standard;
}

StandardChemistryModel: Number of species = 10 and reactions = 27
Selecting ODE solver seulex
Reading/calculating face flux field phi

pressure will be held constant.
 p   = 202650 [Pa]
 T   = 1000 [K] 
 rho = 0.589632 [kg/m^3]


Starting time loop

deltaT = 1e-07
Time = 1e-07

Qdot = -824.966, T = 1000, p = 202650, H2 = 0.0144672
ExecutionTime = 0.01 s  ClockTime = 0 s

deltaT = 1.9996e-07
Time = 2.9996e-07

Qdot = -789.321, T = 1000, p = 202650, H2 = 0.0144672
ExecutionTime = 0.01 s  ClockTime = 0 s

deltaT = 3.9976e-07
Time = 6.9972e-07

Qdot = -717.117, T = 1000, p = 202650, H2 = 0.0144672
ExecutionTime = 0.01 s  ClockTime = 0 s

deltaT = 7.9888e-07
Time = 1.4986e-06

Qdot = -575.829, T = 1000, p = 202650, H2 = 0.0144672
ExecutionTime = 0.01 s  ClockTime = 0 s

deltaT = 1.59776e-06
Time = 3.09636e-06

...

Number of steps = 45
End

chemFoam的源代码

我们希望通过阅读单独的算例,了解openFOAM整体程序的运行机制,而不是纯粹机械的改参数跑程序。而所有的程序代码,保存在如下路径:

dyfluid@dyfluid:~/OpenFOAM/OpenFOAM-7/applications

我们刚才使用的chemFoam在其中的如下文件夹中:

dyfluid@dyfluid:~/OpenFOAM/OpenFOAM-7/applications/solvers/combustion/chemFoam

其中包括如下内容:

dyfluid@dyfluid:~/OpenFOAM/OpenFOAM-7/applications/solvers/combustion/chemFoam$ ls
chemFoam.C              hEqn.H                   setDeltaT.H
createBaseFields.H      Make                     solveChemistry.H
createControls.H        output.H                 thermoTypeFunctions.H
createFieldRefs.H       pEqn.H                   YEqn.H
createFields.H          readControls.H
createSingleCellMesh.H  readInitialConditions.H

好!本帖就到这里,接下来会尝试阅读这里面源文件的内容。

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片