Understanding the CFL Number: Physical significance and Best Practices
CFL Number
Author: Krishnendu GS
Convergence in CFD refers to the process where the solution of the simulation steadily approaches a consistent value as the number of iterations increases. A converged solution indicates that the simulation has stabilized and is no longer changing significantly with further iterations, signalling that the results are reliable. Achieving convergence is often linked to factors like mesh quality, boundary conditions, time step size, and numerical methods.
One of the key factors contributing to the stability of CFD simulations is the Courant-Friedrichs-Lewy (CFL condition), a crucial condition that governs the simulation. The CFL condition ensures that the solution updates are synchronized with the physical constraints of the flow, which is critical for maintaining stability and accuracy in the simulation. By adhering to the CFL condition, CFD experts can produce reliable results for a variety of engineering applications. In this discussion, we will explore the importance of the CFL condition and its role in CFD simulations.
What is CFL Condition?
The CFL condition is a stability criterion derived by mathematicians Richard Courant, Kurt Friedrichs, and Hans Lewy in 1928 [1]. This condition is essential when solving certain partial differential equations (PDEs), particularly those that model wave-like phenomena (usually hyperbolic PDEs), using explicit time-marching schemes. CFL condition quantifies how far the flow (or wave) travels within a computational cell during a single time step. In other words, it is the fraction of the cell size covered by the flow in one time step, based on the local velocity. If this ratio exceeds the prescribed value, the simulation will yield incorrect or unstable results. This stability criterion is essential when applying explicit time-marching solvers for numerical solutions.
The CFL Condition in One Dimension
Here as depicted in Fig. 1, the flow moves a distance Ut across the cell in a time step
t. In this case the CFL number is the ratio of the distance the flow moves in
t time step (U
t) to the length of the cell (
x).
CFL is the maximum permissible value for the Courant number, which depends on the numerical method being used. For explicit solvers, the maximum value of the Courant number is typically CFL
= 1. A schematic representation of the wave or flow propagation with respect to CFL is shown in Fig 2.
For a CFL number of 0.5, the wave travels only half the cell length in a single time step, ensuring stability as it remains well within the confines of the cell. When the CFL number is 1.0, the wave moves exactly one cell length per time step, which is still stable for many explicit numerical schemes but approaches the stability limit. However, if the CFL number exceeds 1.0, the wave travels more than one cell length in a time step, potentially “jumping” over adjacent cells. This can cause numerical instability in explicit schemes, as the solution may fail to capture the wave’s behavior accurately, leading to erroneous results.
In certain compressible flow calculations, it is essential to compute the Acoustic Courant number to assess stability. Acoustic Courant number measures the fraction of a computational cell that a sound wave travels within a time step and is particularly significant in high-speed flows, aeroacoustics, and shockwave modelling. For a one-dimensional grid, the acoustic Courant number is defined as the ratio of the distance a sound wave travels during a time step to the cell size.
To ensure numerical stability in explicit solvers, the Acoustic Courant number must remain less than or equal to 1, preventing sound waves from crossing multiple cells in a single time step. By adhering to this condition, simulations can accurately resolve acoustic phenomena and maintain the stability of compressible flow calculations.
The CFL Condition in Two and Higher Dimensions
In two dimensions, the CFL condition expands to:
Where u and u
represent the velocity components in the x and y directions, respectively, and
x and
y are the spatial step sizes in the respective directions.
For general n-dimensional cases, the CFL condition becomes:
Where u is the velocity component in the i-th spatial dimension, and
is the spatial step size in that dimension. This formula accounts for the fact that the interval lengths may vary in different spatial directions, allowing for optimization of the time step in some cases.
For unstructured grids with complex shapes, directly measuring the distance across a cell can be challenging. In such cases, the distance across the cell can be approximated by considering the ratio of the cell’s volume to its total surface area. The velocity considered is the component normal to the cell face. As shown in Fig. 3, the shaded area represents the distance moved across the cell in one time step, with the velocity normal to the face given by ().
Based on the continuity equation, if we calculate the velocity normal to each face and sum these terms, the result will be zero, . This occurs because the mass flow entering and exiting each cell must balance (Fig. 4).
To avoid this, we use the magnitudes of for each face, rather than the velocity components with direction. This approach effectively reverses half of the flux (Fig. 5), ensuring the total is nonzero.
The resulting CFL is
If we sum the flux magnitudes for all faces of a cell, each face flux is effectively counted twice, once for the current cell and once for its neighbour. To avoid this double counting, we take only half of the summed flux magnitudes. This adjustment ensures that the flux is not overestimated and accurately represents the effective flow across each face for the current cell. The actual CFL is then given by:
Physical Significance
- When the Courant number exceeds the maximum allowable value (
) ,the simulation becomes unstable. This instability can cause numerical oscillations or lead to the blow-up of the solution, producing unphysical results.
- When the Courant number is kept within the allowable limit (
), the simulation remains stable. This ensures that the solution maintains accuracy over time and avoids divergence.
In general, the Courant-Friedrichs-Lewy condition establishes a relationship between the grid spacing (x) and the time step (
t). Specifically, reducing the grid spacing (
x) necessitates a smaller time step (
t) to maintain stability. A smaller grid spacing allows information to travel over shorter distances more quickly, requiring a reduced time step to ensure that the information doesn’t propagate faster than the physical wave speed. Therefore, both
x and
t must be carefully selected to ensure stable and accurate simulations.
The Role of the CFL Condition in CFD Simulations
The CFL condition plays a crucial role in determining the stability of CFD simulations. A well-chosen time step ensures that the numerical solution updates are synchronized with the physical constraints of the flow, enabling the simulation to proceed without errors. If the CFL condition is violated, the solver may fail to converge, or the solution may become physically meaningless. The Courant number has different implications depending on the numerical methods used:
- Explicit Methods:
- Explicit methods compute the future state of a system using the current state as the starting point. These methods rely on known values at the current time step to estimate values at the next time step.
- The calculation typically follows a direct and straightforward approach, making explicit methods computationally efficient.
- However, they are subject to stability constraints, such as the CFL condition, which limits the allowable time step size.
- Choosing a time step that exceeds this limit may result in instability.
- Instability caused by an overly large time step can lead to inaccurate results.
- Implicit Methods:
- Implicit methods determine the next time step by solving a system of equations that depends on both the current and future states.
- Implicit methods can effectively handle stiff or highly transient problems, they are less constrained by the CFL condition compared to explicit methods.
- Despite the higher computational expense, they enable larger time steps, which can result in more efficient simulations for certain applications.
Common Challenges
- Balancing Accuracy and Efficiency:
- Smaller time steps improve accuracy but increase computational cost.
- Larger time steps reduce runtime but risk instability.
- Dynamic Behaviour:
- In complex simulations with varying velocities (e.g., turbulent flows), the Courant number can fluctuate significantly, requiring adaptive time-stepping.
- Mesh Refinement:
- A finer mesh (smaller) reduces the allowable time step, increasing computational demands.
Time Step Calculation Based on the Courant Number
The time step (t) in a CFD simulation is directly linked to the grid spacing (
x), the flow velocity (u), and the Courant number (CFL):
5.1 Example: Time Step Calculation for a Simple CFD Case
Consider a 1D convection problem where a fluid with velocity u=10m/s flows over a domain discretized with a uniform grid spacing of x=0.001m. The simulation uses an explicit time-marching solver, and the maximum allowable Courant number is CFL
=1.
To calculate the maximum time step:
This means the time step must be 0.0001s or smaller to ensure numerical stability.
Courant Number (CFL) field
The Courant number can be represented as a field across the mesh, where each cell has a value determined by its velocity, size, and shape. The motorbike example from OpenFOAM shows how smaller cells result in higher Courant numbers (Fig 6), even with relatively low velocities (Fig 7). Larger cells, on the other hand, lead to lower Courant numbers.
As discussed in the previous sections, if the current CFL exceeds the maximum permissible value, the solver may diverge. If this occurs, plotting the Courant number field helps identify regions with the maximum CFL, allowing for adjustments to the mesh or time step to ensure a stable and efficient simulation. There are two ways to adjust time step, fixed time stepping and adjustable time stepping.
- Fixed Time Step Method:
In this approach, a constant time step size is selected based on the expected maximum Courant number in the domain. This method simplifies implementation but requires prior knowledge of the flow field and often leads to overly conservative time steps, particularly in regions with small cells or high velocities. Once the Courant number field is analyzed, the time step can be adjusted to address these issues. - Adjustable Time Step Method:
This method dynamically adjusts the time step size during the simulation to ensure the maximum Courant number remains below a specified threshold. It is particularly useful for simulations with varying flow conditions or complex geometries, as it optimizes computational efficiency while maintaining stability.
Best Practices for Setting Up the CFL Condition
- Start with Conservative Estimates: For explicit solvers, use a Courant number below the maximum allowable value (CFL
=1) as a starting point. For implicit solvers, you can use higher CFL values but monitor for loss of accuracy.
- Refine Based on Flow Features: If the simulation involves regions with high-velocity gradients, such as shock waves or boundary layers, use local CFL constraints to ensure stability in these critical regions.
- Adapt for Mesh Non-Uniformity: In simulations with non-uniform grids, ensure that the time step satisfies the CFL condition in the smallest cells, as they impose stricter stability requirements.
- Monitor Residuals and Convergence: Adjust the CFL number if residuals show oscillations, or the solution fails to converge.
Conclusion
The Courant-Friedrichs-Lewy (CFL) condition is a fundamental concept in numerical simulations, particularly in computational fluid dynamics (CFD). It ensures the stability of explicit time-marching solvers by limiting the size of the time step relative to the spatial resolution. Understanding and adhering to the CFL condition is crucial for obtaining accurate and stable results, especially in high-fidelity simulations that inform important engineering decisions. By carefully managing the Courant number, CFD practitioners can avoid numerical instability and ensure their simulations produce realistic, reliable results.
References:
[1] Courant, R., Friedrichs, K., & Lewy, H. (1967). On the partial difference equations of mathematical physics. IBM journal of Research and Development, 11(2), 215-234.
Our CFD Courses:
CFD Foundation Course
The first course in CFD to build a strong foundation in theory, coding, and CFD Tools.
Ansys Fluent Beginners to Advanced Level
A comprehensive course to gain a strong grip on the CFD tool, ANSYS Fluent
OpenFOAM for Beginners
The beginner's course to learn and master the most popular open-source CFD tool.
Scientific Computing with C++ : Part1
Learn C++ from scratch to the advanced level for scientific programming
Introduction to FSI
The beginner's course to learn and master the most popular open-source CFD tool.
Introduction to Finite Element Method
A course to learn the fundamentals of the Finite Element Method
Scientific Computing with Python
Learn Python from scratch to the advanced level for scientific programming
Scientific Computing with C++ : Part2
Learn C++ for scientific computing with advanced features
StarCCM+ for a Beginner
This is a beginner's course to learn and master one of the most popular and demanding CFD Tools in the…
Fluid Dynamics for CFD: Part1
Learn the fundamentals of fluid dynamics from a practical perspective
UDF, User defined function (ANSYS Fluent)
Learn UDF & C programming and be a Pro to customize ANSYS Fluent
ML/AI for Fluid Dynamics: A comprehensive training
11 days live workshop on ML and AI of Fluid dynamics in Collaboration with the University of Michigan by Prof. Ricardo Vinuesa
Fundamentals and CFD of Aero-Acoustics
7 days live workshop over weekends to learn High-speed aerodynamics: Theory, Implementation and Hands-on Problems
AI/ML for Fluids Dynamics: An online course
Learn AI/ML for fluid dynamics in a practical way
OpenFOAM- Rotating machine
OpenFOAM rotating machinery course covering MRF, AMI, and CFD workflows. Live sessions, practical examples, and expert guidance included
Responses