<?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: Simulating speaker box - Open baffle</title>
		<link>http://www.k-wave.org/forum/topic/simulating-speaker-box-open-baffle</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 01:09:15 +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/simulating-speaker-box-open-baffle" rel="self" type="application/rss+xml" />

		<item>
			<title>Bradley Treeby on "Simulating speaker box - Open baffle"</title>
			<link>http://www.k-wave.org/forum/topic/simulating-speaker-box-open-baffle#post-8373</link>
			<pubDate>Thu, 16 Dec 2021 11:05:53 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">8373@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;At the very beginning of the simulation with both sources, the amplitudes look roughly the same, so at first glance it looks setup correctly. My guess would be its because of the channeling effect of the baffle.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Simbo_Saheed on "Simulating speaker box - Open baffle"</title>
			<link>http://www.k-wave.org/forum/topic/simulating-speaker-box-open-baffle#post-8331</link>
			<pubDate>Tue, 19 Oct 2021 13:17:55 +0000</pubDate>
			<dc:creator>Simbo_Saheed</dc:creator>
			<guid isPermaLink="false">8331@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Im trying to simulate open baffle speaker box. I based my code on examples with Slit Diffraction (for replacing boundary conditions) and from Transducer Field Patterns Example.&#60;br /&#62;
I'm simulating the membrane by putting two sources - one in front of baffle, one on the other side with opposite phase - In comments of the code. The code below is for one side of membrane only.&#60;br /&#62;
The problem is, that the source placed inside of the box, creates much bigger pressure field, than the source outside. I'm not sure, if this is caused by standing wave resonance of the open box, or by some computational mistake I missed. But the difference is massive, the sources have completely same initial conditions, on the link below is the image of recorded RMS pressure in Pascals for both cases.&#60;/p&#62;
&#60;p&#62;Graph link:&#60;br /&#62;
&#60;a href=&#34;https://ibb.co/G382xJR&#34; rel=&#34;nofollow&#34;&#62;https://ibb.co/G382xJR&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;THE CODE:&#60;br /&#62;
clearvars;&#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 = 200;               % number of grid points in the x (row) direction&#60;br /&#62;
Ny = Nx;                % number of grid points in the y (column) direction&#60;br /&#62;
dx = 0.025;             % grid point spacing in the x direction - vždy 2,5cm [m]&#60;br /&#62;
dy = 0.025;             % grid point spacing in the y direction [m]&#60;br /&#62;
kgrid = kWaveGrid(Nx, dx, Ny, dy);&#60;br /&#62;
t_end=0.5;              % set end of calculation [s]&#60;/p&#62;
&#60;p&#62;%define properties of test signal&#60;br /&#62;
source_freq = 60;       % [Hz]&#60;br /&#62;
source_mag = 1; % [Pa]&#60;/p&#62;
&#60;p&#62;% define the properties of the propagation medium&#60;br /&#62;
medium.sound_speed = 344;  % [m/s]&#60;br /&#62;
%kgrid.makeTime(medium.sound_speed);&#60;br /&#62;
%kgrid.t_array = makeTime(kgrid, medium.sound_speed, 0.3, 0.050);&#60;/p&#62;
&#60;p&#62;% create the speaker&#60;/p&#62;
&#60;p&#62;        slit_mask = zeros(Nx, Ny);&#60;br /&#62;
        % front baffle of speaker&#60;br /&#62;
        slit_mask(Nx/2,41:58) = 1;&#60;br /&#62;
        % left  baffle of speaker&#60;br /&#62;
        slit_mask(Nx/2+1:Nx/2+52,41) = 1;&#60;br /&#62;
        % right  baffle of speaker&#60;br /&#62;
        slit_mask(Nx/2+1:Nx/2+52,58) = 1; &#60;/p&#62;
&#60;p&#62;        % define a transducer element&#60;br /&#62;
        source.p_mask = zeros(Nx, Ny);&#60;br /&#62;
        source.p_mask(Nx/2+1, 43:55) = 1;&#60;br /&#62;
       % source.p_mask(Nx/2-1, 43:55) = 1; FOR BOTH SIDES OF SOURCE&#60;/p&#62;
&#60;p&#62;     % assign the slit to the properties of the propagation medium&#60;br /&#62;
        barrier_scale = 15;&#60;br /&#62;
        c0=344;&#60;br /&#62;
        rho0=1.29;&#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) = 310 * rho0;&#60;br /&#62;
     % assign the reference sound speed to the background medium&#60;br /&#62;
        medium.sound_speed_ref = c0;&#60;/p&#62;
