As part of my profession as an acoustician, I often make use of Open Source software. It might surprising to few that the Open Source ecosystem is actually filled with very good packages for this task. As a result, I decided to try to publish a little series of tutorials about the topic, and this would be its first post.

So let’s first have a look ad the most important numerical simulation programs and technical computing languages that can be used to simulate acoustics. There are many programs out of there, but I mainly made use of ElmerFEM. ElmerFEM will be the focus of the series then, and we will look at how to set up Ubuntu 18.04 to be our workstation!

The Ecosystem

There is plenty of Open Source packages that are either designed to simulate acoustics, can simulate acoustic if one wants to, or can be used to simulate certain parts of multi-physics systems, or can be used for pre and post processing. Here few examples.

Technical Computing Languages

There are many technical computing languages, or languages that can be useful for technical/scientific computing. The most commonly used are:

  • GNU Octave. This is very useful also for having compatible syntax to that of Matlab, but it is not really my favorite, as it is a bit slow.
  • Python (in conjunction with many packages such as Numpy, SciPy...). Python is very nice to code with, and there are tons of scientific packages for it. Moreover, certain numerical software programs and frameworks allow Python scripting (ParaView, as an example, see below) or have Python interfaces. So, it is a language that it is worth having a grasp of.
  • Julia. OK, I am not sure it "among the most used", but it is a new exciting language that feels like what would happen if Octave and Python had a baby. I really like it, and we will probably make a lot of use of it. The main reason being that this is a good excuse for me to study Julia.

This list is not exhaustive: there are many more examples, such as R and Scilab, and there actually are many more open source scientific frameworks such as ROOT. However, I decided to mainly stick with what I am most familiar with.

Also, I should mention Maxima, which I like to use with the front-end wxMaxima. It is a very useful computer algebra system which I often used for symbolic computation.

Physical Modelling DSP

The Faust programming language is a very powerful language to program real-time DSP algorithms. In its library there are numerous functions for physical modelling of music instruments, Moreover, it has an entire Physical Modelling Toolkit. Although I am not a Faust expert, and I sporadically use it, it would be nice to try to use it to turn a simulation result into a plugin!

Numerical Simulation and Analysis Packages

These packages are suites for numerical modelling, using various methods.

  • ElmerFEM is a multiphysical FEM solver which is maybe a bit hard to use, but really powerful. We will be using this a lot. It has very good solvers for various acoustics problems, and we can study vibroacoustics coupling too, and much more.
  • AcouSTO is an interesting BEM solver for acoustics that I regrettably still have to try.
  • OpenPSTD is an acoustics simulation program that uses the Pseudo Spectral Time Domain Method. It integrates with Blender.
  • I-Simpa is open source software designed to simulate 3D acoustic propagation. Another one to add in my must try list.
  • FEMM is a finite element modelling program for magnetics. This can be very useful to model and design speaker magnets, but I never used it myself.
  • Mesh2HRTF seems to a very interesting package for the numerical simulation of Head Related Transfer Functions (HRTF). Unfortunately, it has Matlab as a dependency. Still, this is pretty high in my must try list.
  • Qucs is a nice, quite easy to use, circuit simulator. It can be used to simulate, of course, electronic circuits to use for audio applications, but it can also be used to build lumped acoustic models through electrical analogies (see here, for example).
  • The DREAM Toolbox and Field II are two interesting open source Matlab/Octave toolboxes for the simulation of ultrasonic transducers arrays, with focus on medical imaging applications (especially Field II).

There are actually few more solvers, such as Calculix, Code_Aster, OpenFOAM, GetFEM++, Freefem++ and ONELAB but again I decided to stick with either those I tried, or those that are most relevant to acoustics.

There are cool things too more in the domain pf pyschoacoustcs and analysis:

  • The Auditory Modelling Toolbox is a cool open source Matlab/Octave toolbox for auditory modelling.
  • The The Large Time-Frequency Analysis Toolbox is a Matlab/Octave toolbox that provides many useful transforms for signal analysis that can be very useful to understand acoustic signals.
  • The Psychtoolbox is another Matlab/Octave toolbox that can be used for realtime analysis of auditory stimuli.
  • CMUSphinx is an open source toolbox for speech recognition.

