<?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: Single Slit Diffraction</title>
		<link>http://www.k-wave.org/forum/topic/single-slit-diffraction</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 00:06:30 +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/single-slit-diffraction" rel="self" type="application/rss+xml" />

		<item>
			<title>Paulinetolen on "Single Slit Diffraction"</title>
			<link>http://www.k-wave.org/forum/topic/single-slit-diffraction#post-5051</link>
			<pubDate>Thu, 23 Apr 2015 16:26:21 +0000</pubDate>
			<dc:creator>Paulinetolen</dc:creator>
			<guid isPermaLink="false">5051@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Brad,&#60;/p&#62;
&#60;p&#62;Wow! I overlooked that entire folder. Thank you so much
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Single Slit Diffraction"</title>
			<link>http://www.k-wave.org/forum/topic/single-slit-diffraction#post-5050</link>
			<pubDate>Thu, 23 Apr 2015 09:31:30 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">5050@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Pauline,&#60;/p&#62;
&#60;p&#62;What is the error message you receive?&#60;/p&#62;
&#60;p&#62;You can access vanilla versions of all the examples without needing to copy and paste them via the MATLAB help browser (see Sec. 1.4 in the k-Wave manual). These should run without errors.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anthony on "Single Slit Diffraction"</title>
			<link>http://www.k-wave.org/forum/topic/single-slit-diffraction#post-5049</link>
			<pubDate>Tue, 21 Apr 2015 13:54:52 +0000</pubDate>
			<dc:creator>Anthony</dc:creator>
			<guid isPermaLink="false">5049@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Pauline,&#60;/p&#62;
&#60;p&#62;I didn't try to run your code but you might have a problem because of the very strong heterogeneity.&#60;br /&#62;
See the topic entitled &#34;A Question about The Reflection at The Hetrogeneous Media Boundary&#34; for more details.&#60;/p&#62;
&#60;p&#62;Hope it helps :-)&#60;br /&#62;
Anthony
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Paulinetolen on "Single Slit Diffraction"</title>
			<link>http://www.k-wave.org/forum/topic/single-slit-diffraction#post-5047</link>
			<pubDate>Sat, 18 Apr 2015 20:47:08 +0000</pubDate>
			<dc:creator>Paulinetolen</dc:creator>
			<guid isPermaLink="false">5047@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I'm new to this toolbox and I'm working through some of the simulatons. I tried copy pasting the examples and the ones I tried worked until I tried to run the Single Slit Diffusion. Could anyone look at my code and tell me what I'm doing wrong? &#60;/p&#62;
