Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fftFreq - what does it do? #103

Open
cjn01 opened this issue Aug 17, 2023 · 4 comments
Open

fftFreq - what does it do? #103

cjn01 opened this issue Aug 17, 2023 · 4 comments

Comments

@cjn01
Copy link

cjn01 commented Aug 17, 2023

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
Copy link
Contributor

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
Copy link

LUOFQ5 commented Sep 20, 2023

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
Copy link
Contributor

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
Copy link

LUOFQ5 commented Sep 20, 2023

@mkraposhin Thanks for your reply. I understand now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants