I am trying to use the trapezoidal rule to compute the flow rate of fluid through a pipe.

16 visualizzazioni (ultimi 30 giorni)
clear
% Velocity distribution function of the pipe
v = 3.9*(1-r./r0).^n;
% Area = pi*r^2
% dA = 2*pi*r dr
% Q = V dA dr
% Value of exponent in velocity distribution function
n = 1/5;
% Value of radius in the pipe (cm)
r0 = 6;
% Range over which the integral is to be performed
r = [0,6];
% Now using the trapz method
Q1 = 2.0*pi*trapz(r,v)
It spits out an error after the initialization of the velocity distribution function saying it doesn't recognize the variable 'r', but I don't understand because I stated r as a variable below that.
  2 Commenti
VBBV
VBBV il 14 Apr 2022
clear
% Velocity distribution function of the pipe
% Area = pi*r^2
% dA = 2*pi*r dr
% Q = V dA dr
% Value of exponent in velocity distribution function
n = 1/5;
% Value of radius in the pipe (cm)
r0 = 6;
% Range over which the integral is to be performed
r = [0,6];
v = 3.9*(1-r./r0).^n;
% Now using the trapz method
Q1 = 2.0*pi*trapz(r,v)

Accedi per commentare.

Risposta accettata

Alan Stevens
Alan Stevens il 14 Apr 2022
I think it needs to be more like this:
% Velocity distribution function of the pipe
% Area = pi*r^2
% dA = 2*pi*r dr
% Q = V dA dr
% Value of exponent in velocity distribution function
n = 1/5;
% Value of radius in the pipe (cm)
r0 = 6;
% Range over which the integral is to be performed
dr = r0/1000;
r = 0:dr:r0;
v = 3.9*(1-r./r0).^n;
% Now using the trapz method
Q1 = 2.0*pi*trapz(v)*dr
Q1 = 122.5092
% True value
vfn = @(r) 3.9*(1-r/r0).^n;
Q2 = 2*pi*integral(vfn,0,r0)
Q2 = 122.5221
  1 Commento
Torsten
Torsten il 14 Apr 2022
To get the volume flow rate, the correct integral should be
Vdot = 2*pi*integral_{r=0}^{r=r0} r*v(r ) dr
not
Vdot = 2*pi*integral_{r=0}^{r=r0} v(r ) dr
You can already see this when you consider the unit of Vdot, namely m^3/s (the last integral has m^2/s as unit).

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by