You are on page 1of 3

% Marco 2D. Ejemplo 5.1 "A First Course in FEM" Logan.

CONEC=[1 1 3;
223
335
445
5 5 6];
PROPEL=[1 30e6 0.15 0.02;
2 30e6 0.15 0.02
3 30e6 0.15 0.02
4 30e6 0.30 0.1
5 30e6 0.30 0.1];
COORNOD=[1 0 0;
2 10 15;
3 20 0;
4 30 15
5 32 11.25
6 38 0];
FUEXT=[5 125;
11 25];
RESTR=[1 0;
2 0;
30
16 0;
17 0];

nElem=size(CONEC,1);
nNode=max([max(CONEC(:,2)) max(CONEC(:,3))]);

kGlob=zeros(3*nNode,3*nNode);
fGlob=zeros(3*nNode,1);

for i=1:nElem
kElem=zeros(3*nNode,3*nNode);
gLibe=zeros(1,6);
gLibe(1:3)=(3*CONEC(i,2)*[1 1 1])-[2 1 0];
gLibe(4:6)=(3*CONEC(i,3)*[1 1 1])-[2 1 0];
nodEle=CONEC(i,2:3);
x1Node=COORNOD(nodEle(1),2);
x2Node=COORNOD(nodEle(2),2);
y1Node=COORNOD(nodEle(1),3);
y2Node=COORNOD(nodEle(2),3);
vecEle=[(x2Node-x1Node) (y2Node-y1Node)];
L=norm(vecEle);
theta=atan((y2Node-y1Node)/(x2Node-x1Node));
%theta=acos((dot(vecEle,[1 0]))/L);
S=sin(theta);
C=cos(theta);
EA=PROPEL(i,2)*PROPEL(i,3);
EI=PROPEL(i,2)*PROPEL(i,4);
Ca=EA/L;
Cb=EI/(L^3);
kElePrime=zeros(6,6);
kElePrime(1,2:6)=[0 0 -Ca 0 0];
kElePrime(2,3:6)=[6*L*Cb 0 -12*Cb 6*L*Cb];
kElePrime(3,4:6)=[0 -6*L*Cb 2*(L^2)*Cb];
kElePrime(4,5:6)=[0 0];
kElePrime(5,6)=-6*L*Cb;
kElePrime=kElePrime+kElePrime';
kElePrime(1,1)=Ca;
kElePrime(2,2)=12*Cb;
kElePrime(3,3)=4*(L^2)*Cb;
kElePrime(4,4)=Ca;
kElePrime(5,5)=12*Cb;
kElePrime(6,6)=4*(L^2)*Cb;
matrizT=zeros(6,6);
matrizT(1:3,1:3)=[C S 0;-S C 0;0 0 1];
matrizT(4:6,4:6)=[C S 0;-S C 0;0 0 1];
matRigElem=matrizT'*kElePrime*matrizT;
kElem(gLibe,gLibe)=matRigElem;
kGlob=kGlob+kElem;
end

fGlob(FUEXT(:,1))=FUEXT(:,2);

kGlobTemp = kGlob;
rArra=RESTR(:,1)';
kGlob(rArra,:)=[];
kGlob(:,rArra)=[];
fGlob(rArra)=[];
despl=kGlob\fGlob;

% Vector de deflexiones y rotaciones (rad)

n = length(despl) + length(rArra);
result = zeros(1, n);
d_index = 1; % Initialize an index for iterating through array A

for i = 1:n
if ismember(i,rArra)
result(i) = 0;
else
result(i) = despl(d_index);
d_index = d_index + 1;
end
end

result=result';
printf("Vector de deflexiones y rotaciones (rad): \n")
disp(result)

% calculo de fuerzas y pares en nodos

fGlob = kGlobTemp*result;

printf("Vector de fuerzas y pares en nodos: \n")


disp(fGlob)

You might also like