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.)