Sei sulla pagina 1di 10

Appendices A Matlab Programs for Simulation A.

1 Matlab Code for Power Spectral Density Functions


% Chetan J. Dhruna Masters Thesis % This .m file generates Power Spectral Density (PSD) functions of acceleration % data that was collected by the Sony DAT recorder clear all close all % Defining the parameters S = 0.100; %V / g G = [100 10 10 10 10 10 10 10 10 10 10 10 10 1 1 10]; %gains on signal cond. nchan = 16; %number of channels navg = 30; %number of window averages to complete fs = 6000; %sampling rate T = 1; %period for data window df = 1/T; %frequency resolution nfft = T * fs; %number of points in fft % Load acceleration data fn = input('Name of data file?','s'); cmd = ['load c:\cabdata\' fn ]; eval (cmd) cmd = ['time_data = ' fn ';']; eval(cmd) cmd = ['clear ' fn]; eval(cmd) % Make data into columns and scale time_data = time_data'; time_data = time_data(1:navg*nfft,:);

99

A.1 Continued
for ii = 1:nchan time_data(:,ii) = time_data(:,ii) / (G(ii) * S); end % Compute window and scaling factor for PSD to g^2/Hz RMS Win = hanning(nfft); PSD = []; for ii = 1:16 [curr_psd f] = psd(time_data(:,ii), nfft, fs, Win, 0); PSD = [PSD 2*curr_psd/nfft]; end % Save PSD data fn = input('Name of data file to save PSD in? ','s'); cmd = ['save c:\cabdata\accels\' fn ' PSD f']; eval(cmd) % Establish output frequency range & plot results endf = find(f == 1000); for ii = 1:nchan figure(ii) semilogy(f(1:endf),PSD(1:endf,ii)) title(['Channel ' num2str(ii)]) xlabel('Frequency, Hz') ylabel('PSD, g^2/Hz RMS') end

100

A.2 Matlab Function for Taking an FFT


% Do FFT with hanning window and %overlp overlapping % Edited by Chet Dhruna ; Last Date : July 28, 1997 function [ampli] = hanfft2(signals, n_fft, overlp) n_sig = length(signals) ; n_average = fix((n_sig/n_fft - overlp)/(1-overlp)); if(n_average == 0) disp('Cannot do FFT') ; else win_han = hanning(n_fft) ; ampli_fft = zeros(1, n_fft) ; ampli_spec = zeros(1, n_fft) ; ampli_tmp = zeros(1, n_fft) ; for i_fft = 1:1:n_average n_begin = (i_fft-1)*overlp*n_fft+1; signal_fft = signals(1,n_begin:(n_begin+n_fft-1)) ; signal_han = signal_fft .* win_han' ; ampli_tmp = fft(signal_han, n_fft) ; ampli_fft = ampli_fft + ampli_tmp ; ampli_spec = ampli_spec + sqrt(ampli_tmp .* conj(ampli_tmp)) ; end end % Frequency spectrum ampli = ampli_fft / n_average ; end

101

A.3 Matlab Code for Integrating Acceleration Data


% Data averager and integrator for mount calculations clear all close all % Load File file = 'a1371897'; eval(['load c:\cabdata\' file]) eval(['Sony = ' file ';']) eval(['clear ' file]) location = ['BA','BF','AA','AF']; gain = [1 10 10 10 10 10 10 10 10]; % Calculate frequency vector nfft = 4096; Sony_dt = 6000; df = Sony_dt / nfft; F = df*(0:2048); overlp = 0.25; Sony_max_data_pt = 180000; for i_loop = 1:4 Pos = location((i_loop-1)*2+1:i_loop*2); % Scale Data Force = ((250*4.45) * gain(1)) .* Sony(1,1:Sony_max_data_pt); Xdd = ((9.81*0.1) * gain((i_loop-1)*2+2)) * Sony((i_loop-1) * 2+2, 1:Sony_max_data_pt); Ydd = ((9.81*0.1) * gain((i_loop-1)*2 + 3)) .* Sony((i_loop-1) * 2+3, 1:Sony_max_data_pt); temp = zeros(1:4097); XdF = zeros(1:4097); YdF = zeros(1:4097); % Take ffts and average them together temp = hanfft2(Force,nfft,0.25)*2*(2/nfft); 102 % FFT Size % Data Sample Rate % Frequency Resolution % Frequency Vector % Percent Overlap % Maximum # of data pts from time array

A.3 Continued
ForceF = temp(1:2049); XdF = hanfft2(Xdd,nfft,0.25)*2*(2/nfft); YdF = hanfft2(Ydd,nfft,0.25)*2*(2/nfft); % Divide by j*omega to get sill and structure velocity Xd=XdF(1:(nfft/2 + 1)) ./ (2*pi*i*F); Yd=YdF(1:(nfft/2 + 1)) ./ (2*pi*i*F); eval(['Force' Pos ' = ForceF;']) eval(['Xd' Pos ' = Xd;']) eval(['Yd' Pos ' = Yd;']) eval(['save ' Pos '130718 Force' Pos ' Xd' Pos ' Yd' Pos]) end

103

A.4 Matlab Code for Analytical Prediction Model


% Analytical vibration prediction code clear all close all lbfin = input('Initial Mount Stiffness:') k = lbfin / (4.45 / 0.0254); zeta = 0.05; mass = (7500 / 4) * 0.4536; c = 2*zeta*sqrt(k*mass); nfft = 4096; df = 6000/nfft; F = df*(0:2048);

% Mount Stiffnes (lb/in) converted to (N/m) % Damping Coefficient % Mount Mass (kg) % Damping % # of FFT points % Frequency resolution % Frequency vector

% Compute the impedance of the Lord soft mounts already in place for ii = 1:length(F) Mount_Imp(ii) = c + ( k / (i*F(ii)*2*pi)); end % Load force and velocities at each corner load d:\users\chet\research\aa150820 load d:\users\chet\research\ba150820 load d:\users\chet\research\af150820 load d:\users\chet\research\bf150820

% Compute sill and structure impedance at each corner ZeAA = zeros(length(F),1); ZeBA = zeros(length(F),1); ZeAF = zeros(length(F),1); ZeBF = zeros(length(F),1); ZsAA = zeros(length(F),1); ZsBA = zeros(length(F),1); ZsAF = zeros(length(F),1); ZsBF = zeros(length(F),1);

104

A.4 Continued
for ii = 1:length(F) ZeAA(ii) = ForceAA(ii) / XdAA(ii) + Mount_Imp(ii) * YdAA(ii) / XdAA(ii) Mount_Imp(ii); ZsAA(ii) = Mount_Imp(ii) * XdAA(ii) / YdAA(ii) - Mount_Imp(ii); ZeBA(ii) = ForceBA(ii) / XdBA(ii) + Mount_Imp(ii) * YdBA(ii) / XdBA(ii) Mount_Imp(ii); ZsBA(ii) = Mount_Imp(ii) * XdBA(ii) / YdBA(ii) - Mount_Imp(ii); ZeAF(ii) = ForceAF(ii) / XdAF(ii) + Mount_Imp(ii) * YdAF(ii) / XdAF(ii) Mount_Imp(ii); ZsAF(ii) = Mount_Imp(ii) * XdAF(ii) / YdAF(ii) - Mount_Imp(ii); ZeBF(ii) = ForceBF(ii) / XdBF(ii) + Mount_Imp(ii) * YdBF(ii) / XdBF(ii) Mount_Imp(ii); ZsBF(ii) = Mount_Imp(ii) * XdBF(ii) / YdBF(ii) - Mount_Imp(ii); end % Compute the new mount impedance lbfin2 = input('New Mount Stiffness:') k = lbfin2 / (4.45 / 0.0254); % Mount Stiffnes (lb/in) converted to (N/m) zeta = 0.05; % Damping Coefficient mass = (7500 / 4) * 0.4536; % Mount Mass (kg) c = 2*zeta*sqrt(k*mass); % Damping for ii = 1:length(F) Mount_Imp2(ii) = c + ( k / (i*F(ii)*2*pi)); end % Compute Xd and Yd at each corner using new mount impedance for ii = 1:length(F) Yd2AA(ii) = ForceAA(ii) / ( (Mount_Imp2(ii) + ZeAA(ii)) * ((ZsAA(ii) + Mount_Imp2(ii)) / Mount_Imp2(ii)) - Mount_Imp2(ii)); Xd2AA(ii) = ((ZsAA(ii) + Mount_Imp2(ii)) / Mount_Imp2(ii)) * Yd2AA(ii); Yd2BA(ii) = ForceBA(ii) / ( (Mount_Imp2(ii) + ZeBA(ii)) * ((ZsBA(ii) + Mount_Imp2(ii)) / Mount_Imp2(ii)) - Mount_Imp2(ii)); Xd2BA(ii) = ((ZsBA(ii) + Mount_Imp2(ii)) / Mount_Imp2(ii)) * Yd2BA(ii); Yd2AF(ii) = ForceAF(ii) / ( (Mount_Imp2(ii) + ZeAF(ii)) * ((ZsAF(ii) + Mount_Imp2(ii)) / Mount_Imp2(ii)) - Mount_Imp2(ii)); 105

A.4 Continued
Xd2AF(ii) = ((ZsAF(ii) + Mount_Imp2(ii)) / Mount_Imp2(ii)) * Yd2AF(ii); Yd2BF(ii) = ForceBF(ii) / ( (Mount_Imp2(ii) + ZeBF(ii)) * ((ZsBF(ii) + Mount_Imp2(ii)) / Mount_Imp2(ii)) - Mount_Imp2(ii)); Xd2BF(ii) = ((ZsBF(ii) + Mount_Imp2(ii)) / Mount_Imp2(ii)) * Yd2BF(ii); end % Frequency range to Display fmax = 500; % Plot Results figure % Plot velocities for BA subplot(2,1,1) semilogy(F,abs(XdBA),'b-',F,abs(Xd2BA),'r-') grid legend('Actual','Predicted') title('Velocities for B-side, Aft - Soft Mounted (K=10000)') ylabel('Sill Velocity (m/s)') ax = axis; ax(2) = fmax; ax(3) = .00000001; ax(4) = .001; axis(ax) subplot(2,1,2) semilogy(F,abs(YdBA),'b-',F,abs(Yd2BA),'r-') grid ylabel('Structure Velocity (m/s)') xlabel('Frequency (Hz)') ax = axis; ax(2) = fmax; ax(3) = .00000001; ax(4) = .001; axis(ax)

106

A.4 Continued
figure % Plot velocities for BF subplot(2,1,1) semilogy(F,abs(XdBF),'b-',F,abs(Xd2BF),'r-') grid legend('Actual','Predicted') title('Velocities for B-side, Front - Soft Mounted (K=10000)') ylabel('Sill Velocity (m/s)') ax = axis; ax(2) = fmax; ax(3) = .00000001; ax(4) = .001; axis(ax) subplot(2,1,2) semilogy(F,abs(YdBF),'b-',F,abs(Yd2BF),'r-') grid ylabel('Structure Velocity (m/s)') xlabel('Frequency (Hz)') ax = axis; ax(2) = fmax; ax(3) = .00000001; ax(4) = .001; axis(ax) figure % Plot velocities for AA subplot(2,1,1) semilogy(F,abs(XdAA),'b-',F,abs(Xd2AA),'r-') grid legend('Actual','Predicted') title('Velocities for A-side, Aft - Soft Mounted (K=10000)') ylabel('Sill Velocity (m/s)') ax = axis; ax(2) = fmax; ax(3) = .00000001; ax(4) = .001; axis(ax)

107

A.4 Continued
subplot(2,1,2) semilogy(F,abs(YdAA),'b-',F,abs(Yd2AA),'r-') grid ylabel('Structure Velocity (m/s)') xlabel('Frequency (Hz)') ax = axis; ax(2) = fmax; ax(3) = .00000001; ax(4) = .001; axis(ax) figure %Plot velocities for AF subplot(2,1,1) semilogy(F,abs(XdAF),'b-',F,abs(Xd2AF),'r-') grid legend('Actual','Predicted') title('Velocities for A-side, Front - Soft Mounted (K=10000)') ylabel('Sill Velocity (m/s)') ax = axis; ax(2) = fmax; ax(3) = .00000001; ax(4) = .001; axis(ax) subplot(2,1,2) semilogy(F,abs(YdAF),'b-',F,abs(Yd2AF),'r-') grid ylabel('Structure Velocity (m/s)') xlabel('Frequency (Hz)') ax = axis; ax(2) = fmax; ax(3) = .00000001; ax(4) = .001; axis(ax)

108

Potrebbero piacerti anche