• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

In-Room Speaker Frequency Response Simulation (Low Frequency)

abdo123

Master Contributor
Forum Donor
Joined
Nov 15, 2020
Messages
7,446
Likes
7,955
Location
Brussels, Belgium
@NTK

This is brilliant, I'm going to take time to generate meaningful data but your simulation seems to be quiet solid! If you will be online in the next hour or two i will post measurements vs simulation stuff later.

is the sub z-axis determined by the bottom of the baffle or by the center of the woofer?
 
  • Like
Reactions: NTK
OP
NTK

NTK

Major Contributor
Forum Donor
Joined
Aug 11, 2019
Messages
2,712
Likes
5,991
Location
US East
The coordinates are for the center of the speaker or the subwoofer.

I'll upload my new notebooks later today (my time). I've made changes to make running frequency sweeps easier.
 

abdo123

Master Contributor
Forum Donor
Joined
Nov 15, 2020
Messages
7,446
Likes
7,955
Location
Brussels, Belgium
So the majority of walls in my apartment are infinitely rigid, so it should be an 'okay' enviroment to test the simulation.

I wanted to investigate a ~94Hz null in my response. and fairly enough it showed up enough in my graph. Just not exactly where the listening position is.

1626040806907.png


1626040842375.png


1626040873292.png
 
  • Like
Reactions: NTK
OP
NTK

NTK

Major Contributor
Forum Donor
Joined
Aug 11, 2019
Messages
2,712
Likes
5,991
Location
US East
Thanks for giving it a try and your feedback. Very much appreciate it :)

Here is my animated plot of a frequency sweep from 80 to 110 Hz at 0.5 Hz steps.

FR2.GIF
 

abdo123

Master Contributor
Forum Donor
Joined
Nov 15, 2020
Messages
7,446
Likes
7,955
Location
Brussels, Belgium
Here is my animated plot of a frequency sweep from 80 to 110 Hz at 0.5 Hz steps.

View attachment 140536

Oh wow you can see the 'dipping' migrating between 80Hz and 100Hz.

It's very impressive how this thing can accommodate for 3 variables all at once, because that dip is really a product of the sub-woofers' alignment and is not really visible in the individual responses.

1626043528937.png
 
OP
NTK

NTK

Major Contributor
Forum Donor
Joined
Aug 11, 2019
Messages
2,712
Likes
5,991
Location
US East
Playing with simulations can be fun. How much they reflect reality is a whole other matter. The plots, especially the animated ones, can look pretty cool though :)
 

abdo123

Master Contributor
Forum Donor
Joined
Nov 15, 2020
Messages
7,446
Likes
7,955
Location
Brussels, Belgium
Playing with simulations can be fun. How much they reflect reality is a whole other matter. The plots, especially the animated ones, can look pretty cool though :)

This is already ~80% of the way there, i think if things like wall gaps (doors or arches) or options for different wall rigidities would push this to hyper realism really quickly :p.

Honestly i just placed the subwoofers where it says it should be placed in Toole’s book with regard to my lineup and it worked great from the first try.

but now with this simulation i can explore different options in situ.
 
  • Like
Reactions: NTK
OP
NTK

NTK

Major Contributor
Forum Donor
Joined
Aug 11, 2019
Messages
2,712
Likes
5,991
Location
US East
The ZIP attachment in Post #1 are updated with new versions of the Mathematica and Jupyter notebooks.

Modifications to the code were made to make it easier to run frequency sweeps. Plots are automatically saved to a GIF file or animated GIF file if more than 1 frequency is ran.
 

abdo123

Master Contributor
Forum Donor
Joined
Nov 15, 2020
Messages
7,446
Likes
7,955
Location
Brussels, Belgium
@NTK do you think you can add into the code to make it possible to compare two different subwoofers locations?

by plotting 'A' vs 'B' for each frequency in the animation.

because right now the plot is not really useful in that regard.
 
OP
NTK

NTK

Major Contributor
Forum Donor
Joined
Aug 11, 2019
Messages
2,712
Likes
5,991
Location
US East
Will side-by-side plots of two different sub configurations work?
 

Stu Pidasso

Member
Forum Donor
Joined
Jun 12, 2021
Messages
46
Likes
74
Location
Prosser, WA
You guys might be interested in checking out the applets on Paul Falstad's site. At first glance they may seem rudimentary, but dig a bit deeper and you can quickly add walls, dampening, multiple source locations, 3-D animations, etc. Here, I've taken a couple screenshots for you.

Falstad Room Resonance Screenshot.png Falstad Room Resonance 3D Screenshot.png
 

edechamps

Addicted to Fun and Learning
Forum Donor
Joined
Nov 21, 2018
Messages
910
Likes
3,621
Location
London, United Kingdom
So, as promised in this other thread, I took a closer look at your code, @NTK. This gave me the opportunity to learn Wolfram Language which I must admit is pretty damn impressive - it's quite incredible how much stuff one can do with so little code, and the syntax and mechanics are so elegant it almost brings tears to my eyes!

