Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Assignment 4 word

The document presents Assignment 4 for a Computational Fluid Dynamics course, detailing a numerical analysis using the finite difference method to solve a differential equation. It compares numerical results with analytical solutions across different cases with varying stretching factors (r = 0.7, 0.9, and 1.0), highlighting the accuracy of the numerical method. The findings indicate that lower values of r yield better agreement with analytical results, while higher values introduce greater discrepancies.

Uploaded by

ratnesh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Assignment 4 word

The document presents Assignment 4 for a Computational Fluid Dynamics course, detailing a numerical analysis using the finite difference method to solve a differential equation. It compares numerical results with analytical solutions across different cases with varying stretching factors (r = 0.7, 0.9, and 1.0), highlighting the accuracy of the numerical method. The findings indicate that lower values of r yield better agreement with analytical results, while higher values introduce greater discrepancies.

Uploaded by

ratnesh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Assignment 4 (Date – 31/01/2025)

Submitted in partial fullfilment of the course

ME-864

COMPUTATIONAL FLUID DYNAMICS

in

THERMAL ENGINEERING

DEPARTMENT OF MECHANICAL ENGINEERING (M.TECH)


NATIONAL INSTITUTE OF TECHNOLOGY, KARNATAKA
SURATHKAL, MANGALORE-575025

Submitted By – Submitted To –

Ratnesh Kumar Sharma Dr.Ranjith M.

Roll No.-242TH013

Resistration No. 2420373


Program: assume Φ = y
n = 10;
A = zeros(n + 1, n + 1);
B = zeros(n + 1, 1);
Y = zeros(n + 1, 1);
Y0 = 0;
Y1 = 1;
rho = 1;
u = 1;
gamma = 0.02;
L = 1;
r = 0.7;
h = L / ((r^n - 1) / (r - 1));
for i = 2:n + 1
p(i) = (r^(i - 2)) * h;
end
for i = 1:n + 1
Aw(i) = -rho * u / ((1 + r) * p(i)) - 2 * gamma / (p(i)^2 * (1 + r));
Ae(i) = rho * u / ((1 + r) * p(i)) - 2 * gamma / (p(i)^2 * (1 + r) * r);
Ap(i) = 2 * gamma/ ((1 + r) * p(i)^2 * r) + 2 * gamma / (p(i)^2 * (1 + r));
if i == n
B(n) = -Ae(i);
end
if i == 1
A(i, 1) = 1;
A(i, 2) = 0;
elseif i == n + 1
A(i, n) = 0;
A(i, n + 1) = 1;
else
A(i, i - 1) = Aw(i);
A(i, i) = Ap(i);
A(i, i + 1) = Ae(i);
end
end
A(2, 1) = 0;
A(n, n + 1) = 0;
B(n + 1) = 1;
B(1) = 0;
% Thomas algorithm
for i = 2:n
f = A(i, i - 1) / A(i - 1, i - 1);
A(i, i) = A(i, i) - f * A(i - 1, i);
B(i) = B(i) - f * B(i - 1);
end
Y(n+1) = B(n+1) / A(n+1, n+1);
% Backward substitution
for i = n:-1:1
Y(i) = (B(i) - A(i, i + 1) * Y(i + 1)) / A(i, i);
end
for i = 1:n+1
if i ==1
X(1) = 0;
else if i ==2
X(2) = h;
else
X(i) =X(i-1) + (r.^(i-2))*h;
end
end
end
% Analytical
syms x Phi(x)
eqn = diff(Phi,x)-0.02*diff(Phi,x,2);
bc1 = Phi(0) == 0;
bc2 = Phi(1) == 1;
sol = dsolve(eqn,[bc1,bc2]);
yAnal = arrayfun(@(x_val) double(subs(sol, x, x_val)), X );
% Display the results in tabular form
fprintf('Node----\tDistance---\tDistance between node ----\tNumericalY----
tAnalytical Y-----\n');
fprintf('\n');
for i = 1:n+1
fprintf('%d \t%f \t%f \t%f \t%f \n', i, X(i), r.^(i-2)*h, Y(i), yAnal(i));
end
% Plotting
figure;
plot(X, Y, '-o', 'LineWidth', 2);
hold on;
plot(X, yAnal, '--', 'LineWidth', 2);
hold off;
xlabel('Distance');
ylabel('Y');
title('Numerical vs. Analytical Solution');
legend('Numerical', 'Analytical', 'Location', 'Best');
grid on;
Output : Table-1 , Case-1 for n =10 and r = 0.7

Node Distance Distance Numerical Y Analytical Y


between
nodes
1 0.000000 0.441029 0.000000 0.000000
2 0.308721 0.308721 -0.000027 0.000000
3 0.524825 0.216104 0.000010 0.000000
4 0.676098 0.151273 -0.000050 0.000000
5 0.781989 0.105891 0.000072 0.000018
6 0.856113 0.074124 -0.000292 0.000751
7 0.908000 0.051887 0.002155 0.010052
8 0.944320 0.036321 0.044922 0.061792
9 0.969745 0.025424 0.201682 0.220302
10 0.987542 0.017797 0.525024 0.536387
11 1.000000 0.012458 1.000000 1.000000

Graph:
Table-2, Case 2 :for n =10 and r =0.9

Node Distance Distance Numerical Analytical


between Y Y
nodes
1 0.000000 0.000000 0.000000 0.000000
2 0.153534 0.153534 -0.000173 0.000000
3 0.291715 0.138181 0.000134 0.000000
4 0.416017 0.124363 -0.000449 0.000000
5 0.528003 0.111926 0.000749 0.000000
6 0.628737 0.100734 -0.001947 0.000000
7 0.719397 0.090660 0.004793 0.000001
8 0.800992 0.081594 -0.014261 0.000048
9 0.874426 0.073435 0.048102 0.001876
10 0.940518 0.066091 -.195912 0.051093
11 1.000000 0.059482 1.000000 1.000000

Graph:
Table-3 Case-3 n =10 and r = 1

Node Distance Distance Numerical Y Analytical Y


between
nodes
1 0.000000 0.100000 0.000000 0.000000
2 0.100000 0.100000 -0.000697 0.000000
3 0.200000 0.100000 0.000929 0.000000
4 0.300000 0.100000 -0.002865 0.000000
5 0.400000 0.100000 0.005989 0.000000
6 0.500000 0.100000 -0.014670 0.000000
7 0.600000 0.100000 0.033534 0.000000
8 0.700000 0.100000 -0.078943 0.000000
9 0.800000 0.100000 0.183503 0.000045
10 0.900000 0.100000 -0.428870 0.006738
11 1.000000 0.100000 1.000000 1.000000

Graph:
Inference:

The numerical analysis using the finite difference method provides an approximation
of the solution for the given differential equation in Computational Fluid Dynamics
(CFD). The results are compared with the analytical solution to assess accuracy. The
cases studied (with different values of r: 0.7, 0.9, and 1.0) indicate the following
observations:
For r = 0.7, the numerical values closely match the analytical solution, with small
deviations observed at intermediate nodes.
For r = 0.9, the numerical method initially follows the analytical trend but exhibits
some deviations at later nodes.
For r = 1.0, larger discrepancies appear between numerical and analytical results,
especially in the middle nodes, suggesting possible instability or increased error.
The computational method effectively approximates the analytical solution, with
varying degrees of accuracy depending on the choice of stretching factor(r). Lower
values of r (such as 0.7) result in better agreement with the analytical solution, while
higher values (such as 1.0) introduce numerical errors.

You might also like