<?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 Posts</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:15:44 +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/" 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>atandri 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-9239</link>
			<pubDate>Tue, 30 Sep 2025 16:06:13 +0000</pubDate>
			<dc:creator>atandri</dc:creator>
			<guid isPermaLink="false">9239@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;It seems as though you should be able to do this similar to the &#34;Simulating Ultrasound Beam Patterns&#34; example- essentially by setting the whole grid as sensors.
&#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>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-9234</link>
			<pubDate>Tue, 16 Sep 2025 10:32:02 +0000</pubDate>
			<dc:creator>antonio.marzoa</dc:creator>
			<guid isPermaLink="false">9234@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi again,&#60;/p&#62;
&#60;p&#62;I have sorted the issue of the zeroing of the pressure (it was just an issue regarding reaching the steady state - thus, not having put enough computation time! -).&#60;br /&#62;
I am still looking for a way of obtaining the axial pressure plots from the example_diff_focused_ultrasound_heating.m, any ideas?
&#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>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>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>atandri on "Concave ring transducer"</title>
			<link>http://www.k-wave.org/forum/topic/concave-ring-transducer#post-9230</link>
			<pubDate>Thu, 04 Sep 2025 20:25:39 +0000</pubDate>
			<dc:creator>atandri</dc:creator>
			<guid isPermaLink="false">9230@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;the kWaveArray addAnnularArray seems to exactly fit what you're looking for
&#60;/p&#62;</description>
		</item>
		<item>
			<title>nmin 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-9229</link>
			<pubDate>Mon, 01 Sep 2025 09:41:34 +0000</pubDate>
			<dc:creator>nmin</dc:creator>
			<guid isPermaLink="false">9229@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi ujjal, I am experiencing the same issue. Could you kindly share how you resolved it? Thanks a lot!
&#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>mhopeng on "2D linear array transducer with karray.addRectElement"</title>
			<link>http://www.k-wave.org/forum/topic/2d-linear-array-transducer-with-karrayaddrectelement#post-9227</link>
			<pubDate>Sat, 02 Aug 2025 01:08:13 +0000</pubDate>
			<dc:creator>mhopeng</dc:creator>
			<guid isPermaLink="false">9227@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;You need to define the elements of the Array using one of the methods for adding elements, such as &#60;code&#62;addRectElement()&#60;/code&#62;. I don't see that in the code you have posted here.
&#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-9226</link>
			<pubDate>Wed, 30 Jul 2025 07:40:21 +0000</pubDate>
			<dc:creator>ayitime</dc:creator>
			<guid isPermaLink="false">9226@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;This question has been resolved.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>frezaei 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-9225</link>
			<pubDate>Tue, 29 Jul 2025 02:59:04 +0000</pubDate>
			<dc:creator>frezaei</dc:creator>
			<guid isPermaLink="false">9225@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I have a follow-up question: when I change the frequency, I observe that the sensor signal is higher for a higher frequency than lower frequency. Why does this happen? The material has an attenuation coefficient that depends on frequency, so for higher frequencies, we should see a lower amplitude at the sensor. Why do I see the reverse behavior? I also tried to use the same number of cycles for each case, but again seeing the same behavior, I am interested to learn how the following papers simulated with reasonable results?&#60;br /&#62;
paper1.K‑wave modelling of ultrasound wave propagation in aerogels and the effect of physical parameters on attenuation and loss&#60;br /&#62;
paper2.Simultaneous use of pulse-echo and through-transmission methods in determining a combined reflection coefficient
&#60;/p&#62;</description>
		</item>
		<item>
			<title>frezaei 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-9224</link>
			<pubDate>Mon, 28 Jul 2025 19:05:11 +0000</pubDate>
			<dc:creator>frezaei</dc:creator>
			<guid isPermaLink="false">9224@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello,&#60;/p&#62;
