MATLAB Channel Flow Simulation

The Project

To simulate the velocity profile of a fluid flowing through a channel and determine the mass flow rate as a function of time.

Schematic

Fluid flows from left to right through an axisymmetric channel until the flow reaches a steady state.

Matlab flow schematic

Equations

The equations to be solved for this case after making assumptions, nondimensionalizing, and applying boundary conditions are:

Matlab flow equations.

Finite Difference Method

A grid will be placed over the region of interest to calculate the velocity at a given time and vertical distance.

Matlab flow finite difference method

A Taylor Series Expansion is used to obtain the final equation, using the velocities of a node and its neighboring values.

Matlab flow Taylor series

The Courant condition must be satisfied in order for the finite difference equation to be stable:

Matlab flow courant condition

Mass Flow Rate

At steady state, the velocity profile is constant:

Matlab flow constant velocity profile

The mass flow rate can therefore be calculated:

Matlab flow mass flow rate

MATLAB

The grid is represented using an array.

The script is written to determine if the flow has reached a steady state by checking the difference between the values of the last iteration and the current iteration to determine if the difference is below a given error. Once steady state is detected, the program stops.

An animation of the velocity profile plays until steady state is reached.

Matlab flow gif
Matlab 1
Matlab 2
Matlab 3
Matlab 4

Analytical vs. Numerical

The mass flow rate values are compared:

Matlab analytical versus numerical

This percent error is very low.