0% found this document useful (0 votes)
18 views18 pages

Matlab Vs Sap 2000

The document compares the results of a MATLAB script and SAP2000 for analyzing a multi-bay structural frame, focusing on nodal displacements, reactions, and internal forces. It details the properties of materials and sections, geometry, loading conditions, and provides a thorough comparison of the outputs from both methods. The findings aim to identify and explain any discrepancies between the two approaches.

Uploaded by

Cheran pandian S
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)
18 views18 pages

Matlab Vs Sap 2000

The document compares the results of a MATLAB script and SAP2000 for analyzing a multi-bay structural frame, focusing on nodal displacements, reactions, and internal forces. It details the properties of materials and sections, geometry, loading conditions, and provides a thorough comparison of the outputs from both methods. The findings aim to identify and explain any discrepancies between the two approaches.

Uploaded by

Cheran pandian S
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/ 18

Validation Problem Ahmad Yasin

MATLAB vs SAP 2000

“Comparison for multi-bay


structural frames”

1
Validation Problem Ahmad Yasin

Contents
Contents .................................................................................................................................................. 2

Introduction ............................................................................................................................................. 3

SAP2000 ................................................................................................................................................. 6

Material and Sections properties ......................................................................................................... 6

Geometry and loading ......................................................................................................................... 9

MATLAB .............................................................................................................................................. 11

Script ................................................................................................................................................. 11

Compare Between MATLAB and SAP2000 ........................................................................................ 16

Global Displacements ....................................................................................................................... 16

Reactions ........................................................................................................................................... 16

Internal Forces .................................................................................................................................. 17

Conclusions ........................................................................................................................................... 18

2
Validation Problem Ahmad Yasin

Introduction
This aim of this document is to create a MATLAB script that calculates the nodal
displacements, reactions, and element forces for a multi-story multi-bays frame shown in
Figure 1.
Additionally, the same frame shall be modelled using SAP2000, computing the same
quantities. The last step is to compare the results with those obtained from the MATLAB script
and justify/explain the differences (if any).

Figure 1. 3D View for the frame

Numbering for nodes and elements are unified in both MATLAB code and SAP2000 model
and shown in Figure 2. Loading conditions and dimensions are shown in Figure 3. Main
material characteristics and sections definitions are mentioned in Table 1.

3
Validation Problem Ahmad Yasin

Table 1. Material Characteristics and sections definitions

Modulus of Elasticity 30 x 106 psi


Moment of Inertia for Beams 960 in4
Moment of Inertia for Columns 1440 in4
Cross-sectional area for Beams 40 in2
Cross-sectional area for 46 in2
Columns
Stiffness of Spring 1000 lb./in

Figure 2. 2D view for the frame showing the numbering of nodes and members

4
Validation Problem Ahmad Yasin

Figure 3. Loading Conditions and Dimensions

The following sections show the detailed calculations for SAP2000 and MATLAB.
SAP section is divided into sub-sections for material and sections definitions, and geometry
and loading. MATLAB section is divided into two sub-sections for input script and output
results. Then the third section is for comparison between the two approaches with conclusions.

5
Validation Problem Ahmad Yasin

SAP2000

Material and Sections properties

Figure 4. Loading Patterns in SAP

Figure 5. Material definition

6
Validation Problem Ahmad Yasin

Figure 6. Section properties definition for beams

Figure 7. Section properties definition for columns

7
Validation Problem Ahmad Yasin

Here are some notes regarding Figures (4 to 7)


Figure 4: In this model, loads are assigned on DEAD definition, so self-multiplier factor
should be 0 in order not to add own weight of elements to the analysis results. We could do
this with two other approaches; one is to use the material with zero density and the other is to
use another load pattern and get the results from it directly. However, in this project, the
approach mentioned is used.
Figure 5: In material definition, only the value of modulus of Elasticity will influence the
analysis results. All other properties or factors have an important effect in general, but not in
this case.
Figure 6: General property is used for beams with specified properties mentioned in Table 1.
Figure 7: General property is used for columns with specified properties mentioned in Table
1.

