<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>k-Wave User Forum &#187; Recent Topics</title>
		<link>http://www.k-wave.org/forum/</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 19:08:03 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.k-wave.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.k-wave.org/forum/rss/topics" rel="self" type="application/rss+xml" />

		<item>
			<title>nakterm on "Getting RF data in k-wave"</title>
			<link>http://www.k-wave.org/forum/topic/getting-rf-data-in-k-wave#post-9249</link>
			<pubDate>Tue, 03 Mar 2026 15:38:06 +0000</pubDate>
			<dc:creator>nakterm</dc:creator>
			<guid isPermaLink="false">9249@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello&#60;/p&#62;
&#60;p&#62;What is the way to convert the pressure field from k-wave simulation to RF data? Can anyone please let me know.&#60;/p&#62;
&#60;p&#62;Thanks in advance.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>xf20228 on "Complete Beginner Question"</title>
			<link>http://www.k-wave.org/forum/topic/complete-beginner-question#post-9247</link>
			<pubDate>Tue, 17 Feb 2026 12:48:38 +0000</pubDate>
			<dc:creator>xf20228</dc:creator>
			<guid isPermaLink="false">9247@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi, &#60;/p&#62;
&#60;p&#62;I am working through the Homogeneous Propagation Medium Example but get this error when I run the example .m file:&#60;/p&#62;
&#60;p&#62;Arrays have incompatible sizes for this operation.&#60;/p&#62;
&#60;p&#62;Error in kspaceFirstOrder2D (line 920)&#60;br /&#62;
        ux_sgx = dt .* rho0_sgx_inv .* real(ifft2( bsxfun(@times, ddx_k_shift_pos, kappa .* fft2(p)) )) / 2;&#60;br /&#62;
                                                                                         ^&#60;br /&#62;
Error in example_ivp_homogeneous_medium (line 67)&#60;br /&#62;
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor);&#60;br /&#62;
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&#60;br /&#62;
So far, I have installed MATLAB R2025a, installed k-wave from add-ons, opened the example_ivp_homogeneous_medium.m file in the MATLAB editor, and run the code.&#60;/p&#62;
&#60;p&#62;If someone could tell me what I am doing wrong, I would appreciate it.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>GioF on "Axysimmetric simulations with kspaceFirstOrder-CUDA"</title>
			<link>http://www.k-wave.org/forum/topic/axysimmetric-simulations-with-kspacefirstorder-cuda#post-9246</link>
			<pubDate>Mon, 09 Feb 2026 13:31:57 +0000</pubDate>
			<dc:creator>GioF</dc:creator>
			<guid isPermaLink="false">9246@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I'm trying to move my simulations from MATLAB to C++ exploiting the kspaceFirstOrder executable. I managed to obtain comparable results with my axysimmetric simulation in MATLAB and the one from kspaceFirstOrder-OMP. I would like now to exploit the CUDA executable to speed up the computations, but I noticed that the axysimmetric simulation is not available for this executable. As moving to 3D will increase the computational burden, I was wondering if you are planning to maka the axysimmetric simulation available soon.&#60;br /&#62;
Thank you for your feedback!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>guojia on "The different values of the &#34;cycle&#34; in function &#34; toneBurst&#34; in HIFU simulation"</title>
			<link>http://www.k-wave.org/forum/topic/the-different-values-of-the-cycle-in-function-toneburst-in-hifu-simulation#post-9245</link>
			<pubDate>Thu, 29 Jan 2026 09:16:11 +0000</pubDate>
			<dc:creator>guojia</dc:creator>
			<guid isPermaLink="false">9245@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi everyone, recently, I have been using kWaveArray to simulate the phased array ultrasound focusing sound field. However, when using the function &#34; toneBurst&#34; , I found that the value of &#34;cycle&#34; must be large enough (≥500) to obtain reasonable results; otherwise, the gain of the focused sound field would be too high, which is not reasonable. Could you please tell me what the reason is? The code is as follows:&#60;/p&#62;
&#60;p&#62;input_args={'DisplayMask',source.p_mask + sensor.mask,...&#60;br /&#62;
            'DataCast','double',...&#60;br /&#62;
            'CartInterp','linear',...% 'CartInterp','nearest',...&#60;br /&#62;
            'PMLSize',[20 20 20],...&#60;br /&#62;
            'PMLAlpha',5,...&#60;br /&#62;
            'PMLInside',false};&#60;br /&#62;
sensor_data=kspaceFirstOrder3DG(kgrid,medium,source,sensor,input_args{:});&#60;/p&#62;
&#60;p&#62;% 求取各阵元延时&#60;br /&#62;
% [max_val,max_pos]=max(sensor_data,[],2);&#60;br /&#62;
% travel_time=max_pos;&#60;br /&#62;
% time_delays=max(travel_time)-travel_time;&#60;/p&#62;
&#60;p&#62;sig_rev=fliplr(sensor_data);&#60;br /&#62;
[max_val,max_pos]=max(sig_rev,[],2);&#60;br /&#62;
time_delays=max_pos-min(max_pos);&#60;/p&#62;
&#60;p&#62;focus_mask=source.p_mask;&#60;br /&#62;
source.p_mask=sensor.mask;&#60;br /&#62;
p0=0.1e6;&#60;br /&#62;
% source_cycle2=490;       % 能够聚焦，但是结果会发散，声压增益500倍&#60;br /&#62;
source_cycle2=500;&#60;br /&#62;
source.p=1e6*toneBurst(1/kgrid.dt,f0,source_cycle2,'SignalOffset',time_delays,'Envelope','Rectangular');&#60;/p&#62;
&#60;p&#62;sensor.mask=zeros(nx,ny,nz);&#60;br /&#62;
sensor.mask(Index_x-30:Index_x+30,Index_y-30:Index_y+30,:)=1;&#60;br /&#62;
sensor.record={'p','p_max_all'};&#60;br /&#62;
nT=100;&#60;br /&#62;
sensor.record_start_index=kgrid.Nt-T0/kgrid.dt*nT+1;&#60;/p&#62;
&#60;p&#62;It is currently unclear what specific reason caused this. I would greatly appreciate it if friends could help figure out exactly what the cause is. Thank you very much.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>toehead on "Thanks"</title>
			<link>http://www.k-wave.org/forum/topic/thanks#post-9244</link>
			<pubDate>Wed, 28 Jan 2026 17:12:35 +0000</pubDate>
			<dc:creator>toehead</dc:creator>
			<guid isPermaLink="false">9244@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I just wanted to say thank you for such an amazing toolbox. &#60;/p&#62;
&#60;p&#62;It was just what I needed and is very user-friendly.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Oskar Sadowski on "Time Reversal image reconstruction with kWaveArray elements"</title>
			<link>http://www.k-wave.org/forum/topic/time-reversal-image-reconstruction-with-kwavearray-elements#post-9243</link>
			<pubDate>Tue, 27 Jan 2026 11:00:38 +0000</pubDate>
			<dc:creator>Oskar Sadowski</dc:creator>
			<guid isPermaLink="false">9243@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello,&#60;br /&#62;
I'm still somewhat new to kWave and am trying to work out Time Reversal image reconstruction for a segmented ring array, created using kWaveArray (i.e. &#60;code&#62;addArcElement&#60;/code&#62; and &#60;code&#62;addCustomElement&#60;/code&#62;). During testing around, I noticed a unexpected behaviour, and would be grateful for some insights on the matter.&#60;/p&#62;
&#60;p&#62;I've put together a simple minimal example issued below to explain my problem. The geometry is simply a couple arc shaped elements equally distributed in a circular pattern, all with the same parameters and focus on (0,0). Identical signals (here just &#60;code&#62;toneBurst&#60;/code&#62;, the exact signal doesn't matter) are assigned to all elements using &#60;code&#62;sensor.time_reversal_boundary_data&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;I would expect each elements to send out the same signal, as they are identical and the geometry is symmetrical. However, the simulation process shows that the signal intensity differs quite heavily between different elements, with (as far as I can tell) the ones closer to the cartesian axes having a higher intensity assigned than the ones off-axis. The number of elements does not affect this behavior&#60;/p&#62;
&#60;p&#62;While I'm sure there is a proper explanation for this, that I'm just missing, I can not make sense of this behavior currently, and would be grateful for any advise on how to get the proper results. I should note that a identical result can be achieved when constructing the sensor as a source and setting &#60;code&#62;source.p_mode = &#38;#39;dirichlet&#38;#39;&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;Minimal example:&#60;/p&#62;
&#60;p&#62;clear; clearvars;&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% PARAMETERS&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;numElements     =   7;&#60;/p&#62;
&#60;p&#62;radius          =   1E-2;&#60;br /&#62;
sizeArc         =   1E-3;&#60;br /&#62;
focus           =   [0,0];&#60;/p&#62;
&#60;p&#62;gridSize        =   [2.5E-2, 2.5E-2];&#60;br /&#62;
gridN           =   [512, 512];&#60;br /&#62;
gridStep        =   [gridSize(1)/gridN(1), gridSize(2)/gridN(2)];&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% ELEMENT DEFINITION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;karray = kWaveArray;&#60;/p&#62;
&#60;p&#62;for i=1:numElements&#60;/p&#62;
&#60;p&#62;    pos = [radius*cosd(i*360/numElements), ...&#60;br /&#62;
           radius*sind(i*360/numElements)];&#60;br /&#62;
    karray.addArcElement(pos, radius, sizeArc, focus);&#60;/p&#62;
