matlab有限单元法计算桁架算例代码
E=1.0e7;
A=1.5;
node_number=6;
element_number=8;
nc=[0,0;0,40;40,0;40,40;80,0;80,40];
en=[1,3;1,4;2,4;3,4;3,5;4,5;4,6;5,6];
ed(1:node_number,1:2)=1;
constraint=[1,1;1,2;2,1;2,2];
for loopi=1:length(constraint);
ed(constraint(loopi,1),constraint(loopi,2))=0;
end
dof=0;
for loopi=1:node_number
for loopj=1:2
dof=dof+1;
ed (loopi,loopj)=dof
end
end
ek=EA[1,0,-1,0;0,0,0,0;-1,0,1,0;0,0,0,0];
k(1:dof,1:dof)=0;
thea(1:8)=0;
el(1:8)=0;
e2s(1:4)=0;
for loopi=1:element_number
for zi=1:2
e2s((zi-1)*2+1)=ed(en(loopi,zi),1);
e2s((zi-1)*2+2)=ed(en(loopi,zi),2);
end
el(loopi)=sqrt((nc(en(loopi,1),1)-nc(en(loopi,2),1))2+(nc(en(loopi,1),2)-nc(en(loopi,2),2))2);
theta(loopi)=asin((nc(en(loopi,1),2)-nc(en(loopi,2),2))/el(loopi)) ;
lmd=[cos(theta(loopi)) sin(theta(loopi));-sin(theta(loopi)) cos(theta(loopi))];
t=[lmd zeros(2);zeros(2) lmd] ;
dk=t’ekt/el(loopi);
for jx=1:4
for jy=1:4
if (e2s(jx)*e2s(jy)~=0);
k(e2s(jx),e2s(jy))=k(e2s(jx),e2s(jy))+dk(jx,jy);
end
end
end
end
num=[5 6 7 8 9 10 11 12]
kk=k(num,num)
F=[0 1;-2000 2;0 3;0 4;2000 5;0 6;4000 7;6000 8];
F1=zeros(8,1);
for i=1:8
F1(i)=F(i,1)
end
v=inv(kk)F1;
num1=[1 2 3 4];
kk1=k(num1,1:12);
u1=zeros(12,1);
for i=5:12
u1(i)=v(i-4)
end
F2=kk1u1
strain=zeros(8,1)
for loopi=1:element_number
uc1=zeros(2,1)
uc2=zeros(2,1)
el(loopi)=sqrt((nc(en(loopi,1),1)-nc(en(loopi,2),1))2+(nc(en(loopi,1),2)-nc(en(loopi,2),2))2);
theta(loopi)=asin((nc(en(loopi,1),2)-nc(en(loopi,2),2))/el(loopi)) ;
lmd1=[cos(theta(loopi)),sin(theta(loopi))];
uc1(1)= u1(2en(loopi,1)-1)
uc1(2)= u1(2 en(loopi,1))
uc2(1)= u1(2en(loopi,2)-1)
uc2(2)= u1(2 en(loopi,2))
ub=lmd1uc1;
ue=lmd1uc2;
strain (loopi)=(ub-ue)/el(loopi)
end
stress=E*strain
|
请发表评论