You are on page 1of 36

MSc Structural Analysis

Andrew Phillips
MEng PhD

Lecturer in Structural Engineering and Structural Biomechanics Imperial College London Structural Biomechanics, Structures Section Department of Civil and Environmental Engineering www.imperial.ac.uk/structuralbiomechanics

Implementing the Matrix Stiness Method

Implementing the Matrix Stiness Method

Previously it was stated that the matrix stiness method could easily be implemented in a program such as Matlab. Here we will look at the implementation for a beam and a frame example. The approach can be used for any structure made up of distinct elements connected together at nodes or joints.

Implementing the Matrix Stiness Method

Beam Example

Implementing the Matrix Stiness Method

Node and Element Numbering

Implementing the Matrix Stiness Method

Matlab Code: Setting Up

% Setting up a member stiffness matrix (bending) k = [4 2; 2 4]; % Setting up a matrix of distributed loads w=[40 20 20 60]; % Setting up a matrix of lengths L=[4 6 6 4]; % Setting up a matrix of EI values EI = [1 1.5 1.5 2]; % Assuming use of UB402x140x42 EI = EI.*(2.05*108*0.0001569); % kN/m2 * m4

Implementing the Matrix Stiness Method

Matlab Code: Moment Stiness Matrix

% Setting up the combined structure stiffness matrix % Based on the degree of kinematic indeterminacy (5) ndof=5; K=zeros(ndof,ndof); for n=1:ndof-1 K(n:n+1,n:n+1)=K(n:n+1,n:n+1)+k.*EI(n)./L(n); end

Implementing the Matrix Stiness Method

Matlab Code: Fixed End Moments

% Setting up fixed end moments for each span (FE-M) FEMspan = zeros(ndof-1,2); for n=1:ndof-1 FEMspan(n,1) = +w(n).*L(n)2./12; FEMspan(n,2) = -w(n).*L(n)2./12; end % Setting up fixed end moments at each support (FE-M) FEMsupport=zeros(ndof,1); FEMsupport(1,1)=FEMspan(1,1); for n=2:ndof-1 FEMsupport(n,1)=FEMspan(n-1,2)+FEMspan(n,1); end FEMsupport(ndof,1)=FEMspan(ndof-1,2);

Implementing the Matrix Stiness Method

Matlab Code: Finding Values

= K 1 (R FE )

%%%% Calculation to find values of theta %%%% theta=(K-1)*(-FEMsupport); fprintf('Theta Values (rad): \n'); fprintf('%1.4e, ',theta); fprintf('\n\n');

Theta Values (rad): -1.8199e-003, 3.2354e-004, 1.1122e-004, -7.6841e-004, 1.6278e-003,

Implementing the Matrix Stiness Method

Matlab Code: Vertical Reactions Stiness Matrix

% Setting up a vertical stiffness matrix % These values can be taken from the 3D member stiffness matrix kvert = [6 6; -6 -6]; Kvert = zeros(ndof,ndof); for n=1:ndof-1 Kvert(n:n+1,n:n+1)=Kvert(n:n+1,n:n+1)+kvert.*EI(n)./L(n).2; end

Implementing the Matrix Stiness Method

Matlab Code: Fixed End Vertical Reactions

% Setting up fixed end vertical reactions for each span (FE-R2) FER2span = zeros(ndof-1,2); for n=1:ndof-1 FER2span(n,1) = w(n).*L(n)./2; FER2span(n,2) = w(n).*L(n)./2; end % Setting up fixed end vertical reactions for each support (FE-R2) FER2support=zeros(ndof,1); FER2support(1,1)=FER2span(1,1); for n=2:ndof-1 FER2support(n,1)=FER2span(n-1,2)+FER2span(n,1); end FER2support(ndof,1)=FER2span(ndof-1,2);

Implementing the Matrix Stiness Method

Matlab Code: Vertical Reactions

%%%% Calculation to find values for the vertical support reactions (R2) R2 = FER2support+Kvert*theta; fprintf('Vertical Support Reactions (kN): \n'); fprintf('%1.4e, ',R2); fprintf('\n\n');

