function demoFlowRate
% demoFlowRate  Compute flow rate in a simple, single pipe system
%               The physical dimensions of the pipe system are known.
%               Given an initial guess at the flow rate, the actual flow
%               rate through the system is computed.  There is no pump.

L = 300;                   %  pipe length (m)
D = 0.3;                   %  true pipe diameter (m)
A = 0.25*pi*D^2;           %  cross sectional area (m^2)
e = 0.26e-3;               %  roughness for cast iron
KL = [0.5;  1];            %  minor loss for entrance and exit
Ah = A(1)*ones(size(A));   %  Areas of pipe associated with minor loss
                           %     coefficients are same as pipe area
rho = 999.7;               %  density of water (kg/m^3) at 10 degrees C
mu = 1.307e-3;             %  dynamic viscosity (kg/m/s) at 10 degrees C
nu = mu/rho;               %  kinematic viscosity (m^2/s)
dz = -15;                  %  outlet is 15 m below the inlet
pc = [];                   %  no pump
Q0 = 0.25;                 %  initial guess at flow rate

[Q,hL,~] = pipeFlowSolve(Q0,L,A,D,e,KL,[A; A],nu,dz,pc);
fprintf('\nSolution from pipeFlowSolve:\n')
fprintf('\tFlow rate, Q  = %12.3e\n',Q)
fprintf('\tHead loss, hL = %12.3e\n',hL)

end
