Me24m026 Ahmt Na 2
Me24m026 Ahmt Na 2
COMPUTER ASSIGNMENT 2
Solution:
PYTHON CODE:
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp
from scipy.optimize import newton
# Boundary conditions
u[0, :] = 0 # u(0) = 0
v[0, :] = 0 # v(0) = 0
for Pr in Pr_values:
# Define function to find theta'(0) with root-finding
def temp_bc(guess):
theta_init = [0, guess] # Initial conditions for theta and its derivative
sol_theta = solve_ivp(temperature_ode, [0, xi], theta_init, args=(v[:, iterations], Pr),
t_eval=np.linspace(0, xi, num_points), rtol=1e-6)
return sol_theta.y[0][-1] - 1 # Condition for theta(xi_max) ≈ 1
theta_prime_0 = newton(temp_bc, 1, tol=1e-6)
theta_prime_values[Pr] = theta_prime_0
OUTPUT
Values of Theta' at xi=0 for different Prandtl numbers:
Pr = 0.1: 0.1181
Pr = 0.7: 0.2371
Pr = 1.0: 0.2926
Pr = 100: 3.2498
CODING
import numpy as np
# Domain
R=1
# Discretization
drdash = 0.01
N = int(R / drdash) + 1
rdash = np.linspace(0, 1, N)
K = 1001
tolerance = 1e-7
# Initial conditions
phi[0, :] = 0.0 # phi at rdash = 0
sci[0, 0] = 5 # initial guess for sci at rdash = 0
sci[0, 1] = 3 # another initial guess
# Start iteration
for k in range(K):
Nu = 2 * sci[0, k]
OUTPUT