8
Validation Problem Ahmad Yasin

Geometry and loading

Figure 8. Section properties assignments

Figure 9. Numbering for nodes and elements

9
Validation Problem Ahmad Yasin

Figure 9. Numbering for nodes and elements

Figure 10. Loading patterns

10
Validation Problem Ahmad Yasin

MATLAB

Script
%% Project - Computational Structural Analysis
close all; clear; clc;
% Input data
E = 30e6; % Elastic modulus (psi)
Area_Beam = 40; % Cross-sectional area of Beams (in^2)
Area_Column = 46; % Cross-sectional area of Columns (in^2)
I_Beam = 960; % Moment of inertia of Beams (in^4)
I_Column = 1440; % Moment of inertia of Columns (in^4)
w1 = 25; % Uniform Load 1 = 0.3Kips/ft = 25 lbs/in
w2 = 37.5; % Triangular Load = 0.45 Kips/ft = 37.5 lbs/in
L = [192,192,192,192,192,192,192,192,120,144,144,120,144,144];
I = [repmat(I_Column,1,8), repmat(I_Beam,1,6)];
A = [repmat(Area_Column,1,8), repmat(Area_Beam,1,6)];
Th = [90,90,90,90,90,90,90,90,0,0,0,0,0,0];
Nnodes = 13;
DOFs_node = 3; % DOFs per node
DOFs = Nnodes * DOFs_node;

% Element connectivity [node_i, node_j]


elements = [1, 2;
2, 3;
4,5;
5,6;
7,8;
8,9;
11,12;
12,13;
2,5;
5,8;
8,12;
3,6;
6,9;
9,13;
10,11];
[rows, columns] = size(elements);
Number_Elements = rows;

% Spring stiffness for element 15


k_spring = 1000; % Spring stiffness value (adjust as needed)

w = zeros(1, Number_Elements);
w(1,[9,10,12,13,14]) = w1;
w(1,11) = w2;

% Define external forces


F = zeros(DOFs, 1);

% Assign Equivalent Loads at different nodes


for n = 1:size(elements, 1)
nodes = elements(n,:);
if n ~= 11 && n ~= 15 % Exclude both special load case and spring element
F(nodes*DOFs_node-1) = F(nodes*DOFs_node-1) -w(n)*L(n)/2;

11
Validation Problem Ahmad Yasin

F(nodes(1,1)*DOFs_node) = F(nodes(1,1)*DOFs_node)-w(n)*(L(n))^2/12;
F(nodes(1,2)*DOFs_node) = F(nodes(1,2)*DOFs_node)+w(n)*(L(n))^2/12;
elseif n == 11 % Triangular load case
F(nodes*DOFs_node-1) = F(nodes*DOFs_node-1) -w(n)*L(n)/4;
F(nodes(1,1)*DOFs_node) = F(nodes(1,1)*DOFs_node)-5*w(n)*(L(n))^2/96;
F(nodes(1,2)*DOFs_node) = F(nodes(1,2)*DOFs_node)+5*w(n)*(L(n))^2/96;
end
end

% Boundary conditions (fixed DOFs for nodes 1, 4, 7, 10 )


fixed_dofs = [1,2,3,10,11,12,19,20,21,28,29,30];

% Initialize global stiffness matrix


K = zeros(DOFs, DOFs);

% Precompute cosine and sine values for transformation matrices


cos_angles = cosd(Th);
sin_angles = sind(Th);

% Assembly of global stiffness matrix


for i = 1:size(elements, 1)
% Element properties
if i <= 14 % Ensure we only use existing L, I, A values
L_i = L(i);
I_i = I(i);
A_i = A(i);
c_i = cos_angles(i);
s_i = sin_angles(i);
end

% Check if it's the spring element (last element)


if i == 15
% Spring stiffness matrix
k_local = zeros(6,6);
k_local(1,1) = k_spring;
k_local(4,4) = k_spring;
k_local(1,4) = -k_spring;
k_local(4,1) = -k_spring;

