<?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; Topic: why the simulation with different z-step in 3D model is different?</title>
		<link>http://www.k-wave.org/forum/topic/why-the-simulation-with-different-z-step-in-3d-model-is-different</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 00:20:54 +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/topic/why-the-simulation-with-different-z-step-in-3d-model-is-different" rel="self" type="application/rss+xml" />

		<item>
			<title>bencox on "why the simulation with different z-step in 3D model is different?"</title>
			<link>http://www.k-wave.org/forum/topic/why-the-simulation-with-different-z-step-in-3d-model-is-different#post-8570</link>
			<pubDate>Wed, 13 Jul 2022 17:05:00 +0000</pubDate>
			<dc:creator>bencox</dc:creator>
			<guid isPermaLink="false">8570@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Kevin, &#60;/p&#62;
&#60;p&#62;It's probably best to keep the grid spacings the same in all directions, ie. &#60;code&#62;dx = dy = dz&#60;/code&#62;. If they are different then k-Wave will support a different range of frequencies in different directions, which might matter sometimes, eg. if the nonlinearity in your simulation generates harmonics, different directions may support different numbers of harmonics.&#60;/p&#62;
&#60;p&#62;Best wishes&#60;br /&#62;
Ben
&#60;/p&#62;</description>
		</item>
		<item>
			<title>kevin durant on "why the simulation with different z-step in 3D model is different?"</title>
			<link>http://www.k-wave.org/forum/topic/why-the-simulation-with-different-z-step-in-3d-model-is-different#post-8548</link>
			<pubDate>Sun, 12 Jun 2022 14:08:09 +0000</pubDate>
			<dc:creator>kevin durant</dc:creator>
			<guid isPermaLink="false">8548@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Dear author:&#60;/p&#62;
&#60;p&#62;I use the 'kspaceFirstOrder3D' function for 3D simulation, but the results are different when the different simulation step size in z-axis is set. I wonder if some parameters were wrong in the code.  &#60;/p&#62;
&#60;p&#62;Here is the code. P0 is the input computed through Rayleigh-sommerfeld Integral of focused transducer at 20mm before the focus. The result is different with the &#60;code&#62;dz = 0.1e-3; Nz = 311&#60;/code&#62;.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;clear;
clc;
close all;

% =========================================================================
% DEFINE THE K-WAVE GRID
% =========================================================================
% initial condition
[FileName, FileDir] = uigetfile(&#38;#39;.mat&#38;#39;, &#38;#39;Initial Plane File&#38;#39;);
P0 = load(fullfile(FileDir, FileName));
P0 = cell2mat(struct2cell(P0));

% set total number of grid points not including the PML
[Nx, Ny] = size(P0);              % [grid points]
Nz = 161;   ;     % [grid points]

% calculate the spacing between the grid points
dx = 0.2e-3;                    % [m]
dy = dx;                        % [m]
dz = 0.2e-3;                    % [m]

% set desired grid size in the x-direction not including the PML
x = Nx * dx;                  % [m]
y = Ny * dy;
z = Nz * dz;                  % [m]

% create the k-space grid
kgrid = kWaveGrid(Nx, dx, Ny, dy, Nz, dz);

% =========================================================================
% DEFINE THE MEDIUM PARAMETERS
% =========================================================================
sound_speed_Water = 1482;
medium.sound_speed = sound_speed_Water * ones(Nx, Ny, Nz);	    % [m/s]
medium.density = 994 * ones(Nx, Ny, Nz);       % [kg/m^3]
medium.alpha_coeff = 0 * ones(Nx, Ny, Nz);
medium.alpha_power = 1;
medium.alpha_mode = &#38;#39;no_dispersion&#38;#39;;
medium.BonA = 5.2 * ones(Nx, Ny, Nz);

pml_size = 10;               % PML size
pml_alpha = 2;               % PML absorption coefficient [Np/grid point]

% =========================================================================
% DEFINE THE INPUT SIGNAL
% =========================================================================
% create the time array
source_freq = 1.2e6;       % [Hz]
kgrid.makeTime(medium.sound_speed);
dT = 1/source_freq;
NumT = ceil(dT/kgrid.dt/10) * 10;
T = kgrid.dt * kgrid.Nt;
kgrid.dt = dT/NumT;
Nt = ceil(T/kgrid.dt);
kgrid.t_array = [0:1:Nt] * kgrid.dt;

% define properties of the input signal
source.p_mask = zeros(Nx, Ny, Nz);
source.p_mask(:, :, 11) = 1;

for i = 1:numel(P0)
    source.p(i,:) = abs(P0(i)) * sin(2*pi*source_freq*kgrid.t_array + angle(P0(i)));
end

% define a series of Cartesian points to collect the data
sensor.mask = zeros(Nx, Ny, Nz);
sensor.mask(ceil(Nx/2), :, :) = 1;
sensor.record_start_index = ceil(numel(kgrid.t_array)/2);

% define the field parameters to record
sensor.record = {&#38;#39;p&#38;#39;, &#38;#39;p_max_all&#38;#39;,&#38;#39;p_final&#38;#39;};

input_args = {&#38;#39;DisplayMask&#38;#39;, sensor.mask, &#38;#39;DataCast&#38;#39;, &#38;#39;single&#38;#39;, ...
    &#38;#39;CartInterp&#38;#39;, &#38;#39;nearest&#38;#39;, &#38;#39;PMLSize&#38;#39;, [10 10 10], &#38;#39;PMLAlpha&#38;#39;, pml_alpha, &#38;#39;PMLInside&#38;#39;, false};

% run the simulation
sensor_data = kspaceFirstOrder3D(kgrid, medium, source, sensor, input_args{:});&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Best wishes&#60;br /&#62;
kevin
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