Vertical Support Reactions (kN): 6.1951e+001, 1.6154e+002, 1.1122e+002, 2.0602e+002, 9.9268e+001,

Implementing the Matrix Stiness Method

Conclusions

The script can be generalised for any continuous beam. Results are found to match those obtained from Oasys GSA excluding shear deformations.

Implementing the Matrix Stiness Method

Frame Example

Implementing the Matrix Stiness Method

Node and Element Numbering

Implementing the Matrix Stiness Method

Matlab Code: Setting Up

% Defining the number of elements numelem=13; % Defining the number of nodes numnodes=11; % Defining pinned supports supports=[1 1 1 0; 2 1 1 0; 3 1 1 0; 4 1 1 0];

Implementing the Matrix Stiness Method

Matlab Code: Setting Up

% E I A

Taking a Steel UB406x140x46 = 2.05*108; %(kN/m2) = 15685*10-8; %(m4) = 58.6*10-4; %(m2)

% See the labelling on the diagram L = zeros(numelem,1); %number of elements L(1:12,1)=4; %refer to diagram L(13,1)=4*sqrt(2); %refer to diagram

Implementing the Matrix Stiness Method

Matlab Code: Member Stiness Matrices

% Setting up a reference member stiffness matrix for each member k=zeros(6,6,numelem); for n=1:numelem k(1:6,1:6,n) = [E*A/L(n) 0 0 -E*A/L(n) 0 0;... 0 12*E*I/L(n)3 6*E*I/L(n)2 0 -12*E*I/L(n)3 6*E*I/L(n)2;... 0 6*E*I/L(n)2 4*E*I/L(n) 0 -6*E*I/L(n)2 2*E*I/L(n);... -E*A/L(n) 0 0 E*A/L(n) 0 0;... 0 -12*E*I/L(n)3 -6*E*I/L(n)2 0 12*E*I/L(n)3 -6*E*I/L(n)2;... 0 6*E*I/L(n)2 2*E*I/L(n) 0 -6*E*I/L(n)2 4*E*I/L(n)]; end

Implementing the Matrix Stiness Method

Matlab Code: Member Stiness Matrices

% Rotating the member stiffness matices into the global axes alpha=[90 90 90 90 90 90 90 0 0 0 0 0 45]; alpha=alpha*pi./180; N=zeros(3,3,numelem); kdash=zeros(6,6,numelem); for n=1:numelem; % Setting up a transformation matrix for each of the four quadrants N(1:3,1:3,n)=[cos(alpha(n)) +sin(alpha(n)) 0;... -sin(alpha(n)) cos(alpha(n)) 0;... 0 0 1]; % kdash(1:3,1:3,n)=N(:,:,n)'*k(1:3,1:3,n)*N(:,:,n); kdash(1:3,4:6,n)=N(:,:,n)'*k(1:3,4:6,n)*N(:,:,n); kdash(4:6,1:3,n)=N(:,:,n)'*k(4:6,1:3,n)*N(:,:,n); kdash(4:6,4:6,n)=N(:,:,n)'*k(4:6,4:6,n)*N(:,:,n); end

Implementing the Matrix Stiness Method

Matlab Code: Member Stiness Matrices

Alternative code to transform k to kdash for each element


%%%% The same transformation can be achieved using this code block N=zeros(6,6,numelem); kdash=zeros(6,6,numelem); for n=1:numelem; % setting up a transformation matrix for all four quadrants % top-left and bottom-right quadrants of N contain trigonometric terms % top-right and bottom-left quadrants of N contain zero terms N(1:3,1:3,n)=[cos(alpha(n)) +sin(alpha(n)) 0;... -sin(alpha(n)) cos(alpha(n)) 0;... 0 0 1]; N(4:6,4:6,n)=N(1:3,1:3,n); % kdash(1:6,1:6,n)=N(:,:,n)'*k(:,:,n)*N(:,:,n); end

Implementing the Matrix Stiness Method

Assembling the Structure Stiness Matrix