% Use last angle for spring (90 degrees)


c_i = cos(pi/2);
s_i = sin(pi/2);
else
% Local stiffness matrix (6x6) for beam elements
k_local = E/L_i* [A_i, 0, 0, -A_i , 0, 0;
0, 12*I_i/L_i^2, 6*I_i/L_i, 0, -12*I_i/L_i^2, 6*I_i/L_i;
0, 6*I_i/L_i, 4*I_i, 0, -6*I_i/L_i, 2*I_i;
-A_i, 0, 0, A_i, 0, 0;
0, -12*I_i/L_i^2, -6*I_i/L_i, 0, 12*I_i/L_i^2, -6*I_i/L_i;
0, 6*I_i/L_i, 2*I_i, 0, -6*I_i/L_i, 4*I_i];
end

% Transformation matrix (6x6)


T = [ c_i, s_i, 0, 0, 0, 0;
-s_i, c_i, 0, 0, 0, 0;
0, 0, 1, 0, 0, 0;
0, 0, 0, c_i, s_i, 0;
0, 0, 0, -s_i, c_i, 0;
0, 0, 0, 0, 0, 1];

12
Validation Problem Ahmad Yasin

% Global stiffness matrix for the element


k_global = T' * k_local * T;

% DOFs for the element


node_i = elements(i, 1);
node_j = elements(i, 2);
dofs_elmap = [node_i*3-2:node_i*3, node_j*3-2:node_j*3];

% Assemble into the global stiffness matrix


K(dofs_elmap, dofs_elmap) = K(dofs_elmap, dofs_elmap) + k_global;
end

% Apply boundary conditions (eliminate fixed DOFs)


free_dofs = setdiff(1:DOFs, fixed_dofs); % Remaining DOFs
K_ff = K(free_dofs, free_dofs); % Free DOF stiffness matrix
F_f = F(free_dofs); % Free DOF force vector
d_free = K_ff \ F_f;
d = zeros(DOFs, 1);
d(free_dofs) = d_free;

% Calculate Effective Forces Vector


F_effective = K * d;

% Calculate Reactions at Fixed DOFs


R = F_effective(fixed_dofs) - F(fixed_dofs);

% Initialize Internal Forces Vector


internal_forces = zeros(Number_Elements, 6);

% Calculate Internal Forces for Each Element


for i = 1:Number_Elements
% Element properties
node_i = elements(i, 1);
node_j = elements(i, 2);

% DOFs for the element


dofs_elmap = [node_i*3-2:node_i*3, node_j*3-2:node_j*3];

% Extract element displacements


d_element = d(dofs_elmap);

% Initialize fixed-end forces vector


F_fixed_end = zeros(6, 1);

% Compute local stiffness matrix


if i <= 14 % Regular elements
L_i = L(i);
I_i = I(i);
A_i = A(i);
c_i = cosd(Th(i));
s_i = sind(Th(i));

% Local stiffness matrix


k_local = E/L_i* [A_i, 0, 0, -A_i , 0, 0;
0, 12*I_i/L_i^2, 6*I_i/L_i, 0, -12*I_i/L_i^2, 6*I_i/L_i;
0, 6*I_i/L_i, 4*I_i, 0, -6*I_i/L_i, 2*I_i;
-A_i, 0, 0, A_i, 0, 0;
0, -12*I_i/L_i^2, -6*I_i/L_i, 0, 12*I_i/L_i^2, -6*I_i/L_i;

13
Validation Problem Ahmad Yasin

0, 6*I_i/L_i, 2*I_i, 0, -6*I_i/L_i, 4*I_i];

% Transformation matrix
T = [ c_i, s_i, 0, 0, 0, 0;
-s_i, c_i, 0, 0, 0, 0;
0, 0, 1, 0, 0, 0;
0, 0, 0, c_i, s_i, 0;
0, 0, 0, -s_i, c_i, 0;
0, 0, 0, 0, 0, 1];

% Calculate fixed-end forces for distributed loads


