interFoam Tutorial for OpenFoam
OpenFoam tutorial for the mixing of two gases with interFoam
In this tutorial we are using Helyx as a front end for OpenFoam to simulate the mixing of two gases. The complete workflow is displayed, from the STL modeling in Blender, Helyx to the postprocessing with Paraview is available at this page. The simulation start with all air within a cylinder . Then the air will be displaced by an inflow of Gas2, which also mixes with the air. The inflow comes through the inner pipe. The top lid of the cylinder is used as an outlet.
The first step is to load the geometry al STL files into snappyHexMesh. Then a base mesh is generated out of blockMesh. The parameters are shown in the images below. The meshing is done with a refinement at the walls of the inlet-pipe. checkMesh gives a quick overview if the mesh is alright.
The boundary conditions must be set next. The outlet is set to Phase Fraction: “Inlet Outlet” = 0 which means that a potential back flow will be air. The inflow is from type Gas2 (this has the same properties in this simulation like air).
- velocity: “zero Gradient”
- pressure: “total pressure” = 0
- Phase Fraction: “Inlet Outlet” = 0
- velocity: “volumetric flow rate inlet” = 0.05 m³/s
- pressure: zero gradient
- Phase Fraction: “Inlet Outlet” = 1
The field must be initilised with one gas. In this case this will be 0 which is air. With functions in openFoam the field initialisation can also be used to set only a part of the valome to a certain value. Here this coud be a partly filling of the cylinder with one or the other fluid. However, the cylinder is filld only with air in this simulation.
At last the solver settings must be set and the runtime controls have to be defined. A timestep of 0.001 s should be small enough here. It’s possible to use a Adjustable time step to get the simulation always calculating on the highest efficency. In theroy time step will be decreased if the convcergence is to low and it will be increased if the convergence is good enough. Here the time step will be choosen from the courant number which will saty the same. The Courant number is definet as how many cells the fuid can travel during one time step. For example if a cell has an edge length of 1 mm x 1 mm x 1 mm and the fluid ist travelling 10 mm / s at this cell that the Courant number will be 10. If the Max Courant Number is set to 2 the algorithm will divide the actual time step by 5 to match the max. Courant number.