0% found this document useful (0 votes)
12 views3 pages

% Material Properties

Uploaded by

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

% Material Properties

Uploaded by

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

% material properties

Ym = 206.8*10^9; %Ym: Young's modulus


Pr = 0.3; % Pr: Poisson's ratio
% element properties
th=0.0254; % Thickness

Fapp=22.24*10^3; dof=1; % Force applied and its direction


type=1; % 1 for plane stress and 2 for plane strain

% nodal coordinates
NX=[0 0;0 0.2540;0.5080 0.2540;0.5080 0];
% connectivity
C=[1 3 2;1 4 3];
% applied force data; each row node, dof, force value
forces=[3 1 22226;4 1 22226];
% displacement bc data; each row node, fixed bc type, value
dispbc =[1 1 0.0;1 2 0.0;2 1 0.0;2 2 0.0];
% analysis parameters
nelem=size(C,1); %no of elements
nnod=size(NX,1); %no of nodes
ndof=2; % dof/node

% D matrix
function D = elemstf(Ym, Pr, planeStress)
% Check if plane stress is specified as '1'
if planeStress == 1
% Constitutive matrix D for plane stress condition
D = (Ym / (1 - Pr^2)) * [1, Pr, 0;
Pr, 1, 0;
0, 0, (1 - Pr) / 2];
else
error('Only plane stress condition is supported. Set planeStress to 1.');
end
end

function [Ke, sig] = stiffT3(xe, ye, D, th, Ue)


% stiffT3 calculates the stiffness matrix and stresses for a T3 element.
% Inputs:
% xe, ye - Coordinates of the 3 nodes (arrays of length 3)
% D - Constitutive matrix for plane stress (3x3)
% th - Thickness of the element
% Ue - Nodal displacement vector (6x1), optional
% Outputs:
% Ke - Element stiffness matrix (6x6)
% sig - Stress vector (3x1), if Ue is provided

% Calculate area of the triangle


A = 0.5 * abs(xe(1)*(ye(2) - ye(3)) + xe(2)*(ye(3) - ye(1)) + xe(3)*(ye(1) -
ye(2)));

% Calculate the components of the B matrix


b1 = ye(2) - ye(3);
b2 = ye(3) - ye(1);
b3 = ye(1) - ye(2);
c1 = xe(3) - xe(2);
c2 = xe(1) - xe(3);
c3 = xe(2) - xe(1);
% Form the strain-displacement matrix B
B = (1 / (2 * A)) * [
b1, 0, b2, 0, b3, 0;
0, c1, 0, c2, 0, c3;
c1, b1, c2, b2, c3, b3
];

% Calculate the stiffness matrix Ke


Ke = B' * D * B * A * th;

% Calculate the stress vector if Ue is provided


if nargin == 5
% Calculate strain: epsilon = B * Ue
epsilon = B * Ue;
% Calculate stress: sigma = D * epsilon
sig = D * epsilon;
else
sig = [];
end
end

% initialisation
% global stiffness
%K = zeros();
% global force
%F = zeros(,1);
%freedof=zeros(,1);
K = zeros(nnod * ndof); % Global stiffness matrix
F = zeros(nnod * ndof, 1); % Global force vector
freedof = ones(nnod * ndof, 1); % Free DOF indicator
% Initiating global force vector
% form global stiffness, loop over all elements
for ielem = 1:nelem
conn=C(ielem, :); %get the connectivity for ielem
n1=conn(1);n2=conn(2);n3=conn(3);
%xe=; % get the nodal x coordinates for ielem
%ye=; % get the nodal y coordinates for ielem
xe = NX(conn, 1); % x-coordinates
ye = NX(conn, 2); % y-coordinates
% dest=; % destination matrixfor ielem
D=elemstf(Ym,Pr,1);
[Ke, sig] = stiffT3(xe, ye, D, th);
dest = [(n1-1)*ndof+1, (n1-1)*ndof+2, (n2-1)*ndof+1, (n2-1)*ndof+2, (n3-
1)*ndof+1, (n3-1)*ndof+2];
K(dest, dest) = K(dest, dest) + Ke;
% D matrix for plane stress
%Ke=stiffT3(); %function to create local stiffness matrix for T3 element
% assemble into K
Ke
if ielem == 1
Ke1=Ke;
end
if ielem == 2
Ke2=Ke;
end
end
Kg=K;
K
tempKg=K;
% there are only nodal forces in this problem
% form rhs force vector
%F=(0 0 0 0 -6.89e9*0.127 0 -6.89e9*0.127 0);

% Apply nodal forces


for i = 1:size(forces, 1)
node = forces(i, 1);
dof = forces(i, 2);
forceValue = forces(i, 3);
globalDof = (node - 1) * ndof + dof;
F(globalDof) = F(globalDof) + forceValue;
end
F

% Applying B.C.
%freedof() = ;
for i = 1:size(dispbc, 1)
node = dispbc(i, 1);
dof = dispbc(i, 2);
globalDof = (node - 1) * ndof + dof;
Kg(globalDof, :) = 0; % Zero out the row
Kg(:, globalDof) = 0; % Zero out the column
Kg(globalDof, globalDof) = 1; % Set diagonal to 1
F(globalDof) = dispbc(i, 3); % Set displacement value
end
Kg
% modify rhs for disp boundary condition
U=Kg\F;
% solve for U
U
Kg=tempKg;
% post processing
for ielem=1:nelem
conn=C(ielem, :);; %get the connectivity for ielem
n1=conn(1);n2=conn(2);n3=conn(3);
xe = NX(conn, 1); % x-coordinates
ye = NX(conn, 2); % y-coordinates

dest = [(n1-1)*ndof+1, (n1-1)*ndof+2, (n2-1)*ndof+1, (n2-1)*ndof+2, (n3-


1)*ndof+1, (n3-1)*ndof+2];
D=elemstf(Ym,Pr,1);
Ue=U(dest);
[Ke,sig]=stiffT3(xe, ye, D, th,Ue); %get local stiffness and stresses from the
same function
if ielem == 1
sig1=sig;
end
if ielem == 2
sig2=sig;
end
end

You might also like