AE420 Chpt3 Fall 2021 (Part2)
AE420 Chpt3 Fall 2021 (Part2)
AE420 Chpt3 Fall 2021 (Part2)
1) Use the finite element method (direct and PMPE approaches) to solve the following problem:
Q k6 6
P
• • • • •
k1 k2 k3 k4
1 2 2 3 3 4 4 5
1
5 k5
3. 29
AE 420 / ME 471
Example 2
3. 30
AE 420 / ME 471
Example 3
3. 31
AE 420 / ME 471
Notes (Cont’d)
5) Other methods to derive the FE formulation
So far, we have seen 2 ways to derive the FE formulation (i.e., to derive [k] and {r}) for the
1D axially loaded bar problem :
But, as indicated earlier, there are two other ways to obtain the same results:
3. 32
AE 420 / ME 471
3.4 PVW approach
For the axially loaded bar problem examined earlier, the PVW is written as
L L
du du
W Win Wex E A dx p o u dx 0 u
0
dx dx 0
3. 33
AE 420 / ME 471
du du˜ dN x
Then, we have D
dx dx dx
The PVW becomes
L du dN x L
W EA dx D po u dx 0 u
0 dx dx
0
d u dN
At this point, we introduce u D N , i.e., D
dx dx
L dN x dN x
L
W D EA dx D 0 o
p N x dx 0 D
0 dx dx
Since this has to be true for any choice of the virtual nodal displacements D ,
the part in square bracket has to vanish, yielding:
K D R 0
where
L
dNi x dN j x
Kij E A dx
0 dx dx
L
Ri po N i x dx
0
Just like we did before, we construct the global stiffness matrix [K] and global load vector {R}
by computing [k] and {r} at the element level and then assembling into [K] and {R}.
3. 34
AE 420 / ME 471
Application
Use the PVW approach to derive the finite element formulation for the M-node string
element (on an elastic foundation)
q(x)
T w(x) T
ks
d 2w
GDE: T 2 ks w q for 0 x L
dx
BC: w 0 w L 0
dw d w
L L
T ks w w dx + q w dx 0 for any w
0
dx dx 0
3. 35
AE 420 / ME 471
3.5 Galerkin Weighted Residual approach
• For physical problems which do not have a functional form, from which the differential
equations and non-essential (i.e., natural) boundary conditions can be derived (e.g., when the
DEQ contains odd-order terms).
• We need a different approach which starts from the DEQ itself, or, more precisely, from an
integral formulation (or weak form) of the problem. This approach is called the weighted
residual method (WRM).
The basic idea of the GWRM is as follows : instead of satisfying the GDE at every point in the
domain (0 ≤ x ≤ L), we will only satisfy it in a “weighted average sense” (weak form) :
Side Note:
In (*), the continuity requirements for u(x) and v(x) are “uneven”:
3. 37
AE 420 / ME 471
To balance these requirements, let us integrate the left-hand side by parts :
L L
E Au v dx E Au v E Au v dx
L
0
0 0
L
E Au L vL E Au 0v0 E Au v dx
0
At this point, we introduce into (**) the interpolation-based approximation for u(x) :
dN x
L L
and choose our weight functions to be the shape functions : v(x) = Ni(x) (i=1, …, N+1)
dN x dN x
L L
E A dx D p o N x dx E Au L vL E Au 0v0
dx dx
0
0
K
R
3. 38
AE 420 / ME 471
Or, in component form :
L
dNi x dN j x
Kij E A dx
0 dx dx
L
Ri po N i x dx
0
Application: Use the GWRM approach to derive the finite element formulation for the M-
node string element (on an elastic foundation)
q(x)
T w(x) T
ks
d 2w
GDE: T 2 ks w q for 0 x L
dx
BC: w 0 w L 0
3. 39
AE 420 / ME 471
3.6 Implementation issues
1) Mesh numbering and storage scheme
The global stiffness matrix [K] contains a lot of zeros: which components?
There is no need to keep everything…
There are two basic approaches to organize [K] to reduce storage requirements:
1) banded form
B
X X X 0 0 X 0 0 0 0 B
X X X 0 0 X
X X X X X X X 0 0 0 X X X X X X
X X X X X 0 0 0 0 0 X X X 0 0 0
X X X 0 X 0
0 X X X X X 0 X 0 0
0 X X X X 0 X X
N
X X X X X X 0 X
N
X X X X 0 0
X X 0 X X X X X X 0
X X X X 0 0
0 X 0 0 X X X X X X X
0 X X 0 0 0
0 0 X 0 X X X X X X X 0 0 0 0
X
0 0 0 0 X X X X X X 0 0 0 0 0
0 0 0 0 X 0 X X X X
Storage: N2/2 N*B
Computations: N3/6 N*B2/2
3. 40
AE 420 / ME 471
2) skyline form
X X 0 X 0 0 2 vectors:
X X X 0 0 0 • component vector (a11, a12, a22, a23, a33,
0 X X 0 0 X
X a14, a24, a34, a44, a45, a55, a36, a46, a56, a66)
0 0 X X 0
0 0 0 X X 0
• index vector = position of diagonal terms
0 0 X 0 0 X
(1, 3, 5, 9, 11, 15)
3. 41
AE 420 / ME 471
Implementation issues
2) How to handle prescribed degrees of freedom?
Let us consider the following problem:
x x
px p0 1
L L
uimposed
E, A
x = 0 x=L
3. 43
AE 420 / ME 471
% PROGRAM AXIAL_BAR_1 % FINITE ELEMENT SOLUTION
% %
% BASIC INPUT % loop over the N elements
% for i=1:N
format long % number of significant digits in % initialize local stiffness matrix k(2,2) and
screen output local load vector r(2)
N=input(' Enter the number of elements N ... k=zeros(2,2);
') r=zeros(2,1);
L=1 % beam length (in m) % get element length l
A=0.1 % beam cross-section (in m^2) l=abs(x(i+1)-x(i));
E=10000 % beam stiffness (in Pa) % get load on the element (= value of p(x) at
po=500 % distributed load (in N/m) the center of the element)
uimposed=0.01 % imposed displacement at x=L (in xm=(x(i)+x(i+1))/2; % location of element
m) center
% pm=po*xm*(L-xm)/L^2;
% INITIALIZATIONS % compute local sm and local lv
% k(1,1)=E*A/l;
numnp=N+1; % number of nodes k(1,2)=-k(1,1);
numel=N; % number of elements k(2,1)=k(1,2);
% initialize the global stiffness matrix K and k(2,2)=k(1,1);
global load vector R r(1)=pm*l/2;
K=sparse(N+1,N+1); r(2)=pm*l/2;
R=zeros(N+1,1); % assemble into K and R
% create coordinate vector x(N+1) and n1=lm(1,i);
connectivity table lm(2,N) n2=lm(2,i);
x=zeros(N+1,1); K(n1,n1)=K(n1,n1)+k(1,1);
x(1)=0; K(n1,n2)=K(n1,n2)+k(1,2);
for i=1:N K(n2,n1)=K(n2,n1)+k(2,1);
x(i+1)=x(i)+L/N; K(n2,n2)=K(n2,n2)+k(2,2);
end R(n1)=R(n1)+r(1);
lm=zeros(2,N); R(n2)=R(n2)+r(2);
for i=1:N end % for loop on elements
lm(1,i)=i;
lm(2,i)=i+1;
end
44
% account for boundary conditions % POSTPROCESSING
K(1,1)=1; % compute exact solution
K(N+1,N+1)=1; uex1=zeros(N+1,1); % used for pointwise comparison
for i=2:N+1 xx=zeros(501,1); % used for plotting exact solution
K(1,i)=0; xx=0:L/500:L;
K(N+1,i-1)=0; uex2=zeros(501,1); % used for plotting exact solution
end eta=E*A*uimposed/(po*L^2);
R(1)=0; uex1=po*L^2/(E*A)*(((x/L).^4)/12-
R(N+1)=uimposed; ((x/L).^3)/6+(1/12+eta)*(x/L));
% solve linear system uex2=po*L^2/(E*A)*(((xx/L).^4)/12-
u=zeros(N+1,1); ((xx/L).^3)/6+(1/12+eta)*(xx/L));
u=K\R; % print and plot displacement solution
sprintf('%s','nodal displacements')
iii=1:1:numnp;
aux=[iii;x';u';uex1'];
sprintf(' node %d x = %8.3f u = %15.5f uex =
%15.5f\n',aux)
plot(x/L,E*A*u/(po*L^2),'ro-',xx/L,E*A*uex2/(po*L^2),'b-
','linewidth',2)
xlabel 'x/L'
ylabel 'E*A*u/(po*L^2)'
legend('numerical','analytical',0)
% compute largest difference between exact and FE values at
the nodes (*100/uimposed)
error=100*max(abs(u-uex1))/uimposed;
sprintf(' maximum error on nodal displacement = %17.10f
percent \n',error)
45
Typical Matlab output
>> axial_bar_1
Enter the number of elements N ... 6
N=
6
L=
1
A=
0.10000000000000
E=
10000
po =
500
uimposed =
0.01000000000000
ans =
nodal displacements
ans = Advantages and disadvantages of Method #1
node 1 x = 0.000 u = -0.00000 uex = 0.00000
node 2 x = 0.167 u = 0.00818 uex = 0.00826
node 3 x = 0.333 u = 0.01452 uex = 0.01465 Pros: simplicity
node 4 x = 0.500 u = 0.01788 uex = 0.01802 Cons: unnecessary computations
node 5 x = 0.667 u = 0.01785 uex = 0.01798
node 6 x = 0.833 u = 0.01484 uex = 0.01492 possible ill-conditioning of [ K ]
node 7 x = 1.000 u = 0.01000 uex = 0.01000
ans =
maximum error on nodal displacement = 1.4467592593 percent
3. 46
AE 420 / ME 471
Method #2: partitioning of [ K ] and { R }
The global degree-of-freedom vector < D > is composed of free (to be determined) and
prescribed (known) degrees of freedom. Let us organize < D > as
D f
D p
D
where { Df } is the (column) vector regrouping all free dofs, and { Dp } is the (column) vector
regrouping all prescribed dofs.
The linear system [ K ] { D } = { R } can then be rewritten as
K ff K fp D f R f
pf pp p p
K K D R
We thus solve for the unknown quantities < Df > and < Rp > as follows:
3. 47
420 / ME 471
AE
% PROGRAM AXIAL_BAR_2
% Same as AXIAL_BAR_1 with partitioning of K and R
% Only the sections that are different are listed
%
% BASIC INPUT (same as before) % assemble into Kff, Kpf, Kpp and Rf, Rp
% iaux=zeros(2,1);
% create basic FE quantities iaux(1)=idof(n1);
numel=N; % number of elements iaux(2)=idof(n2);
numnp=N+1; % number of nodes for jj=1:2
numimp=2; % number of imposed dof nj=iaux(jj);
numeq=numnp-numimp; % number of equations for kk=1:2
idof=zeros(numnp,1); % vector with equation numbers nk=iaux(kk);
idof(1)=-1; % negative for first and last nodes if nj>0 & nk>0
idof(numnp)=-2; Kff(nj,nk)=Kff(nj,nk)+k(jj,kk);
for i=2:numnp-1 elseif nj<0 & nk>0
idof(i)=i-1; % positive for other nodes Kpf(-nj,nk)=Kpf(-nj,nk)+k(jj,kk);
end elseif nj<0 & nk<0
%initialize the global stiffness matrices Kff, Kpf and Kpp Kpp(-nj,-nk)=Kpp(-nj,-nk)+k(jj,kk);
% and global load vectors Rf and Rp end
Kff=sparse(numeq,numeq); end
Kpf=sparse(numimp,numeq); if nj>0
Kpp=sparse(numimp,numimp); Rf(nj)=Rf(nj)+r(jj);
Rf=zeros(numeq,1); else
Rp=zeros(numimp,1); Rp(-nj)=Rp(-nj)+r(jj);
%initialize the global dof vectors Uf(numeq) and Up(numimp) end
Uf=zeros(numeq,1); end
Up=zeros(numimp,1); end % end of loop over elements
Up(1)=0.; % account for displacement boundary conditions (stored in Up)
Up(2)=uimposed; Rf=Rf-(Kpf)'*Up;
% % solve linear system
% start of FEA Uf=Kff\Rf;
%
% loop over the N elements
for i=1:N
% initialize local stiffness matrix k(2,2) and local load vector r(2)
% get distributed load pm on the element (= value of p(x) at the center
of the element)
% compute local sm and local lv
3. 48
AE 420 / ME 471
% 2) compute, print and plot stress distribution
stress=zeros(numel,1);
xc=zeros(numel,1);
for i=1:numel
% POST-PROCESSING n1=lm(1,i);
% n2=lm(2,i);
% 1) rebuild, display and plot the global displacement vector U(numnp) l=abs(x(n2)-x(n1));
U=zeros(numnp,1); strain=(U(n2)-U(n1))/l;
for i=1:numnp stress(i)=E*strain;
if idof(i) > 0 xc(i)=(x(n1)+x(n2))/2;
U(i)=Uf(idof(i)); end
else sprintf('%s','axial stress distribution')
U(i)=Up(-idof(i)); iii=1:1:numel;
end aux=[iii;xc';stress'];
end sprintf(' element %d xc = %8.4f stress = %15.8f Newtons\n',aux)
% compute exact solution xx=zeros(2*numel,1); % used to plot the FE stress distribution
uex1=zeros(N+1,1); % used for node-wise comparison stress2=zeros(2*numel,1); % used to plot the FE stress distribution
xx=zeros(501,1); % used for plotting exact solution for i=1:numel
xx=0:L/500:L; xx(2*i-1)=x(lm(1,i));
uex2=zeros(501,1); % used for plotting exact solution xx(2*i)=x(lm(2,i));
eta=E*A*uimposed/(po*L^2); stress2(2*i-1)=stress(i);
uex1=po*L^2/(E*A)*(((x/L).^4)/12-((x/L).^3)/6+(1/12+eta)*(x/L)); stress2(2*i)=stress(i);
uex2=po*L^2/(E*A)*(((xx/L).^4)/12-((xx/L).^3)/6+(1/12+eta)*(xx/L)); end
% print and plot displacement solution xxx=zeros(501,1); % used to plot the exact stress distribution
sprintf('%s','nodal displacements') xxx=0:L/500:L;
iii=1:1:numnp; sigma_ex=po*L/A*(((xxx/L).^3)/3-((xxx/L).^2)/2+(1/12+eta));
aux=[iii;x';U';uex1']; subplot(1,2,2),plot(xxx/L,A*sigma_ex/(po*L),'b.',xx/L,A*stress2/(po*L),'r.:','linewidth',2);
sprintf(' node %d x = %8.3f u = %15.8f uex = %15.8f\n',aux) title(' axial stress')
subplot(1,2,1),plot(x/L,E*A*U/(po*L^2),'r+:',xx/L,E*A*uex2/(po*L^2) xlabel('x/L')
,'b.-','linewidth',2) ylabel('A*sigma/(po*L)')
title(' displacement'); legend('analytical','numerical',0)
xlabel 'x/L' %
ylabel 'E*A*u/(po*L^2)' % 3) obtain and print reactions at supports
legend('numerical','analytical',0) sprintf('%s','support reactions')
% Rp=Rp-(Kpf*Uf+Kpp*Up);
for i=1:numnp
if idof(i)<0
sprintf('node # %d reaction = %15.5f Newtons',i,Rp(-idof(i)))
end
end
3. 49
AE 420 / ME 471
>> axial_bar_2
Enter the number of elements N ... 6
N=
6
L=
2
A=
0.10000000000000
E=
10000
po =
500
uimposed =
0.01000000000000
ans =
nodal displacements
ans =
node 1 x = 0.000 u = 0.00000000 uex = 0.00000000
node 2 x = 0.333 u = 0.02770833 uex = 0.02802984
node 3 x = 0.667 u = 0.04808642 uex = 0.04860082
node 4 x = 1.000 u = 0.05650463 uex = 0.05708333
node 5 x = 1.333 u = 0.05141975 uex = 0.05193416
node 6 x = 1.667 u = 0.03437500 uex = 0.03469650
node 7 x = 2.000 u = 0.01000000 uex = 0.01000000
ans =
axial stress distribution
ans =
element 1 xc = 0.1667 stress = 831.25000000 Newtons
element 2 xc = 0.5000 stress = 611.34259259 Newtons
element 3 xc = 0.8333 stress = 252.54629630 Newtons
element 4 xc = 1.1667 stress = -152.54629630 Newtons
element 5 xc = 1.5000 stress = -511.34259259 Newtons
Advantages and disadvantages of Method #2
element 6 xc = 1.8333 stress = -731.25000000 Newtons
ans =
support reactions Pros: only solve for actual unknown dof
ans = reorganization useful for optimization
node # 1 reaction = 89.49074 Newtons
ans = Cons: more complex
node # 7 reaction = 79.49074 Newtons
3. 50
AE 420 / ME 471