compute the average flow velocity for a pipeline and plot it with the % original velocity profile. in matlab

There are different methods to compute the average velocity for a pipeline. One of them that we can use is the Manning's equation, which relates the average velocity V with the hydraulic radius R, slope S, and Manning's roughness coefficient n:

main.m
V = 1/n * R^(2/3) * S^(1/2)
28 chars
2 lines

To plot the velocity profile, we can use the analytical solution for fully developed flow in a circular pipe, which is parabolic and can be expressed as:

main.m
v(r) = (4 * V_max / D^2) * (r^2 - R^2)
39 chars
2 lines

where V_max is the maximum velocity at the center of the pipe, D is the diameter of the pipe, r is the radial coordinate, and R = D/2 is the hydraulic radius.

Here's some example code that reads the diameter, slope, and roughness coefficient from user input, and plots the velocity profile together with the original (uniform) velocity distribution:

main.m
% User input
D = input('Enter pipe diameter (m): ');
S = input('Enter slope: ');
n = input('Enter Manning roughness coefficient: ');

% Computation of average velocity
g = 9.81;         % gravitational acceleration (m/s^2)
theta = atan(S);  % angle of slope (radians)
R = D/4;          % hydraulic radius (m)
V = 1/n * R^(2/3) * S^(1/2);  % average velocity (m/s)
Q = pi/4 * D^2 * V;           % flow rate (m^3/s)
A = Q/V;                      % cross sectional area (m^2)

% Computation of velocity profile
r = linspace(0, R, 100);         % radial coordinate (m)
V_max = V / (2/3);              % maximum velocity at center (m/s)
v = (4 * V_max / D^2) * (r.^2 - R^2);  % velocity profile (m/s)

% Visualization
figure
hold on
plot([0 R], [V V], 'k-', 'Linewidth', 2)  % uniform velocity distribution
plot(r, v, 'r-', 'Linewidth', 2)         % velocity profile
xlabel('Radial coordinate (m)')
ylabel('Velocity (m/s)')
legend('Uniform distribution', 'Velocity profile')
title(sprintf('Flow in a pipe (D = %.2f m, S = %.3f, n = %.3f)\nAverage velocity = %.3f m/s', D, S, n, V))
1077 chars
28 lines

This code produces a plot like the following:

plot

related categories

gistlibby LogSnag