An unsteady flow has, by definition, fluctuations in velocity and pressure. More often than not this results in a more or less pleasant noise. If you fear this noise could be on the less-pleasant side, you can simulate the sound and listen to it before the finished product causes Ye Royale Paine in Ye Buttocks.
Let’s not cause Ye Royale Paine in one’s Buttocks by physical trial-and-error. Let’s first use OpenFOAM and simulate the sound in theory first and then decide whether to do anything in real life.
OpenFOAM case parameters
First, as many timesteps from a transient simulation as possible. Also, the timesteps should be evenly spaced. The easiest way to achieve this is to set writeControl in system/controlDict:
writeInterval 0.0001; // sampling rate for your audio
purgeWrite 200; // or as many as you can afford
When your simulation ends, open the results in ParaView and load only the pressure field. You will traverse over all timesteps and it makes sense to limit the amount of data to load from disk.
Then choose a point to press your ear against. For a start, maybe somewhere on a wall close to noise source. Select a small number of mesh points around the chosen position (shortcut d) and then choose Plot selection over time filter. Click Copy active selection, then Apply, then grab a coffee.
A Quartile Chart View will pop up with the results but you’ll need a Spreadsheet view. Convert it by right-clicking on the view title. The spreadsheet view enables you to export the row data to CSV. The data includes all kinds of statistics but you’ll only need average. You could read the CSV file with python but I didn’t bother with that, just imported it to Calc and copy-pasted values for time and pressure to a python file.
The following complexities (no pun intended) are here for two reasons:
- You probably don’t have enough timesteps saved for more than a fraction of a second of listening time;
- Spectral analysis gives you a better insight of the sound and vibration: which frequencies are the most prominent (audible), possible resonance with eigenfrequencies of the mechanical part(s), …
Assuming you have two lists p and t for pressure and time, respectively, you obtain frequency spectrum with:
import numpy as np from scipy.fftpack import fft, ifft, fftshift from numpy.fft import fftfreq from matplotlib import pyplot as plt import scipy.io.wavfile as wav N_start = 10 # start with index 10 t = t[N_start:] # t holds times of timesteps (evenly spaced!) p = p[N_start:] # p holds pressure extracted from ParaView t1 = t t2 = t[-1] N = len(t) ts = (t2 - t1)/N # time step # remove DC offset with fftshift yf = fftshift(fft(p)) # calculate at which frequencies to show yf ffreq = fftfreq(N, d=ts)
Then plot the results:
plt.loglog(ffreq[:N//2], 2/N*np.abs(yf[:N//2])) plt.show()
Then, you make a reverse fourier transform and tile the list to obtain a sample of any length (in this case, 1000 times the length of t):
data = np.abs(ifft(yf)) data = data/np.max(np.abs(data))*2**16 data = np.tile(data, 1000)
Save and listen
With scipy.io you can easily save the results to a .wav file for listening. Make sure the sampling rate coincides with your controlDict settings.
Try your default player at first, then VLC, then Audacity as the last resort. Also check the volume of your speakers. I struggled to get the thing working and when I succeeded almost fell off my chair.
sample_rate = 1/ts wav.write("sound.wav", int(sample_rate), data.astype('int16'))
I ran two incompressible cases of a centrifugal pump: Case 1 with a skewed volute cutwater and Case 2 with a perpendicular one. Impeller blades are not inclined at the outlet but parallel to rotation axis (and therefore parallel to the cutwater in case 2).
Old turbomachinery recipes say that skewing the cutwater should help lowering noise and vibration. In this case the fourier transform shows that the noise didn’t go away but the spectrum spread a bit among other frequencies. This can be heard as a noise (Case 1) versus a more audible tone in Case 2.
The sounds don’t sound the same as you’d hear in real life. They sound sterile and plastic and that’s because there’s just the fluid without any additional material such as housings, pipings and walls.
Also the actual volume of the sound can’t be compared this way: you have to take a look at RMS pressure levels to get an indication of which sample would be louder in reality:
rms = np.sqrt(np.mean(p**2))
Anyway, both cases are awful and will not be bearable in real life.
Back to drawing boards and books and no more old recipes, please.