0% found this document useful (0 votes)
16 views19 pages

SAEED Assignment - 28 - 06 - 2024

,,m

Uploaded by

Tomble Bravo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views19 pages

SAEED Assignment - 28 - 06 - 2024

,,m

Uploaded by

Tomble Bravo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Question 10:

% 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:

119.7690 34.0136 -68.5425 -17.1099 -51.2265 -16.9037


34.0136 83.4879 18.2436 -6.1843 -52.2572 -77.3036
-68.5425 18.2436 77.5612 -22.6757 -9.0188 4.4321
-17.1099 -6.1843 -22.6757 55.4524 39.7856 -49.2681
-51.2265 -52.2572 -9.0188 39.7856 60.2453 12.4716
-16.9037 -77.3036 4.4321 -49.2681 12.4716 126.5717

1. Modified plot for Vertical Displacement


%========================================
% Preprocess
%========================================

NElem = 20; % Number of elements


NP = 18; % Number of nodes

E = ones(1,NElem)*30e6; % Young's modulus in psi


v = ones(1,NElem)*0.3; % Poisson's Ratio
t = ones(1,NElem)*1; % Thickness of each element in inches

% Coordinates (x, y) for each node


coor = [0 0; 20 0; 20 9; 11 9; 0 4.5; ...
% ... (add coordinates for all nodes) ...
];
% Connectivity (node indices for each element)
con = [1 2 3; 3 4 5; ...
% ... (add connectivity for all elements) ...
];
% Degree of freedom mapping for each node
np2dof = zeros(NP,2);
for ii = 1:NP
np2dof(ii,:) = [2*(ii-1)+1, 2*(ii-1)+2];
end
BCs = zeros(NP*2,2); % Boundary conditions
BCs(np2dof(1,1),:) = [1 0];
BCs(np2dof(1,2),:) = [1 0];

% Plotting using patch command


close all
figure(1)
xdata = reshape(coor(con(:,:),1),NElem,3)';
ydata = reshape(coor(con(:,:),2),NElem,3)';
zdata = ydata*0 + 1;
patch(xdata,ydata,zdata,'FaceColor','none')
axis equal
title('Original Mesh')

% 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
%=======================================

K = zeros(2*NP,2*NP); % Global stiffness matrix


Ae = zeros(NElem,1); % Element areas

for ii = 1:NElem
nodeIndices = con(ii,:);
coords = coor(nodeIndices, :);

x13 = coords(1,1) - coords(3,1);


x21 = coords(2,1) - coords(1,1);
x32 = coords(3,1) - coords(2,1);
y31 = coords(3,2) - coords(1,2);
y23 = coords(2,2) - coords(3,2);
y12 = coords(1,2) - coords(2,2);

J = [x13 y13; x23 y23];


detJ = det(J);
J_hat = zeros(4,4);
J_hat(1:2,1:2) = inv(J);
J_hat(3:4,3:4) = inv(J);

G = [1 0 0; 0 1 0; 0 0 1];
A = 1/detJ * [y23 0; 0 x32; x32 y23];
B = A * J_hat * G;

D = E(ii)/(1-v(ii)^2) * [1 v(ii) 0; v(ii) 1 0; 0 0 (1-v(ii))/2];


Ae(ii) = detJ / 2;

kel = Ae(ii) * t(ii) * B' * D * B;


fel = Ae(ii) * t(ii) / 3 * [1 0; 0 1; 1 0; 0 1; 1 0; 0 1] * fv(ii,:)';

ind = [np2dof(nodeIndices(1),:) np2dof(nodeIndices(2),:) np2dof(nodeIndices(3),:)];


K(ind,ind) = K(ind,ind) + kel;
F(ind) = F(ind) + fel;
end

% Applying boundary conditions


C = max(abs(K(:)))*1e4;
for ii = 1:2*NP
if BCs(ii,1) == 1
K(ii,ii) = K(ii,ii) + C;
F(ii) = F(ii) + BCs(ii,2) * C;
end
end

% Solve for displacements


Q = K\F;

% Output the horizontal displacement at the bottom-left node


disp_bottom_left = Q(1);
fprintf('Horizontal displacement at the bottom-left node: %.5f inches\n', disp_bottom_left);

%=============================================
% Post-processing
%=============================================

% Calculate deformed coordinates (original coordinates + nodal displacements)


SF = 1; % Scale factor for visualization purposes
coor2 = coor*0;
for ii = 1:NP
coor2(ii,:) = coor(ii,:) + [Q(np2dof(ii,1)) Q(np2dof(ii,2))]*SF;
end

% Plotting original and deformed meshes using patch command


close all
figure(2)
xdata = reshape(coor(con(:,:),1),NElem,3)';
ydata = reshape(coor(con(:,:),2),NElem,3)';
zdata = ydata*0 + 1;
patch(xdata,ydata,zdata,'FaceColor','none')
axis equal
title('Original Mesh')

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')

