k-Wave Toolbox
k-Wave Toolbox Previous   Next


Fast time-domain simulation of wave propagation for homogeneous media


sensor_data = kspaceSecondOrder(kgrid, medium, source, sensor)
sensor_data = kspaceSecondOrder(kgrid, medium, source, sensor, ...) 

[sensor_data, field_data] = kspaceSecondOrder(kgrid, medium, source, sensor)
[sensor_data, field_data] = kspaceSecondOrder(kgrid, medium, source, sensor, ...) 


kspaceSecondOrder simulates the time-domain propagation of linear compressional waves through a one, two, or three dimensional homogeneous acoustic medium given four input structures: kgrid, medium, source, and sensor. The computation is based on an exact second-order k-space model for media with power law absorption. At each time-step (defined by kgrid.t_array), the pressure at the positions defined by sensor.mask are recorded and stored. If kgrid.t_array is set to 'auto', this array is automatically generated using makeTime. To prevent wave wrapping, the computational domain can be automatically expanded by a factor of two by setting the optional input 'ExpandGrid' to true.

An initial pressure distribution can be specified by assigning a matrix (the same size as the computational grid) of arbitrary numeric values to source.p0. An initial pressure gradient can similarly be specified using source.dp0dt. The pressure is returned as an array of time series at the sensor locations defined by sensor.mask. This is specified as a binary matrix (i.e., a matrix of 1's and 0's the same size as the computational grid) representing the grid points within the computational grid that will collect the data. The sensor_data is returned using MATLAB's standard column-wise linear matrix index ordering with the recorded data indexed as sensor_data(sensor_position, time). The final pressure field over the complete computational grid can also be obtained by setting sensor.record to {'p', 'p_final'}. In this case, the output sensor_data is returned as a structure with the outputs appended as the structure fields sensor_data.p and sensor_data.p_final.

Compared to the first-order simulation functions kspaceFirstOrder1D, kspaceFirstOrder2D, and kspaceFirstOrder3D, kspaceSecondOrder is restricted to homogeneous media and has less functionality. However, it is also more computationally efficient and allows an initial pressure gradient to be specified.



k-Wave grid structure returned by makeGrid containing Cartesian and k-space grid fields


evenly spaced array of time values [s] (set to 'auto' by makeGrid)




homogeneous sound speed within the acoustic medium [m/s]


power law absorption exponent


power law absorption coefficient [dB/(MHz^y cm)]




initial pressure within the acoustic medium


initial pressure gradient within the acoustic medium




binary grid specifying where the pressure is recorded at each time-step


cell array of the acoustic parameters to record in the form sensor.record = {'p'}; valid inputs are:
  'p' (acoustic pressure)
  'p_final' (final pressure field at all grid points)

Optional Inputs

Optional 'string', value pairs that may be used to modify the default computational settings.

Input Valid Settings Default Description


(Boolean scalar)


Boolean controlling whether the grid size is expanded on two sides to delay the time before wave wrapping occurs.


(Boolean scalar)


Boolean controlling whether mesh is used in place of imagesc to plot the pressure field.


(Boolean scalar)


Boolean controlling whether the pressure field for each time step is plotted in a new window.


(integer numeric scalar)


The number of iterations which must pass before the simulation plot is updated.


(numeric two element vector)

[-1, 1]

[min, max] values used to control the scaling for imagesc (visualisation).


(Boolean scalar)


Boolean controlling whether the simulation iterations are progressively plotted.


(Boolean scalar)


Boolean controlling whether source.p0 is smoothed using smooth before computation.


If sensor.record is not defined by the user:


time varying pressure recorded at the sensor positions given by sensor.mask

If sensor.record is defined by the user:


time varying pressure recorded at the sensor positions given by sensor.mask (returned if 'p' is set)


final pressure field at all grid points within the domain (returned if 'p_final' is set)


See Also

kspaceFirstOrder1D, kspaceFirstOrder2D, kspaceFirstOrder3D, makeGrid, makeTime, smooth

© 2009-2014 Bradley Treeby and Ben Cox.