unicfdlab / libAcoustics

libAcoustics - OpenFOAM library for far-field noise computation
140 stars 57 forks source link

fftFreq - what does it do? #103

Open cjn01 opened 1 year ago

cjn01 commented 1 year ago

What is the function of fftFreq in the commonSettings file? image

I've run a simulation using the FWH GTFormulation. The acoustics were turned on for 0.1 s of simulation time, and the timestep was 2.5e-6 s. The *-time.dat files have 40000 rows of pFluct vs time data, as expected. However, the fft-*.dat files have 79872 rows of SPL vs Frequency data. Based on my fftFreq of 1024, I would expect 513 SPL vs Frequency values, unless fftFreq is different to nfft?

Furthermore, how is fft implemented for the libacoustics library, i.e, how does one arrive at the SPL vs. Frequency in the fft-*.dat file from the pFluct vs. time in the *-time.dat file.

I could just be misunderstanding something but I'd greatly appreciate any additional information regarding this.

Thank you

mkraposhin commented 1 year ago

This parameters specifies frequency (per time step if i'm not mistaking) of FFT procedure execution. 1024 means that FFT will be runned each 1024-th time step.

LUOFQ5 commented 1 year ago

Does it mean that the final FFT execution is based on all 39936 rows of p-data in cjn01's case? But why fft-data have a double frequency result (79872 rows)?

mkraposhin commented 1 year ago

No it means that if your execution has 4096 time steps, then FFT procedure will be executed over time data 4 times: on 1024-th, 2048-th, 3072-th and 4096-th time steps. If there is no window, then in each executiom time series will have 1024, 2048, 3072 and 4096 points.

Regarding number of frequencies - this is a property of FFT. Resulting spectrum is symmetric and has 2*N points, where N - maximum number of frequencies for a given discrete time sequence. I think, you should read more about FFT theory somewhere.

LUOFQ5 commented 1 year ago

@mkraposhin Thanks for your reply. I understand now.