kWave
A MATLAB toolbox for the timedomain
simulation of acoustic wave fields
 Getting Started
 Examples
 Initial Value Problems
 Example: Homogenous Propagation Medium
 Example: Using A Binary Sensor Mask
 Example: Defining A Sensor Mask By Opposing Corners
 Example: Loading External Image Maps
 Example: Heterogeneous Propagation Medium
 Example: Saving Movie Files
 Example: Recording The Particle Velocity
 Example: Defining A Gaussian Sensor Frequency Response
 Example: Comparison Of Modelling Functions
 Example: Setting An Initial Pressure Gradient
 Example: Simulations In One Dimension
 Example: Simulations In Three Dimensions
 Example: Photoacoustic Waveforms in 1D, 2D and 3D
 Time Varying Source Problems
 Example: Monopole Point Source In A Homogeneous Propagation Medium
 Example: Dipole Point Source In A Homogeneous Propagation Medium
 Example: Simulating Transducer Field Patterns
 Example: Steering A Linear Array
 Example: Snell's Law And Critical Angle Reflection
 Example: The Doppler Effect
 Example: Diffraction Through A Slit
 Example: Simulations In ThreeDimensions
 Sensor Directivity
 Example: Focussed Detector in 2D
 Example: Focussed Detector in 3D
 Example: Modelling Sensor Directivity in 2D
 Example: Modelling Sensor Directivity in 3D
 Example: Sensor Element Directivity in 2D
 Example: Focussed 2D Array with Directional Elements
 Photoacoustic Image Reconstruction
 Example: 2D FFT Reconstruction For A Line Sensor
 Example: 3D FFT Reconstruction For A Planar Sensor
 Example: 2D Time Reversal For A Line Sensor
 Example: 2D Time Reversal For A Circular Sensor
 Example: 3D Time Reversal For A Planar Sensor
 Example: 3D Time Reversal For A Spherical Sensor
 Example: Image Reconstruction With Directional Sensors
 Example: Image Reconstruction With Bandlimited Sensors
 Example: Iterative Image Improvement Using Time Reversal
 Example: Attenuation Compensation Using Time Reversal
 Example: Attenuation Compensation Using Time Variant Filtering
 Example: Automatic Sound Speed Selection
 Diagnostic Ultrasound Simulation
 Example: Defining An Ultrasound Transducer
 Example: Simulating Ultrasound Beam Patterns
 Example: Using An Ultrasound Transducer As A Sensor
 Example: Simulating Bmode Ultrasound Images
 Example: Simulating Bmode Images Using A Phased Array
 Numerical Analysis
 Example: Controlling The Absorbing Boundary Layer
 Example: Source Smoothing
 Example: Filtering A Delta Function Input Signal
 Example: Modelling Power Law Absorption
 Example: Modelling Nonlinear Wave Propagation
 Example: Optimising kWave Performance
 Using The C++ Code
 Elastic Wave Propagation
 Example: Explosive Source In A Layered Medium
 Example: Plane Wave Absorption
 Example: Shear Waves And Critical Angle Reflection
 Example: Simulations In Three Dimensions
 Functions  By Category
 Functions  Alphabetical List
 Release Notes
 License
kWave Toolbox 
kspaceSecondOrder
Fast timedomain simulation of wave propagation for homogeneous media
Syntax
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, ...)
Description
kspaceSecondOrder
simulates the timedomain 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 secondorder kspace model for media with power law absorption. At each timestep (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 columnwise 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 firstorder 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.
Inputs

kWave grid structure returned by 

evenly spaced array of time values [s] (set to 



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 timestep 

cell array of the acoustic parameters to record in the form 
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 

(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) 

[min, max] values used to control the scaling for 

(Boolean scalar) 

Boolean controlling whether the simulation iterations are progressively plotted. 

(Boolean scalar) 

Boolean controlling whether 
Outputs
If sensor.record
is not defined by the user:

time varying pressure recorded at the sensor positions given by 
If sensor.record
is defined by the user:

time varying pressure recorded at the sensor positions given by 

final pressure field at all grid points within the domain (returned if 
Examples
 Comparison Of Modelling Functions
 Setting An Initial Pressure Gradient
 Modelling Power Law Absorption
See Also
kspaceFirstOrder1D
, kspaceFirstOrder2D
, kspaceFirstOrder3D
, makeGrid
, makeTime
, smooth
kspacePlaneRecon  loadImage 
© 20092014 Bradley Treeby and Ben Cox.