The Finite Element Mlethot
using MATLAB
Young UW. won
Hyochoong Bang
CRC Press
Boca Raton 14 igton, D.C.CRC MECHANICAL
ENGINEERING SERIES
Edited by Frank A. Kulacki, University of Minnesota
Published
Entropy Generation Minimization
Adrian Sajaan. Duke University
The Finite Element Method Using MATLAB
Young W. Kwon. Naval Pastaraduate School
Hyochoang Bang, Korea Aerospace Rasearch Insthiute
To be Published
Fundamentals of Environmenta! Discharge Modeling
Lorin A, Davis, Crogan Stato University
Mechanics ot Composite Materials
Autar K. Kaw, University of South Florida,
Norlinear Analysis of Structures
M. Sathyamoarthy, Clarkson University
Mechanics of Solids and Shots
Gerald Wempter, Georgia Institute of Technology
Viscoelastic Sottas
Roderic Lakes, University of lowaLIMITED WARRANTY
CRC Press warants the ptysical disketto(s) enclosed herein to be fee of defects in uateriak ad workmanship
for a period of thirty days from the date of purchase. if within the wartanty period CRC Press receives writen
nolification of éefects in materials oc workmanship, and sein notilicelion is destined by ORC Pres he come,
CRE Fress Wl replace me detective atsectet
‘The ealis and caddusive lability and remedy for becac of dis Linsiled Waray shall Tinted wocpiacement
of defective disketie(s} and shall wot nul ur extend to any claien for or right cover any ober damages, achdieg
but nottimited 10, lost of prof, data, af use ofthe cofewave, ot special, incidanal, of csnsquential damages or other
Amilar claims, even if CRC Press fas been specifically advised of the possibilty af ach damages Fr wo even wil
the liabiy of CRC Press for any damages to you or any ofter person ever exceed the lower sugested ist pie 9
cual pfite paid for the software, regardless of any form of the claim.
‘CRC Press specifically disclaine all other weerantics, expeess ce implied, icuding but oi inited 0, any iplisd
‘warranty of metchantabiity 07 fimness for a particular purpose. Specifically, CRC Press makes no presestation o¢
‘warranty thal the softwave is it for any particular purpose and any ixaplied warranty of mercuabillys bie
Te CLIMY-day eoreTion ef the Liraied Warranty covering the physlcel askees) ony (aN Noche SCO) sd
otherwise eapressty and specifically disclaimed,
‘Since noe Mules de nol allow the exclusion of invidentaf or consequent! dang
on implied warranty last tonsa af the akove may not apply v0 you
srthe lization on howe lag.
DISCLAIMER OF WARRANTY AND LIMITS OF LIABILITY: Thc ator ofthis book hae ued her best
efforts in preparing this material These efforts include the development, rescarch, and testing ofthe theories and
programs to determine cheir effectiveness. Neitacr the author(s) nor the putliser make warantes of any kind,
express or implicd, with regard to trese programs or the documentation conned i tis book, inculing wont
limitation warrants of merchan‘ability oF tiness fora particular purpose. Ne lig Is arcpedin any event for
any damages, tncluding incidental ur oonseyuentil Uareages. 109 profls, so of Ws Uae 9 EO MEET, OF
otherwise in connection with of arising ot of the furnishing, peformance, o sof the programs in this book,
Libcary of Congress Cataloging-In-Publleatien Data
Kwon, Young W.
The finite clerient method using MATLAB / by Yeang W. Koon and Hyocioong Sane,
B. Ga — (The mechanical engincering series)
Includes bibliographical references and index,
IEDN 0-0493-7652-0 (alls. pepo)
1, Finite clement method—Tiata proesssing, 2, MATLAB — Bang, Hyockoone,
TE Tithe IE Series: Advanced topics in mechanical enginesting series.
TAMTFSKSS 1995
624.1 70285832090 96-1901
cp
‘This book contains information obtained from anthentc and highly reganled smrees. Reprint malta acted
‘with permission, and sources are indicated. & wie varcty ofreferences are ied, Reacomoblefiptshave been made
to publish reticbte deta and information, but the author(s) and the publisher carnot asm respeulty fr Lae
saldity of afl materials or for the consequences of their eae
‘Neither this book nor my part muy be reproduced or tansmilted in any for tr by any means, clcroe ot
mechanical, inchuding photocopying, miczofilming, and recording, or by any infornatonsiomye ore system,
without prior permission in writing from the publisher.
‘The consent of CRC Press LLC does aol extend to copying for general dveibution, for promotion, for erating
new works, or for resale. Spesific pecmission must be obtained in writing fem CRC Press LLC for such copying,
Disect al inquiries «9 CRC Press LLC, 2000 Comorate Bivd. N.W., Boca Reto, Horia 3431
© 1997 by CRC Pros LLC
No elim tn original 18 Couersent work:
Inreenational Standaid Book Number 0-8493-9653-0
Library of Congress Card Number 96-9091
Printed in the United Sites of America 34567890
Printed on scid-free paperTABLE OF CONTENTS
CHAPTER 1. INTRODUCTION TO MATLAB
La
2
13
4
15
La
LT
18
19
1.10
LAL
1.12
113
au
Lib
Finite Elernent Method
Overview of the Book
About MATLAB
Vector and Matrix Manipulations
Matrix Functions
Data Analysis Funccions
Tools for Palynomials
Making Complex Numbers
Nonlinear Algebraic Equations
Solving Differential Equations
Loop and Logical Statement
Writing Function Subroutines
File Manipulation
Boosie Input Output Functions
Plotting Tools
CHAPTER 2. APPROXIMATION TECHNIQUES
a4
22
2.3
24
25
26
Ze
Methods of Weighted Residual
‘Weak Formulation
Piccawise Continuous Trial Function
Gelerkin’s Finite Blenent Formulation
Variational Method
Rayleigh-Rita Method
Rayleigh-Kite Finite Element Method
Problems
CHAPTER 3. FINITE ELEMENT PROGRAMMING
BL
32
33
B34
35
CHAPTER 4. DIRECT APPROACH WITH SPRING SYSTEM
41
42
43
Overall Program Structure
Input Data
Assembly of Element Matrices and Vectors
Application of Constraints
Example Programs
Prablems
Linear Spring
Axial Member
Torsional Member
u
i
5
16
1
20
2
28
mu
ay
34
35
a7
a2
4
a
AG
Bt
52
54
68
a
a
Wi
31
bL
144
Other Systems
Problems
CHAPTER 5. LAPLACE’S AND POISSON’S EQUATIONS
5.
5.2
5.3
54
55
5.6
5.7
58
59
5.1C
DLL
5.12
Governing Equation
Linear Triangular Element
Bilinear Rectangular Elemert
Boundary Integral
‘Transient Analysis
Time Tategration Technique
Axisymmetric Analysis
‘Phree-Dimensionel Analycio
MATLAB Application to 2D Steady State Analysis
MATLAB Application tu Axisymmetric Analysis
MATLAB Application to Transient Analysis
MATLAB Application to 3-D Steady State Analysis
Problems
CHAPTER 6, ISOPARAMETRIC ELEMENTS
61
6.2
63
6.4
6.5
6.6
One-Dimensional Elements
Quadrilateral Elements
‘Triangular Elements
Gauss Quadrature
MATLAB Application to Gauss Quadrature
MATLAB Application to Laplace Equation
Problems
CHAPTER. 7. TRUSS STRUCTURES
a
7.2
73
TA
15
7.8
One-Dimensional Truss
Plane Truss
Space Teuse
MATLAB Application to Static Analysis
MATLAB Application to Eigenvalue Analysis
MATLAB Application to Transient Analysis
Problems
CHAPTER 8. BEAM AND FRAME STRUCTURES
at
8.2
8.4
84
8.5
Euler Bernoulli Boam
Timoshenks Beam
Ream Elemente With Only Displacement Degrees of Freedom
Mixed Beam Element
Hybrid Beam Element
7
80
83
86
90
92
96
38
jot
108
107
ng
124
M8
153
wT
160
168
170
1%
183
193
197
199
08
204
15
223
281
295
wz
45
zag
2a
83
187
1987
2358.6
87
8.9
ata
BLL
8.12
B18
B14
Composite Beams
Two-Dimensional Frame Element
‘Three- Dimensional ¥ramne Element
MATLAB Application to Static Analyeis
MATLAR Application to Rigenvalna Analysis
MATLAB Application to Transient Analysis
MATLAB Application to Modal Analysis of Undarpped System
MATLAB Application to Modal Analysis of Damped System
MATLAB Application to Frequency Response Analysis
Problens
CHAPTER 9, ELASTICITY PROBLEM
g1
2
9.9
94
9.5
2.6
97
a8
3.8
Plane Stress and Plane Strain
Force Vector
Bnergy Method
Three-Dimensional Solid
Axisymmetric Solid
Dynamic Analysis
MATLAB Application to 2-1) Stress Analysis
MATLAB Application to Axisymmetric Analysis
MATLAB Application to 3-D Stress Analysia
Problems
CHAPTER 10. PLATE STRUCTURES
04
10.2
10.3
10.4
10.5
10.6
10.7
Classical Plate Theory
Classical Plate Bending Element
Shear Deformable Plate Element
Plate Element With Displacernent Degrees of Freedom
Mixed Plate Element
Hybrid Plate Element
MATLAB Application
Problems
CHAPTER 11, CONTROL OF FLEXIBLE STRUCTURES
dl
11.2
3
14
W5
116
17
11.8
11.9
11.10
Introduction
Stability Theory
Stability of Multiple Degrees of Freedom Systems
“Analysis of 2 Second Order System
State Space Form Description
‘Transfer Function Analysis
Contro) Law Design for State Space Systems
Linear Quadratic Regulator
Mudal Contre for Secund Order Systems
Dynamic Observer
28
9
264
265
0,
284
288
298
29
304
r
BL
313
31a
318
320
82L
334
356
36L
364
368
373
378
308
303
304
398
401
408
Atz
427
438
451
307
361
393.PREFACE
‘The finite element method has become one of the must important ead useful
engineering (uoly for engineers atid scieutisis. This ook prevents introductory and
some advanced topics of the Finite Element Method (FEM). Finite element theories,
formulations, and various example programs written in MATLAB! ate presented. The
book is written a9 s textbook for upper level undergraduete and loner level greduate
courses, as well as a reference book for engineera and scientists who want to write
auick finite element analysis programs.
Understanding basic program structures of the Finite Element Analysis (FEA) is
an important past for better comprehension of the finite element methad, MATLAB
ja especially convenient to writo and underatand finite clement analyes programe
because a MATLAB program manipulates matrices and vectors with ease, Thess
algebraic operations constitute major parts of the FEA program. In adiition,
MATLAB has buili-in graphics features lo Lely ceaiers visuslize Ue wumucrical results
in Wwo- and/or three-dimensional plots, Graphical presentation of aumericel data is
important to interpret the finite element results. Because of thes: benefiie, many
examples of fimte element analysis programs are provided in MATLAB,
‘The baok contains extensive illustrative examples of finite element analyses using
MATLAB program for most problems discussed in the book. Subroutines (MATLAB
functions) are provided in the appendix and a computer diskette which contains all
the subroutines and example problems is also provided.
Chapter 1 has a brief summary of usefal MATLAB commands which can be
used in programming FEA. Readers may refer to MATLAR mammals for additional
information, However, this chapter may be a good etait for readers who have no
experince with MATLAB
Subsequent chapters are presented in a logical order, Chapter 2 diseuseoe the
weighted residual method which is used for the formplation of PEA in the remaining
Clayvery, Tritially, cumtinuuue iia) fynctions ace used by oblaiu appruxiatale sululious
using the weighted residual method. Next, piecewise continuout functions are selected
to achieve approximate sohitions. ‘Then, FEM is introduced from the concept
of piecewise continuous functions. Finally, classical variational formulations are
compared with the weighted residual formulations
Chapter 3 shows the basic program structure of FEA using ordinary differential
equations for an one-dimensional aystern. MATLAB programs are provided to explain
the programming. Both program input and output as well aa internal program
structure are fully discussed. A direct, FEM approarh using simple mechasies i
presented in Chapter 4. This chapter.presents the basic concept of FEM using an
intuitive and physical approach
‘MATLAB is a registered tradomark of The MathWorks, Ine. For additional
informationa, contact:
Phe MathWorks, Tue
24 Prime Park Way
Natick, MA 01760
Phone: (08) 647-100U, fax: (US) 647-7001Finite element formulations for partiel differential oquations are presented in
Chapter 5. ‘This chapter explains not only domain integration for computation of
the finite element matrices but also boundary integration to compute column vectors
Applications of Laplace's equation to two- and three-dimensional domains as well
as an axially symmetric domain are presented for both stesdy-slale and transient
problems.
Chapter 6 shows concepts and programing of isoparametric finite elements
Because a complex shape of domain with enrved bourdary can be eceily haedled using
isoparametric finite clements, these clements ate very useful and common in FEA
Both one-dimensional and two-dimensional isoparametric cements are presented. A
numerical technique und ils programusiag concept are aluo divcusved. Ay 8 program
example, Laplace’s equation is solved using isoparametric elements,
Chapters 7 and 8 discuss truss and frame structures. Static, dynamic, and
eigenvalue problema are solved. In addition, one-, two and three-dimensional
structures are considered. As a result, coordinate transformation from local to global
axes is explained. In particular, various formmlations fot the bea structure are
compared; the relative advantages and disadvantages af each are cited. Modeling of
laminated beams with embedded cracks is also discussed, Further, Chapter 8 presents
the madal analysia and Fast. Fourier Transform
Elasticity is studied in chapter 9. Plane stress/strain, axisymmetric and three
dimensional problems are included. Both static and dynamic analyses ate presented.
The finite clement formulatione are presented in terme of the weighted residual
method. However, an energy method is also discussed for comparison. Plate
bending is given in Chapter 10. Similar to beam formulations, diferent plate beading
formulations are presented for comparison.
Finaily, stractural control using FEM is presented in Chapter 11. This chapter
ig intended to provide a broad understanding of the basic concepts of control law in
conjunction with FEM. Due to limited space, only a few major control theories are
presented. It is assumed that readers are already familiar with fundamentals of linear
dynamic systems analysis.
‘This book contains more material than can be covered in a one-semester. Thus,
materials may be selected depending on course objectives. For an introductory FEM
course, Chapters 2 thrangh 9 ara recommended. Depending on the desired course
contents, some sections may be deleted.
We would like to thank individuals who have contributed to this book. ‘The
authors would Ike to express out appreciation to Profeasor Alekandra Vinogtador
for reviewing the manuscrips and providing us with many useful suggestions. We
are also indebled to the staffs of CRC Press for their professional guidance ia the
production of this book. Finally but not lastly the authors sincerely appreciate the
lifelong support. and encouragement by their parents.
Y.W. Kwon
E. C, BangCHAPTER. ONE
INTRODUCTION TO MATLAB
1 Finite Element Method
In order to analyze an engineering system, « mathematical model is developed to
describe the system, While developing the mathematical 1odel, some assumptions are
made far cimplifestion Finally, tha gaveming rathernalirsl aepraccinn is dovalepard
to describe the behavior of the system. The mathematical expression usually consiste
of differential equations and given conditions.
These differential eyuativas axe usually very difflaus tu obtain solutions which
explain the behavior of the given engineering system. With the advent of high perfor
mance computers, it has become possible to solve such differential equations. Various
numerical solution techniques have been developed and applied to solve numerous en-
gineering problems in order to find their approximate solutions. Especially, the finite
element methed has been one of the major numerical solution techniques. One of the
major advanteges of the finite element method is that a general purpose computer
program can be developed easily to analyze various kinds of problems. In particular,
any compley ahape of peahlem damain with prescribed eonditiona can be handled with
ease using the finite element method.
‘The finite element method requires division of the problem domain into many
subdomains and cach subdomain is called a finite element, Therefore, the problem
domain consists of many finite element patches.
1.2 Overview of the Book
‘This book is written as a textbuok for engineering students as well as a reference
book for practicing engineers and researchers. The book consists of two parts: theory
and program. ‘Therefore, each chapter has initial sections explaining fundamental
theories and formulations of the finite element method, and subsequent sections
showing examples of finite element programs written in the MATLAB program. The
collection of MATLAB function files (i.e. m-files) used in the example programs is
summarized in Appendix A and provided in a separate computer disc.
12 Tntraduction to MATLAB Chapter L
A brief summary of some of MATLAB commands is provided in the following
sections for readers who are nol familiar with ther, Those are the commands which
may be used in finite element programs. Especially, the MATLAB commands for
matrix operation and solution are most frequently ueed in the programs, For visxal-
ination of the finite element solution, some plotting commands are alsa explained.
1,2 Abuut MATLAB
MATLAB is an interactive software which has been used recently in various areas
of ongincaring and ecientifie applications. Il is not a computer language in the normal,
sense but it does most of the work of a computer language. Writing a computer code
ja not a straightforward job; typically boring and time consuming for beginuers, One
aliractive aspech of MATLAB iy that it ix celatively easy to Jean. Tk is wcitien ow
an intuitive basis and it does not require in-deptin knowledge on operational principle
of computer programming like compiling and linking in most of other programmsing
languages. ‘This could be regarded as a disadvantage smec at prevents users from
understanding the basic prineiple in computer prograraming. ‘The interective 1uade
of MATLAB may redace computational speed in some applications.
‘The power of MATLAB is represented by the length and simplicity of the code,
For example, one page of MATLAB code inay be equivalent to many pages of other
compnter langnage source codes. Numerical calculation ix MATLAR uses collections
of well written scicntific/mathematical subroutines such as LINPACK and EISPACK.
MATLAB provides Graphical User Interface (GUI) as well as tatee-dimensional
graphical animation.
Ta general, MATLAB is a useful tool for vector and matrix manipuletions.
Since the majority of the engincering systems are represented by marrix ard vector
equations, we can relieve our workload to a significant extent by using MATLAB,
‘The finite element method is a well defined candidate for whick MATLAB can be
very useful as a solution tool. Matrix and vector manipulations are eseential parta in
the method. MATLAB provides help menu so that we can type felp command when
we need help to figure out a command. The Aelp utility is quite convenient for both
beginners and experts.
1.4 Vector and Matrix Manipulations
Once we get into the MATLAB, we meet a prompt >> called MATLAB prompt.
This prompt receives a user command and processes it providing the ouput on the
next Hine. Let us try the following command to define a matrix.
>> A= [L,3,552.7,8;0,5,9]
‘Then the ontput appears in the next line as shown below.
Az
ane:
cnnSection 1.4 Vector and Matrix Manipulations 3
‘Thus, a matrix is entered row by row, and ezch row is separated by the semi-colon(;).
Within each row, elements are separated by # space or the comma(,). Commands
and variables used in MATLAB are case-sensitive. That is, lower case letters are
distinguished from upper ease letters. The size of the matrix is cheeked with
>> size(A)
ans=3 3
‘Transpoxe of a matrix In order to find the transpose of matrix A, we type
>> a
‘The result is
120
ans= 3 T 3
629
Column or row components MATLAB provides columnwise or rowwise operation
of a matrix. The following expression
>> Al3)
yields
which is the third column of matrix A. In addition,
er AL)
represents the first row of A as
ang=i 30
‘We can also try
>> A(1,:)+.4(3,:)
as addition of the first and third rows of A with the result
ane=1 6 15
Now let us introduce another matrix B as
>> B= [3,4,5:6,7,2:8,1,01;
‘Then there seems to be no output on the screen. MATLAB does not prompt output
on the sereen wlien an operation ends with the semi-colon(;) at the end.
Tf we want by check the Boaalsin again, we simply type
>> B
‘The screen output will be4 Introduetion to MATLAB Chapter £
&
"
mae
nae
Matrix addition Adding two matrices is straightforward Uke
>> C=A4B
47
c=8 14 10
e449
‘Thus we defined a new matrix C' as cum of the previous two matrices
Matix subtraction In order to subtract matrix # from matrix A, we tye
>> Ca A-B
-2 -1 1
406
-8 2 9
Nate that Cis now a new matrix not the summation of A and 4 any more.
Matrix multiplication Similarly, atzix multiplication can be done a8
>> Ca Awe
69 31 11
= 2 6 24
90 30 6
1.5 Matrix Functions
Manipulation of matrices is a key feature of the MATLAB functions, MATLAB
is a useful tool for matrix and vector manipulations. Collections of representative
MATLAB matrix functions are listed in Table 1.5.1. Examples an¢ detailed explana-
tions are provided for each function below.
Matrix inverse The inverse of a matrix is as simple as
>> inv(A)
408
1.8571 0.4286 —0.8071
0.8571 6.4288 = 0.1905,
0.287 0.1429 0.0476
In order to verify the answer, we can try
>> Asinv(A);Section 1.5 Matrix Functions 5
Table 1.5.1. Basic Matrix Rimesions
Symbol. Explanation:
inv inverse of a matrix
det determinant of a matrix
rank rank of a matrix
cond condition number of a matrix
eye(n) the n by m identity matrix
trace summation of diagonal elements of a matrix
zeros(nym) the n by m matrix consisting of all zeros
which should be a 3 by 3 identity matrix.
Determinant of a matrix
>> d =det(A)
produces the determinant of the matrix A. ‘That is,
asm
Rank af a matrix The rank of a matriv A, which is the number of independent
rows or columns, is obtained from
prank);
Identity matrix
>> eye(3)
yidlde
Loo
ans=0 10
ool
eyo(n) produces au identity matrix of size n by m. This command is useful when we
Initialize a satrix.
Matrix of random numbers A matrix consisting of random numbers can be
generated using the following MATLAB function
>>rand(3,3)
0.2190 0.6793 0.5194
ans= 0.0470 0.9347 0.8310
0.6789 0.3835 0.03466 Introduetion to MATLAB Chapter 1
That is, rand(3,3) produces a 3 by 3 matrix whose elements consist of random
nuuthers, The general usage is rand(n, mm).
trace Summation of diagonal elements of a matrix can be obtained using the trace
operator.
For example,
>> Call 39, 67% 8 -1 —4
Then, trace(G) produces 6, which is the sum of disgonal elements of C.
axe umatrin
>> aeros(S, 4)
produces a 5 by 4 matrix consisting of all sero elements. In general, zetos(n, m) is
used for an n by m zero matrix.
condition number The command cond(A) is used to calculate the condision
number of a matrix A. ‘The condition umber represents the degree of singularity
of a matrix, An identity matrix ha a condition number of unity, and the condition
number of a singular matrix is infinity.
>>cond(ege(6))
ans =
!
An example matrix which is near singular is
14
a= [i 1+ 10]
The condition number is
>>eond(A)
4000004006
Further matrix functions are presented in Table 1.5.2. They do not inelide all
matrix fonctions of the MATLAB, but represent only a part of the whole MATLAB
functions. Readers can use the MATLAB Reference’s Guide or help command to
cheele when they need more MATLAB functions.
Matrix exponential The expma(A) produces the exponential cf a mabrix A. Ia
other words,
>> A srand(3, 3)
0.2190 0.8793 6.5194
A= 0.0470 0.9347 0.8310
0.6789 0.3835 0.0346Section 1.5 Matrix Funetions 7
‘Table 1.5.2 Basic Matrix Functions (Gonnued)
Symbol Explanations
expm exponential of w matrix —_
eig eigenvalues/eigenvectors of a matrix
la LU decomposition of a matrix
ovd singular volue decomposition af a matrix
QR decomposition of a masrix
used Wo solve a set of linear algebraic eq
>>expm(A)
1.2448 0.0305 0.6196
ans = 1.0376 L5L16 13380
1.0187 0.1184 2.0652
Bigenvalues The cigeuvalue proviern uf « umria is defined os
Aga dd
where ) is the eigenvalue of matrix A, and ¢ is the associated sigenvector.
vy e selg()
gives the eigenvalues of A, and
set)
produccs V matrix, whose columns are eigenvectors, and the diagenal matrix D whose
valuos are eigenvalues of the matrix A.
For example,
p> Aa[6 3% 146; 07
>> [V,D] seig(A)
04197 a.5999 9.0889
V = 0.5657 —0.7773 —0.6388
0.7217 O.1918 0.7680
>> [KD]
12.5361 0 0
D o (17486 0
4 Q —a.9R47
LU Decomposition ‘The LY decomposition command is used to decompose a
mesrix into a combination of upper and lower triangular matrices, respectively.
p>Aa[L 35 248 47 3h
>> [L,U] =Iul A)8 Introduction to MATLAB Chapter 1
9.2500 1.0000 0
= 0.6600 6.4000 1.0000
1.0000 0 0
4.0000 7.0000 3.0000
= 0 1.2500 4.2500
a 0 4.8000
In order to check the result, we try
>> LeU
136
ans=|2 4 8
473
‘Phe lower triangular matrix Fie not perfectly triangular, There is another command
available
>> [FH P| =Int A)
1.6006 0 0
0.2600 1.0000 8
0.5000 9.4000 1.0000
4.9000 7.0000 3.9000
L
= 0 12800 4.2500
0 0 4.8000
oon
Pol 00
o10
Here, the matrix P is the permutation matrix anch thet ?+A= LeU.
Singular value decomposition The evd command is used for singular value
decompcsition of a matrix. For a given matrix,
A=uEy’
where Dis a diagonal mattix consisting of non-negative values. For example, we define
a matrix D like
>> Dall 37 29 %& 28 5]
‘The singular value decomposition of the matrix is
>> [V, Sigma, V] =evd(D)
which results in
0.4295 0.8998 | - 0.0775
U = | 0.6629 0.6495,
0.6133 0.7564Section 1.6 Matrix Functions 9
1s.6a92 oD 0
Sigma = [ 0 4.1333 0 |
9 0 0.1891
U.7771 -0.5982 -0.1956
0.1905 -0.0725 9.9790
v=
0.5999 0.7980 —0.0576
QR decompouit! A matrix can be olso decompocad inte combination of an
orthonormal matrix and an upper triangular matrix. 1 other words,
AZ=QE
where Q is the matrix with orthonormal columns, and 2 is the upper triangulac
matrix, The Q2 algorithm has wide applications im the analysis of matrices and
associated linear systems. For example,
0.0470 0.9347 9.8310
0.2190 9.6793 0.5194
A=
[soma 0.3835 9.0346
Application of the ar operator follows as
>> [@, 4] =arfA)
yields
0.3063 -0.4667 0.8297
Q= | -0.0858 -0.8591 0.5076
0.0407 0.9101 0.9394
R= 6 1.0205 —0.9490
0.7149 -0.6338 —0.2456
8 0 —0.0011
Solution of linear equations ‘The solution of a linear system of equations is
frequently needed ia the finite element method. The typical form of a linear gystem
of algebraic equations is written as
Azzy
and the solution is obtained by
>> ny (cA)
or we can use \ sign as
>>as AW
For example
p> Aa=|l3 4 5 7 8 23 ot10 Introduction to MATLAB Chapter 1
Table 1.0.1 Dasa Analysis Functions
Explanations
min( max) minimurn(maximurn) of a vertor
sum aum of elements of « vector
std standard deviation of a data collertion
sort sort the claments of vector
mean mean value of a vector
used for componentwise operation of a vecior
and
>> y= [10; 9 a];
Let us compare two different approaches.
>> [inv(A)ey Aud
—4,2500 —4.2500
ans= 1.750C 1.7500
2.2500 2.2500
1.8 Data Analysis Functions
Tip to now, wa diseased matrix related functions and operstara of MATLAB,
MA'TLAG hse also data analysia functions for a vector or a columa of a matrix. Ia
Table 1.6.1, come operators for data manipulation are listed
Minimum (maximum) The min (mex) finds a minimum (maximern) valve of a
given vector. Hor example,
>> vail 28 78 26 49 92 28 23);
>>min(u)
yields
ans =
i
>>max(v)
ans =
99
sum The sum command produces the summation of elements of a vector. For
example,Section 1.6 Data Analysis Functions ul
Standard deviation The std command calculates the standard deviation of a
vector, For example,
>> std(l 4 0 -5 6 9 ~20))
ans =
10.4517
Sort a vector The sort command js used to sort a vector in the ascending order.
>> sorti[l 4 10 -5 6 9 —20)
ans =
-0-51469 19
Moai valuc ofa vecton The uteau valvulates Ure sean yelus uf « veciun
>> mean([I 410 -5 6 9 —20))
ans =
0.7143
Vector componentwise operation Let us define two vectors
>> v= [1,5,6,75u2 = 0,235);
Sometimes we want to multiply components of v; with the corresponding components
of ug. ‘The operation is
D> Ua = Pde
ans =
om 18 9%
In other words, ( ).*{ ) represents the componeatwise multiplication of two vectors
Another useful operator ie
D> te = te/r
with
a= 0 04 05 0.7143
Note that the deta analysie tools explained in the above are applicable to matrices
too. Pach matrix column is regarded 5 a vector for data analysis.12 Introduction to MATLAB Chapter 1
Table 4.7.1 Polynomial Functions
Explanations
converte collection of roots into = polynomial equation
finds the roots of a polynorrial equation
evaluates a polynomial for a given value
multiply two polynomials
decompose a polynomial into a dividend and a residual
curve Biting of 2 given polyaomial
1.7 Tools for Polynomials
Polynomials are frequently used in the analysis of linear systems. MATLAB
provide some tools for handliag polynomials. The sumriary of polynomial funetions
is provided in Table 1.7.1.
Roots of a polynomial equation A polynomial equation is given by
12" fae" +o pant ang =0
The roots of the polynomial equation is solved using roats command
roots([a1 az --- an aa4i]}
For example,
zt 442° —527+62—9
>>roots([} 4 ~—5 6 —9])
yields
5.23564
1.2008
0.0178 1.1963%
0.0178 - 1.19034
Generation of a polynamial equation nsing enats The poly commend takes
the roots, and converts them inio a polynomial equation. Por instance, if we know
Tris ran ota) in
(erie ra) fer} = 2h beget + age pe tena ton
thenSection 1.7 Tools for Polynomials a
>ppoly([ri, %) -°>, tal)
provides us the coefficients{ [a1,a2,--+, dn]) of the polynomial equation. Fer exaznple,
>ppoly([-1 —24+24¢ —2—248 —547«¢ —5—T+i])
produces
ans =
i o15 196 498 968 §92
In order to check the result, we use roots command again.
>>roots([! 15 146 498 968 592))
‘The result should be [-1 —24+2*¢ —2~2ei -5+i#i -5-7ed.
Polysumial value When we want ty calculate the value uf a polynomial ab a certain
point, we can use polyval.
>> yspolyval((1 34 -5 19)
ans =
23
which evaluates the polynomial 6? + 367 4 4s -— 5 at
Multiplication of two polynomials ‘he conv command is used to muliply two
polynomials. For example,
a(s)= se? 44s—1, (a) 2s? + 60-7
‘The multiplication of a(s) and 6(s) follows as
>>excomv(l 3-1, -26 -7)
130-27 7
In other words, we cbtain the coefficient vector c of the product of a/s) and 6(s)
ion of a polynomial The deconv is used to decampose a polynomial!
ae a multiplicend and s residue. Let
a{s) = He)m(«) + r(s)
That ia, the polynomial a(3} is reprosonted in terms of a nmltiplicand fa} and «
residue r(s) via. B(1). The MATLAB command ‘s
>> bm,7] =deconv(a,})
where the parameters are ccefficient vectors for given polynomials. An example is
given by
>» [m,7] =deconv(t -2 6 -7,[1 3-1)
m=14 Introduction to MATLAB Chapter 1
1 6
r=
0 0 22 -12
If we change the order of polynomials,
>> [m.r]=deconv({1 3 —1},[1 -2 6 -7)
m=
Polynomial fit The poly fit command ip to generate » polynomial carve which fits
8 given sel of data, The polynomial is obtained by minimizing the etror between the
polynomial and the given data set. The synopsis is
p =polyfit(z, y,2)
where 2 and y are vectors of the given data cet in (2, y) form, and m is the order of the
desired polynomial to fit the data set. The ouiput result is p, the coefficient vecter of
‘the fitting polynomial, An example is provided below,
praes[l 2345 6);
>>ys[-1 352 -3 1)
>> p =polyfit(z,y,1)
p=
21714 -1.268T
A linear curve fitting is performed for data set (z,x).
1.8 Making Complex Numbers
In order to make a complex number 243 ¢ i, we use
ep D4 Bel
or
>> 2+ aed
MATLAB tokes 4 and j as a pure complex number. In ctse# or j is defined already,
>> i ssqrt(—1)
#=0+ 1.0000Section 1.0 Nonlinear Algebraic Equations 15
‘Kable 1.9.1 Functions for Nonunear Algeprate Equarions
Symbol Explanations
fmin finds minimum of » function of one vsrisble
frero_| solves anonlinear algebraic equation of one variable
abs, angle For a given coraplex number, we use abs and angle commands to find
out the magnitude (abs) and phase angle (angle) of the given complex number. For
example, if
Does lth
then
>> abs(e}
ang = 14142
>> angle(e)
ang = 2.3562
Real, imaginary parts of a complex number The real and imag are used to
toke the real and imaginary parts of a eomplen aumber, For oxample,
W494i
>> freak) ,imag(c)]
ans =—10 9
ppe=
Conjugate The conj command is used to generate a complex conjugate number.
For example
>> conj(-1+5*#)
ans = 1-544
1.9 Nonlinear Algebraic Equations
Nonlinear algebraic equations are frequently adopted in many different. areas,
The nonlinear equations are different from linear equations, and there is no unique
analysis too! to the nonlinear equations. MATLAB is equipped with some functions
which can handle nonlinear aquations The list is precented in Tabla 1.01
Minimum of a function The MATLAD command fain minimises 9 funetion by
finding out 4 value which minimizes the given function. The synopsis is
Hmin(' func’, 22)18 Introduction lo MATLAB Chapter 1
‘Table 1.10.1 Numerical Techniques for Ditferential Equations
Explanations
ede23 | solution using the 2nd/Srd order Runge-Kutta algorithm
odet5 solution using the 4th/5th order Runge-Kutta algorithm:
where “fune’ is the name of function to be minimised and #,(z2) represents &
lower(upper) limit of the interval of the function argument. For example,
>pfmin('z + 208(2)', -2,2)
produces
ana = —0.8603
Solution of a nonlinear algebraic equation When a nonlinear algebraic equation
is written as
0
the MATLAB function frero can be used to find solution of the nonlinear algebraic
equation. ‘The synopsis is
9434 sin{z) —
>> sol =faero(’ function’, 20)
where ‘function’ ic a MATLAB function subroutine and #0 is an initial condition
veclur of the vatiables. For the given example, we write a function aubroutine fotn.w
as
fanetion [f] =fetn(2);
foad4 2 + cos(z) — 42;
Then, ne use fzero command 48
>> sol =frcro(! fetn’,—5)
sol = 984
In order to hack the solution
>>fotm(—2.1981)
ans =
1.9198e-004
The error is due to the numerical dormat error, The number is trunested for screen
display purpose, even if it is calculated using dowble precision format inside MATLAB,
1.10 Solving Differential Equations
Linear and nonlinear differential equations can be also solved using MATLAB.
List of numerical techniques solving differential equations is in ‘lable 1.10.1.Section 1.11 Loop and Logical Statement wv
Runge-Kutta second and third order algorithm MATLAB uses the Runge-
Kutta algorithm to sclve a differential equation or a set of differential equations. The
general synopsis is
[é,2] = ode23(' func ,t0, tf, x0)
where *fune’ is a function containing the derivative information, 10 (tf) is the initial
(final) time, and 20 is an initial condition vector. The outputs are i, which eontaine
the returned time points, and x which is the integrated output
For oxample, we want. te oolve
H+ sin(z) =0
which can be rewritten as
fay
fq = —sin()
where x, = @ and #z =#. The ’fune’ function should be provided as an indpendent
function subroutine ax faxc.m in a directory, which MATLAB can locate. Now we
execute the odezs command
>> [i,2] sode23(' func’, 0, 10, 20);
o-{3)
is an initial condition and furc.m is provided as
Sumctbucs [f] =faue(x);
eros(2,1);
where
Rumge-Kutta Bourth and Pifth arder algorithm There ic snather Runge Katia
algorithm ode45 which is more accurate than ode23.
[t, 2] = edeas(’ func’, 10, ¢/,20)
‘The came calling synopsis as ode23 can be applicd to make uso of the odedS
function.
1.11 Loop and Logical Statement.
‘Phere ove sume logical slatcments available in MATLAB which help us writing
combinations of MATLAB commands. Furthermore, loop commands can be used as
in other programming languages. In fact, we can duplicate the majority of existing
programs using MATLAB commands, which significantly teduces thesive of the source18 Introduction to MATLAB Chapter L
al Statements
Table da. Loup aud ©
Symbol Explanatior
for Joop command similar to other languages
while used for a Joop combined with conditional statement
if produces a conditional statement
elsoif, clea used in conjunction with if command
break breaks a loop when a condition is satisfied
codes. A collection of loop and logical statements in MATLAB is presented in Table
LIL,
for loop The for is a loop command which eads with end command,
In the above example, iis a loop index which starts from 1 and ends at 100. There
may be oloo multiple Ioopa.
>> for i 100
for j=1:50
for k= 1:60
) = AGA) weld) ta
end
while The while command is useful for an infinite loop in conjunction with a
conditional statement. The general synopsis for while command is a8 follows
while condition
statements
end
For example,
1
while (5 < 100)
gait;
end
Another example of the while command is
= 1000;
var =];Section 1.11 Loop and Logical Statement 19
while (n > 0)
n=nft—1;
var = (ear, es
end
‘The result ic
vat =
Cohumns 1 throngh 6
4,9900e+002 2.4850c+002 1.2325e4002 §.0625e+4001 2.9313e4001 1.3856e+001
Columns 7 through 9
5.8281e+000 1.914Je+000 -4.2969e-002
where we used [ ] iu order vo dedare au exupty matrix,
if, elseif, else The if, elseif, and else commands are conditional statemenis which
are used in combination.
if condition #1
staternent #1
elseif condition #2
stuteruent #2
else
atoternent #3
end
For example,
n= 10;
if (rem(n,3) == 0)
2=0;
elseif (rem(n,3) == 1)
eal
where rem(x,y) is used to calculate the temainder of z diviced by y.
break The break command is used to exit from a loop such as if and while, For
cxample,
if(¢== 10) break;
end
end20 Introduction to MATLAB Chapter 1
Table 1.11.2 Loop oud Logical Statearenes
Symbol Explanations
twa conditions are equal
= two conditions are not equal
<=( >=) | oneis less (greater) than or equal to the other
fone ia Teas (greater) than the other
& and operator - two conditions are met
not operalor
I or operaice - either one condition is met
Logical and relational operators The logical and relational operators of
MATLAB are as listed in ‘Table 1.11.2.
The above command sets are used in combination,
1.12 Writing Function Subroutines
MATLAB provides a convenient tool, by which we can write a pregram using
collections of MATLAB commands, ‘This approach is similar to other common
programming languages. It is quite useful especially when we write a series of
MATLAB commande in a text file. Thio text file ic edited and omved for lator noc
‘The text file should have fileneme.m format normally called m-jile. That is,
all MATLAB subroutines should end with .m extension, so thai MATLAB recognizes
them as MATLAB compatible files, The general procedure is to make a text Mle using
any text editor. If we generate a file called func.m, then the file funed.ma should start
with the following file header
fanetion[ou ,ovg,...] = func (ins,ivp,
where iu,,it,... ate input variables while ovy,oo2,... are output variables. The
input variables are specific variables and the output variables are dummy variables,
for which we can use any varinbles.
For example, let us solve a second order algebraic equation.
az? +br+e=0
‘The sulution is given in analytical form as
abt VPN Teaee
QeSection 1.12 Writing Function Subroutines a
We want to write an m-file with the name secrvot.m, which produces the analytical
solution.
fimetion [r1,r2]=secroot(a,t,¢);
%
% Pind Determinant —— Any command in MATLAB which starts with
% % sign is a comment statement
Det = 02 —4waxc;
if (Det <0),
baja agrt(—Det\/Ifa
b= jx egrt(—Det})/2/a;
disp('The two roots are complex conjugates’);
disp('There are two repeated roots‘);
dlse(Det > 0)
Bt agré(Det))/2/a;
—b— sqrélDet))/2/a;
disp(‘The two roots are real’);
end
Some commands appearing in the above example will be discussed later. Once the
secroot.m is created, we call that function as
>> [Pl r2]=seeroot(3, 4,5)
or
>> Ppl. p¥] Ssecroot(3, 4,5)
One thing important about the function command is to set up the mefle
pathname. The mafile should he in th ditectory which is set up by MATLAB
configuration set up slage. In the recent version of MATLAB, the set up procedure is
relatively cacy by aimply adding a directory which wo want to accoea in a MATLAB
configuration file.
Another function subroutine fct.m is provided belov.
function [f] =fet(x)
fa 272)
‘The above function represents f(z) = (1—)®. In the MATLAB command prompt,
we call the function as
=fct(9);
The function subroutine utility of MATLAB allows users to write their own subrou-
tines. It provides flexibility of developing programs using MATLAB.
>>22 Introduction to MATLAB Chapter 1
‘Tablo 1.19.1 File Manipolation Commands.
Symbol Explanations
save gave current variables in a file
load Joad a saved file into MATLAB environment
diary save screen display output in Lext format
1.13 Pile Manipulation
Manipulating files is another attractive feature of MATLAB. We can save
MATLAB workspace, that is, all variables used, in a binary file format and/or
text file format. The saved file can be also reloaded in case we need it Inter on. The
list of fle manipulation commands is presented in Table 1.13.1.
sava The eave command is naed to save variahles when we are working in MATLAB.
‘The synopsis is aa follows
gave filename wary vers os
where jilename is the filename and we want to save the variables, var, vary, .... The
filename generated by save command has extension of -tmai, called a mat-file. If we
do not include the variables name, then all current variables are saved automatically.
In case we Want to save the variables in a standard text format, we use
save filename vary vurg ..fascii/doutte
Joad The load command is the counter-part of save. In other words, it reloads
Uhe variables in the file which was generated by save command. The synopsis is ax
follows
load filename var: varz
where filename is matyfile saved by save command, Without the variables name
specified, all variables are loaded. For example,
ppas[i 3 4};
>> b= 3;
>>save test
>pelear all % clear sll variables
>>who ‘% display current variablea being used
>>load test
>>who
ary Using diary comand, we cm capture all MATLAB teats including command.
and answer lines which are displayed on the screen. The vexts will be saved in a file,
80 that we can edit the file later. For example,
>odiary onSection 1.14 Basic Input/Output Functions 23
Table 1.14.1 Inpul-Outpal. Kunetions
Symbol Explanations
input save current variables ina file
disp load a saved file into MATLAB environment
format check the file status in the directory
poashbadies
pola be]
>> daanh
presgth
>>diary off
Now Wwe can use any 1exXt editor to modify ihe #tary Me, ‘The diary command 's
useful displaying the past. work procedures. Also, it can be used to save datn in text
format,
1.14 Basic Input-Output. Functions
Input/output functions in MATLAB provide MATLAB users a friendly pro-
gramming environment. Some input/output functions ate listed in Teble 1.14.1.
imput The input command is used to receive a user input from the keyboard. Both
pumerical and string inputs ars available. For oxample,
>> age= imput('Houw Old are you?’)
>> name =input('What is your name’, s')
‘The ’s? sign denotes the input type is string.
disp ‘The disp command dispiays a string of text or numerical values on the screen. It
is useful when we write a function subroutine in a user-friendly manner. For example,
pe disp(‘This is a MATLAB tutorial’)
>> disp('‘The computed value of ¢ turns owt 10 bc)
pre
format ‘The format cormand is used to display narsbers in different formats,
MATLAB calculates floating numbers in the double precision mode. We do uot want
to, in some situations, display the numbers in the double precision format on the
sereen, For a display purpose, MATLAB provides following different forrnats
ppr=l/o24 Introduction to MATLAB Chapter 1
Table 125-1 Mowing Commands
Symbol Explanations
plot basic plot command
xlabel{ylabel) attach label to x(y) axis
axis meanuelly scale x and y axes
tont place s toxt an the spacific pasition of graphic eeroen
title place a graphic title on top of the graphic
ginput produce a coordinate of a point on the graphie screen
gtoxt reteives a text fram mouse input
grid add a grid mark to the graphic window
pause hold graphic acroen until keyhonrd ia hit
subplot breaks a graphic window into multiple windows
x= O11
>>format short ¢
z= Lille—001
>>format long
w= DPIILHI1LI1LI1
>aformat long ¢
AULLLU11101 Le — 001
pofurmat hex
SfbeTe7cPle7le
1.15 Plotting Tools
MATLAB supports some plotting tools, by which we cen display the data in
a desired format. The plotting in MATLAB is relatively cnay with various options
available. The collection of plotting commands is listed in Table 1.15.1
A sample plotting command is shown below.
0.4: 105
y= sin(t);
>> plot(y)
>> title plotty))Section 1.16 Plotting Tools 25
‘The resultant plot is presented at the top of Fig. 1.16.1.
>> b= 0:01:10;
>> y= sin(t);
>> plot, y)
>> title('plat(y)’)
The resultant plot is presented at the bottom of Fig. 1.15.1. In the above example,
+= 0: OL : 10 represents a vector ¢ which starts from 0 and ends at 10 with an
interval of 0.1. We can use just y or both y and ¢ together. In the tirst case, the
horizontal axis represents number of data, from 0 to 103. In the second case, the
horizontal axis is the actual time scale ¢ in the plot(t,y) command.
Plotting inultiple data We plot multiple data sets as shown below.
0:4: 100;
sin(t). #4
ros(t) ets
>> plot(tiyd, 4492," )
where ‘-’ and "—’ represent line styles. The line styles, line marks, and colors are
listed in Table 1.15.2.
For example, if we want to plot a data in a dashed blue line, the command becomes
>> plot(y,’4
xdabel, ylabel The xlabel('text’) end ylabel(‘text’) are used to label the and y
axia The axis command sets up the limits of axes. ‘The eynopsis is
aaxishitmins Zmae: Ymins trae)
text The text command is used to write a text on the graphic window at a designated
point. The synopsis is
text(s,y,{text contents’)
‘where 2, y locates the 2, ¥ position of the ‘text conzenzs'. In case we want 1 aormalize
the graphic window size fom 0 to 1, we use
toxt(2,ytext contents / se’)
input This command allows us to pick up any point on a graphic window. The
synopsis is
(t,9) = ginput28 Introduction to MATLAB
ol
as}
04}
oat
pe
potty)
oe
on}
os
oa}
aa
a9}
4,
Figure 1.19.1 A Sample Plot
Chapter 1
We can pick as many points as we want on the graphic screen, ‘The welor [2,9] then
contains all the peints.
gtext The gtext command is used to place a text on the graphic window using the
mouse input. The synopsis is
gtext(‘teat')Section 1.15 Plotting Tools x
Table 1.26.2 Line, Mark, aud Golor Styles
Style Line marks Color
solid point. rel or
dashed = *~’ star * aren
dotted "2 cirde 0 blue b
dackdot 7." plus 4 white
_ x-tnark invisible i
Once the above command is entered or read in a function subroutine, the cursor on
the graphic window is activated waiting for the mouse input, #0 that the “tar? is
located at the point selected by the mause.
grid ‘The grid cemmand adda grids to the graphir window It is useful shen we
want to clarify axis scales.
An example plot constructed using some of the commands described above is
presented in Fig. 1.15.2. ‘The following commands are used for the plot oxtput.
e> #20:0.1:205
>> plottt, san(t))
>> xlabel('Time(see}’)}
>> ylabel(’ydata')
>> title('This is a plot example’)
>> erid
>> gtext('sin(:)')
>> axds((0 20 - 1.5 1.5)
pause This command is useful when we display multiple grapbie windows sequen
tially. It allows us to display one at a time with the keyboard interrupt.
subplot The subplot is used to put multiple plots on the same MATLAB figure
window, The command is
>> subplot(pgr)
‘The plot cise is adjusted by a p by g matrix on the whole-sige of the geaphie window.
‘Then the third index r picks one frame out of the p by q plot frames, Av exanple
subplot is presented in Fig. 1.18.3 with the following commands entered.
pe eS 0: 01 De piyy = sin(e)jx = c0a(s);
>> subplot (222)
ve plot(s,y)
3> title('x and y?}
>> subplot(223)
>> plot(z,2)28 Introduction to MATLAB Chapter 1
‘Theis a pleteoargla
Figure 1.15.2 A Plot Example With Some Commands
xewy
as|
asl
x * 7%
and
os] es|
q
a oa
Figure 1.15.8 A Subplot Example
>> title(x and 2’)
>> subplot(224)
>> plotiz,y/Section 1.15 Plotting ‘Lools
>> tith('x and [y 7}
where pi is an internally defined variable equivalent to 7.CHAPTER TWO
APPROXIMATION TECHNIQUES
2.1 Methods of Weighted Residual
Methods of weighted residual are useful to obtain approximate solutions to «
differential governing equation, In order to explain the methods, we consider the
—, O
jw (419)
0 3 0 2 7 -2| fas] Ju
6 a G Qo -2 te a74 Direct Approach With Spring System Chapter 4
Z
2 le
rigid maselear plate
w
%
2k
«eZ [v T
ae BE
7
po Tigid massless plate
rigid —*
massless plate 3 y
w
|
——rigidt massione plate
5
Figure 4.1.3 A Mass-Spring System
The matrix eqnation determines the displucements of the springs.
4.2 Axial Member
‘The Linear spring can represent vasious systems in ongineczing applications. Onc direct
application is the axial member. Consider an axial member with length 2, nniform crosi-
section A apd elastic modulus £. The elongation § of the axid meraber subjected to an
axial force P is computed from
PL
aE (4.2.1)
Rewriting Raq. (4.2.1) gives
P= os (42.3)
As a reault, che cquivalen: spring coustapt for the axial bar ie
hea — Ag (42.3)Section 4.2 Auual Member cy
Ark,
ky = fe
yt aa
——P
4
uy, LL, us ‘
Figure 4.2.1 Axiel Members Represented by Pauivelont. Springs
Example 4.2.1 Axial members can be represented by serial and/or
parallel Linear springs. For example, a bar of telescoped shape can be replaced
by a sories of springs as shown in Fig. 4.21. There are three Sinear spring
clemanta and each clement haa malvie expression ax shorn ix Pq (444) with
proper spring constant &;. Assembling them gives
hy why 0 0 ts fi
kL with, kp 0 w{_jo
0 kh krtks —ks| Jus (=) o (424)
oO oO fg hs us P
where ky == APE! and f; io the unknown reaction force at the Ieft en! support,
Inotead, u; = Uis given as the boundary condition. Solution of Hq. (42.4) with
this boundary condition will result in fy = ~P which can be also obtained from
the static equilibrinm. However, the finite element firmlation zlready includes
equations of static equilibrium 90 that we may not ure additional equilibrium
equations. These equations are redundant.
& Bxample 4.2.2 Consider a statically indeterminaut syotcan 1m shown in
Pig. 4.2.2. The axial member cam be replaced by two fincat oprings a8 secn in
the figure. The flue element matrix equation for this systema is
sk 05k 0 wy fi
D5 15k Kk] dug b= 40 (42.5)
oo -& | lee b
where k = 42 aad f; and fy are the anknown forces at the supperts. Because
the system is statically indeterminate, we cannot find the forces fem the siatic76 Direct Approach With Spring System Chapter 4
Z AE
Z PF Z,
L
2L E
AE
ey TE op ee 4E
6
on ate b= as
aL ZL
Pigure 4.2.2 A Statically Indeterminate Axial Member
“
i,
Rigid Plate
Figure 4.2.8 A Spring Representing Statically Indeterminate System
equilibrium equation only. However, the finite element formulation includes net
only equilibrium but also geometric compatibility (compatibility of deformation}
‘Therefore, Eq. (4.2.5) along with boundary conditions ty = tis = @ can salve
the deformation as well as the reaction forces.
Another statically indetertainate oyetemt anade of axial sods can he repreccated
‘by a opting constant os shown in Fig. 4.2.3. 1Section 4.4 Other Systems 7
Figure 4.3.1 Torsional Members
4.3 Torsional Member
A cirenlar rod subjected to a twisting momen produses an eugle of twist
TL
a 3.)
in which @ is the angle of twist, T'is the applied torque, Lis he length of the member,
G is the ahear modulus, aad J is the polar moment of inertia of the circular cra
section. Rewriting the equation yields
39
‘The equivalent spring constant is key = $4. Torque T corresponds to the spring farco
F and angle of twist 9 to the spring displacement u. As examples, both statically
determinate and indeterminate torsional members are shown in Fig. 4.3.1 along with
their equivalent spring systems.
4.4 Other Systems
Other frequently used engineering systems, which can be easily substituted with
a spring systern, are heat conduction, siraple fluid flow along pipes and electric cir-
cuits. For one-dimensional heat conduction, leat Hux is proportional to temperature78 Direct Approach With Spring System Chapter 4
_ fi, — ah
ky i fe
Figure 4.4.1 Mechanical Forces From Newton’s ‘Third Law
difference. Phat ia, hoat flux gia
q=-kAT (44)
where k, is the heat conduction coefficient and AT is the temperature differences
between two end points of a one-dimensional bar. The minus sign it: the equation
denotes heat flux is in the opposite direction as the temperature increases along the
positive axis. ‘The equivalent spring system has the spring constant keg — ~hz, the
spring force ? = q and the spring displacement w =P.
Fluid flow rate Uhrough a pipe of constant cross-section is proportional to the
pressure difference of the two ends. That is,
Q=-kAp (44a)
Here, @ is the Dow rate, Ap is Uhe pressure difference, and &y is the proportional
constant. For a laminar flow, the proportional constant can be expressed as
(44.3)
where p is the fluid viscocity, d is the pipe diameter, and J is the pipe length. The
equivalent spring system bas the spring constant kg = —Ky, the spring fore: F = Q
and the spring displacement w = p.
Flectric current flow # through a resistance Ris
v
ing (4.4.4)
where V is voltage. The equivalent spring system has pring constant keg = $, force
F = 4, and displacement w= V. One may think what about ¥ =i R such that
POV, beg = Rand w— i. Which oue is concet? Te dhe oquivalent wpeing wastent
Hor #? One is right and the other is wrong. One way to select the right form is
to understand the nature of spring force and to find the parameter equivalent to the
force. Then, the zest of parameters can be determined accordingly.
When two springs are separated each other, internal forces occur hetween the
two aprings. These forres are equal in magnitnde and opposite in direction When the
two springs are put together, the forees cancel each ather and became sero if there ia
no external force applied at the joint as seen in Fig. 4.4.1. This is known as Newton's
third lew. When considering clectric current, ito aum ot the joint of rosiatante (i.0.
the middle point in Fig. 4.4.2) is also zero like the force. However, voltage docs not
vanish at such a joint. Ap a cesult, electric current is similar to the mechenical force.
‘Therefore, the equivalent spring constant for the electric sirauit is 4 but not X.Section 4.4 Other Systeme ”
Figure 4.4.2 Flow Through a Pipe System,
Example 4.4.1 Consider a pipe system for finid flow as seen in
4.4.2, The ntessnre at the inlet is 200 while the flow rate at the miet is 50.
The proportional constants ky in Eq. (44.2) are given in the fignre, All unite
are asgumedi consistent. We want to determine the flow rate between node 3 and
node 4.
Using the near spring equivalency, the matrix equation becomes
-1 1 0 O 0 Oo PL a
1-3 4 -8 0 of ly 0
0 4 -2 2 t¢@ of|tmt_} o
o 8 2 -1 1 0 J tm f=) 0 (40)
6 0 16 1-49 32 Po
1 0 6 9 2% ~291 Loe = 60
Applying the known pressure 71 = 200 to this equation yields the following
pacomare at cach neds,
pz = 160, ps = 142.2, pa= 147.6, ps = 199.6, ps = 188
Therefore, the flow rate between nodes 3 and 4 is
Qa-4=
2 x (147.6 — 142.2) = -108
Hence, the flow is unward with rate of 10.8. t30 Direct Approach With Spring System Chapter 4
200
NVA A OANA
us
Fignra P41 Problem 4.1
Problems
4.1 Find the system of equations for the spring systern shown in Fig. P41. Solve
the matrix equation to find the displacements of the nodal points.
4.2 A cizcular shaft is made of two different materials and fixed at both ends. It is
subjected to torsions as shown in Fig. P4.2, ‘The diameter of the shaft is 0.1m.
Find the angies of twist at the nodal points.
4.3. For the given mass-spring system (see Fig. P4.3), (a) develop the system mass
and stiffness matrices to determine natural frequencies of the system. (b) Apply
the given boundary conditions to the matrix equations.
4.4 An electric circuit is shown in Fig. P44. Find the current flow using the
equivalent spring system.
4.5. Hor a laminar pipe tow, the How rate is proportional to pressare difference
Construct the system of equations for the given pipe flow as shown in Tig. P4.5
in order to find the flow rate through each pipe.
4.6 Heat conduction through a circular pipe is expressed as
Qrkb
1 Parad
in which & is the heat condhiction coefficient, D is the length of the cylinder, and
, and ry are the onter and inner radii of the cylinder, respectively. Therefore,
two concentric cylinders with radii ry < rg ~< rx vau be represcuted by two
springs im serial connection, Find the equivalent spring constants for the two
Yinear springs in Fig. P4.$ and construct the system of equations.Problems 8
Fred
Diameter = 01 m
Element 1 & 2G = 80 GPo
Element 3G = 40 GPa
Figure P4.z Problem 4.2
rigid bor
ig ks
‘y
AWM\-
oy
Figure P43 Problem 4.3
7 10 volts
Figure P4.4 Problem 4.482 Direct Approach With Spring System Chapter 4
EER
Soren
SNe
Leer
|
Figure P40 Problew 46CHAPTER FIVE
LAPLACE’S AND POISSON’S EQUATIONS
5.1 Governing Equation
Laplace's and Poisson's equations are common field governing equations to de-
scribe various physical asturse. For oxamplo, these differertisl oqustions can reprevent
heat conduction, potential flow and torsion of noncixcular members. Therefore, we
study the finite element formulation of these equations. Laplace's equation is
Vuso (5.1.
while Poisson's equation is
Vusg (5.1.2)
Because Poisson's equation is more general than Laplace's equation as seen above, we
consider Poisson's equation In the following formatazien,
Poisson’s equation in terms of the Cartesian coordinate sysiem becomes
au
Gat
on
oy?
= ery) int (B13)
for the two-dimensional demain Q. The bonndary conditions sre
a 6.1.4)
and
ae =e wl, 61.9
where @ and g denote known variable and flux houndary conditions, aud n in Eg.
(5.1.5) is the outward normal unit yeetor at the boundary. Furthenunote, C4 and Ca
are boundaries for essential and natural boundary conditions, respectively. For the
well-posed boundary value problem,
T.Uln=P (618)
83#4 Laplace’s and Poisson’s Equations Chepter 5
and
Pent, = 619
in which U and N denote sum ad intersection respectively, and [is the total boundary
of the domain 2.
Integration of weighted residual of the differential equation and boundary
condition is
wars
r fw Fe F4 ge.) an [ oar (51.8)
In order to develop the weak formulation of Ea, (5.1.8), integration by patis is applied
to reduce the order of differentiatian within the integral. The subsequent example
shows the integration by parts.
& Example 5.1.2 Consider a two-dimensional domain as seen in Fig. 5.
First of all, we want to evaluate the first term of Eq. (6.18)
[8 wan (5.1.9)
‘The domain integral can be expressed as
fe yes dy (5.1.10)
where 1 and yz are the minimum and maximum values of the domain in the
sania an the otrip along the a-nie moves in the ydircction nanecn in Fig. 6.1.
Integration by parte with respect bo 2 yields
EE Fe eee = [fe] ay GL)
Ba cs oe, FL
and tewtiting the expression nsing the domain and boundary integrations 35
shown in Fig, 5.1.1 results in
dw du au
jn Be Be" fac
f ujpneat (5.1.19)
in which #1, is the s-component of the unit normal vecior which is aswumed to
be positive in the outward direction as shown in Fig 511. Fisally combining
the two boundary integals gives
du du
[a + f ofienat 6.113)
where the boundary integral is in the counter- clockwise ditectionSection 6.1 Governing Equation 86
Yar ty)
SH ar
x x
x Xo
Figure 5.1.1 Two-Dimensional Domain
Similarly, the second term in Eq. (6.1.8) can be written as
ow Ou f ou
[By Ot RT Gad)
Adding Bap (54.18) are (6.118) produces
au du | dw Gs
-f geet 4 Bete an +fo (F ne + am at 6.115)
Since the boundary integral can be written as
é Bu a
an oat
(51.18)
we can rewrite Eq. (5.1.15) a5
[oe 3+ Fp) =
~ Geet eae) fem (B17)
‘The symbol § to denote the line integral around 1 cloned boundary is replaced
by f for simplicity in the following text, Equation (5.1.17) is known as Green's
trcorem.86 Laplace's and Poissen’s Equations Chapter 5
Use of Eq. (5.1.17) to Eq. (5.1.8) results in
- f, (28 + MB) aa finns [ eltn — 1n9
Phe fink velurue inteyral becomes asuatria term while both Ue second volune integral
and the line inbegral become a vector term. In the context of heal conduction, the
second volume integral is related to heat source or sink within the domain, and the
line integral denotes the heat ux through the nalaral boundary.
5.2 Linear Triangular Element
Diseretization of the domain in Eq. (5.1.18) is performed using selected two-
dimensional finite elements. One of the simplest two-dimensional elements is the
three-noded triangular element. This is also known as linear triangular element. The
element is shown in Fig. 5.2.1. It has three nodes at the vertices of the triangle and
the variable interpelation within the element is linear ins and y like
usa tenet agy (B21)
or
walle nfs} (52.3)
where a; is the constant to be determined. The interpolation function, Bq. (6.2.1),
should represent the nodal variables al the three nodal points. Therefor, cubstituting
the 2 and y values at each nodal point gives
a ta vl (a
{eff} 5 i] { node no, and j-> x ory
gcoord(1,1)=¢.
9 (58.1)Section 5.9 MATLAB Application to 2-D Steady State 109
25; aeoord(2,2
55 wooord (S,2)=6.8;
gcoard(4.1}-=3.75: ecoord(4.2}=0.0:
geoard(5,1 wcoord(5,2)=6.0;
gcoord(6,1}—0.0; geoord(62}=1.5;
seovrd(T1)—1.285 geoord(7.2)—9-55
geoord(8,L}=2.5; geoord(8,2)=2.5
geoard(9,1)=3.75; geoord(9,2)
‘g609rd(10,1)=0.9; Ecvord(10,2)=2.95
geoord(11,1}=6.5; geoord(11 2)=5.0;
gcoard(12,1)=1.25; gevord(12,2)=5.0;
geoard(14,2)=2.5; gcaord(13,2)=8.0.
geoord(14,1}=3.75; gooord(14,2)
gcoord(28,1}=8.0; gcoord(8,2)=8.0;
gcoard(16,1)}=0.9; gcoord(16,2)=7.5;
gcoord(I7,1)=1.25; gooord(17,2)=7.
geoord(18,1)=4 5; geoned(12,2)~7.5,
gcoord(19,1)}=3.75; gooord( 19,2)=7.
geoord(20,1)}=5.9; gcoord(20,2)=7.5;
seuurd(22,1}=0.9, gemunl(22,2)=20.,
gcoard(23,1)=2.5; gcoord(23,2)-=10,;
geoord( 24,1}=-3.75; gcoord(24,2)=10.
geoord(25,1)}=5.0; gcoord(25.2)=10.;
%
&—-——_-
% impat data for nodal connectivity for each element
% noranG) whore iat clement no. and 5% crmnected wocten
§—_____________
nodes(1,1)=1; nodea(2,2)=25 nodea(1,3}=7;
nodes{2,1}=2; noden(2,2)=9, noden(2,0)=9;
nodes(3.3}=9;
odes(4,3}=26;
nesdes(9,5}=55
nadea(S,1)=1; nodes(s,7,
nodan(6,1)=2
nodes(9.1):
nodes(20,1
nodes(11,3)=14;
0; nodes(12,3)=15;
nodea(17,1}=211; nodes(27.2)=22; nodes(17,3)=27;
nodes(18,1}=12; nodes(18,2)=13; nodes(18,3)=18;
nodes(18,2)=13; nodes(19,2}=14; nades(19,3)=19;110
Laplace’e and Poisson's Equations Chapter §
nodes(22,1)=12; nodea(22.2);
nodes(28,1}=18; nodes(23,2)=
nodes{24,2}=14; nodes( 24,2)
nodeo(26,}a116; nodea(I6,2)=17; nodea(26,2)—225
nodea(26,2}=17; nodes(26,2)=18; nodes(26,3)—23;
ngdes(27,1}=18; nodes(27,2)=19; nodes(27,3)=24;
nodes(28,1)=19; nodes(z6,2)=20; nodes 28,3)=205
nodes(29,1)=15; nodes(29,2
nodea(30,1)=17; nodes(30,2
nodes(31,1)=18; nodes(#1,2:
nodes( 32,1)=19; nodes(32,2;
%
%— —______.
% input data for houndary conditions
%—
bedof(1}=1; 3% fist node is constrained
beval(1)=0; % whose described value is 0
Vedot2}=2, 7% weouad soe is coueaed
beval(2)=0; % whowe described value is 6
bodof(3}=3; % third node is constrained
beval(3}=0; % whose described value is 0
bedof{d)=4; % Ath node is constrained
beval(4)=0; % whose described value is &
bedof{S}=5; % Sth node is constrained
beval(5)=0; %e whose described valve ia 0
odo (6) E fth nave in comatrainad
beval (@)= % whowe described value is 6
bedaf{7)—13; % Mth node ia constrained
beval(7}=05 96 whore described value is
bedof{8)}=16; % Lith node is constrained
beval(s)=0; % whose described value ia ©
bedo(y}=31; % 2iet node is constimaned
% whose described value is 0
‘% Bad node is constrained
5 whone described value is 38.2683
% Bed node is constrained
% whose described value is 70.7107
% 24th node is constrained
% whose described value is 92.9880
% Bich node is conetrained,
‘% whose described value 8 100
% initialization of matrices and vectora
%——___—_—_____-
HE=zeros(sdet,2); % initialization of system force vectorSection 5.8 MATLAB Application to 2D Steady Stete ut
Kk=zeroe(adoljadol); % initialization of aynteru matrix
index=zeros(nnel*ndof,); lization of index vector
%
%—— eS
% computation of element matrices and vectors and their assembly
% — - —
for id=ILnel % loop for the total number of elements
%
nd(1)=nodes(tel!}; 6 tet connected node for (sl)-th element
nd(2)=nodes(iel,2); % Ind connected rode for fiel)-th element
nd(3)=nodec(iel,3); % 3ed connected node for (el)-th element
xi=geaord{nd(3),1); ylexgooord(nd(4),2); _% cverd values of Jet rode
x2=gcoord(nd(2),1); ¥2=gcoord(nd(2),2); _ % coord ralaes of 2ad node
x3=gcoord ind(3).1): vdsegeoordind(3).2); —% coord valuet of 3rd node
%
index=feeldof{nd,anel,udof}; ‘% extract system dofs for the element
%
k-felp2dtS(x1,y1 x2.y2.x3,3), ¥% compute element matrix.
%
kek—fesambl1 (ck, eamlex); 1% ssromble clement matrices
%
end
%
% —
% apply boundary conditions
% —_——
(kk, f] =feaplyc2(kk, fi, bedof heval);
%
k——_—-
% solve the matrix equation
% an
faolakk\tt;
%
%
% analytical solution
smnode
x=gcoord(i,1); s=geoord(i.2};
esol (i) aT 0*sim h (0.91415997%y)Fain( 0.3141 5927*%) /simh(3.1415927};
end
‘% print both exact and fem solutions
%
store=[unm’ fsal esol’)
%
%—12
Laplace’s snd Puisson’s Equations Chapter 5
fonction [kk]=feastobll (Ek,k,index)
%—_—
% Purpose:
% Assembly of element: matrices into the spatem matrix
%
% Synopsis
% [kk]=teasmbli(ki,kindex)
%
% Variable Description:
% le - ayatem matrix
% k- clement matri
% index - Lo. vector associated with an element
length (index);
iledof
HHindan(i);
Wi (Lat) = KKH) F449
end
ead
x
Annction [index]=feeldof{ndnnel.ndot)
% Purpose:
% Compate syatom dofe astociated with exch element
%
% Synopsis:
% [index]=leeldof(nd,nnel,ndof)
n
% Vasiable Deseription:
% index - system dof vector associated with element iei
% nd - element rode aumbers whose system dofs are to he determined
% anel - number of nodes per element
% ndo€ - number of dofa ner node
Gow ee
%
edof — anel¥ndof
siart = (nd(i)-1)* alos,
for j=tindof
kek+1;
index(k)=atart+isSection 5.9 MATLAB Application to 2-D Steady State 13
end
end
%
Fonction [k}felp2dea(x1,51.22,92.x3,y3)
%—__—
9 Poapores
‘% element matrix for two-dimensional Laplace’s equation
% using thyee-node linear triangular element
%
% Synopsis:
% [k]=felp2dta(ict y1x2,y2,x3,y3)
%
9% Variable Description;
% k- element, stiffuexs matrix (size of 3x3)
% x1, yl x and y coordinate values of the first ode of element
9% x2, y2~ x and y coordinate values of the second node of element
% xt, 72 x and y coordinate value of the third aod of dement
%———
%
% element matrix
%
A=O.5*(x2"pS+x1*y24x3"y]-x2*y 1x1 "5-13" 72),
%
% area of the triangle
(1 1}=( (3-12) *(33-02)4(92-79)¥(y2-y8))/(4FA);
(A 2) = ( (2:92 )* fod 43} 4 (92-93 Ey 3-y LATA:
Ke(L,3) = (x3-x2)* (2x1) 492-79) Ey 1-72) )/ (AFA:
12,2) —( (aed x8} (ad x3) 4672-7 Pv. ))/ UA:
(2,3) = (x1 -x3)* (x21) +{y3-71)* (yd-¥2))/ (AFA)
k(3,1)=k(1,3);
4(,2)=K(2,8),
(8,3) (2-1 )*(2-x]) Hy) 72)" Ly 2))/ 4A);
yO
‘The finite element and analytical solutions are compared below:
store =
dof # fem sol exact
1.090 9,000 (0.0000 9% at x=0.00 and y=0.0
2.unuo 6.0000 0.0000 % at nat 96 ond y=0.9
3.0000 0.0000 0.0000 ‘% ot X=2.50 and y=0.0
4.0000 0.0000 0.0000 Ye ab x=3,75 and y=0
sui von —_g.9000 9 ac x=5.00 and ¥=0.0
6.000 0.0000 u.0000 ‘% at K=0.00 and y=2.5
7.0000 4.6896 2.8785 % at K=1.35 and y=2.5
a.unno =. 56B9 5.3187 96 at x=2.50 and y=d.514
Figure 5.9.2 Mesh With Bilinear Elemente
s.onnn
10.000
ono
12.000
13.000
14.000
15.000
16.000
7.000
18.000
19.090
20.000
21.0uy
22.000
23.000
4.000
25.000
Laplace’s and Poisson's Equations
a.au4e
9.0361
o.oou0
10.621
17.312
21.626
23,124
4.0000
iad
7.568
48.108
49.199
4.0000
38.268
T0711
92.386
99.00
& Example 5.9.2
using bilinear rectangular dlements. The mesh is shown in Fig. 5.$.2 and the
MATLAB programs we lied below.
9.492
T5218
a.noua
7.6257
14.090
12.410
19,927
9.0000
17.324
32.010
41.823
45.289
0.000
36.288
70.711
oa.ze8
100.00
Chapter 6
Few x=ATS and y52.5
at
Kat.
9 ab 20.00 and yo
atx
% ot x=5.00 ond y=1.5
Mat 0 and y=10,
%at
% at x=250 and y=i
% at nat.78 and y=10.
% ab x=.00 ond y=10.
We solve the same problem as given in Beatnple 5.9.1
SS
% BX$.9.2.mSection 5.9 MATLAB Application to 2.D Steady State 118
% to solve the two-dimensional Laplace equation given 28
% wx + ayy =00 element no. and j-> connected andes
yx —
nodes(1,1)=1; nodes(1,2)=2; rades(13
noden(2,1)—2; noden{2,2)—3; nodoa( 2
nodes(3,1}-3; nodes(3,2)—4; nodes(3,3
nodes(4,1)=4; nodes{4,2)=5 nodes(43)=10; nodes(4,4)=9;
sundes(5,2)=7; suder(5,3)=125 woden(5.A)=15
13; nodes( 6,4):
4; nodes(7,4}:
nodes(8,1)=9; nodes(8,2)=10; nodea(8,3}=15; noceni,4)=14;
nodes(9,1)=11; nodes(9,2)—12; nades(9,3)=17; nodes(94}
nodes(10,1}=12; nodes(i0,2)=13; nodes(10,3}=18; nodes( 10,
nodes(11,1)=13; nodes(11,2)=14; nodes(11,3)}=19, nodes( 11,
nnades(12,1)=14; nodeo(12,2)=16; nodes(12.3)=20; nodes(t24)=19,
nodea( 12, nndea(13,2}=17: nates! 2; wodes(14,4)}=21;
nades(14,1)=17; nodes(14,3}
8; nodes(14,3)=23; way
(
(
nadea(15,1)=18; nodeo(16,2)=19; nodeo(15,3)—24; nodes 15,4)23,
noden(161}—19; noden(16,2)—20; noden(16,2)—25; noden(16}4)—24;
%
—$ $$
‘% imput data for boundary conditions
ye
bedof(1 % firot node is constrained
beval(1 % whore deseribed value in
bedof(2} % second rode is constrained
beval(2} % whowe described value is 0
bedof(s 96 third node is constrained
beval 3 % whos: described value is 0
bodof(4 $6 40h sode in coneixsined
Deval(a % whowe described value ie 0
dedof(5) $6 50h code is constrained
bevat(s: 9 whom devcsibed value fs 0
bedot(s) % 6th vode is constrained
beval(6 % whose deverihed valne ie 0
% 11th ode is constrainedSection 5.9 MATLAB Application to 2-D Steady State ur
boval(r)=0; % whose described value is 0
% 16th node is constrained
% whose described vaine is 0
% Dat node is constrained
% whose described value is 0
‘% 23nd node is constrained
% whose described valne is 38.2683
bedof{11}=33; % 28rd node is constrained
beval(11}=70.7107; % whoon devcstbed value ia 70.7107
bodai{t2 % BALA node is constrained
beval(12}=92.3880; % whose described value is 92,3880
% 20th node fs constrained
% whose described valve is 100
fi=reroa(sdof.1); % initialization of system force vector
Ve seroe(edrfindnf): OF initislixation of ayetom menlsie,
ina ¥%G initialization of index vector
% computation of element matrices and vectors and their asverbly
$—=—$
for iel=1: % loop for the total wumber of elements
%
for ici:mnel % loop for aumber of nodes ner element
nd (i)=nodes(ieli}s % extract connected node Sor (iel)-th clement
x(2)=gcoord(nd (i) 1); % extract x value of the node
vi=gocord(ed(),2)s % onteact 7 value of the sede
ead
%
Neng = x(2)-4(1}; % length of Une element in x-axis
yleng = y(4)-7(2); % length of the element in y-axis
index=feeldof(nd,nnel, ndof); ‘% extract system dofs for the element
%
K=felp2ar4(xleng, yleng); % compute element matrix
%
kk=feanmbl (kk k.index}; % awemuble dement. mabrices
%
end
%
4—___-
% apply boundary vouditions
——$———
[kk ff} =feaplye2(kk,ff,balof bevel):
%14g
Laplace’s and Poisson's Equations Chapter 5
Yee
% solve the matrix equation
%
feol IRA;
%
*4——_
% analytical solution
%——_——_
for i=Imnode
x=gcoord{i,1); y=gcoord i,2);
esol (i) =1004 sin h(0.31415627*v)*sin( 031415927 *x) sinh (3.141927);
end
%
%
% print both exact and fem solutions
% Purpors:
% clement matrix for two-dimensional Laplace’s equation
% using fonr-node bilinear reclangalar element
%
% Synopsis:
% (k}=telp2dr4(aleag,yleng)
%
% Variable Description:
% le - elomont stiffness mat
% xleug - clement size in Ub
(size of da)
% yleng - element size iu Uhe y-axis
%—
%
% elemens matrix
%
K(1,1}=(aleng*xleng-+yleng*yleng) /(3*xleng*sleng)
K(1,2}=Gdeng*sleng-2*ylenu*sleng)/(6*xlene*ylens):
K(1,3}—0.5*(1,1);
k(1.4)=(vleng* yleng-2*xleng*xleng) /(6*xieng*ylenz);
(2,1) ke(1,2); k(2,2)—K(1, 1); k(2,9)—KkC1 4); k(2 A) (1,9);
KG1=K(1,3}; ki9,2)=K(2,9}; k(3,
(4,1) (2,4); (4,2) =4(2,4}; C4,Section 5.10 MATLAB Application to Axisymmetry 19
‘The nite element solution ia shown below. ‘The same number of wodes were
used for this case as that in the previous example. Hy comparing the two finite
clement solotions using either linear triangular elements or bilinear rectangular
elements, we see that the rectangmlar elements produced more accurate solntion
in the present exam ple_
dof # femsol exact
1.0000 0.0000 0.0000
2.0nn0 enna n.nooo
3.0000 0.0000 0,0000 % at x=2.50 and y=0.0
4.0000 2.0000 0.0000 % at xed.8 and
5.0000 0.0000, 0.0000 Mat 00 and
ennin 0.0000 0.0000 ab xf. and 7=2.5
70000 2en8e 2.8 TBS % ab me.I aad y=25
8.0000 4.9683 6.8187 % ab x=2.50 and ya25
9.0000 6.4914 6.9493 % at x=3.75 and
10.000 7.0ze3 7.5218 as
11.000 u.UUeu 0.0090 hae
12.000 7.2530 7,6987 Yat
13.000 13.402 14.090 Mat
14.000 17.510 18.410 Rat
15.000 18.953 19.927 % at
16.000 0.0000 0.0000 ae
17.000 16.878 17.324 $i ob RHLI5 ond y=75
iso 71.189 2.010 % ak LEO and y~75
39.090 40.742 41.823 Hat
20,000 44.058, 45.269 Mat
zi.oee 9.0000 a.av00 wae
22.000 38.268 38.268 Meat
23.000 70.711 70.711 hab
24.000 92.388 92.3688 ‘Mat
25.000 100.00 100.00 ‘% at x=8.00 and y=!
5.10 MATLAB Application to Axisymmetric Analysis
This section shows au exauple of gu asisynuuetric sendy stele probies using
MATLAB programs. Linear triangular elements are used.
@ Example 5.10.1 An axisymmetric Laplace equation is solved using
Knoar trisagular clemonte. The governing equation is given ia By. (572) for a
cylinder whose inaide and outside radii are 4 and 6, and whose height ia 1. The
finite element mesh used for the present aualysis is shows in Fig. 5.10.1. The
boundary conditions are u = 100 at the mside of the cylinder and $¢ = 2)120
Laplace’ and Poisson's Equations Chapter §
ae / |
0/0
—— { a a ? a t *
PAL Ody Oty Oy Od Ot
Figure 5.10.1 An Infinite Cylinder Modeled With Symmetric Boundaries
at the outside of the cylinder, Both top and bottom surfaces of tue cylinder
ie. lamlated. "Ten triangnlar elements with 12 woden are ned
and the MATLAB programs are provided below. As seen in the main program,
the constant ux at the outside surface is converted into the nodal ux at the
onteide surface. Each node takes a half of the total flux over the element which
is Qafigql = 240w where r=6, ¢=20 and /=1 as explained in See. 5.7
%*—__—_________-
% EXS.10.1.m
% to solve the axisymmetric Laplace equation given as
Kort Urt nes =0,4or< 606261
% u(4,2) = 100, u,2(6,2) = 20
% uyz{x,0) = 0, wn(r1) =O
% using linear triangular elemenis
Sh(see Fig. 5.10.1 for the finite element mesh)
%
9% Variable descriptions
36 k= clement matrie
element vector
% kk = system matrix
% E = system vector
coordinate valnes of each node
nodal connectivity of each element
a vector containing syatem dof sssaciatrd with each element
a vector containing dofs associated with boundary conditions
ne heomachery cemnditinn values aanorinted with
(he dofs in dedof
input data for control parametersSection 5.10 MATLAB Application to Axisymmetry 121
nel % number of elements
and ‘% mumber of nodes per element
dof: % number of dofs per nede
anode=12: % total sumber of nodes in system
sdol=nnodetndoty % total system dofs
%
%———____..--____.
% input data for nodal coordinate values
% gcoord( iJ) waere 1:> node HO. and f-> x Ory
6
gecord(1,1)=4.0; gevard(1,2}=0.0; geoord(2,1}=4.0; gcoord(2,2}=1.0;
geoord(3,1)=4.4; gcoord(3,2}=0.0; geoord(4,1)=4.4; gcoord(4,2}=1.0;
seoord(5,1}=48; gcoord(§,2}=0.0; geoord(6,1)==£.8; gcoord(6,2}=1.0;
gccord(7,1}=5.2; geoord(7,2}=0.0; gcoord(8,1}=8.2; zcoord(8,2}=1.0;
gcoord(9,1}=5.6; gcoord(9,2}=0.0; gcoord(10,1)=5.6; gcoord(10,2)=1.0;
geoord(11,1)=6.0; gooord(11,2]=0.0; geaord (12, ccoord(12,2}=1.0;
%
—
% input data for nodal connectivity for each element
1% nadeo(ii) where F> element na, aud j connected noves
¢——$ $$
nodea(
nodes{¥,
nodes,
aodes(5,
nodes(6,
noded(®,
nodes(0,
aodes(10,1)=9; nodes(10,2)=11; avdeo( 10,3}
%
$—$———_____—
% input data for boundary conditions
%¥—_
bedof(1)=15 % first node ie constrained
boval( 1}=100; % whose described. value is 100
bedof(2 % second node is constrained
13;
Ddeval(2}=106: % whose described value is 100
ct
Jp
% initialization of matsioes and vectors
%—
etoe(sdof,1); % initialization of system ferce vector
Ru=zeren(doh aot); 36 inisialination of xystean ra
index=teros{nnel*ndof.1); % initialization of index vector
%
pisd*atan(1); % define pi422
Laplace's and Poiason’s Equations Chapter 5
RL} =120*pi;, 9% nodal flux at the oxtsde boundary
£(.2)=120* Dis % nodal flux at the ovtstic boundary
%
%—
% computation of element matrices and vectors and their assombly
rt oe
for iel=1:nel % loop for te lotal mumber of demenis
%
ndf1}=nodestied,t}; 1% Ast connected node for (iain lement
nd(2)=nodes(iel,2); % 2nd connected node for (iel)-th element
nd(3)=nodestiel,3); % 3rd connected node for (iel}-sh element
coord(nd(i),1); 21 =gcoord(nd(3),2); % coudinate of Ist aode
coord(ad(2),1}; 22=gcoord(na(2),3); ‘6 coordinate of 2nd aode
coord (nd(3).1): 23ecoord(nd(3).2): % coordinate of 370 aode
index=fecklof(nd,nnel,ndof}; % exctract system cols for the element
%
ke felpaxt3(r,21,12,22,28,23); "Ye compute eloment matrix,
%
‘ee fenssnbld (Be hehe); % asweuble clement matcices
%
end
%
%—_—___——.
‘% apply boundary conditions
Gece
(kk, ft] =feaplyc2(kk.ff, bodof, beval};
%
%—______-—
% solve the matrix equation
*—______—.
faol=kk\E;
%
_—
% analytical solution
Mer
for
node
r=gooord(i,1}; z=gco0rd i,2);
esol (1) =100-6*20*l0g(4)+6*20*lox{r)s
end
%
a
% ptint both exact and fom solutions
pn
mum=I:L:sdof;
store=[num’ so) e01"]Section 5.10 MATLAB Application to Axisymmetry 128
fonction (kJ=felpaxt3(r1,z1,r2,22,x8,28)
Tan
% Purpose:
% element matrix for axisymmetric Laplace equation
% using three-node linear triangular element
%
% Bynopsis:
% P}felpant9(ct 22,12.22413,53)
%
% Variable Descriptio:
% k - clement stiffness matrix (size of 3x3)
% 11,21 -© and z coordinate values of the firet node of dement
‘% 12, 23 -t and 2 cuurdinate values of the second node cf element
% 18, 2 and 2 coordinate values of the Lhird node of clement
a a—eeor
%
% wlement matriy
%
AxO.5*(c2*28+r1*o2f 13421 22el-11*23 1322}; % area of the triangle
ApxB+19)/35 % x coordinate value of the clement centroid
twopirc=é*atan(L)*r¢;
(18-2) (03-12)-+ (22-23) *(22-23))/{44 A);
8-1)" fel-es}-+(22-23)"(2d-24 ))/ (4°);
rr) (Der! )+ (2223) *{21-22))/(4* A}:
La)
Ce tetera) (s8-01)*(e0-21)/ C42
1-13)" (r2-r1)+(23-21)*(21-22)} /(4*A);
(1.3):
(2.3)5
U(3,3}=( (22-11) * (211) + (61-22)*(21-22)) f(A):
A—twopireths
%
9 ————
‘The results are
store =
doi# femsol exact.
1,000 190.000 100.000 % at 14.0 and 250.0
2.009 [email protected] 100.000 hat r=40 and =1.0
g.on00 | 111.413 111.437 Goad rata and 120.0
4.0000 111.444 111.437 Seat r=44 and o=1.0
5.0000 121.836.121.870 % ob co AG and 2=0.0
5.0000 121,889 «1ZL.8TS Ye ave=4.8 and 2=1.0
7.0000 «131.427 (131.484 oot r=5.3 and 2-0.0
6.9000 432.501 131.a8a % av r=5.2 end 2=1.0
s.0000 140,290 140.377 % avr=s.6 and 250.0
10.000 140.417 140.377 Yoatras6 and aslo
Viago 148.510 148.656 %e ab e=26.0 and 9=0.0124 Laplace’s and Poisson’s Equations Chapter 5
Figure 6.11.1 Mesh With Triangwar Element
12000 4a.749 148.030 1% me r200 and 224.0
5.11 MATLAB Application to Transiont Analysic
Examples ate given for some transient analyses using MATLAB programm.
Forward difference, backward difference and Crank-Nicoloa techniques are usd,
& Example 5.11.1 The transient Laplace equation as described below
is solved using the forward difference technique for time integration. The
differential eqmation iz
du _ Mu Pu
Bt Gxt ~ By?
over a rectangular domain defined by 0 < 2 < § andO< y <2 The whole
domain haa the initial vale of = 0, and euddanly theleft and sight houndizica
Gc. clges with x0 aud a—8) ate maintained at = 100, Ow the wile: lent,
the bop end botiom boundaries (ie. edges with y=0 and y=2) are ineulated (Le.
2 = 0). We want to find the solution as a function of time. A finite dement
mesh of the domain is shown in Fig. 5.11.1 using 16 linear Liangnlar ceents
‘The finite element. analysis program is shown below.
(5.11.1)
a
% EX8.11.1.m
36 bu wdve the Ureasieat owodiuenaiunal Lapletc’s eyuation
Hugs = xx tuyy 0node nv. and }>x or y
%— —
geoord(2,1}
gcootd(3,1}=2.5; geoord (3,2)
geouel(4,1}=3.75; geuved (4,2)=0.0;
acoord(8,1}=5.0; geoord( 5.2)
gcoond(6,1}=0.0; gcovrd(6,2}
gcoord(7,1)=1.25; gooord|7,2}=1.05126
Laplace's and Poisson's Equations Chapter §
75; gcoord(9,2}=1.05
gcoord(10,1)=8.0; acoord(10,2)=1.;
gcoord (11 1}=0.0; geocrd(11,2}
gcoord(12,1}-1.25; geoord(12,2)=2.05
eoord(13,1}—9.8; pooord (13,2}—2.0,
geoord(14,1)—3.75; gooord(14,2)—2.0;
gcoord(15,1}=5.0; gcoord(15,2)=2.0;
%
4
% input data dor nodal connectivity for each element
% nodes(ij) where i-> element nu. and j-> connected nodes
: nodes(.
nodes(2,1)=2; nodes(2,
nodes(3,
nodea(4,2)~5;
nodes(5,
nodes(8,1}=4; nodea(3,
nodes(9,1)=5; nodes(9,
nodes(10,1)=7; odes{10,2)—8; nodes{10,3)=13;
nodes(I1,1)=8; nodes(1,2}-9; nodes( 11,
nodes(12,1)=9; nodes(12,2}=10; nodes(12,3
nodes(13,1)=6; nades(13,2}—12; nodes(13,3)—11;
nodes(14,1)=7; nodes(14,2)==13; nodes(14,3)=12;
nodes(15,1)=R; nodes(1 nodes(15,9
nodes(15,1)=9; nodes(16,2)=15; nodex(16,3
%
Bowe
% input data for boundary conditions
%— —_—_
bedof 1} {i Jat node is constrained
beval(1)=100; % whose described ralne is 100
bedof{2} % Bth node is constrained
beval(2)=100; % whose described value is 100
bedof{3}= 4% 6th node is constiained
bevall3}: % whose described value is 100
bedof4} J 10th node is constrained
eval (6) % whose deseribed value is 100
bodof{5} % AIL nodewin sonstaained
beval(} % whove described valve is 100
hedesl(6) % Ath monde is constrained
beval{)=100; 9% whuve devedbell alae is 100
%
%
Yb initialization of matrices and vectorsSection 5.11 MATLAB Applicetion to Transient Analysis it
feer09(sdoL1}5 % inisiatization of system vector
fn=peros(stof 1): % initialization of effective aystem vector
teol=zeros{sdof,1): % sohition vector
sol=zor0s(2,ntimet I); % vector containing time history solution
Lmecrefodfido)s % initialivetion of nyotcan eantein
mmn=zeros{sdof sdof)}; % initialization of systern matrix
index-zeros(anel*nduf,1); % initialization of index vector
%
%. =.
% computation of element matrices and vectors and their assembly
——__ or
for iel=L:nel % loop for the total number of elements
%
1d(1)=nodes(el,1); % Ist. connected node for fiel)-th element
1d(2)=nodestiel,2); % 2nd connected node for {iel)-th element
24{3}—rodea($al,2); Ged commuted mode fox [ial)-Uh lennon
xL=geoord(nd(1},1}
x2=gcoord(nd(2),1)}; ¥:
geoond(ad(1),2); 9% coord values of Ist node
gcvond (ad(2},2), Weoord values of 2nd node,
sSagcuord(al(3),1), yS=guvid(ad([3},2), 96 cord values uf Srd aude
%
index=feeldof(nd,nnel,adof}; % extract system defs for the clement
%
kefelp2dt (x1 y1,x2.92,%3,93); % compute eletent matrix
ansielpl243(x1 y1e2,92,x3,99); % compute element matrix
%
kk=feasmbl1(kk,kindex}; ‘% assemble element matrices
avnfeasmbll (mm,m,index)s % ascemble element matrices
%
ond
*
%
% loop for time integration
% initial condition
% store time history solution for noite no. 8
% store time history solution for node no. 9
% etart loop for time integration
(n=delU*f+(mmdeltt*kk)"fsol; ‘WG compute effective column vector
%
[mm,fa}=feaplye2(mm.fn,bedofbeval); _% apply boundary condition
%
teol=mum\in; solve he malzix equation128
Laplace’s aud Poisson's Equations Chapter 5
%
sol(L.it+1}=ts0l(8); % store time history eolution for node no, 8
sol(2,it-+T)fenl (9); UZ ktove tite hiatory snlntion for node na, 9
%
end
%
%—
% plot the solution at nodes 8 and 9
Yoon —____—
time=0:deltt:ntime*deltt
plot(time,sol(1,:),™',time,tol(2,:},
xlabel( Time’)
ylabel(’Solution at nodes’)
%
Fe
function ftal=felpt213(x1,51,x2,y2.x3,¥3)
% clement matrix for tronsiant teem of twro-dimencinnl
% Laplace's equation using linear triangular element
%
3% Syavpuis:
% (mjafelpt203 (x1 y,x2,y2,23,y3)
*
% Variable Description:
% m - element stiffness matrix (size of 3x3)
% x1, yl - xand y coordinate values of the first node of element
% x2, y2 - x and y coordinate values of the second node of dement
% x3, y3- x and y coordinate values of the third node of element
ya
%
Y%, clement matrix
%
‘AxO.S*(x24yStalty2- 4x3" yl-x2"yL-xl¥yB-x3%y2);
Foaxea of the tiangle
w
m = (A/12)" (2115
121;
112)
%4—_—_—________.
‘The finite dement solutions are plotted in Fig. 6.11.2 aad Fig. 5.113. Time
history of nodes 8 and 9 in Fig. 5.11.1 is plotted in both figures. While At = 0.1
woo used for Pig. 5.11.2, Af — 0.19 was need for Fig. 6.113, As noticed, the
finite clement solution is unstable whea At = 0.12 is used bucausy the forward
difference technique is conditionally stable.
tSection 5.11 MATLAB Application to Transient Analysis 139
Figuvo 6.11.2 Finite Flement Solution With At—0.12
# Escurmple 511.2 The same example ap Beample £111 i oolved wang
bilinaar rectangslar slemanta, The mosh is the game an thet shown in Fig. 5.11.1
except that 8 rectangular elements are used instead of 16 iieugular elements,
%
% EXS5.11.20
% to solve the transient tio-dimensional Laplace's equation
Hut =urx toy, 0node no. ard j->x ory
$$
gcoord(1,1}=0.0; groord(1,2}=0.0;
gooord!2.1)=1.25: zcoord(2,2)=0.0:
acoord(3,1)=2.5; gcoord(3,2)=0.
gcoord(4,1)=3.75; gcoord(4,2)=0.
necord(6,1)—6.0; geaord(5,2)—0.0;
geoord(6,1)=0.0; gcoord(6,2}=1.
geourd(7,1}=1.25; govord (7,2}=1.05
gevurd(8,1)=2.5; yeuurd(6,2)=1.0;
gcoard(9,1)=3.75; gcoord(9,2)=1.0;
geoord(10,1)=5.0; gcaord( 10,2
geourd(11,1}=0.0; gcoord(11,2}=2.0;Section 5.11 MATLAB Application to Transient Analysis
gcvurd(12,1)=1.28; geoord(12,2}=2.0;
acoord(13,1}=2.5; gcoord(13,2}=:
acoord(14.1)=3.75: geoord(14.2)=2.0;
geourd(15,1}=5.0; gcoord(15,2)=2.0;
%
% -
‘% input date for nodal connectivity for cach clement
% nodes(ij) where i-> slement no. and j-> connected nodes
%———_ -
nodeaf 1,1)=1; nodes(1,2)=2; nodes(1,3)=7; aodes(1,4=6;
nodes{2,1)=2; nodes(2,2)=3; nodes(2,3)=8; aodes(2,4=%
0; nodes(4,4}
nodes(B.1)=7; nodes(6,2)=8; nodes(6.3)=i3; nodes(§.t)=:
nodes(7,1)=8; nedes(?,2)}=9: nodes(7,3)=14; nodes(7 4)
nodes(2,1)—0, noden(2,2)—10; nodea(#,2)—15; nodes(¥,d}=1;
%
%—
% iuput date for boundary conditions
%——_
bedof(1
bedof{2) % Sth node is constrained
beval(2 %e whose described value is 100
bedof(3)=6; % tl node is constrained
beval(3}=100; %h whose described value is 100
hedaf(A! % eth modes constrained
beval(4} % whose described valve ix 100
bedut(S)=11; 4 1th node io constrained
Veval(5}—100; 9% whuse desctibel value is 100
bedol(6) % 1th node is constrained
deval(6} % whose described value is 100
%
%—
fl=zeros(sdof,1); % initialization of sy ster vector
fn=neros(sdof.1): Yoinitialization of effective aystem vector
frol=neros(sdof,1); % solution vector
sol=zerus(2,nlime} 1); % vector vontaining time history solution
Ki-azroa{edofedof); % jnitbaliention of ayelots stale
mnm=zeros(sdof,sdof % inistabization of system matrix
index=seros(nnel*ndof,); % initialization of index vector
%
%
—
% Ist node is constrained
beval(1}=100; % whose described value is 100
% computation of element matrices and vectors and their assembly
131132
Laplace's and Poisson’s Equations Chapter 5
for iel=L-nel % loop for the total nnmber of elements
%
nd(1 )=nodestiel,1): % Ist connected nede for (jel) th element
nd(2)=nodes(iel.2); % 2nd connected ncde for (il)-th element
nd(3)—nodes(iel,a); % 3rd connected nude for ((el)-th element
nd(4}—nodea(iel,3); % 4th connected node for (el)4h clement
xL=gcvord(nd(1),1}; yl—gecord(nd(1),2);-% coord values of Ist node
xd=gcoord(nd(2),1); y2=gcoord(nd(2),2}; _ % courd values of tnd node
xd=gcoord (ad(3),1)3 YS=Kcoord(nd(3),2); _% coord values of Sra node
x4=geuord(ad(4),1); y4=gcoord(ad(4),2), _% coord valuss of Sth node
aleng=x2x5 % element size in x-axis
yleng=y4-y1; % element size in y-axis
%
index=fecldofind.anel.ndat):%
‘k=felp2dr4(aleng,yleng): % Vimne-independent element rairix
m=felpi2r4(xleng,yleng); % taansient. dement matrix
%
‘kk=feasmbL (kk,k,index); ‘% assemble element matrices
yam—feasmbl (mm,m,index); % assemble element matrices
*
end
%
&——_—_—$$____
% loop for time integration
%—
%
for in=1:sdof
feo
end
%
201(2,1) =f501(0)s % store time hintory solution for acde no, @
wol(2,1)=ts0l(3), % store time history solution for nodene. §
%
for t=t:nlime % start loop tor tame tegration
%
fasdeltt*f+(mm-deltt*kk)*fsol; 9% compute effective cola vector
%
{oum,fn]—feaplyc?(mea,fn, bedof,beval}: % apply boundary condition
%
‘sol=mm\fn; % solve the matrix equation
%
eul(1 it-+-1)—feol(9); % elore time history solution for node ne. $
sol(2,it-+1] % store time bistwry solution for node no. $
%
end
%
%*—__—_—
Y% analytical solution at nade &Section 5.11 MATLAB Application to Transient Analysie 133
%
pix4*atan(1);
jeros(1.mtime+1);
0;
for ti=O-deltt:ntimetdeltes
esolfii) esol) 4A)" exxp(-its* pit pitti (lad) *singpitea/ ah
end
end
es01=100-(100"4/pi)*es0l;
%
%. a
% plot fem and exact solutions at node 8
ye
timendidelttentimetdeltty
ploi{ time, ol(1,:),™,time,esal,”};
xlabel(’Pime"}
ylabel(’Solntion at nodes”)
%
%
Ipt2r4(xleng,yleng)
% Purpose:
% element matrix of transieut term for two-dimensional Laplace's
% eauation using four-node bilinear rectangular element
%
% Syropsis:
% [mJ—felptdr4(alonsgyloms)
%
% Variable Desaiption:
1% m - eloment stiffness matix (skze of 6x4)
% sheng - elememt size in the x-axis
% yleny - element size in the y-axis
%&——_____._______.
h
% dement matrix
%
m=(vlengtyleng/36)*[4 2 19;
The finite element solution obtained using rectangular demerts is comparable
to that obtained asing triangular clements. Figure 5.114 compares the ficite134 Laplace’s and Poisson's Equations
Figure 5.11.4 Anatytical and Finite Element Heralts at Node 8
senate
Figure $11.6 ‘Tie History of Nodes 8 and 9
Chapter 6
oloment solution to the svart wolufion at node ® (see Fig 8.i1.1). ‘the fiaite
clement solution approaches the steady state solution dower than the exact
solution. This is duc to the very crude mesh in the a-direction.
i
& Example 5.11.3 The present example solves tie same problem as that
in Example 5.111 acing the backward difference technique for time iutgiation.
Because this technique is unconditionally stable, we use a time stepsire Ai
04
which exceeds the critical time step size for the forward differerce teclniqne.
Figure 5.11.5 shows the tme-history of nodes & and 9.
%—
% EX$.113.mSection 6.11 MATLAB Applicetion to Transient Analycia 135
% to salve the transient two-dimentioxal Laplace's equation
Ut = UK tugy OC XS OC KZ
% boundary conditions:
% w(0,yst) = 100, a(6,y,4) = 100,
% wy(x.0,4) = 0, ny(,2,t) = 0
% inildel condition:
% a(x,y.0) = 0 over the domain
% asing linear triangular elements and backward differeace method
Ylsee Fig, 9.1.1 (OF the finite element mest)
%
% Variable descriptions
% k = dement matrix for time-independent term (1,xx + u,yy)
% m = element matzix for time-dependeat term (x,t)
% {= cement vector
% kk = system matrix of k
% mm = system matrix of m
% = cystom vector
% in = affective system vector
‘% ‘sol = solution vector
76 vol = Gune hivtony culubion of selects wudbes
% geoord = coordinate values of each node
% aodes = nodal connectivity of each elament
% index = a vector containing system dots agcociated with each element
% bedol = a vector containing dofs associaled with boundary conditions
4% boval =a verter containing boundary condition values associated with
% the dofs in bedof
%—
clear
%--—___
% input data for control parameters
*
nel=16; % number of elements
ancl=$; % umber of nodes per clement
adof=t} ‘Ye tumber of dofs per node
anode=15; % total wamber of nodes in system
sdof=nnode*ndof, ‘% total system dofs
% time step size for transicut analysis
% initial time
% termination time
% number of time increment
% input data for nodal coordinate values
% goootd(i,j) whete i->node no. and }>x or y
Soom
geoord(1,1 coord 1,2)=0.0;
coord (2,1) gcoord(2,2)=0.0;
gcoord(3,1}=2.8; gcoord(3,2}=0.05136
Laplace's and Poisson’s Equations Chapter 5
gcoord(4,1)=8.75; gcoord(4,2)=0.0;
gcoord(5,1)=5.0; gevordi5,2}=0.0;
gcoord(6,1 coord (6,2' Bi
geoord(7,1)=1.25; groord(7,2}=1.0;
geoord (8,1 geoord(®, 2
geverd(0,1)—2.75; geoord(0,2)—1.05
gcoord(10,1)=5.0; geoond (10,2)
geoord(12,1)=0.0, goourd(11,2)=!
euerd(15,1}=8.0; geoord (15,2)
%
6—_—_—__—________—
% imput data for nodal connectivity for cach clement
% nodes(ij) where i-> element no. and j-> comnected nodes
i
nodes(1,1}=1; wodes(1,2}=2; nodes( 1,3)
nodes(2,1}=2; nodes(2,2}=3; nodes(2,3}—B;
odea( 3,1) 5 auden( 3,9)
nodes(4,1) ; nodes( 4,3}
nodes(5,1) 5 Nodes(5,4)=85
aodea( 6,1) nodes( 6,3}
aodes(7,1) odes(7,3}8
aoder(8,1) 0; nodes,
; neodes(9,S}e125
nodes(19,1)=7; nodes(10,2)=8; nodes(10,3)=13;
nedes(11,1 nodea( 1,2):
acdes( 12,1 nodes(12,8
nodea(13,1 2; nodes(13,3)
aoden(14,1
nodes(15,1
nodes(16,!
%———$$
‘% inpus data for boundary conditions
$——
bedati(1)
beval(1}
moden(a4,2
; nades(15,
; nodes( 16,
Ist rode is comstrained
% whose described vine is 100
% Sth node is constrained
beval(2}=10 % wheste described value ia 100
hedaf(a)—6; % 61h ande in concteained
% wheoe described velue is 100
% 0th. node is constrained
‘whine described value is 100
% Ath node is constrained
i wehose described value is 100
% 15th noc is constrainedSection 5.11 MATLAB Application ta Transient Analysis 17
eval(6)=100; % whow described value is 108
%
%
% initialization of matrices and vectors
%
Si-mncron(sdof,1)s $% imitiabeation of ayatem vector
fn=zer0s(sdof 1); % initialization of efective wystem vector
fuol=zeroa(sdof,}); % solution veetor
sol=zeros(Zntime+ 1); 9% vector camtaining time hiniory solution
kkk=zer0s(sdof,sdof); % initialization of system matrix
amm=seros(sdof,sdof}; % initialization of system matrix
index=zeroe(nnel*ndof,1); % initialization of index vector
% loop for the total anmber of elements
ud(1)=nodes(icl1); % st connected nude fur [iel}-th element
nd(2)=nodes(el.2); 1% 2nd conuerted node for [iel)-th element
nd(3)=nodes(iel.3); % ard conmected node for [el)-th element
xl=gcoord (nd(1),1); yl=gcoord(nd(1),2); _% coord values of Ist node
scoord(nd(2),1); y2=gcoond (nd(2),2); Yh coord valves of 2nd node
‘% coord values of Std node
index=feeldof(ad,nnel,ndof}; ‘% extract system dofs for the clement
%
Keafel p 2442x191 ¥2.y2.3 92): % enmpute element mateie
m=felpt2A(xt yl x2.y2,x3,¥3); % compute element matrix
%
Seh—fisamsubl (ke sondeca) FR asscuMle desncnt nataices
anm=feasm)li (min,m,index); Fe aseemble emeut matuices
%
end
%
%
% loop fox time integration
% initial condition
sol(1,1)=t0l(8); % sol contains time histay solution of wode 8
sol(2,1)=fs0l(4); % sol contains time-histary solution of node 9
%
kh=mm+dett*kk:
%
for iti mtime138 Laplace's and Poisson's Equations Chapter 5
Us=50 convection cosfficiant = 100
G.02m
Figure 8.11.6 Finite Element Mesh
faadeltt*#¢mmsel % compute effective column vector
[Rote eplyc iff eval; % apply boundary condition
picta\ tn: % solve the matrix eauation
Salc43 at; % sol contains time-history solution of node 8
wol(Qyit-+1}—frol(0)s % sal containe time-history solution of ade 9
% plot the solution at nodes B and 9
&——$_-
time=0:deltt:ntime*deltt;
plot({time.sol(.:)*"time.sol(24).-
xlabel(‘Time’)
ylabel(Sohition xt nodes")
%
%
HExomple G114 A plate ofoise 0.02 m by 0.01 m, whose hat conduction
coefficient is 0,3 W/m0, is initially at a temperature of 300 C. While its left
and right aides are maintained at the same temperature of 900 C, the bation
side is insulated and the tup side is subjected to heat convection with convection
ient of he = 100 W/m? C and the ambient temperature of 50 C. The
material has aiso density =1600 Ky/m? and specific twat c=0.6 1/KgC. The
coefSection §.11 MATLAB Application to Transient Analysis 139
gh oy 8
|
a a aE oa
Wigure 5.11.7 ‘Lime History Plot
MATLAB program usng the backward difference technique is Usted below and
‘the mesh is showa in Fig. 5.11.6. The time-history of the solution of node 8 is
given in Fig. §.11.7.
%—-——_—_
% BXS.11 4m
9% to solve the transient two-dimensional Laplace's equation
Hatat = axetuyy Ue < 0.02,0<¢y <001
% boundary conditions:
% n(0,y,t) = 300, u(0.02,3,¢) == 300,
% uy(x,0,t) = 0, a,y(x0.01,¢) = 20(u-50)
9% initial condition:
% a(x,y\0) = 0 over the domain
% osing bilimear rectangular elements and forward differeno: method
Fé(see Fig. 5.11.6 for the Anite element mesh)
%
% Variable descriptions
% k = clement matrix for time-independent term (uxx + usy)
% m = clement matrix for time-dependent term (ut)
% {= clement vector
9 kkk = system matrix of k
% mm = system matrix of m
1% #F = aystom vector
% fm = effective system vector
% fool — solution vector
Aimehistory solution vector of sulccted nadeo
coordinate valucs of cach node
nodal connectivity of each element
= a vector containing system dots associated with mach clement
8 vector containing dofs associated with boundary conditions
4 vector containing boundary condition values associated with
the def ia bedof140
Laplace’s and Poisson's Equations Chapter 5
% k1 = clement matrix dae te Cauchy-type flux
% {1 = clement vector duc to flux boundary condition
% index = index for nodal dofs with flax
§——
dear
———————
% input date for conizel parameters
% number of elements
‘% mumber of nodes per clement
‘% wamber of defa per ttode
% total mumber of nodes in system
mode"ndal; % total system dots
deltt=0.1; % time step size for iransient aalysi
stime=0.0; % initial time
‘time: % termination time
ntime—fixd (ftime-stime) fault); % socrahoy of fia increment
% covfficient for the transient term
% number of clomert boundaries with dus
Th number of wunkes por side of each clewewt
% iwpot data for nadal coordinate values
% geoord(i,j) where i> node wo. and > xor y
%— ——
Reoord (1,1)=0.05 geoord (1,2
coord(2,1)=0.005; geoord(2,2}=0.
acoord(3,1}=0.010: gcoord(3,2)=0.0;
Reoord(4,1)=0.015; geoord(4,
geoord (8,1)=0.020; geoord(5,
0; geoord(6,2)—0.008;
005; gcootd (7,
010; geoord(8,
gcoort(¥,1)=U.0i5; geoord(¥,2
geoutd(10,1)=0.020; gcoord 10,
gcoord(11,1)=0.0; gcoord(11;
coord (12,1)=0.005; geoord( 12,
gcoord(1 010; geoord(13,2}=0.
gcoord(14,1)=0.015; geoord(14.21=0.01;
gcoord(15,1)=0.020; goootd(15,2)=0.01;
%
a
% input data for nodal connectivity for each element
% nedes(i.j) where i-> element x0. and j-> connected nodes
j wodes(1,2)=2; nodes(1,3)=7; nodea(ly
; nades(2,2)=3; nodes(2,3)=8; nodes(2,
nodes(3,3)=3; nodes(2,2)—4; nodes(3,3)=9; nodea(8,4)=3;Seetion 5.11 MATLAB Application to Transient Analysis
nodes(4,1}=4; nodes(4,
nodex{5,1)=6; nedes(5,
nodes( 6,1) nodes(6, s
nodes(7,1)s8; nodes(7,2)=9; nodes(7,3)=1
nodes(8,1)=0; nodes(8,2)
%
%
% input data for boundary conditions
% input for flux boundary ecuditions
% ufix(ij) where i-> element ao. and j-> two side nodes
Yn
nfix(1,1)=11; nilx(1,2}=12; % nodes on Ist clement side with tux
% nodes om 2nd element. side with fine
‘% nodes on rd element side with flux
% nodes on 4th clem le with flux
% wiviahation of matrices and vectors
%—_—_
fi=zeren(stof,1); % system vector
fa=zeros(sdof,i); % effective aysiom vector
fsol=zeros(sdof,1); % solution vector
eros(Lntime+1); % timetistory of a selected node
cros(sdof.sdof); ‘% of eyetem matrix
mam=zer0s(sdof,sdaf); 4 system matric
indor—zoroe(nnal4ndof,1); % index vector
f=zeros(anclstndaf, 1); % element fox vector
K1=seroa(nnels*ndof,nnels*ndof); % flux matrix
index] scrom(ustelstadufl); % ox index vector
%
9 ——_——_—-
% computation of clement matrices and vectors and their assembly
% let undies constrained,
whose described value is 300
% Sth wove is constrained
% whose described value is 300
% 6th node is constrained
% whove described value is $00
% 10th node is constrained
3% whose described value je 400
‘We Ath node ie constrained
% whose described value is 300
96 15Uh wode is combraime
whose described value is 300
Mt142
Laplace’s and Poisson's Equations Chapter 5
% loop for the total number of elements
des(iel,1); % Ast connected node for (iel)-th element
destiel.2)s % Amd connected node for (iel)-th element
desi 3); % 8rd connected node for (ie!)-th element
des(iel, 4); % 4th connected node for (ie)-th element
xlgeaordind(1),1}; y1=gcoord(nd(1),2); % coord vaines of lat node
xPrgesord(nd(2},1}; y2—geoord(nd(2),2); % coord valor af Ind node
xit=gcoord(nd(3),1); y3=gcoord(nd(#),2); % coord values of 3rd node
xd=ycoord{nd(4),1); y4=gcoord(nd(4),2); % courd values of 4th node
% clement size tn x-axis
yleng=yt-yl} % clement size in y-axis
%
index=fecldof(ndnieladof); —_-% extract system dofe for the clement
%
p2dr4(xleng,yleng); % compute clement matrix
m=a*felpt2r4(xleng, yleng); % compute clement matrix
%
Kr —fesemblt (HL inden
esembL1(mm.an,index);
1% secemble slamant matsiene
% ascemble element maiziees
&—_»-______~..
nda())=nfix(ifk,1); % node with flux BG for [ifx)-th element
anf x(ife,2);, % mode with flux BC for [ifs)th eloment
xi=geoord(ads(1),1); ¥!—gevsrd(nde(1),2); % nodal courdinate
a2=gevord(nds(2),1); y2=geoord(nds(2},2); ‘% nodal coordinate
dlemymsucl((xea1(R22) +271) yey); % element ade lengths
%
indexl=Ieeldof(nds,nnels,ndol); % find related system dofs
%
ki=bMefixl2(deng); % compute element matrix due to ux
fl=b*c*fefil(O,eleng); % compute clement vector due to flux
%
[kk,f]=feasmbl2 (kh, £1,41 index); % assembly
%
ead
m
§——
% loop for time
%—
for in=lisdof