&#60;p&#62;I am new to k-wave simulation, and I am trying to simulate the attenuation through media. First of all, for medium.alpha_coeff, what should the unit be? dB/MHz.cm or Np/MHz.cm? Secondly, how do I make sure the attenuation through the medium is correct? I placed two sensors, one near the source and the other 1.1mm away, and now by looking at sensor signals, I see there is an attenuation, but if I consider the peak-to-peak value of the sensor signal, it does not follow this relationship: P=P0*exp(-alpha*f*x), why? Here is my code:&#60;br /&#62;
% Define medium properties&#60;br /&#62;
medium.sound_speed = zeros(Nx, Ny);&#60;br /&#62;
medium.density     = zeros(Nx, Ny);&#60;/p&#62;
&#60;p&#62;medium.sound_speed(:,:) = 5555;&#60;br /&#62;
medium.density(:,:)     = 2440;&#60;/p&#62;
&#60;p&#62;% Define attenuation coefficients (Np/(MHz^y cm))&#60;br /&#62;
medium.alpha_coeff = zeros(Nx, Ny);   % in dB/(MHz^y cm) but K-Wave expects Np/(MHz^y m)&#60;br /&#62;
medium.alpha_coeff(:,:) = 0.1;     % low loss (converted to Np/(MHz^y m))&#60;br /&#62;
medium.alpha_power = 1.0;        % frequency power&#60;br /&#62;
medium.alpha_mode = 'no_dispersion';&#60;/p&#62;
&#60;p&#62;% Simulation time&#60;br /&#62;
cfl=0.3;&#60;br /&#62;
t_end = 16e-6;       % [s]&#60;br /&#62;
sound_speed=5555;&#60;br /&#62;
dt = cfl * dx / sound_speed;&#60;br /&#62;
kgrid.makeTime(sound_speed, cfl,t_end)&#60;br /&#62;
% Tone burst source settings&#60;br /&#62;
sample_freq = 20e6;             % [Hz]&#60;br /&#62;
signal_freq = 1e6;            % [Hz]&#60;br /&#62;
num_cycles = 3;&#60;br /&#62;
signal=toneBurst(sample_freq,signal_freq,num_cycles,'Plot',true);&#60;/p&#62;
&#60;p&#62;%Defining a single source point&#60;br /&#62;
source.p_mask = zeros(Nx, Ny);&#60;br /&#62;
source.p_mask(round(Nx/2), 1) = 1;&#60;/p&#62;
&#60;p&#62;% define a time varying sinusoidal source&#60;br /&#62;
source_mag = 1e2;   % Amplitude in Pascals&#60;br /&#62;
source.p=source_mag *signal;&#60;/p&#62;
&#60;p&#62;% Initialize sensor mask with unique labels&#60;br /&#62;
sensor.mask = zeros(Nx, Ny);&#60;/p&#62;
&#60;p&#62;% Sensor 1: label '1' in second row (just below source)&#60;br /&#62;
sensor.mask(round(Nx/2), 2) = 1;&#60;/p&#62;
&#60;p&#62;% Sensor 2: label '2' in the row right after the glass layer&#60;br /&#62;
sensor.mask(round(Nx/2), 24) = 1;&#60;/p&#62;
&#60;p&#62;sensor.record = {'p', 'p_final','I'};&#60;/p&#62;
&#60;p&#62;% Run the simulation with memory-safe options&#60;br /&#62;
input_args = {'PMLInside', false, 'PMLSize', 20, 'PMLAlpha',3, 'PlotPML', true, 'DataCast', 'single', 'PlotLayout', true,'RecordMovie', true};&#60;br /&#62;
% input_args = {'DisplayMask', display_mask,'PMLInside', false, 'PMLSize', 20, 'PMLAlpha',2, 'PlotPML', true, 'DataCast', 'single', 'PlotLayout', true};&#60;br /&#62;
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor,input_args{:});&#60;/p&#62;
&#60;p&#62;% Extract pressure signals&#60;br /&#62;
p_signals = sensor_data.p;           % [2 x Nt]&#60;br /&#62;
Nt = length(kgrid.t_array);&#60;br /&#62;
t_micro = (0:Nt-1) * kgrid.dt * 1e6;&#60;/p&#62;
&#60;p&#62;% Plot recorded signals&#60;br /&#62;
figure;&#60;br /&#62;
plot(t_micro, p_signals(1,:), 'b-', 'LineWidth', 1.5);&#60;br /&#62;
xlabel('Time (µs)');&#60;br /&#62;
ylabel('Pressure (Pa)');&#60;br /&#62;
legend('Sensor 1 (near source)');&#60;br /&#62;
title('Pressure1 Time‑Series Recorded by Sensors');&#60;br /&#62;
figure;&#60;br /&#62;
plot(t_micro, p_signals(2,:), 'r-', 'LineWidth', 1.5);&#60;br /&#62;
xlabel('Time (µs)');&#60;br /&#62;
ylabel('Pressure (Pa)');&#60;br /&#62;
legend('Sensor 2 (after 1.1mm)');&#60;br /&#62;
title('Pressure2 Time‑Series Recorded by Sensors');&#60;br /&#62;
grid on;&#60;br /&#62;
[row_sens, col_sens] = find(sensor.mask);&#60;br /&#62;
figure;&#60;br /&#62;
imagesc(x_mm, y_mm, medium.sound_speed'); axis image tight;&#60;br /&#62;
colormap(jet); colorbar;&#60;br /&#62;
xlabel('x (mm)'); ylabel('y (mm)');&#60;br /&#62;
title('Medium with Sensor and Source Locations');&#60;br /&#62;
hold on;&#60;/p&#62;
&#60;p&#62;% Plot source in red&#60;br /&#62;
[row_src, col_src] = find(source.p_mask);&#60;br /&#62;
plot(x_mm(row_src), y_mm(col_src), 'rs', 'MarkerSize', 8, 'LineWidth', 1.5);&#60;/p&#62;
&#60;p&#62;% Plot sensors in green&#60;br /&#62;
plot(x_mm(row_sens), y_mm(col_sens), 'go', 'MarkerSize', 8, 'LineWidth', 1.5);&#60;br /&#62;
legend('Source', 'Sensor');
&#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>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>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>
		<item>
			<title>mcdannold on "Issue with XXX_output.h5 files"</title>
			<link>http://www.k-wave.org/forum/topic/issue-with-xxx_outputh5-files#post-9219</link>
			<pubDate>Mon, 07 Jul 2025 15:35:39 +0000</pubDate>
			<dc:creator>mcdannold</dc:creator>
			<guid isPermaLink="false">9219@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello,&#60;/p&#62;
&#60;p&#62;The computing cluster I run kWave code on was recently migrated to RedHat from centOS. The compiled kspaceFirstOrder3DC code seems to be running fine, but there seems to be an issue with the output temporary files. The XXX_output.h5 files are only 1 kB, and there are additional files starting with '.nfs' that are generated (such as '.nfs7eed9ff995d7a06200000304'). These files don't seem to be deleted.&#60;/p&#62;
&#60;p&#62;I am using matlab2024b. I used to use an older version, but that version was not installed after the OS migration.&#60;/p&#62;
&#60;p&#62;Any idea what is going on?&#60;/p&#62;
&#60;p&#62;Thanks,&#60;br /&#62;
Nathan
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ejoa1234561 on "Linux vs windows GPU memory allocation"</title>
			<link>http://www.k-wave.org/forum/topic/linux-vs-windows-gpu-memory-allocation#post-9218</link>
			<pubDate>Wed, 28 May 2025 04:03:52 +0000</pubDate>
			<dc:creator>ejoa1234561</dc:creator>
			<guid isPermaLink="false">9218@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello,&#60;/p&#62;
&#60;p&#62;I am running this code in 2 workstations.&#60;br /&#62;
The first workstation is a Windows 10 with a GPU ADA A4000 of 12gb VRAM.&#60;br /&#62;
The second is a cluster linux with 2 GPUs A100 of 48gb of VRAM each.&#60;/p&#62;
&#60;p&#62;In the W10 the code can allocate until t_end = 0.12; (11.48gb of 12gb) without problems. However, when I try to do the same in the cluster the VRAM only accepts (t_end=0.1) using 39.8gb of 40gb. What is happening? Linux manages different the VRAM? Is there a way to fix this? I installed the binaries in both cases and the problem is on pstdElastic2D(kgrid, medium, source, sensor, input_args{:}) function.&#60;/p&#62;
&#60;p&#62;clc; clear; close all;&#60;br /&#62;
gpuDevice(1)&#60;/p&#62;
&#60;p&#62;format compact;&#60;br /&#62;
set(0,'defaultAxesFontSize',18);&#60;br /&#62;
set(groot, 'defaultAxesTickLabelInterpreter','tex');&#60;br /&#62;
set(groot, 'defaultLegendInterpreter','tex');&#60;br /&#62;
set(0,'defaulttextInterpreter','tex');&#60;/p&#62;
&#60;p&#62;DATA_CAST = 'gpuArray-single'; &#60;/p&#62;
&#60;p&#62;%% Create the computational grid&#60;br /&#62;
Nx = 60;           % number of grid points in the x direction&#60;br /&#62;
Ny = 100;           % number of grid points in the y direction&#60;br /&#62;
dx = 2e-3;          % grid spacing in x [m]&#60;br /&#62;
dy = 2e-3;          % grid spacing in y [m]&#60;br /&#62;
kgrid = kWaveGrid(Nx, dx, Ny, dy);&#60;/p&#62;
&#60;p&#62;%% Define medium properties&#60;br /&#62;
medium.sound_speed_compression = 1500 * ones(Nx, Ny);   % [m/s] realistic compressional speed&#60;br /&#62;
medium.sound_speed_shear = 2.5 * ones(Nx, Ny);            % [m/s] for gelatin-like shear&#60;br /&#62;
medium.density = 1000 * ones(Nx, Ny);                   % [kg/m^3]&#60;/p&#62;
&#60;p&#62;% Add boundary&#60;br /&#62;
rigid_thickness = 5;&#60;/p&#62;
&#60;p&#62;%AIR&#60;br /&#62;
medium.density(:,1:rigid_thickness) = 12;&#60;br /&#62;
% medium.density(:,end-rigid_thickness:end) = 1.2;&#60;br /&#62;
medium.density(1:rigid_thickness,:) = 12;&#60;br /&#62;
medium.density(end-rigid_thickness:end,:) = 12;&#60;/p&#62;
&#60;p&#62;medium.sound_speed_shear(:, 1:rigid_thickness) = 1;&#60;br /&#62;
% medium.sound_speed_shear(:,end-rigid_thickness:end) = 0.1;&#60;br /&#62;
medium.sound_speed_shear(1:rigid_thickness,:) = 1;&#60;br /&#62;
medium.sound_speed_shear(end-rigid_thickness:end,:) = 1;&#60;/p&#62;
&#60;p&#62;medium.sound_speed_compression(:, 1:rigid_thickness) = 1500;&#60;br /&#62;
% medium.sound_speed_compression(:,end-rigid_thickness:end) = 340;&#60;br /&#62;
medium.sound_speed_compression(1:rigid_thickness,:) = 1500;&#60;br /&#62;
medium.sound_speed_compression(end-rigid_thickness:end,:) = 1500;&#60;/p&#62;
&#60;p&#62;%TX&#60;br /&#62;
medium.density(1:rigid_thickness,40:60) = 12;&#60;br /&#62;
medium.sound_speed_shear(1:rigid_thickness,40:60) = 1000;&#60;br /&#62;
medium.sound_speed_compression(1:rigid_thickness,40:60) = 1500;&#60;/p&#62;
&#60;p&#62;% Attenuation&#60;br /&#62;
medium.alpha_coeff_compression = 0.05;    % [dB/(MHz^2 cm)]&#60;br /&#62;
medium.alpha_coeff_shear = 1000;           % [dB/(MHz^2 cm)]&#60;br /&#62;
% medium.alpha_power_shear = 1.3;&#60;/p&#62;
&#60;p&#62;%% Time array (safe dt based on c_max)&#60;br /&#62;
t_end = 0.1; %0.12;  % [s] to allow steady-state observation&#60;br /&#62;
c_max = max([max(medium.sound_speed_compression(:)), max(medium.sound_speed_shear(:))]);&#60;br /&#62;
cfl = 0.3;&#60;br /&#62;
kgrid.makeTime(c_max, cfl, t_end);&#60;/p&#62;
&#60;p&#62;%% Define source&#60;br /&#62;
cx1 = Nx/2;&#60;br /&#62;
cy1 = Ny-14;&#60;br /&#62;
radius = 10;&#60;br /&#62;
plot_disc = 'true';&#60;br /&#62;
disc1 = makeDisc(Nx, Ny, cx1, cy1, radius, plot_disc);&#60;br /&#62;
source.u_mask = disc1;&#60;/p&#62;
&#60;p&#62;source_freq = 200; % [Hz]&#60;br /&#62;
source_mag = 1e-6;&#60;br /&#62;
source_signal = source_mag * sin(2 * pi * source_freq * kgrid.t_array);&#60;br /&#62;
source.uy= source_signal;&#60;/p&#62;
&#60;p&#62;% source_points = find(source.u_mask);&#60;br /&#62;
% num_sources = length(source_points);&#60;br /&#62;
% source.ux = zeros(length(kgrid.t_array), num_sources);&#60;br /&#62;
% for i = 1:num_sources&#60;br /&#62;
%     source.ux(:, i) = source_signal;&#60;br /&#62;
% end&#60;/p&#62;
&#60;p&#62;%% Define sensor&#60;br /&#62;
mask = zeros(Nx, Ny);&#60;br /&#62;
mask(:, 10:end) = 1;&#60;br /&#62;
sensor.mask = mask;&#60;br /&#62;
sensor.record = {'u', 'u_split_field'};&#60;/p&#62;
&#60;p&#62;%% Run simulation&#60;br /&#62;
input_args = {'PMLAlpha', 2, 'PlotPML', false, 'PMLInside', false, ...&#60;br /&#62;
              'DisplayMask', 'off', 'DataCast', DATA_CAST};&#60;/p&#62;
&#60;p&#62;sensor_data = pstdElastic2D(kgrid, medium, source, sensor, input_args{:});&#60;/p&#62;
&#60;p&#62;ux_s = gather(reshape(sensor_data.ux_split_s, Nx, Ny-9, []));&#60;br /&#62;
ux_p = gather(reshape(sensor_data.ux_split_p, Nx, Ny-9, []));&#60;br /&#62;
ux_total = gather(reshape(sensor_data.ux, Nx, Ny-9, []));&#60;/p&#62;
&#60;p&#62;dinf.dx = dx;&#60;br /&#62;
dinf.dy = dy;&#60;br /&#62;
dinf.dt = kgrid.dt;&#60;/p&#62;
&#60;p&#62;%% Visualization&#60;br /&#62;
figure&#60;br /&#62;
xx = dinf.dx * (0:size(ux_total,1)-1);&#60;br /&#62;
yy = dinf.dy * (0:size(ux_total,2)-1);&#60;br /&#62;
for ii = 1:500:20000&#60;br /&#62;
    im = real(squeeze(ux_total(:,:,ii)));  % amplitude of shear wave&#60;br /&#62;
    imagesc(yy(10:end),xx, im);&#60;br /&#62;
    xlabel('x (m)'); ylabel('y (m)');&#60;br /&#62;
    axis image;&#60;br /&#62;
    clim([-1 1]);&#60;br /&#62;
    title(['Frame ' num2str(ii)]);&#60;br /&#62;
    grid on;&#60;br /&#62;
    colormap('jet');&#60;br /&#62;
    colorbar;&#60;br /&#62;
    drawnow&#60;br /&#62;
    pause(0.1)&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;% Optional: save&#60;br /&#62;
filename = ['ShearReflection_' num2str(source_freq) 'Hz'];&#60;br /&#62;
save(filename, &#34;ux_total&#34;, &#34;ux_p&#34;, &#34;ux_s&#34;, &#34;dinf&#34;, &#34;source_freq&#34;, '-v7.3');&#60;/p&#62;
&#60;p&#62;energy_t = zeros(1, size(ux_s,3));&#60;br /&#62;
for ii = 1:size(ux_s,3)&#60;br /&#62;
    frame = ux_s(:,:,ii);&#60;br /&#62;
    energy_t(ii) = sum(frame(:).^2);  % proportional to elastic energy&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;% 2. Difference between consecutive frames&#60;br /&#62;
diff_energy = zeros(1, size(ux_s,3)-1);&#60;br /&#62;
for ii = 1:(size(ux_s,3)-1)&#60;br /&#62;
    diff = ux_s(:,:,ii+1) - ux_s(:,:,ii);&#60;br /&#62;
    diff_energy(ii) = sum(diff(:).^2);&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;% 3. Plot energy over time&#60;br /&#62;
figure;&#60;br /&#62;
subplot(2,1,1);&#60;br /&#62;
plot(kgrid.t_array, energy_t, 'b-', 'LineWidth', 2);&#60;br /&#62;
xlabel('Time [s]');&#60;br /&#62;
ylabel('Total Shear Energy');&#60;br /&#62;
title('Shear Field Energy vs Time');&#60;br /&#62;
grid on;&#60;/p&#62;
&#60;p&#62;% 4. Plot frame-to-frame difference&#60;br /&#62;
subplot(2,1,2);&#60;br /&#62;
plot(kgrid.t_array(2:end), diff_energy, 'r-', 'LineWidth', 2);&#60;br /&#62;
xlabel('Time [s]');&#60;br /&#62;
ylabel('Frame-to-Frame Energy Change');&#60;br /&#62;
title('Difference Between Consecutive Shear Frames');&#60;br /&#62;
grid on;&#60;/p&#62;
&#60;p&#62;Error output:&#60;br /&#62;
Running k-Wave elastic simulation...&#60;br /&#62;
  start time: 27-May-2025 22:34:42&#60;br /&#62;
  reference sound speed: 1500m/s&#60;br /&#62;
[Warning: Support for ver('distcomp') will be removed in a future release.  Use&#60;br /&#62;
ver('parallel') instead.]&#60;br /&#62;
[&#38;gt; In ver&#38;gt;locGetSingleToolboxInfo (line 283)&#60;br /&#62;
In ver (line 56)&#60;br /&#62;
In verLessThan (line 39)&#60;br /&#62;
In kspaceFirstOrder_inputChecking (line 1306)&#60;br /&#62;
In pstdElastic2D (line 385)&#60;br /&#62;
In sphere (line 104)]&#60;br /&#62;
  dt: 400ns, t_end: 150ms, time steps: 375001&#60;br /&#62;
  input grid size: 60 by 100 grid points (120 by 200mm)&#60;br /&#62;
  maximum supported compressional frequency: 375kHz&#60;br /&#62;
  maximum supported shear frequency: 250Hz&#60;br /&#62;
  expanding computational grid...&#60;br /&#62;
  computational grid size: 100 by 140 grid points&#60;br /&#62;
{Error using gpuArray.zeros&#60;br /&#62;
Out of memory on device. To view more detail about available memory on the GPU,&#60;br /&#62;
use 'gpuDevice()'. If the problem persists, reset the GPU by calling&#60;br /&#62;
'gpuDevice(1)'.&#60;br /&#62;
Error in kspaceFirstOrder_inputChecking&#38;gt;@(sz)gpuArray.zeros(sz,'single') (line 1314)&#60;br /&#62;
                castZeros = @(sz) gpuArray.zeros(sz, 'single');&#60;br /&#62;
Error in kspaceFirstOrder_createStorageVariables (line 336)&#60;br /&#62;
                sensor_data.uy_split_s = castZeros([num_sensor_points, num_recorded_time_points]);&#60;br /&#62;
Error in kspaceFirstOrder_inputChecking (line 1663)&#60;br /&#62;
    kspaceFirstOrder_createStorageVariables;&#60;br /&#62;
Error in pstdElastic2D (line 385)&#60;br /&#62;
kspaceFirstOrder_inputChecking;&#60;br /&#62;
Error in sphere (line 104)&#60;br /&#62;
sensor_data = pstdElastic2D(kgrid, medium, source, sensor, input_args{:});}
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Mekdes Bezabh on "Regarding Homogenous B-mode image simulation"</title>
			<link>http://www.k-wave.org/forum/topic/regarding-homogenous-b-mode-image-simulation#post-9217</link>
			<pubDate>Mon, 26 May 2025 21:37:15 +0000</pubDate>
			<dc:creator>Mekdes Bezabh</dc:creator>
			<guid isPermaLink="false">9217@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Please, I wonder if anyone can suggest any solution.&#60;/p&#62;
&#60;p&#62;Thank you in advance.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>yanyan on "超声传感器阵列显示The defined transducer is too large or positioned outside the grid in"</title>
			<link>http://www.k-wave.org/forum/topic/%e8%b6%85%e5%a3%b0%e4%bc%a0%e6%84%9f%e5%99%a8%e9%98%b5%e5%88%97%e6%98%be%e7%a4%bathe-defined-transducer-is-too-large-or-positioned-outside-the-grid-in#post-9216</link>
			<pubDate>Mon, 26 May 2025 11:25:23 +0000</pubDate>
			<dc:creator>yanyan</dc:creator>
			<guid isPermaLink="false">9216@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;clear&#60;br /&#62;
dx =5e-6;  % x方向分辨率&#60;br /&#62;
dy =5e-6;  % y方向分辨率&#60;br /&#62;
PML_size=20;%设置完美匹配层&#60;br /&#62;
% 阵列参数&#60;br /&#62;
element_size = [12, 12];    % x/y方向各6网格点，z方向1点&#60;br /&#62;
element_spacing = [1, 1]; % x/y间距1点，z方向无间隔&#60;br /&#62;
array_dims = [80, 1];    % x/y各80阵元，单层&#60;br /&#62;
% 总网格数&#60;br /&#62;
Nx=array_dims(1)*(element_size(1)+element_spacing(1)) - element_spacing(1)+2*PML_size;%x方向总网格数量&#60;br /&#62;
Ny=Nx;%y方向总网格数量&#60;br /&#62;
kgrid=kWaveGrid(Nx, dx, Ny, dy);&#60;br /&#62;
%设置介质材料属性&#60;br /&#62;
sound_speed_glass = 5600;     % 玻璃声速 [m/s]&#60;br /&#62;
density_glass = 2400;         % 玻璃密度 [kg/m^3]&#60;br /&#62;
sound_speed_water = 1500;     % 水声速&#60;br /&#62;
density_water = 1000;         % 水密度&#60;br /&#62;
sound_speed_air =343;        % 空气声速&#60;br /&#62;
density_air = 1;            % 空气密度&#60;br /&#62;
medium.sound_speed = sound_speed_glass*ones(Nx,Ny);%声速初始化&#60;br /&#62;
medium.density = density_glass*ones(Nx,Ny); %密度初始化&#60;br /&#62;
reflector_y_pos = 1+(PML_size + round(1e-3 / kgrid.dy));%反射面设置为在21个，避免反射波对计算区域造成影响&#60;br /&#62;
% 定义交替层的位置&#60;br /&#62;
x_start = PML_size + 1;  %定义开始位置&#60;br /&#62;
x_end = Nx-PML_size; %定义结束位置&#60;br /&#62;
interval_num = 20;  %分成20个区域&#60;br /&#62;
interval_grid_points = floor((Nx-2*PML_size+1) / interval_num); % 计算每个区域的网格点数，并使用floor函数取整&#60;br /&#62;
remaining_points =Nx-2*PML_size - interval_num * interval_grid_points; % 剩余的网格点数&#60;br /&#62;
target_column =x_start;&#60;br /&#62;
interval_num=20;&#60;br /&#62;
i = zeros(interval_num,2); %网格单元的长度&#60;br /&#62;
for interval_idx = 0:(interval_num-1)&#60;br /&#62;
    current_x_start = x_start + interval_idx * interval_grid_points;&#60;br /&#62;
    current_x_end = current_x_start + interval_grid_points - 1;&#60;br /&#62;
    i(interval_idx+1,1)=current_x_start;&#60;br /&#62;
    i(interval_idx+1,2)=current_x_end;&#60;br /&#62;
    % 最后一层分配剩余点数&#60;br /&#62;
    if interval_idx == interval_num - 1&#60;br /&#62;
        current_x_end = current_x_end + remaining_points;&#60;br /&#62;
    end&#60;br /&#62;
    % 边界保护&#60;br /&#62;
    if current_x_end &#38;gt; x_end&#60;br /&#62;
        current_x_end = x_end;&#60;br /&#62;
    end&#60;br /&#62;
    % 交替材料设置&#60;br /&#62;
    if mod(interval_idx, 2) == 0&#60;br /&#62;
        medium.sound_speed(current_x_start:current_x_end, :, reflector_y_pos:end) = sound_speed_water;&#60;br /&#62;
        medium.density(current_x_start:current_x_end, :, reflector_y_pos:end) = density_water;&#60;br /&#62;
    else&#60;br /&#62;
        medium.sound_speed(current_x_start:current_x_end, :, reflector_y_pos:end) = sound_speed_air;&#60;br /&#62;
        medium.density(current_x_start:current_x_end, :, reflector_y_pos:end) = density_air;&#60;/p&#62;
&#60;p&#62;    end&#60;br /&#62;
end&#60;br /&#62;
imagesc(medium.sound_speed),&#60;br /&#62;
%设置换能器的位置和检测传感器的位置&#60;br /&#62;
tr.element_width = 12; % 换能器宽度所占网格数&#60;br /&#62;
tr.element_length= 1;% 换能器长度所占网格数&#60;br /&#62;
tr.element_spacing =1; % 换能器间隔所占网格数&#60;br /&#62;
tr.number_elements= 80; % 换能器数量&#60;br /&#62;
tr.radius=Inf;&#60;br /&#62;
transducer_width = tr.number_elements*tr.element_width+(tr.number_elements - 1) * tr.element_spacing;&#60;br /&#62;
tr.position = round([Nx/2 - transducer_width/2,Ny-PML_size]);&#60;br /&#62;
tr.active_elements=zeros(tr.number_elements,1);&#60;br /&#62;
tr.active_elements(1:80)=1;&#60;br /&#62;
% 定义激励超声源信号&#60;br /&#62;
%transducer.mask = transducer_mask;&#60;br /&#62;
source_strength = 1e6;          % [Pa]&#60;br /&#62;
tone_burst_freq = 10e6;        % [Hz]&#60;br /&#62;
tone_burst_cycles = 5;&#60;br /&#62;
t_end = 1e-6; % 设置仿真结束时间为10个周期&#60;br /&#62;
kgrid.makeTime(medium.sound_speed, [], t_end); % 使用kgrid的makeTime方法生成时间数组&#60;br /&#62;
% create the input signal using toneBurst&#60;br /&#62;
input_signal = toneBurst(1/kgrid.dt, tone_burst_freq, tone_burst_cycles);&#60;br /&#62;
%input_signal=(source_strength./(medium.sound_speed* medium.density)).*input_signal;&#60;br /&#62;
tr.input_signal=input_signal;&#60;br /&#62;
transducer=kWaveTransducer(kgrid, tr);&#60;br /&#62;
sensor_data= kspaceFirstOrder2D(kgrid, medium, transducer,transducer);
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Mekdes Bezabh on "Regarding Homogenous B-mode image simulation"</title>
			<link>http://www.k-wave.org/forum/topic/regarding-homogenous-b-mode-image-simulation#post-9215</link>
			<pubDate>Wed, 21 May 2025 18:15:24 +0000</pubDate>
			<dc:creator>Mekdes Bezabh</dc:creator>
			<guid isPermaLink="false">9215@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Dear All,&#60;/p&#62;
&#60;p&#62;I have some questions regarding the code &#34;example_us_bmode_linear_transducer.&#34; I am trying to create a homogeneous B-mode image without any artifacts. I have tested different values for the tone burst frequency—3.47 MHz, 7.8 MHz, and 15.62 MHz—along with varying values for the medium's alpha coefficient and alpha power, while keeping the sound speed and density uniform. I am using a plane wave setup with the focus set to infinity.&#60;/p&#62;
&#60;p&#62;However, I encountered some unexpected results: &#60;/p&#62;
&#60;p&#62;1. At a frequency of 3.47 MHz, the resulting B-mode image was not as expected.&#60;br /&#62;
2. At 7.8 MHz, I observed a bright line in the middle of the final B-mode image.&#60;br /&#62;
3. The same issue occurred at 15.62 MHz.&#60;/p&#62;
&#60;p&#62;I would appreciate your assistance in determining whether my code is correct, as this simulation software is crucial for my project. I would also like to share my code for your review if you have some time to look at it and provide your valuable suggestions.&#60;/p&#62;
&#60;p&#62;Thank you for your attention.&#60;/p&#62;
&#60;p&#62;The code:&#60;/p&#62;
&#60;p&#62;RUN_SIMULATION  = true;    &#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% DEFINE THE K-WAVE GRID&#60;br /&#62;
% =========================================================================&#60;br /&#62;
% set the size of the perfectly matched layer (PML)&#60;br /&#62;
pml_x_size = 20;                % [grid points]&#60;br /&#62;
pml_y_size = 10;                % [grid points]&#60;br /&#62;
pml_z_size = 1;                 % [grid points]&#60;br /&#62;
% set total number of grid points not including the PML&#60;br /&#62;
Nx = 256*2 - 2 * pml_x_size;      % [grid points]&#60;br /&#62;
Ny = 128*2 - 2 * pml_y_size;      % [grid points]&#60;br /&#62;
Nz = 2;                       % [grid points]                 %128 - 2 * pml_z_size;&#60;br /&#62;
x= 40e-3;&#60;br /&#62;
dx = x / Nx;&#60;br /&#62;
dy = dx;&#60;br /&#62;
dz = dx;                    % [m]&#60;br /&#62;
% create the k-space grid&#60;br /&#62;
kgrid = kWaveGrid(Nx, dx, Ny, dy, Nz, dz);&#60;br /&#62;
% =========================================================================&#60;br /&#62;
% DEFINE THE MEDIUM PARAMETERS&#60;br /&#62;
% =========================================================================&#60;br /&#62;
% define the properties of the propagation medium&#60;br /&#62;
c0 = 1540;                      % [m/s]&#60;br /&#62;
rho0 = 1000;                    % [kg/m^3]&#60;br /&#62;
% medium.alpha_mode = 'no_dispersion';&#60;br /&#62;
medium.alpha_coeff = 0.5;      % [dB/(MHz^y cm)]&#60;br /&#62;
medium.alpha_power = 1.0;&#60;/p&#62;
&#60;p&#62;% create the time array&#60;br /&#62;
t_end = (Nx * dx) * 2.2 / c0;   % [s]&#60;br /&#62;
kgrid.makeTime(c0, [], t_end);&#60;br /&#62;
% =========================================================================&#60;br /&#62;
% DEFINE THE INPUT SIGNAL&#60;br /&#62;
% =========================================================================&#60;br /&#62;
% define properties of the input signal&#60;br /&#62;
source_strength = 1e6;          % [Pa]&#60;br /&#62;
tone_burst_freq = 15.62e6;        % [Hz]   7.8 MHz, 3.47 MHz&#60;br /&#62;
tone_burst_cycles = 4;&#60;br /&#62;
% create the input signal using toneBurst&#60;br /&#62;
input_signal = toneBurst(1/kgrid.dt, tone_burst_freq, tone_burst_cycles);&#60;br /&#62;
% scale the source magnitude by the source_strength divided by the&#60;br /&#62;
% impedance (the source is assigned to the particle velocity)&#60;br /&#62;
input_signal = (source_strength ./ (c0 * rho0)) .* input_signal;&#60;br /&#62;
% =========================================================================&#60;br /&#62;
% DEFINE THE ULTRASOUND TRANSDUCER&#60;br /&#62;
% =========================================================================&#60;br /&#62;
% physical properties of the transducer&#60;br /&#62;
transducer.number_elements = 32;  	% total number of transducer elements&#60;br /&#62;
transducer.element_width = 2;       % width of each element [grid points]&#60;br /&#62;
transducer.element_length = 1;     %24;  	% length of each element [grid points]&#60;br /&#62;
transducer.element_spacing = 0;  	% spacing (kerf  width) between the elements [grid points]&#60;br /&#62;
transducer.radius = inf;            % radius of curvature of the transducer [m]&#60;br /&#62;
% calculate the width of the transducer in grid points&#60;br /&#62;
transducer_width = transducer.number_elements * transducer.element_width ...&#60;br /&#62;
    + (transducer.number_elements - 1) * transducer.element_spacing;&#60;br /&#62;
% use this to position the transducer in the middle of the computational grid&#60;br /&#62;
transducer.position = round([1, Ny/2 - transducer_width/2, Nz/2 - transducer.element_length/2]);&#60;br /&#62;
% properties used to derive the beamforming delays&#60;br /&#62;
transducer.sound_speed = c0;                    % sound speed [m/s]&#60;br /&#62;
% transducer.focus_distance = Inf;  %40e-3;              % focus distance [m]&#60;br /&#62;
% transducer.elevation_focus_distance = Inf;  %19e-3;    % focus distance in the elevation plane [m]&#60;br /&#62;
transducer.steering_angle = 0;                  % steering angle [degrees]&#60;br /&#62;
% apodization&#60;br /&#62;
transducer.transmit_apodization = 'Hanning';&#60;br /&#62;
transducer.receive_apodization = 'Rectangular';&#60;br /&#62;
% define the transducer elements that are currently active&#60;br /&#62;
number_active_elements = 32;&#60;br /&#62;
transducer.active_elements = ones(transducer.number_elements, 1);&#60;br /&#62;
% append input signal used to drive the transducer&#60;br /&#62;
transducer.input_signal = input_signal;&#60;br /&#62;
% create the transducer using the defined settings&#60;br /&#62;
transducer = kWaveTransducer(kgrid, transducer);&#60;br /&#62;
% print out transducer properties&#60;br /&#62;
transducer.properties;&#60;br /&#62;
% =========================================================================&#60;br /&#62;
% DEFINE THE MEDIUM PROPERTIES&#60;br /&#62;
% =========================================================================&#60;br /&#62;
% define a large image size to move across&#60;br /&#62;
number_scan_lines = 96;&#60;br /&#62;
Nx_tot = Nx;&#60;br /&#62;
Ny_tot = Ny + number_scan_lines * transducer.element_width;&#60;br /&#62;
Nz_tot = Nz;&#60;br /&#62;
% define a random distribution of scatterers for the medium&#60;br /&#62;
background_map_mean = 1;&#60;br /&#62;
background_map_std = 0.008;&#60;br /&#62;
background_map = background_map_mean + background_map_std * randn([Nx_tot, Ny_tot, Nz_tot]);&#60;br /&#62;
sound_speed_map = c0 * ones(Nx_tot, Ny_tot, Nz_tot) .* background_map;&#60;br /&#62;
density_map = rho0 * ones(Nx_tot, Ny_tot, Nz_tot) .* background_map;  &#60;/p&#62;
&#60;p&#62;% RUN THE SIMULATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% preallocate the storage&#60;br /&#62;
scan_lines = zeros(number_scan_lines, kgrid.Nt);&#60;/p&#62;
&#60;p&#62;% set the input settings&#60;br /&#62;
input_args = {...&#60;br /&#62;
    'PMLInside', false, 'PMLSize', [pml_x_size, pml_y_size, pml_z_size], ...&#60;br /&#62;
    'DataCast', DATA_CAST, 'DataRecast', true, 'PlotSim', false};&#60;br /&#62;
% run the simulation if set to true, otherwise, load previous results from&#60;br /&#62;
% disk&#60;br /&#62;
h = waitbar(0,'Please wait...');&#60;br /&#62;
if RUN_SIMULATION&#60;br /&#62;
    % set medium position&#60;br /&#62;
    medium_position = 1;&#60;br /&#62;
    % loop through the scan lines&#60;br /&#62;
    for scan_line_index = 1:number_scan_lines&#60;br /&#62;
        scan_line_index&#60;br /&#62;
        waitbar(scan_line_index/number_scan_lines,h)&#60;br /&#62;
        % update the command line status&#60;br /&#62;
        disp('');&#60;br /&#62;
        disp(['Computing scan line ' num2str(scan_line_index) ' of ' num2str(number_scan_lines)]);&#60;/p&#62;
&#60;p&#62;        % load the current section of the medium&#60;br /&#62;
        medium.sound_speed = sound_speed_map(:, medium_position:medium_position + Ny - 1, :);&#60;br /&#62;
        medium.density = density_map(:, medium_position:medium_position + Ny - 1, :);&#60;/p&#62;
&#60;p&#62;        % run the simulation&#60;br /&#62;
        sensor_data = kspaceFirstOrder3D(kgrid, medium, transducer, transducer, input_args{:});&#60;br /&#62;
        % extract the scan line from the sensor data&#60;br /&#62;
        scan_lines(scan_line_index, :) = transducer.scan_line(sensor_data);&#60;/p&#62;
&#60;p&#62;        % update medium position&#60;br /&#62;
        medium_position = medium_position + transducer.element_width;&#60;br /&#62;
    end&#60;br /&#62;
    % save the scan lines to disk&#60;br /&#62;
    save HomogeneousTriaNew_scan_lines.mat;&#60;/p&#62;
&#60;p&#62;else&#60;/p&#62;
&#60;p&#62;    % load the scan lines from disk&#60;br /&#62;
    load ('HomogeneousReferenceNew_scan_lines.mat');&#60;/p&#62;
&#60;p&#62;end&#60;br /&#62;
scan_lines_saved = scan_lines;&#60;br /&#62;
scan_lines = scan_lines_saved;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jgreen19 on "kspaceFirstOrder2D - function not recognised as valid"</title>
			<link>http://www.k-wave.org/forum/topic/kspacefirstorder2d-function-not-recognised-as-valid#post-9214</link>
			<pubDate>Sat, 10 May 2025 14:41:13 +0000</pubDate>
			<dc:creator>jgreen19</dc:creator>
			<guid isPermaLink="false">9214@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;have managed to solve somehow, no need to respond!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jgreen19 on "kspaceFirstOrder2D - function not recognised as valid"</title>
			<link>http://www.k-wave.org/forum/topic/kspacefirstorder2d-function-not-recognised-as-valid#post-9213</link>
			<pubDate>Fri, 09 May 2025 11:35:02 +0000</pubDate>
			<dc:creator>jgreen19</dc:creator>
			<guid isPermaLink="false">9213@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi,&#60;br /&#62;
I've been able to run simple functions using k-Wave, then somehow without touching it, MATLAB is now failing to recognize:&#60;br /&#62;
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor);&#60;br /&#62;
function.&#60;/p&#62;
&#60;p&#62;Even when using the code directly copy and pasted from chapter 3 of the user manual. I wonder if there is a solution to this? Perhaps I have installed the add-on incorrectly, but I feel I have tried all methods, but as a simple fact, no code (no matter how simple) is able to be run at the moment.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Sun_hh on "Cuda code kspaceFirstOrder3DG not running on Windows 11"</title>
			<link>http://www.k-wave.org/forum/topic/cuda-code-kspacefirstorder3dg-not-running-on-windows-11#post-9212</link>
			<pubDate>Wed, 07 May 2025 17:39:53 +0000</pubDate>
			<dc:creator>Sun_hh</dc:creator>
			<guid isPermaLink="false">9212@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;the same problem，need help
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ClaireH on "pstdElastic3D in layered fluid and elastic media"</title>
			<link>http://www.k-wave.org/forum/topic/pstdelastic3d-in-layered-fluid-and-elastic-media#post-9211</link>
			<pubDate>Mon, 28 Apr 2025 14:23:22 +0000</pubDate>
			<dc:creator>ClaireH</dc:creator>
			<guid isPermaLink="false">9211@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi,&#60;br /&#62;
I'm a new k-Wave user interested in simulating ultrasound propagation through a layered medium that includes both fluid and elastic materials. The layers, in order of wave propagation, are:&#60;/p&#62;
&#60;p&#62;water → solid → soft tissue → solid → thin water layer → air&#60;/p&#62;
&#60;p&#62;I’m considering using the pstdElastic3D model for this simulation, and I’d like to know:&#60;/p&#62;
&#60;p&#62;Can pstdElastic3D handle a mixture of elastic and fluid media?&#60;/p&#62;
&#60;p&#62;Especially, can it accurately model the interface between water and air, given the large impedance mismatch and strong reflections at that boundary?&#60;/p&#62;
&#60;p&#62;Thanks so much for your help!
&#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>

	</channel>
</rss>
