k-Wave interfaces

Interfaces for 3D and Axisymmetric pressure simulation based on k-Wave Python.

coperniFUS.modules.interfaces.kwave_interfaces.axisymmetric_interpolation(f_rz, r_axisymm, z_axisymm, x_cart, y_cart, z_cart, **kwargs)[source]

Input: f_rz -> 2D axisymmetric field Output: F_xyz -> 3D interpolated field

class coperniFUS.modules.interfaces.kwave_interfaces.KwaveHomogeneousAxisymetricBowlSim[source]

Bases: object

Handles axisymmetric (AS) kWave simulations involving a spherical transducer in an homogeneous media -> mostly used for domain size reduction using coupled AS-3D simulation (IN BETA -> COUPLING MIGHT LEAD TO INCONSISTENT PRESSURES ACCROSS DOMAINS)

KWAVE_CPP_CMD_TYPE = 'powershell'
DEFAULT_SIM_PARAMS = {'AS_domain_r_size': 0.01, 'AS_domain_z_size': 0.03, 'alpha_0': 0.0022, 'alpha_mode': 'stokes', 'alpha_power_0': 1.0, 'bli_tolerance': 0.01, 'c_0': 1482.3, 'c_tx_coupling_medium': 1482.3, 'cfl': 0.1, 'cpp_engine': 'OMP', 'cpp_io_files_directory_path': None, 'domain_z_extension': 20, 'n_reflections': 2, 'ppw': 5, 'record_periods': 1, 'rho_0': 994.04, 'rho_tx_coupling_medium': 994.04, 'run_through_external_cpp_solvers': False, 'source_ac_pwr': 0.0249, 'source_diameter': 0.015, 'source_f0': 1000000.0, 'source_phase': 0.0, 'source_roc': 0.015, 'source_z_offset': 20, 'upsampling_rate': 10}
property cpp_engine

CUDA (gpu) or OMP (cpu)

property cpp_io_files_dir_path
get_kwave_cpp_cmd(kw_hash)[source]

Returns the command that needs to be executed to run a simulation using C++ kwave scripts from a terminal

property simulation_params

Holds the simulation parameters

set_simulation_param(param_name, value)[source]

Call to set simulation parameters

property dx

Kgrid spatial sampling in the x and y directions.

property Nx

Number of spatial sampling points in the x direction. Acoustic axis (z) in the usual kwave convention.

property Ny

Number of spatial sampling points in the y direction. Lateral axis (r) in the usual kwave convention.

property ppp

Number of points per periods

property dt

Temporal sampling duration

property Nt

Number of temporal sampling steps

property alpha_corrected

Evaluating pseudo-alpha coeficient with k-Wave’s AS constraint of alpha_power=2 alpha_0 and alpha_power are defined such that attenuation_coef = alpha * f^alpha_power

property kgrid

Wrapper for k-wave’s kgrid object

property medium

Wrapper for k-wave’s medium object

property source

Wrapper for k-wave’s source object

property sensor

Wrapper for k-wave’s sensor object

run_simulation(io_h5files_directory_path=None)[source]

Call to run simulation. Returns True if computation / previous results loading successfull.

Return type:

bool

property pamp_phase_freq_zr

Pressure magnitude and phase in the whole domain (ZR).

property p_amp_zr

Pressure magnitude in the whole domain (ZR). Call def pamp_phase_freq_zr(self): to get the phase

property p_amp_xyz

Pressure magnitude interpolated to the XYZ domain.

class coperniFUS.modules.interfaces.kwave_interfaces.Kwave3D[source]

Bases: object

Handles 3D kWave simulations in complex medias

KWAVE_CPP_CMD_TYPE = 'powershell'
DEFAULT_SIM_PARAMS = {'AS_domain_z_size': 0, 'alpha_0': 0.0022, 'alpha_1': 2.693, 'alpha_mode': 'stokes', 'alpha_power_0': 1.0, 'alpha_power_1': 1.18, 'bli_tolerance': 0.01, 'c_0': 1482.3, 'c_1': 2400, 'cfl': 0.3, 'cpp_engine': 'OMP', 'cpp_io_files_directory_path': None, 'ppw': 4, 'record_periods': 1, 'rho_0': 994.04, 'rho_1': 1850, 'run_through_external_cpp_solvers': False, 'source_amp': 1000000.0, 'source_diameter': 0.008, 'source_f0': 1000000.0, 'source_phase': 0.0, 'source_roc': 0.015, 'source_z_offset': 10, 't_end': 4e-05, 'threeD_domain_x_size': 0.01, 'threeD_domain_y_size': 0.01, 'threeD_domain_z_size': 0.02, 'upsampling_rate': 10, 'use_gpu': False, 'verbose_level': 1}
property cpp_engine

CUDA (gpu) or OMP (cpu)

property cpp_io_files_dir_path
get_kwave_cpp_cmd(kw_hash)[source]

Returns the command that needs to be executed to run a simulation using C++ kwave scripts from a terminal

property simulation_params

Holds the simulation parameters

set_simulation_param(param_name, value)[source]

Call to set simulation parameters

property dx

Kgrid spatial sampling in the x, y, z directions

property Nx

Number of spatial sampling points in the x direction

property Ny

Number of spatial sampling points in the y direction.

property Nz

Number of spatial sampling points in the z direction.

property ppp

Number of points per periods

property dt

Temporal sampling duration

property Nt

Number of temporal sampling steps

c(material_index=0)[source]

Map of material speeds of sound

rho(material_index=0)[source]

Map of material densities

alpha(material_index=0)[source]

alpha_0 term of the attenuation coeficient -> attenuation_coef = alpha * f^alpha_power

alpha_power(material_index=0)[source]

Frequency dependance of the attenuation coeficient -> attenuation_coef = alpha * f^alpha_power

alpha_corrected(material_index=0)[source]

Evaluating pseudo-alpha coeficient with k-Wave’s ‘stokes’ attenuation constraint of alpha_power=2

property kgrid

Wrapper for k-wave’s kgrid object

property kgrid_coords

kWave grid coordinates

property medium

Wrapper for k-wave’s medium object

property source

Wrapper for k-wave’s source object

property sensor

Wrapper for k-wave’s sensor object

run_simulation(io_h5files_directory_path=None)[source]

Call to run simulation. Returns True if computation / previous results loading successfull.

Return type:

bool

property pamp_phase_freq_xyz

Pressure magnitude and phase in the whole domain (XYZ).

property p_amp_xyz

Pressure magnitude in the whole domain (XYZ). Call pamp_phase_freq_xyz to get the phase