% Setting up connectivity tables for the elements % Refer to the diagram % This will be used to shape the global stiffness matrix connelem=[1 5; 2 6; 3 7; 4 8; 6 9; 7 10; 8 11;... 5 6; 6 7; 7 8; 9 10; 10 11;... 5 9]; % % % % % As mentioned the k matrices can be broken into quadrants 3x3 in size Deriving an initial global stiffness matrix, K Note the final matrix must be symmetrical about the diagonal Taking each of the nodes in turn and working out where the different quadrant of the original kdash matrices should be placed in K

K=zeros(numnodes*3,numnodes*3); Klogic=zeros(numnodes,numnodes);

Implementing the Matrix Stiness Method

Assembling the Structure Stiness Matrix

Implementing the Matrix Stiness Method

Assembling the Structure Stiness Matrix

% placing the top-left quadrant for n=1:numnodes clear a a=find(connelem(:,1)==n); if isempty(a)=1; for m=1:length(a); K(1+(n-1)*3:n*3,1+(n-1)*3:n*3)=... K(1+(n-1)*3:n*3,1+(n-1)*3:n*3)+kdash(1:3,1:3,a(m)); % Klogic(n,n)=Klogic(n,n)+1; end end end

Implementing the Matrix Stiness Method

Assembling the Structure Stiness Matrix

% placing the bottom-right quadrant for n=1:numnodes clear a a=find(connelem(:,2)==n); if isempty(a)=1; for m=1:length(a); K(1+(n-1)*3:n*3,1+(n-1)*3:n*3)=... K(1+(n-1)*3:n*3,1+(n-1)*3:n*3)+kdash(4:6,4:6,a(m)); % Klogic(n,n)=Klogic(n,n)+1; end end end

Implementing the Matrix Stiness Method

Assembling the Structure Stiness Matrix

% placing the top-right and bottom-left quadrant for n=1:numnodes clear a b a=find(connelem(:,1)==n); if isempty(a)=1; b=connelem(a,2); for m=1:length(a); K(1+(n-1)*3:n*3,1+(b(m)-1)*3:b(m)*3)=... K(1+(n-1)*3:n*3,1+(b(m)-1)*3:b(m)*3)+kdash(1:3,4:6,a(m)); K(1+(b(m)-1)*3:b(m)*3,1+(n-1)*3:n*3)=... K(1+(b(m)-1)*3:b(m)*3,1+(n-1)*3:n*3)+kdash(4:6,1:3,a(m)); % Klogic(n,b(m))=Klogic(n,b(m))+1; Klogic(b(m),n)=Klogic(b(m),n)+1; end end end

Implementing the Matrix Stiness Method

Assembling the Structure Stiness Matrix

% Addressing rows and columns in the stiffness matrix associated with % applied support constraints a=size(supports); b=0; Ksupportrefs=zeros(1,sum(sum(supports(:,2:4)=0))); for n=1:a(1) for m=2:a(2) if supports(n,m)==1; b=b+1; Ksupportrefs(b)=(supports(n,1)-1)*3+(m-1); end end end clear a b K(Ksupportrefs(1,:),:)=0; K(:,Ksupportrefs(1,:))=0; for n=1:length(Ksupportrefs) K(Ksupportrefs(1,n),Ksupportrefs(1,n))=1; end

Implementing the Matrix Stiness Method

Assembling the Fixed End Reactions Matrix

%Setting up matrix of distributed loads w=[0 0 0 0 0 0 0 10 10 10 10 10 0]; %Setting up fixed end moments for each element (FE-M) FEMelem = zeros(numelem,2); for n=1:numelem FEMelem(n,1) = +w(n).*L(n)2./12; FEMelem(n,2) = -w(n).*L(n)2./12; end %Setting up fixed end x2 reactions for each element (FE-R2) FER2elem = zeros(numelem,2); for n=1:numelem FER2elem(n,1) = w(n).*L(n)./2; FER2elem(n,2) = w(n).*L(n)./2; end

Implementing the Matrix Stiness Method

Assembling the Fixed End Reactions Matrix

%Setting up fixed end moment for each node FEMnode=zeros(numnodes,1); for n=1:numnodes clear a b a = find(connelem(:,1)==n); if isempty(a)=1; for m=1:length(a); FEMnode(n,1)=FEMnode(n,1)+FEMelem(a(m),1); end end b = find(connelem(:,2)==n); if isempty(b)=1; for m=1:length(b); FEMnode(n,1)=FEMnode(n,1)+FEMelem(b(m),2); end end end