I made a number of changes to your code @NTK, mostly related to performance optimization, presentation of results and refactoring, but also to better model the geometry of my room and to focus on a single listening position.

In the end I was able to produce frequency response graphs for various speaker positions in my room (this is done by solving the PDE at many different frequencies and then taking its value at the listening position). My next step was then to compare these simulated frequency responses with the real, measured, in-room frequency responses to validate the approach. This is of course a requisite step before I can use the simulator to predict the effect of various acoustic modifications - if the simulation results don't match the "ground truth", then obviously the whole approach is doomed as the results cannot be trusted.

Unfortunately, right now I'm clearly not there. The output from the simulation does not match the real-world measurements at all - even as far as the basic shape of the frequency response is concerned. The simulator is also completely unable to predict the phase issue that prompted the original investigation. There is something wrong and I need to figure out what it is and fix it before I can make progress.

To me there are two possible causes: either (1) the physical model is not good enough (e.g. the simplistic absorption characteristics of the walls do not match reality) or (2) there is something wrong with the simulation logic (e.g. something wrong with the PDE, the source function, etc.).

I'm currently trying to rule out (2). One idea I'm pursuing is to compare the output of the simulation with the output of REW's own room simulator (tagging @JohnPM). REW's simulator only supports rectangular rooms and appears to use a very different method ("a frequency domain method based on the rigid boundary solution to the wave equation, modified for lossy boundaries. Results are equivalent to those obtained by the image source method in the time domain (Allen and Berkley 1978)", according to REW docs).

Since I'm comparing the simulator against another simulator using an identical setup, the idea is that the results of both simulators should be identical, aside perhaps from numerical precision issues. If they differ, there is clearly something wrong with the simulation logic.

Here's how things look like in REW:

Screenshot 2022-12-10 162254.png


The simulator is configured with an identical room, sound source and listening position (the absorption coefficient is also the same - 0.1):

room.png


I generated solutions at various "interesting" frequencies that match the peaks and dips shown in REW, and a few frequencies in between:

density.png


Unfortunately, the resulting frequency response at the listening position does not agree with the REW room simulator at all:

fr.png


