Professional Documents
Culture Documents
OpenBEM
αp + βvn = γ. (3)
G is the free space Green’s function which relates the sound pressure between two points.
For 3-D problems:
e−jkR
G(R) = , R = |P − Q| (5)
R
For 2D-problems:
1 (1)
G(R) = H (kR), R = |P − Q| (6)
4i 0
C(P) are constants that depend on the geometry of the body and where the point P is
placed [?, ?]
S is the surface of the body
Q, as the figure 10 shows, a point on the surface
P is any interior or exterior point.
∂G(P, Q)
Z
C(P)p(P) = p(Q)dS + 4πpI (P), ⇒ (7)
S ∂n
N Z
X ∂G(P, Q)
C(P)p(P) ≈ p(Q)dSj + 4πpI (P) (8)
Sj ∂n
j=1
N
∂G(P, Q)
X Z
C(P)p(P) ≈ pj dSj + 4πpI (P) = (9)
Sj ∂n
j=1
In matrix form:
C(Q) · p(Q) = H · p(Q) + 4πpI (Q). (10)
If the matrix A can be inverted, the matrix equation can be multiplied on the left by A−1 , to get
the vector containing the sound pressure at the points Q placed on the surface of the body:
Once the sound pressure is known on the surface, the sound pressure can be solved to any Field
Point:
C(P) · p(P) = H · p(Q) + 4πpI (P), (13)
Note: The BEM is solved in two steps: first, for the boundary and
second for the domain.
v(Q) contains the known velocity on the surface of the body and the
elements of the matrix
B are the surface integrals of the Green function – see eq (4).
The equation (14) must be solved in two steps:
1 Making P → Q and solving for the nodal values, p(Q).
2 Once the nodal values are known, the sound pressure in the field points,
p(P), can be obtained.
OpenBEM (U.Vigo) Boundary Element Method 2014/2015 8 / 44
Mesh generation in 3D
2 Mesh generation in 3D
CAD design: FreeCad
Mesh generation in 3D with Gmsh
Importing 3D Meshes into Matlab
Tasks
Mesh
genera*on
(Meshing)
FreeCad: Example
Example:
Rectangular room with dimensions Length=4 m, Width=3 m and Heigh= 2,7 m
FreeCad: Example
FreeCad: Example
FreeCad: Example
FreeCad: Example
We need to export the file to exchange format to be imported in the
meshing software. In our case, ”step”.
Gmsh: Example
Import the geometry into Gmsh and under the ”mesh” menu, press the
2D option:
Gmsh: Example
Now the mesh is done and ready to save in ”msh” format that can be
imported into Matlab. Save it as box tutorial.msh.
Function geometry=loadgeom(file,n)
The function loadgeom, imports a 3D mesh in ”.msh” format into matlab
Input: The file name: ’filename.msh’ and the direction of the normal vectors desired +1 for
exterior problems and -1 in the case of interior problems.
Output: The structure geometry, with the fields geometry.nodesb and geometry.topologyb
Tasks
Practice to
1 Create, mesh and import into Matlab a cylindrical room with a
dome on the top. Radius of the cylinder and the dome, r= 7 m.
Heigth=3 m. Total Heigh including the dome: 10 m
2 Create, mesh and import into Matlab a room with two non parallel
walls (any dimensions).
3 Resonances in Cavities
Theoretical background
An Example of 2D Cavity: Resonances
Mapping the sound pressure in a 2D cavity
Tasks:
Resonances and modes in 3D
Introduction
Aims:
Know how to generate geometries in 2D-BEM
Understand the use of the kernel functions in OpenBEM (2D and
3D)
Calculate resonances, 2D and 3D, in cavities using BEM.
Theoretical background
Theoretical background
Theoretical Task
1-Data:
We want to calculate the resonance frequencies of a 2D cavity when a
sound source is placed at P = (xs , ys ) = (0.1, 0.1). The cavity
dimensions are: Lx = 4 m, Ly = 3 m. It is desired to calculate the
frequency response from f1 = 40 to f2 = 145Hz:
1 At a field point, P1 , placed at P1 = (0.9, 1.1)
2 At a field point, P2 , placed at P1 = ( L2x , Ly
2 )
Lz
Ly
Lx
Theoretical Task
The temperature is t = 20 o C
The static pressure: po = 101325 Pa.
Relative Humidity: Hr = 50
With this atmospheric conditions, the speed of sound,
c = 343.9862 m/s.
2D BEM calculations
Geometry definition:
Function: [xyb,topology, admitt]=nodegen(segments,see);
2D BEM calculations
Geometry definition:
Function: [xyb,topology, admitt]=nodegen(segments,see);
2D BEM calculations
Geometry definition:
Function: [xyb,topology, admitt]=nodegen(segments,see);
2D BEM calculations
% De-normalized admittance
betaS=betag(sigmaS,fr)/(rho*c);
% Define segments:
segments=[0 0 0 ly ceil(ly*el_wl) 0 betaS;...
0 ly lx ly ceil(lx*el_wl) 0 betaS;...
lx ly lx 0 ceil(ly*el_wl) 0 betaS;...
lx 0 0 0 ceil(lx*el_wl) 0 betaS];
% Call nodegen:
[xyb,topology,Ynodes]=nodegen(segments,’y’);
% Interior problem:
xyb(:,end)=-xyb(:,end);
topology(:,end)=-topology(:,end);
2D BEM calculations
Calculates the 2D Green’s function for free field, rigid plane or plane with impedance.
k: wave number
pxyb: (x,y,body) - coordinates and body number for each point ’P’
betaP: Admittance of the propagation plane: NaN (not a number), then free-field Green’s
function is calculated. ’0’: plane is considered rigid.
xq,yq: Real column vectors containing the global x and y -coordinates for each point to
calculate (integration points).
Output:
G0dir: direct Green’s function for free-field or rigid plane.
G0ref: Reflected Green’s function for free-field or rigid plane.
dG0dirdR1, dG0dirdR2: derivative of the direct and the reflected Green’s function.
Pbeta: correction term for a plane with finite impedance.
dPbetadx,dPbetady: derivatives of the correction term.
2D BEM calculations
Calculates the 2D Green’s function for free field, rigid plane or plane with impedance.
k: wave number
pxyb: (x,y,body) - coordinates and body number for each point ’P’
betaP: Admittance of the propagation plane: NaN (not a number), then free-field Green’s
function is calculated. ’0’: plane is considered rigid.
xq,yq: Real column vectors containing the global x and y -coordinates for each point to
calculate (integration points).
Output:
G0dir: direct Green’s function for free-field or rigid plane.
G0ref: Reflected Green’s function for free-field or rigid plane.
dG0dirdR1, dG0dirdR2: derivative of the direct and the reflected Green’s function.
Pbeta: correction term for a plane with finite impedance.
dPbetadx,dPbetady: derivatives of the correction term.
2D BEM calculations
Calculates the 2D Green’s function for free field, rigid plane or plane with impedance.
k: wave number
pxyb: (x,y,body) - coordinates and body number for each point ’P’
betaP: Admittance of the propagation plane: NaN (not a number), then free-field Green’s
function is calculated. ’0’: plane is considered rigid.
xq,yq: Real column vectors containing the global x and y -coordinates for each point to
calculate (integration points).
Output:
G0dir: direct Green’s function for free-field or rigid plane.
G0ref: Reflected Green’s function for free-field or rigid plane.
dG0dirdR1, dG0dirdR2: derivative of the direct and the reflected Green’s function.
Pbeta: correction term for a plane with finite impedance.
dPbetadx,dPbetady: derivatives of the correction term.
2D BEM calculations
Calculates the 2D Green’s function for free field, rigid plane or plane with impedance.
k: wave number
pxyb: (x,y,body) - coordinates and body number for each point ’P’
betaP: Admittance of the propagation plane: NaN (not a number), then free-field Green’s
function is calculated. ’0’: plane is considered rigid.
xq,yq: Real column vectors containing the global x and y -coordinates for each point to
calculate (integration points).
Output:
G0dir: direct Green’s function for free-field or rigid plane.
G0ref: Reflected Green’s function for free-field or rigid plane.
dG0dirdR1, dG0dirdR2: derivative of the direct and the reflected Green’s function.
Pbeta: correction term for a plane with finite impedance.
dPbetadx,dPbetady: derivatives of the correction term.
2D BEM calculations
Calculates the 2D Green’s function for free field, rigid plane or plane with impedance.
k: wave number
pxyb: (x,y,body) - coordinates and body number for each point ’P’
betaP: Admittance of the propagation plane: NaN (not a number), then free-field Green’s
function is calculated. ’0’: plane is considered rigid.
xq,yq: Real column vectors containing the global x and y -coordinates for each point to
calculate (integration points).
Output:
G0dir: direct Green’s function for free-field or rigid plane.
G0ref: Reflected Green’s function for free-field or rigid plane.
dG0dirdR1, dG0dirdR2: derivative of the direct and the reflected Green’s function.
Pbeta: correction term for a plane with finite impedance.
dPbetadx,dPbetady: derivatives of the correction term.
2D BEM calculations
Calculations: Kernel Functions (II)
Function: [A,B]=bem2d(xyb,topology,k,betaP {,chiefpoints });
Calculates the coefficient matrix for the 2D BEM formulation. It admits a plane with finite or
infinite impedance. It is possible to calculate for the interior or exterior domain, or a combination
of both. The sign of the body numbers indicates whether the interior or exterior domain to that
body must be considered.
xyb: node positions, first column is the x-coordinate, second column is y-coordinate, and
third column is the body number to which the node belongs to.
topology: each row contains the node numbers (row number in xyb) of the nodes in one
element. The last column is the body number the element belongs to.
k: wave number.
betaP: normalised admittance of the plane, at k. If its value is 0, a rigid plane is considered
(infinite impedance); if its value is NaN (not-a-number), free-field is assumed.
chief points: Like ’xyb’, but contains CHIEF points instead One row for each chief point.
Output:
A: coefficient matrix for the pressure.
B: coefficient matrix for the normal velocity.
2D BEM calculations
Calculations: Kernel Functions (II)
Function: [A,B]=bem2d(xyb,topology,k,betaP {,chiefpoints });
Calculates the coefficient matrix for the 2D BEM formulation. It admits a plane with finite or
infinite impedance. It is possible to calculate for the interior or exterior domain, or a combination
of both. The sign of the body numbers indicates whether the interior or exterior domain to that
body must be considered.
xyb: node positions, first column is the x-coordinate, second column is y-coordinate, and
third column is the body number to which the node belongs to.
topology: each row contains the node numbers (row number in xyb) of the nodes in one
element. The last column is the body number the element belongs to.
k: wave number.
betaP: normalised admittance of the plane, at k. If its value is 0, a rigid plane is considered
(infinite impedance); if its value is NaN (not-a-number), free-field is assumed.
chief points: Like ’xyb’, but contains CHIEF points instead One row for each chief point.
Output:
A: coefficient matrix for the pressure.
B: coefficient matrix for the normal velocity.
2D BEM calculations
Calculations: Kernel Functions (II)
Function: [A,B]=bem2d(xyb,topology,k,betaP {,chiefpoints });
Calculates the coefficient matrix for the 2D BEM formulation. It admits a plane with finite or
infinite impedance. It is possible to calculate for the interior or exterior domain, or a combination
of both. The sign of the body numbers indicates whether the interior or exterior domain to that
body must be considered.
xyb: node positions, first column is the x-coordinate, second column is y-coordinate, and
third column is the body number to which the node belongs to.
topology: each row contains the node numbers (row number in xyb) of the nodes in one
element. The last column is the body number the element belongs to.
k: wave number.
betaP: normalised admittance of the plane, at k. If its value is 0, a rigid plane is considered
(infinite impedance); if its value is NaN (not-a-number), free-field is assumed.
chief points: Like ’xyb’, but contains CHIEF points instead One row for each chief point.
Output:
A: coefficient matrix for the pressure.
B: coefficient matrix for the normal velocity.
2D BEM calculations
Calculations: Kernel Functions (II)
Function: [A,B]=bem2d(xyb,topology,k,betaP {,chiefpoints });
Calculates the coefficient matrix for the 2D BEM formulation. It admits a plane with finite or
infinite impedance. It is possible to calculate for the interior or exterior domain, or a combination
of both. The sign of the body numbers indicates whether the interior or exterior domain to that
body must be considered.
xyb: node positions, first column is the x-coordinate, second column is y-coordinate, and
third column is the body number to which the node belongs to.
topology: each row contains the node numbers (row number in xyb) of the nodes in one
element. The last column is the body number the element belongs to.
k: wave number.
betaP: normalised admittance of the plane, at k. If its value is 0, a rigid plane is considered
(infinite impedance); if its value is NaN (not-a-number), free-field is assumed.
chief points: Like ’xyb’, but contains CHIEF points instead One row for each chief point.
Output:
A: coefficient matrix for the pressure.
B: coefficient matrix for the normal velocity.
2D BEM calculations
Calculations: Kernel Functions (II)
Function: [A,B]=bem2d(xyb,topology,k,betaP {,chiefpoints });
Calculates the coefficient matrix for the 2D BEM formulation. It admits a plane with finite or
infinite impedance. It is possible to calculate for the interior or exterior domain, or a combination
of both. The sign of the body numbers indicates whether the interior or exterior domain to that
body must be considered.
xyb: node positions, first column is the x-coordinate, second column is y-coordinate, and
third column is the body number to which the node belongs to.
topology: each row contains the node numbers (row number in xyb) of the nodes in one
element. The last column is the body number the element belongs to.
k: wave number.
betaP: normalised admittance of the plane, at k. If its value is 0, a rigid plane is considered
(infinite impedance); if its value is NaN (not-a-number), free-field is assumed.
chief points: Like ’xyb’, but contains CHIEF points instead One row for each chief point.
Output:
A: coefficient matrix for the pressure.
B: coefficient matrix for the normal velocity.
2D BEM calculations
Calculations: Kernel Functions (II)
Function: [A,B]=bem2d(xyb,topology,k,betaP {,chiefpoints });
Calculates the coefficient matrix for the 2D BEM formulation. It admits a plane with finite or
infinite impedance. It is possible to calculate for the interior or exterior domain, or a combination
of both. The sign of the body numbers indicates whether the interior or exterior domain to that
body must be considered.
xyb: node positions, first column is the x-coordinate, second column is y-coordinate, and
third column is the body number to which the node belongs to.
topology: each row contains the node numbers (row number in xyb) of the nodes in one
element. The last column is the body number the element belongs to.
k: wave number.
betaP: normalised admittance of the plane, at k. If its value is 0, a rigid plane is considered
(infinite impedance); if its value is NaN (not-a-number), free-field is assumed.
chief points: Like ’xyb’, but contains CHIEF points instead One row for each chief point.
Output:
A: coefficient matrix for the pressure.
B: coefficient matrix for the normal velocity.
2D BEM calculations
Calculates rows of coefficients for a set of field points. It admits a plane with finite or infinite
impedance.
Input variables
xyb:node positions, first column is the x-coordinate, second column is y-coordinate,
and third column is the body number to which the node belongs to.
topology:each row contains the node numbers (row number in xyb) of the nodes in
one element. The last column is the body number the element belongs to.
k: wavenumber
betaP: normalised admittance of the plane, at k. If its value is 0, a rigid plane is
considered (infinite impedance); if its value is NaN (not-a-number), free-field is
assumed.
xy:field points to calculate. Two columns [xi yi], with N rows (N: number of field
points).
Output: Ap,Bp and Cp: The rows of coefficients for the A, B and C constants matrixes.
2D BEM calculations
Input variables
t: temperature in Celsius. Standard: 20 Celsius
H: humidity in %. Standard: 50 %
f: frequency in Hz.
ps: static pressure in Pa. Standard: 101325 Pa
Output: c0: This is the variable we are interested in: the speed of sound at f=0.
2D BEM calculations
The resonances in BEM are calculated detecting the maximums of the Condition Number of the
matrix A. For the example given, the next code allows to calculate the resonances and the
pressure at the field points
2D BEM calculations
... from prev. page
Results
The result for two resonance frequencies (f=122.5 and f=129 Hz).
SPL
(dB)
y
(m)
y (m)
x (m)
x (m)
Using the tutorial and the theoretical background given, complete the
tasks:
1 Obtain the Frequency response of the cavity of the example for the data (dimensions,
source position and field points) and frequency range given, using the 2D BEM formulation.
2 Obtain the value of the resonance frequencies. Compare with the theoretical results.
3 Choose two resonances and plot the sound field in the cavity.
4 Identify in the Graphic of the frequency response, the mode shapes for each peak using
the notation mode (nx ,ny ).
5 Modify the geometry and recalculate the frequency response:
1 Keep the dimensions, but change the curvature of one of the segments. Choose two
of the resonances and map the sound pressure inside the cavity.
2 Build and arbitrary polygon with non-parallel sides, recalculate the frequency
response, and compare the mode shapes of the two first resonances with the
resonances of the parallelepiped.
3DBEM
Introduction
Once a geometry has been generated and meshed, it must be imported into Matlab to proceed
with the calculations. In this section the functions related to the post-processing of the mesh, the
calculations (kernel) and the post-processing of the calculations (plotting) are described.
3DBEM
Kernel functions
TriQuadEquat . Provides the matrixes A, B and C, to solve the pressure at the nodes (see
eq(14)
points. Provides the matrixes for the calculation of the sound pressure at the field point
calculations.
Example: Calculation of the sound pressure for the mode (1,0,0) of a rectangular cavity, when a
velocity point source placed in a corner of the room.
Lx=4;
fr=c/(2*Lx);
u0=1 % Velocicy of the source
geometry=loadgeom(’box_tutorial.msh’,-1); % Load the box_tutorial file
% Extract the nodes and topology matrix from the structure
topologyb=geometry.topologyb;
nodesb=geometry.nodesb;
M=size(nodesb,1); N=size(topologyb,1);
3DBEM
Kernel functions
TriQuadEquat . Provides the matrixes A, B and C, to solve the pressure at the nodes (see
eq(14)
points. Provides the matrixes for the calculation of the sound pressure at the field point
calculations.
Example: Calculation of the sound pressure for the mode (1,0,0) of a rectangular cavity, when a
velocity point source placed in a corner of the room.
Lx=4;
fr=c/(2*Lx);
u0=1 % Velocicy of the source
geometry=loadgeom(’box_tutorial.msh’,-1); % Load the box_tutorial file
% Extract the nodes and topology matrix from the structure
topologyb=geometry.topologyb;
nodesb=geometry.nodesb;
M=size(nodesb,1); N=size(topologyb,1);
3DBEM
Graphic Functions to plot the geometry and sound pressure
plotgeometry. Plot a geometry with the format ”nodes” and ”elements” matrixes. It allows
to plot as *, the nodes listed in a set of index.
plotresults. Maps the result of the calculation on the surface of the body.
playresults. Shows an animation of the result.
x y
Results