Vous êtes sur la page 1sur 8

THEORY OF MATRIX STRUCTURAL ANALYSIS

- REPORT (FRAME2D) -

0. RUNNER FILE
The runner file Runner is a MATLAB m-file which evaluates the input file and
initiates the main MATLAB m-file. In this section input file must be specified by
name.
1. MAIN FILE
The main file Frame2D is a MATLAB m-file which assembles the global stiffness
matrix of a planar frame in order to calculate joint displacements and reactions of the
system by using various functions which will be presented below.

clc
jntpel=2;
dofpjnt=3;
totdof=jnts*dofpjnt;

% joint per element


% dof per joint
% total number of dof

[gdof,k,kk]=zeromtrx(totdof,jntpel,dofpjnt);

% creating zero matrix


% for global and local
% stiffness

%% CREATNG GLOBAL STFFNESS MATRX (KN/MM)


L=zeros(1,length(1:elmnts));
for iel=1:elmnts
e=E(iel);
a=A(iel);
i=I(iel);
j1=elends(iel,1);
j2=elends(iel,2);
x1=jcoords(j1,1);

% coordinates of joints
% x1, x2 and y1, y2

y1=jcoords(j1,2);
x2=jcoords(j2,1);
y2=jcoords(j2,2);
L(iel)=(sqrt((x2-x1)^2+(y2-y1)^2))*1000;
l=L(iel);
ex=[x1 x2];
ey=[y1 y2];
jd=[j1 j2];

[gdof]=connectivity(jd,jntpel,dofpjnt); % element index numbering


[k]=elk(ex,ey,e,a,l,i);
[kk]=globalk(kk,k,gdof);

% creating element global


% stiffness matrix
% creating global stiffness matrix

end
%% STFFNESS MATRX REARRANGED, THS OPERATON REARRANGES THE GLOBAL STFFNESS
MATRX OF THE SYSTEM N ORDER TO CALCULATE JONT DSPLACEMENT AND REACTON FORCES

fark=length(cnsval)-sum(cnsval);
i=1;
j=1;
for k=1:length(cnsval)
if cnsval(k)==0
cnsvalN(i)=k;
i=i+1;
else
cnsvalN(j+fark)=k;
j=j+1;
end
end
for i=1:length(cnsval)
for j=1:length(cnsval)
kk_new(i,j)=kk(cnsvalN(i),cnsvalN(j));
end
end
%% ALL UNTS SHOULD BE ENTERED KN AND METERS N THS SECTON
LdDstr='Load_Seperation';
eval(LdDstr);
%% PRNTNG ALL STFFNESS MATRCES TO SCREEN
disp('Global Stiffness Matrix of the Truss "kk" is:')
disp(' ')
disp(kk)
disp('Rearranged Global Stiffness Matrix of the Truss "kk_new" is:')
disp(' ')
disp(kk_new)
%% FORCE VECTOR REARRANGED & DETECTON OF STFFNESS MATRX FOR DSPLACEMENT
ff=ff-pf;
for i=1:fark
ff_new(i)=ff(cnsvalN(i));
for j=1:fark
k(i,j)=kk_new(i,j);
end
end
j=fark;
for i=1:(length(cnsvalN)-fark)
j=j+1;
ff_r(i)=ff(cnsvalN(j));
end
%% DETECTON OF STFFNESS MATRX FOR REACTON FORCES
m=1;
for i=(fark+1):length(cnsval)
n=1;
for j=1:fark
k1(m,n)=kk_new(i,j);
n=n+1;
end
m=m+1;
end

%% CALCULATON OF DSPLACEMENTS (@FREE NODES) AND REACTON FORCES (@SUPPORTS)


defrm=k\ff_new';

% Displacement

React=(k1*defrm)-ff_r';

% Reaction
%% Printing Results to Screen

display(' ')
for i=1:fark
if mod(cnsvalN(i),3)==0
fprintf('Rotation at DOF #%g is %g rad \n',cnsvalN(i),defrm(i,1))
else
fprintf('Displacement at DOF #%g is %g mm \n',cnsvalN(i),defrm(i,1))
end
end
display(' ')
for i=(fark+1):length(cnsval)
if mod(cnsvalN(i),3)==0
fprintf('Moment at DOF #%g is %g kNmm \n',cnsvalN(i),React((i-fark),1))
else
fprintf('Support Reaction at DOF #%g is %g kN \n',cnsvalN(i),React((ifark),1))
end
end
%% REARRANGNG DEFORMATON VECTOR
deform=zeros(totdof,1);
j=1;
for i=1:length(cnsval)
if cnsval(i)==1
deform(i)=0;
else
deform(i)=defrm(j);
j=j+1;
end
end
for i=1:jnts
X(i)=deform((i-1)*2+1);
Y(i)=deform((i-1)*2+2);
end
for i=1:jnts
j=1;
dfrm(i,j)=X(i);
j=j+1;
dfrm(i,j)=Y(i);
end
dfrm=sfactor*(dfrm/1000);
jdeformed=jcoords+dfrm;
%% DETERMNATON OF STFFNESS MATRX FOR GLOBAL MOMENTS
m=1;
n=1;
for j=1:totdof;
if mod(j,3)==0;
for i=1:totdof;
if mod(i,3)==0;
def(n)=deform(i);
k2(m,n)=kk(j,i);
n=n+1;
if n==4;
n=1;

