1 Star 1 Fork 1

Dsy / fft

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

FFT

傅里叶分解

1. Modeling

The magnetization directions of the PMs based on the Halbach linear motor are shown in the figure below,

image-20210908200741305

2. FFT by Maxwell

The magnetic density waveform of the air-gap under a pair of poles is obtained by Maxwell as shown in the figure below,

image-20210908201602626

The Fourier decomposition is obtained by maxwell's FFT as shown in the figure below,

image-20210908201806589

3. FFT by python & Matplotlib (Recommended)

Export the air-gap magnetic density ($B_x$) to csv format and the FFT code in python is as follows,

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.pylab import mpl
 
mpl.rcParams['font.sans-serif'] = ['SimSun']
mpl.rcParams['axes.unicode_minus']=False
#plt.rcParams['figure.dpi'] = 300
plt.rcParams['figure.constrained_layout.use'] = True

fig = plt.figure()
fixed_width_mm = 340
fixed_height_mm = 170
fixed_width_inch = fixed_width_mm / 25.4
fixed_height_inch = fixed_height_mm / 25.4
fig.set_size_inches(fixed_width_inch, fixed_height_inch)

ax1 = fig.add_subplot(121)
ax2 = fig.add_subplot(122)

data = pd.read_csv('Bx.csv')
x = data['Distance [mm]']
y = data['bx []']
ax1.plot(x,y,color='r',label='orgin',ls='--')

fft_y=np.fft.fft(y)
N=fft_y.shape[0]

orders=11
order=orders+1

fundamental=np.abs(fft_y[1])/N*2
harmonics=np.abs(fft_y[2:order])/N*2
thd=np.sqrt(np.sum(harmonics**2))/fundamental
thd_per = round(thd*100, 2)

for i in range(order):
	new_fft_y=np.zeros_like(fft_y)
	new_fft_y[i]=fft_y[i]
	ifft_y=np.fft.ifft(new_fft_y).real*2
	ax1.plot(x,ifft_y,label='order='+str(i))
	normalization_y=np.abs([fft_y[i]])/N*2
	ax2.bar(i,normalization_y)

ax1.legend()
ax1.set_title('各次谐波分解示意图')
ax1.set_xlabel('长度(mm)')
ax1.set_ylabel('各次谐波幅值大小')
ax1.set_xlim(x[0],x[len(x)-1])

ax2.set_title('各次谐波FFT分解柱状图 (THD='+str(thd_per)+'%)')
ax2.set_xlabel('谐波次数')
ax2.set_ylabel('各次谐波幅值大小')
ax2.set_xlim(0,order)
ax2.set_xticks(np.arange(0,order,1))

plt.show()

The FFT is as follows,

Figure_1.jpeg

4. FFT by Matlab (Not recommended)

Export the air-gap magnetic density ($B_x$) to csv format and the FFT code in matlab is as follows,

clc
clear all;
format long;
Ns=1001;		%采样点
order=11;		%谐波数
filename='Bx.csv';		%导出的气隙磁密数据集
data=csvread(filename,1,0);     %从行偏移量 R1 和列偏移量 C1 开始读取文件中的数据
x=data(:,1);        %取第一列
y=data(:,2);        %取第二列
figure;
plot(x,y,'r');      %plot origional waveform
hold on;
grid on;
fft1=fft(y,Ns);
j=0;
amp_har=zeros(1,(order));
%%
for m=1:1:order
j=j+1;
fft1=fft(y,Ns);
fund_ele_front=fft1(m+1);
fund_ele_back=fft1(Ns+1-m);
amp_har(j)=(abs(fund_ele_front))/Ns*2;
fft1=0*fft1;
fft1(m+1)=fund_ele_front;
fft1(Ns+1-m)=fund_ele_back;
fft1=ifft(fft1,Ns);
fft1=real(fft1);
plot(x,fft1);
title('各次谐波分解示意图')
xlabel('长度(mm)')
ylabel('各次谐波幅值大小')
hold on;
end
%%
k=(1:1:order);
figure;
bar(k,amp_har);
title('各次谐波FFT分解柱状图')
xlabel('谐波次数')
ylabel('各次谐波幅值大小')
grid on;
peak_b=max(fft1);
rms_b=0.707*peak_b;
s=amp_har.^2;
THD = sqrt(sum(s(2:(order+1)/2)))/(amp_har(1));
THD_pct = 100*THD;

The decomposition of each harmonic is as follows,

image-20210908202606806

The histogram of FFT decomposition of each harmonic is as follows,

image-20210908202728889

About Project

  • Version:ANASYS Electronics Suite 2021 R2
MIT License Copyright (c) 2021 Kisho Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

fft by python and matlab 展开 收起
Python 等 2 种语言
MIT
取消

发行版 (1)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/kishomoe/fft.git
git@gitee.com:kishomoe/fft.git
kishomoe
fft
fft
main

搜索帮助

53164aa7 5694891 3bd8fe86 5694891