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 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 example, 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`. 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.

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

    % run the simulation
    [sensor_data p_final] = kspaceFirstOrder2D(kgrid, medium, source, sensor, 'DisplayMask', display_mask);

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

Back to Top

© 2009, 2010 Bradley Treeby and Ben Cox.