College

Use the Swamee-Jain equation from problem 3 for a pipe with a diameter of 5 mm. In MATLAB, create a 3D surface plot of the friction factor as a function of the Reynolds number in the range from 6000 to 60000 with 100 steps, and the pipe’s wall roughness in the range from 0.02 to 0.2 with 100 steps.

Provide the script and show the 3D plot with axis titles, plot titles, a color bar, a jet color map, and interpolated shading.

Answer :

Final Answer:

Here's the MATLAB script to generate the 3D surface plot of the friction factor as a function of Reynolds number in the range from 6000 to 60000 and pipe's wall roughness in the range from 0.02 to 0.2 using the Swamee-Jain equation for a pipe with a diameter of 5 mm:

Explanation:

The Swamee-Jain equation for calculating the Darcy-Weisbach friction factor in a pipe is given by:

[tex]f = \(\frac{0.25}{\left[\log_{10}\left(\frac{e}{3.7d}+\frac{5.74}{Re^{0.9}}\right)\right]^2}\)[/tex]

To generate the 3D surface plot in MATLAB, a script is created that iterates through Reynolds numbers from 6000 to 60000 in steps of 100 and pipe wall roughness from 0.02 to 0.2 in steps of 0.002. The script calculates the friction factor 'f' using the Swamee-Jain equation for each combination of Reynolds number and roughness. Here's a pseudocode of the script:

matlab

% Define variables

d = 5 / 1000; % Pipe diameter in meters

Re_range = linspace(6000, 60000, 100); % Reynolds number range

roughness_range = linspace(0.02, 0.2, 100); % Pipe wall roughness range

% Initialize matrix to store friction factors

factors = zeros(100, 100);

% Calculate friction factors

for i = 1:100

for j = 1:100

Re = Re_range(i);

roughness = roughness_range(j);

f = 0.25 / (log10(roughness / (3.7 * d) + 5.74 / Re^0.9))^2;

factors(i, j) = f;

end

end

% Generate 3D surface plot

[X, Y] = meshgrid(Re_range, roughness_range);

surf(X, Y, factors');

xlabel('Reynolds Number');

ylabel('Pipe Wall Roughness');

zlabel('Friction Factor');

title('3D Surface Plot of Friction Factor');

colorbar;

colormap jet;

shading interp;

This script utilizes nested loops to compute the friction factors for varying Reynolds numbers and pipe wall roughness. The 'surf' function creates the 3D surface plot with appropriate axis labels, a title, a color bar indicating the friction factor values, and a jet color map with interpolated shading for better visualization.