MatLab Assignment
MatLab Assignment
clc
clear all
%% Solve flow through a cylindrical pipe of fluid at Room Temperature where the diameter
of pipeline is 0.30 m density is 1000 kg/m 3, viscosity is 10-3 cP and length of the
pipeline is 100 meters.
r0 = -0.15;
v0 = 0;
rEnd = 0.15;
Pi = 1;
rho = 1000;
g = 9.8;
m = 10^-3;
l =100;
P = Pi + (rho*g*l);
for h = 0.001
%%Initialization of Problem
N = (rEnd - r0)./h;
R = (r0:h:rEnd)';
V = zeros(N+1,1);
V(1) = v0;
%% Solving by R-K 4th Order
for i = 1:N
f = -(P/(2*m*l))*R(i);
k1 = f;
k2 = f+(k1.*h./3);
k3 = f+(k2*2.*h./3);
k4 = f+(k3.*h);
V(i+1) = V(i) + (k1+(3*k2)+(3*k3)+k4).*h./8;
end
%% Plotting and Error analysis
Vtrue = (P/(4*m*l)).*(1-((R.^2)./((rEnd)^2)));
a = max(Vtrue)
Err4 = abs(Vtrue-V);
plot(V,R)
Max_Error_Kutta = max(Err4)
PErr4 = (max(Err4)/Vtrue*100);
Percentage_Error_Kutta = max(PErr4)
end
Harsh R Darji (J18IMT601) MATLAB Assignment 14/03/2020
>>>
Max_Error_Kutta =
2.3945e+06
Percentage_Error_Kutta =
97.7339
a =
2.4500e+06