CIVE50003 Computational Methods II - Lecture III - 220123 V3

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Computational Methods II

MEng Module CIVE50003

Lecture 3

Dr Adam Jan Sadowski

Spring Term 2023

CIVE50003 Computational Methods II – Lecture 3 1


Where we left off: the weak for of the j-th element
x
 We got here: I }
{= { f } −  k  {d }
  j 2×1
P
x q x
j 2×1
P
j 2×2 j 2×1 j j +1
j j +1
 Where
ūj ūj +1
.
0  1  1 1
 This { f j } =   Pj +1 −   Pj + qh j   is the element nodal load vector
2×1
1  0  2 1

EA l  1 −1
 This  k j  = 0 j  −1 1  is the element stiffness matrix
2×2 2 Lh j   h j x j +1 − x j
=
where
l j =4 L − x j +1 − x j
 uj 
 This {d j } =   is the element nodal dof vector
u j +1 
2×1

4 x j +1
 But there is still = I = ∑ Ij 0 where
= I j ∫ [] dx
this to do: j =1 x
   j
Discretised on Ω
Element j
(assembly)
CIVE50003 Computational Methods II – Lecture 3 2
Assembly is best illustrated with an example
System diagram: Free body diagram:
Uniform E and q, linearly-varying A(x)
x=0 x=L
x q
PL RH ∫qdx = qL PL
E, A 0
A0
. 2A 0

 Let us discretise the domain Ω (x = 0..L) with mesh of 4 equal-


sized finite elements (e1, e2, e3, e4) located between 5 equally-
spaced nodes (n1, n2, n3, n4, n5)
Element: e1 e2 e3 e4

{
{
{
{
EBC1: ū(x1 ) = 0 ū(x2 ) = ? ū(x3 ) = ? ū(x4 ) = ? ū(x5 ) = ? NBC2:
ū'(x5 ) = P L/EA 0
x1 = 0 x2 = L/4 x3 = L/2 x4 = 3 L/4 x5 = L
Node: n1 n2 n3 n4 n5 .

 There are 5 dofs, of which 4 are unknown. Ultimately, we must


end up solving a 4×4 matrix system.
CIVE50003 Computational Methods II – Lecture 3 3
Formulate {I1} (local view)
e1

{
EBC1: ū(x1 ) = 0 ū(x2 ) = ? NBC2: Px q Px
1 2
ū'(x5 ) = P L/EA 0
x1 = 0 x2 = /4
L
x3 = /2
L
x4 = /4
3L
x5 = L n1 n2
Node: n1 n2 n3 n4 n5 .

L
 Here: x=
j x=
1 0 x j +=
1 x=
2
4
L 15 L
l j =l1 = 4 L − x2 − x1 =
h j = h1 = x2 − x1 =
4 4
Px j =
Px1 =
− RH Px j +1 =
Px2 = 0
0  1  1 1
{f } =   Pj +1 −   Pj + qh j  
Thus, the 1st element’s equation is:
j 2×1

 1  0  2 1
EA l  1 −1
 k j  = 0 j 
2×2 2 Lh j  −1 1 

I1}2×1 { f1}2×1 − [ k1 ]2×2 {d1}2×1


{= u 
{d j }2×1 = u j 
 j +1 

 RH  1 1 15 EA0  1 −1  u1 


=  + qL   −  −1 1  u 
 0  8 1 2L   2

CIVE50003 Computational Methods II – Lecture 3 4


Formulate {I2} (local view)
e2

{
EBC1: ū(x1 ) = 0 ū(x2 ) = ? NBC2: Px q Px
2 3
ū'(x5 ) = P L/EA 0
x1 = 0 x2 = /4
L
x3 = /2
L
x4 = /4
3L
x5 = L n2 n3
Node: n1 n2 n3 n4 n5 .

L L
 Here: x=
j x=
2 x j +=
1 x=
3
4 2
L 13L
h j = h2 = x3 − x2 = l j =l2 = 4 L − x3 − x2 =
4 4
P=
xj P=
x2 0 Px=
j +1
P=
x3 0
0  1  1 1
{f } =   Pj +1 −   Pj + qh j  
Thus, the 2nd element’s equation is:
j 2×1

 1  0  2 1
EA l  1 −1
 k j  = 0 j 
2×2 2 Lh j  −1 1 

I 2 }2×1 { f 2 }2×1 − [ k2 ]2×2 {d 2 }2×1


{= u 
{d j }2×1 = u j 
 j +1 

1 1 13EA0  1 −1 u2 


= qL   −  −1 1  u 
8 1 2L   3

CIVE50003 Computational Methods II – Lecture 3 5


Formulate {I3} (local view)
e3

{
EBC1: ū(x1 ) = 0 ū(x2 ) = ? NBC2: Px q Px
3 4
ū'(x5 ) = P L/EA 0
x1 = 0 x2 = /4
L
x3 = /2
L
x4 = /4
3L
x5 = L n3 n4
Node: n1 n2 n3 n4 n5 .

L 3L
 Here: x=
j x=
3 x j +=
1 x=
4
2 4
L 11L
h j = h3 = x4 − x3 = l j =l3 = 4 L − x4 − x3 =
4 4
P=
xj P=
x3 0 Px=
j +1
P=
x4 0
0  1  1 1
{f } =   Pj +1 −   Pj + qh j  
Thus, the 3rd element’s equation is:
j 2×1

 1  0  2 1
EA l  1 −1
 k j  = 0 j 
2×2 2 Lh j  −1 1 

I 3 }2×1 { f3 }2×1 − [ k3 ]2×2 {d3 }2×1


{= u 
{d j }2×1 = u j 
 j +1 

1 1 11EA0  1 −1 u3 


= qL   −  −1 1  u 
8 1 2L   4

CIVE50003 Computational Methods II – Lecture 3 6


Formulate {I4} (local view)
e4

{
EBC1: ū(x1 ) = 0 ū(x2 ) = ? NBC2: Px q Px
4 5
ū'(x5 ) = P L/EA 0
x1 = 0 x2 = /4
L
x3 = /2
L
x4 = /4
3L
x5 = L n4 n5
Node: n1 n2 n3 n4 n5 .

3L
 Here: x=
j x=
4 x j +=
1 x=
5 L
4
L 9L
h j = h4 = x5 − x4 = l j =l4 = 4 L − x5 − x4 =
4 4
P=
xj P=
x4 0 Px=
j +1
P=
x5 PL
0  1  1 1
{f } =   Pj +1 −   Pj + qh j  
Thus, the 4th element’s equation is:
j 2×1

 1  0  2 1
EA l  1 −1
 k j  = 0 j 
2×2 2 Lh j  −1 1 

I 4 }2×1 { f 4 }2×1 − [ k4 ]2×2 {d 4 }2×1


{= u 
{d j }2×1 = u j 
 j +1 

 0  1 1 9 EA0  1 −1 u4 


  + qL   −
=  −1 1  u 
 PL  8 1 2 L   5

CIVE50003 Computational Methods II – Lecture 3 7


Formulate {I1} (global view)
e1

{
EBC1: ū(x1 ) = 0 ū(x2 ) = ? NBC2: Px q Px
1 2
ū'(x5 ) = P L/EA 0
x1 = 0 x2 = /4
L
x3 = /2
L
x4 = /4
3L
x5 = L n1 n2
Node: n1 n2 n3 n4 n5 .

 In local view:
I1}2×1 { f1}2×1 − [ k1 ]2×2 {d1}2×1
{=
 RH  1 1 15 EA0  1 −1  u1 
=  + qL   −  −1 1  u 
 0  8 1 2L   2
 In global view:
 RH  1   15 −15 0 0 0   u1 
0  1   −15 15 0 0 0  u 
  1   EA    2 
{I1}5×1 = 0  + qL 0  −
0
 0 0 0 0 0  u3 
 0  8 0  2 L   
     0 0 0 0 0  u4 
 0  0   0 0 0 0 0  u5 
CIVE50003 Computational Methods II – Lecture 3 8
Formulate {I2} (global view)
e2

{
EBC1: ū(x1 ) = 0 ū(x2 ) = ? NBC2: Px q Px
2 3
ū'(x5 ) = P L/EA 0
x1 = 0 x2 = /4
L
x3 = /2
L
x4 = /4
3L
x5 = L n2 n3
Node: n1 n2 n3 n4 n5 .

 In local view:
I 2 }2×1 { f 2 }2×1 − [ k2 ]2×2 {d 2 }2×1
{=
1 1 13EA0  1 −1 u2 
= qL   −  −1 1  u 
8 1 2L   3
 In global view:
0  0   0 0 0 0 0   u1 
0  1   0 13 −13 0 0  u 
  1   EA    2 
{I 2 }5×1 =+
0  qL 1  − 0  0 −13 13 0 0  u3 
0  8 0  2 L 
0 0 0 0 0
 
      u4 
0  0   0 0 0 0 0  u5 
CIVE50003 Computational Methods II – Lecture 3 9
Formulate {I3} (global view)
e3

{
EBC1: ū(x1 ) = 0 ū(x2 ) = ? NBC2: Px q Px
3 4
ū'(x5 ) = P L/EA 0
x1 = 0 x2 = /4
L
x3 = /2
L
x4 = /4
3L
x5 = L n3 n4
Node: n1 n2 n3 n4 n5 .

 In local view:
I 3 }2×1 { f3 }2×1 − [ k3 ]2×2 {d3 }2×1
{=
1 1 11EA0  1 −1 u3 
= qL   −  −1 1  u 
8 1 2L   4
 In global view:
0  0   0 0 0 0 0   u1 
0  0   0 0 0 0 0  u 
  1   EA    2 
{I 3 }5×1 =+
0  qL 1  − 0  0 0 11 −11 0  u3 
 0  8 1  2 L 
0 0 −11 11 0
 
      u4 
0  0   0 0 0 0 0  u5 
CIVE50003 Computational Methods II – Lecture 3 10
Formulate {I4} (global view)
e4

{
EBC1: ū(x1 ) = 0 ū(x2 ) = ? NBC2: Px q Px
4 5
ū'(x5 ) = P L/EA 0
x1 = 0 x2 = /4
L
x3 = /2
L
x4 = /4
3L
x5 = L n4 n5
Node: n1 n2 n3 n4 n5 .

 In local view:
I 4 }2×1 { f 4 }2×1 − [ k4 ]2×2 {d 4 }2×1
{=
 0  1 1 9 EA0  1 −1 u4 
  + qL   −
=  −1 1  u 
 PL  8 1 2 L   5
 In global view:
0 0   0 0 0 0 0   u1 
0 0   0 0 0 0 0  u2 
  1   EA0    
{I 4 }5×1 =
 0  + qL 0  −  0 0 0 0 0  u3 
 0  8 1  2 L 
0 0 0 9

−9  u4 
      
 PL  1   0 0 0 −9 9  u5 
CIVE50003 Computational Methods II – Lecture 3 11
The final assembled {I}
4 Element: e1 e2 e3 e4

{I }5×1
= ∑
= {I } {0}

{
{
{
{
j 5×1 EBC1: ū(x1 ) = 0 ū(x2 ) = ? ū(x3 ) = ? ū(x4 ) = ? ū(x5 ) = ? NBC2:
5×1 ū'(x5 ) = P L/EA 0
j =1
 
 x1 = 0
Node: n1
x2 = L/4
n2
x3 = L/2
n3
x4 = 3 L/4
n4
x5 = L
n5 .
Discretised on Ω

 Summing everything, we obtain a 5×5 matrix system


 15 −15 0 0 0   u1   RH   1 
 −15 15 + 13 −13 0 0  u2  0 + 0  1 + 1
EA0       1  
 0 −13 13 + 11 −11 0 =  u3  0 + 0  + qL 1 + 1
2L    0 + 0  8 1 + 1
 0 0 −11 11 + 9 −9  u4     
 0 0 0 −9 9  u5   PL   1 

 This is the tridiagonal sparse [A]{x} = {b} you’ve heard so much about!
 In structural mechanics, it’s often written as [k]{d} = {f}
 But there’s still something missing. Can you say what it is?
CIVE50003 Computational Methods II – Lecture 3 12
Solving the assembled matrix system
 15 −15 0 0 0   u1   RH  1 
Element: e1 e2 e3 e4
 −15 28 −13 0 0  u2  0  2 

{
{
{
{
EBC1: ū(x1 ) = 0 ū(x2 ) = ? ū(x3 ) = ? ū(x4 ) = ? ū(x5 ) = ? NBC2:
ū'(x5 ) = P L/EA 0
EA0 
 0 −13 24 −11 0  =
  
u3 
  1  
 0  + qL 2 
x1 = 0 x2 = L/4 x3 = L/2 x4 = 3 L/4 x5 = L 2L     0  8 2 
Node: n1 n2 n3 n4 n5 .  0 0 −11 20 −9  u4
     
 0 0 0 −9 9  u5  P
 L  1 
or [ k ]5×5 {d }5×1 = { f }5×1

 We cannot solve this yet ([k] is actually singular)


 Solve for what exactly? Essential BCs
Natural BCs
‘applied’ here
 The actual unknows are ū2, ū3, ū4 and ū5 ‘enforced’ here

 We did say on slide 3 that we should be solving a 4×4 system, not 5×5
 How do we incorporate the BCs?
 Essential BC1: ū1 = 0
 Natural BC2: P(x) = PL at x = L
 The natural BC2 is already accounted for, it came from the
‘boundary’ term in the weak form, and you can see PL is
indeed present in the global nodal load vector {f}
CIVE50003 Computational Methods II – Lecture 3 13
Enforcing essential BCs
 There are many ways to enforce essential BCs
 The method presented here is called partitioning
 First identify which matrix rows & columns correspond to:
 ‘restrained’ dofs (those where essential BCs are enforced) i.e. ū1
 ‘free’ dofs (which are as of yet unknown) i.e. ū2, ū3, ū4 and ū5
 A dof can be either ‘restrained’ or ‘free’ but not both
 Then partition the matrix system accordingly:
Restrained Free dofs
dof
Restrained
dof  15 −15 0 0 0   u1   RH   0  1 
 −15 28 −13 0 0  u2   0  0 2 
EA0         1  
Free  0 −13 24 −11 0  u3  =  0  +  0  + qL 2 
2L    0   0  8 2 
dofs
 0 0 −11 20 −9  u4 
       
 0 0 0 −9 9  u5   0   PL  1 
ū1 ū2 ū3 ū4 ū5

CIVE50003 Computational Methods II – Lecture 3 14


Enforcing essential BCs
 We then conceptually rearrange the matrix system so that
rows & columns corresponding to ‘free’ dofs come first
 This does not change the solution, it just moves stuff around
Free dofs Restrained {fr} {fa}
dof

 28 −13 0 0 −15 u2   0  0 2 


 −13 24 −11 0 0  u3   0  0 2 
EA0         
Free
dofs
 0 −11 20 −9 0  u4  =  0   0  1 2
  +   + qL  
2L    0   P  8 1 
 0 0 −9 9 0  u5 
Restrained      L  
 
dof  −15 0 0 0 15   u1   RH   0  1 
ū2 ū3 ū4 ū5 ū1

 The system is now in the following general format:


[ k FF ]4×4 [ kFR ]4×1  {d F }4×1  { f F ,r }4×1  { f F ,a }4×1 
  =     + 
 [ k RF ]1×4 [ RR ]1×1  5×5 {d R }1×1  { f R ,r }1×1 5×1 { f R ,a }1×1 5×1
k
5×1

CIVE50003 Computational Methods II – Lecture 3 15


Enforcing essential BCs
 We now have a system of two matrix equations to solve for two
{f } – unknown nodal forces from reactions
unknowns: {dF} and {fR,r} r

[ kFR ]4×1  {d F }4×1 


Note
[ k FF ]4×4 { f F ,r }  { f F ,a }  always:

{f }
4×1 4×1
 =  + = {0}4×1

 [ k RF ]1×4 [ kRR ]1×1  5×5 {d R }1×1   
{ R ,r }1×1 5×1 { R ,a }1×1 5×1
f f F , r 4×1
5×1

{fa} – known applied nodal forces

 Matrix equation 1 lets you solve for the unknown free dofs {dF}:
[ kFF ]4×4 {d F }4×1 + [ kFR ]4×1 {d R }1×1 = { f F ,r }4×1 + { f F ,a }4×1 A-ha! Here is the 4×4
system!

{d F } [ kFF ]4×4 ({ f F ,r }4×1 + { f F ,a }4×1 − [ kFR ]4×1 {d R }1×1 )


−1
⇒= N.B. [k]5×5 is singular,
4×1
[kFF]4×4 is not

 Matrix equation 2 lets you solve for the unknown nodal reactions: {fR,r}
[ kRF ]1×4 {d F }4×1 + [ kRR ]1×1 {=
dR}
1×1
{ f R,r }1×1 + { f R,a }1×1 No further inversion

⇒ { f R= , r }1×1 [ kRF ]1×4 {d F }4×1 + [ kRR ]1×1 {d R }1×1 − { f R ,a }1×1


operation required here.

CIVE50003 Computational Methods II – Lecture 3 16


FE solution
System diagram: Free body diagram:
Uniform E and q, linearly-varying A(x)
x=0 x=L
x q
PL RH ∫qdx = qL PL
E, A 0
A0
. 2A 0

 Assume same ‘clean’ numbers again: E = 2 [F.L-2], A0 = 1 [L2],


L = 10 [L], q = 1 [F.L-1] and PL = -4 [F].
 First matrix equation:
{=
dF }
4×1
[ kFF ]4×4
−1
({ f } + { f }
F , r 4×1 F , a 4×1 − [ k FR ]4×1 {d R }
1×1
)
−1
 2.8 −1.3 0 0   0   2.5  −1.5  3.1667 
 −1.3 2.4 −1.1      0   4.8974 
0   0   2.5      
⇒ {d F }    +  − × 0 ≈
4×1  0 −1.1 2.0 −0.9   0   2.5   0   4.6702 
         
 0 0 −0 . 9 0.9  0
   −2.7 5   0   1.6146 

CIVE50003 Computational Methods II – Lecture 3 17


FE solution
System diagram: Free body diagram:
Uniform E and q, linearly-varying A(x)
x=0 x=L
x q
PL RH ∫qdx = qL PL
E, A 0
A0
. 2A 0

 Assume same ‘clean’ numbers again: E = 2 [F.L-2], A0 = 1 [L2],


L = 10 [L], q = 1 [F.L-1] and PL = -4 [F].
 Second matrix equation:
{f }
R , r 1×1 = [ k RF ]1×4 {d F } + [ k RR ]1×1 {d R } − { f R ,a }1×1
4×1 1×1

3.1667 
4.8974 
 
=⇒ { f R ,r }1×1  −1.5 0 0 0    + 1.5 × 0 − 1.25 =−6 ≡ RH
4.6702 
1.6146 
 Is equilibrium satisfied?
RH + PL + qL =0 ⇒ RH =− PL − qL =− ( −4 ) − 1× 10 =4 − 10 =−6 Yes!

CIVE50003 Computational Methods II – Lecture 3 18


FE solution

CIVE50003 Computational Methods II – Lecture 3 19


Conclusions
 What you have just seen is your very first complete finite
element solution to a mechanical system

 Our FE formulation was obtained by formulating the ‘weak’ form


from the ‘strong’ form of the ODE
 There are other ways at arriving at the ‘weak’ form directly that do not
need a ‘strong’ form to ever be formulated
 The derivation procedure may seem complex, but once
mastered it is incredibly powerful and lends itself extremely well
to automated computational implementation

 N.B. the solution improves as the element size h gets smaller –


for this reason what we are doing is something called ‘h-
refinement’ (can you see the difference with p-refinement?)
CIVE50003 Computational Methods II – Lecture 3 20
Tips on a good computational implementation
[ k FF ]4×4 [ kFR ]4×1  {d F }4×1  { f F ,r }4×1  { f F ,a }4×1 
 =  +

 [ k RF ]1×4 [ kRR ]1×1  5×5 {d R }1×1  { f R ,r }1×1 5×1 { f R ,a }1×1 5×1
  
5×1

 Partitioning the matrix system to extract the necessary


submatrices does NOT mean that in Matlab you need to actually
store a rearranged matrix or the extracted submatrices separately
in new variables

 Remember, matrices can take up a lot of memory!

 You just need to access the correct rows / columns from memory
– the rearrangement and partitioning is more conceptual

 Matlab makes it very easy to ‘pluck’ submatrices out of a matrix


CIVE50003 Computational Methods II – Lecture 3 21
Tips on a good computational implementation
[ k ] [ k ]  {d }  { f }  { f } 
FF 4×4 FR 4×1 F 4×1 F , r 4×1 F , a 4×1
  =
    + 
[ ]
k [ ]  {d }  { f }  { f } 
k RF 1×4 RR 1×1 5×5 R 1×1 R , r 1×1
5×1
R , a 1×1
5×1
5×1 {fr} – unknown nodal
forces from
 If the assembled matrix is k and the applied load vector is f: reactions
 kFF is actually k([2:5],[2:5])  15 −15 0 0 0   u1   RH   0  1 
 kFR is actually k([2:5],[1])  −15 28 −13 0 0  u2   0  0 2 
 kRF is actually k([1],[2:5]) EA0         1  
 0 −13 24 −11 0  u3  =  0  +  0  + qL 2 
 kRR is actually k([1],[1]) 2L    0   0  8 2 
 0 0 −11 20 −9  u4 
 fF,a is actually fa([2:5])        
 0 0 0 −9 9  u5  0 P
   L  1 
 fR,a is actually fa([1]) ū1 ū2 ū3 ū4 ū5

 We know in advance that: {fa} – known


applied nodal
 ‘free’ dofs are nos. 2, 3, 4 and 5 forces

 ‘restrained’ dofs is no. 1


 To solve for {dF} you don’t even need kRF or kRR...
 This is where using Matlab for scientific methods where linear
algebra operations are required is really valuable!
CIVE50003 Computational Methods II – Lecture 3 22
Tips on Tutorial 2
Element: e1 e2 en -2 en -1

{
{
{

{
EBC1: ū(x1 ) = 0
Node: x1 = 0
ū(x2 ) = ?
x2
ū(x3 ) = ?
x3
ū(xn -2 ) = ?
xn -2

Tutorial 2 is about generalising this procedure so that it is valid


ū(xn -1 ) = ?
xn -1
ū(xn ) = ? NBC2:
xn
ū'(xn ) = P L/EA 0
.

for an arbitrary number of elements


 Think carefully about your programme structure
 Specify input (n nodes – code this in, don’t ask for a tedious prompt)
 Initiate an empty (‘zeros’) global matrix and vector for n – 1 elements
 Construct a ‘for’ loop for n – 1 elements
 For each element, don’t actually store the 2×2 matrix or 2×1 vector in
memory… you only need to compute the coefficients of these, you already
know the positions of these in the global matrix & vector
 Add to the global matrix & vector as you loop, don’t replace
 Also, no need to store kFF, kFR etc. sub-matrices separately…

CIVE50003 Computational Methods II – Lecture 3 23

You might also like