Finite Element Matlab 1
Finite Element Matlab 1
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
""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."
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:
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
Matrix output
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
-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)
Programming Constructs
For loop
INDENT
RANGE [start]:[increment]:[stop]
gives
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
So...
Build programmes up gradually, testing after each change to check there are no errors Use comments % Comment Hi1, Hi2, Hi3
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
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
N3
E3
E5
2m
E4 u 4y 1000 N N4 [ELEMENT,NODE1,NODE2]
1m
2m
DOFs
Local --> Global 1x(1) --> 1 (1) 1y --> 2 (1) 2x --> 5 2y(1) --> 6 2y(4) --> 8
LOCAL REPRESENTATION
u2t 2 1 u1t u1a u2a for element e
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
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)
~ (e) U
(e)
~ ~(e) U
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
~ (e) T (e) K T K T
4x4 4x4
4x4=
4x4
~ ~ (e) K
~ (e) K
4x8
8x8=
8x4
4x4
F
e
~ ~ (e) F ~ ~ (e) K
e
F R
K11 K12 U K 21 K 22 0
F K11U R K 21U
F
4x1=
(e)
K T
4x4
(e)
(e)
(e)
U
8x1
4x4
4x8
ALSO
Note that the transformation and incidence matrices are orthogonal: T 1