0% found this document useful (0 votes)
9 views3 pages

Che 835 Final

The document contains a Python script that calculates and visualizes the temperature distribution along a cone using finite difference methods. It sets parameters for thermal properties and boundary conditions, constructs a linear system, and solves it to obtain temperature values. Finally, it plots the temperature profile against the distance from the tip of the cone.

Uploaded by

isratjahannipa29
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)
9 views3 pages

Che 835 Final

The document contains a Python script that calculates and visualizes the temperature distribution along a cone using finite difference methods. It sets parameters for thermal properties and boundary conditions, constructs a linear system, and solves it to obtain temperature values. Finally, it plots the temperature profile against the distance from the tip of the cone.

Uploaded by

isratjahannipa29
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
You are on page 1/ 3

import numpy as np

import matplotlib.pyplot as plt

# Parameters

R = 0.002 # m

H = 0.06 # m

h = 40 # W/m^2.K

K = 0.002 # W/m.K

T_a = 303 # °k

T_H = 363 # °k

# Discretization

N=5

x = np.linspace(0, H, N)

dx = 0.015

# Preallocate A and b

A = np.zeros((N, N))

b = np.zeros(N)

# Coefficients

for i in range(1, N-1):

xi = x[i]

alpha = xi**2 / dx**2 + xi/ dx

beta = -2 * xi**2 / dx**2 - (2 * h * H / (K * R)) * xi

gamma = xi**2 / dx**2 - xi/ dx


b_val = -(2 * h * H / (K * R)) * xi * T_a

A[i, i-1] = alpha

A[i, i] = beta

A[i, i+1] = gamma

b[i] = b_val

# Boundary conditions

A[0, 0] = 1

A[0, 1] = -1

A[-1, -1] = 1

b[0] = 0

b[-1] = T_H

# Solve the linear system

T = np.linalg.solve(A, b)

# Output results

print("Temperature distribution (°C):", T)

# Plot the results

plt.figure(figsize=(8, 5))

plt.plot(x, T, marker='o', linestyle='-', color='b', label='Temperature Profile')

plt.title("Temperature Distribution Along the Cone", fontsize=14)

plt.xlabel("Distance from Tip (x) [m]", fontsize=12)

plt.ylabel("Temperature (°C)", fontsize=12)


plt.grid(True, linestyle='--', alpha=0.7)

plt.legend(fontsize=12)

plt.show()

You might also like