Improving Stability in OpenFoam

Convergence in OpenFoam

When setting up a simulation, stability is very important of the simulation. If a simulation does not converge, it often depends on the boundary conditions.

Get your simulation to converge
Stability and convergence often are limited by the chosen boundary conditions.

The 5 most common reasons for a not converging

The 5 most common reasons for a not converging CFD simulation are the following:

  1. Wrong or bad chosen boundary conditions
  2. Time step too large
  3. Instationary flow but use of a steady state solver
  4. Instationary boundary condition
  5. Bad mesh

The solutions for the problems might be the following:

  1. As a rule of thumb a boundary condition should always be set as pressure defined or flow defined, not both. For example, if you set a patch to a certain pressure, you define the flow as zero gradient and vice versa.
  2. The timestep can be checked by looking at the Courant number. The Courant Number is defined by how many cells a fluid flow can travel during one time step. For example at a cell is from size 10 mm x 10 mm x 10 mm and the flow velocity in this cell is 0.2 m/s, the Courant number is 20. If the Courant Number is lower than 10 the solution should be computable using the pimple algorithm. For the piso algorithm the Courant number should stay below (<1).
  3. Instationary flow will cause problems if you are computing using a fixed time step and a vortex is rising up the velocity in certain areas or volumes. The Courant number then can be too high to get a good convergence. If you are steady state solver like simpleFoam and vortexes a appearing it can happen, that the solver is not able to find that one solution. Simply use a solver like pimpleFom or pisoFoam.
  4. If instationary boundary conditions are used it can happen that the simulation will have trouble to converge. This can happen if you are using a fixed inflow velocity but you are stating with no velocity in your fluid cells of your mesh. One solution can be to initialise the flow using potentialFoam. The other solution is to increase to values of the boundary condition you are using using the commands and example below.
  5. A bad mesh can ruin everything. However, the mesh is often better than expected. From our experience the mesh is usually not the problem. Considering that mesh-building can take some time, all other possibility should be checked first. If you are using checkMesh on your mesh and checkMesh replies Mesh OK than you should definitely not worry too much about the mesh. Even id checkMesh does not like the mesh, you can get a perfectly working simulation if the four 1. – 4. are used before.

The question is: How can I improve the stability of a CFD simulation?

  • Which boundary conditions should I choose. What is better, fixed pressure or fixed volume flow. 
  • No drastic changes in the boundary conditions, no step functions. 
YouTube

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

Load video

PGlmcmFtZSB0aXRsZT0iSW1wcm92aW5nIFN0YWJpbGl0eSBDRkQgREVNIFNpbXVsYXRpb24gLSBGbHVpZGl6ZWQgQmVkIHdpdGggdGltZSBkZXBlbmRhYmxlIGJvdW5kYXJ5IGNvbmRpdGlvbiIgd2lkdGg9IjEyMDAiIGhlaWdodD0iNjc1IiBzcmM9Imh0dHBzOi8vd3d3LnlvdXR1YmUtbm9jb29raWUuY29tL2VtYmVkL2Q0S1NieFFpbGNJP2ZlYXR1cmU9b2VtYmVkIiBmcmFtZWJvcmRlcj0iMCIgYWxsb3c9ImFjY2VsZXJvbWV0ZXI7IGF1dG9wbGF5OyBjbGlwYm9hcmQtd3JpdGU7IGVuY3J5cHRlZC1tZWRpYTsgZ3lyb3Njb3BlOyBwaWN0dXJlLWluLXBpY3R1cmUiIGFsbG93ZnVsbHNjcmVlbj48L2lmcmFtZT4=

Examples

 

Here you can find two exaples how to set up a variable boundary condition in openFoam using a table. 

boundaryField
{
boundary_inletL
{
type uniformTotalPressure; 
p0 table 
(
( 0 240)
( 2 240)
( 3 320)
( 5 320)
( 6 400)
( 8 400)
( 9 440)
( 10 440)
);

}

boundary_inletR
{
type uniformFixedValue;
uniformValue table
(
( 0 240)
( 2 240)
( 3 320)
( 5 320)
( 6 400)
( 8 400)
( 9 440)
( 10 440)
);

One response to “Improving Stability in OpenFoam”

  1. Bo Zhang says:

    Hi Sir,

    Really nice tutorial! Really appreciate it if you could shear the relating scripts of the tutorial in the video.

    Best regards,
    Bo

Leave a Reply

Your email address will not be published. Required fields are marked *