Open-source thermoacoustic engine and refrigerator design tool
Project description
OpenThermoacoustics
A Python implementation of thermoacoustic engine and refrigerator design tools, based on Rott's linear thermoacoustic theory as extended by Swift.
Overview
OpenThermoacoustics provides a solver for analyzing thermoacoustic devices by modeling them as 1D acoustic networks. It propagates complex oscillating pressure and volumetric velocity through connected segments (ducts, stacks, heat exchangers, etc.) using the linearized thermoacoustic equations.
This project aims to provide an open-source thermoacoustic design tool, implementing well-documented physics from published literature in a clean, modern, extensible Python codebase.
Full docs index: docs/index.md
Installation
pip install -e .
For development with testing tools:
pip install -e ".[dev]"
Quick Start
import openthermoacoustics as ota
# Create working gas: helium at 30 bar
gas = ota.gas.Helium(mean_pressure=3e6)
# Build a simple closed-closed resonator
network = ota.solver.NetworkTopology()
network.add_segment(ota.segments.Duct(length=1.0, radius=0.05))
# Solve for resonant frequency
solver = ota.solver.ShootingSolver(network, gas)
result = solver.solve(
guesses={'p1_amplitude': 1e4, 'frequency': 500},
targets={'U1_end_real': 0, 'U1_end_imag': 0},
options={'T_m_start': 300}
)
print(f"Resonant frequency: {result.frequency:.2f} Hz")
Visualization
Install with visualization extras:
pip install -e ".[viz]"
Plot global profiles with optional segment boundaries and save PNGs:
import openthermoacoustics as ota
gas = ota.gas.Helium(mean_pressure=3e6)
network = ota.solver.NetworkTopology()
network.add_segment(ota.segments.Duct(length=1.0, radius=0.05))
solver = ota.solver.ShootingSolver(network, gas)
result = solver.solve(
guesses={"frequency": 500.0, "U1_imag": 0.0},
targets={"U1_end_real": 0, "U1_end_imag": 0},
options={"T_m_start": 300.0},
)
ota.viz.plot_profiles(
result,
segment_results=network.results,
save_path="profiles.png",
)
ota.viz.plot_phasor_profiles(
result,
segment_results=network.results,
save_path="phasors.png",
)
# Generic sweep plotting utility
import numpy as np
freqs = np.linspace(200, 800, 25)
vals = (freqs - result.frequency) ** 2
ota.viz.plot_frequency_sweep(
freqs,
vals,
ylabel="Synthetic residual",
save_path="sweep.png",
)
Troubleshooting:
- If
pip install -e ".[viz]"succeeds butpythoncannot import matplotlib, install with the same interpreter:python -m pip install -e ".[viz]". - Do not include
HardEnd/SoftEndsegments inNetworkTopologyfor this solver path. Enforce end conditions through solvertargetsinstead.
Features
Gas Properties
Ideal gas models with temperature-dependent transport properties:
- Helium - monatomic, γ = 5/3
- Argon - monatomic, γ = 5/3
- Nitrogen - diatomic, γ = 1.4
- Air - diatomic, γ = 1.4 (Sutherland's law for viscosity)
Pore Geometries
Thermoviscous functions f_ν and f_κ for:
- CircularPore - Bessel function solution
- ParallelPlate - tanh solution
- WireScreen - mesh/screen approximation
Network Segments
- Duct - uniform circular tube
- Cone - linearly tapered tube
- Stack - porous medium with temperature gradient
- HeatExchanger - fixed temperature boundary
- Compliance - lumped acoustic volume
- Inertance - lumped acoustic mass
- HardEnd - closed boundary (U1 = 0)
- SoftEnd - open boundary (p1 = 0)
Solver
Shooting method using scipy.optimize.root to find operating conditions that satisfy boundary constraints.
Core Equations
The solver propagates the state vector [p₁, U₁] through each segment using:
Momentum equation:
dp₁/dx = -(jωρₘ / A(1 - fᵥ)) · U₁
Continuity equation:
dU₁/dx = -(jωA / ρₘa²) · [1 + (γ-1)fκ] · p₁ + (fκ - fᵥ)/((1-fᵥ)(1-σ)) · (dTₘ/dx / Tₘ) · U₁
References
- Swift, G.W. (2017). Thermoacoustics: A Unifying Perspective for Some Engines and Refrigerators, 2nd ed. Springer.
- Swift, G.W. (1988). "Thermoacoustic engines." J. Acoust. Soc. Am. 84(4), 1145–1180.
- Rott, N. (1969). "Damped and thermally driven acoustic oscillations in wide and narrow tubes." Z. Angew. Math. Phys. 20, 230–243.
Development
Run tests:
pytest tests/ -v
Publishing
This repository includes a GitHub Actions release workflow at
/Users/kelly/projects/personal/deltaec/.github/workflows/publish.yml.
- Manual run (
workflow_dispatch) publishes to TestPyPI - GitHub Release
publishedevent publishes to PyPI
One-time setup (Trusted Publisher)
- In PyPI and TestPyPI, create a Trusted Publisher for this GitHub repo.
- Map environments:
pypienvironment -> PyPI trusted publishertestpypienvironment -> TestPyPI trusted publisher
- In GitHub repo settings, create environments
pypiandtestpypi(optionally require approvals).
Release flow
- Bump version in
pyproject.toml. - Merge to
main. - Run workflow manually to TestPyPI and verify install.
- Create GitHub release (for example
v0.1.1) to publish to PyPI.
Documentation quality gate for changes:
- If a change affects public API or behavior, update matching docs in
docs/. - At minimum, update the relevant
docs/api/*page and one usage guide (getting-started,modeling-workflows, ortroubleshooting) when applicable. - If validation behavior changed, update
docs/validation/index.mdanddocs/validation/example-matrix.md. - See the full checklist in docs/contributing-docs.md.
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openthermoacoustics-0.1.1.tar.gz.
File metadata
- Download URL: openthermoacoustics-0.1.1.tar.gz
- Upload date:
- Size: 208.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5da06edb72db36b613551b256ea7c404a256802bf6e11da33db3d7b6591339d3
|
|
| MD5 |
2e3688a685d69d6ef23b8dc75acc46e4
|
|
| BLAKE2b-256 |
987b4f5f12f409337f6c9fc34b34e590d188c2b143849ee07dd65b75b6ffc36f
|
Provenance
The following attestation bundles were made for openthermoacoustics-0.1.1.tar.gz:
Publisher:
publish.yml on kldavis4/open-thermoacoustics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openthermoacoustics-0.1.1.tar.gz -
Subject digest:
5da06edb72db36b613551b256ea7c404a256802bf6e11da33db3d7b6591339d3 - Sigstore transparency entry: 1004632954
- Sigstore integration time:
-
Permalink:
kldavis4/open-thermoacoustics@68b89c4455c0776f7fa8588f2fedc9b69b0666dc -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/kldavis4
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@68b89c4455c0776f7fa8588f2fedc9b69b0666dc -
Trigger Event:
release
-
Statement type:
File details
Details for the file openthermoacoustics-0.1.1-py3-none-any.whl.
File metadata
- Download URL: openthermoacoustics-0.1.1-py3-none-any.whl
- Upload date:
- Size: 214.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e5e58f0e3d0ad734ca1d710c437e2c9c7c1ee44bfe6dcbeb90ed135870e2ad0
|
|
| MD5 |
34811942a38c71d41ef01c6c3d312814
|
|
| BLAKE2b-256 |
090ddbb0219001084705f55aff03305a5332d7e348cddf2b08929c8af86e5212
|
Provenance
The following attestation bundles were made for openthermoacoustics-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on kldavis4/open-thermoacoustics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openthermoacoustics-0.1.1-py3-none-any.whl -
Subject digest:
1e5e58f0e3d0ad734ca1d710c437e2c9c7c1ee44bfe6dcbeb90ed135870e2ad0 - Sigstore transparency entry: 1004632955
- Sigstore integration time:
-
Permalink:
kldavis4/open-thermoacoustics@68b89c4455c0776f7fa8588f2fedc9b69b0666dc -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/kldavis4
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@68b89c4455c0776f7fa8588f2fedc9b69b0666dc -
Trigger Event:
release
-
Statement type: