Académique Documents
Professionnel Documents
Culture Documents
%
%
% Structural Analysis: Principles, Methods and Modelling
%
% Gianluca Ranzi and Raymond Ian Gilbert
%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% WORKED EXAMPLE 10.5
% Difference from Worked Example 10.5:
%
Results calculated with this file adopt following properties for
%
each element: A=1 and E=1
% Note: units of the results are not specified as they are assumed
%
to reflect units used in input
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% clear workspace and command window.
clear
clc
% Open output file.
fid = fopen('Solution_Worked_Example_10_5.txt','w');
'The solution procedure is summarised in file: Solution_Worked_Example_10_5.txt'
% Write to the output file.
fprintf(fid,'\n%s','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s','%
Structural Analysis: Principles, ');
fprintf(fid,'%s\n','Methods and Modelling
%');
fprintf(fid,'%s','%
Gianluca Ranzi and Raymond Ian Gilbert');
fprintf(fid,'%s\n','
%');
fprintf(fid,'%s','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n\n','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s','%
WORKED EXAMPLE 10.5
');
fprintf(fid,'%s\n','
%');
fprintf(fid,'%s','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n\n','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'\n%s','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% INPUT DATA
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Specify the global coordinates for the nodes.
% For example:
% X(i) = specifies the X coordinate of node i
% Y(i) = specifies the Y coordinate of node i
X(1)=0;
Y(1)=0;
X(2)=8;
Y(2)=0;
X(3)=4;
Y(3)=3;
% Specify location vector for each stiffness element.
% This is carried out defining nodes 1 and 2 for each element. In this
% manner, we assign the location vector for each element pointing
% from node 1 to node 2. See Section 10.2.2.
% For example:
% node1(i) = specifies the node number for node 1 of element i
% node2(i) = specifies the node number for node 2 of element i
node1(1)=1;
node2(1)=2;
node1(2)=1;
node2(2)=3;
node1(3)=3;
node2(3)=2;
% Specify nodal coordinates (required at a node when the global
% freedoms are not parallel to the global axes). See Section 10.9.
% Note: in the case there is no need to assign nodal coordinates at a
% node, we leave this variable equal to zero.
% For example:
% nodal_coord(node number)= anti-clockwise angle measured from global X
% which defines positive direction of nodal coordinate Xn
nodal_coord(1)=0;
nodal_coord(2)=-60;
nodal_coord(3)=0;
% Specify cross-sectional and material properties for each member.
% For example:
% A(i) = specifies the area of the cross-section of element i
% E(i) = specifies the elastic modulus for the material of element i
A(1)=1;
E(1)=1;
A(2)=A(1);
E(2)=E(1);
A(3)=A(1);
E(3)=E(1);
% Number all freedoms.
% This is carried out assigning at each node 2 freedoms (because the
% truss element has 2 freedoms at each node). See Sesction 10.2.3.
% In particular:
% -the freedom along the global coordinate X is assigned to dof1
% -the freedom along the global coordinate Y is assigned to dof2
% When numbering the freedoms, it is neceassary to number unrestrained
% freedoms first, followed by the restrained ones.
% For example:
% dof1(i) = number of global freedom along the global X at node i
% dof2(i) = number of global freedom along the global Y at node i
dof1(1)=5;
dof2(1)=6;
dof1(2)=3;
dof2(2)=4;
dof1(3)=1;
dof2(3)=2;
% Specify list of unrestrained global freedoms.
dof_unrestrained=[ 1 2 3 ];
% Calculate direction cosines for each element in the case one of the
% end nodes includes nodal coordinates for element imem.
if(nodal_coord(node1(imem))~=0)|(nodal_coord(node2(imem))~=0)
l_temp(imem) = ( X(node2(imem)) - X(node1(imem)) )/L(imem) ;
m_temp(imem) = ( Y(node2(imem)) - Y(node1(imem)) )/L(imem) ;
angle1_temp=asin( m_temp(imem) )/pi*180 ;
angle2_temp=asin( m_temp(imem) )/pi*180 ;
angle1=asin( m_temp(imem) )/pi*180 - nodal_coord(node1(imem));
angle2=asin( m_temp(imem) )/pi*180 - nodal_coord(node2(imem));
%
%
if (l_temp(imem)<0)&(m_temp(imem)>0)
angle1_temp=180-angle1_temp;
angle2_temp=180-angle2_temp;
elseif (l_temp(imem)<0)&(m_temp(imem)<0)
angle1_temp=-180-angle1_temp;
angle2_temp=-180-angle2_temp;
end
angle1=angle1_temp - nodal_coord(node1(imem));
angle2=angle2_temp - nodal_coord(node2(imem));
l1(imem)
m1(imem)
l2(imem)
m2(imem)
=
=
=
=
cos
sin
cos
sin
(angle1/180*pi);
(angle1/180*pi);
(angle2/180*pi);
(angle2/180*pi);
fprintf(fid,'
Ke(%g) = [ %10g %10g %10g %10g ] \n', imem, Ke(2,1:4,ime
m) );
fprintf(fid,'
[ %10g %10g %10g %10g ] \n', Ke(3,1:4,imem) );
fprintf(fid,'
[ %10g %10g %10g %10g ] \n', Ke(4,1:4,imem) );
fprintf(fid,'%s\n',...
'% Isolated global freedoms 1 2 3 4 are mapped to the following');
fprintf(fid,'%s','% ');
fprintf(fid,'
freedoms of the entire truss: %g %g %g %g \n',...
dof1(node1(imem)),dof2(node1(imem)),dof1(node2(imem)),dof2(node2(imem)))
;
end
% Calculate the total number of global freedoms assigned to the truss.
ifreedom_max=inode_max*idofnode;
% Initialise the stiffness matrix of the entire truss K, and the vectors
% of global displacements D and actions Q.
K=zeros(ifreedom_max,ifreedom_max);
D=zeros(ifreedom_max,1);
Q=zeros(ifreedom_max,1);
% Loop through all truss elements and assemble the stiffness matrix and
% loading vector for the entire truss.
for imem = 1:imem_max
% Recall nodal freedoms of the isolated truss element.
jcount(1)=dof1(node1(imem));
jcount(2)=dof2(node1(imem));
jcount(3)=dof1(node2(imem));
jcount(4)=dof2(node2(imem));
list_dof_mem(1:4,imem)=jcount(1:4);
% Assemble stiffness matrix and equivalent nodal loads related to
% element imem into the stiffness matrix and loading vector of the
% entire truss.
for irow = 1:4
for icol = 1:4
K(jcount(irow),jcount(icol))=K(jcount(irow),jcount(icol))...
+Ke(irow,icol,imem);
end
end
end
% Assign vector of global loads.
% Note: at this point unknown nodal actions (i.e. reactions) are included
% in the vector with zero values. These will be calculated in the
% post-processing stage.
length_Q_applied=length(Q_applied);
Q(1:length_Q_applied)=Q(1:length_Q_applied)+Q_applied(1:length_Q_applied)';
% Assign vector of global displacements.
% Note: at this point unknown nodal displacements (i.e. unrestrained ones)
% are included in the vector with zero values. These will be calculated
% in the post-processing stage.
length_D_enforced=length(D_enforced);
D(1:length_D_enforced)=D(1:length_D_enforced)+D_enforced(1:length_D_enforced)';
% Assign the freedom number related to the highest unrestrained freedom
% to last_dof_unrestrained.
last_dof_unrestrained=dof_unrestrained(end);
% Collect freedoms related to unrestrained freedoms
% in list_of_unrestrained_dof and freedoms related to restrained ones
% to list_of_restrained_dof.
list_of_unrestrained_dof=[1:last_dof_unrestrained];
list_of_restrained_dof=[last_dof_unrestrained+1:ifreedom_max];
% Partition load and displacement vectors to isolate known components.
% See Eqs. 10.38 and 10.39.
Qk=Q(list_of_unrestrained_dof);
Dk=D(list_of_restrained_dof);
% Partition stiffness matrix of the truss. See Eqs. 10.40.
K11 = K(list_of_unrestrained_dof,list_of_unrestrained_dof);
K12 = K(list_of_unrestrained_dof,list_of_restrained_dof);
K21 = K(list_of_restrained_dof,list_of_unrestrained_dof);
K22 = K(list_of_restrained_dof,list_of_restrained_dof);
% Evaluate unknown displacements. See Eq. 10.41.
invK11=inv(K11);
Du = invK11*(Qk - K12*Dk);
% Post-process the solution and calculate unknown reactions.
% See Eq. 10.40c.
Qu = K21*Du + K22*Dk - Q(list_of_restrained_dof);
% Assemble vectors of unknown and known displacements into vector D.
D=[Du ; Dk ];
% Write information related to the entire truss to the output file.
fprintf(fid,'\n%s','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n\n','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n',...
'% Stiffness matrix for the entire truss ');
for icount_row=1:ifreedom_max
if(icount_row==round(ifreedom_max/2))
fprintf(fid,'%s','
K = [ ');
else
fprintf(fid,'%s','
[ ');
end
fprintf(fid,' %10g ' , K(icount_row,1:end) );
fprintf(fid,'%s\n','
] ');
% fprintf(fid,'
K = [ %8g %10g %10g %10g ] \n', imem, K(1,1:4) );
end
fprintf(fid,'\n%s','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n\n','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n',...
'% Stiffness matrix K11 for the entire truss ');
for icount_row=1:last_dof_unrestrained
if(icount_row==round(last_dof_unrestrained/2))
fprintf(fid,'%s','
K11 = [ ');
else
fprintf(fid,'%s','
[ ');
end
fprintf(fid,' %10g ' , K11(icount_row,1:end) );
fprintf(fid,'%s\n','
] ');
% fprintf(fid,'
end
fprintf(fid,'\n%s','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n\n','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n',...
'% Stiffness matrix K12 for the entire truss ');
for icount_row=1:last_dof_unrestrained
if(icount_row==round(last_dof_unrestrained/2))
fprintf(fid,'%s','
K12 = [ ');
else
fprintf(fid,'%s','
[ ');
end
fprintf(fid,' %10g ' , K12(icount_row,1:end) );
fprintf(fid,'%s\n','
] ');
% fprintf(fid,'
K = [ %8g %10g %10g %10g ] \n', imem, K(1,1:4) );
end
fprintf(fid,'\n%s','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n\n','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n',...
'% Stiffness matrix K21 for the entire truss ');
for icount_row=1:ifreedom_max-last_dof_unrestrained
if(icount_row==round((ifreedom_max-last_dof_unrestrained)/2))
fprintf(fid,'%s','
K21 = [ ');
else
fprintf(fid,'%s','
[ ');
end
fprintf(fid,' %10g ' , K21(icount_row,1:end) );
fprintf(fid,'%s\n','
] ');
% fprintf(fid,'
K = [ %8g %10g %10g %10g ] \n', imem, K(1,1:4) );
end
fprintf(fid,'\n%s','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n\n','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n',...
'% Stiffness matrix K22 for the entire truss ');
for icount_row=1:ifreedom_max-last_dof_unrestrained
if(icount_row==round((ifreedom_max-last_dof_unrestrained)/2))
fprintf(fid,'%s','
K22 = [ ');
else
fprintf(fid,'%s','
[ ');
end
fprintf(fid,' %10g ' , K22(icount_row,1:end) );
fprintf(fid,'%s\n','
] ');
% fprintf(fid,'
K = [ %8g %10g %10g %10g ] \n', imem, K(1,1:4) );
end
fprintf(fid,'\n%s','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n\n','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n',...
'% Inverse of stiffness matrix K11 ');
for icount_row=1:last_dof_unrestrained
if(icount_row==round(last_dof_unrestrained/2))
fprintf(fid,'%s','
inv(K11) = [ ');
else
fprintf(fid,'%s','
[ ');
end
fprintf(fid,' %10g ' , invK11(icount_row,1:end) );
fprintf(fid,'%s\n','
] ');
% fprintf(fid,'
end
fprintf(fid,'\n%s','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n\n','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n',...
'% Vectors of known nodal actions ');
fprintf(fid,' Qk(transposed) = [ ');
fprintf(fid,' %7g ', Qk );
fprintf(fid,' ]');
fprintf(fid,'\n\n%s\n',...
'% Vectors of known nodal displacements ');
fprintf(fid,' Dk(transposed) = [ ');
fprintf(fid,' %7g ', Dk );
fprintf(fid,'%s\n',' ]');
fprintf(fid,'\n%s','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n\n','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n',...
'% Vectors of unknown nodal displacements ');
fprintf(fid,' Du(transposed) = [ ');
fprintf(fid,' %10g ', Du );
fprintf(fid,' ]');
fprintf(fid,'\n\n%s\n',...
'% Vectors of unknown nodal actions (reactions) ');
fprintf(fid,' Qu(transposed) = [ ');
fprintf(fid,' %10g ', Qu );
fprintf(fid,'%s\n',' ]');
fprintf(fid,'\n%s','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
% Post-process the solution and calculate axial force for each member
% of the truss. See Eq. 10.42.
for imem = 1:imem_max
qe(1:2,imem)=ke(1:2,1:2,imem)*T(1:2,1:4,imem)*D(list_dof_mem(1:4,imem));
fprintf(fid,'\n%s',...
'% Post-processing of the results for the isolated element ');
fprintf(fid,'%g\n', imem);
fprintf(fid,'%s\n','%
Nodal displacements expressed in global coordinat
es');
fprintf(fid,'
De(%g)(transposed) = [ %8g %10g %10g %10g ] \n', ...
imem, D(list_dof_mem(1:4,imem)) );
fprintf(fid,'%s\n','%
Nodal actions expressed in local coordinates');
fprintf(fid,'
qe(%g)(transposed) = [ %8g %10g ] \n', ...
imem, qe(1:2,imem) );
end
fprintf(fid,'\n%s','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
fprintf(fid,'%s\n','%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
% Close output file.
fclose(fid);