Skip to content

Add aeroacoustic pressure spectrum analysis - #2851

Open
tokito-99 wants to merge 10 commits into
su2code:developfrom
tokito-99:feature/aeroacoustics-postprocessing
Open

Add aeroacoustic pressure spectrum analysis#2851
tokito-99 wants to merge 10 commits into
su2code:developfrom
tokito-99:feature/aeroacoustics-postprocessing

Conversation

@tokito-99

@tokito-99 tokito-99 commented Jul 23, 2026

Copy link
Copy Markdown

Proposed Changes

Adds a command-line aeroacoustic post-processing tool for unsteady pressure histories generated by SU2. The tool reads standard history.csv output 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

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
  • My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
  • I used the pre-commit hook to prevent dirty commits and used pre-commit run --all to format old commits.
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.

@bigfooted

Copy link
Copy Markdown
Contributor

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.

@tokito-99

Copy link
Copy Markdown
Author

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 parallel_regression.py.

The corresponding regression data is provided in su2code/TestCases#201. The focused regression passes locally with zero difference from the stored values.

@pcarruscag

Copy link
Copy Markdown
Member

Do you have validation results? How do we know the regression numbers are correct?

@tokito-99

Copy link
Copy Markdown
Author

Do you have validation results? How do we know the regression numbers are correct?

Yes. The numerical implementation is validated in two ways.

First, test_welch_finds_sine_frequency_and_level uses a synthetic sinusoid with a known frequency of 256 Hz and an RMS pressure of 1 Pa. The expected OASPL is 93.979400086720 dB, and the implementation computes 93.979400086778 dB. It also recovers the frequency exactly at 256 Hz.

For an additional local check, I compared the square-cylinder result with scipy.signal.welch using the same window, segment length, overlap, and detrending. SciPy gives an OASPL of 103.151263476485 dB and a dominant frequency of 1.953125 Hz, compared with the stored values of 103.151263476500 dB and 1.953125 Hz.

@pcarruscag

Copy link
Copy Markdown
Member

Sounds good, thank you.

@tokito-99
tokito-99 changed the base branch from master to develop July 29, 2026 14:33
@tokito-99

Copy link
Copy Markdown
Author

I think the test cases has to be merged in order for the failing regression test to pass

@bigfooted

Copy link
Copy Markdown
Contributor

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?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py CLI/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.

Comment thread SU2_PY/aeroacoustics.py
Comment on lines +190 to +198
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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point on acoustic_metrics. I’ll add validation for matching 1D arrays, finite values, non-negative PSD values, and uniformly increasing frequency bins.

Comment on lines +35 to +40
su2_run = os.environ.get("SU2_RUN")
if su2_run:
sys.path.insert(0, su2_run)

from aeroacoustics import analyze # noqa: E402

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the regression driver import, I’ll also add an explicit error message, but I’ll replace the existing import rather than duplicate it.

@tokito-99

Copy link
Copy Markdown
Author

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?

I can work on a small tutorial. It will take me some time to do that though :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants