def test_stabilisation(): from OpenModal.analysis.lscf import lscf from OpenModal.analysis.utility_functions import prime_factors """ Test of the Complex Exponential Method and stabilisation """ f, frf, modal_sim, eta_sim, f0_sim = get_simulated_receptance( df_Hz=1, f_start=0, f_end=5001, measured_points=8, show=False, real_mode=False) low_lim = 0 nf = (2 * (len(f) - 1)) print(nf) while max(prime_factors(nf)) > 5: f = f[:-1] frf = frf[:, :-1] nf = (2 * (len(f) - 1)) print(nf) df = (f[1] - f[0]) nf = 2 * (len(f) - 1) ts = 1 / (nf * df) # sampling period nmax = 30 sr = lscf(frf, low_lim, nmax, ts, weighing_type='Unity', reconstruction='LSFD') # N = np.zeros(nmax, dtype = 'int') err_fn = 0.001 err_xi = 0.005 fn_temp,xi_temp, test_fn, test_xi= stabilisation(sr, nmax, err_fn, err_xi) stable_fn, stable_xi = stabilisation_plot(test_fn, test_xi, fn_temp, xi_temp, nmax, f, frf.T)
def test_lsfd(): f, frf, modal_sim, eta_sim, f0_sim = get_simulated_receptance( df_Hz=1, f_start=0, f_end=5001, measured_points=8, show=False, real_mode=False) low_lim = 1500 nf = (2 * (len(f) - 1)) while max(prime_factors(nf)) > 5: f = f[:-1] frf = frf[:, :-1] nf = (2 * (len(f) - 1)) df = (f[1] - f[0]) nf = 2 * (len(f) - 1) ts = 1 / (nf * df) # sampling period sr = lscf(frf, low_lim, 6, ts, weighing_type='Unity', reconstruction='LSFD') fr, xi = complex_freq_to_freq_and_damp(sr[-1]) print('Eigenfrequencies\n', fr) print('Damping factors\n', xi)
def test_lsce(): from OpenModal.analysis.utility_functions import complex_freq_to_freq_and_damp """ Test of the Least-Squares Complex Exponential Method """ from OpenModal.analysis.get_simulated_sample import get_simulated_receptance import matplotlib.pyplot as plt f, frf, modal_sim, eta_sim, f0_sim = get_simulated_receptance(df_Hz=1, f_start=0, f_end=5001, measured_points=8, show=False, real_mode=False) low_lim = 100 nf = (2*(len(f)-low_lim-1)) while max(prime_factors(nf)) > 5: f = f[:-1] frf = frf[:, :-1] nf = (2*(len(f)-low_lim-1)) df = (f[1] - f[0]) nf = 2*(len(f)-low_lim-1) ts = 1 / (nf * df) # sampling period n = 12 low_lim = 100 sr = lsce(frf, f[low_lim], low_lim, n, ts, additional_timepoints=0, reconstruction='LSFD') fr, xi = complex_freq_to_freq_and_damp(sr[-2]) print("fr\n", fr) print("xi\n", xi)
def test_stabilisation(): from OpenModal.analysis.lscf import lscf from OpenModal.analysis.utility_functions import prime_factors """ Test of the Complex Exponential Method and stabilisation """ f, frf, modal_sim, eta_sim, f0_sim = get_simulated_receptance( df_Hz=1, f_start=0, f_end=5001, measured_points=8, show=False, real_mode=False) low_lim = 0 nf = (2*(len(f)-low_lim-1)) print(nf) while max(prime_factors(nf)) > 5: f = f[:-1] frf = frf[:, :-1] nf = (2*(len(f)-low_lim-1)) print(nf) df = (f[1] - f[0]) nf = 2*(len(f)-low_lim-1) ts = 1 / (nf * df) # sampling period nmax = 30 sr = lscf(frf, low_lim, nmax, ts, weighing_type='Unity', reconstruction='LSFD') # N = np.zeros(nmax, dtype = 'int') err_fn = 0.001 err_xi = 0.005 fn_temp,xi_temp, test_fn, test_xi= stabilisation(sr, nmax, err_fn, err_xi) stable_fn, stable_xi = stabilisation_plot(test_fn, test_xi, fn_temp, xi_temp, nmax, f, frf.T)
def test_ewins(): import matplotlib.pyplot as plt from OpenModal.analysis.get_simulated_sample import get_simulated_receptance residues = True freq, H, MC, eta, D = get_simulated_receptance( df_Hz=1, f_start=0, f_end=2000, measured_points=10, show=False, real_mode=True) #freq, H = get_measured_accelerance() #identification of natural frequencies ind_nf = get_frf_peaks(freq, H[1, :], freq_min_spacing=10) #identification of modal constants and damping A, mi = ewins(freq, H, freq[ind_nf], type='d', residues=residues) #reconstruction Nfrf = 4 #serial number of compared FRF H_rec = reconstruction(freq, freq[ind_nf], A[1:-1, Nfrf], mi[:, Nfrf], residues=residues, type='d', LR=A[0, Nfrf], UR=A[-1, Nfrf]) H_rec = reconstruction(freq, freq[ind_nf], A[1:-1, Nfrf] , mi[:, Nfrf], residues=True, type='d', LR=A[0, Nfrf], UR=A[-1, Nfrf]) #comparison of original and reconstructed FRF fig, [ax1, ax2] = plt.subplots(2, 1, sharex=True, figsize=(12, 10)) ax1.semilogy(freq, np.abs(H[Nfrf, :])) ax1.semilogy(freq, np.abs(H_rec)) ax2.plot(freq, 180 / np.pi * (np.angle(H[Nfrf, :]))) ax2.plot(freq, 180 / np.pi * (np.angle(H_rec))) ax1.set_ylabel('Frequency [Hz]') ax1.set_ylabel('Magn [m s$^{-2}$ N$^{-1}$]') ax2.set_ylabel('Angle [deg]') plt.show() if residues: plt.plot(range(0, len(A[1, :])), np.real(A[1:-1]).T, 'r') else: plt.plot(range(0, len(A[0, :])), A, 'r') plt.plot(range(0, len(MC[0, :])), MC.T) plt.xlabel('Point') plt.ylabel('Modal constant') plt.show
def test_lsfd(): f, frf, modal_sim, eta_sim, f0_sim = get_simulated_receptance( df_Hz=1, f_start=0, f_end=5001, measured_points=8, show=False, real_mode=False) low_lim = 1500 nf = (2*(len(f)-low_lim-1)) while max(prime_factors(nf)) > 5: f = f[:-1] frf = frf[:, :-1] nf = (2*(len(f)-low_lim-1)) df = (f[1] - f[0]) nf = 2*(len(f)-1) ts = 1 / (nf * df) # sampling period sr = lscf(frf, low_lim, 6, ts, weighing_type='Unity', reconstruction='LSFD') fr, xi = complex_freq_to_freq_and_damp(sr[-1]) print('Eigenfrequencies\n', fr) print('Damping factors\n', xi)
def test_lsce(): from OpenModal.analysis.utility_functions import complex_freq_to_freq_and_damp """ Test of the Least-Squares Complex Exponential Method """ from OpenModal.analysis.get_simulated_sample import get_simulated_receptance import matplotlib.pyplot as plt f, frf, modal_sim, eta_sim, f0_sim = get_simulated_receptance( df_Hz=1, f_start=0, f_end=5001, measured_points=8, show=False, real_mode=False) low_lim = 100 nf = (2 * (len(f) - low_lim - 1)) while max(prime_factors(nf)) > 5: f = f[:-1] frf = frf[:, :-1] nf = (2 * (len(f) - low_lim - 1)) df = (f[1] - f[0]) nf = 2 * (len(f) - low_lim - 1) ts = 1 / (nf * df) # sampling period n = 12 low_lim = 100 sr = lsce(frf, f[low_lim], low_lim, n, ts, additional_timepoints=0, reconstruction='LSFD') fr, xi = complex_freq_to_freq_and_damp(sr[-2]) print("fr\n", fr) print("xi\n", xi)