k-Wave Toolbox |

## Recording The Particle Velocity Example

On this page…
Overview Setting the 'RecordVelocity' Flag Running the simulation

### Overview

This example demonstrates how to record the particle velocity using a Cartesian or binary sensor mask. It builds on the Homogeneous Propagation Medium and Heterogeneous Propagation Medium examples.

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

Back to Top

### Setting the 'RecordVelocity' Flag

By default, the first order simulation functions in k-Wave return the pressure field recorded at the positions specified by `sensor.mask`. This data is assigned directly to the output argument `sensor_data`. The particle velocity at these positions can also be returned by setting the optional input parameter `'ReturnVelocity'` to `true`. In this case, the output argument `sensor_data` is returned as a structure with the pressure and particle velocity appended as separate fields. In two dimensions, these fields are given by `sensor_data.p`, `sensor_data.ux`, and `sensor_data.uy` (similarly for other dimensions).

Back to Top

### Running the simulation

The simulation is run in the same way as in previous examples. In this example, four sensor points are defined centered about the position of a small circular source. The function `kspaceFirstOrder2D` is then called with the optional input parameter `'ReturnVelocity'` set to `true`. A plot of the initial pressure distribution and the sensor mask is given below.

    % define four sensor points centered about source.p0
    sensor_radius = 40; % [grid points]
    sensor.mask = zeros(Nx, Ny);
    sensor.mask(Nx/2 + sensor_radius, Ny/2) = 1;
    sensor.mask(Nx/2 - sensor_radius, Ny/2) = 1;
    sensor.mask(Nx/2, Ny/2 + sensor_radius) = 1;
    sensor.mask(Nx/2, Ny/2 - sensor_radius) = 1;

    % run the simulation
    sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, 'ReturnVelocity', true);

The pressure and velocity recorded at the four sensor positions is shown below (these are indexed top to bottom, left to right). The recorded pressure signals are shown in the left column. As the sensor points are all equidistance from the center of the source, the signals appear the same. The recorded particle velocity signals in the x-direction are shown in the central column. The signals from the second and third sensor points are mirrored as the wave at these points is travelling in opposite directions. The signals at the first and fourth sensor points are almost zero because the wave at these positions is travelling largely in the y-direction. The recorded particle velocity signals in the y-direction are shown in the right column. The signals from the first and fourth sensor points are mirrored as the wave at these points is travelling in opposite directions. The signals at the second and third sensor points are almost zero because the wave at these positions is travelling largely in the x-direction.

Back to Top

© 2009-2012 Bradley Treeby and Ben Cox.