*This is a purely mathematical post covering some of the theoretical basis behind the matrices used in finite element analysis for acoustics in fluids. In coming posts, I'll cover some of the more practical uses for the method.*

A lot of the content presented here is based on the book "Computational Acoustics of Noise Propagation in Fluids - Finite and Boundary Element Methods". I'll do the examination in 2D, to make things as simple as possible.

## The Helmholtz equation

The linearized Euler equation is the most basic theoretical basis I will consider, even though even this equation can be derived using continuum mechanics. The linearized Euler equation is as following:

where is the Laplacian and refers to the local perturbation of the pressure (i.e. small disturbance around the equilibrium that causes sound). is a position vector. The pressure is dependent on both position and time. If the problem is assumed to be time harmonic, i.e. the time variation is sinusoidal, can be replaced by . Placing this into the Euler equation gives the Helmholtz-equation:

where , the wave number, equals . Note that the speed of sound can in some cases vary inside the medium. In these cases, where diffraction is to be considered, an additional factor (*the index of refraction*) should be used to multiply the term on the right.

## The boundary conditions

The boundary conditions can be divided into the following types of conditions:

- Dirichlet boundary conditions, often called a
*soft boundary*, which in acoustics means that the pressure at the boundary is specified - Neumann boundary conditions, often called a
*hard boundary*, which in acoustics means that the mean particle velocity normal to the boundary is specified - Robin boundary conditions, which allows for specification of the boundary
*admittance*.

The Robin boundary condition allows for the specification of both hard and soft boundaries, and it can be defined on the boundary of the problem as following:

where represents the boundary admittance. denotes the normal velocity of the boundary and denotes the normal fluid velocity of the acoustic domain. What exactly does this state? It states that the difference between the speed of the fluid and the speed of the structure equals the impedance times the pressure at the boundary. can be calculated from the normal derivative of the sound pressure as following:

## The weak formulation

The weak formulation is calculated in precisely the same way as was the case with the Euler-Bernoulli beam equation, in a previous blog post. In this case, the weak formulation is calculated from the following equation (the -parts are omitted for clarity), where represents the *weighting function*:

After integrating by parts (the first term, the one with the Laplace operator):

The first term can now be rewritten:

After inserting the earlier equation for :

Finally, let's insert the Robin boundary condition defined earlier (replacing with ):

Substituting , we get:

## The shape functions

I'll choose Lagrange quadratic shape functions for this endeavor. Using local coordinates, they look as following:

As these functions are one-dimensional, we need to multiply them by each other in order to get two-dimensional shape functions. To get a 2D shape function with the value 1 at some specific node , we need to do the following multiplication:

with and denoting local coordinates inside the element. A resulting two-dimensional shape function for the node at coordinates (0,0), for example, looks as following:

We do the same multiplication for all the nodes 1 ... 9. Thus we have 9 shape functions describing the evenly spaced values in a 2D square. The node numbering doesn't really matter, as long as it's something that is agreed upon.

Note that we can now get the continuous values of the pressure inside the 2D square using the shape functions as following:

## Integrating the shape functions

Later on, it will become apparent that we need to integrate the 2D quadratic shape functions. There will be two cases of integration:

- Multiples of shape functions across the fluid domain
- Multiples of shape functions on the boundary of the problem

The derivatives and integrals are, as always, performed in global coordinates. As the shape functions are defined in local coordinates, we need a way of transforming a derivation/integration performed in one coordinate system to the other. It turns out that this can be done using the *jacobian matrix*. It's basically the same thing as the chain rule, but in matrix form. The jacobian matrix in our case is defined as following:

To convert the derivative the other way around, we invert the jacobian matrix, like this:

For integration, the following holds true:

In this case, I won't write up all the possible integrals. Suffice to say, all the necessary integrals and derivatives can be calculated using these equations.

## Discretization

The continuous problem can now be discretized using the shape functions. I'll use the following notation for the different discretizations, adopted from the book I mentioned in the beginning of the post:

Inserting the shape functions into the weak formulation (again, omitting the -parts), we now get:

The weighting functions are once again arbitrary. We'll use the Galerkin discretization, which here means that the weighting functions are also replaced with 2D Lagrange quadratic shape functions, . Thus we get N equations (I tried to explain this more thoroughly in this post, which covers a more simple case of finite element analysis). The equations A = 1 ... N can be written as following:

Okay, it's starting to get confusing. But now we can finally start to simplify things. Let's write the equation in the following matrix form:

with the following matrices. For the purposes of this post, the impedance will be assumed to be constant on the boundary, which makes the damping matrix simpler to calculate. We'll also assume that Lagrange quadratic shape functions are used consistently.

## Conclusion

This post by no means went through everything one should know to be able to do finite element analysis of acoustics in 2D. Still, it covered the theoretical basis behind what I will cover in the following posts.

john hudsonHi Kai

I found your interesting blog while searching for 2D acoustic finite elements. I am starting to model domestic room acoustics.

Just a thought on 2D interpolation. The Lagrange interpolation functions on a rectangular grid you mention, eg. N1 are not particularly "flat". For example, if I set up a 2D grid N1(x)*N1(y) at all the integer axis point and set all their amplitudes to unity then the values between the integer axis points are not unity. At worst at a point such as (x=0.5, y=0.5) has value 4*N1(0.5) ^2 = 9/4 or 7.2 dB too high and very different from unity. So if I solve the FEM for the pressure values at the integer 2D axis points, I don't expect an accurate interpolation result in between the integer points. Have you any comments on this.

regards

John hudson

KaiPost authorHi! Thanks for your comment, let me know if I misunderstood something. I'll go through some initial stuff first, so we can be sure we're talking about the same thing.

When you calculate the interpolated values, you need to sum up

allthe shape functions at the given point. N1*N1 is the shape function for just a single node, there will be 9 shape functions (N1*N2, N1*N3, N2*N2, etc) which each form a seperate 2-dimensional shape function, with value 1 at one of the nodes and 0 at the others. One such shape function is shown in the image "two-dimensional lagrange shape function" in the post.You'll get the value like this: , where N_i is all of the possible 2D shape functions. So, assuming the value is 1 for all the nodes (you'll want a single value everywhere), you'll sum up all the 2D shape functions times 1.

With the quadratic Lagrange functions mentioned in the post, you'll get the single value 1 when summing up all the shape functions. and will cancel each other out. Which means that the interpolation will work perfectly, you'll get the value 1 everywhere!

PS, you can try it yourself (this mess is the sum of the shape functions times 1):

will simplify to the value one.

john hudsonthanks for your rapid reply !. My mistake was to truncate the Lagrange function for x,y1. If they are allowed to have infinite extent then the problem disappears as you say. I was starting from the triangle (1st order) interpolation 1-|x|, -1<x<1, which works in 1D, but has an interpolation problem in 2D. An alternative was using 1st order hexagonal shape functions in 2D but these don't fit well into orthogonal coordinates x,y for the wave equation.