&#60;p&#62;end&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% GRID &#38;amp; MEDIUM PROPERTIES&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;medium.sound_speed  =   1520;&#60;br /&#62;
medium.density      =   1040;&#60;/p&#62;
&#60;p&#62;kgrid = kWaveGrid(gridN(1), gridStep(1), gridN(2), gridStep(2));&#60;br /&#62;
kgrid.makeTime(medium.sound_speed)&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% ASSIGN SOURCE &#38;amp; SENSOR&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;signal = repmat(toneBurst(1/kgrid.dt, 100E4, 24).*15, numElements, 1);&#60;/p&#62;
&#60;p&#62;source.p0 = 0;&#60;/p&#62;
&#60;p&#62;sensor.mask = karray.getArrayBinaryMask(kgrid);&#60;br /&#62;
sensor.time_reversal_boundary_data = karray.getDistributedSourceSignal(kgrid, signal);&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% RUN SIMULATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;simulation = kspaceFirstOrder2D(kgrid, medium, source, sensor, ...&#60;br /&#62;
                                'PMLInside', false, 'DataCast', 'gpuArray-single');&#60;/p&#62;
&#60;p&#62;figure;&#60;br /&#62;
imagesc(kgrid.y_vec, kgrid.x_vec, simulation)&#60;br /&#62;
axis image; colormap(&#34;gray&#34;)&#60;/p&#62;
&#60;p&#62;hold on;&#60;br /&#62;
karray.plotArray(false);
&#60;/p&#62;</description>
		</item>
		<item>
			<title>scmmw on "HIFU Wave through a heterogenous medium"</title>
			<link>http://www.k-wave.org/forum/topic/hifu-wave-through-a-heterogenous-medium#post-9242</link>
			<pubDate>Tue, 13 Jan 2026 16:35:52 +0000</pubDate>
			<dc:creator>scmmw</dc:creator>
			<guid isPermaLink="false">9242@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi, I'm trying to simulate a HIFU wave propagating through a heterogeneous medium (water, soft tissue, muscle, thyroid, and nodule). My simulation works as expected at 2 MHz, producing a lesion at the focus point. However, at 3 MHz, side lesions appear instead of a lesion at the focus. I'm unsure how to resolve this issue. Any help would be greatly appreciated!&#60;/p&#62;
&#60;p&#62;Here is my script (I have a lot of visualisations, this is just to help me understand the process)&#60;/p&#62;
&#60;p&#62;clearvars;&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% ACOUSTIC SIMULATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;%% define the PML size&#60;br /&#62;
pml_size = 20;              % [grid points]&#60;/p&#62;
&#60;p&#62;% define the grid parameters&#60;br /&#62;
Nx = 524 - 2 * pml_size;    % [grid points]&#60;br /&#62;
Ny = 427 - 2 * pml_size;    % [grid points]&#60;br /&#62;
dx = 206e-6;               % [m]&#60;br /&#62;
dy = 206e-6;               % [m]&#60;/p&#62;
&#60;p&#62;% create the computational grid&#60;br /&#62;
kgrid = kWaveGrid(Nx, dx, Ny, dy);&#60;/p&#62;
&#60;p&#62;% define the properties of the propagation medium&#60;br /&#62;
medium.sound_speed = zeros(Nx,Ny);  % [m/s]&#60;br /&#62;
medium.density     = zeros(Nx,Ny);  % [kg/m^3]&#60;br /&#62;
medium.alpha_coeff = zeros(Nx,Ny);  % [dB/(MHz^y cm)]&#60;/p&#62;
&#60;p&#62;water.sound_speed          = 1480;&#60;br /&#62;
water.density              = 1000;  % [kg/m^3]&#60;br /&#62;
water.alpha_coeff          = 0.0022;     % [dB/(MHz^y cm)]&#60;br /&#62;
water.alpha_power          = 1;&#60;/p&#62;
&#60;p&#62;tissue.sound_speed          = 1540;&#60;br /&#62;
tissue.density              = 1020;  % [kg/m^3]&#60;br /&#62;
tissue.alpha_coeff          = 0.75;  % [dB/(MHz^y cm)]&#60;br /&#62;
tissue.alpha_power          = 1.5;&#60;/p&#62;
&#60;p&#62;muscle.sound_speed          = 1588;&#60;br /&#62;
muscle.density              = 1090;  % [kg/m^3]&#60;br /&#62;
muscle.alpha_coeff          = 0.63;  % [dB/(MHz^y cm)]&#60;br /&#62;
muscle.alpha_power          = 1.3;&#60;/p&#62;
&#60;p&#62;thyroid.sound_speed          = 1585;&#60;br /&#62;
thyroid.density              = 1050;  % [kg/m^3]&#60;br /&#62;
thyroid.alpha_coeff          = 1.34;     % [dB/(MHz^y cm)]&#60;br /&#62;
thyroid.alpha_power          = 1.5;&#60;/p&#62;
&#60;p&#62;nodule.sound_speed          = 1583;&#60;br /&#62;
nodule.density              = 1080;  % [kg/m^3]&#60;br /&#62;
nodule.alpha_coeff          = 0.31;     % [dB/(MHz^y cm)]&#60;br /&#62;
nodule.alpha_power          = 1.1;&#60;/p&#62;
&#60;p&#62;% now break down the grid&#60;br /&#62;
% --- Water region -------------------------------------------------------&#60;br /&#62;
medium.sound_speed(1:156, :)     = water.sound_speed;&#60;br /&#62;
medium.density(1:156, :)         = water.density;&#60;br /&#62;
medium.alpha_coeff(1:156, :)     = water.alpha_coeff;&#60;/p&#62;
&#60;p&#62;% --- Tissue region -------------------------------------------------------&#60;br /&#62;
medium.sound_speed(157:341, :)     = tissue.sound_speed;&#60;br /&#62;
medium.density(157:341, :)         = tissue.density;&#60;br /&#62;
medium.alpha_coeff(157:341, :)     = tissue.alpha_coeff;&#60;br /&#62;
%medium.alpha_power(1:185, :)     = tissue.alpha_power;&#60;/p&#62;
&#60;p&#62;% --- Muscle region -------------------------------------------------------&#60;br /&#62;
medium.sound_speed(342:416, :)   = muscle.sound_speed;&#60;br /&#62;
medium.density(342:416, :)       = muscle.density;&#60;br /&#62;
medium.alpha_coeff(342:416, :)   = muscle.alpha_coeff;&#60;br /&#62;
%medium.alpha_power(186:260, :)   = muscle.alpha_power;&#60;/p&#62;
&#60;p&#62;% --- Thyroid region ------------------------------------------------------&#60;br /&#62;
medium.sound_speed(417:427, :)   = thyroid.sound_speed;&#60;br /&#62;
medium.density(417:427, :)       = thyroid.density;&#60;br /&#62;
medium.alpha_coeff(417:427, :)   = thyroid.alpha_coeff;&#60;br /&#62;
%medium.alpha_power(261:270, :)   = thyroid.alpha_power;&#60;/p&#62;
&#60;p&#62;% --- Nodule region -------------------------------------------------------&#60;br /&#62;
medium.sound_speed(427:end, :)    = nodule.sound_speed;&#60;br /&#62;
medium.density(427:end, :)        = nodule.density;&#60;br /&#62;
medium.alpha_coeff(427:end, :)    = nodule.alpha_coeff;&#60;br /&#62;
%medium.alpha_power(271:end, :)    = nodule.alpha_power;&#60;/p&#62;
&#60;p&#62;medium.sound_speed = smooth(medium.sound_speed, true);&#60;br /&#62;
medium.density     = smooth(medium.density, true);&#60;br /&#62;
medium.alpha_coeff = smooth(medium.alpha_coeff, true);&#60;/p&#62;
&#60;p&#62;% define the source parameters&#60;br /&#62;
diameter = 64e-3;           % [m]&#60;br /&#62;
radius   = 63.2e-3;         % [m]&#60;br /&#62;
aperture = 20e-3;           % [m]&#60;br /&#62;
freq     = 2e6;           % [Hz]&#60;br /&#62;
amp      = 0.5e6;           % [Pa]&#60;/p&#62;
&#60;p&#62;%% This may need running a few times to optimise alphafit to get best fit power value i.e. lines overlap as best as possible.&#60;br /&#62;
alpha_coeff_vec = [water.alpha_coeff, tissue.alpha_coeff, muscle.alpha_coeff, thyroid.alpha_coeff, nodule.alpha_coeff];&#60;br /&#62;
alpha_power_vec = [water.alpha_power,tissue.alpha_power, muscle.alpha_power, thyroid.alpha_power, nodule.alpha_power];&#60;br /&#62;
c_vec           = [water.sound_speed, tissue.sound_speed, muscle.sound_speed, thyroid.sound_speed, nodule.sound_speed];&#60;br /&#62;
alphaFit    = 1.5;&#60;br /&#62;
alpha_coeff_fit_vec = fitPowerLawParamsMulti(alpha_coeff_vec, alpha_power_vec, c_vec, freq, alphaFit, true);&#60;/p&#62;
&#60;p&#62;medium.alpha_power = alphaFit;&#60;/p&#62;
&#60;p&#62;%%&#60;br /&#62;
% --- Tissue ---&#60;br /&#62;
medium.alpha_coeff(1:156, :)  = alpha_coeff_fit_vec(1);&#60;/p&#62;
&#60;p&#62;% --- Tissue ---&#60;br /&#62;
medium.alpha_coeff(157:341, :) = alpha_coeff_fit_vec(2);&#60;/p&#62;
&#60;p&#62;% --- Muscle ---&#60;br /&#62;
medium.alpha_coeff(342:416, :)  = alpha_coeff_fit_vec(3);&#60;/p&#62;
&#60;p&#62;% --- Thyroid ---&#60;br /&#62;
medium.alpha_coeff(417:427, :)  = alpha_coeff_fit_vec(4);&#60;/p&#62;
&#60;p&#62;% --- Nodule ---&#60;br /&#62;
medium.alpha_coeff(427:end, :)   = alpha_coeff_fit_vec(5);&#60;/p&#62;
&#60;p&#62;%%&#60;br /&#62;
close all&#60;/p&#62;
&#60;p&#62;source.p_mask = zeros(Nx,Ny);&#60;/p&#62;
&#60;p&#62;% define a focused ultrasound transducer&#60;/p&#62;
&#60;p&#62;null_mask     = makeArc([Nx, Ny], [1, Ny/2], round(radius / dx), round(aperture / dx), [Nx/2, Ny/2]); % define aperture in transducer&#60;br /&#62;
source.p_mask = source.p_mask + makeArc([Nx, Ny], [1, Ny/2], round(radius / dx), round(diameter / dx), [Nx/2, Ny/2]) - null_mask;&#60;/p&#62;
&#60;p&#62;% calculate the time step using an integer number of points per period&#60;br /&#62;
ppw = mean(mean(medium.sound_speed)) / (freq * dx); % points per wavelength&#60;br /&#62;
cfl = 0.3;                              % cfl number&#60;br /&#62;
ppp = ceil(ppw / cfl);                  % points per period&#60;br /&#62;
T   = 1 / freq;                         % period [s]&#60;br /&#62;
dt  = T / ppp;                          % time step [s]&#60;/p&#62;
&#60;p&#62;% calculate the number of time steps to reach steady state&#60;br /&#62;
t_end = sqrt( kgrid.x_size.^2 + kgrid.y_size.^2 ) / mean(mean(medium.sound_speed));&#60;br /&#62;
Nt = round(t_end / dt);&#60;/p&#62;
&#60;p&#62;% create the time array&#60;br /&#62;
kgrid.setTime(Nt, dt);&#60;/p&#62;
&#60;p&#62;% define the input signal&#60;br /&#62;
source.p = createCWSignals(kgrid.t_array, freq, amp, 0);&#60;/p&#62;
&#60;p&#62;% set the sensor mask to cover the entire grid&#60;br /&#62;
sensor.mask = ones(Nx, Ny);&#60;br /&#62;
sensor.record = {'p', 'p_max_all'};&#60;/p&#62;
&#60;p&#62;% record the last 3 cycles in steady state&#60;br /&#62;
num_periods = 3;&#60;br /&#62;
T_points = round(num_periods * T / kgrid.dt);&#60;br /&#62;
sensor.record_start_index = Nt - T_points + 1;&#60;/p&#62;
&#60;p&#62;% set the input arguements&#60;br /&#62;
input_args = {'PMLInside', false, 'PlotPML', false, 'DisplayMask', ...&#60;br /&#62;
    'off', 'PlotScale', [-1, 1] * amp};&#60;/p&#62;
&#60;p&#62;% run the acoustic simulation&#60;br /&#62;
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% CALCULATE HEATING&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% convert the absorption coefficient to nepers/m&#60;br /&#62;
alpha_np = db2neper(medium.alpha_coeff, medium.alpha_power) * ...&#60;br /&#62;
    (2 * pi * freq).^medium.alpha_power;&#60;/p&#62;
&#60;p&#62;% extract the pressure amplitude at each position&#60;br /&#62;
p = extractAmpPhase(sensor_data.p, 1/kgrid.dt, freq);&#60;/p&#62;
&#60;p&#62;% reshape the data, and calculate the volume rate of heat deposition&#60;br /&#62;
p = reshape(p, Nx, Ny);&#60;br /&#62;
Q = alpha_np .* p.^2 ./ (medium.density .* medium.sound_speed);&#60;/p&#62;
&#60;p&#62;% Find the location of maximum heat deposition&#60;br /&#62;
[maxQ, idxMaxQ] = max(Q(:));&#60;br /&#62;
[rowMax, colMax] = ind2sub(size(Q), idxMaxQ);&#60;/p&#62;
&#60;p&#62;% Place the thermal sensor at that location&#60;br /&#62;
sensor.mask = zeros(Nx, Ny);&#60;br /&#62;
sensor.mask(rowMax, colMax) = 1;&#60;/p&#62;
&#60;p&#62;% Report coordinates&#60;br /&#62;
fprintf('Thermal sensor placed at row=%d, col=%d (x=%.3f m, y=%.3f m)\n', ...&#60;br /&#62;
    rowMax, colMax, kgrid.x_vec(rowMax), kgrid.y_vec(colMax));&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% THERMAL SIMULATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% clear the input structures&#60;br /&#62;
%clear source sensor; %medium&#60;/p&#62;
&#60;p&#62;% set the background temperature and heating term&#60;br /&#62;
source.Q  = Q;&#60;br /&#62;
source.T0 = 37;&#60;/p&#62;
&#60;p&#62;medium.thermal_conductivity = zeros(Nx,Ny); % [W/(m.K)]&#60;br /&#62;
medium.specific_heat        = zeros(Nx,Ny); % [J/(kg.K)]&#60;/p&#62;
&#60;p&#62;water.thermal_conductivity = 0.598; % [W/(m.K)]&#60;br /&#62;
water.specific_heat        = 4200;  % [J/(kg.K)]&#60;/p&#62;
&#60;p&#62;tissue.thermal_conductivity = 0.5;   % [W/(m.K)]&#60;br /&#62;
tissue.specific_heat        = 3600;  % [J/(kg.K)]&#60;/p&#62;
&#60;p&#62;muscle.thermal_conductivity = 	0.49;&#60;br /&#62;
muscle.specific_heat = 3421;&#60;/p&#62;
&#60;p&#62;thyroid.thermal_conductivity = 0.5;&#60;br /&#62;
thyroid.specific_heat = 3826;&#60;/p&#62;
&#60;p&#62;nodule.thermal_conductivity = 0.5;&#60;br /&#62;
nodule.specific_heat = 3826;&#60;/p&#62;
&#60;p&#62;% --- Water region -------------------------------------------------------&#60;br /&#62;
medium.thermal_conductivity(1:156, :)     = water.thermal_conductivity;&#60;br /&#62;
medium.specific_heat(1:156, :)       = water.specific_heat;&#60;/p&#62;
&#60;p&#62;% --- Tissue region -------------------------------------------------------&#60;br /&#62;
medium.thermal_conductivity(157:341, :)    = tissue.thermal_conductivity;&#60;br /&#62;
medium.specific_heat(157:341, :)        = tissue.specific_heat;&#60;/p&#62;
&#60;p&#62;% --- Muscle region -------------------------------------------------------&#60;br /&#62;
medium.thermal_conductivity(342:416, :)   = muscle.thermal_conductivity;&#60;br /&#62;
medium.specific_heat(342:416, :)       = muscle.specific_heat;&#60;/p&#62;
&#60;p&#62;% --- Thyroid region ------------------------------------------------------&#60;br /&#62;
medium.thermal_conductivity(417:427, :)  = thyroid.thermal_conductivity;&#60;br /&#62;
medium.specific_heat(417:427, :)      = thyroid.specific_heat;&#60;/p&#62;
&#60;p&#62;% --- Nodule region -------------------------------------------------------&#60;br /&#62;
medium.thermal_conductivity(427:end, :)     = nodule.thermal_conductivity;&#60;br /&#62;
medium.specific_heat(427:end, :)       = nodule.specific_heat;&#60;/p&#62;
&#60;p&#62;% create kWaveDiffusion object&#60;br /&#62;
kdiff = kWaveDiffusion(kgrid, medium, source, sensor);&#60;/p&#62;
&#60;p&#62;% set source on time and off time&#60;br /&#62;
on_time  = 10;  % [s]&#60;br /&#62;
off_time = 200;  % [s]&#60;/p&#62;
&#60;p&#62;% set time step size&#60;br /&#62;
dt = 0.1;&#60;/p&#62;
&#60;p&#62;% Number of timesteps for the entire heating period&#60;br /&#62;
num_steps = round(on_time / dt);&#60;/p&#62;
&#60;p&#62;% Initialize a container for CEM43 values at each timestep&#60;br /&#62;
cem43_values = zeros(1, num_steps);&#60;/p&#62;
&#60;p&#62;% Initialize variable to store the time when CEM43 exceeds 240&#60;br /&#62;
time_cem43_exceeded = NaN;  % Default to NaN (not exceeded yet)&#60;/p&#62;
&#60;p&#62;% Iterate over each timestep&#60;br /&#62;
for step = 1:num_steps&#60;br /&#62;
    % Take one timestep&#60;br /&#62;
    kdiff.takeTimeStep(1, dt);&#60;/p&#62;
&#60;p&#62;    % Record CEM43 value at the sensor location&#60;br /&#62;
    cem43_values(step) = max(kdiff.cem43(sensor.mask == 1));  % Assuming you want the max CEM43 at the sensor position&#60;/p&#62;
&#60;p&#62;    % Display the CEM43 value and time&#60;br /&#62;
    %fprintf('Time: %.2f s, CEM43: %.2f\n', step * dt, cem43_values(step));&#60;/p&#62;
&#60;p&#62;    % Check if CEM43 exceeds 240&#60;br /&#62;
    if cem43_values(step) &#38;gt;= 240 &#38;amp;&#38;amp; isnan(time_cem43_exceeded)&#60;br /&#62;
        time_cem43_exceeded = step * dt;  % Record the time when it exceeds 240&#60;br /&#62;
        fprintf('CEM43 exceeded 240 at time %.2f s.\n', time_cem43_exceeded);&#60;br /&#62;
    end&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;% After the loop, you can use time_cem43_exceeded to check when the threshold was met&#60;br /&#62;
if ~isnan(time_cem43_exceeded)&#60;br /&#62;
    fprintf('CEM43 exceeded 240 at %.2f seconds during the simulation.\n', time_cem43_exceeded);&#60;br /&#62;
else&#60;br /&#62;
    disp('CEM43 did not exceed 240 during the simulation.');&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;% store the current temperature field&#60;br /&#62;
T1 = kdiff.T;&#60;br /&#62;
    if max(max(T1)) &#38;gt;= 100&#60;br /&#62;
        disp('Boiling occured');&#60;br /&#62;
    end&#60;/p&#62;
&#60;p&#62;% turn off heat source and take time steps&#60;br /&#62;
kdiff.Q = 0;&#60;br /&#62;
kdiff.takeTimeStep(round(off_time / dt), dt);&#60;/p&#62;
&#60;p&#62;% store the current temperature field&#60;br /&#62;
T2 = kdiff.T;&#60;/p&#62;
&#60;p&#62;[max_dose, idx_dose] = max(kdiff.cem43(:));  % Find max thermal dose and index&#60;br /&#62;
[row_dose, col_dose] = ind2sub(size(kdiff.cem43), idx_dose);  % Get coordinates&#60;/p&#62;
&#60;p&#62;% Get the x and y coordinates of the maximum thermal dose&#60;br /&#62;
center_x_dose = kgrid.x_vec(row_dose);&#60;br /&#62;
center_y_dose = kgrid.y_vec(col_dose);&#60;/p&#62;
&#60;p&#62;% Display the result&#60;br /&#62;
disp(['Center of Thermal Dose: x = ', num2str(center_x_dose), ' m, y = ', num2str(center_y_dose), ' m']);&#60;br /&#62;
disp(['Center of Thermal Dose: x = ', num2str(row_dose), ' , y = ', num2str(col_dose), ' ']);&#60;/p&#62;
&#60;p&#62;%% break&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% VISUALISATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% Define the intensity threshold for ablated tissue&#60;br /&#62;
threshold = 0.99; % Values close to 1 indicate ablated tissue&#60;/p&#62;
&#60;p&#62;% Create a binary mask of the ablated region&#60;br /&#62;
binary_mask = kdiff.lesion_map &#38;gt;= threshold;&#60;/p&#62;
&#60;p&#62;% Find the rows and columns where the ablated tissue exists&#60;br /&#62;
[row_idx, col_idx] = find(binary_mask);&#60;/p&#62;
&#60;p&#62;% Add half the grid spacing to account for pixel edges&#60;br /&#62;
min_x = min(kgrid.x_vec(row_idx)) - abs(kgrid.x_vec(2) - kgrid.x_vec(1)) / 2;&#60;br /&#62;
max_x = max(kgrid.x_vec(row_idx)) + abs(kgrid.x_vec(2) - kgrid.x_vec(1)) / 2;&#60;br /&#62;
min_y = min(kgrid.y_vec(col_idx)) - abs(kgrid.y_vec(2) - kgrid.y_vec(1)) / 2;&#60;br /&#62;
max_y = max(kgrid.y_vec(col_idx)) + abs(kgrid.y_vec(2) - kgrid.y_vec(1)) / 2;&#60;/p&#62;
&#60;p&#62;% Compute the adjusted dimensions&#60;br /&#62;
length_ablated = (max_x - min_x) * 1e3; % in mm&#60;br /&#62;
width_ablated = (max_y - min_y) * 1e3;  % in mm&#60;/p&#62;
&#60;p&#62;% Display the results&#60;br /&#62;
fprintf('Ablated Tissue Dimensions:\n');&#60;br /&#62;
fprintf('Length: %.2f mm\n', length_ablated);&#60;br /&#62;
fprintf('Width: %.2f mm\n', width_ablated);&#60;/p&#62;
&#60;p&#62;% Optional: Visualize the lesion map with bounding box&#60;br /&#62;
figure;&#60;br /&#62;
imagesc(kgrid.y_vec * 1e3, kgrid.x_vec * 1e3, kdiff.lesion_map, [0, 1]);&#60;br /&#62;
colorbar;&#60;br /&#62;
xlabel('y-position [mm]');&#60;br /&#62;
ylabel('x-position [mm]');&#60;br /&#62;
axis image;&#60;br /&#62;
title('Ablated Tissue');&#60;/p&#62;
&#60;p&#62;% Use adjusted bounds in the rectangle function&#60;br /&#62;
rectangle('Position', [min_y * 1e3, min_x * 1e3, ...&#60;br /&#62;
          width_ablated, length_ablated], ...&#60;br /&#62;
          'EdgeColor', 'r', 'LineWidth', 1.5);&#60;/p&#62;
&#60;p&#62;% Create time axis for the recorded data&#60;br /&#62;
t_axis = (0:kdiff.time_steps_taken - 1) * dt;&#60;/p&#62;
&#60;p&#62;% Plot temperature at every grid point (optional: you can visualize data at a specific point)&#60;br /&#62;
figure;&#60;br /&#62;
imagesc(kgrid.y_vec * 1e3, kgrid.x_vec * 1e3, kdiff.sensor_data(:,:,end));  % Plot temperature at last time step&#60;br /&#62;
colorbar;&#60;br /&#62;
xlabel('y-position [mm]');&#60;br /&#62;
ylabel('x-position [mm]');&#60;br /&#62;
title('Temperature at Last Time Step');&#60;/p&#62;
&#60;p&#62;% Plot temperature time profile&#60;br /&#62;
figure;&#60;br /&#62;
plot(t_axis, kdiff.sensor_data, 'LineWidth', 1.5); % Enhanced line width for better visibility&#60;br /&#62;
xlabel('Time [s]');&#60;br /&#62;
ylabel('Temperature [^\circC]');&#60;/p&#62;
&#60;p&#62;% Add grid lines&#60;br /&#62;
grid on; % Turns on the grid&#60;/p&#62;
&#60;p&#62;% Customize y-axis ticks&#60;br /&#62;
ylim([floor(min(kdiff.sensor_data(:))), ceil(max(kdiff.sensor_data(:)))]); % Ensure y-axis limits encompass the data&#60;br /&#62;
yticks(floor(min(kdiff.sensor_data(:))):1:ceil(max(kdiff.sensor_data(:)))); % Set ticks with a step of 1&#60;/p&#62;
&#60;p&#62;% Optionally add a title&#60;br /&#62;
title('Temperature Time Profile');&#60;/p&#62;
&#60;p&#62;% plot the thermal dose and lesion map&#60;br /&#62;
figure;&#60;/p&#62;
&#60;p&#62;% plot the acoustic pressure&#60;br /&#62;
subplot(2, 3, 1);&#60;br /&#62;
imagesc(kgrid.y_vec * 1e3, kgrid.x_vec * 1e3, p * 1e-6);&#60;br /&#62;
h = colorbar;&#60;br /&#62;
xlabel(h, '[MPa]');&#60;br /&#62;
ylabel('x-position [mm]');&#60;br /&#62;
xlabel('y-position [mm]');&#60;br /&#62;
axis image;&#60;br /&#62;
title('Acoustic Pressure Amplitude');&#60;/p&#62;
&#60;p&#62;% plot the volume rate of heat deposition&#60;br /&#62;
subplot(2, 3, 2);&#60;br /&#62;
imagesc(kgrid.y_vec * 1e3, kgrid.x_vec * 1e3, Q * 1e-7);&#60;br /&#62;
h = colorbar;&#60;br /&#62;
xlabel(h, '[kW/cm^2]');&#60;br /&#62;
ylabel('x-position [mm]');&#60;br /&#62;
xlabel('y-position [mm]');&#60;br /&#62;
axis image;&#60;br /&#62;
title('Volume Rate Of Heat Deposition');&#60;/p&#62;
&#60;p&#62;% plot the temperature after heating&#60;br /&#62;
subplot(2, 3, 3);&#60;br /&#62;
imagesc(kgrid.y_vec * 1e3, kgrid.x_vec * 1e3, T1);&#60;br /&#62;
h = colorbar;&#60;br /&#62;
xlabel(h, '[degC]');&#60;br /&#62;
ylabel('x-position [mm]');&#60;br /&#62;
xlabel('y-position [mm]');&#60;br /&#62;
axis image;&#60;br /&#62;
title('Temperature After Heating');&#60;/p&#62;
&#60;p&#62;% plot the temperature after cooling&#60;br /&#62;
subplot(2, 3, 4);&#60;br /&#62;
imagesc(kgrid.y_vec * 1e3, kgrid.x_vec * 1e3, T2);&#60;br /&#62;
h = colorbar;&#60;br /&#62;
xlabel(h, '[degC]');&#60;br /&#62;
ylabel('x-position [mm]');&#60;br /&#62;
xlabel('y-position [mm]');&#60;br /&#62;
axis image;&#60;br /&#62;
title('Temperature After Cooling');&#60;/p&#62;
&#60;p&#62;% plot thermal dose&#60;br /&#62;
subplot(2, 3, 5);&#60;br /&#62;
imagesc(kgrid.y_vec * 1e3, kgrid.x_vec * 1e3, kdiff.cem43, [0, 1000]);&#60;br /&#62;
h = colorbar;&#60;br /&#62;
xlabel(h, '[CEM43]');&#60;br /&#62;
ylabel('x-position [mm]');&#60;br /&#62;
xlabel('y-position [mm]');&#60;br /&#62;
axis image;&#60;br /&#62;
title('Thermal Dose');&#60;/p&#62;
&#60;p&#62;% plot lesion map&#60;br /&#62;
subplot(2, 3, 6);&#60;br /&#62;
imagesc(kgrid.y_vec * 1e3, kgrid.x_vec * 1e3, kdiff.lesion_map, [0, 1]);&#60;br /&#62;
colorbar;&#60;br /&#62;
ylabel('x-position [mm]');&#60;br /&#62;
xlabel('y-position [mm]');&#60;br /&#62;
axis image;&#60;br /&#62;
title('Ablated Tissue');&#60;/p&#62;
&#60;p&#62;% set colormap and enlarge figure window&#60;br /&#62;
colormap(jet(256));&#60;br /&#62;
scaleFig(1.5, 1);
&#60;/p&#62;</description>
		</item>
		<item>
			<title>amadou on "Artifact pattern (chevron-like) in 2D (and 3D) k-Wave simulation with linear arr"</title>
			<link>http://www.k-wave.org/forum/topic/artifact-pattern-chevron-like-in-2d-and-3d-k-wave-simulation-with-linear-arr#post-9241</link>
			<pubDate>Thu, 16 Oct 2025 16:39:01 +0000</pubDate>
			<dc:creator>amadou</dc:creator>
			<guid isPermaLink="false">9241@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Dear k-Wave team,&#60;/p&#62;
&#60;p&#62;I’m currently running a 2D simulation using kspaceFirstOrder2DG to model ultrasound propagation of a plane wave at 0° from a linear array source in water (L11-5), and I’m observing a strong “chevron-like” interference pattern in the reference medium (homogeneous water).&#60;br /&#62;
This pattern looks like crossed diagonal bands, even though the medium is fully homogeneous.I define the sources using karraysources class. My grid size is 1/15 of the wavelengt&#60;/p&#62;
&#60;p&#62;The same simulation were also conducted in 3D considering probe elevation of 5 mm and using kwave_transducer. &#60;/p&#62;
&#60;p&#62;If the simulatios are run with a kerf (both 2D and 3D) of some grid points, the issue is amplificated and the artifacts become stronger. At lower frequencies, these artifacts are still present but at a smaller scale. &#60;/p&#62;
&#60;p&#62; Here are the main parameters of my setup:&#60;/p&#62;
&#60;p&#62;fc = 7.6e6;                 % Central frequency&#60;br /&#62;
c_water = 1540;             % Sound speed in water&#60;br /&#62;
rho_water = 1000;           % Density&#60;br /&#62;
ppw = 15;                   % Points per wavelength&#60;br /&#62;
dx = floor((c_water/fc/ppw)*1e5)*1e-5;&#60;br /&#62;
dy = dx;&#60;/p&#62;
&#60;p&#62;N_elements = 64;&#60;br /&#62;
pitch_m = 300e-6;&#60;br /&#62;
elem_width_m = pitch_m;&#60;br /&#62;
ix_probe = round(1e-3/dx)+1;&#60;br /&#62;
tone_burst_cycles=3;&#60;br /&#62;
win = hanning(N_elements);&#60;br /&#62;
source_signal = toneBurst(1/kgrid.dt, fc, tone_burst_cycles);&#60;/p&#62;
&#60;p&#62;PML_size = 30;&#60;br /&#62;
PML_alpha =4; % higher values were also used but no change&#60;br /&#62;
cfl = 0.15;&#60;/p&#62;
&#60;p&#62;`&#60;br /&#62;
The transducer and sensor are both linear arrays located at ix_probe (which is 1mm away from the boundary).&#60;br /&#62;
I’m running two simulations (one with scatterers, one reference), then subtracting their pressure fields.&#60;br /&#62;
However, even in the reference case (homogeneous water), I see this strong interference pattern (see attached figure).&#60;/p&#62;
&#60;p&#62;My questions are:&#60;/p&#62;
&#60;p&#62;    Is this interference pattern expected given my pitch (300 µm) and frequency (7.6 MHz)?&#60;/p&#62;
&#60;p&#62;    Could it be a spatial aliasing or grating-lobe effect related to the array discretization?&#60;/p&#62;
&#60;p&#62;    Are there recommended values for pitch, element_width, or PML parameters to avoid these artifacts in k-Wave 2D simulations?&#60;/p&#62;
&#60;p&#62;    Would reducing the pitch below λ/2 or adjusting the apodization help mitigate this?&#60;/p&#62;
&#60;p&#62;Any insight or guidance on proper transducer discretization or grid setup to avoid this pattern would be greatly appreciated.&#60;/p&#62;
&#60;p&#62;Best regards,&#60;/p&#62;
&#60;p&#62;Amadou
&#60;/p&#62;</description>
		</item>
		<item>
			<title>antonio.marzoa on "Issues with beam propagation when comparing two different examples"</title>
			<link>http://www.k-wave.org/forum/topic/issues-with-beam-propagation-when-comparing-two-different-examples#post-9240</link>
			<pubDate>Wed, 08 Oct 2025 01:06:40 +0000</pubDate>
			<dc:creator>antonio.marzoa</dc:creator>
			<guid isPermaLink="false">9240@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi all,&#60;/p&#62;
&#60;p&#62;I am simulating the propagation in water of a beam generated by a single focused transducer (focal length = 100 mm, aperture diameter = 64 mm, operating frequency = 1.1 MHz, initial pressure = 100 kPa) with different examples from the toolbox. I've done with the &#34;Heating By A Focused Ultrasound Transducer&#34; script and by using the &#34;example_at_focused_bowl_3D&#34; script. I am using the same parameters for the transducer and for the medium in both examples, however, the peak pressure at focus is of 0.5 MPa in the former and of 2.5 MPa when running the later. Does anybody had encounter with this issue before? What could be happening?&#60;br /&#62;
Thanks!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>antonio.marzoa on "Obtaining pressure axial plots and issues using example_at_focused_bowl_3D.m"</title>
			<link>http://www.k-wave.org/forum/topic/obtaining-pressure-axial-plots-and-issues-using-example_at_focused_bowl_3dm#post-9232</link>
			<pubDate>Mon, 15 Sep 2025 18:30:04 +0000</pubDate>
			<dc:creator>antonio.marzoa</dc:creator>
			<guid isPermaLink="false">9232@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi everyone,&#60;/p&#62;
&#60;p&#62;I am trying to simulate the behaviour of a focused spherical ultrasound transducer (64 mm diameter, 100 mm focal length, operating at 1.1 MHz) in water. I am particularly interested in obtaining an axial plot of the pressure and I was using the example_at_focused_bowl_3D.m file to do so, however, it seems that the example does not complete simulating my transducer, as the pressure field map obtained is constant (zero) before reaching the focal position (the simulation is completed, taking almost 2h to complete). Then the axial plot is obtained in which the exact O’Neil solution is perfectly plotted, but the k-wave numerical computation goes to be zero before reaching the focal position. I tried to compare the results with other software’s (like HIFU Beam) but since the k-wave computation is null for most of the region, I couldn’t.&#60;/p&#62;
&#60;p&#62;The issue didn’t occur with the original example parameters and I am using these for my simulation:&#60;/p&#62;
&#60;p&#62;% medium parameters&#60;br /&#62;
c0              = 1500;     % sound speed [m/s]&#60;br /&#62;
rho0            = 1000;     % density [kg/m^3]&#60;/p&#62;
&#60;p&#62;% source parameters&#60;br /&#62;
source_f0       = 1.1e6;      % source frequency [Hz]&#60;br /&#62;
source_roc      = 100e-3;    % bowl radius of curvature [m]&#60;br /&#62;
source_diameter = 64e-3;    % bowl aperture diameter [m]&#60;br /&#62;
source_amp      = 0.879e6;      % source pressure [Pa]&#60;/p&#62;
&#60;p&#62;% grid parameters&#60;br /&#62;
axial_size      = 120e-3;    % total grid size in the axial dimension [m]&#60;br /&#62;
lateral_size    = 120e-3;    % total grid size in the lateral dimension [m]&#60;/p&#62;
&#60;p&#62;Does anybody have come across something like this before?&#60;br /&#62;
As an alternative I am running the example_diff_focused_ultrasound_heating.m and I was trying to extract the 2D plot of the axial pressure. Any ideas to do so?&#60;/p&#62;
&#60;p&#62;Thank you in advance.&#60;br /&#62;
All the best,&#60;/p&#62;
&#60;p&#62;Tony
&#60;/p&#62;</description>
		</item>
		<item>
			<title>sgb2155 on "Instability Simulating a Constant Volume Force"</title>
			<link>http://www.k-wave.org/forum/topic/instability-simulating-a-constant-volume-force#post-9236</link>
			<pubDate>Thu, 18 Sep 2025 22:12:39 +0000</pubDate>
			<dc:creator>sgb2155</dc:creator>
			<guid isPermaLink="false">9236@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I am running a simulation based on the elastic wave propagation example for pstd3dElastic(). &#60;/p&#62;
&#60;p&#62;I'm first running my simulation as described in the example to reach a steady state. I am then simulating a longer period, where instead of the velocity input as described in the example, I am simulating a volumetric velocity input based on the steady state (a constant velocity field spanning my whole volume, derived from the acoustic radiation force). &#60;/p&#62;
&#60;p&#62;I am able to simulate for exactly one time step with this volumetric input before reaching an instability and getting only NaN outputs. I've experimented with lowering my frequency (0.5e6) and reducing my CFL (0.08), but the former didn't get me any further than the first time step with my velocity field, and the latter led to issues with RAM. I have confirmed that my velocity field input contains real values across my simulated time range, so it does appear to me to be a convergence issue to me, but I want to make sure I am headed towards a solution and not completely in the wrong direction.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Artyom on "Hydroacoustic, boundary conditions and sound propagation"</title>
			<link>http://www.k-wave.org/forum/topic/hydroacoustic-boundary-conditions-and-sound-propagation#post-9233</link>
			<pubDate>Mon, 15 Sep 2025 20:25:47 +0000</pubDate>
			<dc:creator>Artyom</dc:creator>
			<guid isPermaLink="false">9233@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello everyone,&#60;/p&#62;
&#60;p&#62;First, let me introduce myself: my name is Artem, and I am a student at the Faculty of Physics. In my research work at the Department of Acoustics, I have been using k-Wave for about six months now to numerically model sound propagation in a coastal wedge. There are a few nuances I would like to clarify, as they are preventing me from fully converging my results with the analytical solution.&#60;/p&#62;
&#60;p&#62;Here’s the issue: I am currently trying to numerically solve the problem of sound propagation in an ideal fluid wedge with acoustically soft boundaries using k-Wave. The analytical solution for this scenario is presented in the paper by Buckingham and Tolstoy (1990). In k-Wave, I’ve encountered a problem where I cannot set boundary conditions on the wedge edges—specifically, the requirement that the acoustic pressure must be zero at the boundaries. Most likely, this is the reason I am unable to achieve full convergence with the analytical solution. Therefore, I would like to know if it is possible to set such boundary conditions in k-Wave, or whether k-Wave automatically accounts for these boundary conditions based on the defined medium model.&#60;/p&#62;
&#60;p&#62;Thank you to anyone who responds and helps me resolve this issue!&#60;/p&#62;
&#60;p&#62;Best regards,&#60;br /&#62;
Artyom
&#60;/p&#62;</description>
		</item>
		<item>
			<title>atandri on "Adding elements in kArray"</title>
			<link>http://www.k-wave.org/forum/topic/adding-elements-in-karray#post-9231</link>
			<pubDate>Thu, 04 Sep 2025 20:52:23 +0000</pubDate>
			<dc:creator>atandri</dc:creator>
			<guid isPermaLink="false">9231@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I am having some trouble creating sensical shapes when rotating kArray 2D elements in a 3D simulation. For example, the addRectElement makes a flat rectangle structure when the angle of rotation is [0,0,0], but with any other angle of rotation, it forms a 3D rectangular prism with + shaped structures on the end when the binary mask is visualized in volumeViewer or similar. I have found this to be the case with other element shapes as well when rotated. Is there a fix for this to obtain the expected rotated structures?&#60;/p&#62;
&#60;p&#62;Sample code:&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% DEFINE THE K-WAVE GRID&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% set the size of the perfectly matched layer (PML)&#60;br /&#62;
PML_X_SIZE = 10;            % [grid points]&#60;br /&#62;
PML_Y_SIZE = 10;            % [grid points]&#60;br /&#62;
PML_Z_SIZE = 10;            % [grid points]&#60;br /&#62;
PML_size = [PML_X_SIZE, PML_Y_SIZE, PML_Z_SIZE];&#60;br /&#62;
% set total number of grid points not including the PML&#60;br /&#62;
Nx = 256 - 2*PML_X_SIZE;    % [grid points]&#60;br /&#62;
Ny = 256 - 2*PML_Y_SIZE;     % [grid points]&#60;br /&#62;
Nz = 256 - 2*PML_Z_SIZE;     % [grid points]&#60;br /&#62;
grid_size = [Nx, Ny, Nz];&#60;/p&#62;
&#60;p&#62;% calculate the spacing between the grid points&#60;br /&#62;
dx = 2e-4;                % [m]&#60;br /&#62;
dy = dx;                    % [m]&#60;br /&#62;
dz = dx;                    % [m]&#60;/p&#62;
&#60;p&#62;% create the k-space grid&#60;br /&#62;
kgrid = kWaveGrid(Nx, dx, Ny, dy, Nz, dz);&#60;/p&#62;
&#60;p&#62;%% =========================================================================&#60;br /&#62;
% DEFINE KARRAY&#60;br /&#62;
% =========================================================================&#60;br /&#62;
karray = kWaveArray;&#60;/p&#62;
&#60;p&#62;karray.addRectElement([-6e-3,1.5e-3,0],5e-3, 2e-4, [90, 0, 0]);&#60;br /&#62;
source_mask = karray.getArrayBinaryMask(kgrid);&#60;/p&#62;
&#60;p&#62;slice(single(source_mask), 127,88,118);&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
Edit: My apologies, it seems I have submitted this under the wrong forum subject but there is no way to delete.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ukilic on "Concave ring transducer"</title>
			<link>http://www.k-wave.org/forum/topic/concave-ring-transducer#post-9222</link>
			<pubDate>Tue, 15 Jul 2025 22:19:15 +0000</pubDate>
			<dc:creator>ukilic</dc:creator>
			<guid isPermaLink="false">9222@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi everyone,&#60;/p&#62;
&#60;p&#62;I try to simulate a concave ring transducer. addDisc is good for flat transducers. My transducer is better fit for addBowl but then I cannot put more input, eg. inner diameter.&#60;br /&#62;
Any ideas?&#60;/p&#62;
&#60;p&#62;Thanks a lot! BTW- it is single element sonic concept H233
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ujjal on "Issue with Accessing k-Wave GPU Code on Ubuntu 24"</title>
			<link>http://www.k-wave.org/forum/topic/issue-with-accessing-k-wave-gpu-code-on-ubuntu-24#post-9204</link>
			<pubDate>Sat, 05 Apr 2025 06:40:53 +0000</pubDate>
			<dc:creator>ujjal</dc:creator>
			<guid isPermaLink="false">9204@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi everyone,&#60;/p&#62;
&#60;p&#62;We are trying to access MATLAB (k-Wave) GPU code on Ubuntu 24. Our system configuration is as follows: CUDA Device: NVIDIA RTX A4000&#60;/p&#62;
&#60;p&#62;CUDA Toolkit Version: 12.2.0&#60;/p&#62;
&#60;p&#62;NVIDIA-SMI: 535.230.02&#60;/p&#62;
&#60;p&#62;Driver Version: 535.230.02&#60;/p&#62;
&#60;p&#62;CUDA Version: 12.2&#60;/p&#62;
&#60;p&#62;MATLAB Version: R2024b&#60;/p&#62;
&#60;p&#62;k-Wave Toolbox Version: 1.4&#60;/p&#62;
&#60;p&#62;k-Wave Toolbox Version (CUDA): 1.3 (CPP Linux Binaries)&#60;/p&#62;
&#60;p&#62;When we run the following command in MATLAB: sensor_data = kspaceFirstOrder2DG(kgrid, medium, source, sensor, input_args{:}, 'RecordMovie', false, 'DataCast', 'single');&#60;/p&#62;
&#60;p&#62;We encounter the following error message:&#60;br /&#62;
┌───────────────────────────────────────────────────────────────┐&#60;br /&#62;
│                  kspaceFirstOrder-CUDA v1.3                   │&#60;br /&#62;
├───────────────────────────────────────────────────────────────┤&#60;br /&#62;
│ Reading simulation configuration:                        Done │&#60;br /&#62;
│ Selected GPU device id:                                Failed │&#60;br /&#62;
└───────────────────────────────────────────────────────────────┘&#60;br /&#62;
┌───────────────────────────────────────────────────────────────┐&#60;br /&#62;
│            !!! K-Wave experienced a fatal error !!!           │&#60;br /&#62;
├───────────────────────────────────────────────────────────────┤&#60;br /&#62;
│ Error: All CUDA-capable devices are busy or unavailable.      │&#60;br /&#62;
├───────────────────────────────────────────────────────────────┤&#60;br /&#62;
│                      Execution terminated                     │&#60;br /&#62;
└───────────────────────────────────────────────────────────────┘&#60;br /&#62;
Error using h5readc&#60;br /&#62;
Unable to open '/tmp/kwave_output_data05-Apr-2025-16-29-44.h5'. File or folder not found.&#60;/p&#62;
&#60;p&#62;Error in h5read (line 95)&#60;br /&#62;
    [data,var_class] = h5readc(Filename,Dataset,start,count,stride);&#60;br /&#62;
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&#60;br /&#62;
Error in kspaceFirstOrder3DC (line 569)&#60;br /&#62;
Nx = h5read(output_filename, '/Nx');&#60;br /&#62;
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&#60;br /&#62;
Error in kspaceFirstOrder2DG (line 76)&#60;br /&#62;
sensor_data = kspaceFirstOrder3DC(varargin{:});&#60;br /&#62;
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&#60;br /&#62;
Error in untitled (line 51)&#60;br /&#62;
sensor_data = kspaceFirstOrder2DG(kgrid, medium, source, sensor, input_args{:}, 'RecordMovie', false, 'DataCast', 'single');&#60;br /&#62;
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&#60;br /&#62;
 Is it not possible to run the k-Wave binaries (related to the Linux version) with CUDA support? If so, how can we resolve this issue?&#60;/p&#62;
&#60;p&#62;Thank you for your help!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>abbasK on "Transducer object for elastic simulations"</title>
			<link>http://www.k-wave.org/forum/topic/transducer-object-for-elastic-simulations#post-9228</link>
			<pubDate>Fri, 15 Aug 2025 15:27:02 +0000</pubDate>
			<dc:creator>abbasK</dc:creator>
			<guid isPermaLink="false">9228@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello,&#60;br /&#62;
can the kWaveTransducer be used with the pstdElastic3D function?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>masud407 on "2D linear array transducer with karray.addRectElement"</title>
			<link>http://www.k-wave.org/forum/topic/2d-linear-array-transducer-with-karrayaddrectelement#post-9210</link>
			<pubDate>Thu, 24 Apr 2025 17:25:58 +0000</pubDate>
			<dc:creator>masud407</dc:creator>
			<guid isPermaLink="false">9210@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I am trying to simulate a linear array which I can do for 3D case using the following example:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://www.k-wave.org/documentation/example_at_linear_array_transducer.php&#34; rel=&#34;nofollow&#34;&#62;http://www.k-wave.org/documentation/example_at_linear_array_transducer.php&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;However, I was trying to modify it for 2D case as following:&#60;/p&#62;
&#60;p&#62;clearvars;&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% DEFINE LITERALS&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% select which k-Wave code to run&#60;br /&#62;
%   1: MATLAB CPU code&#60;br /&#62;
%   2: MATLAB GPU code&#60;br /&#62;
%   3: C++ code&#60;br /&#62;
%   4: CUDA code&#60;br /&#62;
model           = 2;&#60;/p&#62;
&#60;p&#62;% medium parameters&#60;br /&#62;
c0              =1540;     % sound speed [m/s]&#60;br /&#62;
cs1 = 5;        % shear wave speed&#60;br /&#62;
alpha0_p1 = 0.002;        % absorption coefficient for water  % [dB/(MHz^2 cm)]&#60;br /&#62;
alpha0_s1 = 0.002;        % absorption coefficient for water (shear)&#60;br /&#62;
rho0            = 1000;     % density [kg/m^3]&#60;/p&#62;
&#60;p&#62;%define acrylic layer_tissue&#60;br /&#62;
cp2 = 2750;   % Longitudinal wave speed&#60;br /&#62;
cs2 = 1150;     % shear wave speed&#60;br /&#62;
rho2 = 1180;  %density&#60;br /&#62;
%alpha0_p2 = 0.5;        % absorption coefficient&#60;br /&#62;
%alpha0_s2 = 0.5;        % absorption coefficient&#60;br /&#62;
alpha0_p2 = 1.58;        % absorption coefficient  % [dB/(MHz^2 cm)]&#60;br /&#62;
alpha0_s2 =  0.016;        % absorption coefficient&#60;/p&#62;
&#60;p&#62;% source parameters&#60;br /&#62;
source_f0       =1e6;      % source frequency [Hz]&#60;br /&#62;
source_amp      = 1e6;      % source pressure [Pa]&#60;br /&#62;
source_cycles   = 12;        % number of toneburst cycles %12&#60;br /&#62;
source_focus    = 35e-3;    % focal length [m]&#60;br /&#62;
element_num     = 90;       % number of elements&#60;br /&#62;
element_width   = 0.25e-3;     % width [m]&#60;br /&#62;
element_length  = 7e-3;    % elevation height [m]&#60;br /&#62;
element_pitch   = 0.3e-3;     % pitch [m]0.03mm&#60;/p&#62;
&#60;p&#62;% transducer position&#60;br /&#62;
translation     = [0, 0];&#60;br /&#62;
rotation        = [0, 0];&#60;/p&#62;
&#60;p&#62;% grid parameters&#60;br /&#62;
grid_size_x     = 40e-3;    % [m]&#60;br /&#62;
grid_size_y     = 20e-3;    % [m]&#60;br /&#62;
% grid_size_z     = 40e-3;    % [m]&#60;/p&#62;
&#60;p&#62;% computational parameters&#60;br /&#62;
ppw             = 4;        % number of points per wavelength&#60;br /&#62;
t_end           = 35e-6;    % total compute time [s]&#60;br /&#62;
cfl             = 0.1;      % CFL number&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% RUN SIMULATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% --------------------&#60;br /&#62;
% GRID&#60;br /&#62;
% --------------------&#60;/p&#62;
&#60;p&#62;% calculate the grid spacing based on the PPW and F0&#60;br /&#62;
%  dx = 2*c0 / (ppw * source_f0);   % [m]&#60;br /&#62;
 dx=  1.9250e-04;&#60;br /&#62;
% compute the size of the grid&#60;br /&#62;
Nx = roundEven(grid_size_x / dx);&#60;br /&#62;
Ny = roundEven(grid_size_y / dx);&#60;br /&#62;
% Nz = roundEven(grid_size_z / dx);&#60;/p&#62;
&#60;p&#62;% create the computational grid&#60;br /&#62;
% kgrid = kWaveGrid(Nx, dx, Ny, dx, Nz, dx);&#60;br /&#62;
kgrid = kWaveGrid(Nx, dx, Ny, dx);&#60;br /&#62;
% create the time array&#60;br /&#62;
kgrid.makeTime(c0, cfl, t_end);&#60;/p&#62;
&#60;p&#62;% --------------------&#60;br /&#62;
% SOURCE&#60;br /&#62;
% --------------------&#60;/p&#62;
&#60;p&#62;% set indices for each element&#60;br /&#62;
if rem(element_num, 2)&#60;br /&#62;
    ids = (1:element_num) - ceil(element_num/2);&#60;br /&#62;
else&#60;br /&#62;
    ids = (1:element_num) - (element_num + 1)/2;&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;% set time delays for each element to focus at source_focus&#60;br /&#62;
time_delays = -(sqrt((ids .* element_pitch).^2 + source_focus.^2) - source_focus) ./ c0;&#60;br /&#62;
time_delays = time_delays - min(time_delays);&#60;br /&#62;
time_delays = 1*time_delays;&#60;br /&#62;
% create time varying source signals (one for each physical element)&#60;br /&#62;
source_sig = source_amp .* toneBurst(1/kgrid.dt, source_f0, source_cycles, 'SignalOffset', round(time_delays / kgrid.dt));&#60;/p&#62;
&#60;p&#62;% create empty kWaveArray&#60;br /&#62;
karray = kWaveArray('BLITolerance', 0.05, 'UpsamplingRate', 10);&#60;/p&#62;
&#60;p&#62;Unfortunately, I am getting the following error: &#60;/p&#62;
&#60;p&#62;Expected input number 4, theta, to be an array with number of elements equal to 1.&#60;/p&#62;
&#60;p&#62;Error in kWaveArray/addRectElement (line 715)&#60;br /&#62;
            validateattributes(theta, {'numeric'}, {'finite', 'real', 'numel', theta_length}, 'addRectElement', 'theta', 4);&#60;/p&#62;
&#60;p&#62;Any suggestion on resolving it is highly appreciated.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ayitime on "Delay Between Symmetric Sensors Despite Symmetric Setup in k-Wave"</title>
			<link>http://www.k-wave.org/forum/topic/delay-between-symmetric-sensors-despite-symmetric-setup-in-k-wave#post-9223</link>
			<pubDate>Wed, 16 Jul 2025 10:25:29 +0000</pubDate>
			<dc:creator>ayitime</dc:creator>
			<guid isPermaLink="false">9223@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;I'm running a 2D simulation in k-Wave using a line source placed symmetrically along the x-axis and a symmetrical arc-shaped sensor array (e.g., 6 elements). Both the source and sensor are symmetric in geometry.&#60;/p&#62;
&#60;p&#62;However, although symmetric sensor elements visibly receive the wavefront at the same time in the simulation movie, their recorded signals in combined_sensor_data show a delay of about 200 time steps (out of 1200), which is unexpected.&#60;/p&#62;
&#60;p&#62;I’m wondering:&#60;/p&#62;
&#60;p&#62;What might cause this delay between symmetric receivers?&#60;/p&#62;
&#60;p&#62;Could it be due to the use of kWaveArray, combineSensorData(), or the element size?&#60;/p&#62;
&#60;p&#62;Any ideas would be appreciated. Thanks!&#60;/p&#62;
&#60;p&#62;=================== code ==================&#60;br /&#62;
clear;&#60;br /&#62;
clc;&#60;/p&#62;
&#60;p&#62;Nx = 256;&#60;br /&#62;
Ny = 256;&#60;br /&#62;
dx = 0.5e-3;&#60;br /&#62;
dy = dx;&#60;/p&#62;
&#60;p&#62;%% grid&#60;br /&#62;
kgrid = kWaveGrid(Nx, dx, Ny, dy);&#60;/p&#62;
&#60;p&#62;%% medium&#60;br /&#62;
medium.sound_speed = 1500;&#60;br /&#62;
kgrid.makeTime(medium.sound_speed);&#60;/p&#62;
&#60;p&#62;%% source [array type]&#60;br /&#62;
karrayy = kWaveArray;&#60;/p&#62;
&#60;p&#62;x_bias = -20e-3;&#60;br /&#62;
y_width = 50e-3;&#60;br /&#62;
start_pos = [x_bias, -y_width / 2];&#60;br /&#62;
end_pos = [x_bias, +y_width / 2];&#60;br /&#62;
karrayy.addLineElement(start_pos, end_pos);&#60;/p&#62;
&#60;p&#62;source.p_mask = karrayy.getArrayBinaryMask(kgrid);&#60;br /&#62;
imagesc(kgrid.x_vec*1000, kgrid.y_vec*1000, source.p_mask);&#60;br /&#62;
xlabel(&#34;y/mm&#34;); ylabel(&#34;x/mm&#34;);&#60;br /&#62;
axis equal; axis tight; colorbar;&#60;/p&#62;
&#60;p&#62;f1 = 100e3;     % 0.1MHz&#60;br /&#62;
sig1 = toneBurst(1/kgrid.dt, f1, 3);&#60;br /&#62;
source.p = sig1;&#60;br /&#62;
% plot(sig1);&#60;/p&#62;
&#60;p&#62;%% sensor [array type]&#60;br /&#62;
karray = kWaveArray;&#60;br /&#62;
radius = 50e-3;&#60;br /&#62;
num_elements = 6;&#60;br /&#62;
elem_pos = makeCartCircle(radius, num_elements, [0, 0]);   &#60;/p&#62;
&#60;p&#62;radius_of_curv = 10e-3;&#60;br /&#62;
diameter = 1e-3;&#60;br /&#62;
focus_pos = [0, 0];&#60;/p&#62;
&#60;p&#62;for ind = 1:num_elements&#60;br /&#62;
    karray.addArcElement(elem_pos(:, ind), radius_of_curv, diameter, focus_pos);&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;sensor.mask = karray.getArrayBinaryMask(kgrid);&#60;br /&#62;
imagesc(sensor.mask);&#60;br /&#62;
xlabel(&#34;y/mm&#34;); ylabel(&#34;x/mm&#34;);&#60;br /&#62;
axis equal; axis tight; colorbar;&#60;/p&#62;
&#60;p&#62;input_args = {'DisplayMask',(source.p_mask &#124; sensor.mask),...&#60;br /&#62;
              'RecordMovie', true,...&#60;br /&#62;
              'MovieName','video2',...&#60;br /&#62;
              'DataCast', 'gpuArray-single',...&#60;br /&#62;
              'PlotSim',true};    &#60;/p&#62;
&#60;p&#62;%% run&#60;br /&#62;
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});&#60;/p&#62;
&#60;p&#62;combined_sensor_data = karray.combineSensorData(kgrid, sensor_data);&#60;br /&#62;
stackedPlot(combined_sensor_data);
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Crusher on "I want to do a 2D elastic wave simulation on step geometry"</title>
			<link>http://www.k-wave.org/forum/topic/i-want-to-do-a-2d-elastic-wave-simulation-on-step-geometry#post-8920</link>
			<pubDate>Tue, 03 Oct 2023 11:53:34 +0000</pubDate>
			<dc:creator>Crusher</dc:creator>
			<guid isPermaLink="false">8920@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I want to do a 2D elastic wave simulation on step geometry, like a small rectangle of different property placed on a big rectangle of different property. How to do that?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>NicholasHorton on "Seems attenuation settings (following power law) affect signals&#039; time-of-arrival"</title>
			<link>http://www.k-wave.org/forum/topic/seems-attenuation-settings-following-power-law-affect-signals-time-of-arrival#post-9221</link>
			<pubDate>Mon, 14 Jul 2025 07:59:55 +0000</pubDate>
			<dc:creator>NicholasHorton</dc:creator>
			<guid isPermaLink="false">9221@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi everyone,&#60;br /&#62;
