2024 of Shooting
2024 of Shooting
𝑑𝑓 𝜈𝑢∞ 𝑑𝑓 𝑢∞
𝑢(𝑥, 𝑦) = 𝑢∞ (𝜂), 𝑣(𝑥, 𝑦) = √ (𝜂 (𝜂) − 𝑓(𝜂)), 𝜂 = 𝑦√
𝑑𝜂 4𝑥 𝑑𝜂 𝜈𝑥
where 𝑢∞ (𝑚/𝑠) is the free stream velocity far from the wall and 𝜈(𝑚2 /𝑠) is the kinematic viscosity.
Observe that one of the BCs is given at 𝜂 = ∞. #### Shooting method, The Blasius’ equation
can be formulated as a first-order system of ODEs. Let 𝑢1 = 𝑓, 𝑢2 = 𝑓 ′ and 𝑢3 = 𝑓 ″
𝑑𝑢1
= 𝑢2 , 𝑢1 (0) = 0
𝑑𝜂
𝑑𝑢2
= 𝑢3 , 𝑢2 (0) = 0
𝑑𝜂
𝑑𝑢3 1
= − 𝑢1 𝑢3 , 𝑢3 (0) = 𝑠
𝑑𝜂 2
where 𝑠, the shooting parameter is to be computed so that 𝑢2 (𝑠, 𝐿) = 1, where 𝐿 is large number.
Python Implimentation
[7]: #important modules
import sys
import numpy as np
import matplotlib.pyplot as plt
[8]: # We use Runge kutta order four for solving the sistem
def RungeKutta4(f, a, L, u, N):
"""
1
A function for numerical solution using RK4
Imputs:
=======
f : the right side fucntion of the system of ODE
a : eta = a in the domain interval [a, L]
L : eta = L
u : the initial condition
N : number of grid points
Returns:
========
grid points
numerical solution
"""
h = (L - a) / N # step size
result = [] # empty list for storing the numerical solution
grid = [] # empty list for storing the grid points
result.append(u)
grid.append(a)
x = a
for i in range(1, N + 1): # implementation of RK4 algorithm
k1 = f(x, u)
k2 = f(x + h / 2, u + h * k1 / 2)
k3 = f(x + h / 2, u + h * k2 / 2)
k4 = f(x + h, u + h * k3)
u = u + h * (k1 + 2 * k2 + 2 * k3 + k4)/6
x = x + h
result.append(u)
grid.append(x)
return np.array(grid), np.array(result)
[11]: #formulate as a first-order system and define the right side function for the␣
↪nonlinear ode
2
f[1] = u[2]
f[2] = -0.5 * u[0] * u[2]
return f
[12]: # the secant method for solving the algebric equation F(s) = 0
def Secant(F, s0, s1, tol, itr, L):
global s
F0 = F(s0, L)
F1 = F(s1, L)
iteration_counter = 0
[13]: # Parameters
a = 0
b = 1
L = 6
N = 100 # number of grid points
s = 0.33256594137380135
number of iteration = 6
3
[14]: # Now we use the approperaite shooting parameter in the initial condition and␣
↪solve for the system of ODE
u = u0(s)
grid, result = RungeKutta4(f, a, L, u, N)
Comparing result for different values of 𝐿 (say 𝐿 = 1, 3, 6, 16) and check the convergence
of the 𝑓(𝜂)- curve.
[17]: Ls = [1, 3, 6, 16]
ss = []
no_iterationss = []
results = []
4
plt.figure(figsize=(12, 8))
for l in range(0,len(Ls)):
s, it = Secant(F, s0, s1, eps, max_iteration, Ls[l])
ss.append(s)
no_iterationss.append(it)
u = u0(s)
grid, result = RungeKutta4(f, a, Ls[l], u, N)
results.append(result) # here we store the solution of f for different␣
↪value of L
plt.subplot(2, 2, l+1)
plt.plot(grid, result[:, 1],'r')
plt.xlabel('$\eta$')
plt.ylabel("f")
plt.ylim([0,1.2])
plt.grid(True)
plt.legend(["f', where L = "+ str(Ls[l])])
plt.show()
5
0.2 Q: Extend the code to compute the velocity components using the formula
given in the slide. Discus the application with PhD students from fluid
streem.
[ ]:
[ ]: