Contents

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 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.

Recording the statistics of the pressure field

To visualise the acoustic beam produced by the curved transducer, a sensor mask covering the entire computational domain is defined using the grid coordinates of two opposing corners of a rectangle (a list of the different sensor mask types is given in the Homogeneous Propagation Medium Example). 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 using the
% opposing corners of a rectangle
sensor.mask = [1, 1, Nx, Ny].';
% set the record mode to capture the final wave-field and the statistics at
% each sensor point
sensor.record = {'p_final', 'p_max', 'p_rms'};

Note, if recording the maximum or minimum pressure everywhere, it is also possible to set sensor.record to {'p_max_all', 'p_min_all'}. This returns the maximum and minimum pressure everywhere, regardless of the shape or type of sensor mask. Consequently, provided no other outputs are required, in this case it is possible to leave the sensor mask blank by setting sensor.mask = [].

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 overlaid 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.

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 sensor mask defined using the grid coordinates of opposing corners of a rectangle, p_rms and p_max are indexed as (x_index, y_index), where x_index and y_index correspond to the grid index within the rectangle. 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.