SAEED Assignment - 28 - 06 - 2024
SAEED Assignment - 28 - 06 - 2024
% Define matrix B
B = [[-5, 0, 4, 0, 1, 0];
[0, -3, 0, -2.5, 0, 5.5];
[-3, -5, -2.5, 4, 5.5, 1]] / 24.5;
% Define matrix D
D = 101.01 * [1, 0.1, 0;
0.1, 1, 0;
0, 0, 0.45];
% Define parameters
A = 24.5;
t = 1;
% Calculate k
k = B'*D*B*A*t;
% Display matrix k
disp('Matrix k:')
disp(k)
Matrix k:
% Force vector
fv = zeros(NElem,2); % Force per unit of volume (column 1 corresponds to x-direction)
F = zeros(2*NP,1);
F(np2dof(5,1)) = 120000; % Apply load of 120,000 lb/in at node 5 in x-direction
%=======================================
% Processing
%=======================================
for ii = 1:NElem
nodeIndices = con(ii,:);
coords = coor(nodeIndices, :);
G = [1 0 0; 0 1 0; 0 0 1];
A = 1/detJ * [y23 0; 0 x32; x32 y23];
B = A * J_hat * G;
%=============================================
% Post-processing
%=============================================
hold on
xdata2 = reshape(coor2(con(:,:),1),NElem,3)';
ydata2 = reshape(coor2(con(:,:),2),NElem,3)';
zdata = ydata*0 + 1;
patch(xdata2,ydata2,zdata,'FaceColor','none','EdgeColor',[1 0 0])
axis equal
title('Deformed Mesh')
legend ('Original','Deformed')
B = 1/detJ * [y23 0 y31 0 y12 0; 0 x32 0 x13 0 x21; x32 y23 x13 y31 x21 y12];
D = E(ii)/(1-v(ii)^2) * [1 v(ii) 0; v(ii) 1 0; 0 0 (1-v(ii))/2];
subplot(2,3,2)
cdata = stress(2,:)'; % Matlab will assign a color based on the value of the stress
patch(xdata2,ydata2,zdata,'FaceColor','flat','EdgeColor','k','CData',cdata,'CDataMapping','scal
ed')
set(gca,'CLim',[min(cdata(:)) max(cdata(:))])
axis equal
title ('Syy stress')
colorbar
subplot(2,3,3)
cdata = stress(3,:)'; % Matlab will assign a color based on the value of the stress
patch(xdata2,ydata2,zdata,'FaceColor','flat','EdgeColor','k','CData',cdata,'CDataMapping','scal
ed')
set(gca,'CLim',[min(cdata(:)) max(cdata(:))])
axis equal
title ('Txy stress')
colorbar
subplot(2,3,4)
cdata = strain(1,:)'; % Matlab will assign a color based on the value of the strain
patch(xdata2,ydata2,zdata,'FaceColor','flat','EdgeColor','k','CData',cdata,'CDataMapping','scal
ed')
set(gca,'CLim',[min(cdata(:)) max(cdata(:))])
axis equal
title ('Exx strain')
colorbar
subplot(2,3,5)
cdata = strain(2,:)'; % Matlab will assign a color based on the value of the strain
patch(xdata2,ydata2,zdata,'FaceColor','flat','EdgeColor','k','CData',cdata,'CDataMapping','scal
ed')
set(gca,'CLim',[min(cdata(:)) max(cdata(:))])
axis equal
title ('Eyy strain')
colorbar
subplot(2,3,6)
cdata = strain(3,:)'; % Matlab will assign a color based on the value of the strain
patch(xdata2,ydata2,zdata,'FaceColor','flat','EdgeColor','k','CData',cdata,'CDataMapping','scal
ed')
set(gca,'CLim',[min(cdata(:)) max(cdata(:))])
axis equal
title ('Gxy strain')
colorbar
% Calculate nodal values of stress and strain and plot them the same way as the displacement
W = zeros(NP,NP);
R = zeros(NP,6);
for ii = 1:NElem
We = Ae(ii)/12*[2 1 1;1 2 1;1 1 2];
Re = Ae(ii)/3*[1;1;1]*[strain(:,ii)' stress(:,ii)'];
W(con(ii,:),con(ii,:)) = W(con(ii,:),con(ii,:)) + We;
R(con(ii,:),:) = R(con(ii,:),:) + Re;
end
EandS = inv(W)*R;
figure(5)
subplot(2,3,1)
cdata = reshape(EandS(con(:),4),NElem,3)'; % Matlab will assign a color based on the value
of the stress
patch(xdata2,ydata2,zdata,'FaceColor','interp','EdgeColor','k','CData',cdata,'CDataMapping','s
caled')
set(gca,'CLim',[min(cdata(:)) max(cdata(:))])
axis equal
title ('Sxx stress')
colorbar
subplot(2,3,2)
cdata = reshape(EandS(con(:),5),NElem,3)'; % Matlab will assign a color based on the value
of the stress
patch(xdata2,ydata2,zdata,'FaceColor','interp','EdgeColor','k','CData',cdata,'CDataMapping','s
caled')
set(gca,'CLim',[min(cdata(:)) max(cdata(:))])
axis equal
title ('Syy stress')
colorbar
subplot(2,3,3)
cdata = reshape(EandS(con(:),6),NElem,3)'; % Matlab will assign a color based on the value
of the stress
patch(xdata2,ydata2,zdata,'FaceColor','interp','EdgeColor','k','CData',cdata,'CDataMapping','s
caled')
set(gca,'CLim',[min(cdata(:)) max(cdata(:))])
axis equal
title ('Txy stress')
colorbar
subplot(2,3,4)
cdata = reshape(EandS(con(:),1),NElem,3)'; % Matlab will assign a color based on the value
of the strain
patch(xdata2,ydata2,zdata,'FaceColor','interp','EdgeColor','k','CData',cdata,'CDataMapping','s
caled')
set(gca,'CLim',[min(cdata(:)) max(cdata(:))])
axis equal
title ('Exx strain')
colorbar
subplot(2,3,5)
cdata = reshape(EandS(con(:),2),NElem,3)'; % Matlab will assign a color based on the value
of the strain
patch(xdata2,ydata2,zdata,'FaceColor','interp','EdgeColor','k','CData',cdata,'CDataMapping','s
caled')
set(gca,'CLim',[min(cdata(:)) max(cdata(:))])
axis equal
title ('Eyy strain')
colorbar
subplot(2,3,6)
cdata = reshape(EandS(con(:),3),NElem,3)'; % Matlab will assign a color based on the value
of the strain
patch(xdata2,ydata2,zdata,'FaceColor','interp','EdgeColor','k','CData',cdata,'CDataMapping','s
caled')
set(gca,'CLim',[min(cdata(:)) max(cdata(:))])
axis equal
title ('Gxy strain')
colorbar
2. Solution:
% Define the node coordinates
nodes = [0, 0; 29, 0; 29, 9; 9, 9; 0, 4.5];
% Material properties
E = 30e6; % psi
nu = 0.3;
t = 1; % inch