% Plot displacement map


figure(3)
cdata = reshape(Q(np2dof(con(:,:),2)),NElem,3)'; % Matlab will assign a color based on the
value of the displacement
patch(xdata2,ydata2,zdata,'FaceColor','interp','EdgeColor','k','CData',cdata,'CDataMapping','s
caled')
set(gca,'CLim',[min(cdata(:)) max(cdata(:))])
axis equal
title ('Vertical Displacements')
colorbar

% Calculate strain and stress


stress = zeros(3,NElem);
strain = zeros(3,NElem);
Ae = zeros(NElem,1);
for ii = 1:NElem
nodeIndices = con(ii,:);
coords = coor(nodeIndices, :);

x13 = coords(1,1) - coords(3,1);


x21 = coords(2,1) - coords(1,1);
x32 = coords(3,1) - coords(2,1);
y31 = coords(3,2) - coords(1,2);
y23 = coords(2,2) - coords(3,2);
y12 = coords(1,2) - coords(2,2);

J = [x13 y13; x23 y23];


detJ = det(J);

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];

ind = [np2dof(nodeIndices(1),:) np2dof(nodeIndices(2),:) np2dof(nodeIndices(3),:)];


strain(:,ii) = B * Q(ind);
stress(:,ii) = D * strain(:,ii);
Ae(ii) = detJ / 2;
end
% Plotting stresses as a color map
figure(4)
subplot(2,3,1)
cdata = stress(1,:)'; % 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 ('Sxx stress')
colorbar

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];

% Define the connectivity of the elements


elements = [1, 2, 5; 2, 3, 5; 3, 4, 5; 4, 1, 5];

% Material properties
E = 30e6; % psi
nu = 0.3;
t = 1; % inch

% Initialize global stiffness matrix and force vector


numNodes = size(nodes, 1);
numDOF = numNodes * 2;
K = zeros(numDOF, numDOF);
F = zeros(numDOF, 1);

% Force applied at node 5


F(2*5 - 1) = 120000; % Horizontal force

% Loop over each element to assemble the global stiffness matrix


for el = 1:size(elements, 1)
node_indices = elements(el, :);
coords = nodes(node_indices, :);
% Compute element stiffness matrix (B, D, etc.)
% ... (similar to the previous example)

% Assembly into global stiffness matrix


% ...
end

% Apply boundary conditions


% Node 1: fixed in both x and y directions
K(1, :) = 0;
K(:, 1) = 0;
K(1, 1) = 1;
K(2, :) = 0;
K(:, 2) = 0;
K(2, 2) = 1;

% Node 2: fixed in y direction


K(4, :) = 0;
K(:, 4) = 0;
K(4, 4) = 1;

% Solve the system of equations


U = K \ F;

% Horizontal displacement of the bottom-left node (Node 1)


disp_x = U(1);
disp(disp_x)
matlab
% Force applied at node 5
F(2*5 - 1) = 120000; % Horizontal force at Node 5
% Loop over each element to assemble the global stiffness matrix
for el = 1:size(elements, 1)
node_indices = elements(el, :);
coords = nodes(node_indices, :);

% Calculate element stiffness matrix


x = coords(:, 1);
y = coords(:, 2);
A = polyarea(x, y);

% B matrix (strain-displacement matrix)


B = 1/(2*A) * [y(2) - y(3), 0, y(3) - y(1), 0, y(1) - y(2), 0;
0, x(3) - x(2), 0, x(1) - x(3), 0, x(2) - x(1);
x(3) - x(2), y(2) - y(3), x(1) - x(3), y(3) - y(1), x(2) - x(1), y(1) - y(2)];

% D matrix (material property matrix)


D = (E/(1 - nu^2)) * [1, nu, 0;
nu, 1, 0;
0, 0, (1 - nu)/2];

% Element stiffness matrix


k_el = t * A * B' * D * B;

% Assembly into global stiffness matrix


for i = 1:3
for j = 1:3
K(2*node_indices(i)-1:2*node_indices(i), 2*node_indices(j)-1:2*node_indices(j)) =
...
K(2*node_indices(i)-1:2*node_indices(i), 2*node_indices(j)-1:2*node_indices(j))
+ k_el(2*i-1:2*i, 2*j-1:2*j);
end
end
end

% Apply boundary conditions


% Node 1: fixed in both x and y directions
K(1, :) = 0;
K(:, 1) = 0;
K(1, 1) = 1;
K(2, :) = 0;
K(:, 2) = 0;
K(2, 2) = 1;

% Node 2: fixed in y direction


K(4, :) = 0;
K(:, 4) = 0;
K(4, 4) = 1;

% Solve the system of equations


U = K \ F;

% Horizontal displacement of the bottom-left node (Node 1)


disp_x = U(1);
fprintf('Horizontal displacement of the bottom-left node (Node 1): %.6f inches\n', disp_x);

Answer: 0.0491 Inches

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy