k-Wave Toolbox |
![]() ![]() |
On this page… |
---|
This example provides a simple demonstration of using k-Wave for the simulation and detection of a time varying pressure dipole source within a two-dimensional homogeneous propagation medium. It builds on the Monopole Point Source In A Homogeneous Propagation Medium Example.
A time varying velocity source is defined analogous to the time varying pressure source encountered in the previous example.
A binary matrix (i.e., a matrix of 1's and 0's
with the same dimensions as the computational grid) is assigned to to source.u_mask
where the
1's represent the pixels that form part of the source. The time varying input signal is then
assigned to source.ux
and source.uz
. These must be the same length as kgrid.t_array
and can be a single time series
(in which case it is applied to all source elements), or a matrix of time series following
the source elements using MATLAB's standard column-wise linear matrix index ordering.
In this example a dipole is created by assigning a sinusoidal velocity input to a single source element. Note, to avoid numerical
stabilities, the input should first be filtered using filterTimeSeries
(see the Filtering A Delta Function Input Signal Example
for more information).
% define a single source element source.u_mask = zeros(Nz, Nx); source.u_mask(end - Nz/4, Nx/2) = 1; % define a time varying sinusoidal velocity source in the z-direction source_freq = 0.25e6; source_mag = 2/(medium.sound_speed*medium.density); source.uz = source_mag*sin(2*pi*source_freq*kgrid.t_array); source.ux = zeros(size(source.uz)); % smooth the source source.uz = filterTimeSeries(kgrid, medium, source.uz);
Note, an acoustic dipole could also be created using a pressure source comprising of two adjacent pixels with their inputs out of phase. Higher order source patterns can similarly be created using combinations of pressure or velocity sources.
A plot of the input time series driving the source element along with the acoustic pressure recorded at
the sensor element is given below. By scaling the magnitude of the velocity input by the impedance of the medium,
the magnitude of the pressure recorded at the sensor is the same as in the previous example.
The final pressure field within the computational domain can also be returned by assigning both the sensor_data
and field_data
output fields.
% run the simulation [sensor_data, field_data] = kspaceFirstOrder2D(kgrid, medium, source, sensor);
![]() |
Monopole Point Source In A Homogeneous Propagation Medium | Simulating Transducer Field Patterns | ![]() |
© 2009, 2010, 2011 Bradley Treeby and Ben Cox.