I was working on the simulation of ultrasound propagation. I designed three homogeneous mediums. Their speed-of-sounds were 1500 m/s. Their densities were 1000 kg/m^3. Their alpha_power were set as 1.1. Their alpha_coeff were 0.002, 0.7, and 3.0, respectively.&#60;br /&#62;
A sensor was set to record transmitted signal.&#60;br /&#62;
I just found that with different alpha_coeff, the time-of-arrivals of the signals were different. The larger alpha_coeff was, the earlier the signal arrived.&#60;br /&#62;
The change was so significant that it was counter-intuitive. I wonder if dispersion can explain this phenomenon.&#60;br /&#62;
I would like to ask you, is this simulation result consistent with the physical phenomenon? If not, how should I correct my code?&#60;br /&#62;
The code has been attached below.&#60;br /&#62;
Thanks a lot.&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;% To compare TOFs of transmitted signals, with different [constant] att.s or wvfroms.
% * The 2-D numerical simulations are based on k-Wave toolbox
% * Emitted pulse: a 3-cycle tone-burst whose centre-frequency is 2 MHz
% * Emitter and receiver: two points about 25 cm apart, recording transmitted signal
% * Medium: homogeneous, whose attenuation power is 1.1, and attenuation coefficient
%   is 0.002, 0.7 or 3.0 dB/cm/MHz^1.1
clc;clear
close all
%% Define Params
% default medium params
sos_ref                 = 1500;         % [m/s]
density_ref             = 1000;         % [kg/m^3]
att_power               = 1.1;          % y

