OneSimulation docs Website Free books Plans on Gumroad

Docs › Build a first case in each physics package › Acoustics

5.2 Acoustics

onesim.physics.acoustics

Choose LinearAcoustics for linear pressure and axial particle velocity on a line. Supply density in kg/m\(^3\), sound speed in m/s, damping if needed and the initial pressure and velocity. A traveling sinusoid uses \(u=p/(\rho c)\) for the positive propagation direction. A reflecting wall, a periodic pair and a prescribed flux represent different physical experiments. Verified routes include FD with a polynomial derivative, FV with a Rusanov flux and MUSCL reconstruction, and DG with a Rusanov face flux. Start with test_acoustic_method_flexibility.py for the line case and plot pressure versus arclength at successive times.

Choose PressureDrivenMode for a single mechanical mode with force equal to effective area times applied pressure. RadiatingMode adds a constant radiation resistance. UltrasonicAcoustics uses the linear damped wave model. The structural-acoustics, vibroacoustics and ultrasound facades have their own provider contracts.

# Use run_lumped and scalar_series from the cooling chapter.
from onesim.physics.acoustics import PressureDrivenMode

domain = LumpedDomain()
mode = PressureDrivenMode(
    domain=domain.system, mass=2.0, stiffness=3.0, area=0.5,
    damping=0.4, pressure_loading=4.0,
)
_, samples, time = run_lumped(
    domain, mode, ((mode.displacement, 0.0), (mode.velocity, 0.0)),
    (mode.displacement, mode.velocity), end=1.0, dt=0.01, interval=0.05,
)
displacement = scalar_series(samples, mode.displacement)
assert displacement[-1] > 0