3D Modelling and CAD

In order to solve a problem, one must first create its geometry. There are really many programs out of there which can be used for this, but those I actually know best are:

  • FreeCAD, this is very good to prepare geometries for FEM solving. FreeCAD can also provide an interface to solvers.
  • Blender, this is more for graphics, but certain solvers (such as AcouSTO) actually have plugins for Blender. Blender is another good example of software that allows internal Python scripting.

Pre and Post Processing

In order to use any solver, our geometry needs to be prepossessed. Moreover, our results from the numerical solvers might need further postprocessing. This is why we need these packages:

  • gmsh is a great, and very lightweight, tool which does the job nicely.
  • Salome Platform is for now my favorite tool when it comes to pre-processing. To be noticed that Code_Aster distributes Salome-Meca, a modelling suite based on Salome Platform incorporating the Code_Aster solver.
  • ParaView is instead my favorite post-processor.

Getting Started on Ubuntu 18.04

Now that we seen what the ecosystem has to offer, let’s try to build a simple simulation workstation based around ElmerFEM, with which I am most familiar. So, let’s install the various packages on Ubuntu and let’s prepare our environment. We will use the command line to install the packages.

But first, why Ubuntu? Well, it turns out that, even though Ubuntu is missing few of the packages we want to use in its repo, all packages are pretty easy to install, especially ElmerFEM and Salome, which can be quite complicated in other distros.

FreeCAD

It is best to install from the FreeCAD stable releases PPA:

sudo add-apt-repository ppa:freecad-maintainers/freecad-stable
sudo apt-get update
sudo apt-get install freecad

This should pull in the latest stable FreeCAD version. There is a not very outdated version in the official Ubuntu repos, but it does not seem to work on Ubuntu 18.04 at the time of writing.

Salome

To install Salome we should head to the download page. At the moment of writing there isn’t a version for Ubuntu 18.04, but I tried the universal version and it seems to work fine after a cursory test. So, let’s just download the universal binaries for Linux, and then let’s open a terminal in the download folder. These commands should take care of the installation:

chmod +x Salome-V8_5_0-univ_public.run
./Salome-V8_5_0-univ_public.run

You might need to adapt the commands to match the filename of your download. The installer will ask a few questions. Answering the default by pressing enter worked just fine in my case.

ElmerFEM

ElmerFEM can be very conveniently installed from the Ubuntu PPA with these commands:

sudo apt-get install libqt5xml5
sudo apt-add-repository ppa:elmer-csc-ubuntu/elmer-csc-ppa
sudo apt-get update
sudo apt-get install elmerfem-csc-eg
sudo cp -rs /usr/share/ElmerGUI/edf-extra/* /usr/share/ElmerGUI/edf/

The last command is meant to create links to the various ElmerGUI elements that by default are not included in the GUI. It could be best to run it after each upgrade.

Julia

It is now time to install Julia. At the moment, there aren’t official packages for Ubuntu 18.04, so let’s follow the Julia installation tips for generic Linux operating systems. Let’s download the Linux binary from here. Then extract the archive. I would suggest to do it in a reasonable folder, where you will not risk to remove Julia by mistake. Then, let’s create a symbolic link to the Julia executable to a folder in the PATH variable. /usr/local/bin should be a good choice. In this example, I extracted the archive in my home folder, resulting in the folder julia-1.0.1:

sudo ln -fs ~/julia-1.0.1/bin/julia /usr/local/bin/julia

As above, you might need to adapt the command to reflect the extracted folder name for future versions. If you now issue the command “julia” to the terminal, you should be able to see the julia REPL. use exit() to quite Julia.

Other Distributions?

It is possible, of course, to set any distribution to be a numerical modelling workstation. There is also a ready to use Linux distribution for the purpose: CAELinux.

What's next?

I will try to publish some baby step tutorials regularly. We will maybe first try to model a rectangular room, and compare it with the known analytical solution, of which we will build a Julia version.

So, let’s just hope I can keep up with this commitment!