<?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: difference in Mendousse and k-Wave simulation</title>
		<link>http://www.k-wave.org/forum/topic/difference-in-mendousse-and-k-wave-simulation</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 00:15:41 +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/difference-in-mendousse-and-k-wave-simulation" rel="self" type="application/rss+xml" />

		<item>
			<title>vpiskun on "difference in Mendousse and k-Wave simulation"</title>
			<link>http://www.k-wave.org/forum/topic/difference-in-mendousse-and-k-wave-simulation#post-6433</link>
			<pubDate>Fri, 20 Apr 2018 20:53:22 +0000</pubDate>
			<dc:creator>vpiskun</dc:creator>
			<guid isPermaLink="false">6433@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Thank you Brad!&#60;br /&#62;
vadim
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "difference in Mendousse and k-Wave simulation"</title>
			<link>http://www.k-wave.org/forum/topic/difference-in-mendousse-and-k-wave-simulation#post-6418</link>
			<pubDate>Wed, 18 Apr 2018 09:16:28 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">6418@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I've never noticed this before, but it looks the &#60;code&#62;mendousse&#60;/code&#62; function breaks for large values of the Gol'dberg number. If you reduce this (e.g., by increasing absorption to say &#60;code&#62;alpha0 = 4&#60;/code&#62;), it works ok. If the shock parameter is also high, you could try coding up the Fay solution (described on page 136 of Nonlinear Acoustics, by Hamilton and Blackstock).&#60;/p&#62;
&#60;p&#62;Hope that helps,&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>vpiskun on "difference in Mendousse and k-Wave simulation"</title>
			<link>http://www.k-wave.org/forum/topic/difference-in-mendousse-and-k-wave-simulation#post-6417</link>
			<pubDate>Wed, 18 Apr 2018 00:54:56 +0000</pubDate>
			<dc:creator>vpiskun</dc:creator>
			<guid isPermaLink="false">6417@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi,&#60;br /&#62;
I modified modeling non-linearity example to run it on the air at 40 kHz. I have different results for k-Wave and Mendousse simulations. I set the wave separation to be less than shock formation distance. The file looks like this&#60;br /&#62;
*****&#60;br /&#62;
%&#60;br /&#62;
% define the properties used in the simulation&#60;br /&#62;
p0 = 290;                     % source pressure [Pa]&#60;br /&#62;
c0 = 343;                     % sound speed [m/s]&#60;br /&#62;
rho0 = 1.225;                   % density [kg/m^3]&#60;br /&#62;
alpha_0 = 0.25;                % absorption coefficient [dB/(MHz^2 cm)]&#60;br /&#62;
% sigma = 2;                     % shock parameter&#60;br /&#62;
source_freq = 40000;             % frequency [Hz]&#60;br /&#62;
points_per_wavelength = 100;   % number of grid points per wavelength at f0&#60;br /&#62;
% wavelength_separation = 10;    % separation between the source and detector&#60;br /&#62;
wavelength_separation = 40;&#60;br /&#62;
pml_size = 80;                 % PML size&#60;br /&#62;
pml_alpha = 1.5;               % PML absorption coefficient [Np/grid point]&#60;br /&#62;
CFL = 0.25;                    % CFL number&#60;br /&#62;
BonA = .7;&#60;br /&#62;
% =========================================================================&#60;br /&#62;
% RUN SIMULATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% compute grid spacing&#60;br /&#62;
dx = c0 / (points_per_wavelength * source_freq);            % [m]&#60;/p&#62;
&#60;p&#62;% compute grid size&#60;br /&#62;
Nx = wavelength_separation * points_per_wavelength + 20;    % [grid points]&#60;/p&#62;
&#60;p&#62;% create the computational grid&#60;br /&#62;
kgrid = kWaveGrid(Nx, dx);&#60;/p&#62;
&#60;p&#62;% assign the properties of the propagation medium&#60;br /&#62;
medium.sound_speed = c0;&#60;br /&#62;
medium.density = rho0;&#60;br /&#62;
medium.alpha_power = 2;&#60;br /&#62;
medium.alpha_coeff = alpha_0;&#60;/p&#62;
&#60;p&#62;% extract the maximum frequency supported by the grid&#60;br /&#62;
f_max = min(medium.sound_speed) / (2 * dx);     % [Hz]&#60;/p&#62;
&#60;p&#62;% define a single source element&#60;br /&#62;
source_pos = 1;&#60;br /&#62;
source.p_mask = zeros(Nx, 1);&#60;br /&#62;
source.p_mask(source_pos) = 1;&#60;/p&#62;
&#60;p&#62;% define a single sensor position an integer number of wavelengths away&#60;br /&#62;
sensor.mask = zeros(Nx, 1);&#60;br /&#62;
x_px = wavelength_separation * points_per_wavelength;&#60;br /&#62;
sensor.mask(source_pos + x_px) = 1;&#60;br /&#62;
x = x_px * dx&#60;/p&#62;
&#60;p&#62;% shock formation distance rho0*c0^3/(omega*beta*p0)&#60;br /&#62;
xsh = rho0*c0^3/(2*pi*source_freq*(1+BonA)*p0)&#60;br /&#62;
medium.BonA = BonA;&#60;/p&#62;
&#60;p&#62;% set the simulation options&#60;br /&#62;
input_args = {'PlotFreq', 80, 'PlotScale', [-1, 1] * p0 * 1.05, ...&#60;br /&#62;
    'PMLInside', false, 'PMLSize', pml_size, 'PMLAlpha', pml_alpha};&#60;/p&#62;
