Simple Code for Running CSI Sap 2000 from Matlab in Batch mode for finding Natural Frequency

버전 1.0 (4.64 KB) 작성자: Sajeer Modavan
This code help you to adjust material property from matlab to match with actual Natural frequency
다운로드 수: 645
업데이트 날짜: 2015/12/1

라이선스 보기

%#########################################################################%
%# PROGRAMMER : MOHAMED SAJEER IBN AZAD MODAVAN #%
%# DATE : 03.09.2013(Last modified: 01:12:2015) #%
%# ABSTRACT : This Code used to Run SAP2000 from Matlab to find the #%
%# Natural frequency. This code may help you to adjest the #%
%# material properties to match the Natural frequency #%
%# of model with the actual value of Natural frequency. %#
%# Also you can use optimisation tool with this code for #%
%# finding optimum Design properties. #%
%#=======================================================================#%
%# Modifications may be required #%
%#=======================================================================#%
%# * Modify the version number of SAP2000 in line 31 #%
%# * This code required to modify for file path in line 40 #%
%# * In line 57 & 58 change the material name according to your model #%
%# * Material properties you can #%
%#########################################################################%
clear; clc; close all
% Material Properties
Eco = 20e6; % Modulus of Elasticity of Concrete
Est = 21e7; % Modulus of Elasticity of Steel
nu_c = 0.2; % Poisson's Ratio of Concrete
nu_s = 0.3; % Poisson's Ratio of Steel
% Pass data to Sap2000 as one-dimensional arrays
feature('COM_SafeArraySingleDim', 1);
% Pass non-scalar arrays to Sap2000 API by reference
feature('COM_PassSafeArrayByRef', 1);
% Create Sap2000 object
SapObject = actxserver('sap2000v15.SapObject'); % Version of Sap2000
% Start Sap2000 application
SapObject.ApplicationStart;
% Hide Application, Hide <=> Unhide
SapObject.Hide;
% Create SapModel object
Sap = SapObject.SapModel;
%%
% Open existing file
FilePath = 'D:\Frame'; % Location of Sap2000 Model
Sap.File.OpenFile([FilePath,'.sdb']);
%%
% Edit Model
% ----------
% Model lock =>(1)or unlock =>(0)
Sap.SetModelIsLocked(0);

% Switch to units
% lb_in_F = 01 lb_ft_F = 02 kip_in_F = 03 kip_ft_F = 04
% kN_mm_C = 05 kN_m_C = 06 kgf_mm_C = 07 kgf_m_C = 08
% N_mm_C = 09 N_m_C = 10 Ton_mm_C = 11 Ton_m_C = 12
% kN_cm_C = 13 kgf_cm_C = 14 N_cm_C = 15 Ton_cm_C = 16
Unit = 06;
Sap.SetPresentUnits(Unit);

% Assign isotropic mechanical properties
Sap.PropMaterial.SetMPIsotropic('Concrete', Eco, nu_c, 1.170E-05);
Sap.PropMaterial.SetMPIsotropic('Steel', Est, nu_s, 1.170E-05);

% Run model (this will create the analysis model)
Sap.Analyze.RunAnalysis();
% Set run case model
% Sap.Analyze.SetRunCaseFlag('MODAL', 1);
%%
% Results
% -------
% Count number of joints & DOF
countP = Sap.PointElm.Count;
DOF = countP*3-12;
disp('DEGREE OF FREEDOM');disp(DOF)

% Frequency
AA = fopen([FilePath,'.LOG'],'r');
Fr1 = fread(AA);
s = char(Fr1');
fclose(AA);
word1Location = strfind(s, 'NUMBER OF EIGEN MODES FOUND');
word2Location = strfind(s, 'NUMBER OF ITERATIONS PERFORMED');
TextLine = s(word1Location:word2Location-1);
Number_Modes = str2double(TextLine(54:end));
disp('NUMBER OF EIGEN MODES');disp(Number_Modes)
Frq = zeros(Number_Modes,1);
for ii = 1:Number_Modes
if ii == Number_Modes
word1Location = strfind(s, ['Found mode ' num2str(ii)]);
word2Location = strfind(s, 'NUMBER OF EIGEN MODES FOUND');
elseif ii < 9
word1Location = strfind(s, ['Found mode ' num2str(ii)]);
word2Location = strfind(s, ['Found mode ' num2str(ii+1)]);
elseif ii == 9
word1Location = strfind(s, ['Found mode ' num2str(ii)]);
word2Location = strfind(s, ['Found mode ' num2str(ii+1)]);
elseif (ii>9) && (ii~=Number_Modes)
word1Location = strfind(s, ['Found mode ' num2str(ii)]);
word2Location = strfind(s, ['Found mode ' num2str(ii+1)]);
end
Mode = s(word1Location:word2Location-1);
word1Location = strfind(Mode, 'f=');
word2Location = strfind(Mode, ', T= ');
Fre = Mode(word1Location:word2Location-1);
Freq = str2double(Fre(3:14));
Frq(ii,:) = Freq;
end
disp('FREQUENCY IN Hz');disp(Frq)
%%
% save model
Sap.File.Save([FilePath,'.sdb']);
%%
% close Sap2000
SapObject.ApplicationExit(false());
SapModel = 0;
SapObject = 0;

인용 양식

Sajeer Modavan (2024). Simple Code for Running CSI Sap 2000 from Matlab in Batch mode for finding Natural Frequency (https://www.mathworks.com/matlabcentral/fileexchange/54259-simple-code-for-running-csi-sap-2000-from-matlab-in-batch-mode-for-finding-natural-frequency), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2007b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0