k-Wave Toolbox |
On this page… |
---|
The first-order simulation codes included within the k-Wave Toolbox (kspaceFirstOrder1D
, kspaceFirstOrder2D
, and kspaceFirstOrder3D
) use a special type of anisotropic absorbing boundary layer known as a perfectly matched layer (PML) to absorb acoustic waves when they reach the edge of the computational domain. By default, this layer occupies a strip of 20 grid points (10 in 3D) around the edge of the domain. Without this boundary layer, the computation of the spatial derivates via the FFT causes waves leaving one side of the domain to reappear at the opposite side. The use of the PML thus facilitates infinite domain simulations without the need to increase in the size of the computational grid. This example demonstrates how to control the parameters of the PML within k-Wave via optional input parameters.
The PML has four properties, each of which can be controlled via optional input parameters:
'PMLSize'
in units of grid points. The default setting is 20 grid points in 1D and 2D and 10 grid points in 3D. If the size is specified as a single number, this is used for all Cartesian directions. Alternatively, the size for each direction can be set individually by setting 'PMLSize'
to [PML_X_SIZE, PML_Y_SIZE]
in 2D, and [PML_X_SIZE, PML_Y_SIZE, PML_Z_SIZE]
in 3D.'PMLAlpha'
in units of Nepers per grid point. The default setting is 2 for all dimensions. Again, if the absorption is specified as a single number, this is used for all Cartesian directions. Alternatively, the absorption for each direction can be set individually by setting 'PMLAlpha'
to [PML_X_ALPHA, PML_Y_ALPHA]
in 2D, and [PML_X_ALPHA, PML_Y_ALPHA, PML_Z_ALPHA]
in 3D.'PMLInside'
(the default setting is true
). If 'PMLInside'
is set to false
, the input grids are enlarged on each edge by the size given by 'PMLSize'
.'PlotPML'
(the default setting is true
).For accurate simulations, care must be taken that the initial pressure distribution and the sensor mask don't lie within the PML. This can be avoided by setting 'PMLInside'
to false
. However, the computational time will still be dependent on the total size of the grid including the PML (i.e., computations will be fastest for grids where the total number of grid points in each dimension is given by a power of two).
The effect of the PML can be illustrated most clearly by switching it completely off by setting the optional input 'PMLAlpha'
to 0
(set example_number = 1
within the example m-file). This sets the absorption within the layer to zero, thus the waves leaving one side of the domain reappear at the opposite side. A visualisation of the recorded time-series is given below.
A similar effect is seen if the value for 'PMLAlpha'
is set too high (set example_number = 2
within the example m-file). This causes the waves to be reflected from the layer.
The effectiveness of the PML depends on its size and absorption, but also on the time step used in the simulation (the more time steps the wave spends in the layer, the more it will be absorbed). A partially effective PML can be illustrated by reducing the size of the PML by setting the optional input 'PMLSize'
to 2
(set example_number = 3
within the example m-file). The layer absorbs some (but not all) of the waves approaching the boundaries, and some of the wave wrapping seen in the previous example is still visible.
By default, the PML will be inside the grid defined by the user, so care must be taken that the source and sensor are not defined within this region. This can be avoided by setting the optional input 'PMLInside'
to false
(set example_number = 4
within the example m-file). In this case the computational grid and input variables are automatically expanded by the size of the PML. This setting gives several additional command line status readouts, including feedback on expanding the input grids and the total size of the computational grid (in this case 168 by 168 grid points).
Running k-Wave simulation... start time: 02-Nov-2011 20:16:41 reference sound speed: 1500m/s dt: 20ns, t_end: 12.06us, time steps: 604 input grid size: 128 by 128 grid points (12.8 by 12.8mm) maximum supported frequency: 7.5MHz smoothing p0 distribution... expanding computational grid... computational grid size: 168 by 168 grid points calculating Delaunay triangulation... precomputation completed in 1.1535s starting time loop... estimated simulation time 5.9372s... simulation completed in 9.6409s total computation time 10.8585s
As the inner part of the computation grid is identical to that in the Homogeneous Propagation Medium Example, the recorded time-series (shown below) is also identical. In this case, the default size and absorption for the PML are adequate to prevent any visible wave wrapping. For any particular example, if the performance of the PML is not sufficient, increasing the size of the PML, optimising the value of PMLAlpha
, or reducing the time-step used in t_array
will give improvements.
Numerical Analysis | Source Smoothing |
© 2009-2014 Bradley Treeby and Ben Cox.