MATLAB Codes for Finite Element Analysis - Springer978-1-4020-9200-8/1.pdf · 123 MATLAB Codes for...
Transcript of MATLAB Codes for Finite Element Analysis - Springer978-1-4020-9200-8/1.pdf · 123 MATLAB Codes for...
MATLAB Codes for Finite Element Analysis
123
MATLAB Codes for Finite
Solids and Structures
A.J.M. Ferreira
Universidade do PortoPortugal
Element Analysis
Preface
This book intend to supply readers with some MATLAB codes for finite elementanalysis of solids and structures.
After a short introduction to MATLAB, the book illustrates the finite elementimplementation of some problems by simple scripts and functions.
The following problems are discussed:
• Discrete systems, such as springs and bars• Beams and frames in bending in 2D and 3D• Plane stress problems• Plates in bending• Free vibration of Timoshenko beams and Mindlin plates, including laminated
composites• Buckling of Timoshenko beams and Mindlin plates
The book does not intends to give a deep insight into the finite element details,just the basic equations so that the user can modify the codes. The book wasprepared for undergraduate science and engineering students, although it may beuseful for graduate students.
The MATLAB codes of this book are included in the disk. Readers are welcomedto use them freely.
The author does not guarantee that the codes are error-free, although a majoreffort was taken to verify all of them. Users should use MATLAB 7.0 or greaterwhen running these codes.
Any suggestions or corrections are welcomed by an email to [email protected].
Porto, Portugal, Antonio Ferreira2008
v
Contents
1 Short introduction to MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.3 Operating with matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.4 Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.5 Matrix functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.6 Conditionals, if and switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.7 Loops: for and while . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.8 Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.9 Scalar functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.10 Vector functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.11 Matrix functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.12 Submatrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101.13 Logical indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.14 M-files, scripts and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.15 Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.15.1 2D plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141.15.2 3D plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.16 Linear algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2 Discrete systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.2 Springs and bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.3 Equilibrium at nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202.4 Some basic steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.5 First problem and first MATLAB code . . . . . . . . . . . . . . . . . . . . . . . . 212.6 New code using MATLAB structures . . . . . . . . . . . . . . . . . . . . . . . . . 28
3 Analysis of bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333.1 A bar element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333.2 Numerical integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
vii
viii Contents
3.3 An example of isoparametric bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373.4 Problem 2, using MATLAB struct . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413.5 Problem 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4 Analysis of 2D trusses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514.2 2D trusses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514.3 Stiffness matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524.4 Stresses at the element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534.5 First 2D truss problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534.6 A second truss problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584.7 An example of 2D truss with spring . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5 Trusses in 3D space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695.1 Basic formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695.2 A 3D truss problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695.3 A second 3D truss example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
6 Bernoulli beams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 796.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 796.2 Bernoulli beam problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 816.3 Bernoulli beam with spring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7 2D frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 897.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 897.2 An example of 2D frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 917.3 Another example of 2D frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
8 Analysis of 3D frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1038.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1038.2 Stiffness matrix and vector of equivalent nodal forces . . . . . . . . . . . 1038.3 First 3D frame example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1048.4 Second 3D frame example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
9 Analysis of grids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1139.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1139.2 A first grid example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1169.3 A second grid example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
10 Analysis of Timoshenko beams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12310.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12310.2 Formulation for static analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12310.3 Free vibrations of Timoshenko beams . . . . . . . . . . . . . . . . . . . . . . . . . 13010.4 Buckling analysis of Timoshenko beams . . . . . . . . . . . . . . . . . . . . . . . 136
Contents ix
11 Plane stress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14311.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14311.2 Displacements, strains and stresses . . . . . . . . . . . . . . . . . . . . . . . . . . . 14311.3 Boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14411.4 Potential energy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14511.5 Finite element discretization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14511.6 Interpolation of displacements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14511.7 Element energy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14611.8 Quadrilateral element Q4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14711.9 Example: plate in traction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14911.10 Example: beam in bending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
12 Analysis of Mindlin plates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16112.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16112.2 The Mindlin plate theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
12.2.1 Strains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16212.2.2 Stresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
12.3 Finite element discretization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16312.4 Example: a square Mindlin plate in bending . . . . . . . . . . . . . . . . . . . 16512.5 Free vibrations of Mindlin plates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18212.6 Buckling analysis of Mindlin plates . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
13 Laminated plates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20313.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20313.2 Displacement field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20313.3 Strains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20313.4 Strain-displacement matrix B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20513.5 Stresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20513.6 Stiffness matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20713.7 Numerical example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20813.8 Free vibrations of laminated plates . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233