Solution To Engineering Problems Using Finite Element Methods [1st ed.]

This book intends to provide the theoretical and practical foundation of the Finite Element Method (FEM). The target aud

655 206 48MB

English Pages 0 [1087]

Report DMCA / Copyright

DOWNLOAD FILE

Polecaj historie

Solution To Engineering Problems Using Finite Element Methods [1st ed.]

Citation preview

TO: CREATOR OF... Heavens and Earth, Knowledge and Wisdom, Math and Science, Man and Woman. OUR FAMILIES. ENGINEERING STUDENTS AND PROFESSIONALS.

PREFACE The field of mechanics consists of three major areas: 1. Theoretical mechanics: field that deals with fundamental laws and principles of mechanics. 2. Applied mechanics: field that transfers this theoretical knowledge to scientific and engineering applications by building mathematical models to study the physical phenomena. 3. Computational mechanics: field that solves specific problems through numerical simulation. This book mainly focuses on Finite Element Methods, a subset of the field of computational mechanics. Over the past decades, the Finite Element Analysis (FEA) has become easier to use and implement, enabling engineering designers to carry out complex and more robust simulations. The steady growth of analysis software coincides with the availability and affordability of high-performance computing architectures, making FEA applications a possible reality for most engineers. Although there are some excellent books for engineering analysis using finite element techniques to solve engineering problems, the intent here to guide the reader through the finite element method through the very basic concepts to the extent of a first-year graduate student. Intended Audience This book intends to provide the theoretical and practical foundation of the Finite Element Method (FEM). The target audience is first-year graduate students who have had little to no exposure to the subject. The practicing engineers will also benefit from the approach of this book as they will learn the theoretical aspects of the finite element methods, basically, on their own. Thus, we can assure that this book will fill up a void in the personal library of many engineers trying to, or planning, use finite element analysis in their next design. The recommended background to successfully read this book is solid mechanics, calculus, continuum mechanics, or theory of elasticity, and basic programming knowledge is required. Motivation When writing this textbook, we have kept the reader in mind at all times. After years of using the earlier versions of the book, engineering graduates (from the University of Puerto Rico at Mayagüez) found the approach in this book instrumental in their respective jobs. In teaching and applying the subject for years, we have concluded that students and engineers too often take a "black-box" approach when using the FEA software. They usually lack fundamental knowledge of what the finite

viii element analysis software is doing. Hence, the main goal of the book is to provide a fundamental engineering treatment associated with FEM at a level that is reasonably accessible to those studying the topic for the first time. The book also attempts to provide intuitive and mathematical insight into finite element analysis by using modern mathematical tools. After the reader has completed this book, he/she will be able to: 1. Explain what the finite element method is. 2. Use the theory of elasticity to provide a computational formulation of a structural problem. 3. Develop and use computer codes to solve springs, axial bars, beams and plate problems. Mathematical Level We kept the mathematics to a basic knowledge in linear algebra, differential equations, and programming. For those who do not have prior knowledge of linear algebra, we have included a self-learning Appendix that will enable the reader to self-study, or review, this topic. The authors assume that the readers have little experience with programming languages and numerical methods. Chapter Organization and Topical Coverage The format of this book is reader-friendly since each chapter begins with instructional objectives and ends with a chapter summary while highlighting the most important aspects of the chapter along with an outline of the ongoing research within the topics presented in the chapter. It includes various examples, specifically worked with a pedagogical approach, using a step-by-step procedure that is easy to apply to a wide range of engineering problems. At the end of each chapter, there are a variety of problems that have been carefully worked-out in an accompanying solution manual to the book, available online to the instructors. Emphasis was placed on applications to keep the reader interested in the subject. 1. The contents of this book are intended for a single-term course. Chapter 1 provides a background of the finite element method, including how continuum mechanics fits within the FEA. We have included several complementary appendices for those who are not familiar with linear elasticity. 2. Chapter 2 is an introduction of the fundamental philosophy used in FEA. It explains the advantage of converting a differential equation into strong and weak formulations and providing its functional, whenever it exists. 3. Chapter 3 focuses entirely on spring analysis and shows the reader how each stage of the finite element analysis works. We begin with simple spring analysis to help the student grasp concepts regarding stiffness matrices, force and displacement vectors, assembly, and the system solution using MATLABr programming. Appendix A provides a review of linear algebra using MATLABr , which is essential for this chapter. The goal is to explain how the preprocessor, processor and postprocessor work and how these are implemented into a computer program.

ix 4. Chapter 4 extends the fundamental concepts in finite element analysis presented in Chapter 3 to solve second-order ordinary differential equations. The chapter uses the energy and work principles combined with a vectorial notation to derive the elemental equations. 5. Chapter 5 develops the finite element formulation for the one-dimensional fourth-order ordinary differential equations. As a special case, we apply these concepts to beam theory. The primary difference between the finite elements we will derive in this chapter and the finite elements of the previous chapter is the order of the governing differential equation. 6. Chapter 6 discusses how to analyze axial bar and beam structures when they are rotated about the z-axis and are part of a whole system. The procedure is identical to that covered in previous chapters. The major difference is that we need to use a transformation matrix to take into account the rotation. 7. Chapter 7 discusses how to solve second-order partial differential equations defined over a two-dimensional domain. 8. Chapter 8 is basically an extension of the one- and two-dimensional elements. Axisymmetric elements are used to model structural components that are rotationally symmetric about an axis. 9. Chapter 9 is covers time dependent engineering applications using FEM. In short, this unique book will help the reader, whether a student or a practicing engineer, to independently learn the topics through carefully worked-out examples and apply them to real engineering problems. Any comments and suggestions are most welcome and very much appreciated. You can send your comments to [email protected] Vijay K. Goyal April 2021

ACKNOWLEDGEMENTS Writing a book is not an easy task and takes support and help from multiple people. The hard work is as rewarding as the fun of working with people who believe in your vision. I want to thank the team that made this project a success. Next, I want to thank the God who created everything: Yeshua. “Any knowledge of science, technology, engineering, and math is worthy if it leads to the path of its Founder.” (Vijay K. Goyal) Could not be said any better than by the British physicist, chemist, and mathematician William H. Bragg (1862–1942, 1915 Awarded Nobel Prize winner): “From religion comes a man’s purpose; from science, his power to achieve it. Sometimes people ask if religion and science are not opposed to one another. They are: in the sense that the thumb and fingers of my hands are opposed to one another. It is an opposition by means of which anything can be grasped.” We cannot leave behind our families, who have been very supportive of sharing their time and providing their inputs throughout this project. They are our number one fans and motivators! We could not have completed this task without their prayers, love, understanding, encouragement, and support. Thanks to all who made this final project a reality. Some graduate students collaborated on the early stages of this work. There were a vast number of students who commented, suggested, and helped improve the manuscript. Thanks to those students who assisted in the early version of examples and computer code developments. We cannot leave behind the industry’s invaluable inputs, especially those who graduated and went to work for the aerospace industry and were kind to give us feedback on this work. We cannot leave behind Dr. Carlos A. Felippa, Professor of Aerospace Engineering Sciences at the University of Colorado Boulder, who gave us permission to use text and figure extracts from his online class lecture notes, available through public domain. Lastly, and not least, thanks to all our professional colleagues through whom we have learned what no textbook or journal paper could ever teach. Sometimes experiential knowledge surpasses the theoretical one, although the latter can be equally important. Special thanks to our former doctoral advisors Dr. Rakesh Kapania and Dr. Eric Johnson, from Virginia Tech, for shared knowledge throughout the years. Thank you! Vijay K. Goyal April 2021

xii 1.2.4 1.2.5 1.2.6 1.2.7

Verification and Validation Model Discretization . . . . Model Mesh . . . . . . . . . Basic FEM Steps . . . . . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

14 16 19 22

1.3

Boundary Value Problems

1.3.1 1.3.2 1.3.3 1.3.4

Time Independent and Dependent Problems Linear and Nonlinear Problems . . . . . . . . . . . Applications to Structural Analysis . . . . . . . . . Applications to Heat Transfer . . . . . . . . . . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

1.4

References

2

Approximations to Differential Equations . . . . . . . . . . . 35

22 23 24 24 28

31

2.1

Differential Equations

2.1.1 2.1.2

Exact Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Approximate Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

36

2.2

Methods of Weighted Residual

2.2.1 2.2.2 2.2.3 2.2.4 2.2.5

Definition . . . . . . . . . . . . Trial Functions . . . . . . . . . Common Methods . . . . . Algebraic Representation Error Calculation . . . . . . .

2.3

Galerkin and Ritz Approximations

51

2.4

Strong Form Galerkin

53

2.4.1 2.4.2

Polynomial Trial Functions for Strong Form Galerkin . . . . . . . . . . . . . 54 Strong Form Galerkin Approximation . . . . . . . . . . . . . . . . . . . . . . . . 57

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

40 . . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

2.5

Weak Form Galerkin

2.5.1 2.5.2 2.5.3 2.5.4 2.5.5

Weak Formulation . . . . . . . . . . . . . . . . . . . . . . . Test function . . . . . . . . . . . . . . . . . . . . . . . . . . . Bilinear and Linear Functionals . . . . . . . . . . . . . . Polynomial Trial Functions for Weak Form Galerkin Weak Form Galerkin Approximation . . . . . . . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

41 41 43 45 46

66 . . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

67 68 68 80 80

2.6

Ritz Method

2.6.1 2.6.2

Approximations for Nonlinear Problems . . . . . . . . . . . . . . . . . . . . . . 93 Rayleigh-Ritz Approximation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

88

2.7

Special Cases: Only Weak Formulation Exists

105

2.8

Coupled Boundary Value Problems

108

2.8.1 2.8.2

Strong Form Galerkin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Weak Form Galerkin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

xiii 2.9

Piecewise Continuous Trial Functions

2.9.1 2.9.2 2.9.3 2.9.4

Choice of Linear Piecewise Trial Functions . . . . Linear System of Equations . . . . . . . . . . . . . . . Galerkin Formulation via Piecewise Linear Trial Ritz Method via Piecewise Linear Trial Functions

118

2.10

Approximations to Partial Differential Equations

2.10.1 2.10.2 2.10.3

Second-Order Linear PDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 Strong Form Galerkin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 Weak Form Galerkin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

2.11

Summary

146

2.12

References

147

2.13

Suggested Problems

148

3

Introduction to Matrix Structural Analysis . . . . . . . . . . 163

3.1

Structural Analysis

3.1.1 3.1.2 3.1.3 3.1.4

Methods of Structural Analysis Matrix Formulation . . . . . . . . Sign Convention . . . . . . . . . . Idealization of Physical System

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

118 121 124 131

135

164 . . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

3.2

Two-Node Linear elastic Spring Model

3.2.1 3.2.2 3.2.3 3.2.4

Derivation via Static Equilibrium . . . . . . . . . . . . . . . . . . . Derivation via Unit Displacement Method . . . . . . . . . . . . Derivation via Principle of Minimum Total Potential Energy Derivation via Principle of Virtual Work . . . . . . . . . . . . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

3.3

Two Linear Elastic Spring Model via UDM

181

3.4

Global Stiffness Matrix Using Connectivity Vectors

184

3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6

Basic Definitions . . . . . . . . . . . . . . . . . One-Element Equations . . . . . . . . . . . . Multi-Element Equations . . . . . . . . . . . Use of Connectivity Vector . . . . . . . . . Nature of the Global Stiffness Matrix . . . Application of the Boundary Conditions

3.5

FEA Computer Program for Linear Spring Analysis

3.5.1 3.5.2 3.5.3

Preprocessor.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 Processor.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 Postprocessor.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

3.6

References

211

3.7

Suggested Problems

212

. . . . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

164 166 167 167

173

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

173 173 175 178

185 186 186 188 199 199

209

xiv

II Part Two: One-Dimensional Analysis 4

Second-Order Ordinary Differential Equations . . . . . 219

4.1

Physical Systems

220

4.2

One-Dimensional Elastic Axial Bar

223

4.2.1 4.2.2 4.2.3 4.2.4

Displacement field (3 equations): Physical System Strain Field: Compatiblity Equations (6 equations) Stress Field: Constitutive Relationship (6 equations) Strain Energy . . . . . . . . . . . . . . . . . . . . . . . . . .

4.3

Discretization of the Elasticity Field

4.3.1 4.3.2 4.3.3

Displacement function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 Discretized Stress Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 Discretized Strain Energy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230

4.4

Derivation of Elemental Matrices

4.4.1 4.4.2 4.4.3

Principle of Minimum Total Potential Energy . . . . . . . . . . . . . . . . . . . 231 Principle of Virtual Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 Elastic Axial Bar Element Formulation . . . . . . . . . . . . . . . . . . . . . . . 238

4.5

One-Dimensional Axial Bar: Preprocessing

240

4.6

One-Dimensional Axial Bar: Processing

243

4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6

Elemental Stiffness Matrix . . . . . . . . Global Stiffness Matrix . . . . . . . . . . Elemental Load Vector . . . . . . . . . Global Load Vector . . . . . . . . . . . Linear System of Equations . . . . . . . Application of Boundary Conditions

. . . .

. . . .

. . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . .

. . . .

. . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

Three Alternative Techniques for FEM

. . . .

. . . .

. . . . . .

4.9

. . . .

. . . .

. . . . . .

General Second-Order Ordinary Differential Equations Weak Form Galerkin . . . . . . . . . . . . . . . . . . . . . . . . Finite Element Formulation . . . . . . . . . . . . . . . . . . . . Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . .

. . . .

. . . . . .

4.8.1 4.8.2 4.8.3 4.8.4 4.8.5

. . . .

. . . .

. . . . . .

A General One-Dimensional Problem

. . . .

. . . .

. . . . . .

4.8

. . . .

. . . .

. . . . . .

One-Dimensional Heat Conduction Analysis . . . .

. . . .

. . . . . .

Strong Formulation Functional . . . . . . Discretization . . . . Elemental Matrices

. . . .

. . . .

224 224 225 226

231

4.7.1 4.7.2 4.7.3 4.7.4

. . . .

. . . .

227

4.7

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

243 244 246 246 247 248

268 268 268 269 269

280 . . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

280 280 281 283 284

305

xv 4.10

Isoparametric Formulation

327

4.10.1

Global, Local, and Natural Coordinates . . . . . . . . . . . . . . . . . . . . . 328

4.10.2

Natural Coordinate System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328

4.10.3

Isoparametric Representation of the One-Dimensional Linear Element 329

4.11

Accuracy of FEM Results

4.11.1

Two Common Methods in FEM . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346

4.11.2

One-Dimensional Quadratic Element . . . . . . . . . . . . . . . . . . . . . . . 347

4.12

References

374

4.13

Suggested Problems

375

5

Fourth-Order Ordinary Differential Equations . . . . . . . 385

5.1

Fourth-Order Ordinary Differential Equations

386

5.2

One-Dimensional Elastic Beam

387

5.2.1

Sign Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387

5.2.2

Euler-Bernoulli Beam Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388

5.2.3

Elastic Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389

5.3

Discretization of the Elasticity Field

5.3.1

Displacement function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393

5.3.2

Discretization of the Strain-Displacement Relationship . . . . . . . . . . . 396

5.3.3

Discretization of the Stress-Strain Relationship . . . . . . . . . . . . . . . . . . 397

5.4

Isoparametric Formulation

398

5.5

FE Equations Using The Principle of Virtual Work

402

5.5.1

Principle of Virtual Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402

5.5.2

External Loads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405

5.6

One-Dimensional Elastic Beam: Preprocessing

408

5.7

One-Dimensional Elastic Beam: Processing

412

5.7.1

Elemental Stiffness Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412

5.7.2

Global Stiffness Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412

5.7.3

Elemental Load Vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414

5.7.4

Global Load Vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415

5.7.5

Linear System of Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416

5.7.6

Application of Boundary Conditions . . . . . . . . . . . . . . . . . . . . . . . . 416

5.8

General Fourth-Order Ordinary Differential Equations

5.8.1

Finite Element Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429

5.9

References

346

393

429 464

xvi

6

Plane Truss and Plane Frame Elements . . . . . . . . . . . . 467

6.1

Elastic Plane Truss Element

6.1.1 6.1.2 6.1.3 6.1.4 6.1.5 6.1.6

Displacements . . . . . . . . . . . . . . . . Internal Loads . . . . . . . . . . . . . . . . . Elemental Linear System of Equations Strains . . . . . . . . . . . . . . . . . . . . . . Stresses . . . . . . . . . . . . . . . . . . . . . Elastic Truss Bar: Preprocessing . . . . .

468

6.2

Elastic Frame Element

6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.2.7 6.2.8

Elastic Field . . . . . . . . . . . . . . . . . . . Internal Loads . . . . . . . . . . . . . . . . . Elemental Linear System of Equations Elemental Stiffness Matrix . . . . . . . . . Elemental load vector . . . . . . . . . . . Strains . . . . . . . . . . . . . . . . . . . . . . Stresses . . . . . . . . . . . . . . . . . . . . . Plane Frame Element: Preprocessing

6.3

References

542

6.4

Suggested Problems

543

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

468 469 469 471 471 471

487 . . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

487 492 492 501 502 503 504 504

III Part Three: Two-Dimensional Analysis 7

Two-Dimensional Finite Elements . . . . . . . . . . . . . . . . . 553

7.1

Typical Two-Dimensional Problem

7.1.1 7.1.2 7.1.3

Typical Two-Dimensional Problems . . . . . . . . . . . . . . . . . . . . . . . . . 554 Elastic Field for Plane Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . 555 Discretization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562

7.2

Three-Node Linear Triangular Element for a Plane Structure

7.2.1 7.2.2 7.2.3 7.2.4 7.2.5 7.2.6 7.2.7 7.2.8 7.2.9

Displacement function . . . . . . . . . . . . . . . . . . Isoparametric Formulation . . . . . . . . . . . . . . . . Preprocessor . . . . . . . . . . . . . . . . . . . . . . . . . Discretization of the Elastic Field . . . . . . . . . . . . Linear System of Equations . . . . . . . . . . . . . . . . Elemental Stiffness Matrix . . . . . . . . . . . . . . . . . Loads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Assembly of the Elemental Matrices and Vectors Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

554

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

566 . . . . . . . . .

. . . . . . . . .

. . . . . . . . .

566 568 571 573 578 580 581 586 589

xvii 7.3

Bilinear Quadrilateral Element for a Plane Structure

633

7.3.1

Displacement function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633

7.3.2

Isoparametric Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635

7.3.3

Preprocessor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637

7.3.4

Discretization of the Elastic Field . . . . . . . . . . . . . . . . . . . . . . . . . . . 640

7.3.5

Linear System of Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645

7.3.6

Elemental Stiffness Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647

7.3.7

Loads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 648

7.3.8

Assembly of the Elemental Matrices and Vectors . . . . . . . . . . . . . . . 655

7.3.9

Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659

7.4

Practical Considerations

7.4.1

Non-physical Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695

7.4.2

Model Checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698

7.4.3

Seeking Computational Efficiency . . . . . . . . . . . . . . . . . . . . . . . . . 700

7.5

References

702

7.6

Suggested Problems

703

8

Axisymmetric Problems . . . . . . . . . . . . . . . . . . . . . . . . . 705

8.1

Structures of Revolution

706

8.2

Linear Elastic Field in Cylindrical Coordinates

709

8.2.1

General Three-Dimensional Solid . . . . . . . . . . . . . . . . . . . . . . . . . . 709

8.2.2

Two-Dimensional Axisymmetric . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712

8.2.3

One-Dimensional Axisymmetric . . . . . . . . . . . . . . . . . . . . . . . . . . . 716

8.2.4

Weak Form of the Equilibrium Equations . . . . . . . . . . . . . . . . . . . . . 718

8.3

Axisymmetric One-Dimensional Element

8.3.1

Isoparametric Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720

8.3.2

Elastic Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721

8.3.3

Linear System of Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723

8.4

Two-Dimensional Axisymmetric Triangular Element

8.4.1

Isoparametric Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732

8.4.2

Elastic Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732

8.4.3

Linear System of Equations

8.5

Axisymmetric Quadrilateral Element

8.5.1

Isoparametric Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755

8.5.2

Elastic Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 756

8.5.3

Linear System of Equations

8.6

References

695

720

731

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 737

755

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 759

775

xviii

IV Part Four: Advanced Topics 9

Initial and Boundary Value Problems . . . . . . . . . . . . . . 779

9.1

Overview

9.1.1

Types of Initial-Boundary Value Problems . . . . . . . . . . . . . . . . . . . . . 780

780

9.1.2

An Analytical Solution: Separation of Variables . . . . . . . . . . . . . . . . 781

9.1.3

Example of Heat Transfer Problem . . . . . . . . . . . . . . . . . . . . . . . . . 781

9.1.4

Numerical Finite Element Methods for Time-Dependent Problems . . . 782

9.2

Finite Difference Schemes for 1D Systems

9.2.1

Forward Finite Difference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 784

9.2.2

Backward Finite Difference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 786

9.2.3

Central Finite Difference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 787

784

9.3

Numerical Time Integration Schemes for Multi-DOF Systems

9.3.1

Newmark Method Time Integration Scheme . . . . . . . . . . . . . . . . . . 790

789

9.3.2

Newmark Method: No Damping Case . . . . . . . . . . . . . . . . . . . . . . 790

9.3.3

Newmark Method: Damping Case . . . . . . . . . . . . . . . . . . . . . . . . . 793

9.3.4

Implicit Versus Explicit Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 794

9.4

Finite Elements: Direct Time Integration

9.4.1

Elemental Discretization of the Spatial Domain . . . . . . . . . . . . . . . . 796

9.4.2

Three-Element Discretization of the Spatial Domain . . . . . . . . . . . . . 797

9.4.3

Heat Transfer Problem: 1D Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . 799

9.4.4

Solid Mechanics Problem: Elastic Bar . . . . . . . . . . . . . . . . . . . . . . . 802

9.4.5

Application to a Solid Mechanics Problem: Elastic Beam . . . . . . . . . 809

796

9.5

Mass Matrix

9.5.1

Consistent Mass Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 813

813

9.5.2

Lump Mass Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 814

9.6

Finite Elements: Modal Extraction Procedure

9.6.1

Analytical Mode Shapes and Frequencies . . . . . . . . . . . . . . . . . . . 818

9.6.2

Approximations for Mode Shapes and Frequencies . . . . . . . . . . . . . 820

9.7

Modal Dynamics Procedure

9.7.1

Mode Truncation Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 825

9.7.2

Damping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 827

9.7.3

Initial Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 828

9.7.4

Application of the Modal Dynamic Procedure . . . . . . . . . . . . . . . . . 830

9.8

References

817

825

832

xix

10

Timoshenko Beam Theory . . . . . . . . . . . . . . . . . . . . . . . . 833

10.1

Background for Timoshenko Beam Theory

10.1.1 10.1.2 10.1.3

Displacement Assumptions of the Theory . . . . . . . . . . . . . . . . . . . . 834 Strain-Displacement Relationship . . . . . . . . . . . . . . . . . . . . . . . . . . 835 Equilibrium Equations for the Timoshenko Beam . . . . . . . . . . . . . . . . 835

833

10.2

Element Formulation via the Ritz Method

835

10.3

Element Formulation via Weak Form Galerkin

839

10.4

Isoparametric Formulation for a Linear Element

841

10.5

Limitations of the Linear Timoshenko Element

843

11

Three-Dimensional Finite Element Analysis . . . . . . . . 847

11.1

Introduction

848

11.2

Strain-Displacement Relationship

850

11.3

Equilibrium Equations of Elasticity

851

11.4

Stress-Strain Constitutive Relationship