% define k-Wave Grid
Nx                      = 3072;
dx                      = 1e-4;
kgrid                   = kWaveGrid(Nx, dx, Nx, dx);
t_end                   = Nx * dx / sos_ref * 2;
kgrid.makeTime(sos_ref, 0.5, t_end);                    % CFL = 0.5

% different wvforms and att.s
small_att               = 0.002;        % dB/cm/MHz^y
big_att                 = 0.7;
bigger_att              = 3.0;
wv_tb                   = toneBurst(1./kgrid.dt, 2e6, 3, &#38;#39;SignalLength&#38;#39;, kgrid.Nt);
%% Define numerical phantom
%------------define Medium One, no attenuation at all
medium_noAtt.sound_speed        = sos_ref * ones(Nx);
medium_noAtt.density            = density_ref * ones(Nx);

%------------define Medium Two, with a small atten. coeff.,
medium_smallAtt                 = medium_noAtt;
medium_smallAtt.alpha_power     = att_power;
medium_smallAtt.alpha_coeff     = small_att * ones(Nx);            

%------------define Medium Three, with a big atten. coeff.,
medium_bigAtt                   = medium_smallAtt;
medium_bigAtt.alpha_coeff       = big_att * ones(Nx);

%------------define Medium Three, with a big atten. coeff.,
medium_biggerAtt                = medium_smallAtt;
medium_biggerAtt.alpha_coeff    = bigger_att * ones(Nx);
%% Define source &#38;amp; sensor
source.p_mask                   = zeros(Nx, Nx);
source.p_mask(Nx / 2, 250)      = 1;
sensor.mask                     = zeros(Nx, Nx)
sensor.mask(Nx / 2, Nx - 250)   = 1;
% source.p not defined
%% Execute the simulations
input_args      = {&#38;#39;PMLSize&#38;#39;, &#38;#39;auto&#38;#39;,...
                   &#38;#39;PMLInside&#38;#39;, false,...
                   &#38;#39;PlotPML&#38;#39;, false,...
                   &#38;#39;DisplayMask&#38;#39;, &#38;#39;off&#38;#39;,...
                   &#38;#39;DataPath&#38;#39;, pwd,...
                   &#38;#39;DeleteData&#38;#39;, false};

for medium_name = {&#38;#39;smallAtt&#38;#39;, &#38;#39;bigAtt&#38;#39;, &#38;#39;biggerAtt&#38;#39;}
    cmd         = [&#38;#39;medium  = medium_&#38;#39;, medium_name{1}, &#38;#39;;&#38;#39;];
    eval(cmd)
    source.p    = wv_tb;
    rf_data     = kspaceFirstOrder2DC(kgrid, medium, source, sensor, input_args{:});
    cmd         = [&#38;#39;sig_&#38;#39;, medium_name{1}, &#38;#39; = rf_data;&#38;#39;];
    eval(cmd)
end
%% Visulaization
f1              = figure(&#38;#39;Units&#38;#39;,&#38;#39;centimeters&#38;#39;, &#38;#39;Position&#38;#39;, [2, 2, 25, 40]);
plt_cnt         = 0;
plt_c           = 3;
plt_r           = 1;
range_          = [160, 175] * 1e-6;    % unit: s

for medium_name = { &#38;#39;smallAtt&#38;#39;, &#38;#39;bigAtt&#38;#39;, &#38;#39;biggerAtt&#38;#39;}
    cmd             = [&#38;#39;sig = sig_&#38;#39;, medium_name{1}, &#38;#39;;&#38;#39;];
    eval(cmd)
    env             = abs(hilbert(sig));
    % ----------
    plt_cnt         = plt_cnt + 1; subplot(plt_c, plt_r, plt_cnt)
    plot(kgrid.t_array * 1e6, env, &#38;#39;color&#38;#39;,&#38;#39;r&#38;#39;, &#38;#39;lineWidth&#38;#39;, 1.5)
    grid on
    grid minor
    xlabel(&#38;#39;Time [\mus]&#38;#39;)
    xlim(range_ * 1e6)
    title(medium_name{1}, &#38;#39;Interpreter&#38;#39;, &#38;#39;none&#38;#39;)
end
sgtitle(&#38;#39;Signal Envelope&#38;#39;)&#60;/code&#62;&#60;/pre&#62;</description>
		</item>

	</channel>
</rss>
