Ha (z1-z2) (Q) (D)
Ha (z1-z2) (Q) (D)
)(עבודת בית
input data:
.) בתחום הנתוןd( ) עבור כל קוטרq( ) חשב את הספיקהz1-z2( עבור כל, ha עבור כל
q.)d(q את התוצאות יש להציג באמצעות גראפים
.' שבוע ימים לאחר המבחן מועד א:מועד האחרון להגשת העבודה
Shalom,
The attached is the Matlab program cpipe.m.
Input
0.0 p1 - gauge pressure at point 1 in kilopascals
0.0 p2 - gauge pressure at point 2 in kilopascals
0.0 v1 - velocity - 0 if essentially zero, otherwise 1.0
1.0 v2 - velocity - 0 if essentially zero, otherwise 1.0
39.0 z1 - elevation at point 1 in meters
0.0 z2 - elevation at point 2 in meters
67.0 ha - energy added between points 1 and 2 in kilowats
0.0 hr - energy removed between points 1 and 2 in kilowats
0.0 hm - minor losses between points 1 and 2 in meters
300. d - diameter of conduit in millimeters
90.0 l - length of conduit in meters
1.0e-6 vis - kinematic viscosity in m^2/s
0.000045 e - conduit material roughness in meters; zero for smooth
9.8 sw - specific weight of fluid in kilonewtons per m^3
0.0 q - flow rate in m^3/s, =0 if unknown
%The program:
% program cpipe, should be named cpipe.m
%
% this program computes the flow rate or the required conduit
% diameter. the international system of units is used.
% the application of the program is limited to cases involving
% a single pipe with constant diameter.
%
% this program is based on solution of the bernoulli equation.
% accordingly, certain data must be entered for each of two points
% in a pipe system. however, both the velocity at point 1 and the
% velocity at point 2 are not considered as known values initially.
% if either value of velocity is essentially zero (such as at a
% reservoir or tank surface) - enter 0 (zero) for that velocity or
% for both velocities if both are essentially zero, otherwise - enter
% 1.0 for all other velocities.
%
pi = 4.*atan(1.0);
% Input Data
%
p1=0; % gauge pressure at point 1 in kilopascals
p2=0; % gauge pressure at point 2 in kilopascals
v1=0; % velocity = if essentially zero, otherwise 1.0
v2=1; % velocity = if essentially zero, otherwise 1.0
z1=39; % elevation at point 1 in meters
z2=0; % elevation at point 2 in meters
ha=67; % energy added between points 1 and 2 in kilowats
hr=0; % energy removed between points 1 and 2 in kilowats
hm=0; % minor losses between points 1 and 2 in meters
d=300; % diameter of conduit in millimeters
l=90; % length of conduit in meters
vis=1e-6; % kinematic viscosity in m^2/s
e=0.000045; % conduit material roughness in meters; zero for smooth
sw=9.8; % specific weight of fluid in kilonewtons per m^3
q=0; % flow rate in m^3/s, =0 if unknown
%--------------------------------------------------------------------------
g = 9.807;
p1sw = p1/sw;
p2sw = p2/sw;
% friction coefficient initial guess
ff = 0.02;
% d is known, find q
if v1>0.0001
v1 = 1/2/g;
end
if v2>0.0001
v2 = 1./2./g;
end
for j=1:10000
hf = ff*l/d*factor/2/g; %105
hat = ha/sw;
hrt = hr/sw;
% flow rate q first guess
q = 0.001;
vtry = (q/(pi*(d/factor)^2/4))^2;
try1 = p1sw+vtry*v1+z1+hat/q-hrt/q-(p2sw+vtry*v2+z2+hf*vtry);
for n=1:10000
q = q + 0.001;
vtry = (q/(pi*(d/factor)^2/4))^2;
try2 = p1sw+vtry*v1+z1+hat/q-hrt/q-(p2sw+vtry*v2+z2+hf*vtry);
if try1*try2>0
try1 = try2;
else
q = q - 0.0005;
break
end
end
v = q/(pi*(d/factor)^2/4);
rn = d/factor*v/vis;
ed = e/d*factor;
% compute friction coefficient
f=rough(ed,rn); % call rough
diff = abs(f-ff);
if diff<0.0001 % goto 104
break
else
ff = f;
continue %goto 105
end
end
if v1>=0.0001 % 104
v1 = v;
end
if v2>=0.0001
v2 = v;
end
% writing input and output on screen
fprintf(' \n')
fprintf(' sample analysis for a closed conduit carrying fluid \n')
fprintf('--------------------------------------------------------\n')
fprintf(' \n')
fprintf(' input data: \n')
fprintf(' \n')
fprintf(' pressure at point 1 = %4f kPa \n',p1)
fprintf(' pressure at point 2 = %4f kPa \n',p2)
fprintf(' elevation at point 1 = %4f m \n',z1)
fprintf(' elevation at point 2 = %4f m \n',z2)
fprintf(' actual energy added between points 1 and 2 = %4f m \n',hat)
fprintf(' actual energy removed between points 1 and 2 = %4f m \n',hrt)
fprintf(' minor losses between points 1 and 2 = %4f m \n',hm)
fprintf(' length of conduit = %4f m \n',l)
fprintf(' conduit material roughness = %4f mm \n',e*factor)
fprintf(' fluid viscosity = %4f m^2/s \n',vis)
fprintf(' \n')
fprintf(' computed data: \n')
fprintf(' \n')
fprintf(' flow rate will be %4f m^3/s \n',q)
fprintf(' velocity at point 1 = %4f m/s \n',v1)
fprintf(' velocity at point 2 = %4f m/s \n',v2)
fprintf('--------------------------------------------------------\n')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% function rough, should be saved separately as rough.m
%
function f=rough(ed,rn)
if rn<2000
f = 64/rn;
return
end
% friction coefficient quess
f = 0.006;
try1 = 1/sqrt(f)+2*log10(ed/3.7+2.51/rn/sqrt(f));
for i=1:10000
f = f + 0.00001;
try2 = 1./sqrt(f)+2.*log10(ed/3.7+2.51/rn/sqrt(f));
if try1*try2>0
try1 = try2;
else
f = f - 0.000005;
return
end
end
======================================================================
output:
sample analysis for a closed conduit carrying fluid
---------------------------------------------------
input data:
computed data: