<?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: Ultrasonic three-layer medium propagation simulation</title>
		<link>http://www.k-wave.org/forum/topic/ultrasonic-three-layer-medium-propagation-simulation</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 14:55:42 +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/ultrasonic-three-layer-medium-propagation-simulation" rel="self" type="application/rss+xml" />

		<item>
			<title>Bradley Treeby on "Ultrasonic three-layer medium propagation simulation"</title>
			<link>http://www.k-wave.org/forum/topic/ultrasonic-three-layer-medium-propagation-simulation#post-6833</link>
			<pubDate>Wed, 10 Apr 2019 12:50:53 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">6833@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi zhangwei198202,&#60;/p&#62;
&#60;p&#62;You set:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;air(2/3*Nx:end, :) = 2;&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;But later use:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;medium.sound_speed_compression(air == 1) = cp3;&#60;/code&#62; (etc)&#60;/p&#62;
&#60;p&#62;You should use either both 1 or both 2.&#60;/p&#62;
&#60;p&#62;Brad
&#60;/p&#62;</description>
		</item>
		<item>
			<title>zhangwei198202 on "Ultrasonic three-layer medium propagation simulation"</title>
			<link>http://www.k-wave.org/forum/topic/ultrasonic-three-layer-medium-propagation-simulation#post-6789</link>
			<pubDate>Mon, 18 Mar 2019 16:06:31 +0000</pubDate>
			<dc:creator>zhangwei198202</dc:creator>
			<guid isPermaLink="false">6789@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello, Bradley Treeby, thank you for your advice. I carefully refer to the example &#34;Shear Waves And Critical Angle Reflection Example&#34; in the software, because this example is very similar to the model I want to do. But my ability is limited, I can't fully understand the program. I added a layer of air medium to the program, placed it on the bottom as the third layer medium, and set all the parameters of the air to zero. Although the program can run, I know that it is definitely not correct. I sent the program to you. Please help me check it.&#60;br /&#62;
What I don't understand is that the difference in acoustic impedance between the second medium and the third layer is obvious, why the reflected wave is not visible in the second medium.&#60;br /&#62;
I hope that you can take the time to give your answer, thank you very much!&#60;br /&#62;
Here is the program:&#60;/p&#62;
&#60;p&#62;clearvars;&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% SIMULATION PARAMETERS&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% change scale to 2 to reproduce higher resolution figures in help file&#60;br /&#62;
scale               = 1;&#60;/p&#62;
&#60;p&#62;% create the computational grid&#60;br /&#62;
PML_size            = 10;                           % [grid points]&#60;br /&#62;
Nx                  = 128*scale - 2*PML_size;       % [grid points]&#60;br /&#62;
Ny                  = 192*scale - 2*PML_size;       % [grid points]&#60;br /&#62;
dx                  = 0.5e-3/scale;                 % [m]&#60;br /&#62;
dy                  = 0.5e-3/scale;                 % [m]&#60;br /&#62;
kgrid               = kWaveGrid(Nx, dx, Ny, dy);&#60;/p&#62;
&#60;p&#62;% define the medium properties for the top layer&#60;br /&#62;
cp1                 = 1540;     % compressional wave speed [m/s]&#60;br /&#62;
cs1                 = 0;        % shear wave speed [m/s]&#60;br /&#62;
rho1                = 1000;     % density [kg/m^3]&#60;br /&#62;
alpha0_p1           = 0.1;      % compressional absorption [dB/(MHz^2 cm)]&#60;br /&#62;
alpha0_s1           = 0.1;      % shear absorption [dB/(MHz^2 cm)]&#60;/p&#62;
&#60;p&#62;% define the medium properties for the bottom layer&#60;br /&#62;
cp2                 = 3000;     % compressional wave speed [m/s]&#60;br /&#62;
cs2                 = 1400;     % shear wave speed [m/s]&#60;br /&#62;
rho2                = 1850;     % density [kg/m^3]&#60;br /&#62;
alpha0_p2           = 1;        % compressional absorption [dB/(MHz^2 cm)]&#60;br /&#62;
alpha0_s2           = 1;        % shear absorption [dB/(MHz^2 cm)]&#60;/p&#62;
&#60;p&#62;% define the third layer medium properties for the bottom layer&#60;br /&#62;
cp3                 = 0;     % compressional wave speed [m/s]&#60;br /&#62;
cs3                 = 0;     % shear wave speed [m/s]&#60;br /&#62;
rho3                = 0;     % density [kg/m^3]&#60;br /&#62;
alpha0_p3           = 0;        % compressional absorption [dB/(MHz^2 cm)]&#60;br /&#62;
alpha0_s3           = 0;        % shear absorption [dB/(MHz^2 cm)]&#60;/p&#62;
&#60;p&#62;% create the time array&#60;br /&#62;
cfl                 = 0.1;&#60;br /&#62;
t_end               = 60e-6;&#60;br /&#62;
kgrid.makeTime(cp1, cfl, t_end);&#60;/p&#62;
&#60;p&#62;% define position of heterogeneous slab&#60;br /&#62;
slab                = zeros(Nx, Ny);&#60;br /&#62;
slab(Nx/3:2/3*Nx, :)   = 1;&#60;/p&#62;
&#60;p&#62;% define position of heterogeneous slab&#60;br /&#62;
air                = zeros(Nx, Ny);&#60;br /&#62;
air(2/3*Nx:end, :)   = 2;&#60;/p&#62;
&#60;p&#62;% define the source geometry in SI units (where 0, 0 is the grid center)&#60;br /&#62;
arc_pos             = [-15e-3, -25e-3]; % [m]&#60;br /&#62;
focus_pos           = [5e-3, 5e-3];     % [m]&#60;br /&#62;
radius              = 25e-3;            % [m]&#60;br /&#62;
diameter            = 20e-3;            % [m]&#60;/p&#62;
&#60;p&#62;% define the driving signal&#60;br /&#62;
source_freq         = 500e3;    % [Hz]&#60;br /&#62;
source_strength     = 1e6;      % [Pa]&#60;br /&#62;
source_cycles       = 3;        % number of tone burst cycles&#60;/p&#62;
&#60;p&#62;% define the sensor to record the maximum particle velocity everywhere&#60;br /&#62;
sensor.record = {'u_max_all'};&#60;/p&#62;
&#60;p&#62;% set the input arguments&#60;br /&#62;
input_args = {'PMLSize', PML_size, 'PMLAlpha', 2, 'PlotPML', false, ...&#60;br /&#62;
    'PMLInside', false, 'PlotScale', [-1, 1]*source_strength, ...&#60;br /&#62;
    'DisplayMask', 'off', 'DataCast', 'single'};&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% FLUID SIMULATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% assign the medium properties&#60;br /&#62;
