0% found this document useful (0 votes)
3 views2 pages

Python Implementation

The document presents a Python script for simulating 2D fully developed channel flow under steady, incompressible conditions with no body forces. It utilizes the Navier-Stokes equations and applies boundary conditions to solve for velocity profiles using numerical methods. The results are visualized through contour plots and velocity profiles at the mid-channel.

Uploaded by

Ryad Bma
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Python Implementation

The document presents a Python script for simulating 2D fully developed channel flow under steady, incompressible conditions with no body forces. It utilizes the Navier-Stokes equations and applies boundary conditions to solve for velocity profiles using numerical methods. The results are visualized through contour plots and velocity profiles at the mid-channel.

Uploaded by

Ryad Bma
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

python script for 2D fully developed channel flow :

assumptions :
-​ steady
-​ incompressible
-​ 2D/2C
-​ no body forces
∂𝑣
and from the continuity equation we get : ∂𝑦 = 0 ⇒ 𝑣 = 𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡
applying boundary conditions we get : 𝑣 = 0
∂²𝑢 1 ∂𝑝
Thus the x-navier stokes equation reduces to : ∂𝑦² = µ × ∂𝑥
import numpy as np
import [Link] as plt

h = 1
l = 5
ny = 200
nx = 50
mu = 0.0000182
dpdx = -0.05
e = 10e-6
y = [Link](0, h, ny)
x = [Link](0,l,nx)
X, Y = [Link](x, y)
dy = y[1]-y[0]
u = [Link]((ny,nx))
u[0,:] = 0
u[-1,:] = 0
for _ in range(1000) :
u_new = [Link]()
for j in range(1,ny-1) :
for i in range(nx) :
u[j,i] = 0.5*((u[j+1,i]+u[j-1,i])-((dpdx/mu)*pow(dy,2)))
tolerance = [Link]([Link](u-u_new))
if [Link]() <= e :
break
[Link](figsize=(15,5))
[Link](1, 2, 1)
contour = [Link](X, Y, u, levels=20, cmap='gray')
[Link](contour, label='Velocity (m/s)')
[Link](X, Y, u, np.zeros_like(u), color='white', density=1.5, linewidth=0.7)
[Link]('2D Channel Flow Velocity Field')
[Link]('x (m)')
[Link]('y (m)')
[Link](1, 2, 2)
[Link](u[:,nx//2], y, 'ko', label='Numerical')
[Link]('Velocity Profile at Mid-Channel')
[Link]('Velocity (m/s)')
[Link]('y (m)')
[Link]()
[Link](True)
plt.tight_layout()
[Link]()

You might also like