k-Wave Toolbox Previous   Next

Recording The Particle Velocity Example

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.

 Back to Top

Setting the acoustic variables that are recorded

By default, the first-order simulation functions in k-Wave return the pressure field recorded at each time step at the positions specified by sensor.mask. This data is assigned directly to the output argument sensor_data. It is also possible to control the acoustic variables that are recorded by the sensor mask by setting the value of sensor.record. The desired field parameters are listed as strings within a cell array. For example, to record both the acoustic pressure and the particle velocity, sensor.record should be set to {'p', 'u'}. If a value for sensor.record is set, the output sensor_data returned from the simulation is defined as a structure, with the recorded acoustic variables appended as structure fields. For example, if sensor.record = {'p', 'p_max', 'u'}, then the individual output variables are accessed as sensor_data.p, sensor_data.p_max, sensor_data.ux, sensor_data.uy (similarly for other dimensions). A full list of other sensor.record options is given in kspaceFirstOrder2D.

 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, and the sensor is set to record both the acoustic pressure and the particle velocity. 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;

% set the acoustic variables that are recorded
sensor.record = {'p', 'u'};

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

The pressure and velocity signals recorded at the four sensor positions are 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.

Note, the first-order simulation functions use both spatially and temporally staggered grids. This means the output pressure and velocity values are offset from each other. For example, sensor_data.ux is obtained at grid points staggered in the x-direction by +kgrid.dx/2 and in the temporal direction by -kgrid.dt/2. More information is given in the k-Wave Manual.

 Back to Top


© 2009-2012 Bradley Treeby and Ben Cox.