Azzera filtri
Azzera filtri

How to apply low pass filter to forces generated by OpenFOAM?

5 visualizzazioni (ultimi 30 giorni)
Hello there,
currently I'm writing my master thesis and investigating wave-wall interactions with OpenFOAM. It's my first time using numerical simulations or MATLAB or writing code, so please bear with me.
In the data are many peaks with "wrong" data. My supervisor told me that this is normal in numerical simulations and that I should use a low pass filter to correct the data and that this is quite easy. As an example I attached a plot to this post. In the second phase the blue line reaches negative values, which is impossible.
How can I fix this with a filter? All the instructions/videos/threads I found were about filtering acustic signals and I don't know / didn't achieve to transfer this information to my case.
If you got any hints or references which could help me I'd really appreciate.
Thanks a lot!

Risposte (1)

Star Strider
Star Strider il 15 Mag 2024
Filters do not care what data you present to them. They assume that the data are sampled at constant intervals, and that the chosen frequencies for the cutoff (or cutoffs) are greater than zero and less than the Nyquist frequency (one-half the sampling frequency). The independent varriable is most often time, however it can be distance or anything else.
If you have the Signal Processing Toolbox, use the lowpass function with the 'ImpulseResponmse','iir' name-value pair to design an efficient elliptic filter. (If you want to filter more than one signal at the same time, and they have the same lengths, you can combine them into a matrix. Each signal has to be a separate column. Otherwise, if the sampling and cutoff frequencies are the same, get the second output from lowpass and use it with filtfilt to filter more signals of different lengths.)
It is relatively straightforward to design filters in MATLAB using command-line arguments in a script, however lowpass (and its firends) make this much easier.
If your data are not regularly sampled, you must use the resample function first in order to make them regularly sampled. Choose a sampling frequency that is reasonably close to the mean sampling frequency of the signal and then use resample:
Fs = 1/mean(diff(t));
[yr,tr] = resample(t, t, Fs);
to create a resampled signal to present to the filter. Do that for each signal. UIse the same value for ‘Fs’ for all of them.
If you are unsure of the correct cutoff frequency for your filter, first use the fft function or the pspectrum function on the resampled signal to examine its spectral characteristics. Use that to design the cutoff frequency.
.

Prodotti


Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by