Report: 2D Channel Flow Simulation Using Python
By : BENMISSOUM Aymene Mohammed Ryad
Objective: The aim of this practical work is to simulate fully developed 2D channel flow by
numerically solving the Navier-Stokes equations. This involves setting boundary conditions,
solving for the pressure and velocity fields using finite difference methods, and visualizing
the results.
1. Introduction
In fluid mechanics, simulating channel flow is a classic benchmark problem. The goal of this
simulation is to model the steady-state flow of an incompressible fluid through a
two-dimensional channel. To achieve this, the Navier-Stokes equations are solved
numerically using Python, with the finite difference method applied to discretize the
governing equations.
We assume a periodic flow in the x-direction, and the flow behavior is governed by a
combination of pressure forces and viscosity.
2. Problem Setup
The domain for this problem is a rectangular channel, with specified no-slip boundary
conditions at the top and bottom walls. The key aspects of the problem setup include:
Domain: A 2D rectangular channel discretized using a grid of points. The domain is divided
into small cells where calculations will be made.
Grid Parameters: The grid resolution is determined by the number of points in both the x
and y directions.
Boundary Conditions:
- No-slip condition: This is applied at the top and bottom channel walls, where the
velocity is zero.
- Periodic boundary conditions: These are applied at the inlet and outlet of the
channel to model continuous flow.
Assumptions:
● The fluid flow is steady and incompressible, meaning the fluid density remains
constant and the flow does not change over time.
● The viscous forces within the fluid are dominant, which is captured by the viscosity
parameter.
3. Approach
The problem is solved iteratively using the finite difference method, which discretizes space
and time into small steps. Here's a step-by-step breakdown of the process:
3.1 Functions Used in the Code
1. build_up_b Function:
This function calculates the term b used in the pressure equation, based on the current
velocity fields. It helps ensure the continuity equation is satisfied, which enforces mass
conservation in the fluid.
2. pressure_poisson_periodic Function:
This function solves the Poisson equation for pressure, ensuring that the pressure field is
updated in each time step. The periodic boundary conditions ensure that the pressure at the
outlet matches the pressure at the inlet.
3.2 Main Simulation Loop
The core of the simulation is a time-stepping loop that repeats the following steps:
1. Calculate the Source Term: The function build_up_b calculates the term that ensures
mass conservation.
2. Solve the Pressure Equation: Using the pressure_poisson_periodic function, the
Poisson equation for pressure is solved iteratively.
3. Update Velocity Fields: The velocity fields (both u and v components) are updated
based on the new pressure field and the previously computed velocities.
4. Apply Boundary Conditions: The periodic boundary conditions are applied along
the length of the channel, and no-slip conditions are maintained at the walls.
5. Check for Convergence: The loop continues until the velocity change between
iterations is sufficiently small, indicating that the solution has converged to a
steady-state.
4. Numerical Results and Visualization
Once the flow has reached a steady state, the following plots are generated using matplotlib:
1. Velocity Field Visualization:
A quiver plot is used to display the velocity vectors in the flow domain, giving a visual
representation of how the fluid moves through the channel.
2. Velocity Profile:
A contour plot is used to show the velocity distribution in the channel. Additionally, a 1D plot
along the midline of the channel shows the velocity profile, which gives insight into the fully
developed flow conditions.
The results provide insight into the velocity distribution and pressure variations in the
channel.
5. Discussion and Conclusion
The simulation results provide a detailed understanding of 2D incompressible flow in a
channel. The finite difference method was successfully used to solve the Navier-Stokes
equations and simulate steady flow conditions.
The code accurately models:
● The periodicity of the flow: Velocity and pressure values repeat between the inlet
and outlet.
● No-slip condition: The velocity is zero at the channel walls.
● Fully developed flow: The velocity profile flattens out towards the channel center,
indicating that viscous forces have smoothed the velocity gradients.