100% found this document useful (1 vote)
54 views

Finite Element Matlab 1

This document provides an overview of using MATLAB to analyze finite element problems. It discusses representing systems as matrices, defining element stiffness matrices in local coordinate systems, transforming them to global coordinates using transformation matrices, expanding them using incidence matrices, and assembling the global stiffness matrix and load vector. It also covers partitioning the matrices to apply boundary conditions and solving for displacements, then back-substituting to find element forces and stresses. Key steps include numbering nodes and elements, defining local matrices, transforming and expanding them, and assembling the global system for solution.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
54 views

Finite Element Matlab 1

This document provides an overview of using MATLAB to analyze finite element problems. It discusses representing systems as matrices, defining element stiffness matrices in local coordinate systems, transforming them to global coordinates using transformation matrices, expanding them using incidence matrices, and assembling the global stiffness matrix and load vector. It also covers partitioning the matrices to apply boundary conditions and solving for displacements, then back-substituting to find element forces and stresses. Key steps include numbering nodes and elements, defining local matrices, transforming and expanding them, and assembling the global system for solution.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

MATLAB for Finite Elements

An introduction

[X,Y] = meshgrid(-10:0.25:10,-10:0.25:10); f = sinc(sqrt((X/pi).^2+(Y/pi).^2)); mesh(X,Y,f); axis([-10 10 -10 10 -0.3 1]) xlabel('{\bfx}') ylabel('{\bfy}') zlabel('{\bfsinc} ({\bfR})') hidden off

MATlab: Its all about the MATRIX


But what is the matrix?
Do not fool yourself. Matlab will not add any magic ingredient for the assignment that has not been covered in the tutorials and lectures. Neither will ANSYS. Its pretty interface is the world that has been pulled over your eyes to blind you from the truth. The truth that you are a slave. Like everyone else you were born into bondage to overpriced commercial software.

""Let me tell you why you're here. You're here because you know something. What you know you can't explain, but you feel it."

"No, I don't believe it. It's not possible."

FF RR

K K K12 U 11 12 U 11 K 21 K K 22 0 K 0 21 22

U 11 FF KK U 11
"I didn't say it would be easy, Neo. I just said it would be the truth""

R K 2121 U

R K U

"But I believe that, as a species, human beings define their reality through suffering and misery"

T0(1)=100; % % INCIDENCE MATRICES AND ASSEMBLY I=zeros(2,(E+1),(E+1)); for a=1:E I(1,a,a)=1; I(2,(a+1),a)=1; end I2=zeros(2,(E+1)); for a=1:E I2(:,:)=I(:,:,a); K=K+I2'*KE*I2; M=M+I2'*ME*I2; end % % DOF CONSTRAINTS AND REDUCTION OF GLOBAL MATRICES % bcdof(1)=1; %DOF constraint on global DOF 1 bcval(1)=100; % fixed value for DOF constraint no. 1 for ic=1:1 % loop over BCs id=bcdof(ic); val=bcval(ic); for i=1:(E+1) % loop over total DOFs F(i)=F(i)-val*K(i,id); K(id,i)=0; K(i,id)=0; end K(id,id)=0; F(id)=val;

Using Matlab
Command line Text files/m-files Everything is a matrix:

>> A=6 >> A='QWERTY' >> A=3e5

QWERTY

A 300000

Basics

Matrix input
Square brackets
Comma or space separates

>> A=[1,3,6;2,7,8;0,3,9]
1 3 6 A 2 7 8 0 3 9

Semicolon separates rows


Semicolon at end suppresses output

Matrix output

>> A >> A(2,1) >> A(:,3)


6 A 8 9

[ENTER] [ENTER] [ENTER]

Matrix definition (other ways) - Element specification >> A(2,2)=7;


Range specification Colons >> A=1:2:9
A 1 3 5 7 9

>> A(2,1:3)=[2 7 8];

Initialisation

>> A=zeros(3,3)
0 0 0 A 0 0 0 0 0 0

>>A=eye(4)
1 0 0 0 A 0 1 0 0 0 0 1 0 0 0 0 1

Matrix Algebra
A 1 2 3 4

5 6 7 8

- Addition/subtraction - Matrix multiplication

>> C=A+B; >> C=A-B; >> C=A*B;

-Element-by-element operations

>> C=A.*B

12

21 32

Special Functions
- Matrix transpose - Matrix inverse -Matrix size - Solution of system of linear equations Ax=b - Trigonometric functions (in radians) - Exponents >> A >> inv(A) >> size(A)

>> x=A\b >> f=cos(0.5) >> a= 2^7

and many more...


>> help >> why

Programming Constructs

For loop

INDENT

b=0; for a=1:10 b=b+1 end

