Escolar Documentos
Profissional Documentos
Cultura Documentos
clc
clear all
close
%entrada de dados
%coord=[Xno Yno]
coord=[0 0
4 0
8 0
12 0
16 0
20 5
12 5
4 5
0 5];
%incidencia de elementos
%inci=[elemento,prop mat,prop geom,noi,noj,]
inci=[1 2 2 1 2
2 2 2 2 3
3 2 2 3 4
4 2 1 4 5
5 2 2 5 6
6 2 2 6 7
7 2 2 7 8
8 2 1 8 9
9 2 1 1 8
10 2 1 8 2
11 2 1 8 3
12 2 1 7 3
13 2 1 7 4
14 2 1 7 5
15 2 2 9 1];
%propriedades geométricas
%tgeo=[area m^2;momento de inercia m^4]
tgeo=[0.005 0.003 0.1
0.0001 0.0001 0.0001];
%condições de contorno
%cont=[nº do no, GDL(U=1,V=2),valor]
cont=[1 1 0
1 2 0
9 1 0];
%forças
%loads=[nº do no, GDL(U=1,V=2),valor]
loads=[6 2 -4];
%-----------------------------------------------------------------------
%Modulo de Calculo
%nº de nós
disp('#####################################')
disp(' n de nos ')
nnos=size(coord,1)
%nº de elementos
disp('n de elementos')
nel=size(inci,1)
%n de condioes de contorno
ncont=size(cont,1);
for i=1:ncont
id(cont(i,2),cont(i,1))=0;
end
for i=1:nnos
for j=1:ngdl
if id(j,i)==1
neq=neq+1;
id(j,i)=neq;
end
end
end
disp(' ######################################')
disp(' numero de equacoes ')
neq
F=zeros(neq,1);
Kg=zeros(neq,neq);
nloads=size(loads,1);
for i=1:nloads
% //if loads(i,2),loads(i,1))==0
% // disp('A Força aplicada no grau de liberdade',loads(i,2),'do
nó',loads(i,1),'está em um nó travado')
% // halt
% // else
% // end
F(id(loads(i,2),loads(i,1)),1)=loads(i,3);
end
for i=1:nel
ke=zeros(ngdel,ngdel);
noi=inci(i,4);
noj=inci(i,5);
xi=coord(noi,1);
yi=coord(noi,2);
xj=coord(noj,1);
yj=coord(noj,2);
xm=(xi+xj)/2;
ym=(yi+yj)/2;
coordm(i,1)=xm;
coordm(i,2)=ym+0.1;
L=sqrt((xj-xi)^2+(yj-yi)^2);
c=(xj-xi)/L;
s=(yj-yi)/L;
ntgeo=inci(i,3);
ntmat=inci(i,2);
Area=tgeo(1,ntgeo);
Inercia=tgeo(2,ntgeo);
E=tmat(1,ntmat);
for il=1:ngdel
ilg=loc(il);
if ilg~=0
for ic=1:ngdel
icg=loc(ic);
if icg~=0
Kg(ilg,icg)=Kg(ilg,icg)+ke(il,ic);
end
end
end
end
end
% disp('Matriz Global')
Kg
for i=1:nel
A(inci(i,4),inci(i,4))=1;
A(inci(i,5),inci(i,5))=1;
A(inci(i,4),inci(i,5))=1;
A(inci(i,5),inci(i,4))=1;
end
xmin=min(coord(:,1));
xmax=max(coord(:,1));
ymin=min(coord(:,2));
ymax=max(coord(:,2));
Lx=xmax-xmin;
Ly=ymax-ymin;
xmin=xmin-0.3*Lx;
xmax=xmax+0.3*Lx;
ymin=ymin-0.3*Ly;
ymax=ymax+0.3*Ly;
xyz=[coord(:,1) coord(:,2)];
xyz(:,3)=0;
xy=[coord(:,1) coord(:,2)];
gplot(A,xyz);
axis([xmin xmax ymin ymax]);
for i=1:nel
A(inci(i,4),inci(i,4))=1;
A(inci(i,5),inci(i,5))=1;
A(inci(i,4),inci(i,5))=1;
A(inci(i,5),inci(i,4))=1;
end
xmin=min(coord(:,1));
xmax=max(coord(:,1));
ymin=min(coord(:,2));
ymax=max(coord(:,2));
Lx=xmax-xmin;
Ly=ymax-ymin;
xmin=xmin-0.03*Lx;
xmax=xmax+0.03*Lx;
ymin= ymin-0.03*Ly;
ymax=ymax+0.03*Ly;
xyz=[coord(:,1) coord(:,2)];
xyz(:,3)=0;
xy=[coord(:,1) coord(:,2)];
gplot(A,xyz);
hold ( 'on' )
%Plotando a trelica deslocada
%3##################
fator=800000;
% #############
coordX = coord;
for i=1:size(id,1);
for j=1:size(id,2);
if id(i,j) ~= 0;
coordX(j,i) = coord(j,i) + fator*X(id(i,j));
end
end
end
gplot(A,coordX,'r');
grid
% //annotation1 = annotation('textarrow',...
% // [0.7111 0.7111],[0.8 0.6771],'String',{'1000'});
% //annotation1 = annotation('textarrow',...
% // [0.3232 0.3232],[0.8 0.6771],'String',{'1000'});
for i=1:nel;
text(coordm(i,1),coordm(i,2),num2str(i));
end
% % #####################################
% % % #####################################
% for i=1:5
%
% xi=coord(noi,1);
% yi=coord(noi,2);
% xj=coord(noj,1);
% yj=coord(noj,2);
%
% L=sqrt(((xj-xi)^2)+((yj-yi)^2));
%
% Tensao(i)=E*(X(i+1)-X(i))/L
% end
%
% % #####################################
% % #####################################
% Tarefa
% //calcular tensao nas barras da treliça e comparar com Ansys
% //Elemento Link 1
KgL=zeros(neq,neq);
for i=1:nel
ke=zeros(ngdel,ngdel);
noi=inci(i,4);
noj=inci(i,5);
xi=coord(noi,1);
yi=coord(noi,2);
xj=coord(noj,1);
yj=coord(noj,2);
xm=(xi+xj)/2;
ym=(yi+yj)/2;
coordm(i,1)=xm;
coordm(i,2)=ym+0.1;
L=sqrt((xj-xi)^2+(yj-yi)^2);
c=(xj-xi)/L;
s=(yj-yi)/L;
ntgeo=inci(i,3);
ntmat=inci(i,2);
Area=tgeo(1,ntgeo);
Inercia=tgeo(2,ntgeo);
E=tmat(1,ntmat);
for il=1:ngdel
ilg=loc(il);
if ilg~=0
for ic=1:ngdel
icg=loc(ic);
if icg~=0
KgL(ilg,icg)=KgL(ilg,icg)+keL(il,ic);
end
end
end
end
end
KgL