Troubleshooting acoustic propagation tutorial

I’ve been following this amazing tutorial that Antonio @bay_swiss published on Youtube, Open source computational acoustics with FEniCSx
I’m running FEniCSx in a docker container.
I’ve had to deviate from the tutorial just to get it to run, any of these deviations could be a reason my results do not match the results Antonio gets at the end of part one.

When running the mesher the program seems to freeze on the first surface.

Since I didn’t want to give up five minutes into the tutorial I manually assigned the velocity BC and impedance using the Gmsh GUI. Making sure to set the mesh elements to be second order.

From there I replaced
BoundingBoxTree with bb_tree
geometry.compute_collisions with geometry.compute_collisions_points

Finally I changed
plt.plot(f_axis, 20 * np.log10(np.abs(p_mic/2e-5)))
plt.plot(f_axis, 20 * np.log10(np.abs(p_mic)/2e-5))
Since the plot wouldn’t print giving me the traceback:
TypeError: unsupported operand type(s) for /: 'list' and 'float'

Finally if I’m using the nightly build I replace

Can someone spot the error of my ways?
Geometry files and code can be found here.

Ólafur Marteinsson

Hi @Olafur.

As mentioned in the description, I am still using DOLFINx 0.6.0 for compatibility reasons.

With the release of DOLFINx 0.7.0, many features have changed, all of which are listed here:,User%20facing%20changes,-Add%20functionalities%20to

You will need to port my code to 0.7 (or use an older docker image), and it should run smoothly.

Currently, I have an enormous amount of code written in 0.6.0 that I rely on for the analyses I need to run daily for my customers.

I plan to port all the code and functions one day (probably with version 0.8), but not today, unfortunately!



1 Like

Thank you for the swift reply :heart: @bay_swiss

I rolled back the changes to the code and pulled a build of 0.6.0 using:

docker pull dolfinx/dolfinx:v0.6.0

I run into the same problem when I try to run the mesher, it freezes at the first surface:

root@d6df6291e5c3:/home/fenicsx/shared# python3
Info    : Reading '/home/fenicsx/shared/duct.step'...
Info    :  - Label 'Shapes/Cube' (3D)
Info    :  - Color (0.8, 0.8, 0.8) (3D & Surfaces)
Info    : Done reading '/home/fenicsx/shared/duct.step'
Info    : Meshing 1D...
Info    : [  0%] Meshing curve 1 (Line)
Info    : [ 10%] Meshing curve 2 (Line)
Info    : [ 20%] Meshing curve 3 (Line)
Info    : [ 30%] Meshing curve 4 (Line)
Info    : [ 40%] Meshing curve 5 (Line)
Info    : [ 50%] Meshing curve 6 (Line)
Info    : [ 50%] Meshing curve 7 (Line)
Info    : [ 60%] Meshing curve 8 (Line)
Info    : [ 70%] Meshing curve 9 (Line)
Info    : [ 80%] Meshing curve 10 (Line)
Info    : [ 90%] Meshing curve 11 (Line)
Info    : [100%] Meshing curve 12 (Line)
Info    : Done meshing 1D (Wall 0.0781816s, CPU 0.058344s)
Info    : Meshing 2D...
Info    : [  0%] Meshing surface 1 (Plane, Frontal-Delaunay)

and the visualization is the same as when using stable or nightly with the modified code.

I suspect that there is something wrong with my mesh and how I manually created the groups.

Same problem persist with the plot, that is it refuses to divide a list by a float.

plt.plot(f_axis, 20 * np.log10(np.abs(p_mic/2e-5)))

My instinct is that by taking only the magnitude of p_mic solves the issue and allows the plot to print, but the fact that you were able to run it as is and how vastly different the visualization turns out tells me that there is some underlying problem that I am still not addressing.

Ólafur Marteinsson

From the following:

It seems that this duct is 250 meters high while you are choosing a meshsize of 0.03 meters.

The mesher is taking so long because the meshsize is very small compared to the full geometry.

Scale down the CAD, it should be fine

1 Like

Thank you so much Antonio.

I was able to recreate your results. :smiley:

Changing the export units from FreeCAD was not enough.
I ended up changing the units in the step file from meters to mm.:thinking: Suspicious if you ask me.
Short unlisted youtube video of how things behave.

Another question
What is the point of


The code seems to output the same mesh whether the line is commented out or not

Ólafur Marteinsson

It’s just the gmsh model name. If not called, a new unnamed model will be created on the fly, if necessary.

If you don’t need it, you can remove it.