Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
188 views

Coding of Direct Stiffness Method

This document outlines the steps to perform a direct stiffness method analysis for a structural system. It includes taking inputs like the number of nodes, elements, nodal connectivities, and forces. It then creates the global stiffness matrix and force vector by looping through the elements. Boundary conditions are imposed by modifying the matrix. The displacements are then calculated by inverting the matrix and multiplying it by the force vector. Finally, it outputs the reactions and internal element forces.

Uploaded by

grabsp
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
188 views

Coding of Direct Stiffness Method

This document outlines the steps to perform a direct stiffness method analysis for a structural system. It includes taking inputs like the number of nodes, elements, nodal connectivities, and forces. It then creates the global stiffness matrix and force vector by looping through the elements. Boundary conditions are imposed by modifying the matrix. The displacements are then calculated by inverting the matrix and multiplying it by the force vector. Finally, it outputs the reactions and internal element forces.

Uploaded by

grabsp
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

%Coding of direct stiffness method

%Taking input

n=input('Enter number of nodes\n');
ne=input('Enter number of springs or elements\n');
nca=input('Enter the nodal connectivities in a form of matrix\n');
k=input('Enter the stiffness of the springs as an array\n');
nf=input('Enter number of forces\n');
f=input('Enter node number & force values as a matrix\n');
nr=input('Enter number of restraints\n');
nre=input('Enter node number of corresponding restraints as an array\n' );

%Creation of the global matrix

kg=zeros(n);
for i=1:ne
ke=[k(i) -k(i);-k(i) k(i)];
n1=nca(i,1);
n2=nca(i,2);
kg(n1,n1)=kg(n1,n1)+ke(1,1);
kg(n1,n2)=kg(n1,n2)+ke(1,2);
kg(n2,n1)=kg(n2,n1)+ke(2,1);
kg(n2,n2)=kg(n2,n2)+ke(2,2);
end

%Creation of force vector matrix.

kg_original=kg
fg=zeros(n,1);
for i=1:nf
n1=f(i,1);
fg(n1)=fg(n1)+f(i,2);
end

%Imposition of boundary conditions.

for i=1:nr
n1=nre(i);
kg(n1,:)=0;
kg(:,n1)=0;
kg(n1,n1)=1;
end

%Solution of global matrix.

U=inv(kg)*fg;
for i=1:n
fprintf('\nDisplacement of node %d = %fmm\n',i,U(i,1));
end

%Finding the reaction forces.

for i=1:nr
n1=nre(1,i);
R(n1)=0;
for j=1:n
R(n1)=R(n1)+kg_original(n1,j)*U(j,1);

end
fprintf('\nReaction at node %d=%f Newton\n',n1,R(n1));
end

%Finding the force on each spring.

for i=1:ne
k1=k(1,i);
n1=nca(i,1);
n2=nca(i,2);
n3=U(n1,1);
n4=U(n2,1);
F=k1*(n3-n4);
fprintf('\nForce on element %d = %f Newton\n',i,F);
end

You might also like