k-Wave Toolbox |

## Simulating Transducer Field Patterns Example

On this page…
Overview Defining the time varying pressure source Running the simulation

### Overview

This example demonstrates the use of k-Wave to compute the field pattern generated by a curved single element transducer in two dimensions. It builds on the Monopole Point Source In A Homogeneous Propagation Medium Example.

- open the file in the MATLAB Editor
- run the file in MATLAB

Back to Top

### Defining the time varying pressure source

As in the previous examples, a time varying pressure source is defined by assigning a binary source mask `source.p_mask` (which defines the shape and position of the source) along with a time varying source input `source.p`. Here a single sinusoidal time series is used to drive a curved transducer element.

    % define a curved transducer element
    source.p_mask = makeCircle(Nx, Nz, 50, 50, 30, pi/2);

    % define a time varying sinusoidal source
    source_freq = 0.25e6;
    source_mag = 0.5;
    source.p = source_mag*sin(2*pi*source_freq*kgrid.t_array);

    % smooth the source
    source.p = filterTimeSeries(kgrid, medium, source.p);

Back to Top

### Running the simulation

The simulation is again invoked by calling `kspaceFirstOrder2D`. Because no sensor output is required, the sensor input structure is simply assigned as an empty array. To allow visualisation of the source elements within the grid, the source mask is assigned to the optional input `'DisplayMask'`. This mask is overlayed onto the plot during the simulation. The PML is also set to be outside the computational grid defined by the user and then hidden from display by setting the optional inputs `'PlotPML'` and `'PMLInside'` to `false`.

    % create a display mask to display the transducer
    display_mask = source.p_mask;

    % assign the input options
    input_args = {'DisplayMask', display_mask, 'PMLInside', false, 'PlotPML', false};

    % run the simulation
    [sensor_data, p_final] = kspaceFirstOrder2D(kgrid, medium, source, [], input_args{:});

The final pressure field is plotted below. Both the transducer focus and the side lobes are clearly visible.

Back to Top

© 2009, 2010, 2011 Bradley Treeby and Ben Cox.