Implementing the Matrix Stiness Method

Assembling the Fixed End Reactions Matrix

%Setting up fixed end x2 reactions for each node FER2node=zeros(numnodes,1); for n=1:numnodes clear a b a = find(connelem(:,1)==n); if isempty(a)=1; for m=1:length(a); FER2node(n,1)=FER2node(n,1)+FER2elem(a(m),1); end end b = find(connelem(:,2)==n); if isempty(b)=1; for m=1:length(b); FER2node(n,1)=FER2node(n,1)+FER2elem(b(m),2); end end end

Implementing the Matrix Stiness Method

Assembling the Fixed End Reactions Matrix

%Setting up matrix of FE reactions FERnode=zeros(3*numnodes,1); FERnode(3:3:3*numnodes,1)=FEMnode(1:1:numnodes,1); FERnode(2:3:3*numnodes,1)=FER2node(1:1:numnodes,1); FERnode(Ksupportrefs,1)=0;

Implementing the Matrix Stiness Method

Finding the Joint Displacements

= K 1 (R FE )

%Finding the joint displacements displacements=(K-1)*(-FERnode); reshapedisplacements=reshape(displacements,3,[]); fprintf('\nDisplacements at the nodes (m,m,rad):\n\n'); disp(reshapedisplacements);

Implementing the Matrix Stiness Method

Results: Joint Displacements

Displacements at the nodes (m,m,rad): 1.0e-003 * Columns 1 through 6 0 0 0.0689 0 0 -0.0355 0 0 -0.0198 0 0 -0.0971 0.0672 -0.0661 -0.1882 0.0760 -0.1966 0.0140

Columns 7 through 11 0.0893 -0.2742 -0.0274 0.1013 -0.1290 0.1182 0.2331 -0.2546 -0.1916 0.2170 -0.4155 -0.0053 0.2021 -0.1922 0.2021

Implementing the Matrix Stiness Method

Find the Support Reactions

R = k + R FE

%Finding the support reactions %Isolating the elements that have restrained ends %This relies on supports being defined for single elements a=size(supports); for n=1:a(1) b=find(connelem(:,1)==n); EndAdisp=displacements(1+(connelem(b,1)-1)*3:3+(connelem(b,1)-1)*3,1); EndBdisp=displacements(1+(connelem(b,2)-1)*3:3+(connelem(b,2)-1)*3,1); Endsdisp(1:3,1)=EndAdisp; Endsdisp(4:6,1)=EndBdisp; reactions(1+(n-1)*3:3+(n-1)*3,1)=kdash(1:3,1:6,b)*Endsdisp+... FERnode(1+(connelem(b,1)-1)*3:3+(connelem(b,1)-1)*3,1); end reshapereactions=reshape(reactions,3,[]); fprintf('\nReactions (kN,kN,kNm):\n\n'); disp(reshapereactions);

Implementing the Matrix Stiness Method

Results: Support Reactions

Reactions (kN,kN,kNm): 1.0333 19.8530 0.0000 -0.1987 59.0480 0.0000 0.0305 82.3450 -0.0000 -0.8651 38.7540 0.0000

Implementing the Matrix Stiness Method

Check: Assembled Structure Stiness Matrix

Assembly logic of the K matrix: 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 3 1 0 0 1 0 0 0 1 0 0 1 4 1 0 1 0 0 0 0 1 0 0 1 4 1 0 1 0 0 0 0 1 0 0 1 3 0 0 1 0 0 0 0 1 1 0 0 3 1 0 0 0 0 0 0 0 1 0 1 3 1 0 0 0 0 0 0 0 1 0 1 2

Implementing the Matrix Stiness Method

Conclusions

The script can be generalised for any plane frame. The script can be adapted to include dierent cross sections. Results are found to match those obtained from Oasys GSA excluding shear deformations.

Implementing the Matrix Stiness Method

Ask not what you can do for the matrix stiness method... Ask what the matrix stiness method can do for you.

Implementing the Matrix Stiness Method

You might also like