RANGE [start]:[increment]:[stop]

gives

b=1 b=2 b=3 b=10

Programming Constructs

If statements
b=input('Give me a number '); if (b>0) i_say_that='bigger than zero'; elseif (b<0) i_say_that ='less than zero'; else i_say_that ='exactly zero'; end i_say_that Less than (b<0) Greater than (b>0) Equal to (b==0) Not equal to (b~=0) Less than or equal to (b<=0) etc

There will always be errors


Matlab is usually quite helpful in reporting errors

Common errors include


Undefined variables Division by zero Array indices used wrongly or out of range Programme gets stuck in a loop

So...

Build programmes up gradually, testing after each change to check there are no errors Use comments % Comment Hi1, Hi2, Hi3

STATIC, LINEAR TRUSSES


1. Number nodes and elements 2. For each element Calculate K(e) , T(e) and (e) matrices Transform K(e) into global coordinates Expand K(e) with incidence matrices Expand F(e) with incidence matrices Materials Element section properties Nodal coordinates Element connectivity Element stiffness matrix K(e) Transformation matrix T(e) Element incidence matrices (e) Loads Boundary conditions

3. Sum Ks and Fs to form global stiffness matrix and global load vector 4. Partition K using BCs 5. Solve for unknown displacements U

6. Back-substitute to solve for unknown R


7. Use displacement solution to calculate element forces/stresses

NOTATION
Element vs. model quantities (one exists for each element?) Local vs. global coordinate systems (effects of element orientation) Local vs. global DOFs (size of vector/matrix) Subscripts: x/y = global directions a/t=local axial/transverse directions 4x4

A ~ (e) A ~ ~ (e) A A

(e)

Element quantity (in local coordinate system) Tranformation matrix T(e) Element quantity (in global coordinate system) Incidence matrix (e) Element quantity (in terms of global DOFs) Summation over elements Model quantity

4x4

nxn nxn

1.NUMBERING
N1 E2
1m
u1x u1y u 2x

[NODE,X,Y]

NODES

N2 E1

u 2y u 3x u 3y u 4x

1,0,3 2,2,2 3,0,0 4,3,0

N3

E3

E5
2m

E4 u 4y 1000 N N4 [ELEMENT,NODE1,NODE2]
1m

2m

ELEMENTS 1,1,3 2,1,2 3,2,3 4,2,4 5,3,4

DOFs
Local --> Global 1x(1) --> 1 (1) 1y --> 2 (1) 2x --> 5 2y(1) --> 6 2y(4) --> 8

A=0.01m2 E=210 GPa

LOCAL REPRESENTATION
u2t 2 1 u1t u1a u2a for element e

Local stiffness matrix using local DOF convention:

u1a U
(e)

f1a F
(e)

1 K
(e)

1 0 0 1 0 0 0 0

u1t u2 a u2 t

f1t f2a f 2t

EA 0 0 l (e) 1 0 0 0

2a. CALCULATING LOCAL MATRICES


Local stiffness matrix for each element depends on length: Local transformation matrix for each element depends on inclination to positive x-axis: (e) ( e ) ~ ( e ) (+ = antiU T U clockwise )

1 K
(e)

1 0 0 1 0 0 0 0

EA 0 0 l (e) 1 0 0 0

(e)

cos sin 0 0

(e) (e)

sin ( e ) cos ( e ) 0 0

0 0 cos sin

0 0
(e) (e)

sin cos

(e) (e)

Incidence matrices map the 4 local to 8 global degrees of freedom:

~ (e) U

(e)

~ ~(e) U

4x1 = (4x8) x (8x1)

1 0 0 0 0 0 0 0
(1)

0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0

because

1x(1) 1y(1) 2x(1) 2y(1)

--> 1 --> 2 --> 5 --> 6

2b. TRANSFORM LOCAL STIFFNESS MATRICES

~ (e) T (e) K T K T
4x4 4x4

4x4=

4x4

2c. EXPAND LOCAL STIFFNESS MATRICES

~ ~ (e) K

~ (e) K
4x8

8x8=

8x4

4x4

2d. TRANSFORM & EXPAND LOCAL LOAD MATRICES

~ (e) T (e) F T F ~ ~ (e) T ~ (e) F F

3. ASSEMBLE GLOBAL MATRICES

F
e

~ ~ (e) F ~ ~ (e) K
e

4-6. PARTITION AND SOLVE MATRICES

F R

K11 K12 U K 21 K 22 0

F K11U R K 21U

7. CALCULATE ELEMENT FORCES

F
4x1=

(e)

K T
4x4

(e)

(e)

(e)

U
8x1

4x4

4x8

for each element e

ALSO
Note that the transformation and incidence matrices are orthogonal: T 1

You might also like