end
end
end
m=m+1;
end
end
R1=k2*def';
%%

2. FUNCTIONS
2.1. zeromtrx
This function generates a number of zero matrices which will then be filled by
calculated values.

function [index,k,kk]=zeromtrx(totdof,jntpel,dofpjnt)

index=zeros(jntpel*dofpjnt,1);
k=zeros(jntpel*dofpjnt,jntpel*dofpjnt);
kk=zeros(totdof,totdof);

2.2. connectivity
This function generates a connectivity vector which will be used for the global
stiffness matrix calculations for the element that is being considered.

function [gdof]=connectivity(jd,jntpel,dofpjnt)

k=0;
for i=1:jntpel
start=(jd(i)-1)*dofpjnt;
for j=1:dofpjnt
k=k+1;
gdof(k)=start+j;
end
end

2.3. elk
This function calculates the local stiffness matrix for the element that is being
considered and converts it to the global coordinate system.

function [k]=elk(ex,ey,E,A,L,I)

c=(ex(2)-ex(1))*1000/L;
s=(ey(2)-ey(1))*1000/L;
T=[c
-s
0
0
0
0

s
c
0
0
0
0

0
0
1
0
0
0

0 0 0;
0 0 0;
0 0 0;
c s 0;
-s c 0;
0 0 1];

a=(A/L);
b=(12*I/L^3);
c=(6*I/L^2);
d=(4*I/L);
e=(2*I/L);
lclk=[ a 0 0 -a 0 0 ;
0 b c 0 -b c ;
0 c d 0 -c e ;
-a 0 0 a 0 0 ;
0 -b -c 0 b -c ;
0 c e 0 -c d ]*E;

k=T'*lclk*T;

2.4. globalk
This function constructs the global stiffness matrix of the element by use of the
values calculated by the elk function, afterwards, locates the values to the global
stiffness matrix which is generated as a zeroes-matrix by the zeromtrx function.

function [kk]=globalk(kk,k,gdof)

edof=length(gdof);
for i=1:edof
ii=gdof(i);
for j=1:edof
jj=gdof(j);
kk(ii,jj)=kk(ii,jj)+k(i,j);
end
end

2.5. Load_Seperation
This m-file is used in the case of load existence between joints in order to calculate
fixed end moments and reactions. Results of this file will be evaluated in the main
m file.

n=size(Loading);
for i=1:n(1)
iel=Loading(i,1);
j1=elends(iel,1);
j2=elends(iel,2);
jd=[j1 j2];
[gdof]=connectivity(jd,jntpel,dofpjnt);
l=L(iel)/1000;
x=Loading(i,2);
if x==1
p=Loading(i,3);
a=Loading(i,4);
b=l-a;
m1=(p*a*b^2)/l^2;
m2=-((p*a^2*b)/l^2);
r1=(p*b^2*(3*a+b))/l^3;
r2=(p*a^2*(a+3*b))/l^3;
l1=0;
l2=0;
end
if x==2
q=Loading(i,3);
d=l-(Loading(i,4)+Loading(i,5))*l;
a=Loading(i,4)*l+(d/2);
b=l-a;
m1=(q*d/l^2)*[a*b^2+(a-2*b)*d^2/12];
m2=-(q*d/l^2)*[a*b^2+(b-2*a)*d^2/12]
r1=(q*d/l^3)*[(2*a+l)*b^2+((a-b)/4)*d^2];
r2=(q*d/l^3)*[(2*b+l)*a^2-((a-b)/4)*d^2];
l1=0;
l2=0;
end
if x==3
m=Loading(i,3);
a=Loading(i,4);
b=l-a;
m1=m*b*(2*a-b)/l^2;
m2=m*a*(2*b-a)/l^2;
r1=6*m*a*b/l^3;
r2=-(6*m*a*b/l^3);
l1=0;
l2=0;
end
pf_elm=[l1;r1;m1*1000;l2;r2;m2*1000];
for i=1:jntpel*dofpjnt
pf(gdof(i))=pf(gdof(i))+pf_elm(i);
end
end

*****
When the loop is completed for all the elements, global stiffness matrix of the planar
frame, joint displacements and reactions will be presented in the MATLAB screen.

Vous aimerez peut-être aussi