852

11.5

Boundary Value Problem in 3D

853

11.6

Total Potential Energy 3D Solids

853

11.7

Element Formulation via the Ritz Method

854

11.8

Isoparametric Element Formulation

856

11.9

3D Element Types

858

A Appendix A

Relevant Math and MATLAB Concepts . . . . . . . . . . . . 863

A.1

What is MATLAB?

A.1.1 A.1.2 A.1.3 A.1.4 A.1.5 A.1.6 A.1.7

Getting Familiar with MATLAB Basic commands and syntax MATLAB Help Command . . . M-Files . . . . . . . . . . . . . . . . Programming in MATLAB . . . Diary on and diary off . . . . . Final Remarks on MATLAB . . .

864 . . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

864 865 866 867 868 872 873

A.2

Linear Algebra

A.2.1 A.2.2

Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 873 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 882

873

xx A.2.3 A.2.4 A.2.5

Matrix and Vector Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 887 Inverse of a matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 911 Norm of a Vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 923

A.3

Solution to Linear System of Equations

926

A.4

Polynomial Approximation

931

A.4.1 A.4.2 A.4.3 A.4.4

Lagrange Interpolation Functions Newton Interpolating Polynomial Hermite Interpolation Polynomial Pascal’s Triangle Polynomials . . .

A.5

Roots of polynomials

A.5.1 A.5.2 A.5.3

Linear Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 934 Quadratic Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 934 Cubic Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 935

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

931 932 933 933

934

A.6

The Eigenvalue Problem

A.6.1 A.6.2 A.6.3

Derivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 937 Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 938 Eigenvalues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 938

937

A.7

Numerical Integration

A.7.1 A.7.2 A.7.3 A.7.4

One-Dimensional Gauss Rules . . . . . . . . . 2D Gauss Rules for a Quadrilateral Domain 2D Gauss Rules for a Triangular Domain . . . Gaussian Quadrature Code . . . . . . . . . . .

A.8

References

975

A.9

Suggested Problems

976

B

Review of Calculus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 985

B.1

Functions

B.1.1 B.1.2 B.1.3

Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 986 Functions of More Than One Variables . . . . . . . . . . . . . . . . . . . . . . 986 Vector notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 987

B.2

First-Order Partial Derivatives

987

B.3

Second-Order Partial Derivatives

989

B.4

Chain Rule

990

B.5

Integration by parts

992

B.6

References

995

C

Elemental Matrices via Summation Approach . . . . . 997

944 . . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

945 959 964 971

986

xxi

D

Relevant Information for Structural Analysis . . . . . . . 1001

D.1

Green-Lagrange strains

1002

D.2

Stresses at a Point in the Structure

1009

D.2.1 D.2.2

Cauchy’s Stress Tensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1009 Stress Measures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1010

D.3

Constitutive Equations for Linear Elastic Materials

D.3.1 D.3.2

Hooke’s Law . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1011 Consequences of Planes Stress Assumption in Bars and Beams . . . . 1013

1011

D.4

Internal Strain Energy

E

Damping Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1017

F

2D Finite Element Method Implementation in MATLAB

1014

1019 F.1

Introduction

1020

F.2

Formulation of Governing Equations

1020

F.2.1 F.2.2

Isoparametric Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1022 Gauss Quadrature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1023

F.3

MATLAB Implementation

F.3.1 F.3.2 F.3.3 F.3.4

User Input Files . . . . . Control Parameters . . Output Files . . . . . . . Summary of all Results

F.4

Problem 1-A: Linear Quadrilateral Elements

F.4.1 F.4.2 F.4.3

Displacement Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1026 Strain Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1027 Stress Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1029

F.5

Problem 1-B: Linear Triangular Elements

F.5.1 F.5.2 F.5.3

Displacement Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1032 Strain Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1033 Stress Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1034

. . . .

. . . .

. . . .

1024 . . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

1024 1025 1025 1025

1026

1031

F.6

Problem 2: Linear Quadrilateral Elements

F.6.1

Displacement Profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1038

1036

F.7

MATLAB Code

F.7.1 F.7.2 F.7.3

MAIN SCRIPT FEA.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1040 FUNCTION inputRead.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1053 FUNCTION outputWrite.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1055

1040

F.8

References

1057

xxiv

LIST OF FIGURES 1.11 Typical finite element geometries in one through three dimensions. (Felippa, 2007) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 1.12 Example of typical idealization of primitive structural elements. (Felippa, 2007) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 1.13 Example of typical idealization of continuum elements. (Felippa, 2007) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 1.14 Mesh dependency on type of finite elements. . . . . . . . . . . . . 19 1.15 Approximating static stress concentration factor for an open whole plate under axial tensile load using Abaqus. . . . . . . . . . . . . . . . . . . 20 1.16 Idealizing the physical system to assist with FEA. . . . . . . . . . . . 21 1.17 Example mesh refinement of an idealized composite joint and its solution. Courtesy of Jim Lua, Global Engineering, NJ. (Pham et al., 2021) 21 1.18 Modeling of Bird-Strike Events. (Goyal et al., 2013) . . . . . . . . . . 23 1.19 Finite element analysis for a centered hole plate experiencing a pulling load. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 2.1 Exact solution (solid in black) and Weighted-Residual Method (dashed in red). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 2.2 Summary of Galerkin and Ritz Methods. . . . . . . . . . . . . . . . . . . 107 2.3 Piecewise linear trial functions for a domain divided into 5 elements. 119 3.1 Positive sign convention. . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Idealization of the physical system and its discretization. 2007). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3 Identifying the elements and nodes. . . . . . . . . . . . . . . . . 3.4 Tapered tabular column. . . . . . . . . . . . . . . . . . . . . . . . . 3.5 System’s domain and subdomain. . . . . . . . . . . . . . . . . . . 3.6 Representation of the nodes and elements. . . . . . . . . . . . 3.7 Representation of the nodes and elements. . . . . . . . . . . . 3.8 Connectivity number assignment for a two-spring solution.

