Python中时间和空间中的电磁力谐波

时间:2017-07-02 09:41:58

标签: python numpy fft

我必须计算电动机的径向力谐波并在时间和空间上表示它们。用于寻找径向力的方法是Maxwell应力张量(该方法在FEM求解器中实现:Gmsh并从那里获得径向和切向通量密度的值)。我在Python中导入了所有数据,在这里我写了径向力的表达式,如下所示:

def integrateForces (Axiallength,dtheta,Rad,br,bt):    
    integral_rad =0
    for i in range(len(br)):
        integral_rad +=  (1/(2*mu0)*(br[i]*br[i]-bt[i]*bt[i])*Axiallength*Rad*dtheta)
    return integral_rad  

现在我想在时间和空间上代表fft的径向力,但我不知道如何。我得到的只是时间fft,代码是这样的:

Fs = 100   #sampling frequency
n  = 145   #number of samples
t = np.linspace(0,n/Fs,n)   # time vector
y =  fradial
def plotFFT(t,y,Fs,n):
    fft_v = np.fft.fft(y)
    fft_pow = np.abs(fft_v)/t.shape[-1]
    freq = np.fft.fftfreq(t.shape[-1],d=t[2]-t[1])
    # basically fftfreq returns the frequencies
    pl.figure(figsize=(8,5))
    pl.xlabel('Frequency [Hz]',fontsize =13)
    pl.ylabel('Power spectrum',fontsize =13)
    baseline = pl.stem(freq,fft_pow)
    pl.axis([-0.1,100,0,45])
    pl.xscale('symlog', linthreshx=0.1)
    pl.yscale('symlog', linthreshx=0.1)
    pl.setp(baseline, 'color','b', 'linewidth', 2)
    pl.grid()
    pl.show()

plotFFT(t,y,Fs,n)

任何想法都会有所帮助。谢谢!

0 个答案:

没有答案