medium.sound_speed            = cp1*ones(Nx, Ny);&#60;br /&#62;
medium.sound_speed(slab == 1) = cp2;&#60;br /&#62;
medium.density                = rho1*ones(Nx, Ny);&#60;br /&#62;
medium.density(slab == 1)     = rho2;&#60;br /&#62;
medium.alpha_coeff            = alpha0_p1*ones(Nx, Ny);&#60;br /&#62;
medium.alpha_coeff(slab == 1) = alpha0_p2;&#60;br /&#62;
medium.alpha_power            = 2;&#60;/p&#62;
&#60;p&#62;% convert the source parameters to grid points&#60;br /&#62;
arc_pos     = round(arc_pos / dx) + [Nx/2, Ny/2];&#60;br /&#62;
focus_pos   = round(focus_pos / dx) + [Nx/2, Ny/2];&#60;br /&#62;
radius      = round(radius / dx);&#60;br /&#62;
diameter    = round(diameter / dx);&#60;/p&#62;
&#60;p&#62;% force the diameter to be odd&#60;br /&#62;
if ~rem(diameter, 2)&#60;br /&#62;
    diameter = diameter + 1;&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;% generate the source geometry&#60;br /&#62;
source_mask = makeArc([Nx, Ny], arc_pos, radius, diameter, focus_pos);&#60;/p&#62;
&#60;p&#62;% assign the source&#60;br /&#62;
source.p_mask = source_mask;&#60;br /&#62;
source.p = source_strength*toneBurst(1/kgrid.dt, source_freq, source_cycles);&#60;/p&#62;
&#60;p&#62;% run the fluid simulation&#60;br /&#62;
sensor_data_fluid = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% ELASTIC SIMULATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% define the medium properties&#60;br /&#62;
clear medium&#60;br /&#62;
medium.sound_speed_compression            = cp1*ones(Nx, Ny);&#60;br /&#62;
medium.sound_speed_compression(slab == 1) = cp2;&#60;br /&#62;
medium.sound_speed_compression(air == 1) = cp3;&#60;/p&#62;
&#60;p&#62;medium.sound_speed_shear                  = cs1*ones(Nx, Ny);&#60;br /&#62;
medium.sound_speed_shear(slab == 1)       = cs2;&#60;br /&#62;
medium.sound_speed_shear(air == 1)       = cs3;&#60;/p&#62;
&#60;p&#62;medium.density                            = rho1*ones(Nx, Ny);&#60;br /&#62;
medium.density(slab == 1)                 = rho2;&#60;br /&#62;
medium.density(air == 1)                 = rho3;&#60;/p&#62;
&#60;p&#62;medium.alpha_coeff_compression            = alpha0_p1*ones(Nx, Ny);&#60;br /&#62;
medium.alpha_coeff_compression(slab == 1) = alpha0_p2;&#60;br /&#62;
medium.alpha_coeff_compression(air == 1) = alpha0_p3;&#60;/p&#62;
&#60;p&#62;medium.alpha_coeff_shear                  = alpha0_s1*ones(Nx, Ny);&#60;br /&#62;
medium.alpha_coeff_shear(slab == 1)       = alpha0_s2;&#60;br /&#62;
medium.alpha_coeff_shear(air == 1)       = alpha0_s3;&#60;/p&#62;
&#60;p&#62;% assign the source&#60;br /&#62;
clear source&#60;br /&#62;
source.s_mask = source_mask;&#60;br /&#62;
source.sxx = -source_strength*toneBurst(1/kgrid.dt, source_freq, source_cycles);&#60;br /&#62;
source.syy = source.sxx;&#60;/p&#62;
&#60;p&#62;% run the elastic simulation&#60;br /&#62;
sensor_data_elastic = pstdElastic2D(kgrid, medium, source, sensor, input_args{:});&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% VISUALISATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% define plot vector&#60;br /&#62;
x_vec = kgrid.x_vec * 1e3;&#60;br /&#62;
y_vec = kgrid.y_vec * 1e3;&#60;/p&#62;
&#60;p&#62;% calculate square of velocity magnitude&#60;br /&#62;
u_e = sensor_data_elastic.ux_max_all.^2 + sensor_data_elastic.uy_max_all.^2;&#60;br /&#62;
u_f = sensor_data_fluid.ux_max_all.^2 + sensor_data_fluid.uy_max_all.^2;&#60;/p&#62;
&#60;p&#62;% plot layout&#60;br /&#62;
figure;&#60;br /&#62;
imagesc(y_vec, x_vec, double(source_mask &#124; slab));&#60;/p&#62;
&#60;p&#62;xlabel('y [mm]');&#60;br /&#62;
ylabel('x [mm]');&#60;br /&#62;
axis image;&#60;br /&#62;
colormap(flipud(gray));&#60;/p&#62;
&#60;p&#62;% plot beam patterns for the fluid simulation&#60;br /&#62;
figure;&#60;br /&#62;
subplot(2, 1, 1);&#60;br /&#62;
imagesc(y_vec, x_vec, 20*log10(u_f./max(u_f(:))));&#60;br /&#62;
xlabel('y [mm]');&#60;br /&#62;
ylabel('x [mm]');&#60;br /&#62;
axis image;&#60;br /&#62;
h = colorbar;&#60;br /&#62;
caxis([-50, 0]);&#60;br /&#62;
title('Fluid Model');&#60;br /&#62;
ylabel(h, '[dB]');&#60;/p&#62;
&#60;p&#62;% plot beam patterns for the elastic simulation&#60;br /&#62;
subplot(2, 1, 2);&#60;br /&#62;
imagesc(y_vec, x_vec, 20*log10(u_e./max(u_e(:))));&#60;br /&#62;
xlabel('y [mm]');&#60;br /&#62;
ylabel('x [mm]');&#60;br /&#62;
axis image;&#60;br /&#62;
h = colorbar;&#60;br /&#62;
caxis([-50, 0]);&#60;br /&#62;
title('Elastic Model');&#60;br /&#62;
colormap(jet(256));&#60;br /&#62;
ylabel(h, '[dB]');&#60;/p&#62;
&#60;p&#62;scaleFig(1, 1.5);
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Ultrasonic three-layer medium propagation simulation"</title>
			<link>http://www.k-wave.org/forum/topic/ultrasonic-three-layer-medium-propagation-simulation#post-6786</link>
			<pubDate>Sun, 17 Mar 2019 22:45:30 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">6786@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi zhangwei198202,&#60;/p&#62;
&#60;p&#62;(1) Yes this is possible. Take a look at the examples included in k-Wave, in particular, the &#34;Snell's Law And Critical Angle Reflection Example&#34;.&#60;/p&#62;
&#60;p&#62;(2) It is not currently possible to turn off just one PML. In any case, k-Wave uses a Fourier collocation spectral method, so turning off the PML results in wave wrapping rather than reflections.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>zhangwei198202 on "Ultrasonic three-layer medium propagation simulation"</title>
			<link>http://www.k-wave.org/forum/topic/ultrasonic-three-layer-medium-propagation-simulation#post-6772</link>
			<pubDate>Fri, 15 Mar 2019 14:56:55 +0000</pubDate>
			<dc:creator>zhangwei198202</dc:creator>
			<guid isPermaLink="false">6772@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello, ask for a question:&#60;br /&#62;
1. I want to simulate the sound wave from the first medium obliquely incident into the second medium, reflect and refract at the interface of the two layers of media, then the sound wave re-enters the third medium from the second medium, and produces reflection at the interface between the two media. And refraction. I tried to program, but it didn't work. I don't know if I can simulate three layers of media using this software, or there are other ways to solve my problem.&#60;br /&#62;
I am looking forward to the expert's answer, thank you very much.&#60;br /&#62;
2.Regarding the PML problem, I have not understood thoroughly whether one of the four boundaries of the square region can be set to be non-PML, so that when the sound wave is incident on the bottom surface of the medium, it is reflected back instead of being absorbed.&#60;br /&#62;
I look forward to your answer, thank you very much.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
