KEMBAR78
File:truss.m: © 2013 by Taylor & Francis Group, LLC | PDF | Coordinate System | Matrix (Mathematics)
0% found this document useful (0 votes)
62 views4 pages

File:truss.m: © 2013 by Taylor & Francis Group, LLC

Truss Coding

Uploaded by

maqsooolff
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)
62 views4 pages

File:truss.m: © 2013 by Taylor & Francis Group, LLC

Truss Coding

Uploaded by

maqsooolff
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/ 4

File:truss.

m
%

truss.m
%
% LINEAR STATIC ANALYSIS OF A TRUSS STRUCTURE
%
clc % Clear screen
clear % Clear all variables in memory
%
% Make these variables global so they can be shared
% by other functions
%
global nnd nel nne nodof eldof n global geom connec prop nf load
%
disp(’Executing truss.m’);

%
%%
% ALTER THE NEXT LINES TO CHOOSE AN OUTPUT FILE FOR THE RESULTS
% Open file for output of results
%
fid = fopen(’truss_1_results.txt’,’w’); disp(’Results printed in
file : truss_1_results.txt ’);
%
% ALTER THE NEXT LINE TO CHOOSE AN INPUT FILE
%
truss_1_data % Load the input file
%
print_truss_model % Print model data
%
KK =zeros(n) ; % Initialize global stiffness
% matrix to zero
%
F=zeros(n,1); % Initialize global force
% vector to zero
%
for i=1:nel
kl=truss_kl(i); % Form element matrix in local xy
%
C = truss_C(i); % Form transformation matrix
%
kg=C*kl*C’ ; % Transform the element matrix from
% local to global coordinates
%
g=truss_g(i) ; % Retrieve the element steering
% vector
%
KK =form_KK(KK, kg, g); % assemble global stiffness
% matrix
%
end
%

© 2013 by Taylor & Francis Group, LLC


Bar Element

%
F = form_truss_F(F); % Form global force vector
%
%
%%%%%%%%%%%% End of assembly %%%%%%%%%%%
%
%
delta = KK\F ; % solve for unknown displacements
%
% Extract nodal displacements
%
for i=1:nnd
for j=1:nodof
node_disp(i,j) = 0;
if nf(i,j)~= 0;
node_disp(i,j) = delta(nf(i,j)) ;
end
end
end
%
% Calculate the forces acting on each element
% in local coordinates, and store them in the
% vector force().
%
for i=1:nel
kl=truss_kl(i); % Form element matrix in local xy
C = truss_C(i); % Form transformation matrix
kg=C*kl*C’ ; % Transform the element matrix from
% local to global coordinates
g=truss_g(i) ; % Retrieve the element steering vector
for j=1:eldof
if g(j)== 0
edg(j)=0.; % displacement = 0. for restrained freedom
else
edg(j) = delta(g(j));
end
end
fg = kg*edg’; % Element force vector in global XY
fl=C’*fg ; % Element force vector in local xy
force(i) = fl(3);
end
%
print_truss_results;
%
fclose(fid);

File:truss_1_data.m
% File: truss_1_data.m
%
% The following variables are declared as global in order
% to be used by all the functions (M-files) constituting
% the program
%
global nnd nel nne nodof eldof n global geom connec prop nf load
%
format short e
%
%%%%%%%%%%%%%% Beginning of data input %%%%%%%%%%%%%%%%
%
nnd = 3; % Number of nodes:
nel = 3; % Number of elements:
nne = 2 ; % Number of nodes per element:
nodof =2 ; % Number of degrees of freedom per node
eldof = nne*nodof; % Number of degrees of freedom
% per element
%

© 2013 by Taylor & Francis Group, LLC


% Nodes coordinates X and Y
geom=zeros(nnd,2);
geom = [0. 0. ; ... % X and Y coord. node 1
4000. 0. ; ... % X and Y coord. node 2
4000. 6000.]; % X and X coord. node 3
%
% Element connectivity
%
connec=zeros(nel,2);
connec = [1 2 ; ... % 1st and 2nd node of element 1
2 3 ; ... % 1st and 2nd node of element 2
1 3]; % 1st and 2nd node of element 3
%
% Geometrical properties
%
% prop(1,1) = E; prop(1,2)= A
%
prop=zeros(nel,2);
prop = [200000 2300; ... % E and A of element 1
200000 2300; ... % E and A of element 2
200000 2300]; % E and A of element 3
%
% Boundary conditions
%
nf = ones(nnd, nodof); % Initialize the matrix nf to 1
nf(1,1) = 0; nf(1,2) =0 ; % Prescribed nodal freedom of node 1
nf(2,2) = 0 ; % Prescribed nodal freedom of node 3
%
% Counting of the free degrees of freedom
%
n=0; for i=1:nnd
for j=1:nodof
if nf(i,j) ~= 0
n=n+1;
nf(i,j)=n;
end
end
end
%
% loading
%
load = zeros(nnd, 2);
load(3,:)=[1200. 0]; %forces in X and Y directions at node 3
%
%%%%%%%%%%%%%%%%%%%%%%% End of input %%%%%%%%%%%%%%%%%%%%%%

File:truss_1_results.txt
******* PRINTING MODEL DATA **************

------------------------------------------------------
Number of nodes: 3
Number of elements: 3
Number of nodes per element: 2
Number of degrees of freedom per node: 2
Number of degrees of freedom per element: 4

------------------------------------------------------
Node X Y
1, 0000.00, 0000.00
2, 4000.00, 0000.00
3, 4000.00, 6000.00

------------------------------------------------------
Element Node_1 Node_2
1, 1, 2

© 2013 by Taylor & Francis Group, LLC


Bar Element

2, 2, 3
3, 1, 3

------------------------------------------------------
Element E A
1, 200000, 2300
2, 200000, 2300
3, 200000, 2300

------------------------------------------------------
Node disp_U disp_V
1, 0, 0
2, 1, 0
3, 2, 3

------------------------------------------------------
Node load_X load_Y
1, 0000.00, 0000.00
2, 0000.00, 0000.00
3, 1200.00, 0000.00
------------------------------------------------------

Total number of active degrees of freedom, n = 3

--------------------------------------------------------

******* PRINTING ANALYSIS RESULTS **************

------------------------------------------------------
Global force vector F
0
1200
0

------------------------------------------------------
Displacement solution vector: delta
-0.00000
0.09635
-0.02348

------------------------------------------------------
Nodal displacements
Node disp_X disp_Y
1, 0.00000, 0.00000
2, -0.00000, 0.00000
3, 0.09635, -0.02348

------------------------------------------------------
Members actions
element force action
1, -0.00, Compression
2, -1800.00, Compression
3, 2163.33, Tension

© 2013 by Taylor & Francis Group, LLC

You might also like