<?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: hologram focal length</title>
		<link>http://www.k-wave.org/forum/topic/hologram-focal-length</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Tue, 12 May 2026 23:07:57 +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/hologram-focal-length" rel="self" type="application/rss+xml" />

		<item>
			<title>hyeongyu on "hologram focal length"</title>
			<link>http://www.k-wave.org/forum/topic/hologram-focal-length#post-8875</link>
			<pubDate>Mon, 31 Jul 2023 08:38:39 +0000</pubDate>
			<dc:creator>hyeongyu</dc:creator>
			<guid isPermaLink="false">8875@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi, &#60;/p&#62;
&#60;p&#62;I am trying to simulate acoustic hologram in 3D dimension. My goal is to use the acoustic hologram to focus the beam where I want it. i tried the example (&#60;a href=&#34;http://www.k-wave.org/documentation/example_tvsp_equivalent_source_holography.php&#34; rel=&#34;nofollow&#34;&#62;http://www.k-wave.org/documentation/example_tvsp_equivalent_source_holography.php&#60;/a&#62;)&#60;/p&#62;
&#60;p&#62;First, i set my source on 30 index in z-direction. and i want to focus 80 index(5mm focusing)&#60;br /&#62;
But my beam focused on 60 index in z-direction.&#60;br /&#62;
And i changed the environment. Source is on 50 index, and focusing point is 100index.&#60;/p&#62;
&#60;p&#62;What am I doing wrong?&#60;br /&#62;
here is my matlab k-wave code.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;clearvars;
clc;
close all;
clear;
% =========================================================================
% DEFINE SIMULATION SETTINGS
% =========================================================================

% define grid properties
Nx = 50;                    % number of grid points in the x direction
Ny = 50;                    % number of grid points in the y direction
Nz = 150;                    % number of grid points in the z direction
dx = 1e-4;                  % grid point spacing [m]
c0 = 1500;                  % sound speed [m/s]

% define source properties
source_freq = 2e6;          % [Hz]
input_plane_z_index = 100;  	% [grid points]

% define simulation properties
cfl = 0.3;
t_end = 10e-6;               % [s]

% settings for calculating the equivalent source
grid_expansion = 0;
number_optimisation_steps = 20;

% =========================================================================
% SIMULATE MEASURED DATA
% =========================================================================

% create the computational grid
kgrid = kWaveGrid(Nx, dx, Ny, dx, Nz, dx);

% assign medium properties
medium.sound_speed = c0;

% compute sampling rates, forcing points-per-period to be an integer
points_per_wavelength = c0 / (source_freq * dx);
points_per_period = round(points_per_wavelength / cfl);

% compute corresponding time spacing
dt = 1 / (points_per_period * source_freq);    

% create the time array
Nt = round(t_end / dt);
kgrid.setTime(Nt, dt);

% define rectangular source mask
source.p_mask = zeros(Nx, Ny, Nz);
source.p_mask(20:30, 20:30 , 50) = 1;

% define source signal as a continuous wave sinusoid
source.p = createCWSignals(kgrid.t_array, source_freq, 1, 0);

%% 센서 위치
% define two planar sensor masks using opposing corners of a cuboid
sensor.mask = [1, 1, input_plane_z_index, Nx, Ny,   input_plane_z_index;
                        1, Ny/2, 1, Nx, Ny/2, Nz].&#38;#39;;
%% 센서가 데이터를 받아들이는 시작점 설정
% set the start time to only record the last three periods
sensor.record_start_index = kgrid.Nt - 3 * points_per_period + 1;

% assign input arguments
input_args = {...
    &#38;#39;PMLInside&#38;#39;, false&#38;#39;, ...
    &#38;#39;PMLSize&#38;#39;, &#38;#39;auto&#38;#39;, ..., Nx, Ny
    &#38;#39;DataCast&#38;#39;, &#38;#39;single&#38;#39;, ...
    &#38;#39;DataRecast&#38;#39;, true, ...
    };
