Skip to content

Commit 2a13c0e

Browse files
bayswissjorgensd
andauthored
Adding Acoustic Helmholtz equation to the tutorial (#232)
* Acoustic Helmholtz scripts helmholtz.md contains the mathematical derivation of the variational formulation, while the helmholtz_code scripts contain the implementation. * Fix * equations rendering bug fixed * Update helmholtz.md Equations rendering second fix, missing spaces * Major updates to helmholtz * Add to toc * Updates to helmholtz * Update to work in parallel --------- Co-authored-by: jorgensd <[email protected]>
1 parent 2fa0960 commit 2a13c0e

File tree

4 files changed

+939
-1
lines changed

4 files changed

+939
-1
lines changed

_toc.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ parts:
3535
- file: chapter2/ns_code1
3636
- file: chapter2/ns_code2
3737
- file: chapter2/hyperelasticity
38+
- file: chapter2/helmholtz
39+
sections:
40+
- file: chapter2/helmholtz_code
41+
3842
- caption: Subdomains and boundary conditions
3943
chapters:
4044
- file: chapter3/neumann_dirichlet_code
@@ -48,4 +52,4 @@ parts:
4852
- file: chapter4/solvers
4953
- file: chapter4/compiler_parameters
5054
- file: chapter4/convergence
51-
- file: chapter4/newton-solver
55+
- file: chapter4/newton-solver

chapter2/helmholtz.md

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# The Helmholtz equation
2+
Author: Antonio Baiano Svizzero
3+
4+
The study of computational acoustics is fundamental in fields such as noise, vibration, and harshness (NVH), noise control, and acoustic design. In this chapter, we focus on the theoretical foundations of the Helmholtz equation - valid for noise problems with harmonic time dependency - and its implementation in FEniCSx to compute the sound pressure for any acoustic system.
5+
6+
## The PDE problem
7+
The acoustic Helmholtz equation in its general form reads
8+
9+
$$
10+
\begin{align}
11+
\nabla^2 p + k^2 p = -j \omega \rho_0 q \qquad\text{in } \Omega,
12+
\end{align}
13+
$$
14+
15+
where $k$ is the acoustic wavenumber, $\omega$ is the angular frequency, $j$ the imaginary unit and $q$ is the volume velocity ($m^3/s$) of a generic source field.
16+
In case of a monopole source, we can write $q=Q \delta(x_s,y_s,z_s)$, where $\delta(x_s,y_s,z_s)$ is the 3D Dirac Delta centered at the monopole location.
17+
18+
This equation is coupled with the following boundary conditions:
19+
20+
- Dirichlet BC:
21+
22+
$$
23+
\begin{align}
24+
p = \bar{p} \qquad \text{on } \partial\Omega_p,
25+
\end{align}
26+
$$
27+
28+
- Neumann BC:
29+
30+
$$
31+
\begin{align}
32+
\frac{\partial p}{\partial n} = - j \omega \rho_0 \bar{v}_n\qquad \text{on } \partial\Omega_v,
33+
\end{align}
34+
$$
35+
36+
- Robin BC:
37+
38+
$$
39+
\begin{align}
40+
\frac{\partial p}{\partial n} = - \frac{j \omega \rho_0 }{\bar{Z}} p \qquad \text{on } \partial\Omega_Z,
41+
\end{align}
42+
$$
43+
44+
where we prescribe, respectively, an acoustic pressure $\bar{p}$ on the boundary $\partial\Omega_p$,
45+
a sound particle velocity $\bar{v}_n$ on the boundary $\partial\Omega_v$ and
46+
an acoustic impedance $\bar{Z}$ on the boundary $\partial\Omega_Z$ where $n$ is the outward normal.
47+
In general, any BC can also be frequency dependant, as it happens in real-world applications.
48+
49+
## The variational formulation
50+
Now we have to turn the equation in its weak formulation.
51+
The first step is to multiplicate the equation by a *test function* $v\in \hat V$,
52+
where $\hat V$ is the *test function space*, after which we integrate over the whole domain, $\Omega$:
53+
54+
$$
55+
\begin{align}
56+
\int_{\Omega}\left(\nabla^2 p + k^2 p \right) \bar v ~\mathrm{d}x = -\int_{\Omega} j \omega \rho_0 q \bar v ~\mathrm{d}x.
57+
\end{align}
58+
$$
59+
60+
Here, the unknown function $p$ is referred to as *trial function* and the $\bar{\cdot}$ is the complex conjugate operator.
61+
62+
In order to keep the order of derivatives as low as possible, we use integration by parts on the Laplacian term:
63+
64+
$$
65+
\begin{align}
66+
\int_{\Omega}(\nabla^2 p) \bar v ~\mathrm{d}x =
67+
-\int_{\Omega} \nabla p \cdot \nabla \bar v ~\mathrm{d}x
68+
+ \int_{\partial \Omega} \frac{\partial p}{\partial n} \bar v ~\mathrm{d}s.
69+
\end{align}
70+
$$
71+
72+
Substituting in the original version and rearranging we get:
73+
74+
$$
75+
\begin{align}
76+
\int_{\Omega} \nabla p \cdot \nabla \bar v ~\mathrm{d}x
77+
- k^2 \int_{\Omega} p \bar v ~\mathrm{d} x = \int_{\Omega} j \omega \rho_0 q \bar v ~\mathrm{d}x
78+
+ \int_{\partial \Omega} \frac{\partial p}{\partial n} \bar v ~\mathrm{d}s.
79+
\end{align}
80+
$$
81+
82+
Since we are dealing with complex values, the inner product in the first equation is *sesquilinear*,
83+
meaning it is linear in one argument and conjugate-linear in the other,
84+
as explained in [The Poisson problem with complex numbers](../chapter1/complex_mode).
85+
86+
The last term can be written using the Neumann and Robin BCs, that is:
87+
88+
$$
89+
\begin{align}
90+
\int_{\partial \Omega} \frac{\partial p}{\partial n} \bar v ~\mathrm{d}s =
91+
-\int_{\partial \Omega_v} j \omega \rho_0 \bar v ~\mathrm{d}s
92+
- \int_{\partial \Omega_Z} \frac{j \omega \rho_0 \bar{v}_n}{\bar{Z}} p \bar v ~\mathrm{d}s.
93+
\end{align}
94+
$$
95+
96+
Substituting, rearranging and taking out of integrals the terms with $j$ and $\omega$ we get the variational formulation of the Helmholtz.
97+
Find $u \in V$ such that:
98+
99+
$$
100+
\begin{align}
101+
\int_{\Omega} \nabla p \cdot \nabla \bar v ~\mathrm{d}x
102+
+ \frac{j \omega }{\bar{Z}} \int_{\partial \Omega_Z} \rho_0 p \bar v ~\mathrm{d}s
103+
- k^2 \int_{\Omega} p \bar v ~\mathrm{d}x
104+
= j \omega \int_{\Omega} \rho_0 q \bar v ~\mathrm{d}x
105+
-j \omega\int_{\partial \Omega_v} \rho_0 \bar{v}_n \bar v ~\mathrm{d}s \qquad \forall v \in \hat{V}.
106+
\end{align}
107+
$$
108+
109+
We define the sesquilinear form $a(p,v)$ is
110+
111+
$$
112+
\begin{align}
113+
a(p,v) = \int_{\Omega} \nabla p \cdot \nabla \bar v ~\mathrm{d}x
114+
+ \frac{j \omega }{\bar{Z}} \int_{\partial \Omega_Z} \rho_0 p \bar v ~\mathrm{d}s,
115+
- k^2 \int_{\Omega} p \bar v ~\mathrm{d}x
116+
\end{align}
117+
$$
118+
119+
and the linear form $L(v)$ reads
120+
121+
$$
122+
\begin{align}
123+
L(v) = j \omega \int_{\Omega}\rho_0 q \bar v ~\mathrm{d}x - j \omega \int_{\partial \Omega_v} \rho_0 \bar{v}_n \bar v ~\mathrm{d}s.
124+
\end{align}
125+
$$

0 commit comments

Comments
 (0)