Skip to content

[FEATURE] add pytta.rays, stochastic ray tracing in convex rooms - #124

Open
aguirreSL wants to merge 1 commit into
PyTTaMaster:developmentfrom
aguirreSL:dev-rays
Open

aguirreSL wants to merge 1 commit into
PyTTaMaster:developmentfrom
aguirreSL:dev-rays

Conversation

@aguirreSL

Copy link
Copy Markdown

Adds pytta.rays, stochastic ray tracing in convex rooms (Krokstad, Strøm and Sørsdal, "Calculating the acoustical room response by the use of a ray tracing technique", J. Sound Vib. 8(1), 1968; Vorländer, Auralization, 2008), as in the ray tracing part of RAVEN, which the ITA-Toolbox drives through its simulation application:

  1. shoebox(Lx, Ly, Lz, alpha, scattering=0) and convex_room(vertices, alpha, scattering=0): a room as planes, each with its absorption and scattering coefficients; the second takes the planes from the convex hull of the corners.
  2. trace(room, source, receiver, numRays, duration, radius, dt, c, m, seed): rays leave the source in random directions with equal energy. At each wall they lose the absorbed share and are reflected specularly or, with the probability of the scattering coefficient, in a direction drawn from Lambert's law. Air absorbs them with the power attenuation m. A sphere around the receiver counts each crossing with the energy of the ray times the chord over the volume of the sphere, so the histogram is the energy per unit area in each time bin.

The rays are traced together with NumPy, and 20000 rays over 1.2 s in a room of 120 m³ take under a second. Rooms that are not convex need a test of the polygon each ray hits, which is left for a later change. Rectangular rooms by image sources are in #101.

The tests in tests/test_rays.py compare with results of statistical room acoustics and print the measured values:

  1. The direct sound carries E0 / (4πr²) per unit area (1.055 of it with 200000 rays, within the statistical spread of about 4 %).
  2. In a room without absorption and with diffuse walls the late histogram is the energy density E0 / V times c dt (1.010 of it).
  3. With α = 0.2 on every wall of a 6 × 5 × 4 m room and diffuse reflections, T30 = 0.611 s lies between Eyring (0.585 s) and Sabine (0.653 s), as Kuttruff's correction for the spread of the free path lengths predicts.
  4. The convex hull of the corners of the box gives its six planes.

Checked with Python 3.12, numpy 1.26 and scipy 1.17. The 7 failures of development (3 in test_h5io.py, 4 in test_pyttasave.py) are the same with and without this change.

Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant