k-Wave Toolbox Previous   Next

Simulating Transducer Field Patterns Example

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.

 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 to source.p_mask (which defines the shape and position of the source) along with a time varying source input to 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, Ny, 61, 61, 60, pi/2);

% define a time varying sinusoidal source
source_freq = 0.25e6;       % [Hz]
source_mag = 0.5;           % [au]
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

Recording the statistics of the pressure field

To visualise the pattern of the acoustic beam produced by the curved transducer, a binary sensor mask covering the entire computational domain is defined. If only the total beam pattern is required (rather than the beam pattern at particular frequencies or times), this can be produced without having to store the time series at each sensor element by setting sensor.record_mode to 'statistics'. With this option, at each time step k-Wave only updates the maximum and rms values of the pressure at each sensor element. This can significantly reduce the memory requirements for storing the sensor data, particularly if sensor masks with large numbers of active elements are used.

% create a sensor mask covering the entire computational domain
sensor.mask = ones(Nx, Ny);

% set the record mode to only capture statistics at each sensor point
sensor.record_mode = 'statistics';

 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. 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, sensor, input_args{:});

When sensor.record_mode is set to 'statistics', both the rms and maximum pressure at each grid point are returned. In this case the output sensor_data is given as a structure with the fields sensor_data.p_max and sensor_data.p_rms. For a binary sensor mask, the ordering of the output data again follows MATLAB's column-wise linear matrix index ordering. In this example, a binary sensor mask covering the entire computational domain is used, thus the returned output data must be reshaped before display.

% reshape the sensor data
sensor_data.p_max = reshape(sensor_data.p_max, Nx, Ny);
sensor_data.p_rms = reshape(sensor_data.p_rms, Nx, Ny);

The final pressure field along with the maximum and rms beam patterns are plotted below. Both the transducer focus and the side lobes are clearly visible.

 Back to Top


© 2009-2012 Bradley Treeby and Ben Cox.