Skip to main content

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 but python cannot import matplotlib, install with the same interpreter: python -m pip install -e ".[viz]".
  • Do not include HardEnd/SoftEnd segments in NetworkTopology for this solver path. Enforce end conditions through solver targets instead.

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

  1. Swift, G.W. (2017). Thermoacoustics: A Unifying Perspective for Some Engines and Refrigerators, 2nd ed. Springer.
  2. Swift, G.W. (1988). "Thermoacoustic engines." J. Acoust. Soc. Am. 84(4), 1145–1180.
  3. 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 published event publishes to PyPI

One-time setup (Trusted Publisher)

  1. In PyPI and TestPyPI, create a Trusted Publisher for this GitHub repo.
  2. Map environments:
    • pypi environment -> PyPI trusted publisher
    • testpypi environment -> TestPyPI trusted publisher
  3. In GitHub repo settings, create environments pypi and testpypi (optionally require approvals).

Release flow

  1. Bump version in pyproject.toml.
  2. Merge to main.
  3. Run workflow manually to TestPyPI and verify install.
  4. 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, or troubleshooting) when applicable.
  • If validation behavior changed, update docs/validation/index.md and docs/validation/example-matrix.md.
  • See the full checklist in docs/contributing-docs.md.

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openthermoacoustics-0.1.1.tar.gz (208.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openthermoacoustics-0.1.1-py3-none-any.whl (214.8 kB view details)

Uploaded Python 3

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

Hashes for openthermoacoustics-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5da06edb72db36b613551b256ea7c404a256802bf6e11da33db3d7b6591339d3
MD5 2e3688a685d69d6ef23b8dc75acc46e4
BLAKE2b-256 987b4f5f12f409337f6c9fc34b34e590d188c2b143849ee07dd65b75b6ffc36f

See more details on using hashes here.

Provenance

The following attestation bundles were made for openthermoacoustics-0.1.1.tar.gz:

Publisher: publish.yml on kldavis4/open-thermoacoustics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file openthermoacoustics-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for openthermoacoustics-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1e5e58f0e3d0ad734ca1d710c437e2c9c7c1ee44bfe6dcbeb90ed135870e2ad0
MD5 34811942a38c71d41ef01c6c3d312814
BLAKE2b-256 090ddbb0219001084705f55aff03305a5332d7e348cddf2b08929c8af86e5212

See more details on using hashes here.

Provenance

The following attestation bundles were made for openthermoacoustics-0.1.1-py3-none-any.whl:

Publisher: publish.yml on kldavis4/open-thermoacoustics

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page