<?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: A Question about The Reflection at The Hetrogeneous Media Boundary</title>
		<link>http://www.k-wave.org/forum/topic/a-question-about-the-reflection-at-the-hetrogeneous-media-boundary</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 00:12:03 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.k-wave.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.k-wave.org/forum/rss/topic/a-question-about-the-reflection-at-the-hetrogeneous-media-boundary" rel="self" type="application/rss+xml" />

		<item>
			<title>g.c. on "A Question about The Reflection at The Hetrogeneous Media Boundary"</title>
			<link>http://www.k-wave.org/forum/topic/a-question-about-the-reflection-at-the-hetrogeneous-media-boundary#post-9089</link>
			<pubDate>Tue, 07 May 2024 15:09:01 +0000</pubDate>
			<dc:creator>g.c.</dc:creator>
			<guid isPermaLink="false">9089@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi!&#60;br /&#62;
I am currently working on my master thesis and want to simulate the propagation of a pressure distribution in a structure of alterning Al and Pb foils (a few um thick, circular, 2cm radius, the whole thing is in vacuum). I am having problems with my result, as it is diverging: the mean pressure on a thin detector on the other side of the stack is going towards 10^293Pa. I assumed it accured because my geometry is not smooth enougth, so to check I just built a block of Pb in vacuum and put a circular pressure source inside of it, and run the simulation in 2D. As I understood from one of the last posts (point 4) it shouldn't be a problem if the source originates from within the high impedance material. Why does my code still diverge? is there a solution to this problem? i tried to change the material properties, but I have to change them so much, that the simulation is not rapresentative anymore. &#60;/p&#62;
&#60;p&#62;Here is my code:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;%% % create masks
z_lim = 0.03;
x_lim = 0.01;%in m

Nx = 200;           % number of grid points in the x direction
Nz = 600;           % number of grid points in the z direction
dz = 0.00005;
dx = 0.0001;
[Z,X] = meshgrid((0:dz:z_lim-dz),(-1*x_lim:dx:x_lim-dx));
geom = zeros(size(Z));
det = zeros(size(Z));

