FEM-Course-Matlab/3.matlab矩形薄板小挠度弯曲有限元编程/main_thickness.m

94 lines
2.2 KiB
Mathematica
Raw Normal View History

2024-01-28 16:46:36 +00:00
%----------------------------------------------------------------
% PURPOSE
% Analysis of a plate.
% unit mm N MPa
%----------------------------------------------------------------
clear all;clc;
%----- Topology -------------------------------------------------
%square plate with n element each side
n_length=100;
m_width=20;
num=0;
for j=1:m_width
for i=1:n_length
num=num+1;
Enode(num,:)=[num (j-1)*(n_length+1)+i (j-1)*(n_length+1)+i+1 (j)*(n_length+1)+i+1 (j)*(n_length+1)+i];
ex(num,:)=[(i-1)*5 i*5 i*5 (i-1)*5];%unit mm
ey(num,:)=[(j-1)*5 (j-1)*5 j*5 j*5];
if i*5>=0 && i*5<200
t(num)=0.5+(3-0.5)/200*i*5;
elseif i*5>=200 && i*5<300
t(num)=3;
elseif i*5>=300 && i*5<=500
t(num)=0.5+(3-0.5)/200*(500-i*5);
end
end
end
% Enode=[1 1 2 5 4;
% 2 2 3 6 5;
% 3 5 6 9 8;
% 4 4 5 8 7];
ndof=3;
Edof=caldof(Enode,ndof);
% ex=[0 1 1 0;
% 1 2 2 1;
% 1 2 2 1;
% 0 1 1 0];
% ey=[0 0 1 1;
% 0 0 1 1;
% 1 1 2 2;
% 1 1 2 2];
%----- Element stiffness ----------------------------------------
E=2.1*10^5; %2.1e5MPa
v=0.3;
D=hooke(E,v);
% t=2;
ep=[t];
nie=size(Enode,1);
for i=1:nie
Ke(:,:,i)=platre(ex(i,:),ey(i,:),ep(i),D);
end
%----- Assemble Ke into K ---------------------------------------
K=zeros(max(max(Edof))); K=assem(Edof,K,Ke);
%----- load vector f and boundary conditions bc -----------------
f=zeros(max(max(Edof)),1); f(3184)=-400;
num=0;
for i=0:20
num=num+1;
boundary_node(num)=(i)*101+1;
num=num+1;
boundary_node(num)=(i+1)*101;
end
for i=1:length(boundary_node)
bc((i-1)*3+1,:)=[3*(boundary_node(i)-1)+1 0];
bc((i-1)*3+2,:)=[3*(boundary_node(i)-1)+2 0];
bc((i-1)*3+3,:)=[3*(boundary_node(i)-1)+3 0];
end
%----- Solve the system of equations and compute reactions ------
[a]=solveq(K,f,bc);
%----- Postprocess ----------------------------------------------
Ed=extract(Edof,a);
num=0;
for i=1:21
for j=1:101
num=num+1;
x(i,j)=(j-1)*5;
y(i,j)=(i-1)*5;
z(i,j)=abs(a((num-1)*3+1));
end
end
surf(x,y,z)
xlabel('length(mm)');
ylabel('width(mm)');
zlabel('displacement(mm)');
%------------------------ end -----------------------------------