Sei sulla pagina 1di 4

16/10/2554 0:26 .

G:\Bai's Memory\Knowledge & Education\Ot...\LinearFrame.m

1 of 4

clc
clear all;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
Theerapat Singprasert ID : 5270608721
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
Input zone by User
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
E = 1;
A = 1.855*10e6;
I = 9.27*10e3;
nelem = 2;
nnode = 3;
node_coord = [ 0 0; 12.936 0.386; 25.872 0];
connec = [ 1 2; 2 3];
P = [ 0 0 0 0 -20 0 0 0 0]; % Nodal Load
bc = [ 1 1 1 0 0 0 1 1 1]; % essential BC ( 1 = restrained )
disp = [ 0 0 0 0 0 0 0 0 0]; % Initial displacement
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Processing zone (Linear analysis)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ndof = nnode*3;
ks = zeros(ndof,ndof); % Element Stiffness
for e = 1: nelem
ns = connec(e,1);
ne = connec(e,2);
x_ns=node_coord(ns,1);
y_ns=node_coord(ns,2);
x_ne=node_coord(ne,1);
y_ne=node_coord(ne,2);
L=sqrt((x_ne-x_ns)^2+(y_ne-y_ns)^2);
k = [ E*A/L 0 0 -E*A/L 0 0;
0 12*E*I/L 6*E*I/L^2 0 -12*E*I/L 6*E*I/L^2;
0 6*E*I/L^2 4*E*I/L 0 -6*E*I/L^2 2*E*I/L;
-E*A/L 0 0 E*A/L 0 0;
0 -12*E*I/L -6*E*I/L^2 0 12*E*I/L -6*E*I/L^2;
0 6*E*I/L^2 2*E*I/L 0 -6*E*I/L^2 4*E*I/L];
dx = x_ne-x_ns;
dy = y_ne-y_ns;
%%%%%%%%%%%%%%%%%%%%%%%%
% Tranformation Matrix %

16/10/2554 0:26 .

G:\Bai's Memory\Knowledge & Education\Ot...\LinearFrame.m

%%%%%%%%%%%%%%%%%%%%%%%%
cos = dx/L;
sin = dy/L;
T = [

cos sin 0 0 0 0;
-sin cos 0 0 0 0;
0 0 1 0 0 0;
0 0 0 cos sin 0;
0 0 0 -sin cos 0;
0 0 0 0 0 1];

kGlo = T' * k * T;
%%%%%%%%%%%%%%%%
% Assemble k %
%%%%%%%%%%%%%%%%
dvec = [(ns-1)*3+1 (ns-1)*3+2 (ns-1)*3+3 (ne-1)*3+1 (ne-1)*3+2 (ne-1)*3+3];
for i=1:6
for j=1:6
ks(dvec(i),dvec(j))=ks(dvec(i),dvec(j))+kGlo(i,j);
end
end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Input Boundary Condition %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
kstar = ks;
for i=1 : ndof
if ( bc(i)==1 )
kstar(:,i) = 0;
kstar(i,:) = 0;
kstar(i,i) = 1;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%
% Assemble Force Vector %
%%%%%%%%%%%%%%%%%%%%%%%%%
force = P;
for i=1 : ndof
if( bc(i)==1 )
force(i) = disp(i);
for j=1 : ndof
if( j~=i )
force(j) = force(j) - ks(j,i)*disp(i);
end
end
end
end

2 of 4

16/10/2554 0:26 .

G:\Bai's Memory\Knowledge & Education\Ot...\LinearFrame.m

3 of 4

ug = kstar\force';
%%%%%%%%%%%%%%%%%%%%%%%%%%
% Internal element force %
%%%%%%%%%%%%%%%%%%%%%%%%%%
for e=1 : nelem
ns = connec(e,1);
ne = connec(e,2);
x_ns=node_coord(ns,1);
y_ns=node_coord(ns,2);
x_ne=node_coord(ne,1);
y_ne=node_coord(ne,2);
L=sqrt((x_ne-x_ns)^2+(y_ne-y_ns)^2);
ug_elem = [ug((ns-1)*3+1) ug((ns-1)*3+2) ug((ns-1)*3+3) ug((ne-1)*3+1) ug((ne-1)
*3+2) ug((ne-1)*3+3)]; % From destination vector
k = [ E*A/L 0 0 -E*A/L 0 0;
0 12*E*I/L 6*E*I/L^2 0 -12*E*I/L 6*E*I/L^2;
0 6*E*I/L^2 4*E*I/L 0 -6*E*I/L^2 2*E*I/L;
-E*A/L 0 0 E*A/L 0 0;
0 -12*E*I/L -6*E*I/L^2 0 12*E*I/L -6*E*I/L^2;
0 6*E*I/L^2 2*E*I/L 0 -6*E*I/L^2 4*E*I/L];
dx = x_ne-x_ns;
dy = y_ne-y_ns;
%%%%%%%%%%%%%%%%%%%%%%%%
% Tranformation Matrix %
%%%%%%%%%%%%%%%%%%%%%%%%
cos = dx/L;
sin = dy/L;
T = [

cos sin 0 0 0 0;
-sin cos 0 0 0 0;
0 0 1 0 0 0;
0 0 0 cos sin 0;
0 0 0 -sin cos 0;
0 0 0 0 0 1];

ul_elem = T*ug_elem';
force_elem = k*ul_elem;
Test = T\force_elem; % Checked Balanced Force (for nonlinear)
%%%%%%%%%%%%%%%%%%
% Element Output %
%%%%%%%%%%%%%%%%%%
No_of_element = e;
No_of_element
force_elem

16/10/2554 0:26 .

G:\Bai's Memory\Knowledge & Education\Ot...\LinearFrame.m

4 of 4

end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%
% Global Output %
%%%%%%%%%%%%%%%%%
ug

Potrebbero piacerti anche