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 result of the simulation is on YouTube . You can download the case and simulate the InterFoam[2]

YouTube

By loading the video, you agree to YouTube's privacy policy.
Learn more

Load video

PGlmcmFtZSB0aXRsZT0iaW50ZXJGb2FtIGV4YW1wbGUgT3BlbkZvYW0gLSBtaXhpbmcgYWlyIHdpdGggZ2FzIiB3aWR0aD0iMTIwMCIgaGVpZ2h0PSI2NzUiIHNyYz0iaHR0cHM6Ly93d3cueW91dHViZS1ub2Nvb2tpZS5jb20vZW1iZWQvTjYzUFJzMWFkbVk/ZmVhdHVyZT1vZW1iZWQiIGZyYW1lYm9yZGVyPSIwIiBhbGxvdz0iYWNjZWxlcm9tZXRlcjsgYXV0b3BsYXk7IGNsaXBib2FyZC13cml0ZTsgZW5jcnlwdGVkLW1lZGlhOyBneXJvc2NvcGU7IHBpY3R1cmUtaW4tcGljdHVyZTsgd2ViLXNoYXJlIiByZWZlcnJlcnBvbGljeT0ic3RyaWN0LW9yaWdpbi13aGVuLWNyb3NzLW9yaWdpbiIgYWxsb3dmdWxsc2NyZWVuPjwvaWZyYW1lPg==

 

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

In the next step the type of simulation will be defined. In this case a multi-phase flow is used. The solver will be interFoam. The values which have to be set are shown in the image below.

 

Initial parameters for the interFoam solver

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).

  • outlet:
    • velocity: “zero Gradient” 
    • pressure: “total pressure” = 0
    • Phase Fraction: “Inlet Outlet” = 0
  • inlet:
    • 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.