Challenge

MATLAB Module For Calculating Global Stiffness Matrix

Objective: -

  • To calculate the individual stiffness matrix for the elements
  • To calculate the global stiffness matrix
  • To analyze the 2D frame using Mastan and compute the results

Solution procedure: -

  • Calculation of number of the nodes
  • Calculation of number of elements
  • Then assign the maximum number of degree the freedom that can b associated with the structure
  • Pre-assigning the stiffness matrix with zero and initializing it as a zero matrix
  • Then use we looped over the number of elements used to control the flow operator to invoke the concept of nested function
  • Stiffness of the members is the forces applied on the member that produces a unit displacement

Function to calculate the Axial Stiffness Matrix

% Function to compute the stiffness
% To calculate axial element stiffness
% Input Parameters
% Dof - Degree of freedom
% node_xy - Vector containing node informations
% E - modulus of elasticity =200000mpa
% A - Area of cross-section =1000 sqmm

function [stiffness] = axial_element_stiffness_mix(dof,node_xy,E,A)
stiffness = zeros(size(node_xy,1));               

% Computation of the element stiffness matrix

node_x =node_xy(:,1);
node_y = node_xy(:,2);

x_co = node_x(2,1) - node_x(1,1);
y_co = node_y(2,1) - node_y(1,1);

length_element = sqrt(x_co*x_co + y_co*y_co);

C = x_co/length_element
S = y_co/length_element

stiffness = ((E*A)/length_element)* [C*C C*S -C*C -C*S; C*S S*S -C*S -S*S; -C*C -C*S C*C C*S; -C*S -S*S C*S S*S];

end

Explanation of the above code function:-

% Function to compute stiffness - comments
% To clculate axial element stiffness
% Input Parameters
% Dof - Degree of freedom - comments to make a program user friendly
% node_xy - Vector containing node informations
% E - modulus of elasticity
% A - Area of cross section

function [stiffness] = axial_element_stiffness_mix(dof,node_xy,E,A) - to calculate the stiffness matrix
stiffness = zeros(size(node_xy,1)); - to make a zeroes matrix of the size of the node coordinates

% Computation of the element stiffness matrix

node_x =node_xy(:,1); - to access the column1 one of the matrix of node coordinates
node_y = node_xy(:,2);- to access the column2 one of the matrix of node coordinates

x_co = node_x(2,1) - node_x(1,1); - calculation to calculate the length of the element
y_co = node_y(2,1) - node_y(1,1);- calculation to calculate the length of the element

length_element = sqrt(x_co*x_co + y_co*y_co); - to calculate the length of the element

C = x_co/length_element - to calculate the values
S = y_co/length_element

stiffness = ((E*A)/length_element)* [C*C C*S -C*C -C*S; C*S S*S -C*S -S*S; -C*C -C*S C*C C*S; -C*S -S*S C*S S*S]; - matrix generated to calculate the axial stiffness matrix for the elements
%stiffness = stiffness + k1 %-----------------we don't want to add new stiffness matrix to the older one(same dimension),instead use this step in while calculating Global stiffness matrix
end - toend the function

_______________________________________________________________________________________________________________

Function for the code to calculate global stiffness matrix: -

% funtion for the Global Stiffness matrix
% [stiffness_matrix] = global_stiffnesss_matrix([0 0;0 4;4 4;4 0],[1 2;2 3;3 4;4 1],200000,1000)
function[stiffness_matrix] = global_stiffnesss_matrix(node_xy,elements,E,A)
no_nodes = size(node_xy,1);
%to calculate no of nodes
no_elements =size(elements,1);
%To calculate number of elements
%To computate the number of degrees of freedom
%Assuming 2 dof per node
dof=2*no_nodes;
%Assigning stiffness matrix to zero for degree of freedom
stiffness_matrix = zeros(2*no_nodes);
for e=1:no_elements
%elementDof : element degrees of freedom(Dof)
%elements_nodes : element_nodes
element_nodes = elements(e,1:2);
%nodes coordinates
node_co = node_xy(element_nodes,:);
% Nested function : Calling function in function
stiffness = axial_element_stiffness_mix(dof,node_co,E,A);
element_dof = 2*(element_nodes(1)-1)+1:2*(element_nodes(1)-1)+2;
element_dof =[element_dof 2*(element_nodes(2) - 1)+1:2*(element_nodes(2)-1)+2];
stiffness_matrix(element_dof,element_dof) =...
stiffness_matrix(element_dof,element_dof)+ stiffness;

end
    

Explanation of the above function code for global stiffness matrix: -

function[stiffness_matrix] = global_stiffnesss_matrix(node_xy,elements,E,A) - to calculate the global stiffness matrix
no_nodes = size(node_xy,1); - to calculate the size of the nodes or number of the nodes
%to calculate no of nodes
no_elements =size(elements,1); - to calculate the number of the elements
%To calculate number of elements
%To computate the number of degrees of freedom
%Assigning stiffness matrix to zero for degree of freedom

%Assuming 2 dof per node
dof=2*no_nodes;
stiffness_matrix= zeros(2*no_nodes); - initializing the matrix with zeros with respect to number of nodes
for e=1:no_elements - loop to transverse through the number of the lements
%elementDof : element degrees of freedom(Dof)
%elements_nodes : element_nodes
element_nodes = elements(e,1:2); - calculating the element nodes
%nodes coordinates
node_co = node_xy(element_nodes,:); - to calculate the nodes coordinates
% Nested function : Calling function in function
stiffness = challenge2_test(); - calling the function calculate the individual stiffness matrix
element_dof = 2*(element_nodes(1)-1)+1:2*(element_nodes(1)-1)+2; - to calculate the degree of freedom for the elements
element_dof =[element_dof 2*(element_nodes(2) - 1)+1:2*(element_nodes(2)-1)+2]; - to calculate the degree of freedom for the elements
stiffness_matrix(element_dof,element_dof) =...
stiffness_matrix(element_dof,element_dof)+ stiffness; - to perform the contamination of the individual matrices generated
end - end for the fuction

Results : -

global stiffness matrix

_____________________________________________________________________________________________________

4) Perform analysis on the following 2D frame using Mastan 2

Moment about Z

Shear Y values

Shear Z values

Displacement at point of application of loads at Node 2,3 as UDL and Node N5 Axial force:-

Model information:-

Result and conclusion: -

  • We performed the analysis but for the truss, we only should have an axial force, and but for the frame analysis we have other forces also.
  • We use the 1st order elastic frame analysis for the above problem.
  • The above report consist of a screen snapshot of


    ● Model information
    ● Moment about Z
    ● Shear values
    ● Displacement at point of application of loads

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.