Add aeroacoustic pressure spectrum analysis - #2851
Conversation
|
Hi, @tokito-99 Thanks for this addition. Do you have a regression test for this? So a well-converged result from a case that the python script uses to compute some result that we can check against a stored result in e.g. parallel_regression.py. |
Thanks for the suggestion. I added a regression test using the converged pressure history from the existing unsteady square-cylinder case. The test runs the complete aeroacoustics analysis pipeline and checks the computed OASPL and dominant frequency against values stored in The corresponding regression data is provided in su2code/TestCases#201. The focused regression passes locally with zero difference from the stored values. |
|
Do you have validation results? How do we know the regression numbers are correct? |
Yes. The numerical implementation is validated in two ways. First, For an additional local check, I compared the square-cylinder result with |
|
Sounds good, thank you. |
|
I think the test cases has to be merged in order for the failing regression test to pass |
|
I've merged the testcase, and restarted the checks. Can you also create a small tutorial on how to use it on the su2code.github.io website? |
There was a problem hiding this comment.
Pull request overview
Adds a new Python-based aeroacoustic post-processing capability to SU2 that computes pressure spectra and SPL metrics from history.csv probe signals, and wires it into both unit tests and regression testing (square cylinder case).
Changes:
- Introduces
SU2_PY/aeroacoustics.pyCLI/library implementing Welch PSD, SPL metrics, CSV output, and optional JSON summary. - Adds unit tests for the new aeroacoustics functionality (
SU2_PY/tests/test_aeroacoustics.py) and installs the script via Meson. - Adds a square-cylinder regression driver/config and registers it in
TestCases/parallel_regression.py.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| TestCases/unsteady/square_cylinder/run_aeroacoustics.py | Regression driver that calls the aeroacoustics analyzer and prints comparable scalar metrics. |
| TestCases/unsteady/square_cylinder/aeroacoustics.cfg | Minimal config file specifying history input and column names for the regression driver. |
| TestCases/parallel_regression.py | Registers a new parallel regression test for aeroacoustic post-processing. |
| SU2_PY/tests/test_aeroacoustics.py | Adds unit tests covering PSD estimation, history parsing, output writing, and end-to-end analysis. |
| SU2_PY/meson.build | Installs aeroacoustics.py into the SU2 Python install set. |
| SU2_PY/aeroacoustics.py | New implementation of Welch PSD + acoustic metrics and CLI argument parsing/output. |
| Docs/Aeroacoustics.md | New documentation describing usage, sampling guidance, and outputs. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| def acoustic_metrics(frequencies, psd, reference_pressure=20.0e-6): | ||
| """Calculate PSD level, bin SPL, OASPL, and the dominant frequency.""" | ||
| if reference_pressure <= 0.0 or not math.isfinite(reference_pressure): | ||
| raise ValueError("reference pressure must be positive and finite") | ||
| if frequencies.size < 2: | ||
| raise ValueError("an acoustic spectrum needs at least two frequency bins") | ||
|
|
||
| frequency_step = float(frequencies[1] - frequencies[0]) | ||
| tiny = np.finfo(float).tiny |
There was a problem hiding this comment.
Good point on acoustic_metrics. I’ll add validation for matching 1D arrays, finite values, non-negative PSD values, and uniformly increasing frequency bins.
| su2_run = os.environ.get("SU2_RUN") | ||
| if su2_run: | ||
| sys.path.insert(0, su2_run) | ||
|
|
||
| from aeroacoustics import analyze # noqa: E402 | ||
|
|
There was a problem hiding this comment.
For the regression driver import, I’ll also add an explicit error message, but I’ll replace the existing import rather than duplicate it.
I can work on a small tutorial. It will take me some time to do that though :) |
Proposed Changes
Adds a command-line aeroacoustic post-processing tool for unsteady pressure histories generated by SU2. The tool reads standard
history.csvoutput and computes pressure power spectral density using Welch's method, narrowband SPL, OASPL, and dominant frequency.Multiple pressure probes, transient sample removal, nondimensional pressure scaling, configurable windows, overlap, and detrending are supported. Results are written to CSV with an optional JSON summary.
This contribution only adds post-processing functionality and does not modify the flow solver or existing LES numerics.
Related Work
This is not associated with an existing issue or pull request. It complements the existing LES and hybrid RANS–LES capabilities by providing a workflow for analyzing unsteady pressure-probe output.
PR Checklist
pre-commit run --allto format old commits.