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

17 vues (au cours des 30 derniers jours)
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 commentaires
VBBV
VBBV le 14 Avr 2022
Modifié(e) : VBBV le 14 Avr 2022
Define equation below vector r
VBBV
VBBV le 14 Avr 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)

Connectez-vous pour commenter.

Réponse acceptée

Alan Stevens
Alan Stevens le 14 Avr 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 commentaire
Torsten
Torsten le 14 Avr 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).

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by