. . . . 167 (Felippa, . . . . 168 . . . . 168 . . . . 169 . . . . 184 . . . . 185 . . . . 187 . . . . 189

4.1 Element Equilibrium of a bar subject to an axially distributed load. 223 4.2 The kth one-dimensional finite element in local coordinates. . . . 227 4.3 One-dimensional Elastic Bar Element . . . . . . . . . . . . . . . . . . . . 228 4.4 An axial bar with arbitrary cross-sectional shape. . . . . . . . . . . . 240 4.5 Assigning properties to each finite element for the axial bar. . . . 242 4.6 Number assignment for a two-element solution. . . . . . . . . . . . . 242 4.7 Two element solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 4.8 Three alternative techniques for the finite element method. . . . 305 4.9 One-dimensional representation of global, local, and natural coordinates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 4.10 Quadratic one-dimensional element in global and natural coordinates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348

xxv

LIST OF FIGURES 4.11 4.12 4.13

Figure for problem 4-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375 Figure for problem 4-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 Figure for problem 4-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381

5.1 Equilibrium element supporting a general force system under the stress convention in the x–y plane. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388 5.2 Decomposition of the axial displacement field. . . . . . . . . . . . . 389 5.3 The kth one-dimensional beam finite element in local coordinates. 393 5.4 An elastic beam with arbitrary cross-sectional shape. . . . . . . . . 408 5.5 Assigning properties to each finite element for the beam. . . . . 410 5.6 Two element solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412 6.1 6.2 6.3 6.4

Elastic truss bar in local and global system. . Planar truss configuration. . . . . . . . . . . . . . Elastic frame in local and global system. . . Plane Frame configuration. . . . . . . . . . . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

468 472 487 504

7.1 Figure shows the various discretization models depending on the type of elements being used. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563 7.2 Element and node numbering of the discretized model. . . . . . 564 7.3 Typical three-node linear triangular element. . . . . . . . . . . . . . . 565 7.4 Typical bilinear quadrilateral element. . . . . . . . . . . . . . . . . . . . 565 7.5 Typical three-node triangular element. . . . . . . . . . . . . . . . . . . 566 7.6 Isoparametric representation of the three-node linear triangular element. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569 7.7 Two element assembly using a three-node linear triangular element. 571 7.8 Number assignment for a two-element linear triangular element solution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572 7.9 Number assignment for a two-element linear triangular element solution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586 7.10 Typical four-node rectangular element. . . . . . . . . . . . . . . . . . 633 7.11 Isoparametric representation of the four-node bilinear quadrilateral element. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636 7.12 Two element assembly using a four-node bilinear quadrilateral element. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637 7.13 Number assignment for a two-element bilinear quadrilateral element solution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639 7.14 Number assignment for a two-element bilinear quadrilateral element solution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655 7.15 Linear Triangular Elements. . . . . . . . . . . . . . . . . . . . . . . . . . . 695 7.16 Linear Quadrilateral Elements. . . . . . . . . . . . . . . . . . . . . . . . . 696 7.17 Solution improves significantly with other elements compared to CST: at least 3 elements needed to improve convergence. . . . . . . . . . . . 697

xxvi

LIST OF FIGURES 7.18

Comparisons of Element Performance. . . . . . . . . . . . . . . . . . 697

7.19

Element Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698

7.20 An adequate mesh (left), inadequate mesh due to element distortion (center), and inadequate mesh due to bad aspect ratios (right). . . . 698 7.21 Circumscribing a circle in the element and inscribing the element in a circle can provide clues as to the element quality. . . . . . . . . . . . . 699 7.22 Ensure that all intended nodes to be connected, are connected. 699 7.23 Left: Incompatible mesh led to a crack (no proper load transfer). Right: Mesh on either side is tied using constraints; results in proper load transfer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700 7.24 Using incompatible meshes can result in computational efficient models, use coarse mesh in areas of no concern, and fine mesh in areas where mesh refinement is needed. (Goyal et al., 2006) . . . . . . . . . . 701 8.1 A structure of revolution is generated by rotating a generating cross section about an axis of revolution. (From Dr. Carlos A. Fellipa’s web-book, used with permission.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706 8.2 Cylindrical coordinate system (r, z, θ ) for axisymmetric structural analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707 8.3 FEM discretization of a solid of revolution with one-dimensional axisymmetric element. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720 8.4 FEM discretization of a solid of revolution with axisymmetric triangular “ring” element. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731 8.5

Axisymmetric triangular “ring” element. . . . . . . . . . . . . . . . . . . 732

8.6

Axisymmetric quadrilateral “ring” element. . . . . . . . . . . . . . . . 755

9.1

Forward finite difference scheme. . . . . . . . . . . . . . . . . . . . . . . 785

9.2

Backward finite difference scheme. . . . . . . . . . . . . . . . . . . . . . 786

9.3

Central finite difference scheme. . . . . . . . . . . . . . . . . . . . . . . 787

9.4

Linear finite element. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 796

9.5 Example of typical idealization of continuum using three elements. 798 9.6

Mode shapes of a simply-supported plate. . . . . . . . . . . . . . . . 817

9.7 First two mode shapes for a cantilevered beam using the finite element method. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 823 9.8 Beam modes from a 20-element cantilevered beam. From the 40 modeshapes, only the first seven are shown. . . . . . . . . . . . . . . . . . 824 9.9 The deflections as a function of time in a linear system is equal to a linear combination of mode shapes. . . . . . . . . . . . . . . . . . . . . . . . 825 9.10 Spacecraft FEM has over thousands of degrees of freedom, the fundamental mode shapes and corresponding frequencies can be determined (> A=[2 -2 1; 3 1 -1; 1 -3 2]

 ⇒



1 −3 0  0 1 0 0 0 1  1 0 0  0 1 0 0 0 1

 2 0  −1  2 0  −1

Chapter A. Relevant Math and MATLAB Concepts

930

A = 2 3 1

-2 1 -3

1 -1 2

>> b=[3; 7; 0] b = 3 7 0 >> x=inv(A)*b x = 2.0000 0.0000 -1.0000 >> x=mldivide(A,b) x = 2.0000 0.0000 -1.0000 >> x=A\b x = 2.0000 0.0000 -1.0000 END EXAMPLE 

A.4 Polynomial Approximation

A.4

931

Polynomial Approximation When the actual polynomial may not be available, thee data point sets are. For such cases, there may be a need for an approximate polynomial that fits the data using interpolation functions.

A.4.1

Lagrange Interpolation Functions For a set of data points: {(x1 , y1 ), (x2 , y2 ), . . . , (xi , yi ), . . . , (xn , yn )}

for i = 1, 2, . . . , n (n > 0)

the elementary Lagrange interpolation formula is n

Lin (x) =



j=1, j6=i

x−xj , xi − x j

i = 1, 2, . . . , n

(A.25)

where Lin (x) is a polynomial with degree no greater than n − 1. Its value at any data point xk within the data set is either 1 or 0:  n xk − x j 0, fori 6= k; Lin (xk ) = ∏ = δik = (A.26) 1, fori = k x − x i j j=1, j6=i Thus, the Lagrange interpolation polynomial of degree n − 1 is n

pn−1 (x) = ∑ yi Lin (x)

(A.27)

i=1

For the simplest case where n = 1, there are only two data points: {(x1 , y1 ), (x2 , y2 )} and is a linear function which passes through the two data points. Thus, is just a straight line with its two end points being the two data points: p1 (x) = y1

x − x2 x − x1 + y2 x1 − x2 x2 − x1

(A.28)

For n = 3, there are only three data points: {(x1 , y1 ), (x2 , y2 ), (x3 , y3 )} and it is a quadratic polynomial that passes through three data points: p1 (x) = y1

(x − x2 ) (x − x3 ) (x − x1 ) (x − x3 ) (x − x1 ) (x − x2 ) + y2 + y3 (A.29) (x1 − x2 ) (x1 − x3 ) (x2 − x1 ) (x2 − x3 ) (x3 − x1 ) (x3 − x2 )

An advantageous property of the Lagrange interpolation polynomial is that there is no need to arrange the data points in any particular order, as long as they are mutually distinct. Thus, the order of the data points is irrelevant. For an application of the Lagrange interpolation polynomial, say the known points are [y1 , y2 ] or [y1 , y2 , y3 ], it is possible to estimate the function y(x) anywhere in x ∈ [x1 , x2 ] linearly, and x ∈ [x1 , x3 ] quadratically.

Chapter A. Relevant Math and MATLAB Concepts

932

A.4.2

Newton Interpolating Polynomial Suppose there is a known polynomial pn−1 (x) that interpolates the data set {(x1 , y1 ), (x2 , y2 ), . . . , (xi , yi ), . . . , (xn , yn )}

for i = 1, 2, . . . , n (n > 0)

When one more data point (xn+1 , yn+1 ), which is distinct from all the old data points, is added to the data set, it is possible to build a new polynomial that interpolates the new data set. Keep in mind that the new data point does not need to be at the end of the old data set. Consider the following polynomial of degree n n

pn (x) = pn−1 (x) + cn ∏ (x − xi )

(A.30)

i=1

where cn is an unknown constant. In the case of n = 1, specify p0 (x) as p0 (x) = y1 where data point 1 does not need to be at the beginning of the data set. When expanding the recursive form, the right-hand-sides of the above equation, it is possible to obtain a standard polynomial form: pn−1 (x) = c0 + c1 (x − x1 ) + c2 (x − x1 ) (x − x2 ) + · · · + cn (x − x1 ) (x − x2 ) · · · (x − xn ) (A.31) The above is known as the Newton’s interpolation polynomial. From the data set information, it is possible to determine Its constants: p0 (x1 ) = y1 = c0 p1 (x2 ) = y2 = c0 + c1 (x2 − x1 ) p2 (x3 ) = y3 = c0 + c1 (x3 − x1 ) + c2 (x3 − x1 ) (x3 − x2 ) which gives c0 = y1 c1 =

y2 − c0 x2 − x1

c2 =

y3 − c0 − c1 (x3 − x1 ) (x3 − x1 ) (x3 − x2 )

Thus, cn =

pn (xn+1 ) − pn−1 (xn+1 ) n

∏ (xn+1 − xi ) i=1

A.4 Polynomial Approximation

933

When forcing the polynomial through data with no regard for rates of change in the data (i.e., derivatives), it results in a C0 continuous interpolating polynomial. Alternatively, each data condition p(xi ) = yi is called a C0 constraint. It is important to realize that both the Lagrange and Newton polynomials are C0 continuous, and each would generate the same result.

A.4.3

Hermite Interpolation Polynomial The Hermite interpolation accounts for the derivatives of a given function. The advantage is that it takes information regarding the slope at the known point. 1. Consider: y = a x3 + b x2 + c x + d and x ∈ [0, 1]. 2. Apply conditions x = 0;

x=1 0

Case 1: y = 1, y = 0; y = 0, y0 = 0 Case 2: y = 0, y0 = 1; y = 0, y0 = 0 Case 3: y = 0, y0 = 0; y = 1, y0 = 0 Case 4: y = 0, y0 = 0; y = 0, y0 = 1 3. Solve each case for a, b, c, d.

A.4.4

Pascal’s Triangle Polynomials We get these higher order polynomials using the Pascal’s triangle to ensure completeness and continuity: 1 x x2 x3 x4 x5

x2 y

y2 x y2

x2 y2 x3 y2

: first-order

y xy

x3 y x4 y

: constant

: second-order y3

x y3 x 2 y3

: third-order y4

x y4

: fourth-order y5

: fifth-order

For some application, it is convenient to neglect the constant and first-order terms.

Chapter A. Relevant Math and MATLAB Concepts

934



EXAMPLE

Example A.29 : Pascal’s Triangle Polynomials

Build fourth-order bivariate polynomials using Pascal’s Triangle. Φ(x, y) =A1 x4 + A2 x3 y + A3 x2 y2 + A4 x y3 + A5 y4 + B1 x3 + B2 x2 y + B3 x y2 + B4 y3 +C1 x2 +C2 x y +C3 y2 + D1 x y + D2 y2 + E1 END EXAMPLE 

A.5

Roots of polynomials MATLAB can fing the roots of polynomials of the form cn xn + · · · + c2 x2 + c1 x + c0 = 0 as follows: >> c=[c_n ... c_2

c_1

c_0]

>> roots(c)

A.5.1

Linear Equations The general form of a linear equation is: c1 α + c0

= 0

and its root is: c0 α1 = − c1

A.5.2

(A.32)

Quadratic Equations The general form of a quadratic equation is: c2 α 2 + c1 α + c0 = 0 and its roots are: α=

−c1 ±

q c21 − 4 c2 c0 2 c2

(A.33)

A.5 Roots of polynomials

α1 =

A.5.3

−c1 +

q c21 − 4 c2 c0 2 c2

935

α2 =

−c1 −

q

c21 − 4 c2 c0

(A.34)

2 c2

Cubic Equations The general form of a Cubic equation is: α 3 + c2 α 2 + c1 α + c0 = 0

(A.35)

and its roots are (note that c3 = +1, positive one):   q c2 2 β 2 α1 = − + c2 − 3 c1 cos 3 3 3

(A.36a)

α2

c2 2 = − + 3 3

  q β 2π 2 c2 − 3 c1 cos + 3 3

(A.36b)

α3

c2 2 = − + 3 3

  q β 4π 2 c2 − 3 c1 cos + 3 3

(A.36c)

where: ( β = cos−1



−2 c32 + 9 c1 c2 − 27 c0 3/2 2 c22 − 3 c1

)

Example A.30 : Roots of Polynomials

Using MATLAB, find the roots of α2 + 7 α + 6 = 0 >> c=[1 7 6] c = 1

7

>> roots(c) ans = -6

6

(must be in radians)

EXAMPLE

Chapter A. Relevant Math and MATLAB Concepts

936 -1

END EXAMPLE 



EXAMPLE

Example A.31 : Roots of Polynomials

Find the roots of −8 + 13 α + 6.5 α 2 − α 3 = 0 First, ensure that c3 = 1: α 3 − 6.5 α 2 − 13 α + 8 = 0 Using the cubic equation produces: c2 = −6.5

c1 = −13

c0 = 8

and the solution to the above equation is (note that c3 = 1): ) ( 3 −1 −2 c2 + 9 c1 c2 − 27 c0 (must be in radians) β = cos 3/2 2 c22 − 3 c1 = 0.72769 rads c2 2 α1 = − + 3 3

q

c2 2 α2 = − + 3 3

q

c2 2 α3 = − + 3 3

q

c22 − 3 c1

c22 − 3 c1

c22 − 3 c1

  β cos = −2.0 3 

β 2π cos + 3 3 

β 4π cos + 3 3

 = 0.5  = 8.0 END EXAMPLE 



Example A.32 :

Using MATLAB, find the roots of α 3 − 6α 2 − 15α + 29 = 0

EXAMPLE

A.6 The Eigenvalue Problem

937

>> c=[1 -6 -15 29] c = 1 -6 -15 29 >> roots(c) ans = 7.4862 -2.8469 1.3607

END EXAMPLE 

A.6

The Eigenvalue Problem The origin of eigen is German and means “proper” or “characteristic”. In other words, the eigenvalue problem relates to the characteristic of a matrix. This section provides a brief derivation and explanation of the eigenvalue problems and possible solution techniques.

A.6.1

Derivation Express the linear system of equations as follows: Ax = b (A.37) ˜ ˜ where A is an n × n square matrix, x an n × 1 column vector, and b an n × 1 column ˜ vector. When b is a nonzero vector,˜ the linear equations are commonly referred as a ˜ system. For a nonhomogeneous system, unique solutions exist as long nonhomogeneous as the determinant of matrix A is nonzero. Assuming the vector b is a scalar multiplied by ˜ the x, e.g., ˜ b=αx (A.38) ˜ ˜ leads to a set of linear equations of the form Ax = α x ˜ ˜ Recall that

(A.39)

x = Ix (A.40) ˜ ˜ where I is an identity matrix of order n. It is possible to rewrite Eq. (A.39) as follows: Ax = α Ix ˜ ˜

(A.41)

Chapter A. Relevant Math and MATLAB Concepts

938

It is of common practice to express Eq. (A.41) as Ax−α Ix = 0 ˜ ˜ ˜ or [A − α I] x = 0 ˜ ˜

(A.42)

where A is an n × n square matrix, I the identity matrix of order n, x an n × 1 unknown ˜ of an eigenvalue vector, and α an unknown scalar. Eq. (A.42) is the representation problem. Applications to the eigenvalue problem are common in engineering. For example, buckling problems, vibration of elastic structures, electrical systems, principal stresses, and optimization problems.

A.6.2

Solution The matrix eigenvalue problem is [A − α I] x = 0 ˜ ˜

(A.43)

Here, both vector x and scalar α are unknown. The goal is to determine both unknowns. ˜ equations, Eq. (A.43), has two possible solutions: The linear system of

1. x = 0: When x = 0 is a solution of Eq. (A.43) for any value of α, and it is of no ˜ ˜ interest ˜ because ˜ practical it provides no information regarding the problem. This is a trivial solution, and the desired solution is one of nonzero solutions. 2. x 6= 0: A value of α for which Eq. (A.43) has a solution x 6= 0 is called an eigenvalue, ˜ characteristic ˜ ˜ ˜ or value, of the matrix A. The corresponding solutions x 6= 0 of ˜ to ˜that Eq. (A.43) are the eigenvectors, or characteristic vectors, of A corresponding eigenvalue of α.

In general, to solve an eigenvalue problem, the square matrix A should be nonsingular. Otherwise, it would lead to at least one zero eigenvalue.

A.6.3

Eigenvalues In order to find the eigenvalues, start with [A − α I] x = 0 ˜ ˜

(A.44)

A.6 The Eigenvalue Problem

939

Since the interest are only nonzero values of x, ˜

 a11   a21  .  . . an1  a11   a21  .  . . an1

a12 a22 .. .

··· ··· .. .

a1n a2n .. .

an2

···

ann

a12 a22 .. .

··· ··· .. .

a1n a2n .. .

an2

···

ann





1

0

  −α 

    

0 .. .

1 .. . ···

0 

α

0

    −   

0 .. .

α .. . ···



0

(a11 − α) a12 a (a − α) 21 22 .. .. . . an1 an2

det [A − α I] = 0

(A.45a)

··· .. . .. . 0

 0 ..  .   = 0  0  1

(A.45b)

··· .. . .. . 0

 0 ..  .   = 0  0  α

(A.45c)

= 0 (ann − α)

(A.45d)

··· ··· .. . ···

a1n a2n .. .

This will lead to a characteristic equation: (a11 − α) a12 ··· a1n a (a − α) · · · a2n 21 22 p(α) = .. .. .. . . . . . . an1 an2 · · · (ann − α)

=0

(A.46)

The characteristic equation of matrix A will be in terms of α. If the size of matrix A is n × n then the characteristic equations will produce a nth degree polynomial, i.e., have at most n distinct roots, some of which may be complex. The roots to this polynomials are the eigenvalues. In summary, 1. The roots of the characteristic equation of A are the eigenvalues of the square matrix A. 2. An n × n matrix has at least one eigenvalue and at most n numerically different eigenvalues. 3. The eigenvalues must be determined first. In practice, eigenvalues of large matrices are not computed using the characteristic polynomial. Faster and more numerically robust methods are available, for instance the QR/QZ decompositions. MATLAB uses robust and stable algorithms based on LAPACK libraries to obtain the eigenvalues:

Chapter A. Relevant Math and MATLAB Concepts

940 E = EIG(A,B)

The vector E is a vector containing the generalized eigenvalues of square matrices A and ˜ B. [V,D] = EIG(A,B)

The above statement produces a diagonal matrix D of generalized eigenvalues and a full matrix V whose columns are the corresponding eigenvectors so that A V = B V D. ˜ EIG(A,B,’chol’)

The above is the same as EIG(A,B) for a symmetric A, and a symmetric positive definite B. It computes the generalized eigenvalues of A and B using the Cholesky factorization of B. EIG(A,B,’qz’)

The above ignores the symmetry of A and B and uses the QZ algorithm. In general, the two algorithms return the same result. However, using the QZ algorithm may be more stable for certain problems. The flag is ignored when A and B are not symmetric. 

Example A.33 : Eigenvalues

Obtain the eigenvalues for the following matrix:   −5 2 A= 2 −2 [A − α I] x = 0 ˜ ˜

EXAMPLE

A.6 The Eigenvalue Problem

941

Since the interest is only in nonzero values of x, ˜ det [A − α I] = 0    −5 2 1 2 −2 − α 0

0 1

    −5 2 α = 2 −2 − 0

0 α

 = 0

(−5 − α) 2 2 (−2 − α)

= 0

Defining the characteristic determinant as: (−5 − α) 2 = (−2 − α)(−5 − α) − 4 = 0 p(α) = 2 (−2 − α) Then, the characteristic equation of matrix A is p(α) = α 2 + 7 α + 6 = (α + 6)(α + 1) = 0 and the eigenvalues are then: α = −1, −6 Using MATLAB, >> A=[-5,2;2,-2] A = -5 2

2 -2

>> alpha =eig(A) alpha = -6 -1

END EXAMPLE 

Chapter A. Relevant Math and MATLAB Concepts

942



Example A.34 : Eigenvalues

Obtain the eigenvalues for the following matrix:   −2 0 3 A= 1 4 3  2 3 4 [A − α I] x = 0 ˜ ˜ Since the interest is only in nonzero values of x, ˜ det [A − α I] = 0    −2 0 3 1  1 4 3  − α  0 2 3 4 0

0 1 0

  0 −2 0  =  1 2 1

(−2 − α) 0 3 1 (4 − α) 3 2 3 (4 − α)

Then, the characteristic equation of matrix A is p(α) = α 3 − 6α 2 − 15α + 29 = 0

α = 7.4862, −2.8469, 1.3607 Using MATLAB, >> A=[-2,0,3;1,4,3;2,3,4] A = -2

0

3

0 α 0

 0 0  = 0 α

= 0

Defining the characteristic determinant as: (−2 − α) 0 3 p(α) = 1 (4 − α) 3 2 3 (4 − α)

and the eigenvalues are then:

  0 3 α 4 3 − 0 3 4 0

= −α 3 + 6α 2 + 15α − 29 = 0

A.6 The Eigenvalue Problem 1 2

4 3

943

3 4

>> alpha =eig(A) alpha = 7.4862 -2.8469 1.3607

END EXAMPLE 

Chapter A. Relevant Math and MATLAB Concepts

944

A.7

Numerical Integration An important aspect of isoparametric finite element analysis is the use of an appropriate numerical integration scheme. Whether a one-, two- or three-dimensional integrals, the goal is never to solve the exact integration. Although the exact solution might seem practical, it is helpful for only very few cases. In fact, with modern computers numerical integration is faster and more convenient than the exact close-form solutions to finite element equations. The close-form solutions provide an understanding of how the finite element method works. However, the preference of numerical methods over close-form solutions is evident when looking at the computer implementation. In the most general sense, the required integrals in the finite element calculations have the following form ¨ ˚ ˆ F (ξ , η) dξ dη; F (ξ , η, ζ ) dξ dη dζ F (ξ ) dξ ; in the one-, two-, and three-dimensional cases, respectively. It is possible to numerically approximate these integrals by using weighted factors as follows: ˆ F (ξ ) dξ = ∑ wi F (ξi ) + Rn ¨

i

F (ξ , η) dξ dη = ∑ ∑ wi j F (ξi , η j ) + Rn ˚

j

i

F (ξ , η, ζ ) dξ dη dζ = ∑ ∑ ∑ wi jk F (ξi , η j , ζk ) + Rn k

j

i

where the summations extend over all i, j, and k specified, the weighting factors are wi ’s and Fi ’s are the evaluated matrices at the ith point. The matrices Rn are the error matrices that are often ignored in the calculation. This section aims to present the theory and practical implications of numerical integrations. As is the case of most numerical techniques, the interest is on the accuracy, where the number of required integration points plays an important role. Typically, the finite element method uses either one of the following two integration schemes: 1. Newton-Cotes: Requires (n + 1) function evaluations to integrate without error a polynomial of order n. 2. Gauss quadrature: Requires n function evaluations to integrate exactly a polynomial of order (2n − 1). It is worth highlighting that as the number of function evaluations increases in the finite element analysis, so does the cost of analysis, making the Gauss quadrature more attractive for fewer function evaluations. This is the primary reason for its treatment in the book. However, Newton-Cotes formulas may be more efficient for nonlinear analysis. Every problem and situation has its requirement, being the determining factor for choosing the appropriate integration scheme. Once the numerical scheme is set, the next step would be determining the order of numerical integration. The choice of the order of numerical integration is important because the cost increases with higher-order integrations, and different integration orders may vary the results by a large amount.

Chapter A. Relevant Math and MATLAB Concepts

946

where typically two-, three-, four-, and five-point samplings are sufficient to reach convergence. Table A.1 gives the weighted factors for each sampling point. It should be evident that as the number of evaluation points increase, so does the accuracy of the integral calculation. If ng is the number of Gauss points, the polynomial of order p that can be integrated exactly is given by p ≤ 2 ng − 1 The reason for this is that p + 1 parameters define the polynomial of order p. Hence, the number of integration points needed to integrate a polynomial of order p exactly is given 11–9by §11.5 NUMERICAL INTEGRATION BY GAUSS RULES p + 1 Integration by Gauss Rules §11.5. Numerical ng ≥ 2 ItThe is possible to material calculateonthenumerical Gauss quadrature and weights anyChapter number17of following integrationpoints is transcribed herefor from integration points, as given in Table A 1. In the finite element program, the subroutines of the IFEM Notes for convenience. The Gauss quadrature information modules listed program these values once such that the analyst does not have to obtain their values below are used in the implementations covered in theGauss next two Chapters. repeatedly. Figure A.3element shows the first five one-dimensional rules. Sample point locations are marked with black circles. The radii of those circles are proportional to the integration weights. Table A.1 summarizes the one-dimensional Gauss rules. The use of numerical integration is essential for practical evaluation of integrals over isoparametric element domains. The standard practice has been to use Gauss integration because such rules use a minimal number of sample points to achieve a desired level of accuracy. This economy is important for efficient element calculations, since a matrix product is evaluated at each sample point. The fact that the location of the sample points in Gauss rules is usually given by non-rational numbers is of no concern in digital computation.

ξ=1 p=1

ξ = −1

p=2 p=3 p=4 p=5 Figure 11.3. The first five unidimensional Gauss rules p = 1, 2, 3, 4, 5 depicted over the line segment ξ ∈ [−1, +1]. Sample point locations are marked with black circles. The radii of those circles are proportional to the integration weights Figure A.3: Gauss one-dimensional numerical integrations sample points over

a line

segment ξ ∈ [−1, +1] for Gauss rules p = 1, 2, 3, 4, 5. §11.5.1. One Dimensional Rules The classical Gauss integration rules are defined by

1

−1

F(ξ ) dξ ≈

p

wi F(ξi ).

(11.19)

i=1

Here p ≥ 1 is the number of Gauss integration points (also known as sample points), wi are the integration weights, and ξi are sample-point abcissae in the interval [−1,1]. The use of the canonical transformed to [−1, +1] via a simple linear transformation of the independent variable, as shown

A.7 Numerical Integration

947

Table A.1: One-Dimensional Gauss Rules with 1 through 6 sampling points (interval −1 to +1).

Points (n)

Order of Polynomial (p)

1 2

3

4

5

6

Weighting factors (wi )

Evaluation points (ξi )

p≤1

w1 = 2

ξ1 = 0

p≤3

w1 = 1 w2 = 1

√ ξ1 = −1/ √ 3 ξ2 = 1/ 3

w1 = 5/9 w2 = 8/9 w3 = 5/9

p ξ1 = − 3/5 ξ2 = 0 p ξ3 = 3/5

p≤5

p≤7

p≤9

p ≤ 11

w1 = 1/2 −

p

5/216

w2 = 1/2 +

p

5/216

w3 = 1/2 +

p

5/216

w4 = 1/2 −

p

5/216

q p ξ1 = − 3/7 + 24/245 q p ξ2 = − 3/7 − 24/245 q p ξ3 = 3/7 − 24/245 q p ξ4 = 3/7 + 24/245

√ w1 = (322 − 13 70)/900 √ w2 = (322 + 13 70)/900 w3 = 512/900 √ w4 = (322 + 13 70)/900 √ w5 = (322 − 13 70)/900

q p ξ1 = − 5/9 + 2 10/567 q p ξ2 = − 5/9 − 2 10/567 ξ3 = 0 q p ξ4 = 5/9 − 2 10/567 q p ξ5 = 5/9 + 2 10/567

w1 = 0.1713244924 w2 = 0.3607615730 w3 = 0.4679139346 w4 = 0.4679139346 w5 = 0.3607615730 w6 = 0.1713244924

ξ1 = −0.9324695142 ξ2 = −0.6612093865 ξ3 = −0.2386191861 ξ4 = 0.2386191861 ξ5 = 0.6612093865 ξ6 = 0.9324695142

The p are recommended only for polynomial and are not applicable for nonlinear equations not represented by polynomials. For finite element analysis, programming for ng = 5 is acceptable for linear finite element analysis.

Chapter A. Relevant Math and MATLAB Concepts

948



EXAMPLE

Example A.35 :

Use Gauss-Legendre Quadrature to evaluate the following integral: ˆ

6

(1 + x) (1 − x2 ) dx 2

First, proceed to express the integral in its isoparametric representation (map from x to ξ ):     xb − xa xb − xa xb + xa x= + ξ → dx = dξ 2 2 2 x = 4+2ξ



dx = 2 dξ

Hence, f (x) = (1 + x) (1 − x2 )

f (ξ ) = (2ξ + 5) 1 − (2ξ + 4)2



and the Jacobian is:     dx J= = 2 dξ





|J| = 2

Hence, the isoparametric representation is ˆ

ˆ

b

1

f (x) dx = |J|

I= ˆ

f (ξ ) dξ −1

a

ˆ

6

1

(1 + x) (1 − x2 ) dx = |J|

I=

 (2ξ + 5) 1 − (2ξ + 4)2 dξ −1

2

The exact solution is (obtained through direct integration): I=−

1108 = −369.333 3

Using Gauss-Legendre Quadrature: 1. One-point ξ1 = 0

w1 = 2

f1 = f (ξ1 ) = −75.00

Hence, h i I ≈ |J| (w1 f1 ) = (2) (2)(−75) = −300

Chapter A. Relevant Math and MATLAB Concepts

950



EXAMPLE

Example A.36 : Gauss Rules for elemental stiffness matrix

Gauss Rules to evaluate the following elemental stiffness matrix:    ˆ 80  1  x 2  − 80 1 1 E 1+ Ke = dx − 80 1 80 40 0 80 First, proceed to express the integral in its isoparametric representation (map from x to ξ ):     xb + xa xb − xa xb − xa x= + ξ → dx = dξ 2 2 2 →

x = 40 + 40 ξ

dx = 40 dξ

Hence,  F(x) =

1 − 80 1 80



    x 2  1 1 E 1+ − 80 80 40  "   # 1 40 + 40 ξ 2  − 80 1 F(ξ ) = E 1+ − 80 1 40 80

and the Jacobian is:     dx J= = 40 dξ



1 80



|J| = 40

Hence, the isoparametric representation is ˆ

ˆ

b

1

F(x) dx = |J|

Ke = ˆ

F(ξ ) dξ −1

a 80



1 − 80

    x 2  1 1 Ke = E 1+ dx − 80 1 80 40 0 80 " #    ˆ 1  1 40 + 40 ξ 2  − 80 1 = 40 E 1+ − 80 1 40 −1 80

1 80





The exact solution is (obtained through direct integration):      ˆ 80  1  x 2  13 E 1 −1 − 80 1 1 Ke = dx = E 1 + − 1 80 80 −1 1 40 240 0 80 Using Gauss-Legendre Quadrature:

A.7 Numerical Integration

951

1. One-point ξ1 = 0

w1 = 2

"   # 40 + 40 ξ1 2  1 F1 = F(ξ1 ) = E 1+ − 80 1 40 80  "   # 1  40 2  − 80 1 1 = E 1+ − 80 1 80 40 80   E 1 −1 = 1600 −1 1 

1 − 80

1 80



Hence,      E 1 −1 Ke ≈ |J| w1 F1 = (40) (2) 1600 −1 1   12 E 1 −1 = −1 1 240 2. Two-point ξ1 = −0.57735

w1 = 1  F1 = F(ξ1 ) =

ξ2 = 0.57735

1 − 80

"   # 40 + 40 ξ1 2  1 E 1+ − 80 40

1 80



1 − 80

"   # 40 + 40 ξ2 2  1 E 1+ − 80 40

1 80



1 80

w2 = 1  F2 = F(ξ2 ) =

1 80

ξ1 = −0.57735

w1 = 1

ξ2 = 0.57735

w2 = 1

√ 2   −6 + 3 E 1 −1 F1 = −1 1 57600 √ 2   6+ 3 E 1 −1 F2 = −1 1 57600

Chapter A. Relevant Math and MATLAB Concepts

952 Hence,

Ke ≈ |J| (w1 F1 + w2 F2 ) ( √ 2  ! −6 + 3 E 1 −1 = (40) (1) −1 1 57600 √ 2  !) 6+ 3 E 1 −1 +(1) −1 1 57600   13 E 1 −1 = −1 1 240 3. Three-point (There is no need to continue since the exact solution was achievable.) END EXAMPLE 

A.7 Numerical Integration



953

EXAMPLE

Example A.37 : Gauss Rules for elemental mass matrix

Gauss Rules to evaluate the following elemental mass matrix:    ˆ 80  x  x 2  1 − 80 x x ρ 1+ Me = dx 1 − 80 x 80 40 0 80 First, proceed to express the integral in its isoparametric representation (map from x to ξ ):     xb + xa xb − xa xb − xa x= + ξ → dx = dξ 2 2 2 x = 40 + 40 ξ



dx = 40 dξ

Hence,  F(x) =

x 1 − 80

    x 2  x x → ρ 1 + 1 − 80 x 80 40 80 " #"  2 # h ξ 40 + 40 ξ 1 − 40+40 ξ 80 F(ξ ) = ρ 1+ 1 − 40+40 40+40 ξ 80 40 80

and the Jacobian is:     dx J= = 40 dξ



i

40+40 ξ 80

|J| = 40

Hence, the isoparametric representation is ˆ

ˆ

b

1

F(x) dx = |J|

Me = ˆ

F(ξ ) dξ −1

a 80



x 1 − 80

    x 2  x x Me = ρ 1+ dx 1 − 80 x 80 40 0 80 # " # "   ˆ 1 ξ 40 + 40 ξ 2 h 1 − 40+40 ξ 80 = 40 ρ 1 + 1 − 40+40 40+40 ξ 80 40 −1 80

40+40 ξ 80

The exact solution is (obtained through direct integration):     ˆ 80  x  x 2  ρ 384 1 − 80 x x Me = ρ 1 + dx = 1 − x 80 80 40 6 336 0 80 Using Gauss-Legendre Quadrature:

i



336 1024



Chapter A. Relevant Math and MATLAB Concepts

954 1. One-point ξ1 = 0 " F1 = F(ξ1 ) =  =ρ

w1 = 2

ξ1 1 − 40+40 80 40+40 ξ1 80

1 −1 −1 1

#"   # 40 + 40 ξ1 2 h ξ1 ρ 1+ 1 − 40+40 80 40

40+40 ξ1 80

i



Hence,   Me ≈ |J| w1 F1     ρ 480 1 −1 = (40) (2) ρ = −1 1 6 480

480 480



2. Two-point ξ1 = −0.57735

w1 = 1

F1 = F(ξ1 )

ξ2 = 0.57735

w2 = 1

F2 = F(ξ2 )

" F1 = F(ξ1 ) =

ξ1 1 − 40+40 80 40+40 ξ1 80

" F2 = F(ξ2 ) =

ξ2 1 − 40+40 80 40+40 ξ2 80

ξ1 = −0.57735 ξ2 = 0.57735

#"   # i 40 + 40 ξ1 2 h 40+40 ξ1 ξ1 ρ 1+ 1 − 40+40 80 80 40 # #"   i 40 + 40 ξ2 2 h ξ2 40+40 ξ2 ρ 1+ 1 − 40+40 80 80 40   ρ 7.55342 7.55342 w1 = 1 F1 = 6 2.02393 2.02393   ρ 1.77992 1.77992 w2 = 1 F2 = 6 6.64273 6.64273

Hence, Ke ≈ |J| (w1 F1 + w2 F2 )       ρ 1.77992 ρ 7.55342 7.55342 = (40) (1) + (1) 6 2.02393 2.02393 6 6.64273   ρ 373.3 346.7 = 6 346.7 1013.3 3. Three-point

1.77992 6.64273



A.7 Numerical Integration

955

p ξ1 = − 3/5

w1 = 5/9

F1 = F(ξ1 )

ξ2 = 0.0 p ξ3 = 3/5

w2 = 8/9

F2 = F(ξ2 )

w3 = 5/9

F3 = F(ξ3 )

" F1 = F(ξ1 ) =

ξ1 1 − 40+40 80 40+40 ξ1 80

" F2 = F(ξ2 ) =

ξ2 1 − 40+40 80 40+40 ξ2 80

" F3 = F(ξ3 ) =

ξ3 1 − 40+40 80 40+40 ξ3 80

p ξ1 = − 3/5 ξ2 = 0.0 ξ3 =

p 3/5

#"   # i 40 + 40 ξ1 2 h ξ1 40+40 ξ1 ρ 1+ 1 − 40+40 80 80 40 # #"   i 40 + 40 ξ2 2 h ξ2 40+40 ξ2 ρ 1+ 1 − 40+40 80 80 40 # #"   i 40 + 40 ξ3 2 h ξ3 40+40 ξ3 ρ 1+ 1 − 40+40 80 80 40   ρ 7.09331 7.09331 w1 = 5/9 F1 = 6 0.900968 0.900968   ρ 6 6 w2 = 8/9 F2 = 6 6 6   ρ 0.586694 0.586694 w3 = 5/9 F3 = 4.61903 4.61903 6

Hence, Ke ≈ |J| (w1 F1 + w2 F2 + w3 F3 )          5 ρ 8 ρ 6 7.09331 7.09331 = (40) + 9 6 0.900968 0.900968 9 6 6     5 ρ 0.586694 0.586694 + 4.61903 4.61903 9 6   ρ 384 336 = 6 336 1024

6 6



Note that this mass matrix required a three-point integration. There is a need for a higher-order integration in calculating this mass matrix because it is obtained from the displacement interpolation functions, whereas the stiffness matrix is calculated using derivatives of the displacement functions. It is interesting to note that with too low an order of integration, the total mass of the element and the total load to which the element is subject is not taken fully into account. END EXAMPLE 

Chapter A. Relevant Math and MATLAB Concepts

956

Although the integrals in the previous example produced the exact value, this is absolutely not true for most of the problems. In fact: 1. Numerical integration is not always exact but an approximation 2. Numerical integration converges to exactness as to the number of integration points increases. Usually, when the integrand is a polynomial, one can achieve the exact solution; however, only approximations are achieved in all other cases. The following example illustrates this point. 

EXAMPLE

Example A.38 :

Use Gauss-Legendre Quadrature to evaluate the following integral: ˆ

1

ξ2 −1

−1

(ξ + 3)2

I=



Note that this integral is expressed in its isoparametric representation. Hence, proceed to directly use Gauss Rules at this point. The integrand is: f (ξ ) =

ξ2 −1 (ξ + 3)2

The exact solution is (obtained through direct integration): ˆ

1

ξ2 −1

−1

(ξ + 3)2

I=

dξ = 4 − ln(64) = −0.158883

Using Gauss-Legendre Quadrature: 1. One-point ξ1 = 0

w1 = 2

f1 = f (ξ1 ) = −0.111111

Hence, I ≈ w1 f1 = (2)(−0.111111) = −0.222222 2. Two-point ξ1 = −0.57735

w1 = 1

f1 = f (ξ1 ) = −0.113587

ξ2 = 0.57735

w2 = 1

f2 = f (ξ2 ) = −0.0520938

A.7 Numerical Integration

957

Hence, I ≈ w1 f1 + w2 f2 = (1)(−0.113587) + (1)(−0.0520938) = −0.16568 3. Three-point ξ1 = −0.774597

w1 = 0.555556

f1 = f (ξ1 ) = −0.0807686

ξ2 = 0

w2 = 0.888889

f2 = f (ξ2 ) = −0.111111

ξ3 = 0.774597

w3 = 0.555556

f3 = f (ξ3 ) = −0.0280749

Hence, I ≈ w1 f1 + w2 f2 + w3 f3 = (0.555556)(−0.0807686) + (0.888889)(−0.111111) + (0.555556)(−0.0280749) = −0.159234 4. Four-point ξ1 = −0.861136

w1 = 0.347855

f1 = f (ξ1 ) = −0.0564938

ξ2 = −0.339981

w2 = 0.652145

f2 = f (ξ2 ) = −0.124993

ξ3 = 0.339981

w3 = 0.652145

f3 = f (ξ3 ) = −0.0792806

ξ4 = 0.861136

w4 = 0.347855

f4 = f (ξ4 ) = −0.0564938

Hence, I ≈ w1 f1 + w2 f2 + w3 f3 + w4 f4 = (0.347855)(−0.0564938) + (0.652145)(−0.124993) + (0.652145)(−0.0792806) + (0.347855)(−0.0173355) = −0.158898 This example shows that it is impossible to reach the exact value. Instead, the results only converge to the exact value. It is possible to increase the convergence by increasing the number of sampling or Gauss points. Convergence plot is

A.7 Numerical Integration



961

EXAMPLE

Example A.39 :

Using 1 through 3 product rules in Gauss-Legendre Quadrature, evaluate the following two-dimensional integral defined over a quadrilateral region:  ˆ 2ˆ 6   1  1+ 2 1 − (x y)2 dx dy x 0 2 First, proceed to express the integral in its isoparametric representation (map from x to ξ ):     xb − xa xb + xa + ξ → x = 4+2ξ x= 2 2     yb + ya yb − ya y= + η → y = 1+η 2 2 Hence,    1  f (x, y) = 1 + 2 1 − (x y)2 x    1 2 2 1 − (η + 1) (2ξ + 4) → f (ξ , η) = 1 + (2ξ + 4)2 and the Jacobian is:  ∂x ∂y  ∂ξ ∂ξ  J=  ∂x ∂y ∂η

  2    =  0

0

 



|J| = 2

1

∂η

Hence, the isoparametric representation is  ˆ 1 ˆ 1 n I = |J| f (ξ , η) dξ dη ≈ |J| ∑ −1

−1

m

∑ wi w j f (ξi , η j )

i=1 j=1

The exact solution is (obtained through direct integration):  ˆ 2ˆ 6   1  1682 I= 1+ 2 1 − (x y)2 dx dy = − = −186.889 9 x 0 2 Using Gauss-Legendre Quadrature:

Chapter A. Relevant Math and MATLAB Concepts

962 1. One-point ξ1 = 0 η1 = 0

→ wξ1 = 2 → wη1 = 2

 →

f11

= f (ξ1 , η1 ) = −15.9375

Hence,  I ≈ |J| wξ1 wη1 f11 h i = (2) (2)(2)(−15.9375) = −127.5 2. Two-point ξ1 = −0.57735 η1 = −0.57735

→ wξ1 = 1 → wη1 = 1



ξ1 = −0.57735 η2 = 0.57735

→ wξ1 = 1 → wη2 = 1



ξ2 = 0.57735 η1 = −0.57735 ξ2 = 0.57735 η2 = 0.57735

→ wξ2 = 1 → wη1 = 1



→ wξ2 = 1 → wη2 = 1





f11

= f (ξ1 , η1 ) = −0.501274



f12

= f (ξ1 , η2 ) = −21.507



f21

= f (ξ2 , η1 ) = −3.88744



f22

= f (ξ2 , η2 ) = −67.5598

Hence,  I ≈ |J| wξ1 wη1 f11 + wξ1 wη2 f12 + wξ2 wη1 f21 + wξ2 wη2 f22 h = (2) (1)(1)(−0.501274) + (1)(1)(−21.507) + (1)(1)(−3.88744) i + (1)(1)(−67.5598) = −186.911 3. Three-point → wξ1 = 0.555556 → wη1 = 0.555556



ξ1 = −0.774597 η2 = 0.00000

→ wξ1 = 0.555556 → wη2 = 0.888889



ξ1 = −0.774597 η3 = 0.774597

→ wξ1 = 0.555556 → wη3 = 0.555556



ξ1 = −0.774597 η1 = −0.774597



f11

= f (ξ1 , η1 ) = 0.810513



f12

= f (ξ1 , η2 ) = −5.83997



f13

= f (ξ1 , η3 ) = −20.8982

A.7 Numerical Integration

965

where the summations extend over all i specified, the weighting factors are wi ’s and Fi ’s the matrices evaluated at the ith point, n the number of Gauss points in the triangular region. Note that the enclosed area for a straight triangle is given by: Ae =

1 |J| 2

The procedure is similar to that of the quadrilateral region; however, use Table A.2 instead, Gauss rules for a triangle, and express the integrals are expressed from 0 < η < 1 and 0 < ξ < 1 − η. Figure A.7 shows the first six two-dimensional Gauss rules for triangular regions. Sample point locations are marked with black circles.

A.7 Numerical Integration

967

Table A.2: Gauss rules for a triangular region (0 < η < 1, 0 < ξ < 1 − η). Gauss Rule (n)

Degree of precision

Weighting factors (wi )

(ξi )

1

(ηi )

1

1

1/3

1/3

3

2

1/3 1/3 1/3

2/3 1/6 1/6

1/6 2/3 1/6

−3

2

1/3 1/3 1/3

0 1/2 1/2

1/2 0 1/2

4

3

−27/48 25/48 25/48 25/48

1/3 0.6 0.2 0.2

1/3 0.2 0.6 0.2

0.22338158967801146570 0.22338158967801146570 0.22338158967801146570 0.10995174365532186764 0.10995174365532186764 0.10995174365532186764

0.10810301816807022736 0.44594849091596488632 0.44594849091596488632 0.81684757298045851308 0.091576213509770743460 0.091576213509770743460

0.44594849091596488632 0.10810301816807022736 0.44594849091596488632 0.091576213509770743460 0.81684757298045851308 0.091576213509770743460

3/10 3/10 3/10 1/30 1/30 1/30

2/3 1/6 1/6 0 1/2 1/2

1/6 2/3 1/6 1/2 0 1/2

5

0.12593918054482715260 0.12593918054482715260 0.12593918054482715260 0.13239415278850618074 0.13239415278850618074 0.13239415278850618074 9/40

0.79742698535308732240 0.10128650732345633880 0.10128650732345633880 0.059715871789769820459 0.47014206410511508977 0.47014206410511508977 1/3

0.10128650732345633880 0.79742698535308732240 0.10128650732345633880 0.47014206410511508977 0.059715871789769820459 0.47014206410511508977 1/3

6

0.050844906370206816921 0.050844906370206816921 0.050844906370206816921 0.11678627572637936603 0.11678627572637936603 0.11678627572637936603 0.082851075618373575194 0.082851075618373575194 0.082851075618373575194 0.082851075618373575194 0.082851075618373575194 0.082851075618373575194 0.082851075618373575194

0.87382197101699554332 0.063089014491502228340 0.063089014491502228340 0.50142650965817915742 0.24928674517091042129 0.24928674517091042129 0.059715871789769820459 0.053145049844816947353 0.31035245103378440542 0.053145049844816947353 0.31035245103378440542 0.63650249912139864723 0.63650249912139864723

0.063089014491502228340 0.87382197101699554332 0.063089014491502228340 0.24928674517091042129 0 50142650965817915742 0.24928674517091042129 0.47014206410511508977 0 31035245103378440542 0.053145049844816947353 0.63650249912139864723 0.63650249912139864723 0.053145049844816947353 0 31035245103378440542

6

4

−6

4

7

13

Evaluation points

Gauss Rules are 1, 3, −3, 6, −6, 7, and 13, the order of the rule. Note that there are two rules of order 3 and 6: hence, the negative value returns the second one.

Chapter A. Relevant Math and MATLAB Concepts

968



EXAMPLE

Example A.40 :

Using 1 and 3 sampling points in Gauss-Legendre Quadrature, evaluate the following two-dimensional integral defined over a triangular region: ˆ 1ˆ 0

1−η

   4 ξ − 1 6 ξ − 4 η |J| dξ dη

0

where the Jacobian is   −2 −6  J= 5 −4 First, calculate the determinant of the Jacobian: −2 −6 = 38 |J| = 5 −4 The integrand is    f (ξ , η) = 4 ξ − 1 6 ξ − 4 η Using Gauss Quadrature ˆ 1ˆ

1−η

I= 0

0

   n 1 4 ξ − 1 6 ξ − 4 η |J| dξ dη ≈ |J| ∑ wi f (ξi , ηi ) 2 i=1

The exact solution is (obtained through direct integration): ˆ 1ˆ I= 0

1−η

   4 ξ − 1 6 ξ − 4 η (38) dξ dη = 38

0

Using Gauss-Legendre Quadrature: 1. One-point  ξ1 = 0.333333  η1 = 0.333333  w1 = 1



f1

= f (ξ1 , η1 ) = 0.222222

A.7 Numerical Integration

969

Hence, 1 |J| (w1 f1 ) 2 h i 1 = (38) (1)(0.222222) = 4.22222 2

I≈

2. Three-point (+3)  ξ1 = 0.666667  η1 = 0.1666667  w1 = 0.333333  ξ2 = 0.1666667  η2 = 0.666667  w2 = 0.333333  ξ3 = 0.1666667  η3 = 0.1666667  w3 = 0.333333



f1

= f (ξ1 , η1 ) = 5.55556



f2

= f (ξ2 , η2 ) = 0.555556



f3

= f (ξ3 , η3 ) = −0.111111

Hence, 1 |J| (w1 f1 + w2 f2 + w3 f3 ) 2 h i 1 = (38) (0.333333)(5.55556) + (0.333333)(0.555556) + (0.333333)(−0.111111) 2 = 38

I≈

3. Three-point (−3)  ξ1 = 0  η1 = 0.5  w1 = 0.333333  ξ2 = 0.5  η2 = 0  w2 = 0.333333  ξ3 = 0.5  η3 = 0.5  w3 = 0.333333



f1

= f (ξ1 , η1 ) = 2



f2

= f (ξ2 , η2 ) = 3



f3

= f (ξ3 , η3 ) = 1

A.7 Numerical Integration

A.7.4

971

Gaussian Quadrature Code Following is an explanation of the Gaussian Quadrature function developed in MATLAB: function [I]= GaussQuadratures(Type,Np,f) The function GaussianQuadrature.m approximates line integrals as well as two-dimensional integrals over both triangular and quadrilateral regions. Always express the integrals in their natural coordinates in order to use the function. The function requires the following input: Type, Np, f. Type: The type of Gauss Quadrature to perform: “1" for a one-dimensional region; “2" for a two-dimensional quadrilateral region; “3" for a two-dimensional triangular region. Np: The number of Gauss Points to approximate the integral. For triangular elements, the Gauss Points and their corresponding weight factors are given for the following cases: 1, 3, −3, 4, 6, −6, 7 and 13. The function will always return values for −3 or −6 for triangular regions. f: The integrand (the function to integrate). Always define the function (which may be a scalar, vector, or a matrix) as follows: f = @(xi) [integrand function goes here] f = @(xi,eta) [integrand function goes here]

% for one-dim % for two-dim

Now, the function chooses the appropriate Gauss Rule, as requested by the user. First, determines what type of integral needs approximating, i.e., switch(Type) case(1) . . . case(2) . . . case(3) . . . end

%One Dimensional Gaussian Quadrature

%Two Dimensional Quadrilateral Quadrature

%Two Dimensional Triangular Quadrature

972

Chapter A. Relevant Math and MATLAB Concepts

Then it chooses the number of Gauss rules of interest and reads the Gauss rules and points, i.e., switch(abs(Np)) case(1) w(1)=2; xi(1)=0; case(2) w(1)=1; w(2)=1; xi(2)=1/sqrt(3); xi(1)=-xi(2); . . . end The function returns the approximate value of the integral. For one-dimensional region: I=0; for ii=1:abs(Np); %Subscript for xi I = I + w(ii)*f(xi(ii)); end For a two-dimensional quadrilateral region: I=0; for ii=1:abs(Np); %Subscript for xi for jj=1:abs(Np); %Subscript for eta I = I + w(ii)*w(jj)*f(xi(ii),eta(jj)); end end For a two-dimensional triangular region: I=0; for ii=1:abs(Np); %Subscript for xi and eta I = I + 0.5*w(ii)*f(xi(ii),eta(ii)); end

A.7 Numerical Integration



973

EXAMPLE

Example A.41 :

Redo all Gauss Quadrature examples using MATLAB: 1. Example A.35 [email protected](xi) 2*(2*xi+5)*(1-(2*xi+4)^2) I = GaussQuadratures(1,5,f); Output is The approximation is I = -369.3333 2. Example A.36 (Note that E is taken as one) [email protected](xi) 40*[-1/80; 1/80]*[(1+(40+40*xi)/40)^2]*[-1/80 I = GaussQuadratures(1,5,f); Output is The approximation is I = 0.0542 -0.0542 -0.0542 0.0542 3. Example A.37 (Note that ρ is taken as one) [email protected](xi) 40*[1-(40+40*xi)/80; (40+40*xi)/80]... *[(1+(40+40*xi)/40)^2]*[1-(40+40*xi)/80 (40+40*xi)/80] I = GaussQuadratures(1,5,f); Output is The approximation is I = 64.0000 56.0000 56.0000 170.6667 4. Example A.38 [email protected](xi) (xi^2-1)/(xi+3)^2 I = GaussQuadratures(1,5,f);

1/80]

Chapter A. Relevant Math and MATLAB Concepts

974 Output is

The approximation is I = -0.1589 5. Example A.39 [email protected](xi,eta) 2*(1+1/(2*xi+4)^2)*(1-(eta+1)^2*(2*xi +4)^2) I = GaussQuadratures(2,5,f); Output is The approximation is I = -186.8889 6. Example A.40 [email protected](xi,eta) 38*(4*xi-1)*(6*xi-4*eta) I = GaussQuadratures(3,5,f); Output is The approximation is I = 38 END EXAMPLE 

A.8 References

A.8

975

References Burden, R. L. and J. D. Faires, Numerical Analysis, Sixth Edition, Brooks/Cole Publishing Company, New York, NY. 1997. Chapters 6–7. Chapra, S. C. and Canale, R. P. Numerical Methods for Engineers, Fourth Edition, McGraw-Hill, New York, NY. 2002. Kreyszig, E., Advanced Engineering Mathematics, Eighth Edition, John Wiley and Sons, New York, NY. 1999. Recktenwald, G.. Numerical Methods with MATLAB: Implementation and Application, Prentice Hall, New Jersey, 2000. Thomas, G. B., R. L. Finney, M. D. Weir and F. R. Giordano, Thomas’ Calculus, Early Transcendentals Update, Tenth Edition, Addison-Wesley, Massachusetts, 2003.

Chapter A. Relevant Math and MATLAB Concepts

976

A.9

Suggested Problems 

EXERCISE PROBLEM

Exercise A.1

You are asked to create a program using MATLAB. The program should consist in: a script file, a function file, and an output file. All input and output must be done from the script file only. All output must be done to an external file. The files must be well documented. The following is a description of what the program should do: 1. The function cadprog takes as an input three arbitrary real numbers a, b and c. The output should be: (a) z1 = a eb (b) z2 = ln c (c) z3 = cb (d) z4 = a/c (e) z5 a condition for not running the function if c = 0. Make sure the function does not print anything. 2. The script file should: (a) Contain all the input variables. (b) Print the input variables (with an explanation). (c) Call the function. (d) Place a condition, where the output of the variables is only printed if c 6= 0. Otherwise use your condition z5 to print a line saying there is an error. 3. Use good programming skills. END EXERCISE 

A.9 Suggested Problems



977

EXERCISE PROBLEM

Exercise A.2

Solve this problem by hand and verify your answers using MATLAB. Consider the following matrices and vectors: x

−y

1

1

  A =  xz 

z2

y

  x  

−y

z





a   C= b 



0



  4 −3  

0 −3

3



0

a3

  −a4   a c b2

8 −2

  B =  −2 

y3 z 2

bc

0 −c b2



   20  d= 0 ˜  −4 

Taking x = y = z = 1,

a = 2 b = −3 c = 6

determine the following: 1. AT B 2. det[C]. Is matrix C singular? Justify your answer.   3. Use Gauss-Jordan elimination to determine the inverse of matrix AT A . Verify your answer using MATLAB. 4. A d ˜ 5. dT ˜ 6. dT A ˜ 7. d dT ˜˜ 8. dT d ˜ ˜ 9. B + dT ˜ 10. B + AT 11. B + CT 12. Eigenvalues of A

Chapter A. Relevant Math and MATLAB Concepts

978 13. Eigenvalues of C 14. Eigenvalues of d ˜

END EXERCISE 



EXERCISE PROBLEM

Exercise A.3

Solve this problem by hand and verify your answers using MATLAB. Consider the following matrices and vectors:   −3 2 −1     −y2 −y2 1 0    −2   1 −3      2 A =  xzy xzy z B= y    0 −3   3      −y −y z 10 z 10 a

−b

c2

  C =  −b 

a3

  a2 b  

c2

a2 b

a



3

2

 d= ˜



1

1 −2

1



Taking x = y = 2 z = 2,

a=2 b=1 c=1

determine the following: 1. AT A. Is the matrix symmetric? 2. d I 3. (A B)T 4. det[C]. Is matrix C singular? Justify your answer.   5. Use Gauss-Jordan elimination to determine the inverse of matrix AT A . Verify your answer using MATLAB.

6. γ dT 2 where γ = 2 ˜

A.9 Suggested Problems

979

7. AT dT ˜ 8. A dT ˜ 9. d AT ˜ 10. d dT ˜˜ 11. dT d ˜ ˜ 12. B + AT 13. A I 14. Eigenvalues of C END EXERCISE 



EXERCISE PROBLEM

Exercise A.4

Solve this problem by hand (using Gauss-Jordan elimination) and verify your answers using MATLAB. Solve the given system of equations: (a)

(b)

3 x1 + 2 x2

= 18

18 x1 + 17 x2

= 123

x1 − 4 x2 + 2 x3

= 81

− 4 x1 + 25 x2 + 4 x3

= −153

2 x1 + 4 x2 + 24 x3

=7

  x1            x2  0 4 −3           0 0 5 x3 

(c)

2

1

7

=

        

 7     −27     5 END EXERCISE 

Chapter A. Relevant Math and MATLAB Concepts

980



EXERCISE PROBLEM

Exercise A.5

Consider the following linear system of equations:       −2  ε −1  x1    =  2  1 1  x2  1. For what values of ε, does the system of equations have a solution? Verify your answer using MATLAB and Gauss-Jordan elimination. 2. For what values of ε, the system of equations does not have a finite number of solutions? Justify your answer using MATLAB. END EXERCISE 



EXERCISE PROBLEM

Exercise A.6

Create the MATLAB function cadcourse and script file, that will take as input the following matrices, vectors, and variables:   −3 2 −1     −y2 −y2 1 0      −2 1 −3      2 B= A =  xzy xzy z y    0 −3   3      −y −y z 10 z 10 a   C =  −b 

−b

c2

a3

  a2 b  

c2

a2 b

a



x = y = 2 z = 2,

d= ˜

2. Z2 = (A B)T



a=2 b=1 c=1

and the function should output the following: 1. Z1 = AT A

3

2

 1

1 −2

1



A.9 Suggested Problems

981

3. mm =det[C] 4. nn = kdk2 ˜ 5. Z3 = dT d ˜ ˜ 6. Phi = Eigenvalues of C. (Phi must be a row vector and not a diagonal matrix.) ˜ ˜ Provide a printout of the M-Files. Print the output to a different file and print this output-file. END EXERCISE 

Chapter A. Relevant Math and MATLAB Concepts

982



EXERCISE PROBLEM

Exercise A.7

Solve by hand and use the MATLAB function to evaluate the following onedimensional integrals using Gauss quadrature. Provide a convergence plot using the first six Gauss rules for one-dimensional domains: one-, two-, three-, four-, five-, and six- point. 1. ˆ

4

 x2 + 1 cos x dx 2

2. ˆ 3 3 ex + x 2 + 0

1 x+2

 cos x dx

END EXERCISE 



EXERCISE PROBLEM

Exercise A.8

Solve by hand and use the MATLAB function to evaluate the following twodimensional quadrilateral regions integrals using Gauss quadrature. Provide a convergence plot using the first five Gauss product rules for quadrilateral domains. 1. ˆ 1ˆ 0

1

e−(x

2 +y2

) dy dx

0

2. ˆ 1ˆ 0

0

1

tan−1 (x y) dy dx

A.9 Suggested Problems

983

3. ˆ

2π ˆ π

(sin x + cos y) dx dy π

0

END EXERCISE 

Chapter A. Relevant Math and MATLAB Concepts

984



EXERCISE PROBLEM

Exercise A.9

Solve by hand and use the MATLAB function to evaluate the following twodimensional triangular regions integrals using Gauss quadrature. Provide a convergence plot using the first five Gauss rules for triangular domains: one-, three- (+3 or −3), four-, six- (+6 or −6), and seven- point. 1. ˆ 1ˆ 0

1−η

0

 J=

2 0

ˆ 1ˆ

1−η

   1 1 1−ξ − √ η 1 + ξ − √ η |J| dξ dη 34 34  1 2

2.

0

0

 J=

2 0

  1 1 + ξ − √ η |J| dξ dη 34  1 2

END EXERCISE 

B. Review of Calculus

chapter2.png Instructional Objectives of Chapter 12

1. Review multivariate calculus. 2. Review of partial derivatives. 3. Review of the chain rule. 4. Review of integration by parts. 

The purpose of this appendix is to review fundamental concepts of multivariable calculus because these concepts are extremely important in engineering optimization design and finite element analysis.

Chapter B. Review of Calculus

986

B.1

Functions The value of many functions can be determined by one or more independent variables. First, let us review the mathematical definition of a function and then discuss functions with more than one variables.

B.1.1

Definition The function is a rule (process or method) that produces a correspondence between two sets of elements such that to each element in the first set there corresponds one and only one element in the second set. The first set is called the domain and the second set is called range. Some example of functions are y(x)

h(x1 )

g(z)

(B.1)

The input values are the domain values (in the above example x1 , x, z) and the output values are range values (in the above example y, h, g). Any variable used as a placeholder for domain values is called an independent variable. Any variable that is used as a placeholder for range values is called a dependent variable. In an equation in two variables, if to each value of the independent variable (input) there corresponds exactly one value of the dependent variable (output), then the equation specifies a function. If there is any value of the independent variable to which there corresponds more than one value of the dependent variable, then the equation does not specify a function. For any element x in the domain of the function f , the symbol f (x) represents the element in the range of f corresponding to x in the domain of f . In other words, if x is an input values, then f (x) is the corresponding output value. A continuous function is one that is continuous at each point of its domain.

B.1.2

Functions of More Than One Variables Let us review the concept of functions that have more than one independent variables. Real-values functions of two or more real variables are defined in a similar way when compared to the single-variable case. Suppose D is a set of n-tuples of real numbers (x1 , x2 , . . . , xn ). Then a real-valued function f on D is a rule that assigns a real number w = f (x1 , x2 , . . . , xn ) to each element in D. The set D is the function’s domain. The set of w-values taken on by f is the function’s range. The symbol w is the dependent variable of f and f is said to be a function of the n independent variables x1 to xn .

B.2 First-Order Partial Derivatives



987

Example B.1 :

Let us consider the volume of a right circular cylinder. Suppose the volume is a function of its height h and radius r, then the independent variables would be r and h and the volume function can be written as follows V = V (r, h) = π r2 h one could also write the above as follows: V = V (x1 , x2 ) = π x12 x2 where x1 represents the cylinder’s radius and x2 its height. Both expression as equivalent. For this example, x1 (or r) and x2 (or h) would the independent variables and V the dependent variable of the function. If in the previous example we had imposed the condition r = 5 h, then the function reduces to a one variable function: V = V (r),

or V = V (x1 ) END EXAMPLE 

B.1.3

Vector notation Consider a set of independent variables: {x1 , x2 , . . . , xn } We shall express the vector of independent variables in vector form as follows: x = {x1 x2 · · · xn } ˜ Thus the function can be expressed as follows f (x) = f (x1 , x2 , . . . , xn ) ˜

B.2

(B.2)

(B.3)

First-Order Partial Derivatives Partial derivatives are what we get when we hold all but one of the independent variables of the function constant and differentiate with respect to that one variable. If a function is dependent on n independent variables, f (x) = f (x1 , x2 , . . . , xn ), ˜

(B.4)

Chapter B. Review of Calculus

988 then the partial derivatives of f are

fx1 =

∂f ∂ x1

fx2 =

∂f ∂ x2

···

f xn =

∂f ∂ xn

(B.5)

The notation we use for the partial derivatives of f with respect to an independent variable xi depends on what aspect of the derivative we want to emphasize: fxi =

∂f ∂ xi

Partial derivative of f with respect to xi .

∂ f fxi (x∗ ) = ∂ xi x=x∗ ˜ ˜ ˜

Partial derivative of f with respect to xi evaluated at x = x∗ ˜ ˜

A function that has a derivative at a point x∗ is said to be differentiable at x. A function that is differentiable at every point of its˜ domain is called differentiable.˜ If a function f (x) is differentiable at x∗ then f is continuous at x∗ . ˜ ˜ ˜ 

EXAMPLE

Example B.2 :

Obtain the first order partial derivative of 1 f (x) = x13 + 3 x1 x2 + x22 − 1 2 ˜ Note we have two variable, thus: fx1 =

∂f = 3 x12 + 3 x2 ∂ x1

fx2 =

∂f = 3 x1 + x2 ∂ x2 END EXAMPLE 



Example B.3 :

Obtain the first order partial derivative of 2 x2 f (x) = x + ˜ 2 cos(x1 )

EXAMPLE

B.3 Second-Order Partial Derivatives

989

Note we have two variable, thus:   ∂ 2 x2 ∂f = fx1 = ∂ x1 ∂ x1 x2 + cos(x1 ) (x2 + cos(x1 )) =

=

∂ ∂ (2 x2 ) − (2 x2 ) (x2 + cos(x1 )) ∂ x1 ∂ x1 (x2 + cos(x1 ))2

(x2 + cos(x1 )) (0) − (2 x2 ) (− sin(x1 )) 2

(x2 + cos(x1 ))   2 x2 ∂f ∂ fx2 = = ∂ x2 ∂ x2 x2 + cos(x1 ) (x2 + cos(x1 )) =

=

=

2 x2 sin(x1 ) (x2 + cos(x1 ))2

∂ ∂ (2 x2 ) − (2 x2 ) (x2 + cos(x1 )) ∂ x2 ∂ x2 (x2 + cos(x1 ))2

(x2 + cos(x1 )) (2) − (2 x2 ) (1) (x2 + cos(x1 ))2

=

2 cos(x1 ) (x2 + cos(x1 ))2 END EXAMPLE 

B.3

Second-Order Partial Derivatives If a function is dependent on n independent variables, f (x) = f (x1 , x2 , . . . , xn ), ˜

(B.6)

then the second-order partial derivatives of f with respect to x1 and x2 is fx1 x2

∂ = ∂ x1



∂f ∂ x2

 =

∂2 f ∂ x1 ∂ x2

! (B.7)

or with respect to xi and x j is

fxi x j

∂ = ∂ xi



∂f ∂xj

 =

∂2 f ∂ xi ∂ x j

! (B.8)

Chapter B. Review of Calculus

990



EXAMPLE

Example B.4 : Second order partial derivative

Obtain the second order partial derivative for the function: 1 f (x) = x13 + 3 x1 x2 + x22 − 1 2 ˜ Note we have two variable, thus:   ∂ ∂f fx1 ,x1 = = 6 x1 ∂ x1 ∂ x1 fx2 ,x1

∂ = ∂ x2



∂f ∂ x1

 =3

∂ ∂ x1



∂ = ∂ x2



fx1 ,x2 =

fx2 ,x2

∂f ∂ x2



∂f ∂ x2



=3

=1 END EXAMPLE 

B.4

Chain Rule Suppose w = f (x1 , x2 , . . . , xn ) is a differentiable function of the variables x1 , x2 , . . . , xn (a finite set) and the x1 , x2 , . . . , xn are themselves differentiable functions of the variable p, q, . . . ,t (another finite set). In other words, x1 = x1 (p, q, . . . ,t),

x2 = x2 (p, q, . . . ,t),

xn = xn (p, q, . . . ,t).

Suppose also that all the functions involved are continuous. Then w is a differentiable function of the variables p through t and the partial derivatives of w with respect to these variables are given by equations of the form: ∂w ∂p

=

∂ w ∂ x1 ∂ w ∂ x2 ∂ w ∂ xn + +···+ ∂ x1 ∂ p ∂ x2 ∂ p ∂ xn ∂ p

∂w ∂q

=

∂ w ∂ x1 ∂ w ∂ x2 ∂ w ∂ xn + +···+ ∂ x1 ∂ q ∂ x2 ∂ q ∂ xn ∂ q

.. . . = .. ∂w ∂t

=

∂ w ∂ x1 ∂ w ∂ x2 ∂ w ∂ xn + +···+ ∂ x1 ∂t ∂ x2 ∂t ∂ xn ∂t

In other words, the other equations are obtained by differentiating p, q, . . . ,t, one at a time.

B.4 Chain Rule



991

Example B.5 :

Obtain the partial derivatives with respect to x, y, z, and t for: w = xy+z

x = cost

wx =

∂w = y = sint ∂x

wy =

∂w = x = cost ∂y

wz =

∂w =1 ∂z

sint

z=t

∂w ∂w ∂x ∂w ∂y ∂w ∂z = + + ∂t ∂ x ∂t ∂ y ∂t ∂ z ∂t = (y)(− sint) + (x)(cost) + (1)(1)

wt =

= (sint)(− sint) + (cost)(cost) + (1)(1) = − sin2 t + cos2 t + 1 = cos(2t) + 1 END EXAMPLE 

Chapter B. Review of Calculus

992

B.5

Integration by parts In many engineering problems, we have to deal with functionals containing up to the second derivative of the dependent variable. For this type of problems, the Euler-Lagrange equation for a functional containing the second derivative will be a fourth-order ordinary differential equation and will need a total of four boundary conditions (two boundary conditions at each end). The governing equation is obtained by determining the conditions that will yield the stationary point of the functional: ˆ

b

I(w) =

F(w, w0 , w00 , x) dx

(B.9)

a

Using the rule of integration for variational operators, the variation becomes ˆ δI =

b

δ F(w, w0 , w00 , x) dx + · · · + Higher Order Terms

a

The first variation of the Lagrange function is defined as: δF =

∂F ∂F ∂F δw+ δ w0 + δ w00 ∂w ∂ w0 ∂ w00

(B.10)

Using Eq. B.10 and ignoring higher order terms, the variation in the functional can be written as  ˆ b ∂F ∂F ∂F 0 00 δI = δw+ δ w + δ w dx (B.11) ∂w ∂ w0 ∂ w00 a Note that in the above equation we have δ w, δ w0 and δ w00 . However, the method consists in express all variations in the integrand of Eq. B.11 as variations of δ w only. This can be accomplished by integrating the second and third terms by parts. Integration by parts is a techniques used mainly to simplify integrals of the form: ˆ

b

f (x) g(x) dx a

where f can be differentiated repeatedly to become zero and g can be integrated repeatedly without difficulty. In this course, we are mainly interested in eliminated derivatives of “δ ” quantities. In general, the integral can be expressed as follows: ˆ

ˆ

b

u(x) dv(x) = a

a

b

dv u(x) dx = dx

ˆ

b

u(x) v0 (x) dx

a

where we want to eliminate derivatives on the expression v0 (x). The easiest method method is using tabular integration. This saves a great deal of work. Basically, we make

B.5 Integration by parts

993

to columns. The first column is labelled u(x) and the second column v0 (x). In the second column we place the expression to eliminate derivatives and the rest under u(x): v0

u Every expression not

Expression to

0

included under v (x)

eliminate derivatives

In our example, integrating the second term by parts: ˆ

b

a

∂F δ w0 dx ∂ w0

(B.12)

v0

u ∂F ∂ w0 d dx



∂F ∂ w0



&+

δ w0

^−

δw

The last term always goes inside the integral along with the sign and the rest of the terms are known as boundary terms. Thus, ˆ

b

a

x=b ˆ b d  ∂ F  ∂F ∂F 0 δ w dx = δ w δ w dx − 0 x=a ∂ w0 ∂ w0 a dx ∂ w

(B.13)

Now integrating by parts the third term: ˆ

b

a

∂F δ w00 dx ∂ w00

(B.14)

v0

u ∂F ∂ w00 d dx



d2 dx2

∂F ∂ w00





∂F ∂ w00



&+

δ w00

&−

δ w0

^+

δw

Chapter B. Review of Calculus

994

Thus, ˆ b x=b d  ∂ F  x=b ˆ b d 2  ∂ F  ∂F ∂F 00 0 − δ w dx = δ w δ w δ w dx (B.15) + 00 00 00 2 dx x=a x=a ∂ w ∂ w ∂ w ∂ w00 a dx a Substituting Eqs. B.13 and B.15 into Eq. B.10, the stationary condition for the functional I leads to    ˆ b ˆ b ˆ b 2  ∂F d ∂F ∂F d δ w dx− δ w dx + δ w dx 0 2 ∂ w00 a ∂w a dx ∂ w a dx (B.16)   x=b x=b x=b ∂F d ∂F ∂F δ w + δ w0 − δ w =0 + dx ∂ w00 x=a x=a x=a ∂ w0 ∂ w00 Now we can regroup terms having the same δ w and δ w0 ,   )  ˆ b( d ∂F d2 ∂F ∂F − + 2 δ w dx ∂ w dx ∂ w0 ∂ w00 dx a (B.17)  +

d ∂F 0 − dx ∂w



∂F ∂ w00



x=b x=b ∂ F 0 δ w =0 δ w + x=a x=a ∂ w00

Expanding the boundary terms we get:    ) ˆ b( ∂F d ∂F d2 ∂F − + 2 δ w dx ∂ w dx ∂ w0 ∂ w00 dx a  +

+

∂F d 0 − dx ∂w



∂F ∂ w00



δ w

x=b

 −

∂F d 0 − dx ∂w



∂F ∂ w00



δ w

(B.18)

x=a

∂F ∂F 0 0 δ w δ w − =0 x=b x=a ∂ w00 ∂ w00

Since the boundary terms have to vanish, we get the same boundary terms given by the problem. Furthermore, since the integral has to vanish for all δ w, the integrand is zero:     ∂F d ∂F d2 ∂F − + =0 (B.19) 00 ∂ w dx ∂ w0 dx2 ∂ w And the governing equation is valid for a < x < b.

B.6 References

B.6

995

References Burden, R. L. and Faires, J. D., Numerical Analysis, Sixth Edition, Brooks/Cole Publishing Company, New York, NY. 1997. Chapters 6–7. Kreyszig, E., Advanced Engineering Mathematics, Eighth Edition, John Wiley and Sons, New York, NY. 1999. Chapter 7. Meirovitch, L., Principles and Techniques of Vibrations, Prentice Hall, New Jersey, 1997. Chapter 4. Moaveni, S., Finite Element Analysis: Theory and Applications with ANSYS, Second Edition, Prentice Hall, New Jersey, 2003. Chapter 2. Thomas, G. B., Finney R. L., Weir, M. D., and Giordano F. R. Thomas’ Calculus, Early Transcendentals Update, Tenth Edition, Addison-Wesley, Massachusetts, 2003. Entire book.

Chapter C. Elemental Matrices via Summation Approach

998

The total potential energy for a given axial bar element is given by: Π = U +V

(C.1)

where U is the total strain energy of the bar and V the potential of the applied loads. The total strain energy for an axial bar, assuming linear elastic isotropic material, reduces to ˚ 1 U= ET S dΓ 2 ˜ ˜ Γ ˚ ˚  2 1 1 du = dΓ E εxx2 dΓ = E 2 2 dx Γ Γ    2 ˆ `k  2 ¨ ˆ du  1 `k du 1  E EA = dA dx = dx 2 0 dx 2 0 dx A | {z } A(x)

where quantity EA = EA(x) is called the axial rigidity. The potential of the applied loads is opposite in sign of the work done by conservative forces: 2

V = −Q1 u1 − Q2 u2 = − ∑ Qi ui

(C.2)

i=1

Thus, total potential energy for a given bar element is given by: ˆ 2 2 1 `k Π = U +V = EA u0 dx − ∑ Qi ui 2 0 i=1

(C.3)

We proceed to discretize the total potential energy. This is done by substituting Eq. (4.8) into Eq. (C.3). Before we proceed, note that o 2 du dn = u0 (x) = N1 (x) u1 + N2 (x) u2 = N10 (x) u1 + N20 (x) u2 = ∑ Ni0 (x) ui dx dx i=1 Thus, the total potential energy for a given bar element can be discretized as follows: !2 ˆ 2 2 1 `k Π = U +V = EA(x) ∑ Ni0 (x) ui dx − ∑ Qi ui 2 0 i=1 i=1 Note that the functional Π is only a function of the nodal values Π = Π(u1 , u2 ) We are interested to minimized the functional Π with respect to the nodal displacements u1 and u2 , or find the stationary value of the functional: δΠ =

∂Π ∂Π δ u1 + δ u2 = ∂ u1 ∂ u2

2

∂Π

∑ ∂uj δuj = 0

j=1

999 Since all δ u j ’s are independent, the only way the above can be zero is if each coefficient of δ u j vanishes: ∂Π =0 ∂uj

j = 1, 2

Since we are minimizing with respect to the approximate displacement field, we will obtain equations that when solved will give an approximate solution to the exact differential equation for the problem. Note that    

o ∂ n N1 (x) u1 + N2 (x) u2 = N1 (x) ∂ u1 o ∂ n N1 (x) u1 + N2 (x) u2 = N2 (x) ∂ u2



  

!

2

∂ ∂uj

∑ Ni (x) ui

= N j (x) (C.4)

i=1

Similarly, ∂ ∂uj

!

2

∑ Ni0 (x) ui

∂ ∂uj

= N 0j (x)

i=1

!

2

∑ Qi ui

= Qj

i=1

Thus, minimizing the total energy with respect to an arbitrary nodal displacement u j in the assumed displacement function

∂Π ∂uj

=

=

=

 ˆ ∂  1 `k EA(x) ∂uj 2 0  ˆ ∂  1 `k EA(x) ∂uj 2 0

1 2

ˆ 0

`k

 ∂  EA(x) ∂uj 

!2

2

∑ Ni0 (x) ui

dx − ∑ Qi ui  = 0

i=1

i=1

!2

2



Ni0 (x) ui

i=1

2



Ni0 (x) ui



2



!2  

∂ dx −  ∂uj

i=1

!

2

∂ dx − ∂uj

∑ Qi ui

=0

i=1

(

)

2

∑ Qi ui

= 0 (C.5)

2

!

i=1

Note that  ∂  ∂uj 

2

∑ Ni0 (x) ui

i=1

!2   

2

=2

∑ Ni0 (x) ui

i=1

!

∂ ∂uj

2

∑ Ni0 (x) ui

i=1

! =2

∑ Ni0 (x) ui

i=1

N 0j (x)

Chapter C. Elemental Matrices via Summation Approach

1000 Thus ∂Π ∂uj

1 2

=

ˆ

ˆ

(

`k

EA(x)



)

Ni0 (x) ui

N 0j (x)

!

)

dx − Q j = 0

i=1

(

`k

EA(x) 0

2



Ni0 (x) ui

N 0j (x)

dx − Q j = 0

i=1



2

=

2

0

=

!

2



i=1

`k

) EA(x) N 0j (x) Ni0 (x) dx

ui − Q j = 0

0

Thus, the solution to the following system of equations minimizes the functional Π (ˆ ) `k

2



i=1

EA(x) N 0j (x) Ni0 (x) dx

ui − Q j = 0

j = 1, 2

(C.6)

0

Let us expand Eq. (C.6) for j = 1, 2: (ˆ `k

j=1: 0

|

{z

(ˆ j=2: 0

| Same as before.

EA(x) N10 (x) N10 (x) dx K11

`k



) u1 +

0

}

{z

(ˆ 0

|

EA(x) N10 (x) N20 (x) dx K12

u1 + }

)

{z

|

) EA(x) N20 (x) N10 (x) dx K21

`k

`k

u2 − Q1 = 0 } )

EA(x) N20 (x) N20 (x) dx {z

K22

u2 − Q2 = 0 }

D.1 Green-Lagrange strains

1003

Consider the quantities defined in Fig. D.1. Then derivatives of r1 with respect to r ˜ format: ˜ constitute the deformation gradient matrix, F, when arranged in Jacobian     ∂U ∂ x1 ∂ x1 ∂ x1 ∂U ∂U 1+  ∂x  ∂y ∂z   ∂x ∂y ∂z   ∂y  ∂V ∂ y1 ∂ y1  ∂V    ∂V  1 (D.1) F= 1+ =   ∂x  ∂y ∂z   ∂x ∂y ∂z   ∂z   ∂W ∂ z1 ∂ z1 ∂W ∂W 1 1+ ∂x ∂y ∂z ∂x ∂y ∂z The determinant of the deformation gradient matrix is known as the Jacobian determinant and is defined as J = det[F]

(D.2)

The displacement gradients with respect to the reference configuration are defined as     ∂U ∂U ∂U ∂ x1 ∂ x1 ∂ x1 −1  ∂x   ∂x ∂y ∂z ∂y ∂z    ∂y ∂ y1 ∂ y1  ∂V ∂V     ∂V  1 G = F−I =  −1 =    ∂x  ∂x ∂y ∂z ∂y ∂z     ∂z ∂ z1 ∂ z1 ∂W ∂W ∂W  (D.3) 1 −1 ∂x ∂y ∂z ∂x ∂y ∂z   g1 g4 g7 =  g2 g5 g8  g3 g6 g9 where I is the identity matrix. For arbitrary rigid-body motions (motions without deformations) FT F = F FT = I that is, F is an orthogonal matrix. Displacement gradient matrices are connected by the relations G = (I − J)−1 − I and J = I − (I + G)−1 For small deformations, G ≈ J−1

and J ≈ G−1

Sometimes, it is convenient to arrange the displacements gradients in vector form as follows  gT = g1 g2 g3 g4 g5 g6 g7 g8 g9 (D.4) ˜ Now, the displacement gradients for the displacement field are: ∂U(x, y, z) ∂x ∂U(x, y, z) g4 = ∂y ∂U(x, y, z) g7 = ∂z

g1 =

∂V (x, y, z) ∂x ∂V (x, y, z) g5 = ∂y ∂V (x, y, z) g8 = ∂z g2 =

∂W (x, y, z) ∂x ∂W (x, y, z) g6 = ∂y ∂W (x, y, z) g9 = ∂z g3 =

(D.5)

Chapter D. Relevant Information for Structural Analysis

1004

the Green-Lagrange strain components were given as  1 2 g1 + g22 + g23 2  1 2 ε2 = eyy = g5 + g4 + g25 + g26 2  1 2 ε3 = ezz = g9 + g7 + g28 + g29 2 ε4 = 2 eyz = g6 + g8 + g4 g7 + g5 g8 + g6 g9 ε1 = exx = g1 +

ε5 = 2 exz = g3 + g7 + g1 g7 + g2 g8 + g3 g9 ε6 = 2 exy = g2 + g4 + g1 g4 + g2 g5 + g3 g6 and were rewritten in the quadratic form 1 εi = hTi g + gT Hi g 2 ˜ ˜ ˜ ˜ The vectors hi ’s are sparse 9 × 1 vectors: ˜  hT1 = 1 0 0 0 0 0 0 0 0 ˜  hT2 = 0 0 0 0 1 0 0 0 0 ˜  hT3 = 0 0 0 0 0 0 0 0 1 ˜  hT4 = 0 0 0 0 0 1 0 1 0 ˜  hT5 = 0 0 1 0 0 0 1 0 0 ˜  hT6 = 0 1 0 1 0 0 0 0 0 ˜ The matrices Hi ’s are very sparse 9 × 9 symmetric matrices:    1 0 0 0 0 0 0 0 0 0 0  0 1 0 0 0 0 0 0 0   0 0     0 0 1 0 0 0 0 0 0   0 0     0 0 0 0 0 0 0 0 0   0 0      H2 =  H1 =  0 0 0 0 0 0 0 0 0   0 0  0 0 0 0 0 0 0 0 0   0 0     0 0 0 0 0 0 0 0 0   0 0     0 0 0 0 0 0 0 0 0   0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

0 0 0 1 0 0 0 0 0

0 0 0 0 1 0 0 0 0

0 0 0 0 0 1 0 0 0

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

             

D.1 Green-Lagrange strains

       H3 =               H5 =       

1005

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 1 0 0

0 0 0 0 0 0 0 1 0

0 0 0 0 0 0 0 0 1





            

      H4 =       

0 0 0 0 0 0 1 0 0

0 0 0 0 0 0 0 1 0

0 0 0 0 0 0 0 0 1

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

1 0 0 0 0 0 0 0 0

0 1 0 0 0 0 0 0 0

0 0 1 0 0 0 0 0 0





            

      H6 =       

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 1 0 0

0 0 0 0 0 0 0 1 0

0 0 0 0 0 0 0 0 1

0 0 0 1 0 0 0 0 0

0 0 0 0 1 0 0 0 0

0 0 0 0 0 1 0 0 0



0 0 0 1 0 0 0 0 0

0 0 0 0 1 0 0 0 0

0 0 0 0 0 1 0 0 0

1 0 0 0 0 0 0 0 0

0 1 0 0 0 0 0 0 0

0 0 1 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0



These strains are usually expressed in vectorial form as follows   Exx        Eyy        Ezz E= Eyz  ˜       Exz        Exy

            

            

Chapter D. Relevant Information for Structural Analysis

1006



Example D.1 : Green-Lagrange Linear and Nonlinear Strains

Express the state of strain in terms of the Green-Lagrange linear and nonlinear strains. The displacement field is  U(x, y, z) = 0.01 x2 + 3  V (x, y, z) = 0.01 3 y2 z W (x, y, z) = 0.01 (x + 3 z) and the state of strain at (0,2,3) is   0.000 0.000 0.005 e =  0.000 0.360 0.060  0.005 0.060 0.030 1. Linear Green-Lagrange strains. εi = hTi g ˜ ˜ where hi ’s are given in Appendix C. The linear Green-Lagrange strains are: ˜ ε1 = exx = g1 ε2 = eyy = g5 ε3 = ezz = g9 ε4 = 2 eyz = g6 + g8 ε5 = 2 exz = g3 + g7 ε6 = 2 exy = g2 + g4 where the displacement gradient is ∂U ∂U ∂U = 0.02 x = 0.000 g4 = = 0.000 g7 = = 0.000 ∂x ∂y ∂z ∂V ∂V ∂V g2 = = 0.000 g5 = = 0.06 y z g8 = = 0.03 y2 ∂x ∂y ∂z ∂W ∂W ∂W g3 = = 0.01 g6 = = 0.00 g9 = = 0.03 ∂x ∂y ∂z g1 =

EXAMPLE

D.1 Green-Lagrange strains

1007

The displacement gradient vector is       g1  0.02 x                g2  0.00            g3     0.01             g4     0.00       g= = g5 0.06 y z      ˜      g6  0.00                  g 0.00 7             2     g 0.03 y 8         g   0.03   9 and the displacement gradient matrix becomes:    0.02 x 0.0 0.01 0.00 =  0.00 G =  0.00 0.06 y z 0.03 y2  0.00 0.0 0.03 0.01 (x,y,z)=(0,2,3) The linear strains are      0.02 x  ε1                   ε2  0.06 y z                0.03 ε3 = = ε= 2 ε4       0.03 y        0.01     ε         5           0.00 ε6 (x,y,z)=(0,2,3)

0.00 0.36 0.03 0.12 0.01 0.00

0.00 0.36 0.0

 0.00 0.12  0.03

              

2. Full Green-Lagrange Strains. 1 εi = hTi g + gT Hi g ˜ ˜ 2˜ ˜ where hi ’s and Hi ’s are given in Appendix C. ˜    ε1  0.00005 + 0.02 x + 0.0002 x2            ε2  0.06 y z + 0.0018 y2 z2         ε3 0.03045 + 0.00045 y4 ε= = ε4  0.03 y2 + 0.0018 y3 z             ε   0.0103   5     ε6 0.00

       

  0.00005        0.4248        0.0376 = 0.1632               0.0103        0.00 (x,y,z)=(0,2,3)

1008

Chapter D. Relevant Information for Structural Analysis

3. Comparing both solutions (Linear and Nonlinear Green-Lagrange Strains):     exx  0.0000        e     15.2542        yy          ezz 20.3187 percentage of error = = e   26.4706      yz             e 2.9126  xz         exy 0.0000 END EXAMPLE 

D.2 Stresses at a Point in the Structure

D.2

1009

Stresses at a Point in the Structure ˆ For an infinite number of cutting planes through point P, each identified by a specific n, ˜ there will be an infinite associated stress vector T(n) for a given loading of the body. This ˜ P define the state of stress at that point. total pair of the corresponding vectors T(n) and nˆ at ˜ ˜ The stress vector will help to obtain the state of stress at a point for the Cartesian coordinate system: x–y–z. The above three equations show that a total of nine stress components describe the state of stress at a point. It is common to express these stress equations in each mutually orthogonal planes as      σxx τxy τxz  nx   Tx  Ty =  τxy σyy τyz  ny (D.6)     Tz τxz τyz σzz nz where σ is the stress tensor and nˆ the unit normal to the plane. ˜

D.2.1

Cauchy’s Stress Tensor The stress tensor contains the nine stress components and we defined it as follows   σxx τxy τxz σ =  τxy σyy τyz  (D.7) τxz τyz σzz All normal and shear stress components fully characterize the state of stress at a point. Normal stresses are those stresses perpendicular (normal) to the plane on which they act; and shear stresses, τ, are stresses parallel to the plane on which they act. Commonly, τ represents shear stresses and σ the normal stress. Typically, the stress components have two subscripts: 1. Representation: τ[plane where stress acts][direction of the stress] 2. Explanation: (a) The first index represents the direction of the plane on which it acts (b) The second index represents the direction of the stress in the plane. 3. Example: τzx is the shear stress acting on the z-plane in the direction of x. The convention is such that a stress component acting on the x-plane, will be positive if acting toward the positive x-axis. Based on our convention, if the normal stress is positive in its value, then it will be in tension; if it is negative, then it will be in compression. Positive (+) shear stresses act in the direction of an axis whose sign is the same as the sign of the axis in the direction of the outward drawn normal to the plane on which the shear stresses act.

Chapter D. Relevant Information for Structural Analysis

1010

D.2.2

Stress Measures We introduced the concept of stress in the body through the Cauchy’s formula at the beginning of the chapter. We used σ to denote the Cauchy stress tensor, which is the true stress in the body. However, other stress measures may be defined as functions of Cauchy’s stress tensor: 1. The first Piola-Kirchhoff stress tensor P P = J σ F−T where J is the Jacobian determinant, and F the deformation gradient matrix as defined by Eq. (D.1). The first Piola-Kirchhoff stress tensor is nonsymmetric. 2. The second Piola-Kirchhoff (PK2) stress tensor S S = J F−1 σ F−T where J is the Jacobian determinant, σ the Cauchy (true) stresses, and F the deformation gradient matrix as defined by Eq. (D.1). The second Piola-Kirchhoff stress tensor is symmetric. The stresses corresponding to the Green-Lagrange strains are the second Piola-Kirchhoff stresses. The three dimensional tensor in Cartesian coordinates is     Sxx Sxy Sxz Sxx Sxy Sxz S =  Syx Syy Syz  =  Sxy Syy Syz  (D.8) Szx Szy Szz Sxz Syz Szz It can be shown that the PK2 stresses are linearly related to the Cauchy stresses as follows S = S0 + J F−1 σ F−T

(D.9)

where S0 are the prestresses, J the Jacobian determinant, F the deformation gradient matrix, S the PK2 stresses, and σ the Cauchy (true) stresses. From continuity equation, we know that the total mass of the entire body must be conserved: ρ1 dΓ1 = ρ dΓ

⇒ ⇒

ρ1 det[F] dΓ = ρ dΓ ρ dΓ1 J = det[F] = = dΓ ρ1

(D.10a) (D.10b)

where dΓ1 and dΓ are the volumes in the current configuration and reference configuration, respectively; ρ1 and ρ are the mass densities in the current and reference configuration, respectively. Assuming that isochoric deformation takes place (volume-preserving deformation), J = det[F] =

dΓ1 ρ = =1 dΓ ρ1

D.3 Constitutive Equations for Linear Elastic Materials

1011

Also, we assume that the prestressed state in the reference configuration, S0 , is zero. Further, recall that we restrict our analysis to small deformations and small strains. Under these assumptions, it can be shown that the PK2 and Cauchy stresses coalesce. Thus, Eq. (D.9) reduces to S≈σ

(D.11)

and these stresses are usually expressed in vectorial form as follows   Sxx        Syy        Szz S= Syz  ˜       Sxz        Sxy In short, the Cauchy stress works with the Almansi strain or Green-Cauchy strain, and the Green-Lagrange strain works with the second Piola-Kirchhoff stress tensor. For small deformation, no difference are made between the two of them.

D.3

Constitutive Equations for Linear Elastic Materials This section focuses on determining the relationship between the internal stresses and strains within the structural components. Equations describing stress-strain behavior are often called constitutive equations.

D.3.1

Hooke’s Law Symbolically, we can write the constitutive equations for elastic behavior in its most general for as S = G(ε) ˜ ˜ where G is a symmetric tensor-valued function, S and ε are any of the stress and strain ˜ ˜ tensors, respectively. Within this context the constitutive equations for linear elastic behavior are written as S = Dε ˜ ˜ where the tensor of elastic coefficients has 81 components. It can be shown that for the three-dimensional anisotropic Hookean strain formulation is given by      Sxx  D11 D12 D13 D14 D15 D16  exx             D12 D22 D23 D24 D25 D26   Syy  eyy                D13 D23 D33 D34 D35 D36  Szz e zz  = (D.12)     Syz    D14 D24 D34 D44 D45 D46    γyz          D15 D25 D35 D45 D55 D56       Sxz    γxz       Sxy D16 D26 D36 D46 D56 D66 γxy

Chapter D. Relevant Information for Structural Analysis

1012

The above is known as the inverted form of the Hooke’s Law. Then the Hooke’s Law is defined as      exx  C11 C12 C13 C14 C15 C16  Sxx              eyy  C12 C22 C23 C24 C25 C26  Syy                 ezz C C C C C C S zz 13 23 33 34 35 36  = (D.13)     γyz    C14 C24 C34 C44 C45 C46    Syz          C15 C25 C35 C45 C55 C56       γxz    Sxz       γxy C16 C26 C36 C46 C56 C66 Sxy where matrix C is the elastic compliance material constant matrix and is defined as: C = D−1 For isotropic materials it can be shown that G=

E 2(1 + ν)

(D.14)

The stress-strain relationship for normal components can be also expressed in matrix form as follows:      1 −ν −ν  Sxx   exx  1 eyy 1 −ν  Syy =  −ν (D.15)  E    ezz −ν −ν 1 Szz Thus the number of independent elastic constants reduces to two and the elastic matrix is symmetric regardless of the existence of a strain energy function. For orthotropic materials, it reduces to: S = DE ˜ ˜  Sxx     Syy    Szz S= S  yz    Sxz    Sxy

       



   =          

D11 D21 D31 0 0 0

D12 D22 D32 0 0 0

D13 D23 D33 0 0 0

0 0 0 D44 0 0

0 0 0 0 D55 0

and for isotropic materials it further reduces to:  1−ν ν ν   ν 1−ν ν     ν ν 1−ν  E  D= (1 + ν)(1 − 2 ν)   0 0 0    0 0  0  0

0

0

0 0 0 0 0 D66

               

exx eyy ezz 2 eyz 2 exz 2 exy

              

0

0

0



0

0

0

0

0

0

1−2 ν 2

0

0

0

1−2 ν 2

0

              

0

0

1−2 ν 2

D.3 Constitutive Equations for Linear Elastic Materials

D.3.2

1013

Consequences of Planes Stress Assumption in Bars and Beams For the analysis of elastic bars and beams,     Sxx  Sxx              Syy  0              Szz 0 S= = Syz    0            Sxz  0              Sxy 0 Although the assumed displacement field suggests that     exx  exx           0     eyy              0 ezz = E= 2 eyz  ˜     0       0     2 exz              0 2 exy Because of the Poisson’s ratio, eyy and ezz cannot be zero. Note that the shear strains and stresses are identical zero for Euler-Bernoulli Beam analysis. Hence, the constitutive relationship reduces to (for orthotropic materials)      Sxx  exx  D11 D12 D13 0 0 0              eyy  D21 D22 D23 0 0 0  0                 ezz D31 D32 D33 0 0 0  0   = S= 0 0 D44 0 0    2 eyz    0  0             2 exz  0 0 0 0 D 0 0     55         0 0 0 0 0 D66 0 2 exy Hence, the above can be simplified to      D11 D12 D13  exx   Sxx  0 eyy S= =  D21 D22 D23      0 D31 D32 D33 ezz Hence, the above can be simplified to      D11 D12 D13  exx   Sxx  0 eyy S= =  D21 D22 D23      0 D31 D32 D33 ezz The three equations are Sxx = D11 exx + D12 eyy + D13 ezz Syy = D21 exx + D22 eyy + D23 ezz = 0 Szz = D31 exx + D32 eyy + D33 ezz = 0

Chapter D. Relevant Information for Structural Analysis

1014

Solving the last two equations in terms of exx : D23 D31 − D21 D33 exx D22 D33 − D23 D32 (D21 D32 − D22 D31 ) exx ezz = D22 D33 − D23 D32

eyy =

Now, substitute into the first equation to get Sxx = D¯ 11 exx where, D13 (D21 D32 − D22 D31 ) + D12 (D23 D31 − D21 D33 ) + D11 (D22 D33 − D23 D32 ) D¯ 11 = D22 D33 − D23 D32 Now, we proceed to do static condensation to eliminate eyy and ezz from the above equations, as we did in the previous chapter, to get Sxx = D¯ 11 exx We can show that for isotropic materials, D¯ 11 = E. Hence, ¯ = [E] D Hence, ¯E S=D ˜ ˜ ¯ The matrix D is known as the statically condensed, or sometimes reduced, elastic coefficient matrix. Now, let us proceed to discretize the axial bar to obtain our finite element equations.

D.4

Internal Strain Energy When loads are applied to a structure, the material of the structural element will deform. In the process the external work done by the loads will be converted by the action of either normal or shear stress into internal work called strain energy, provided that no energy is lost in the form of heat. Hence, the strain energy is stored in the body and we use the symbol U to designate strain energy. The unit of strain energy is [N–m] in SI and [lb–in] in English. Strain energy is always a positive scalar quantity even if the stress is compressive because stress and strain are always in the same direction. When an external force acts upon an elastic body and deforms it, the work done by the force is stored within the body in the form of strain energy. In the case of elastic deformation, the total strain energy density due to a general state of stress is o 1 1n (D.16) u = ST ε = Sxx εxx + Syy εyy + Szz εzz + Sxy εxy + Sxz εxz + Syz εyz 2˜ ˜ 2

D.4 Internal Strain Energy Then total strain energy due to a general state of stress is ˚ o 1n Sxx εxx + Syy εyy + Szz εzz + Sxy εxy + Sxz εxz + Syz εyz dVol U= 2 Vol

Material that have a strain energy function are known as hyperelastic materials.

1015

(D.17)

Chapter E. Damping Matrix

1018

and the coefficients ak are calculated from the following r simultaneous equations ξi =

1 n (2r−3) ∑ ar−1 ωi 2 r=1

(E.2)

where n represents the total number of modes, ξi the i-th mode damping ratio, M the global mass matrix, and KL the global linear stiffness matrix. When r > 2, the above matrix could be a fully populated matrix, increasing the cost of analysis. For most practical purposes taking r = 2 (Rayleigh damping) is adequate. A disadvantage of Rayleigh damping is that the higher modes are considerably more damped than the lower modes, for which the Rayleigh constants have been selected. Rayleigh damping is obtained as follows C = a0 M + a1 KL

(E.3)

where constants ak are found from Eq. (E.2) 2 ξ1 ω1 = a0 + a1 ω12 2 ξ2 ω2 = a0 + a1 ω22

(E.4)

In the second method, damping effect is considered as hysteresis effect. This method can be considered at the element basis. The stiffness matrix can be rewritten as Ke = (1 + i ζ ) K

(E.5)

√ where, ζ is the structural damping or loss factor and i = −1. Generally, the Rayleigh damping suffices the purposes of structural dynamics analysis.

1020

F.1

Chapter F. 2D Finite Element Method Implementation in MATLAB

Introduction The finite element code presented here was developed in MATLAB to solve the displacements, stresses, and strains of any arbitrary two-dimensional structure under applied point loads and essential boundary conditions. The code matches well with Abaqus results. The code itself can use linear triangular and linear quadrilateral elements under plane stress or plane strain conditions. The user can also specify either a two-point or three-point Gauss quadrature for numerical integration. The entry of nodal positions, constraints, and loads is accomplished through text-input files, and the results of the computation are automatically written out to text output files.

F.2

Formulation of Governing Equations One must always begin with the governing partial differential equations whenever formulating a finite element. The weak form of the problem is developed as it reduces the continuity requirements and the approximation function only needs to satisfy the essential boundary conditions of the problem. Start by with the strong form in 2D: where

σT DE+b = 0 ˜ ˜ ˜ ˜

E = Lu ˜ ˜ Here, D represents the constitutive relationships and can be specified by the user to be either plane stress or plane strain:   1 v 0 E  v 1 0  Plane Stress: D =  2 1 − v 1−v 0 0 2   1−v v 0 E  v  1−v 0 Plane Strain: D =   1 − 2v (1 + v)(1 − 2v) 0 0 2 The weak form is developed by using the following steps: 1. Multiply the residual function by a weight function and integrate by parts: ¨ ¨ h i − L w · DL u + w · b dA + w · P dA = 0 ˜ ˜ ˜ ˜ ˜ ˜ ˜ 2. Discretize the weak form: u → N d and w → NT ˜ ˜ ˜ ¨ ¨ h i LNT DLN d − NT b dA − NT · P dA = 0 ˜ ˜ ˜ ˜

F.2 Formulation of Governing Equations





ˆ



T

|

1021

T

B DB dA d = ˜ {z } |

N b dA + ˜ {z

K

 T

where B , LN

N P dl ˜

(F.1)

}

Q ˜

Equation (F.1) represents the discretized weak form of the elasticity equations. In the discretization, N represents the shape functions and these shape functions differ depending on the type of element chosen. In the MATLAB FEA.m code, the user can specify either linear quadrilateral or linear triangular elements. The vector B represents the derivative of the displacement field and is known as the strain-displacement operator. The expansion of the displacement fields and strain displacement operator for an element with n nodes element is as follows:   u1       v1  u N1 0 N2 0 . . . Nn 0  .  =  .  v 0 N1 0 N2 · · · 0 Nn  .   un  vn 

∂ N1  ∂x    B = LN =  0    ∂ N1 ∂y

0 ∂ N1 ∂y ∂ N1 ∂x

...

∂ Nn ∂x

...

0

...

∂ Nn ∂y

 0   ∂ Nn    ∂y   ∂ Nn  ∂x

The shape functions themselves must satisfy two properties: partition unity and Kronecker delta. The former ensures that the summation of all n shape functions is always unity. The latter ensures that the shape function defined for node k is zero at nodes i 6= k and unity at node i = k.

1022

F.2.1

Chapter F. 2D Finite Element Method Implementation in MATLAB

Isoparametric Formulation In global coordinates, numerical integration of Equation (F.1) becomes cumbersome, and in addition every element will have a unique shape function. To remedy this, isoparametric formulation maps the actual element domain into a standard element domain, such that the shape functions are the same for every element and so that numerical integration can be applied readily using Gaussian Quadrature rules. Using this isoparametric transformation, the weak form takes the following characteristic: 1. Triangular Elements: (a) Stiffness matrix: ˆ 1 ˆ 1−s BT DB |J| drds 0

0

(b) Jacobian 

∂x  dr J=  ∂x ds

 ∂y dr   ∂y  dx

(c) Shape Functions N1 = 1 − r − s ,

N2 = r

,

N3 = s

2. Quadrilateral Elements: (a) Stiffness matrix: ˆ 1ˆ 1 BT DB |J| dξ dη −1 −1

(b) Jacobian ∂x  dξ J=  ∂x dη 

 ∂y dξ   ∂y  dη

(c) Shape Functions 1 N1 = (1 − ξ )(1 − η), 4

1 N2 = (1 + ξ )(1 − η) 4

1 N3 = (1 + ξ )(1 + η), 4

1 N4 = (1 − ξ )(1 + η) 4

F.2 Formulation of Governing Equations

1023

As before, the shape functions satisfy both Kronecker delta and partition unity properties. However, isoparametric formulation results in the same shape function for every element, and the element domain is the same for every element. The actual geometry of the element is captured within the Jacobian; therefore, the numerical evaluation of the integrals can be accomplished through Gauss Quadrature.

F.2.2

Gauss Quadrature Rather than performing numerical integrations directly in the actual element domain, the integrals are calculated in the isoparametric domain. Gauss Quadrature points for either linear quadrilateral or linear triangular elements can be readily used in the standard isoparametric domain. The formulation for both element types is shown below: 1. Triangular Elements: ˆ 1ˆ 0

1−s

0

1 [BT DB] |J| drds → 2 | {z } ϕ

N

∑ wi ϕ (ri , si )

j=1

2. Quadrilateral Elements: ˆ

1

−1

ˆ

1

N

N

BT DB |J| dξ dη → ∑ ∑ wi w j ϕ (ξi , η j ) −1 | {z } i=1 j=1 ϕ

Two-point and three-point Gauss Quadrature tables were implemented within the MATLAB FEA.m code, each corresponding to either triangular or quadrilateral elements, with the user having the option of specifying the number of integration points. Note that because the integrand for triangular elements will be constant, the number of integration points will be inconsequential.

1024

F.3

Chapter F. 2D Finite Element Method Implementation in MATLAB

MATLAB Implementation The implementation of the FEM procedure into the MATLAB script involved three main parts: First, the user-specified input file is read, shape functions are defined, quadrature tables are defined, and element properties are assigned. Function handles were used for the shape functions and their derivatives to evaluate the functions later explicitly. In the second part of the code, the local element stiffness matrix K is calculated for each element. Here, the appropriate Gauss Quadrature tables were used depending on the type of element being used. Since the code only assumed concentrated loads, the local load vector calculation was not required in this step. Finally, in the last part of the code, all local stiffness matrices were assembled into a global stiffness matrix for all unconstrained degrees of freedom. An internal code number system took user-specified node numbers and created an internal specification of each node corresponding to x- and y-displacements. The global load vector was also assembled by assigning the appropriate user-specified loads. Finally, with this information, the displacements were solved by inverting the stiffness matrix from the resulting global assembly: d = K−1 Q. ˜ ˜

F.3.1

User Input Files The user needs only specifies node numbers that make up each element (in a counterclockwise direction), the node position, any concentrated point loads, and the physical parameters of the structure. The goal was to allow the user to enter this information in a similar fashion as the way it is implemented in Abaqus. The following four fields are specified in the input file by the user: nodes nodePos elemProp cload

node numbers of each element in a CCW direction x-position y-position x-constraint y-constraint Young’s Modulus Poisson’s Ratio node number x-load y-load

A comma delimiter separates all fields, and each block is terminated with an end line. The x-constraint and y-constraint fields within the nodePos block are set to either zero if the node is unconstrained, or unity if the node is constrained in a particular direction. Before execution, the inputRead function takes in the data from the text file and assigns it to the appropriate variables. This function also checks to ensure that all values are adequately defined and returns an error and warning messages if any issues are detected.

F.3 MATLAB Implementation

F.3.2

1025

Control Parameters In addition to the input file, the user can control several other parameters declared at the top of the FEA.m script. The functionality of each parameter is defined below: inputNmae arcaysize iFig iPlot df iQuad C type

F.3.3

Indicate the name of the input.datfile Indicates the resolution of the stress and strain contour plots Figure start number Plot Options Deformation Scale Factor Number of Quadrature Points to Use Constitutive Relationship (1 = Plane Stress, 2 = Plane Strain)

Output Files For easy verification, the FEA.m code automatically generates output files with a summary of the input data and the calculated displacements at each node. It should be noted that, like Abaqus, the FEA.m code makes no distinction between measurement systems, so it is up to the user to ensure that all inputs are entered in consistent units.

F.3.4

Summary of all Results To verify the code, two separate problems were simulated quantitatively, comparing the displacement fields and qualitatively comparing stress and strain contour plots against the results produced by Abaqus. Very close agreement was found between the two programs. Two-point loads of opposite signs were applied to a simple rectangular plate’s endpoints under plane stress in the first problem. This problem was first solved using linear quadrilateral elements and then with linear triangular elements. The purpose of this problem was to show the inherent disadvantages that can arise with the use of linear triangular elements. Namely, the strain displacement operator for these elements is constant, and therefore, the stress and strain within each element are constant. In the second problem, an arbitrarily complicated geometry was constructed, and loads were applied in both the x- and y-directions. The purpose was to show that the MATLAB code works for any conceivable two-dimensional structure under concentrated loads – a remarkable property of finite element analysis! Here, only linear quadrilateral elements were used due to their superior accuracy compared to triangular elements. Excellent agreement was found for all test cases. The following sections present these results.

1026

F.4

Chapter F. 2D Finite Element Method Implementation in MATLAB

Problem 1-A: Linear Quadrilateral Elements In problem 1a, the FEA program was used to solve a simple geometry using linear quadrilateral elements. Table 1 shows that the MATLAB results are in agreement with Abaqus exactly for all metrics: displacements, stresses, and strains. It should be noted that near-perfect agreement between the codes does not imply that the results are physically correct. Caution should be exercised when employing full integration with quadrilateral elements. One must always be wary of spurious modes. With only one integration point in the quadrature scheme, certain stretching modes may not be sensed. This can be remedied through hourglass control. Abaqus Input File nodes 2,6,7,4 6,5,8,7 5,1,3,8 end nodePos 3,0,0,0 0,0,1,1 3,1,0,0 0,1,1,1 2,0,0,0 1,0,0,0 1,1,0,0 2,1,0,0 end elemProp 200*10^9,0.33 end cLoad 1,-1*10^6,0 3,1*10^6,0 end

F.4.1

Displacement Profile

F.4 Problem 1-A: Linear Quadrilateral Elements

1027 Elasticity Results (Deformation Scale Factor

1665)

1.5

y-position

14

7

8

3

6

5

1

0.5

02

-0.5 original displaced 0

a) ABAQUS

0.5

1

1.5 x-position

2

2.5

3

b) MATLAB

Figure F.1: Displacement Profile using Linear Quadrilateral Elements. Table F.1: Problem 1-A: Displacement Comparison (Linear Quadrilateral Elements)

Node 1 2 3 4 5 6 7 8

F.4.2

Abaqus u v −6.0074E − 05 −1.8022E − 04 −1.0000E − 30 5.6052E − 45 6.0074E − 05 −1.8022E − 04 1.0000E − 30 4.2039E − 45 −4.0049E − 05 −8.0099E − 05 −2.0025E − 05 −2.0025E − 05 2.0025E − 05 −2.0025E − 05 4.0049E − 05 −8.0099E − 05

Strain Profile

FEA u v −6.0074E − 05 −1.8022E − 04 0.0000E + 00 0.0000E + 00 6.0074E − 05 −1.8022E − 04 0.0000E + 00 0.0000E + 00 −4.0049E − 05 −8.0099E − 05 −2.0025E − 05 −2.0025E − 05 2.0025E − 05 −2.0025E − 05 4.0049E − 05 −8.0099E − 05

F.5 Problem 1-B: Linear Triangular Elements

F.5

1031

Problem 1-B: Linear Triangular Elements In problem 1b, the FEA program is applied to the same structure, but this time using only linear triangular elements. Again, Table 2 shows a near-perfect match between Abaqus and FEA.m. This once again verifies that the code appropriately calculates and assembles the stiffness matrices and load vectors. In examining the contour plots, it can be seen why triangular elements are often insufficient for modeling pure bending as both Abaqus and FEA.m plots show that the stress and strain within each element remain constant. This particular property of linear triangular elements is what often makes them inferior to linear quadrilaterals. Abaqus Input File nodes 1,2,6 1,6,5 2,3,7 2,7,6 3,4,8 3,8,7 end nodePos 0,0,1,1 1,0,0,0 2,0,0,0 3,0,0,0 0,1,1,1 1,1,0,0 2,1,0,0 3,1,0,0 end elemProp 200*10^9,0.33 End cLoad 4,-1*10^6,0 8,1*10^6,0 end

1032

Displacement Profile Elasticity Results (Deformation Scale Factor

4712)

1.5

15

y-position

F.5.1

Chapter F. 2D Finite Element Method Implementation in MATLAB

6

7

8

2

3

4

0.5

01

-0.5 original displaced 0

a) ABAQUS

0.5

1

1.5 x-position

2

2.5

b) MATLAB

Figure F.8: Displacement Profile using Linear Triangular Elements. Table F.2: Problem 1-B: Displacement Comparison (Linear Triangular Elements

Node 1 2 3 4 5 6 7 8

Abaqus u v −1.0000E − 30 4.9810E − 31 −6.6766E − 06 −6.6780E − 06 −1.3409E − 05 −2.6806E − 05 −2.2016E − 05 −6.3662E − 05 1.0000E − 30 −4.9810E − 31 6.6753E − 06 −6.6739E − 06 1.3360E − 05 −2.6667E − 05 2.0372E − 05 −5.8968E − 05

FEA u v 0.0000E + 00 0.0000E + 00 −6.6766E − 06 −6.6780E − 06 −1.3409E − 05 −2.6806E − 05 −2.2016E − 05 −6.3661E − 05 0.0000E + 00 0.0000E + 00 6.6753E − 06 −6.6739E − 06 1.3360E − 05 −2.6667E − 05 2.0372E − 05 −5.8968E − 05

3

1034

Chapter F. 2D Finite Element Method Implementation in MATLAB

xy Contour

-6

x 10

1.2

6 1 4 0.8  y = -6.67 e-006

 y = -6.6 1e-006

2

 y = -5 532e-006

y-pos tion

0.6 0 0.4

xy = 6.67 e-006

xy = 6.6 1e-006

xy = 5.532e-006

-2

0.2 -4 0 -6 -0.2

0

0.5

1

a) ABAQUS

1.5 2 x-position

2.5

3

3.5

b) MATLAB

Figure F.11: Strain exy Profile using Linear Triangular Elements.

Stress Profile  xx Contour

6

x 10

1.2

1.5

1 1 0.8 xx 1.498e+006

y-position

F.5.3

 x 1.501e+006

0.5

 x 1.584e+006

0.6 0 0.4

 x -1.498e+006

x

-1.501e+006

 x -1.584e+006

-0.5 0.2 -1 0

-0.2

a) ABAQUS

-1.5 0

0.5

1

1.5 2 x-position

2.5

b) MATLAB

Figure F.12: Stress Sxx Profile using Linear Triangular Elements.

3

3.5

1036

F.6

Chapter F. 2D Finite Element Method Implementation in MATLAB

Problem 2: Linear Quadrilateral Elements The MATLAB FEA.m code is verified using a more complicated geometry. Table 3 shows a near-perfect match in the displacements at every node. The magnitudes of stresses and strains at each point were quantitatively compared, and a very close match was found. Abaqus Input File

nodes 21,31,35,30 31,21,19,20 2,6,34,5 21,29,18,19 23,22,9,10 27,32,25,26 28,24,32,27 25,23,10,11 13,26,12,3 14,27,26,13 15,28,27,14 4,16,28,15 29,24,17,18 30,22,36,21 31,5,34,35 1,5,31,20 22,30,8,9 6,7,35,34 8,30,35,7 33,32,24,29 16,17,24,28 26,25,11,12 22,23,33,36 23,25,32,33 36,33,29,21 end nodePos 0,1,1,1 0,0,1,1 4,0,0,0 3,2,0,0 0,0.5,0,0 0.5,0,0,0

F.6 Problem 2: Linear Quadrilateral Elements 1,0,0,0 1.5,0,0,0 2,0,0,0 2.5,0,0,0 3,0,0,0 3.5,0,0,0 3.75,0.5,0,0 3.5,1,0,0 3.25,1.5,0,0 2.5,1.83333337,0,0 2,1.66666663,0,0 1.5,1.5,0,0 1,1.33333337,0,0 0.5,1.16666663,0,0 1.34425139,0.884218574,0,0 1.87579596,0.362374276,0,0 2.34729695,0.381954312,0,0 2.29598641,1.27870631,0,0 2.80725431,0.432972103,0,0 3.28278184,0.469816923,0,0 3.03842568,0.945499599,0,0 2.77677631,1.40194166,0,0 1.82105589,1.12653661,0,0 1.40127754,0.409009665,0,0 0.710633457,0.755190432,0,0 2.56564474,0.874667943,0,0 2.12314081,0.780635238,0,0 0.478520691,0.271007061,0,0 0.896862268,0.378518879,0,0 1.81414878,0.657367408,0,0 end elemProp 200*10^9,0.33 end cLoad 3,2*10^6,0 4,1*10^6,-2*10^6 end

1037

1038

Displacement Profile Elasticity Results (Deformation Scale Factor

465.9)

original displaced

2

4 16 17 18

1.5

19 20 y-position

F.6.1

Chapter F. 2D Finite Element Method Implementation in MATLAB

11

21

31 0.5 5

34 02

6

36

35

30

22

7

8

9

15

28

24

29

23 10

14

27

32

33

25 11

13

26 12

3

-0.5 0

a) ABAQUS

0.5

1

1.5

2 x-position

2.5

3

b) MATLAB

Figure F.15: Displacement Profile using Linear Triangular Elements.

3.5

4

F.6 Problem 2: Linear Quadrilateral Elements

1039

Table F.3: Problem 2: Displacement Comparison (Linear Quadrilateral Elements

Node 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

Abaqus u v 0.0000E + 00 0.0000E + 00 0.0000E + 00 0.0000E + 00 −6.9545E − 05 −8.5738E − 04 4.0961E − 04 −6.6675E − 04 2.7739E − 07 1.4632E − 05 −5.4517E − 05 −4.6042E − 05 −8.8444E − 05 −1.3560E − 04 −1.1018E − 04 −2.4827E − 04 −1.2002E − 04 −3.7524E − 04 −1.1919E − 04 −5.0764E − 04 −1.0982E − 04 −6.3683E − 04 −9.3508E − 05 −7.5521E − 04 1.0471E − 05 −8.1186E − 04 1.2868E − 04 −7.6355E − 04 2.5624E − 04 −7.1442E − 04 3.4468E − 04 −5.1235E − 04 2.9097E − 04 −3.8202E − 04 2.3342E − 04 −2.5608E − 04 1.6835E − 04 −1.4207E − 04 9.3603E − 05 −4.7901E − 05 7.9670E − 05 −2.1097E − 04 −2.9862E − 05 −3.4260E − 04 −2.4242E − 05 −4.6807E − 04 1.9233E − 04 −4.5736E − 04 −8.6525E − 06 −5.9024E − 04 4.3453E − 06 −7.1003E − 04 1.1398E − 04 −6.5248E − 04 2.2805E − 04 −5.8845E − 04 1.4696E − 04 −3.3287E − 04 −1.8095E − 05 −2.2230E − 04 3.2393E − 05 −7.3179E − 05 9.4600E − 05 −5.2818E − 04 6.8947E − 05 −4.0926E − 04 −1.9010E − 05 −4.1833E − 05 −1.6859E − 05 −1.0810E − 04 3.7842E − 05 −3.2781E − 04

FEA u v 8.0000E − 30 −1.0080E − 30 −5.0000E − 30 −9.9200E − 31 −6.9747E − 05 −8.5861E − 04 4.1009E − 04 −6.6765E − 04 2.3934E − 07 1.4658E − 05 −5.4694E − 05 −4.6076E − 05 −8.8610E − 05 −1.3585E − 04 −1.1037E − 04 −2.4865E − 04 −1.2022E − 04 −3.7579E − 04 −1.1939E − 04 −5.0836E − 04 −1.1003E − 04 −6.3772E − 04 −9.3712E − 05 −7.5627E − 04 1.0436E − 05 −8.1301E − 04 1.2882E − 04 −7.6462E − 04 2.5655E − 04 −7.1540E − 04 3.4510E − 04 −5.1307E − 04 2.9133E − 04 −3.8257E − 04 2.3373E − 04 −2.5646E − 04 1.6860E − 04 −1.4228E − 04 9.3789E − 05 −4.7956E − 05 7.9762E − 05 −2.1130E − 04 −2.9944E − 05 −3.4311E − 04 −2.4315E − 05 −4.6874E − 04 1.9257E − 04 −4.5801E − 04 −8.7094E − 06 −5.9107E − 04 4.3011E − 06 −7.1102E − 04 1.1410E − 04 −6.5339E − 04 2.2832E − 04 −5.8927E − 04 1.4715E − 04 −3.3336E − 04 −1.8159E − 05 −2.2265E − 04 3.2420E − 05 −7.3281E − 05 9.4693E − 05 −5.2893E − 04 6.9007E − 05 −4.0986E − 04 −1.9010E − 05 −4.1866E − 05 −1.6915E − 05 −1.0829E − 04 3.7872E − 05 −3.2829E − 04

1040

F.7 F.7.1

Chapter F. 2D Finite Element Method Implementation in MATLAB

MATLAB Code MAIN SCRIPT FEA.m close all clear all clc %% User-Defined Inputs inputName = ’p2_q.dat’; %Resolution of Contour Plot arraySize = 10; %Flags iFig = 1; iPlot = 1; %(0) - Plot off %(1) - Plot Gemoetry & Contours %(2) - Plot only Geometry df = 4.659*10^(2); %Deformation Scale Factor iQuad = 2; %(1) - 2-point guassian quadrature %(2) - 3-point guassian quadrature %Constitutive Relationship c_type = 1; %(1) - Plane Stress %(2) - Plane Strain %% Read in Input Data [element_nodes nodePos elemProp f_cLoad] = inputRead(inputName); %% Perliminary Analysis [totalNodes,trash] = size(nodePos); [numElems, numNodes] = size(element_nodes); if numNodes == 3 elemType = 1; %Linear Triangular Elements elseif numNodes == 4 elemType = 2; %Linear Quadralateral Elements end %% Define Quadrature Tables if elemType == 2 if iQuad == 1 quad.val(1) = -0.57735027; quad.val(2) = 0.57735027; quad.w(1) = 1.0; quad.w(2) = 1.0; elseif iQuad == 2 quad.val(1) = -0.77459667; quad.val(2) = 0.0; quad.val(3) = 0.77459667; quad.w(1) = 0.55555555555; quad.w(2) = 0.88888888889; quad.w(3) = 0.55555555555;

F.7 MATLAB Code

1041

end elseif elemType == 1 %Table B.2 if iQuad == 1 quad.r(1) = 1/3; quad.s(1) = 1/3; quad.w(1) = 1.0; elseif iQuad == 2 quad.r(1) = 0; quad.r(2) = 1/2; quad.r(3) = 1/2; quad.s(1) = 1/2; quad.s(2) = 0; quad.s(3) = 1/2; quad.w(1) = 1/3; quad.w(2) = 1/3; quad.w(3) = 1/3; end end % Assemble Element Geometry for ii=1:numNodes for jj=1:numElems kk = 1; for qq=1:numNodes elem(jj).xpos(qq) = nodePos(element_nodes(jj,qq),1); elem(jj).ypos(qq) = nodePos(element_nodes(jj,qq),2); elem(jj).nodes(qq) = element_nodes(jj,qq); elem(jj).code(kk) = elem(jj).nodes(qq)*10; elem(jj).constraint(kk) = nodePos(element_nodes(jj,qq),3); elem(jj).code(kk+1) = elem(jj).nodes(qq)*10+1; elem(jj).constraint(kk+1) = nodePos(element_nodes(jj,qq),4); kk = kk+2; end end end % Assign Loads to Each Element for kk=1:numElems for ii=1:length(elem(kk).code); for jj=1:length(elem(kk).nodes) if (exist(’f_cLoad’,’var’) == 1) if ismember(elem(kk).code(ii),f_cLoad(:,1)*10) == 1 [index_gload] = find(abs(f_cLoad(:,1)*10-elem(kk).code(ii))==0); elem(kk).load(ii) = f_cLoad(index_gload,2); elseif ismember(elem(kk).code(ii),(f_cLoad(:,1)*10+1)) == 1 [index_gload] = find(abs((f_cLoad(:,1)*10+1)-elem(kk).code(ii))==0); elem(kk).load(ii) = f_cLoad(index_gload,3); end else

1042

Chapter F. 2D Finite Element Method Implementation in MATLAB elem(kk).load(ii) = 0; end end

end end %Constitutive Relations E = elemProp(1); nu = elemProp(2); if c_type == 1 %Plane Stress E_matrix = E/(1-nu^2)*[... 1,nu,0;... nu,1,0;... 0,0,(1-nu)/2;... ]; elseif c_type == 2 %Plane Strain E_matrix = E/((1+nu)*(1-2*nu))*[... (1-nu), nu, 0;... nu, (1-nu), 0;... 0, 0, (1-2*nu)/2;... ]; end %Define Shape Functions if elemType == 1 N1 = @(r,s) 1-r-s; N2 = @(r,s) r; N3 = @(r,s) s; dN1_dr = @(r,s) -1; dN2_dr = @(r,s) 1; dN3_dr = @(r,s) 0; dN1_ds = @(r,s) -1; dN2_ds = @(r,s) 0; dN3_ds = @(r,s) 1; elseif elemType == 2 N1 = @(xi,eta) 1/4*(1-xi)*(1-eta); N2 = @(xi,eta) 1/4*(1+xi)*(1-eta); N3 = @(xi,eta) 1/4*(1+xi)*(1+eta); N4 = @(xi,eta) 1/4*(1-xi)*(1+eta); dN1_dxi = @(xi,eta) 1/4*(-1+eta); dN2_dxi = @(xi,eta) 1/4*(1-eta); dN3_dxi = @(xi,eta) 1/4*(1+eta); dN4_dxi = @(xi,eta) 1/4*(-1-eta); dN1_deta = @(xi,eta) 1/4*(-1+xi); dN2_deta = @(xi,eta) 1/4*(-1-xi); dN3_deta = @(xi,eta) 1/4*(1+xi); dN4_deta = @(xi,eta) 1/4*(1-xi); end %Assign Shape Function

F.7 MATLAB Code for ii=1:numElems if elemType == 1 elem(ii).x_iso = @(r,s) elem(ii).xpos(1)*N1(r,s)... + elem(ii).xpos(2)*N2(r,s)... + elem(ii).xpos(3)*N3(r,s); elem(ii).y_iso = @(r,s) elem(ii).ypos(1)*N1(r,s)... + elem(ii).ypos(2)*N2(r,s)... + elem(ii).ypos(3)*N3(r,s); elseif elemType == 2 elem(ii).x_iso = @(xi,eta) elem(ii).xpos(1)*N1(xi,eta)... + elem(ii).xpos(2)*N2(xi,eta)... + elem(ii).xpos(3)*N3(xi,eta)... + elem(ii).xpos(4)*N4(xi,eta); elem(ii).y_iso = @(xi,eta) elem(ii).ypos(1)*N1(xi,eta)... + elem(ii).ypos(2)*N2(xi,eta)... + elem(ii).ypos(3)*N3(xi,eta)... + elem(ii).ypos(4)*N4(xi,eta); end end; %% Evaluate Stiffness Matrix for Each Element %Define Jacobian for ii=1:numElems if elemType == 1 elem(ii).J11 = @(r,s) elem(ii).xpos(1)*dN1_dr(r,s)... + elem(ii).xpos(2)*dN2_dr(r,s)... + elem(ii).xpos(3)*dN3_dr(r,s); elem(ii).J12 = @(r,s) elem(ii).ypos(1)*dN1_dr(r,s)... + elem(ii).ypos(2)*dN2_dr(r,s)... + elem(ii).ypos(3)*dN3_dr(r,s); elem(ii).J21 = @(r,s) elem(ii).xpos(1)*dN1_ds(r,s)... + elem(ii).xpos(2)*dN2_ds(r,s)... + elem(ii).xpos(3)*dN3_ds(r,s); elem(ii).J22 = @(r,s) elem(ii).ypos(1)*dN1_ds(r,s)... + elem(ii).ypos(2)*dN2_ds(r,s)... + elem(ii).ypos(3)*dN3_ds(r,s); elseif elemType == 2 elem(ii).J11 = @(xi,eta) elem(ii).xpos(1)*dN1_dxi(xi,eta)... + elem(ii).xpos(2)*dN2_dxi(xi,eta)... + elem(ii).xpos(3)*dN3_dxi(xi,eta)... + elem(ii).xpos(4)*dN4_dxi(xi,eta); elem(ii).J12 = @(xi,eta) elem(ii).ypos(1)*dN1_dxi(xi,eta)... + elem(ii).ypos(2)*dN2_dxi(xi,eta)... + elem(ii).ypos(3)*dN3_dxi(xi,eta)... + elem(ii).ypos(4)*dN4_dxi(xi,eta); elem(ii).J21 = @(xi,eta) elem(ii).xpos(1)*dN1_deta(xi,eta)... + elem(ii).xpos(2)*dN2_deta(xi,eta)... + elem(ii).xpos(3)*dN3_deta(xi,eta)...

1043

1044

Chapter F. 2D Finite Element Method Implementation in MATLAB + elem(ii).xpos(4)*dN4_deta(xi,eta); elem(ii).J22 = @(xi,eta) elem(ii).ypos(1)*dN1_deta(xi,eta)... + elem(ii).ypos(2)*dN2_deta(xi,eta)... + elem(ii).ypos(3)*dN3_deta(xi,eta)... + elem(ii).ypos(4)*dN4_deta(xi,eta);

end end % Evaluate [K] Using Guassian Qudrature for ii=1:numElems kk = 1; if elemType == 1 for qq=1:length(quad.w) r = quad.r(qq); s = quad.s(qq); J = [elem(ii).J11(r,s), elem(ii).J12(r,s);... elem(ii).J21(r,s), elem(ii).J22(r,s)]; dN1 = J^(-1)*[dN1_dr(r,s); dN1_ds(r,s)]; dN2 = J^(-1)*[dN2_dr(r,s); dN2_ds(r,s)]; dN3 = J^(-1)*[dN3_dr(r,s); dN3_ds(r,s)]; B = [dN1(1), 0, dN2(1), 0, dN3(1), 0;... dN1(2), dN1(1), dN2(2), dN2(1), dN3(2), dN3(1)]; integrand = B’*E_matrix*B*det(J); if kk == 1 quadSum = integrand*quad.w(qq)*1/2; else quadSum = quadSum + integrand*quad.w(qq)*1/2; end kk = kk+1; end elseif elemType == 2 for qq=1:length(quad.val) for tt=1:length(quad.val) xi = quad.val(qq); eta = quad.val(tt); J = [elem(ii).J11(xi,eta), elem(ii).J12(xi,eta);... elem(ii).J21(xi,eta), elem(ii).J22(xi,eta)]; dN1 = J^(-1)*[dN1_dxi(xi,eta); dN1_deta(xi,eta)]; dN2 = J^(-1)*[dN2_dxi(xi,eta); dN2_deta(xi,eta)]; dN3 = J^(-1)*[dN3_dxi(xi,eta); dN3_deta(xi,eta)]; dN4 = J^(-1)*[dN4_dxi(xi,eta); dN4_deta(xi,eta)]; B = [dN1(1), 0, dN2(1), 0, dN3(1), 0, dN4(1), 0;... 0, dN1(2), 0, dN2(2), 0, dN3(2), 0, dN4(2);... dN1(2), dN1(1), dN2(2), dN2(1), dN3(2), dN3(1), dN4(2), dN4(1)]; integrand = B’*E_matrix*B*det(J); if kk == 1 quadSum = integrand*quad.w(qq)*quad.w(tt); else

F.7 MATLAB Code

1045

quadSum = quadSum + integrand*quad.w(qq)*quad.w(tt); end kk = kk+1; end end end elem(ii).K = quadSum; end %% Assemble Global Stiffness & Load Vector %Determine Degrees of Freedom constraint_count = 0; constraint_nodes = []; for ii=1:numElems for jj=1:length(elem(ii).constraint) if elem(ii).constraint(jj) == 1 && ismember(elem(ii).code(jj),constraint_nodes) == 0 constraint_nodes = [constraint_nodes elem(ii).code(jj)]; constraint_count = constraint_count+1; end end end DOF = 2*totalNodes-constraint_count; K = zeros(DOF,DOF); K_code = elem(1).code; for kk=2:numElems K_code = [K_code elem(kk).code]; end qq=1; for kk=1:numElems for tt=1:length(elem(kk).constraint) if elem(kk).constraint(tt) == 1 K_code(qq) = []; qq = qq-1; end qq = qq+1; end end K_code = unique(K_code); for kk=1:numElems qq = 1; for tt=1:length(elem(kk).code) if ismember(elem(kk).code(tt),K_code) [index_g(qq)] = find(abs(K_code-elem(kk).code(tt))==0); index_l(qq) = tt; qq=qq+1; end end for ii=1:length(index_g)

1046

Chapter F. 2D Finite Element Method Implementation in MATLAB for jj=1:length(index_g) K(index_g(ii),index_g(jj)) = K(index_g(ii),index_g(jj)) +... elem(kk).K(index_l(ii),index_l(jj)); end

end clear index_g index_l end %% Assemble Global Load Vector Q = zeros(DOF,1); if (exist(’f_cLoad’,’var’) == 1) [rows, cols] = size(f_cLoad); for ii=1:rows if ismember(f_cLoad(ii,1)*10,K_code) index = find(abs(K_code-f_cLoad(ii)*10)==0); Q(index) = f_cLoad(ii,2); end if ismember((f_cLoad(ii,1)*10+1),K_code) index = find(abs(K_code-(f_cLoad(ii)*10+1))==0); Q(index) = f_cLoad(ii,3); end end end %% Solve KD = Q D = K^(-1)*Q; %% Calculate Stress/Strain for Each Element for kk=1:numElems for ii=1:numNodes if ismember(elem(kk).nodes(ii)*10,K_code) [index] = find(abs(K_code-elem(kk).nodes(ii)*10)==0); elem(kk).u_disp(ii) = D(index); else elem(kk).u_disp(ii) = 0; end if ismember((elem(kk).nodes(ii)*10+1),K_code) [index] = find(abs(K_code-(elem(kk).nodes(ii)*10+1))==0); elem(kk).v_disp(ii) = D(index); else elem(kk).v_disp(ii) = 0; end elem(kk).xpos_f(ii) = elem(kk).xpos(ii)+elem(kk).u_disp(ii); elem(kk).ypos_f(ii) = elem(kk).ypos(ii)+elem(kk).v_disp(ii); end end globe.X = zeros(100,100); for ii=1:numElems kk = 1; if elemType == 1

F.7 MATLAB Code

1047

r_array = linspace(0,1,arraySize); s_array = linspace(0,1,arraySize); for mm=1:arraySize for nn=1:arraySize r_f = 1-s_array(mm); r_i = 0; r = (nn-1)*(r_f-r_i)/(arraySize-1)+r_i; s = (mm-1)*1/(arraySize-1); J = [elem(ii).J11(r,s), elem(ii).J12(r,s);... elem(ii).J21(r,s), elem(ii).J22(r,s)]; dN1 = J^(-1)*[dN1_dr(r,s); dN1_ds(r,s)]; dN2 = J^(-1)*[dN2_dr(r,s); dN2_ds(r,s)]; dN3 = J^(-1)*[dN3_dr(r,s); dN3_ds(r,s)]; B = [dN1(1), 0, dN2(1), 0, dN3(1), 0;... 0, dN1(2), 0, dN2(2), 0, dN3(2);... dN1(2), dN1(1), dN2(2), dN2(1), dN3(2), dN3(1)]; N = [N1(r,s), 0, N2(r,s), 0, N3(r,s), 0;... 0, N1(r,s), 0, N2(r,s), 0, N3(r,s)]; pos = N*[elem(ii).xpos_f(1);elem(ii).ypos_f(1);... elem(ii).xpos_f(2);elem(ii).ypos_f(2);... elem(ii).xpos_f(3);elem(ii).ypos_f(3)]; strain_vector = B*[elem(ii).u_disp(1);elem(ii).v_disp(1);... elem(ii).u_disp(2);elem(ii).v_disp(2);... elem(ii).u_disp(3);elem(ii).v_disp(3)]; elem(ii).eps_xx(mm,nn) = strain_vector(1); elem(ii).eps_yy(nn,mm) = strain_vector(2); elem(ii).eps_xy(nn,mm) = strain_vector(3); stress_vector = E_matrix*strain_vector; elem(ii).sig_xx(nn,mm) = stress_vector(1); elem(ii).sig_yy(nn,mm) = stress_vector(2); elem(ii).sig_xy(nn,mm) = stress_vector(3); elem(ii).X(nn,mm) = pos(1); elem(ii).Y(nn,mm) = pos(2); min_eps_xx(ii) = min(min(elem(ii).eps_xx)); max_eps_xx(ii) = max(max(elem(ii).eps_xx)); end end elseif elemType == 2 xi_array = linspace(-1,1,arraySize); eta_array = linspace(-1,1,arraySize); for mm=1:length(xi_array) for nn=1:length(eta_array) xi = xi_array(mm); eta = eta_array(nn); J = [elem(ii).J11(xi,eta), elem(ii).J12(xi,eta);... elem(ii).J21(xi,eta), elem(ii).J22(xi,eta)]; dN1 = J^(-1)*[dN1_dxi(xi,eta); dN1_deta(xi,eta)];

1048

Chapter F. 2D Finite Element Method Implementation in MATLAB dN2 dN3 dN4 B =

= J^(-1)*[dN2_dxi(xi,eta); dN2_deta(xi,eta)]; = J^(-1)*[dN3_dxi(xi,eta); dN3_deta(xi,eta)]; = J^(-1)*[dN4_dxi(xi,eta); dN4_deta(xi,eta)]; [dN1(1), 0, dN2(1), 0, dN3(1), 0, dN4(1), 0;... 0, dN1(2), 0, dN2(2), 0, dN3(2), 0, dN4(2);... dN1(2), dN1(1), dN2(2), dN2(1), dN3(2), dN3(1), dN4(2), dN4(1)]; N = [N1(xi,eta), 0, N2(xi,eta), 0, N3(xi,eta), 0, N4(xi,eta), 0;... 0, N1(xi,eta), 0, N2(xi,eta), 0, N3(xi,eta), 0, N4(xi,eta)]; pos = N*[elem(ii).xpos_f(1);elem(ii).ypos_f(1);... elem(ii).xpos_f(2);elem(ii).ypos_f(2);... elem(ii).xpos_f(3);elem(ii).ypos_f(3);... elem(ii).xpos_f(4);elem(ii).ypos_f(4)]; strain_vector = B*[elem(ii).u_disp(1);elem(ii).v_disp(1);... elem(ii).u_disp(2);elem(ii).v_disp(2);... elem(ii).u_disp(3);elem(ii).v_disp(3);... elem(ii).u_disp(4);elem(ii).v_disp(4)]; elem(ii).eps_xx(nn,mm) = strain_vector(1); elem(ii).eps_yy(nn,mm) = strain_vector(2); elem(ii).eps_xy(nn,mm) = strain_vector(3); stress_vector = E_matrix*strain_vector; elem(ii).sig_xx(nn,mm) = stress_vector(1); elem(ii).sig_yy(nn,mm) = stress_vector(2); elem(ii).sig_xy(nn,mm) = stress_vector(3); elem(ii).X(nn,mm) = pos(1); elem(ii).Y(nn,mm) = pos(2); end end end end %% Write Displacements to Text File outputWrite(inputName,totalNodes,nodePos,elemProp,f_cLoad,K_code,D); %% Plot textSize = 8; if iPlot ~= 0 figure(iFig) iFig = iFig+1; hold on for ii=1:numElems plot(elem(ii).xpos,elem(ii).ypos,’b*-’,’linewidth’,2); plot((elem(ii).xpos+elem(ii).u_disp*df),(elem(ii).ypos +... elem(ii).v_disp*df),’r*--’,’linewidth’,2); plot([elem(ii).xpos(end) elem(ii).xpos(1)],[elem(ii).ypos(end)... elem(ii).ypos(1)],’b*-’,’linewidth’,2); plot([(elem(ii).xpos(end)+elem(ii).u_disp(end)*df)... (elem(ii).xpos(1)+elem(ii).u_disp(1)*df)],... [(elem(ii).ypos(end) + elem(ii).v_disp(end)*df) (elem(ii).ypos(1) +... elem(ii).v_disp(1)*df)],’r*--’,’linewidth’,2);

F.7 MATLAB Code

1049

for jj=1:length(elem(ii).nodes) text(elem(ii).xpos(jj),elem(ii).ypos(jj),... num2str(elem(ii).nodes(jj)),’color’,’k’,’fontsize’,14); end legend(’original’,’displaced’,’location’,’best’) min_eps_xx(ii) = min(min(elem(ii).eps_xx)); max_eps_xx(ii) = max(max(elem(ii).eps_xx)); min_eps_yy(ii) = min(min(elem(ii).eps_yy)); max_eps_yy(ii) = max(max(elem(ii).eps_yy)); min_eps_xy(ii) = min(min(elem(ii).eps_xy)); max_eps_xy(ii) = max(max(elem(ii).eps_xy)); min_sig_xx(ii) = min(min(elem(ii).sig_xx)); max_sig_xx(ii) = max(max(elem(ii).sig_xx)); min_sig_yy(ii) = min(min(elem(ii).sig_yy)); max_sig_yy(ii) = max(max(elem(ii).sig_yy)); min_sig_xy(ii) = min(min(elem(ii).sig_xy)); max_sig_xy(ii) = max(max(elem(ii).sig_xy)); end axis equal title(’Elasticity Results’); eval([’title(’’Elasticity Results (Deformation Scale Factor = ’,... num2str(df),’)’’)’]); xlabel(’x-position’); ylabel(’y-position’); %% Contours if iPlot == 1; %Strain (epsilon_xx) figure(iFig) iFig = iFig+1; hold on for kk=1:numElems plot(elem(kk).xpos_f,elem(kk).ypos_f,’k*--’,’linewidth’,2); plot([elem(kk).xpos_f(end) elem(kk).xpos_f(1)],[elem(kk).ypos_f(end)... elem(kk).ypos_f(1)],’k*-’,’linewidth’,2); if elemType == 2 [hC hC] = contourf([elem(kk).X],[elem(kk).Y],[elem(kk).eps_xx],100); set(hC,’LineStyle’,’none’); elseif elemType == 1 if sign(elem(kk).eps_xx(1,1)) == 1 col = ’r’; else col = ’b’; end text(mean(elem(kk).xpos_f),mean(elem(kk).ypos_f),... [’\epsilon_{xx} = ’,num2str(elem(kk).eps_xx(1,1),’%.3e’)],... ’HorizontalAlignment’,’center’,’fontsize’,textSize,’color’,col); end

1050

Chapter F. 2D Finite Element Method Implementation in MATLAB end for kk=1:numElems plot(elem(kk).xpos_f,elem(kk).ypos_f,’k*--’,’linewidth’,2); plot([elem(kk).xpos_f(end) elem(kk).xpos_f(1)],[elem(kk).ypos_f(end)... elem(kk).ypos_f(1)],’k*-’,’linewidth’,2); end colorbar caxis([min(min_eps_xx) max(max_eps_xx)]) title(’\epsilon_{xx} Contour’) xlabel(’x-position’) ylabel(’y-position’) %Strain (epsilon_yy) figure(iFig) iFig = iFig+1; hold on for kk=1:numElems plot(elem(kk).xpos_f,elem(kk).ypos_f,’k*--’,’linewidth’,2); plot([elem(kk).xpos_f(end) elem(kk).xpos_f(1)],[elem(kk).ypos_f(end)... elem(kk).ypos_f(1)],’k*-’,’linewidth’,2); if elemType == 2 [hC hC] = contourf(elem(kk).X,elem(kk).Y,elem(kk).eps_yy,100); set(hC,’LineStyle’,’none’); elseif elemType == 1 if sign(elem(kk).eps_yy(1,1)) == 1 col = ’r’; else col = ’b’; end text(mean(elem(kk).xpos_f),mean(elem(kk).ypos_f),... [’\epsilon_{xy} = ’,num2str(elem(kk).eps_yy(1,1),’%.3e’)],... ’HorizontalAlignment’,’center’,’fontsize’,textSize,’color’,col); end end for kk=1:numElems plot(elem(kk).xpos_f,elem(kk).ypos_f,’k*--’,’linewidth’,2); plot([elem(kk).xpos_f(end) elem(kk).xpos_f(1)],[elem(kk).ypos_f(end)... elem(kk).ypos_f(1)],’k*-’,’linewidth’,2); end colorbar caxis([min(min_eps_yy) max(max_eps_yy)]) title(’\epsilon_{yy} Contour’) xlabel(’x-position’) ylabel(’y-position’) %Strain (epsilon_xy) figure(iFig) iFig = iFig+1; hold on

F.7 MATLAB Code

1051

for kk=1:numElems plot(elem(kk).xpos_f,elem(kk).ypos_f,’k*--’,’linewidth’,2); plot([elem(kk).xpos_f(end) elem(kk).xpos_f(1)],[elem(kk).ypos_f(end)... elem(kk).ypos_f(1)],’k*-’,’linewidth’,2); if elemType == 2 [hC hC] = contourf(elem(kk).X,elem(kk).Y,elem(kk).eps_xy,100); set(hC,’LineStyle’,’none’); elseif elemType == 1 if sign(elem(kk).eps_xy(1,1)) == 1 col = ’r’; else col = ’b’; end text(mean(elem(kk).xpos_f),mean(elem(kk).ypos_f),... [’\epsilon_{xy} = ’,num2str(elem(kk).eps_xy(1,1),’%.3e’)],... ’HorizontalAlignment’,’center’,’fontsize’,textSize,’color’,col); end end for kk=1:numElems plot(elem(kk).xpos_f,elem(kk).ypos_f,’k*--’,’linewidth’,2); plot([elem(kk).xpos_f(end) elem(kk).xpos_f(1)],[elem(kk).ypos_f(end)... elem(kk).ypos_f(1)],’k*-’,’linewidth’,2); end colorbar caxis([min(min_eps_xy) max(max_eps_xy)]) title(’\epsilon_{xy} Contour’) xlabel(’x-position’) ylabel(’y-position’) %Stress (sigma_xx) figure(iFig) iFig = iFig+1; hold on for kk=1:numElems plot(elem(kk).xpos_f,elem(kk).ypos_f,’k*--’,’linewidth’,2); plot([elem(kk).xpos_f(end) elem(kk).xpos_f(1)],[elem(kk).ypos_f(end)... elem(kk).ypos_f(1)],’k*-’,’linewidth’,2); if elemType == 2 [hC hC] = contourf(elem(kk).X,elem(kk).Y,elem(kk).sig_xx,100); set(hC,’LineStyle’,’none’); elseif elemType == 1 if sign(elem(kk).sig_xx(1,1)) == 1 col = ’r’; else col = ’b’; end text(mean(elem(kk).xpos_f),mean(elem(kk).ypos_f),... [’\sigma_{xx} = ’,num2str(elem(kk).sig_xx(1,1),’%.3e’)],...

1052

Chapter F. 2D Finite Element Method Implementation in MATLAB ’HorizontalAlignment’,’center’,’fontsize’,textSize,’color’,col); end end for kk=1:numElems plot(elem(kk).xpos_f,elem(kk).ypos_f,’k*--’,’linewidth’,2); plot([elem(kk).xpos_f(end) elem(kk).xpos_f(1)],[elem(kk).ypos_f(end)... elem(kk).ypos_f(1)],’k*-’,’linewidth’,2); end colorbar caxis([min(min_sig_xx) max(max_sig_xx)]) title(’\sigma_{xx} Contour’) xlabel(’x-position’) ylabel(’y-position’) %Stress (sigma_yy) figure(iFig) iFig = iFig+1; hold on for kk=1:numElems plot(elem(kk).xpos_f,elem(kk).ypos_f,’k*--’,’linewidth’,2); plot([elem(kk).xpos_f(end) elem(kk).xpos_f(1)],[elem(kk).ypos_f(end)... elem(kk).ypos_f(1)],’k*-’,’linewidth’,2); if elemType == 2 [hC hC] = contourf(elem(kk).X,elem(kk).Y,elem(kk).sig_yy,100); set(hC,’LineStyle’,’none’); elseif elemType == 1 if sign(elem(kk).sig_yy(1,1)) == 1 col = ’r’; else col = ’b’; end text(mean(elem(kk).xpos_f),mean(elem(kk).ypos_f),... [’\sigma_{yy} = ’,num2str(elem(kk).sig_yy(1,1),’%.3e’)],... ’HorizontalAlignment’,’center’,’fontsize’,textSize,’color’,col); end end for kk=1:numElems plot(elem(kk).xpos_f,elem(kk).ypos_f,’k*--’,’linewidth’,2); plot([elem(kk).xpos_f(end) elem(kk).xpos_f(1)],[elem(kk).ypos_f(end)... elem(kk).ypos_f(1)],’k*-’,’linewidth’,2); end colorbar caxis([min(min_sig_yy) max(max_sig_yy)]) title(’\sigma_{yy} Contour’) xlabel(’x-position’) ylabel(’y-position’) %Stess (sigma_xy) figure(iFig)

F.7 MATLAB Code

1053

iFig = iFig+1; hold on for kk=1:numElems plot(elem(kk).xpos_f,elem(kk).ypos_f,’k*--’,’linewidth’,2); plot([elem(kk).xpos_f(end) elem(kk).xpos_f(1)],[elem(kk).ypos_f(end)... elem(kk).ypos_f(1)],’k*-’,’linewidth’,2); if elemType == 2 [hC hC] = contourf(elem(kk).X,elem(kk).Y,elem(kk).sig_xy,100); set(hC,’LineStyle’,’none’); elseif elemType == 1 if sign(elem(kk).sig_xy(1,1)) == 1 col = ’r’; else col = ’b’; end text(mean(elem(kk).xpos_f),mean(elem(kk).ypos_f),... [’\sigma_{xy} = ’,num2str(elem(kk).sig_xy(1,1),’%.3e’)],... ’HorizontalAlignment’,’center’,’fontsize’,textSize,’color’,col); end end for kk=1:numElems plot(elem(kk).xpos_f,elem(kk).ypos_f,’k*--’,’linewidth’,2); plot([elem(kk).xpos_f(end) elem(kk).xpos_f(1)],[elem(kk).ypos_f(end)... elem(kk).ypos_f(1)],’k*-’,’linewidth’,2); end colorbar caxis([min(min_sig_xy) max(max_sig_xy)]) title(’\sigma_{xy} Contour’) xlabel(’x-position’) ylabel(’y-position’) end end

F.7.2

FUNCTION inputRead.m %This function reads in user input data from a text file to be used by %FEA.m for finite element computation of a 2-dimensional structure function [data_element_nodes data_nodePos data_elemProp data_cLoad] = ... inputRead(filename) fid = fopen(filename); %% Intialize Flags nodes_flag = 0; nodePos_flag = 0; cLoad_flag = 0;

1054

Chapter F. 2D Finite Element Method Implementation in MATLAB

elemProp_flag = 0; i_nodes = 0; i_nodePos = 0; i_cLoad =0; i_elemProp = 0; nodes.readPos = 0; nodePos.readPos =0; cLoad.readPos = 0; elemProp.readPos = 0; %% Read in Data & Assign to Appropriate Variable C = textscan(fid, ’%s’); for ii=1:length(C{:}) if strcmp(C{1}(ii),’nodes’) nodes_flag = 1; i_nodes = 1; nodes.readPos = ii+1; kk = 1; end if strcmp(C{1}(ii),’nodePos’) nodePos_flag = 1; i_nodePos = 1; nodePos.readPos = ii+1; kk = 1; end if strcmp(C{1}(ii),’elemProp’) elemProp_flag = 1; i_elemProp = 1; elemProp.readPos = ii+1; kk = 1; end if strcmp(C{1}(ii),’cLoad’) cLoad_flag = 1; i_cLoad = 1; cLoad.readPos = ii+1; kk = 1; end if ii >= nodes.readPos && i_nodes == 1 && strcmp(C{1}(ii),’end’) == 0 data_element_nodes(kk,:) = str2num(cell2mat(C{1}(ii))); kk = kk+1; end if ii >= nodePos.readPos && i_nodePos == 1 && strcmp(C{1}(ii),’end’) == 0 data_nodePos(kk,:) = str2num(cell2mat(C{1}(ii))); kk = kk+1; end if ii >= elemProp.readPos && i_elemProp == 1 && strcmp(C{1}(ii),’end’) == 0 data_elemProp(kk,:) = str2num(cell2mat(C{1}(ii))); kk = kk+1;

F.7 MATLAB Code

1055

end if ii >= cLoad.readPos && i_cLoad == 1 && strcmp(C{1}(ii),’end’) == 0 data_cLoad(kk,:) = str2num(cell2mat(C{1}(ii))); kk = kk+1; end if strcmp(C{1}(ii),’end’) && i_nodes == 1; i_nodes = 0; kk = 1; end if strcmp(C{1}(ii),’end’) && i_nodePos == 1; i_nodePos = 0; end if strcmp(C{1}(ii),’end’) && i_elemProp == 1; i_elemProp = 0; end if strcmp(C{1}(ii),’end’) && i_nodePos == 1; i_elemProp = 0; end end %% Error Messages if nodes_flag == 0 fprintf(’ERROR: Node Definitions (’’nodes’’) NOT FOUND \n’); end if nodePos_flag == 0 fprintf(’ERROR: Node Locations (’’nodePos’’) NOT FOUND \n’); end if cLoad_flag == 0 fprintf(’WARNING: No Concentrated Loads Found (’’cLoad’’) \n’); end if elemProp_flag == 0 fprintf(’ERROR: Element Properties (’’elemProp’’) NOT FOUND \n’); end fclose(fid);

F.7.3

FUNCTION outputWrite.m function outputWrite(inputName,totalNodes,nodePos,elemProp,f_cLoad,K_code,D) outputName = strcat(’OUTPUT_’,inputName); fid = fopen(outputName,’wt’); %% Print Results to File fprintf(’\n’); fprintf(’Saving Results to file: %s’,strcat(outputName)); fprintf(’\n’); fprintf(fid,’%47s \n\n’,’2D FEA ANALYSIS’);

1056

Chapter F. 2D Finite Element Method Implementation in MATLAB

fprintf(fid,’%62s \n’,’-------------------------------------------- ’); fprintf(fid,’%46s \n’,’USER INPUTS ’); fprintf(fid,’%62s \n’,’-------------------------------------------- ’); fprintf(fid,’%s %20s \n’,’Young’’s Modulus’, ’Poisson’’s Ratio’); fprintf(fid,’%.3e %20.2f \n\n’,elemProp(1),elemProp(2)); fprintf(fid,’%s %13s %14s %12s %15s %20s %20s\n’,... ’node #’,’x-position’,’y-position’,... ’x-load’,’y-load’,’x-constrained?’,’y-constrained’); for ii=1:totalNodes if nodePos(ii,3) == 1 x_c = ’y’; else x_c = ’n’; end if nodePos(ii,4) == 1 y_c = ’y’; else y_c = ’n’; end if ismember(ii,f_cLoad(:,1)) [index] = find(abs(f_cLoad(:,1)-ii)==0); x_load = f_cLoad(index,2); y_load = f_cLoad(index,3); else x_load = 0; y_load = 0; end fprintf(fid,’%i %15.2f %15.2f %15.2e %15.2e %13s %20s \n’,... ii,nodePos(ii,1),nodePos(ii,2),x_load,y_load,x_c,y_c); end fprintf(fid,’%62s \n’,’-------------------------------------------- ’); fprintf(fid,’%46s \n’,’DEFORMATION OUTPUTS ’); fprintf(fid,’%62s \n’,’-------------------------------------------- ’); fprintf(fid,’%s %19s %20s \n’,’node #’,’x-displacement’,’y-displacement’); for ii=1:totalNodes if nodePos(ii,3) == 1 u = 0; else index_x = find(abs(K_code./10-ii)==0); u = D(index_x); end if nodePos(ii,4) == 1 v = 0;

F.8 References

1057

else index_y = find(abs((K_code-1)./10-ii)==0); v = D(index_y); end fprintf(fid,’%i %22.4e %21.4e \n’,ii,u,v); end return

F.8

References V. Reznikov and V. Goyal, 2011, “2-D FEA Analysis MATLAB Formulation & ABAQUS Comparison,” Report prepared for the Finite Element Methods’ course at University of California at Los Angeles. May 31, 2011. This modified report is included in this appendix with permission.