from dataclasses import dataclassfrom typing import Optionalimport matplotlib.pyplot as pltimport numpy as npN_TIME_SAMPLES = 1000N_SIMULATED_IMPULSES = 5NATURAL_FREQUENCY = 10.0DECAY_RATE = 5.0AVERAGE_PERIOD = 1.0@dataclassclass DecayComponentCreator:"""Class that represents the decay component of fault signal."""natural_frequency: floatdecay_rate: floatdef __call__(self, t: np.ndarray) -> np.ndarray:decay_component = np.exp(-self.decay_rate * t) * np.cos(2 * np.pi * self.natural_frequency * t)# Set signal amplitude for time before zero to zerodecay_component[t @dataclassclass FaultSignalCreator:"""Class that represents the fault signal."""impulse_amplitudes: np.ndarraycreate_decay_component: DecayComponentCreatoraverage_period: floatperiod_fluctuations: Optional[np.ndarray] = Nonedef _create_fault_impulse(self, t: np.ndarray, idx: int) -> np.ndarray:"""Create a single fault impulse."""fault_impulse = self.impulse_amplitudes[idx] * self.create_decay_component(t - idx * self.average_period - self.period_fluctuations[idx])return fault_impulsedef __call__(self, t: np.ndarray) -> np.ndarray:if self.period_fluctuations is None:self.period_fluctuations = np.zeros(len(t))fault_impulses = np.array([self._create_fault_impulse(t, idx)for idx, _ in enumerate(self.impulse_amplitudes)])fault_signal = np.sum(fault_impulses, axis=0)return fault_signaldef main -> None:impulse_amplitudes = np.ones(N_SIMULATED_IMPULSES)create_decay_component = DecayComponentCreator(NATURAL_FREQUENCY, DECAY_RATE)create_fault_signal = FaultSignalCreator(impulse_amplitudes,create_decay_component,AVERAGE_PERIOD,)signal_duration = AVERAGE_PERIOD * N_SIMULATED_IMPULSESt = np.linspace(0, signal_duration, N_TIME_SAMPLES)x = create_fault_signal(t)plt.plot(t, x)plt.grid(True)plt.showif __name__ == "__main__":main知乎学术咨询:https://www.zhihu.com/consult/people/792359672131756032?isMe=1担任《Mechanical System and Signal Processing》《中国电机工程学报》等期刊审稿专家,擅长领域:信号滤波/降噪,机器学习/深度学习,时间序列预分析/预测,设备故障诊断/缺陷检测/异常检测。摘要:from dataclasses import dataclassfrom typing import Optionalimport matplotlib.pyplot as pltimport numpy as npN_TIME_SAMPLES = 1000
分割线分割线分割线
MATLAB环境下滚动轴承故障模拟振动信号生成方法
简单研究了滚动轴承复合故障仿真信号及时频谱,并给出了相应的程序,运行环境为MATLAB R2021B,包括但不限于:滚动轴承内圈、外圈和滚动体复合故障,复合故障+随机冲击故障,复合故障+齿轮啮合干扰信号+转子干扰信号,部分代码如下:
% 加噪信号生成nDb = -0;sig = bearing + rot + gear;x = noisegen(sig,nDb);noi = x - sig;%时域图figure(13)plot(t,x);ylabel('Amplitude');xlabel('Time [s]');xlim([0 0.4]);setfontsize(14);%频谱figure(14)myfft(fs,x,1);ylabel('Amplitude');xlabel('Frequency [Hz]');setfontsize(14);ncomb = 20;helperPlotCombs(ncomb,113.0457);xlim([0 3000]);%原始信号的CWT时频谱figure(16)cwt(sig(1:0.4*fs),fs,'morse');setfontsize(14);% 加噪后信号的CWT时频谱figure(17)cwt(x(1:0.4*fs),fs,'morse')setfontsize(14);部分出图如下:
轴承内圈故障+随机冲击信号
轴承内圈故障+随机冲击信号+转子干扰信号
轴承内圈故障+随机冲击信号+转子干扰信号+齿轮啮合信号
轴承外故障+随机冲击信号+转子干扰信号+齿轮啮合信号
完整代码可通过知乎学术咨询获得
基于改进字典学习的旋转机械故障诊断(MATLAB)
该算法主要是由多尺度变换、信号的系数正则和源区分加权项组成,将旋转机械故障信号分解成不同的尺度,每个尺度会有一个子字典,这使得组合字典D具有多尺度特性;由于子字典是从不同频带中分解学习得到的,所以可有效的保障故障特征的周期性和全局性;故障信号的数据长度N可人为设定,减少了计算的复杂度;对谐波干扰有很好的滤波作用。
来源:小丁科技论
免责声明:本站系转载,并不代表本网赞同其观点和对其真实性负责。如涉及作品内容、版权和其它问题,请在30日内与本站联系,我们将在第一时间删除内容!