k-Wave Toolbox |
![]() ![]() |
On this page… |
---|
Defining the time varying pressure source |
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 and Recording The Particle Velocity Examples.
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 position of the source points) 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; % [Pa] source.p = source_mag*sin(2*pi*source_freq*kgrid.t_array); % filter the source to remove any high frequencies not supported by the grid source.p = filterTimeSeries(kgrid, medium, source.p);
To visualise 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 complete time series at each sensor point by setting sensor.record
to {'p_final', 'p_max', 'p_rms'}
. With this option, at each time step k-Wave only updates the maximum and rms values of the pressure at each sensor point. This can significantly reduce the memory requirements for storing the sensor data, particularly if sensor masks with large numbers of sensor points are used.
% create a sensor mask covering the entire computational domain sensor.mask = ones(Nx, Ny); % set the record mode capture the final wave-field and the statistics at % each sensor point sensor.record = {'p_final', 'p_max', 'p_rms'};
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{:});
As described in the Recording The Particle Velocity Example, if an input for sensor.record
is defined, the output sensor_data returned from the simulation is defined as a structure, with the recorded acoustic variables appended as structure fields. In this case the output sensor_data
is given as a structure with the fields sensor_data.p_final
, sensor_data.p_max
, and sensor_data.p_rms
. For a binary sensor mask, p_rms
and p_max
are indexed as (sensor_point_index)
and are ordered using MATLAB's column-wise linear matrix index ordering. This means the 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.
![]() |
Dipole Point Source In A Homogeneous Propagation Medium | Steering A Linear Array | ![]() |
© 2009-2012 Bradley Treeby and Ben Cox.