This project we are interested in estimating the temperature

This project we are interested in estimating the temperature at various locations along a rod. The temperatures at the end points of the rod are 0 C and 100 C respectively. The equation governing the temperature distribution is d^2T/dx^2 = 0 The exact solution of the equation leads to the temperature being given by T = 100 x, where times is any location along the road. In this project, we want to solve the equation numerically by approximating the second derivative as d^2T_i/dx^2 = T_i - 1 - 2T_i + T_i+1/delta x^2 Develop the system of linear equations for the three unknown temperatures shown in the Figure above. Solve the equations and compare the solution against the analytical result. Retina the mesh by using delta x = 0.1. Notice that you have more number of unknown temperatures at what mesh size does the maximum error in the numerical result drop below 5%.

Solution

-2*T2 + T3 = 0;

T2 - 2*T3 + T4 = 0;

T3 - 2*T4 + T5 = 0; T3 - 2*T4 = -100

Solving: T2 = 25, T3 = 50, T4 = 75 which is same as analytical results.

MATLAB Code:

clc
clear all
format long
n = 10; % Number of divisions
T(1,1) = -2;
T(1,2) = 1;

for i = 2:(n-2)
T(i,i-1) = 1;
T(i,i) = -2;
T(i,i+1) = 1;
end
T(n-1,n-2) = 1;
T(n-1,n-1) = -2;

b = zeros(n-1,1);
b(n-1) = -100;

Temp_numerical = inv(T)*b

% Analytical
x = (1/n):(1/n):(1-(1/n));
Temp_analytical = 100.*x

percent_error = (Temp_analytical\'-Temp_numerical).*100./Temp_analytical\'

OUTPUTS:

Temp_numerical =

9.999999999999995
19.999999999999989
29.999999999999989
39.999999999999993
49.999999999999986
59.999999999999986
69.999999999999986
79.999999999999986
89.999999999999986

Temp_analytical =

10.000000000000000
20.000000000000000
30.000000000000004
40.000000000000000
50.000000000000000
60.000000000000000
70.000000000000000
80.000000000000000
90.000000000000000

percent_error =

1.0e-13 *

0.532907051820075
0.532907051820075
0.473695157173400
0.177635683940025
0.284217094304040
0.236847578586700
0.203012210217171
0.177635683940025
0.157898385724467

Percent error is always less than 5%

 This project we are interested in estimating the temperature at various locations along a rod. The temperatures at the end points of the rod are 0 C and 100 C
 This project we are interested in estimating the temperature at various locations along a rod. The temperatures at the end points of the rod are 0 C and 100 C

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site