numCycles = 6 ampInit = 1 ampFinal = 1 freqMinDes_rps = 0.1 * hz2rps * np.ones(numExc) freqMaxDes_rps = 10.3 * hz2rps * np.ones(numExc) freqStepDes_rps = (20 / freqRate_hz) * hz2rps methodSW = 'zip' # "zippered" component distribution # Generate MultiSine Frequencies freqExc_rps, sigIndx, time_s = GenExcite.MultiSineComponents(freqMinDes_rps, freqMaxDes_rps, freqRate_hz, numCycles, freqStepDes_rps, methodSW) # Generate Schroeder MultiSine Signal ampExcit_nd = np.linspace(ampInit, ampFinal, len(freqExc_rps)) / np.sqrt(len(freqExc_rps)) rExc, phaseElem_rad, sigExcit = GenExcite.MultiSine(freqExc_rps, ampExcit_nd, sigIndx, time_s, phaseInit_rad = 0, boundPhase = 1, initZero = 1, normalize = 'peak', costType = 'Schroeder') rExc = rExc / np.std(rExc) rPeak = np.mean(GenExcite.PeakFactor(rExc) * np.std(rExc))**2 # Excited Frequencies per input channel freqChan_rps = freqExc_rps[sigIndx] freqChan_hz = freqChan_rps * rps2hz # Null Frequencies freqGap_rps = freqExc_rps[0:-1] + 0.5 * np.diff(freqExc_rps) freqGap_hz = freqGap_rps * rps2hz #%% Simulate the excitation through the system np.random.seed(0) # Time Response p = np.random.normal([0.0, 0.0], pSigma, size = (len(time_s), 2)).T
#freqMaxDes_rps = (freqRate_hz/2) * hz2rps * np.ones(numChan) freqMaxDes_rps = 10 * hz2rps * np.ones(numChan) freqStepDes_rps = (10 / freqRate_hz) * hz2rps methodSW = 'zip' # "zippered" component distribution ## Generate MultiSine Frequencies freqElem_rps, sigIndx, time_s = GenExcite.MultiSineComponents(freqMinDes_rps, freqMaxDes_rps, freqRate_hz, numCycles, freqStepDes_rps, methodSW) timeDur_s = time_s[-1] - time_s[0] ## Generate Schroeder MultiSine Signal ampElem_nd = np.ones_like(freqElem_rps) ## Approximate relative signal amplitude, create flat sigList, phaseElem_rad, sigElem = GenExcite.MultiSine(freqElem_rps, ampElem_nd, sigIndx, time_s, costType = 'Norm2', phaseInit_rad = 0, boundPhase = 1, initZero = 1, normalize = 'peak'); ## Results peakFactor = GenExcite.PeakFactor(sigList) peakFactorRel = peakFactor / np.sqrt(2) print(peakFactorRel) # Signal Power sigPowerRel = (ampElem_nd / max(ampElem_nd))**2 / len(ampElem_nd) if True: fig, ax = plt.subplots(ncols=1, nrows=numChan, sharex=True) for iChan in range(0, numChan): ax[iChan].plot(time_s, sigList[iChan]) ax[iChan].set_ylabel('Amplitude (nd)') ax[iChan].grid(True) ax[iChan].set_xlabel('Time (s)')
freqMaxDes_rps = 10.1 * hz2rps * np.ones(numExc) freqStepDes_rps = (10/freqRate_hz) * hz2rps methodSW = 'zip' # "zippered" component distribution # Generate MultiSine Frequencies freqExc_rps, sigIndx, time_s = GenExcite.MultiSineComponents(freqMinDes_rps, freqMaxDes_rps, freqRate_hz, numCycles, freqStepDes_rps, methodSW) freqGap_rps = freqExc_rps[0:-1] + 0.5 * np.diff(freqExc_rps) #time_s = time_s[0:-5] # Generate Schroeder MultiSine Signal ampExcit_nd = np.linspace(ampInit, ampFinal, len(freqExc_rps)) / np.sqrt(len(freqExc_rps)) uExc, phaseElem_rad, sigExcit = GenExcite.MultiSine(freqExc_rps, ampExcit_nd, sigIndx, time_s, phaseInit_rad = 0, boundPhase = 1, initZero = 1, normalize = 'rms', costType = 'Schroeder') uExc = (uExc.T * (1 / np.std(uExc, axis = -1))).T uStd = np.std(uExc, axis = -1) uPeak = np.mean(GenExcite.PeakFactor(uExc) * uStd)**2 # Excited Frequencies per input channel freqChan_rps = freqExc_rps[sigIndx] freqChan_hz = freqChan_rps * rps2hz # Simulate the excitation through the system _, y, _ = control.forced_response(sysPlant, T = time_s, U = uExc) # Plant-Output Noise noiseK11 = (2/8) * np.abs(sysPlant.dcgain())[0, 0]; noiseWn11 = 6 * hz2rps; noiseD11 = 0.1; noiseK22 = (8/8) * np.abs(sysPlant.dcgain())[1, 1]; noiseWn22 = 4 * hz2rps; noiseD22 = 1.0; sysN = control.tf([[[-noiseK11, 0, noiseK11 * noiseWn11**2], [0]], [[0], [-noiseK22, 0, noiseK22 * noiseWn22**2]]],
#time_s = time_s[0:-5] # Generate Schroeder MultiSine Signal ampExcit_nd = np.linspace(ampInit, ampFinal, len(freqExc_rps)) / np.sqrt( len(freqExc_rps)) exc, phaseElem_rad, sigExcit = GenExcite.MultiSine(freqExc_rps, ampExcit_nd, sigIndx, time_s, phaseInit_rad=0, boundPhase=1, initZero=1, normalize='peak', costType='Schroeder') exc = exc / np.std(exc) uPeak = np.mean(GenExcite.PeakFactor(exc) * np.std(exc, axis=-1))**2 # Excited Frequencies per input channel freqChan_rps = freqExc_rps[sigIndx] freqChan_hz = freqChan_rps * rps2hz #%% N = 2**8 fBin = np.linspace(0, 10, num=N) D = FreqTrans.Dirichlet(fBin, N) Dmag = np.abs(D) Dmax = np.nanmax(Dmag) Dnorm_mag = Dmag / Dmax Dnorm_dB = mag2db(Dnorm_mag)