&#60;p&#62;% compute points per temporal period&#60;br /&#62;
points_per_period = round(points_per_wavelength / CFL);&#60;/p&#62;
&#60;p&#62;% compute corresponding time spacing&#60;br /&#62;
dt = 1 / (points_per_period * source_freq);    &#60;/p&#62;
&#60;p&#62;% create the time array using an integer number of points per period&#60;br /&#62;
% t_end = 25e-6; %original&#60;br /&#62;
t_end = 2e-3;&#60;br /&#62;
Nt = round(t_end / dt);&#60;br /&#62;
kgrid.setTime(Nt, dt);&#60;/p&#62;
&#60;p&#62;% set the start time to only record the last three periods&#60;br /&#62;
sensor.record_start_index = kgrid.Nt - 5 * points_per_period + 1;&#60;/p&#62;
&#60;p&#62;% create the source term&#60;br /&#62;
source.p = p0 * sin(2 * pi * source_freq * kgrid.t_array);&#60;/p&#62;
&#60;p&#62;% run the simulation&#60;br /&#62;
sensor_data = kspaceFirstOrder1D(kgrid, medium, source, sensor, input_args{:});&#60;/p&#62;
&#60;p&#62;% create time axis for mendousse solution&#60;br /&#62;
t_axis = (0:(length(sensor_data) - 1)) .* dt; &#60;/p&#62;
&#60;p&#62;% compute mendousse solution for comparison&#60;br /&#62;
p_mendousse = mendousse(x * ones(size(t_axis)), t_axis, source_freq, p0, c0, rho0, BonA, alpha_0);&#60;/p&#62;
&#60;p&#62;% get the amplitude spectra&#60;br /&#62;
as_mendousse = spect(p_mendousse, 1/dt);&#60;br /&#62;
% f = f * 1e-6;&#60;br /&#62;
as_kspace = spect(sensor_data, 1/dt);&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% VISUALISATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% plot the time series&#60;br /&#62;
figure;&#60;br /&#62;
subplot(3, 1, 1);&#60;br /&#62;
plot(t_axis, sensor_data, 'r-');&#60;br /&#62;
hold on;&#60;br /&#62;
plot(t_axis, p_mendousse, 'k--');&#60;br /&#62;
xlabel('Time');&#60;br /&#62;
ylabel('Pressure');&#60;br /&#62;
legend('k-Wave', 'Mendousse');&#60;br /&#62;
subplot(3, 1, 2);&#60;/p&#62;
&#60;p&#62;    % plot simulation&#60;br /&#62;
    plot(as_kspace,'color','r');&#60;br /&#62;
    legend('k-Wave');&#60;br /&#62;
subplot(3, 1, 3);&#60;br /&#62;
    % plot reference&#60;br /&#62;
    plot(as_mendousse, 'color', 'k');&#60;br /&#62;
legend('Mendousse');&#60;br /&#62;
*******&#60;br /&#62;
thank you very much!&#60;br /&#62;
vadim
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
