Professional Documents
Culture Documents
Subject (wi4012TA)
Max Mustermann
d du ∆p
(r ) = r r (0, R) (1)
dr dr VL
where u(r) is the velicity in axial direction, r is the radial direction, v is the
viscosity, ∆p is the pressure drop and L is the length of the tube.
1 ∆p 2
u=− (R − r2 )
4 vL
It can be proved easily that this is indeed a solution:
du 1 ∆p
= r
dr 2VL
du 1 ∆p 2
r = r
dr 2VL
d du 2 ∆p ∆p
r( ) = r=r
dr dr 2 vL VL
1
Figure 1: The velocity profile
d du(r) ∆p
(r v(r)
) = v(r)r
dr dr VL
2. Integrate over the Domain (0 → R):
Z R Z R
d du(r) ∆p
v(r) (r )dr = v(r)r
0 dr dr 0 VL
3. Integrate by parts:
du(r) R
Z R Z R
dv(r) du(r) ∆p
r dr = v(r)r − v(r)r dr
0 dr dr dr 0 0 VL
Z R Z R
dv(r) du(r) ∆p
r dr = − v(r)r dr (2)
0 dr dr 0 VL
2
Figure 2: The gridding scheme
N Z R Z R Z R
X dµj dµi dµ0 dµi ∆p
Wj rdr = − µi rF dr− rdr i {1, ..., N } F =
0 dr dr 0 0 dr dr VL
j=1
2. Writing out this equation element wise for each i and considering the fact
that only contributions from neighbouring elements are non-zero (all other
elements don’t contribute to the global matrix) leads to equations like this
(for brevity only eqns. 1,2, and 20 are shown here):
Equation 1:
Z r1 Z r2 Z r2
W1 µ01 µ01 rdr + µ01 µ01 rdr + W2 µ01 µ02 rdr + 0 + 0 + ... =
r0 r1 r1
Z r1 Z r2 Z r1
− µ1 rF dr − µ1 rF dr − W0 µ00 µ01 rdr
r0 r1 r0
Equation 2:
Z r2 Z r2 Z r3 Z r3
W1 µ01 µ02 rdr+W2 µ02 µ02 rdr + W2 µ02 µ02 rdr +W3 µ02 µ03 rdr + 0 + 0+ ... =
r1 r1 r2 r2
Z r2 Z r3
− µ2 rF dr − µ2 rF dr
r1 r2
Equation 20:
3
The most practicable way to generate the global stiffness matrix with a
computer algorithm is based on the concept of the element-matrices. This
concept can be used because the individial elements always contribute the
same value (only including a transformation for the increasing r) to the
global stiffness matrix.
The next step is to evaluate the integrals containend in the element matrix
and the element vector, with a suitable integration method. As we have
chosen piecewise linear basis functions, like illustrated in figure 3, this can
be done easily. Here this is done on the example of the top left integral of
the element matrix:
Z ri
dµi−1 dµi−1 1 1 1 2 ri
rdr = − r r
ri−1 dr dr h h 2 i−1
1 2 2
= (r − ri−1 )
2h2 i
Similarly the other matrix elements are computed. We arrive at the following
evaluated element matrix, which can be easily implemented in an computer
algorithm:
1 2 2 − 2h1 2 (ri2 − ri−1
2 )
i 2h2 (ri − ri−1 )
Ke =
− 2h1 2 (ri2 − ri−1
2 ) 1
2h2 i
(r2 − ri−1
2 )
For the evaluation of the solution’s vectors elements we make use of the
trapezoidal rule to integrate over half a tent functions:
Z ri
h1 2 2
− µi rF dr = −F (ri − ri−1 )
ri−1 2 2
Z ri+1
h1 2
− µi rF dr = −F (ri+1 − ri2 )
ri 2 2
Summing these two up gives the following components of the assembled
solution vector: −F h4 (ri+1
2 − ri2 )
4
Figure 3: Basis functions µj and their derivatives.
for k=1:1:(N-1)
K(i,j)=K(i,j)+((1/(2*h^2))*((j*h)^2-(h*(j-1))^2));
K(i+1,j+1)=K(i+1,j+1)+((1/(2*h^2))*((j*h)^2-(h*(j-1))^2));
K(i+1,j)=K(i+1,j)+((-1/(2*h^2))*((j*h)^2-(h*(j-1))^2));
K(i,j+1)=K(i,j+1)+((-1/(2*h^2))*((j*h)^2-(h*(j-1))^2));
j=j+1;
i=i+1;
end
for l=2:1:N
f(l)=1/4*((r(l+1))^2-(r(l-1))^2);
end
5
∆p
With the parameters VL = −1, R = 2, h = 0.1 we get a global matrix K:
Columns 1 through 10
0.5 −0.5
−0.5 2.0 −0.5
−1.5 4.0 −1.5 0
−2.5 6.0 −2.5
−3.5 8.0 −3.5
−4.5 10.0 −4.5
−5.5 12.0 −5.5
0 −6.5 14.0 −6.5
−7.5 16.0 −7.5
−8.5 18.0 −8.5
Columns 11 through 20
Columns 11 through 20
1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
Kw = f
and can be solved for examples with the help of Matlabs backslash operator
or a Gauss elimination method.
6
Subtask 5: Numerical simulations and results
The numerical simulations were performed with the already mentioned pa-
rameters. For efficiency reasons matlab sparse matrix storage was used. In
figure 4 both the analytical and the numerical solution are plotted. As one
can see there is an excellent agreement between the two curves. Only in for
smaller r values the numerical solution shows miner deviations. The green
curve shows the absolute error in percent and illustrates how the numerical
solution converges towards the true solution for higher r values. The error
for N=20 has its maximum of 0.6199% at r = 0.
1 ∆p
umax = − ∗ ∗ R2
4 VL
7
while the general velocity in distance r from the center axis is given by
1 ∆p
u(r) = − ∗ ∗ (R2 − r2 )
4 VL
So the relation between u(r) and umax is given by
u(r) (R2 − r2 ) r2
= and u(r) = umax (1 − )
umax R2 R2
This relation can now be substituted in the Integral formula for the flow
rate Q which is given by
Z R
Q= 2πru(r)dr
0
R R
r2
2
r4
Z
r umax
Q= 2πrumax (1 − 2 )dr = 2πumax − 2
= A
0 R 2 4R 0 2
where A is the tube area. When you plug in πR2 for A with R=2, then you
get a exact flow rate of
22 π
Q= = 2π
2
Now we want to compute the same flow rate by means of a numerical integra-
tion method. Again we use the trapezoidal rule. The Integral is evaluated
section wise. Subsequently all sections are summed up.
for p=1:1:N-1
c=c+(-1/2)*pi*(w(p)+w(p+1))*((r(p))^2-(r(p+1))^2);
end
8
Subtask 7: Error estimation
With h = 0.1 we get an approximation of ∼ 6.2156.
With h = 0.05 we get an approximation of ∼ 6.2659.
With h = 0.025 we get an approximation of ∼ 6.2788.
9
Appendix: Matlab code
%MATLAB implementation of Nr. 4, 5 and 6
%Ludwig Auer, 02.03.2010
function []=femflow()
close all
clf;
%Analytical solution
y=(1/4)*(R^2-r.^2);
10
%Error calculation
for o=1:1:N
error(o)=(y(o)-w(o))*100/y(o);
end
%Plot everything
plot(w,’r’);
hold on
plot(y);
hold on
plot(error,’g’)
title([’Fluid velocity profiles’]);
xlabel([’N is ’,num2str(N),’ and stepsize h is ’,num2str(h)]);
ylabel([’Fluid velocity in percent’]);
k=legend(’FEM’,’Analytical’,’Error in %’,3);
axis ([1 N 0 1])
%disp(max(error));
%disp(errorq);
11