if any(i == [9,10,12,13,14]) % Uniform load w1
% Fixed-end forces for uniform load
F_fixed_end = [0;
-w1*L_i/2;
-w1*L_i^2/12;
0;
-w1*L_i/2;
w1*L_i^2/12];

elseif i == 11 % Triangular load with max at middle

F_fixed_end = [0;
-w2*L_i/4;
-5*w2*L_i^2/96;
0;
-w2*L_i/4;
5*w2*L_i^2/96];
end

% Transform displacements to local coordinates


d_local = T * d_element;

% Calculate element forces in local coordinates


% F = ku - F_fixed_end
internal_forces(i, :) = (k_local * d_local - F_fixed_end)';

elseif i == 15 % Spring element


c_i = 0; % cos(90°)
s_i = 1;
T = [ c_i, s_i, 0, 0, 0, 0;
-s_i, c_i, 0, 0, 0, 0;
0, 0, 1, 0, 0, 0;
0, 0, 0, c_i, s_i, 0;
0, 0, 0, -s_i, c_i, 0;
0, 0, 0, 0, 0, 1];
% Spring stiffness matrix
k_local = zeros(6,6);
k_local(1,1) = k_spring;
k_local(4,4) = k_spring;
k_local(1,4) = -k_spring;
k_local(4,1) = -k_spring;

d_local = T * d_element;

% Calculate spring element forces (no fixed-end forces for spring)


internal_forces(i, :) = k_local * d_local;
end
end

14
Validation Problem Ahmad Yasin

% Display Results
fprintf('\n=== NODAL DISPLACEMENTS ===\n');
for i = 1:Nnodes
fprintf('\nNode %d:\n', i);
fprintf('X-displacement: %.6f inches\n', d((i-1)*3 + 1));
fprintf('Y-displacement: %.6f inches\n', d((i-1)*3 + 2));
fprintf('Rotation: %.6f radians\n', d((i-1)*3 + 3));
end

fprintf('\n=== SUPPORT REACTIONS ===\n');


for i = 1:length(fixed_dofs)
node_num = floor((fixed_dofs(i)-1)/3) + 1;
dof_type = mod(fixed_dofs(i)-1, 3) + 1;

% Determine DOF type description


if dof_type == 1
dof_desc = 'X-direction force';
elseif dof_type == 2
dof_desc = 'Y-direction force';
else
dof_desc = 'Moment';
end

fprintf('Node %d, %s: %.2f\n', node_num, dof_desc, R(i));


end

fprintf('\n=== INTERNAL FORCES ===\n');


for i = 1:Number_Elements
fprintf('\nElement %d (Nodes %d to %d):\n', i, elements(i,1), elements(i,2));
fprintf('At Node %d:\n', elements(i,1));
fprintf(' Axial Force: %.2f\n', internal_forces(i,1));
fprintf(' Shear Force: %.2f\n', internal_forces(i,2));
fprintf(' Moment: %.2f\n', internal_forces(i,3));
fprintf('At Node %d:\n', elements(i,2));
fprintf(' Axial Force: %.2f\n', internal_forces(i,4));
fprintf(' Shear Force: %.2f\n', internal_forces(i,5));
fprintf(' Moment: %.2f\n', internal_forces(i,6));
end

15
Validation Problem Ahmad Yasin

Compare Between MATLAB and SAP2000

Global Displacements
Table 2. Global displacements in MATLAB and SAP2000
MATLAB SAP2000
Nodes
Ux(in) Uy(in) Rotation (rad) Ux(in) Uy(in) Rotation (rad)
1 0 0 0 0 0 0
2 0.004914 -0.0002 -4.67x10-5 0.004914 -0.0002 -4.7x10-5
3 0.018414 -0.00032 -5.75x10-5 0.018414 -0.000324 -5.8x10-5
4 0 0 0 0 0 0
5 0.004891 -0.00089 -2.66x10-5 0.004891 -0.000889 -2.7x10-5
6 0.01844 -0.001327 -1.87x10-5 0.01844 -0.00133 -1.9x10-5
7 0 0 0 0 0 0
8 0.004804 -0.00161 -7.89x10-5 0.004804 -0.001605 -7.9x10-5
9 0.018551 -0.00243 -0.0001 0.018551 -0.002433 -0.000101
10 0 0 0 0 0 0
11 -0.01974 -0.0306 -0.00013 -0.01974 -0.030602 -0.000127
12 0.004723 -0.03061 -0.00013 0.004723 -0.030606 -0.000127
13 0.018632 -0.03065 -0.00011 0.018632 -0.030651 -0.000113