lz = 0.02; % [m], z length
lx = 0.01; % [m], x length
z0 = 0.015; % [m], z center
x0 = 0; % [m], x center
ind = ((Z &#38;gt;= z0-lz/2) &#38;amp; (Z &#38;lt; z0+lz/2) &#38;amp; (X &#38;gt;= x0-lx/2) &#38;amp; (X &#38;lt; x0+lx/2));
[num, ~] = materials(4); %add the material of interest
geom(ind) = num;
geom = permute(geom,[2,1]);

% Create the computational grid for the 2D slice
kgrid = kWaveGrid(Nz, dz, Nx, dx);
[densitymask,speedmask,alphamask,ymask] = get_masks(geom);

%%
% Define the properties of the upper layer of the propagation medium

medium.sound_speed = speedmask;
medium.density = densitymask;

% Create time array
t_end = 3e-6;  % [s]
kgrid.makeTime(medium.sound_speed, [], t_end);
%%
%create SOURCE
% define a single source point
disc_magnitude = 300; % [Pa]
disc_x_pos = Nx/2;    % [grid points]
disc_z_pos = Nz/4;
disc_radius = 0.4;    % [grid points]
disc = disc_magnitude * makeDisc(Nz, Nx, disc_z_pos, disc_x_pos, disc_radius);

source.p0 = zeros(Nz, Nx);
source.p0 = disc  ;
% %%
%  %SENSOR

det = makeLine(Nz, Nx, [round(0.023/dz), 90],[round(0.023/dz), 110]);
%det = permute(det,[2,1]);
sensor.mask=det;
%%

% Run the simulation with PlotLayout and PlotScale
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor,...
                &#38;#39;PlotLayout&#38;#39;, true);

%%
% Assuming your pressure data is stored in a variable named &#38;#39;pressure_data&#38;#39;
figure
% Calculate the mean pressure across all pixels at each time step
mean_pressure = mean(sensor_data, 1);

% Plot pressure versus time
plot(kgrid.t_array, mean_pressure, &#38;#39;LineWidth&#38;#39;, 2);
xlabel(&#38;#39;Time&#38;#39;);
ylabel(&#38;#39;Mean Pressure on detector&#38;#39;);
title(&#38;#39;Mean Pressure vs Time&#38;#39;);
grid on;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;the materials are defined as follows: &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;function [num, mat, rho, c, gamma, alpha_coeff,y] = materials(arg)

% attenuation data: Appl. Sci. 2020, 10(7), 2230; &#60;a href=&#34;https://doi.org/10.3390/app10072230&#34; rel=&#34;nofollow&#34;&#62;https://doi.org/10.3390/app10072230&#60;/a&#62; 

if arg == 0 &#124; strcmpi(arg,&#38;#39;vacuum&#38;#39;) &#124; strcmpi(arg,&#38;#39;vac&#38;#39;)
    mat = &#38;#39;vacuum&#38;#39;;
    num = 0;

    rho = 0.0012 ;% 1.2e-3; %                 [g/cm^3] density
    c = 0.4; %0.4; %                    [mm/us] speed of sound
    beta = 3400e-6; %               [1/K] vol. thermal expansion
    c_p = 1012; %                   [J/kg/K] spec. heat capacity
    gamma = beta*(c*1000)^2/c_p; %  [Pa/(J/m^3)] Grüneisenparameter
    alpha_coeff = 1e-6; %0                    [dB/cm/MHz^y] acoustic attenuation coef.
    y = 1; %                        attenuation exponent

elseif arg == 4 &#124; strcmpi(arg,&#38;#39;lead&#38;#39;) &#124; strcmpi(arg,&#38;#39;Pb&#38;#39;)
    mat = &#38;#39;Pb&#38;#39;;
    num = 4;

    A = 207; %                      [u] eff. Massezahl
    Z = 82; %                       [u] eff. Ordnungszahl
    rho = 11.29;%11.29; %                  [g/cm^3] density
    c = 1.96; % 1.96                    [mm/us] speed of sound
    beta = 29e-6; % 87e-6; %                 [1/K] vol. thermal expansion
    c_p = 129; %                    [J/kg/K] spec. heat capacity
    gamma = beta*(c*1000)^2/c_p; %  [Pa/ (J/m^3)] Grüneisenparameter
    I = 823; %                      [eV] mean excitation energy
    alpha_coeff = 4.33; %alpha = 4.33; %                 [dB/cm/MHz] acoustic attenuation coef.
    y = 1; %                        attenuation exponent

end&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;and get masks is a function: &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;function [densitymask,speedmask,alphamask,ymask] = get_masks(geom)  

% create mask arrays
densitymask = zeros(size(geom));
speedmask = zeros(size(geom));
alphamask = zeros(size(geom));
ymask = zeros(size(geom));

% initialise counter
n = 0;

while ~all(densitymask(:)) 

    % assign values of materials to masks
    [~, ~, rho, c, ~, alpha_coeff,y] = materials(n);

    densitymask(geom == n) = rho*1e3; %     [kg/m^3]

    speedmask(geom == n) = c*1e3; %         [m/s]

    alphamask(geom == n) = alpha_coeff; %         [dB/cm/MHz^y] 

    ymask(geom == n) = y; % 

    % increase counter
    n = n+1;

end
end&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Thank you in advance for any help.&#60;br /&#62;
Best regards,&#60;br /&#62;
Gianna
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "A Question about The Reflection at The Hetrogeneous Media Boundary"</title>
			<link>http://www.k-wave.org/forum/topic/a-question-about-the-reflection-at-the-hetrogeneous-media-boundary#post-5690</link>
			<pubDate>Thu, 29 Sep 2016 13:40:09 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">5690@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi peet2521,&#60;/p&#62;
&#60;p&#62;We don't have the data presented in exactly that form, but there are some plots in &#60;a href=&#34;http://www.k-wave.org/papers/2014-Robertson-IEEEIUS.pdf&#34;&#62;this paper&#60;/a&#62; that might be useful.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>peet2521 on "A Question about The Reflection at The Hetrogeneous Media Boundary"</title>
			<link>http://www.k-wave.org/forum/topic/a-question-about-the-reflection-at-the-hetrogeneous-media-boundary#post-5684</link>
			<pubDate>Mon, 19 Sep 2016 21:41:43 +0000</pubDate>
			<dc:creator>peet2521</dc:creator>
			<guid isPermaLink="false">5684@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Brad,&#60;/p&#62;
&#60;p&#62;Are there any case studies or something on the grid resolution we should use to get a correct transmission/reflection for a given impedance mismatch ratio?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>cge on "A Question about The Reflection at The Hetrogeneous Media Boundary"</title>
			<link>http://www.k-wave.org/forum/topic/a-question-about-the-reflection-at-the-hetrogeneous-media-boundary#post-4643</link>
			<pubDate>Wed, 16 Jul 2014 06:52:27 +0000</pubDate>
			<dc:creator>cge</dc:creator>
			<guid isPermaLink="false">4643@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Brad&#60;/p&#62;
&#60;p&#62;Thank you very much. Now it works and I have got the correct result
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "A Question about The Reflection at The Hetrogeneous Media Boundary"</title>
			<link>http://www.k-wave.org/forum/topic/a-question-about-the-reflection-at-the-hetrogeneous-media-boundary#post-4641</link>
			<pubDate>Tue, 15 Jul 2014 11:21:35 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">4641@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi cge,&#60;/p&#62;
&#60;p&#62;There are a few problems with your simulation:&#60;/p&#62;
&#60;p&#62;(1) Your source is defined within the perfectly matched layer (PML). The PML is a thin layer that surrounds the domain and absorbs the outgoing waves to simulate free-field conditions. The default PML thickness for 2D simulations is 20 grid points. You can either move your source to be outside the PML, or set the PML to be outside the domain you specify by using the optional input &#60;code&#62;&#38;#39;PMLInside&#38;#39;, false&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;(2) You are using a initial pressure source at the very edge of the grid. By default, the &#60;code&#62;source.p0&#60;/code&#62; is smoothed inside the simulation functions. This means that parts of the source will be wrapped to the other side of the domain. To see what I mean, try running the following code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;% define grid
kgrid = makeGrid(20, 1);

% define source and smooth
p0 = [1; zeros(19, 1)];
p0_smooth = smooth(kgrid, p0, true);

% plot
figure;
stem(p0, &#38;#39;bx&#38;#39;);
hold on;
stem(p0_smooth, &#38;#39;r&#38;#39;);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;(3) The medium interfaces are defined within the PML (see discussion above).&#60;/p&#62;
&#60;p&#62;(4) As Anthony has already mentioned, the third layer has a huge impedance mismatch changing from 3.2 MRayls to 0.4 kRayl (a factor of nearly 10,000). The problem we have found with such large changes is that the transmission coefficient when waves travel from the low to high impedance material is vastly over-estimated (except using high numbers of points per wavelength), resulting in very large amplitude waves. However, in your case, this shouldn't be a problem as the source originates from within the high-impedance material. The CFL number also affects the accuracy of the simulation as mentioned above.&#60;/p&#62;
&#60;p&#62;A revised script is below.&#60;/p&#62;
&#60;p&#62;Brad.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;clear all;

% =========================================================================
% SIMULATION
% =========================================================================

% create the computational grid, with the PML outside the grid
PML_size = 20;          % [grid points]
Nx = 128 - 2*PML_size;  % [grid points]
dx = 0.05e-3;           % [m]
kgrid = makeGrid(Nx, dx);

% define position of source and interfaces
source_pos      = 15;   % [grid points]
sensor_pos      = 30;   % [grid points]
interface_1_pos = 35;   % [grid points]
interface_2_pos = 60;   % [grid points]

% define material properties
c1   = 1540;  % [m/s]
rho1 = 1000;  % [kg/m^3]
c2   = 2690;  % [m/s]
rho2 = 1190;  % [kg/m^3]
c3   = 340;   % [m/s]
rho3 = 1.2;   % [kg/m^3]

% define sound speed map
medium.sound_speed = c1*ones(Nx, 1);
medium.sound_speed(interface_1_pos:interface_2_pos - 1) = c2;
medium.sound_speed(interface_2_pos:end) = c3;

% define density
medium.density = rho1*ones(Nx, 1);
medium.density(interface_1_pos:interface_2_pos - 1) = rho2;
medium.density(interface_2_pos:end) = rho3;

% set the simulation time to capture the reflections
t_end = Nx*dx/min(medium.sound_speed);

% define the time array
CFL = 0.05;
[kgrid.t_array, dt] = makeTime(kgrid, medium.sound_speed, CFL, t_end);

% define source, offset from the edge to prevent smoothing from wrapping
% the source
source_mag = 1e6;
source.p0 = zeros(Nx,1);
source.p0(source_pos) = source_mag;

% create a binary sensor mask
sensor_mask = zeros(Nx,1);
sensor_mask(sensor_pos) = 1;
sensor.mask = sensor_mask;

% run the simulation
sensor.record = {&#38;#39;p&#38;#39;};
sensor_data = kspaceFirstOrder1D(kgrid, medium, source, sensor,...
    &#38;#39;PMLInside&#38;#39;, false, &#38;#39;PlotLayout&#38;#39;, true, ...
    &#38;#39;PlotScale&#38;#39;, [-1, 1]*source_mag, &#38;#39;PlotFreq&#38;#39;, 10);

% =========================================================================
% VISUALISATION
% =========================================================================

% plot the recorded time signals
figure;
plot(kgrid.t_array, sensor_data.p);
xlabel(&#38;#39;time step&#38;#39;);
ylabel(&#38;#39;pressure at the sensor position&#38;#39;);&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>cge on "A Question about The Reflection at The Hetrogeneous Media Boundary"</title>
			<link>http://www.k-wave.org/forum/topic/a-question-about-the-reflection-at-the-hetrogeneous-media-boundary#post-4638</link>
			<pubDate>Mon, 14 Jul 2014 05:41:26 +0000</pubDate>
			<dc:creator>cge</dc:creator>
			<guid isPermaLink="false">4638@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Hypermoi&#60;/p&#62;
&#60;p&#62;Thank you very much for your suggestion. I will take a try &#60;/p&#62;
&#60;p&#62;Best Regards
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anthony on "A Question about The Reflection at The Hetrogeneous Media Boundary"</title>
			<link>http://www.k-wave.org/forum/topic/a-question-about-the-reflection-at-the-hetrogeneous-media-boundary#post-4635</link>
			<pubDate>Fri, 11 Jul 2014 11:57:13 +0000</pubDate>
			<dc:creator>Anthony</dc:creator>
			<guid isPermaLink="false">4635@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi cge,&#60;/p&#62;
&#60;p&#62;I am not part of the development team but I would say that k-wave is accurate only for weakly heterogeneous media. &#60;/p&#62;
&#60;p&#62;What if you try other values for the second medium sound speed, density and attenuation? Is there a threshold on the difference of impedance under which this strange peak disappears?&#60;/p&#62;
&#60;p&#62;Intuitively, it seems natural that a spectral method is not comfortable with discontinuities. I have not investigated in details the references mentioned at the bottom of the 21st page of the user's manual but maybe you can try to play with the CFL number. You could also smooth your sound speed and density distributions (see p63 of the user's manual).&#60;/p&#62;
&#60;p&#62;Maybe you could also set a source mask at the place where the interface should be and use Dirichlet boundary conditions (see p34), in order to have a reflecting interface.&#60;/p&#62;
&#60;p&#62;Best regards,&#60;br /&#62;
Anthony
&#60;/p&#62;</description>
		</item>
		<item>
			<title>cge on "A Question about The Reflection at The Hetrogeneous Media Boundary"</title>
			<link>http://www.k-wave.org/forum/topic/a-question-about-the-reflection-at-the-hetrogeneous-media-boundary#post-4622</link>
			<pubDate>Tue, 08 Jul 2014 06:57:34 +0000</pubDate>
			<dc:creator>cge</dc:creator>
			<guid isPermaLink="false">4622@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi everyone&#60;/p&#62;
&#60;p&#62;Recently I am helping another guy in our group to simulate the reflection at the hetrogeneous media boundary.&#60;/p&#62;
&#60;p&#62;I started from a simple 1D simulation, the code is provided below.&#60;/p&#62;
&#60;p&#62;clear all;&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% SIMULATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% create the computational grid&#60;br /&#62;
Nx = 64;       % number of grid points in the x (row) direction&#60;br /&#62;
dx = 0.05e-3;   % grid point spacing in the x direction [m]&#60;br /&#62;
kgrid = makeGrid(Nx, dx);&#60;/p&#62;
&#60;p&#62;% define the properties of the propagation medium&#60;br /&#62;
medium.sound_speed = 1540*ones(Nx, 1);    	% [m/s]&#60;br /&#62;
medium.sound_speed(11:50) = 2690;&#60;br /&#62;
medium.sound_speed(51:64) = 340; % [m/s]&#60;br /&#62;
medium.density = 1000*ones(Nx, 1);          % [kg/m^3]&#60;br /&#62;
medium.density(11:50) = 1190;   % [kg/m^3]&#60;br /&#62;
medium.density(51:64) = 1.204;&#60;br /&#62;
medium.alpha_power=2;&#60;br /&#62;
medium.alpha_coeff=0.002*ones(Nx,1);&#60;br /&#62;
medium.alpha_coeff(11:50)=1.19;&#60;br /&#62;
medium.alpha_coeff(51:64)=1.64;&#60;br /&#62;
% create initial pressure distribution using a smoothly shaped sinusoid&#60;br /&#62;
source_mask=zeros(Nx,1);&#60;br /&#62;
source_mask(1)=1;&#60;br /&#62;
source.p0 =10^6*source_mask; &#60;/p&#62;
&#60;p&#62;% create a Cartesian sensor mask&#60;br /&#62;
sensor_mask=zeros(Nx,1)&#60;br /&#62;
sensor_mask(9)=1;&#60;br /&#62;
sensor.mask = sensor_mask;  % [mm]&#60;/p&#62;
&#60;p&#62;% set the simulation time to capture the reflections&#60;br /&#62;
t_end = dx*10/1540+dx*40/2690+dx*14/340;&#60;/p&#62;
&#60;p&#62;% define the time array&#60;br /&#62;
[kgrid.t_array, dt] = makeTime(kgrid, medium.sound_speed, [], t_end);&#60;/p&#62;
&#60;p&#62;% run the simulation&#60;br /&#62;
sensor.record={'p'};&#60;br /&#62;
sensor_data = kspaceFirstOrder1D(kgrid, medium, source, sensor, 'PlotLayout', true);&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% VISUALISATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% plot the recorded time signals&#60;br /&#62;
figure;&#60;br /&#62;
plot(kgrid.t_array, abs(sensor_data.p));&#60;br /&#62;
xlabel('time step');&#60;br /&#62;
ylabel('pressure at the sensor position');&#60;/p&#62;
&#60;p&#62;As for the result, a interesting happens, the excitation has a amplitude only of 10^6 Pa, however, the result I got in this end is quite huge, almost 10^60~70 pa, almost infinity and impossible.&#60;/p&#62;
&#60;p&#62;I checked the code but can not find the problem. Can anyone helo?&#60;/p&#62;
&#60;p&#62;Best Regards
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