&#60;p&#62;% create the time array&#60;br /&#62;
%kgrid.makeTime(medium.sound_speed);&#60;br /&#62;
kgrid.t_array = makeTime(kgrid, medium.sound_speed, 0.3, 0.050);&#60;br /&#62;
%define a time varying sinusoidal source&#60;br /&#62;
signal_A=[source_mag * sin(2 * pi * source_freq * kgrid.t_array)];&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% signal for Both sides of source&#60;br /&#62;
% signal_A=[source_mag * sin(2 * pi * source_freq * kgrid.t_array); source_mag2 * sin(2 * pi * source_freq * kgrid.t_array+pi);source_mag * sin(2 * pi * source_freq * kgrid.t_array); source_mag2 * sin(2 * pi * source_freq * kgrid.t_array+pi);source_mag * sin(2 * pi * source_freq * kgrid.t_array); source_mag2 * sin(2 * pi * source_freq * kgrid.t_array+pi);source_mag * sin(2 * pi * source_freq * kgrid.t_array); source_mag2 * sin(2 * pi * source_freq * kgrid.t_array+pi);source_mag * sin(2 * pi * source_freq * kgrid.t_array); source_mag2 * sin(2 * pi * source_freq * kgrid.t_array+pi);source_mag * sin(2 * pi * source_freq * kgrid.t_array); source_mag2 * sin(2 * pi * source_freq * kgrid.t_array+pi);source_mag * sin(2 * pi * source_freq * kgrid.t_array); source_mag2 * sin(2 * pi * source_freq * kgrid.t_array+pi);source_mag * sin(2 * pi * source_freq * kgrid.t_array); source_mag2 * sin(2 * pi * source_freq * kgrid.t_array+pi);source_mag * sin(2 * pi * source_freq * kgrid.t_array); source_mag2 * sin(2 * pi * source_freq * kgrid.t_array+pi);source_mag * sin(2 * pi * source_freq * kgrid.t_array); source_mag2 * sin(2 * pi * source_freq * kgrid.t_array+pi);source_mag * sin(2 * pi * source_freq * kgrid.t_array); source_mag2 * sin(2 * pi * source_freq * kgrid.t_array+pi);source_mag * sin(2 * pi * source_freq * kgrid.t_array); source_mag2 * sin(2 * pi * source_freq * kgrid.t_array+pi);source_mag * sin(2 * pi * source_freq * kgrid.t_array); source_mag2 * sin(2 * pi * source_freq * kgrid.t_array+pi)];&#60;br /&#62;
% =========================================================================&#60;br /&#62;
source.p=signal_A;&#60;/p&#62;
&#60;p&#62;% create a display mask to display the transducer&#60;br /&#62;
display_mask = source.p_mask;&#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 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;% assign the input options&#60;br /&#62;
input_args = {'DisplayMask',slit_mask, 'PMLInside', false, 'PlotPML', false};&#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;br /&#62;
% VISUALISATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% add the source mask onto the recorded wave-field&#60;br /&#62;
sensor_data.p_final(source.p_mask ~= 0) = 1;&#60;br /&#62;
sensor_data.p_max(source.p_mask ~= 0) = 1;&#60;br /&#62;
sensor_data.p_rms(source.p_mask ~= 0) = 1;&#60;/p&#62;
&#60;p&#62;% plot the final wave-field&#60;br /&#62;
figure;&#60;br /&#62;
subplot(1, 3, 1);&#60;br /&#62;
imagesc(kgrid.y_vec * 1e3, kgrid.x_vec * 1e3, sensor_data.p_final, [-1 1]);&#60;br /&#62;
colormap(getColorMap);&#60;br /&#62;
ylabel('x-position [mm]');&#60;br /&#62;
xlabel('y-position [mm]');&#60;br /&#62;
axis image;&#60;br /&#62;
title('Final Wave Field');&#60;/p&#62;
&#60;p&#62;% plot the maximum recorded pressure&#60;br /&#62;
subplot(1, 3, 2);&#60;br /&#62;
imagesc(kgrid.y_vec * 1e3, kgrid.x_vec * 1e3, sensor_data.p_max, [-1 1]);&#60;br /&#62;
colormap(getColorMap);&#60;br /&#62;
ylabel('x-position [mm]');&#60;br /&#62;
xlabel('y-position [mm]');&#60;br /&#62;
axis image;&#60;br /&#62;
title('Maximum Pressure');&#60;/p&#62;
&#60;p&#62;% plot the rms recorded pressure&#60;br /&#62;
subplot(1, 3, 3);&#60;br /&#62;
imagesc(kgrid.y_vec * 1e3, kgrid.x_vec * 1e3, sensor_data.p_rms, [0 0.5]);&#60;br /&#62;
colormap(getColorMap);&#60;br /&#62;
ylabel('x-position [mm]');&#60;br /&#62;
xlabel('y-position [mm]');&#60;br /&#62;
axis image;&#60;br /&#62;
title('RMS Pressure');&#60;br /&#62;
scaleFig(2, 1);
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