Reactions
Table 3. Reaction forces in MATLAB and SAP2000
MATLAB SAP2000
Nodes
Rx(lb) Ry(lb) M(lb.in) Rx(lb) Ry(lb) M(lb.in)
1 -31.386 1541.9 13525 -31.39 1541.9 13525.2
4 -171.56 6391.6 22444 -171.56 6391.55 22443.96
7 202.95 1153.6 -17294 202.95 11535.94 -1729.42
10 0 30.6 0 0 30.6 0

16
Validation Problem Ahmad Yasin

Internal Forces

Figure 11. Local axes for all elements

Table 4. Internal forces in MATLAB and SAP2000


Start (i) MATLAB SAP2000
Member
End (j) Normal (lb) Shear (lb) Moment (lb.in) Normal (lb) Shear (lb) Moment(lb.in)
i 1541.9 31.3857 13525 1541.9 31.3858 13525.3
1
j -1541.9 -31.3858 -7499.1 -1541.9 -31.3858 -7499.13
i 786.2126 255.95 26998 786.21 255.95 26998
2
j -786.2126 -255.95 22144 -786.21 -255.95 22144
i 6391.6 171.56 22444 6391.55 171.56 22443.96
3
j -6391.6 -171.56 10496 -6391.55 -171.56 10496.25
i 3143.2 674.56 62959 3143.2 674.26 62959.37
4
j -3143.2 -674.56 6649.8 -3143.2 -674.26 66498.45
i 11536 -202.95 -1729.4 11535.94 -202.95 -1729.42
5
j -11536 202.95 -37237 -11535.94 202.95 -37236.87
i 5952.7 -259.15 -19872 5952.65 -259.15 -19872.28
6
j -5952.7 259.15 -29884 -5952.65 259.15 29884.1
i 30.6 0 0 30.6 0 0
7
j -30.6 0 0 -30.6 0 0
i 317.93 -671 -67686 317.93 -671.06 -67686
8
j -317.93 671 -61158 -317.93 671.06 61158.35
i 224.567 755.7 -19499 224.57 755.69 -19499.34
9
j -224.567 2244.3 -69818 -224.57 2244.31 -69817.59
i 727.26 1000 -3638 727.26 1004.04 -3638.03
10
j -727.26 2596 -110980 -727.26 2595.96 110980.03
i 671 2987 168090 671 2987.33 168089.2
11
j -671 -287.3 67686 -671 -287.33 67686.02
i -255.95 786.2 -22144 -255.95 786.21 -22144.44
12
j 255.95 2213.8 -63510 255.95 2213.79 -63510.05
i -930.2 929.42 -2988.4 -930.21 929.42 -2988.4
13
j 930.2 2670.6 -122380 930.21 2670.58 -122375.6
i -671.06 3282.1 152260 -671.06 3282.07 152259.7
14
j 671.06 317.93 61158 671.06 317.93 61158.35
i 30.6 0 0 30.6 0 0
15
j -30.6 0 0 -30.6 0 0

Note: Sign convention of SAP2000 software is different, so, data in this table is modified to match
with MATLAB sign conventions

17
Validation Problem Ahmad Yasin

Conclusions
Results shown in the comparison section show an exact matching between SAP2000 and
MATLAB results in terms of displacements, internal forces, and reactions. This is reasonable
since SAP2000 builds its analysis equations based on same criterion used in MATLAB
(Direct Stiffness Matrix).

SAP.sdb and MATLAB.m files are attached.

18

You might also like