&#60;p&#62;=====================================================================&#60;/p&#62;
&#60;p&#62;%%%%% load homogenous Propogation Medium&#60;/p&#62;
&#60;p&#62;% define the properties used in the simulation&#60;br /&#62;
p0 = 7*10^6; % source pressure [Pa]&#60;br /&#62;
c0 = 1500; % sound speed [m/s]&#60;br /&#62;
rho0 = 1000; % density [kg/m^3]&#60;br /&#62;
alpha_0 = 0.25; % absorption coefficient [dB/(MHz^2 cm)]&#60;br /&#62;
sigma = 1; % shock parameter&#60;br /&#62;
source_freq = 1e6; % frequency [Hz]&#60;br /&#62;
points_per_wavelength = 50; % number of grid points per wavelength at f0&#60;br /&#62;
wavelength_separation = 15; % separation between the source and detector&#60;br /&#62;
PML_size = 64; % PML size&#60;br /&#62;
CFL = 0.25; %&#60;/p&#62;
&#60;p&#62;% create the computational grid&#60;br /&#62;
Nx = 128;           % number of grid points in the x (row) direction&#60;br /&#62;
Ny = 128;           % number of grid points in the y (column) direction&#60;br /&#62;
dx = 0.1e-3;        % grid point spacing in the x direction  [m]&#60;br /&#62;
dy = 0.1e-3;        % grid point spacing in the y direction  [m]&#60;br /&#62;
kgrid = makeGrid(Nx, dx, Ny, dy);&#60;/p&#62;
&#60;p&#62;% define the properties of the propagation medium&#60;br /&#62;
medium.sound_speed = 1500;  % [m/s]&#60;br /&#62;
medium.alpha_coeff = 0.75;  % [dB/(MHz^y cm)]&#60;br /&#62;
medium.alpha_power = 1.5;&#60;/p&#62;
&#60;p&#62;% define the ratio between the barrier and background sound speed and density&#60;br /&#62;
barrier_scale = 20;&#60;/p&#62;
&#60;p&#62;% create the time array using the barrier sound speed&#60;br /&#62;
t_end = 40e-6;                % [s]&#60;br /&#62;
CFL = 0.5;                    % Courantâ€“Friedrichsâ€“Lewy number&#60;br /&#62;
kgrid.t_array = makeTime(kgrid, c0*barrier_scale, CFL, t_end);&#60;/p&#62;
&#60;p&#62;% create a mask of a barrier with a slit&#60;br /&#62;
slit_thickness = 2;                     % [grid points]&#60;br /&#62;
slit_width = 10;                        % [grid points]&#60;br /&#62;
slit_x_pos = Nx - Nx/4;                 % [grid points]&#60;br /&#62;
slit_offset = Ny/2 - slit_width/2 - 1;  % [grid points]&#60;br /&#62;
slit_mask = zeros(Nx, Ny);&#60;br /&#62;
slit_mask(slit_x_pos:slit_x_pos + slit_thickness, 1:1 + slit_offset) = 1;&#60;br /&#62;
slit_mask(slit_x_pos:slit_x_pos + slit_thickness, end - slit_offset:end) = 1;&#60;/p&#62;
&#60;p&#62;% assign the slit to the properties of the propagation medium&#60;br /&#62;
medium.sound_speed = c0*ones(Nx, Ny);&#60;br /&#62;
medium.density = rho0*ones(Nx, Ny);&#60;br /&#62;
medium.sound_speed(slit_mask == 1) = barrier_scale*c0;&#60;br /&#62;
medium.density(slit_mask == 1) = barrier_scale*rho0;&#60;/p&#62;
&#60;p&#62;% define a centered circular sensor&#60;br /&#62;
sensor_radius = 4e-3;   % [m]&#60;br /&#62;
num_sensor_points = 50;&#60;br /&#62;
sensor.mask = makeCartCircle(sensor_radius, num_sensor_points);&#60;/p&#62;
&#60;p&#62;% create time array&#60;br /&#62;
t_end = 3e-5;&#60;br /&#62;
kgrid.t_array = makeTime(kgrid, medium.sound_speed, [], t_end);&#60;/p&#62;
&#60;p&#62;% define four sensor points centered about source.p0&#60;br /&#62;
sensor_radius = 40; % [grid points]&#60;br /&#62;
sensor.mask = zeros(Nx, Ny);&#60;br /&#62;
sensor.mask(Nx/2 + sensor_radius, Ny/2) = 1;&#60;br /&#62;
sensor.mask(Nx/2 - sensor_radius, Ny/2) = 1;&#60;br /&#62;
sensor.mask(Nx/2, Ny/2 + sensor_radius) = 1;&#60;br /&#62;
sensor.mask(Nx/2, Ny/2 - sensor_radius) = 1;&#60;/p&#62;
&#60;p&#62;% define a single source point&#60;br /&#62;
source.p_mask = zeros(Nx, Ny);&#60;br /&#62;
source.p_mask(end - Nx/4, Ny/2) = 1;&#60;/p&#62;
&#60;p&#62;% define a time varying sinusoidal source&#60;br /&#62;
source_freq = 0.25e6;   % [Hz]&#60;br /&#62;
source_mag = 2;         % [Pa]&#60;br /&#62;
source.p = source_mag*sin(2*pi*source_freq*kgrid.t_array);&#60;/p&#62;
&#60;p&#62;% filter the source to remove high frequencies not supported by the grid&#60;br /&#62;
source.p = filterTimeSeries(kgrid, medium, source.p);&#60;/p&#62;
&#60;p&#62;% define a curved transducer element&#60;br /&#62;
source.p_mask = makeCircle(Nx, Ny, 61, 61, 60, pi/2);&#60;/p&#62;
&#60;p&#62;% define a time varying sinusoidal source&#60;br /&#62;
source_freq = 0.25e6;       % [Hz]&#60;br /&#62;
source_mag = 0.5;           % [Pa]&#60;br /&#62;
source.p = source_mag*sin(2*pi*source_freq*kgrid.t_array);&#60;/p&#62;
&#60;p&#62;% filter the source to remove any high frequencies not supported by the grid&#60;br /&#62;
source.p = filterTimeSeries(kgrid, medium, source.p);&#60;/p&#62;
&#60;p&#62;% create a sensor mask covering the entire computational domain using the&#60;br /&#62;
% opposing corners of a rectangle&#60;br /&#62;
sensor.mask = [1, 1, Nx, Ny].';&#60;/p&#62;
&#60;p&#62;% set the record mode to capture the final wave-field and the statistics at&#60;br /&#62;
% each sensor point&#60;br /&#62;
sensor.record = {'p_final', 'p_max', 'p_rms'};&#60;/p&#62;
&#60;p&#62;% set the input options&#60;br /&#62;
input_args = {'PMLInside', false, 'PMLSize', PML_size, 'PlotPML', false, ...&#60;br /&#62;
    'DisplayMask', slit_mask, 'DataCast', 'single'};&#60;/p&#62;
&#60;p&#62;% run the simulation&#60;br /&#62;
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});&#60;/p&#62;
&#60;p&#62;================================================================&#60;/p&#62;
&#60;p&#62;Thank you!&#60;br /&#62;
Pauline
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