I'm going to keep looking into this and try to figure out what's going on. Not sure how far I can go given my limited understanding of the highly advanced math/physics. Maybe @NTK's original code is correct and I introduced a bug while refactoring it. Could be as silly as a typo in the code that went unnoticed, or maybe there's something more subtle going on. The Jupyter notebook that generated the above is attached in case anyone else wants to take a look. (Apologies the code is a bit more complicated than it could be as it's derived from my ongoing work simulating my real-world room.)
 

Attachments

  • vsrew1.zip
    910.9 KB · Views: 41

abdo123

Master Contributor
Forum Donor
Joined
Nov 15, 2020
Messages
7,446
Likes
7,955
Location
Brussels, Belgium
So, as promised in this other thread, I took a closer look at your code, @NTK. This gave me the opportunity to learn Wolfram Language which I must admit is pretty damn impressive - it's quite incredible how much stuff one can do with so little code, and the syntax and mechanics are so elegant it almost brings tears to my eyes!

I made a number of changes to your code @NTK, mostly related to performance optimization, presentation of results and refactoring, but also to better model the geometry of my room and to focus on a single listening position.

In the end I was able to produce frequency response graphs for various speaker positions in my room (this is done by solving the PDE at many different frequencies and then taking its value at the listening position). My next step was then to compare these simulated frequency responses with the real, measured, in-room frequency responses to validate the approach. This is of course a requisite step before I can use the simulator to predict the effect of various acoustic modifications - if the simulation results don't match the "ground truth", then obviously the whole approach is doomed as the results cannot be trusted.

Unfortunately, right now I'm clearly not there. The output from the simulation does not match the real-world measurements at all - even as far as the basic shape of the frequency response is concerned. The simulator is also completely unable to predict the phase issue that prompted the original investigation. There is something wrong and I need to figure out what it is and fix it before I can make progress.

To me there are two possible causes: either (1) the physical model is not good enough (e.g. the simplistic absorption characteristics of the walls do not match reality) or (2) there is something wrong with the simulation logic (e.g. something wrong with the PDE, the source function, etc.).

I'm currently trying to rule out (2). One idea I'm pursuing is to compare the output of the simulation with the output of REW's own room simulator (tagging @JohnPM). REW's simulator only supports rectangular rooms and appears to use a very different method ("a frequency domain method based on the rigid boundary solution to the wave equation, modified for lossy boundaries. Results are equivalent to those obtained by the image source method in the time domain (Allen and Berkley 1978)", according to REW docs).

Since I'm comparing the simulator against another simulator using an identical setup, the idea is that the results of both simulators should be identical, aside perhaps from numerical precision issues. If they differ, there is clearly something wrong with the simulation logic.

Here's how things look like in REW:

View attachment 249051

The simulator is configured with an identical room, sound source and listening position (the absorption coefficient is also the same - 0.1):

View attachment 249056

I generated solutions at various "interesting" frequencies that match the peaks and dips shown in REW, and a few frequencies in between:

View attachment 249057

Unfortunately, the resulting frequency response at the listening position does not agree with the REW room simulator at all:

View attachment 249058

I'm going to keep looking into this and try to figure out what's going on. Not sure how far I can go given my limited understanding of the highly advanced math/physics. Maybe @NTK's original code is correct and I introduced a bug while refactoring it. Could be as silly as a typo in the code that went unnoticed, or maybe there's something more subtle going on. The Jupyter notebook that generated the above is attached in case anyone else wants to take a look. (Apologies the code is a bit more complicated than it could be as it's derived from my ongoing work simulating my real-world room.)

You're the one making my eyes tear right now. remarkable work!
 

JohnPM

Senior Member
Technical Expert
Joined
Apr 9, 2018
Messages
344
Likes
919
Location
UK
Both are solving the wave equation subject to the constraints imposed by the room's geometry and surface absorptions, so the answers should be the same for the response at the measurement position. REW uses the explicit solution for a rectangular room, but finite element should not produce a different answer if the assumptions about the surfaces are the same. Both approaches are covered in depth in Kuttruff's "Room acoustics".
 
OP
NTK

NTK

Major Contributor
Forum Donor
Joined
Aug 11, 2019
Messages
2,712
Likes
5,991
Location
US East
Both are solving the wave equation subject to the constraints imposed by the room's geometry and surface absorptions, so the answers should be the same for the response at the measurement position. REW uses the explicit solution for a rectangular room, but finite element should not produce a different answer if the assumptions about the surfaces are the same. Both approaches are covered in depth in Kuttruff's "Room acoustics".
John,

Thank you very much for chiming in. I want to check out @edechamps' script. I blew away my Wolfram engine installation a while ago, and am reinstalling it.

@edechamps
Thanks for trying out my room simulation scripts. I will try to cross check the rectangular room simulation using the image source model method, with help from pyroomacoustics. It may take a few days before I'll get results.
 

edechamps

Addicted to Fun and Learning
Forum Donor
Joined
Nov 21, 2018
Messages
910
Likes
3,621
Location
London, United Kingdom
Both are solving the wave equation subject to the constraints imposed by the room's geometry and surface absorptions, so the answers should be the same for the response at the measurement position. REW uses the explicit solution for a rectangular room, but finite element should not produce a different answer if the assumptions about the surfaces are the same.

Thanks John, that's what I would expect as well. I'll dig into the code further, hopefully it's something silly like a typo or wrong unit or something. Or maybe the definition of the absorption coefficient is not quite right, I don't know. I need to investigate some more.

Another potential explanation I can think of is that it has something to do with the definition of the sound source, which in theory is supposed to be a Dirac function in space, but from what I understand that doesn't really work with FEM. I saw in @NTK's code that he "regularized" it using a rapidly decaying exponential. I wonder if that could potentially cause problems, especially given that the function @NTK used is not the one Wolfram recommends.

Both approaches are covered in depth in Kuttruff's "Room acoustics".

Thanks for the recommendation. That book looks interesting, I just ordered it.
 
Last edited:
  • Like
Reactions: 800

edechamps

Addicted to Fun and Learning
Forum Donor
Joined
Nov 21, 2018
Messages
910
Likes
3,621
Location
London, United Kingdom
@NTK I think I found the issue (or at least a large chunk of it). In your code you define the boundary condition as:

origneumann.png


Where alpha is the absorption coefficient.

Equivalently, the above defines an impedance boundary condition where the specific acoustic impedance is given by c/alpha.

I don't think that's right. Various papers (for example this one or this one) define the specific acoustic impedance in relation to the absorption coefficient as follows (after some derivation through R):

impedance.png


If I plug this in (which results in a much larger acoustic impedance - i.e. way less absorption), I get these results instead:

vsrew2d.png


vsrew2f.png


The density plots look much more like one would expect (look at the obvious modal distribution at 58.60, 68.50, 103 and 131.50 Hz for example), and the frequency response is a much better match to the one generated by REW.

The notebook that produced the above is attached. (I also took the opportunity to replace your PDE with the newfangled AcousticPDEComponent and AcousticImpedanceValue Wolfram functions to make the code more readable and to double-check that the results are the same.)
 

Attachments

  • vsrew2.zip
    884.5 KB · Views: 29
Last edited:

edechamps

Addicted to Fun and Learning
Forum Donor
Joined
Nov 21, 2018
Messages
910
Likes
3,621
Location
London, United Kingdom
By the way @JohnPM, I have a feature request for the REW room simulator: it would be nice to have a way to export the predicted frequency response, e.g. add it as a measurement. Right now I need to eyeball the graphs to compare them because I couldn't find a way to get the raw data out of the REW simulator.
 
Top Bottom