Open Ended Lab of MATLAB (Truss Design by FEM)
Open Ended Lab of MATLAB (Truss Design by FEM)
TECHNOLOGY, SARGODHA
where (0 0),(3 3),(6 3),(9 3),(6 -2),(3 0) are the joint coordinates of the truss element in the global directions. The local
coordinates are always numbered 1 2 3 4 5 6 7 8 9 10 11 12 with 2 4 6 8 10 and 12 pointing in the global Y direction (up)
and with 1 3 5 7 9 and 11 pointing in the global X direction (to the right). Some or all of these twelve coordinates will line
up with the structural degrees of freedom that I identified in step 2., above. And where 1 2 3 4 5 6 are the nodal identities.
Element Stiffness Matrices in Global Coordinates, K. For each element, find its (4x4) element stiffness matrix, by
evaluating the equations below:
𝐿 = √ (𝑥2 − 𝑥1 )2 − (𝑦2 − 𝑦1 )2
(𝑥2 − 𝑥1 )
𝑙𝑠 =
𝐿
(𝑦2 − 𝑦1 )
𝑙𝑚 =
𝐿
MATLAB Code:
function k=TaimoorrazaOEL(E,A,cord)
x1=cord([1],[1]);
x2=cord([2],[1]);
y1=cord([1],[2]);
y2=cord([2],[2]);
L=sqrt((x2-x1)^2+(y2-y1)^2);
i=E*A/L;
ls=(x2-x1)/L;
lm=(y2-y1)/L;
k=i*[ls^2,ls*lm,-ls^2,-ls*lm;ls*lm,lm^2,-ls*lm,-lm^2;-ls^2,-ls*lm,ls^2,ls*lm;-ls*lm,-
lm^2,ls*lm,lm^2]
function [Du,Fu]=taimoorrazaa(K1,F,KDOF,KLDOF)
A=size(F);
ULDOF=setdiff(1:A,KLDOF);
Fk=F(ULDOF,:);
K11=K1(ULDOF,ULDOF);
K12=K1(ULDOF,KLDOF)
K21=K1(KLDOF,ULDOF);
K22=K1(KLDOF,KLDOF);
X=K12*KDOF;
Du=(inv(K11))*(Fk-X);
Fk=(K11*Du)+(K12*KDOF);
Fu=(K21*Du)+(K22*KDOF);
function U=TaimoorrazaOELmb(E,A,cord)
x1=cord([1],[1]);
x2=cord([2],[1]);
y1=cord([1],[2]);
y2=cord([2],[2]);
L=sqrt((x2-x1)^2+(y2-y1)^2);
b=E*A/L;
ls=(x2-x1)/L;
lm=(y2-y1)/L;
U=(E*A/L)*([1 -1;-1 1])*([ls lm 0 0;0 0 ls lm]);
--------------------------------------------------------------------------------------------------------------------
-----------------------
E=1000
A=1e-6
element=9;
K1=zeros(12,12);
cord=[0 0;3 3;6 3;9 3;6 -2;3 0];
lmm=[1 2 3 4;3 4 5 6;5 6 7 8;7 8 9 10;1 2 9 10;1 2 11 12;3 4 11 12;5 6 11 12;5 6 9 10];
conn=[1,2;2,3;3,4;4,5;1,5;1,6;2,6;3,6;3,5];
for i=1:element
con=conn(i,:);
coord=cord(con,:);
[K]=TaimoorrazaOEL(E,A,coord);
lm=lmm(i,:);
K1(lm,lm)=K1(lm,lm)+K
end
F=zeros(12,1);
F([4])=-4;
F([2])=-28;
KLDOF=[7;8;10];
KDOF=[0;0;-0.025];
[Du,Fu,Fk]=taimoorrazaa(K1,F,KDOF,KLDOF)
D=zeros(12,1);
B=size(D);
ULDOF=setdiff(1:B,KLDOF);
D(KLDOF,1)=KDOF;
D(ULDOF,1)=Du;
for i=1:element
con=conn(i,:);
coord=cord(con,:);
U=TaimoorrazaOELmb(E,A,cord);
lm=lmm(i,:);
MF=U*D(lm)
End
RESULTS:
Global Stiffness Matrix=K1
Unknown Displacements = Du
Known Forces = Fk
Unknown Forces = Fu
Member Forces = MF