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

20 次查看(过去 30 天)
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 个评论
VBBV
VBBV 2022-4-14
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)

请先登录,再进行评论。

采纳的回答

Alan Stevens
Alan Stevens 2022-4-14
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 个评论
Torsten
Torsten 2022-4-14
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).

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by