%% 시뮬레이션 하는 파트 kspacefirstorder를 이용
% run k-Wave simulation
sensor_data = kspaceFirstOrder3D(kgrid, medium, source, sensor, input_args{:});
%% extractAmpPhase를 이용하여 센서 데이터로부터 크기와 위상 추출하기
% extract the amplitude and phase from the time series data
[input_plane_amp, input_plane_phase] = extractAmpPhase(squeeze(sensor_data(1).p), 1/kgrid.dt, source_freq, ...
    &#38;#39;Dim&#38;#39;, 3, ...
    &#38;#39;FFTPadding&#38;#39;, 1, ...
    &#38;#39;Window&#38;#39;, &#38;#39;Rectangular&#38;#39;);

[output_plane_amp, output_plane_phase] = extractAmpPhase(squeeze(sensor_data(2).p), 1/kgrid.dt, source_freq, ...
    &#38;#39;Dim&#38;#39;, 3, ...
    &#38;#39;FFTPadding&#38;#39;, 1, ...
    &#38;#39;Window&#38;#39;, &#38;#39;Rectangular&#38;#39;);
%%
% form data into matrix of complex values for use with angularSpectrumCW
input_plane_complex = input_plane_amp .* exp(1i * input_plane_phase);

% =========================================================================
% PROJECT MEASURED DATA USING A DIRICHLET BOUNDARY CONDITION
% =========================================================================

%% 디리클레 조건에서의 프로젝션

% assign source mask where data was measured
clear source;
source.p_mask = zeros(Nx, Ny, Nz);
source.p_mask(:, :, 100) = 1;

% assign the measured data as a dirichlet boundary condition
source.p = createCWSignals(kgrid.t_array, source_freq, input_plane_amp(:), input_plane_phase(:));
source.p_mode = &#38;#39;dirichlet&#38;#39;;

% run k-Wave simulation to project measured data
sensor_data = kspaceFirstOrder3D(kgrid, medium, source, sensor, input_args{:});

% extract amplitude from the time series data
proj_dirch = extractAmpPhase(squeeze(sensor_data(2).p), 1/kgrid.dt, source_freq, ...
    &#38;#39;Dim&#38;#39;, 3, ...
    &#38;#39;FFTPadding&#38;#39;, 1, ...
    &#38;#39;Window&#38;#39;, &#38;#39;Rectangular&#38;#39;);

% =========================================================================
% PROJECT MEASURED DATA USING THE ANGULAR SPECTRUM METHOD
% =========================================================================

% run angular spectrum to project measured data
proj_asm = angularSpectrumCW(input_plane_complex, dx, ...
    (0:(Nz - input_plane_z_index)) * dx, source_freq, c0, ...
    &#38;#39;FFTLength&#38;#39;, 512);

% extract amplitude from required plane
proj_asm = squeeze(abs(proj_asm(:, Ny/2, :)));

% =========================================================================
% CALCULATE EQUIVALENT SOURCE
% =========================================================================

% offset between the input plane and source plane [grid points]
source_offset = input_plane_z_index - 1;

% calculate equivalent source
[source_estimate, optim_params] = calculateMassSourceCW(input_plane_complex, dx, ...
    source_freq, c0, source_offset, grid_expansion, ...
    &#38;#39;NumSteps&#38;#39;, number_optimisation_steps);

% =========================================================================
% PROJECT MEASURED DATA USING EQUIVALENT SOURCE
% =========================================================================

% assign source mask at the beginning of the grid
clear source;
source.p_mask = zeros(Nx, Ny, Nz);
source.p_mask(:, :, 50) = 1;

% assign the measured data as a dirichlet boundary condition
source.p = createCWSignals(kgrid.t_array, source_freq, abs(source_estimate(:)), angle(source_estimate(:)));

% run k-Wave simulation to project measured data
sensor_data = kspaceFirstOrder3D(kgrid, medium, source, sensor, input_args{:});

% extract amplitude from the time series data
proj_eqs = extractAmpPhase(squeeze(sensor_data(2).p), 1/kgrid.dt, source_freq, ...
    &#38;#39;Dim&#38;#39;, 3, ...
    &#38;#39;FFTPadding&#38;#39;, 1, ...
    &#38;#39;Window&#38;#39;, &#38;#39;Rectangular&#38;#39;);

proj_eqsA = extractAmpPhase(squeeze(sensor_data(2).p), 1/kgrid.dt, source_freq, ...
    &#38;#39;Dim&#38;#39;, 3, ...
    &#38;#39;FFTPadding&#38;#39;, 1, ...
    &#38;#39;Window&#38;#39;, &#38;#39;Rectangular&#38;#39;);

proj_eqsL = extractAmpPhase(squeeze(sensor_data(1).p), 1/kgrid.dt, source_freq, ...
    &#38;#39;Dim&#38;#39;, 3, ...
    &#38;#39;FFTPadding&#38;#39;, 1, ...
    &#38;#39;Window&#38;#39;, &#38;#39;Rectangular&#38;#39;);
% =========================================================================
% VISUALISATION
% =========================================================================
%%
% plot the input data
figure;
title(&#38;quot;kspace(original)&#38;quot;)
subplot(1, 2, 1);
imagesc(input_plane_amp);
axis image;
colorbar;
title(&#38;#39;Input Plane - Amplitude&#38;#39;);

subplot(1, 2, 2);
imagesc(input_plane_phase);
axis image;
colorbar;
title(&#38;#39;Input Plane - Phase&#38;#39;);

% plot the reconstructed source plane
figure;
title(&#38;#39;equivalent source&#38;#39;)
subplot(1, 2, 1);
imagesc(abs(source_estimate));
axis image;
colorbar;
title(&#38;#39;Equivalent Source - Amplitude&#38;#39;);

subplot(1, 2, 2);
imagesc(angle(source_estimate));
axis image;
colorbar;
title(&#38;#39;Equivalent Source - Phase&#38;#39;);

% plot the output data
figure;
imagesc(proj_eqsA);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;&#60;img src=&#34;https://i.ibb.co/xMCmF69/image.png&#34; /&#62;&#60;br /&#62;
&#60;img src=&#34;https://i.ibb.co/qNrX2fs/2.png&#34; /&#62;&#60;br /&#62;
&#60;img src=&#34;https://i.ibb.co/zVd3NBM/3.png&#34; /&#62;&#60;/p&#62;
&#60;p&#62;Thank you&#60;br /&#62;
Hyeongyu
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
