<?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: How to simulate high pressure field pattern with spherical source?</title>
		<link>http://www.k-wave.org/forum/topic/how-to-simulate-high-pressure-field-pattern-with-spherical-source</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Tue, 12 May 2026 23:28:35 +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/how-to-simulate-high-pressure-field-pattern-with-spherical-source" rel="self" type="application/rss+xml" />

		<item>
			<title>Bradley Treeby on "How to simulate high pressure field pattern with spherical source?"</title>
			<link>http://www.k-wave.org/forum/topic/how-to-simulate-high-pressure-field-pattern-with-spherical-source#post-6327</link>
			<pubDate>Wed, 07 Mar 2018 22:47:47 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">6327@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Hammerben1.&#60;/p&#62;
&#60;p&#62;The default plot scale is [-1, 1]. You can modify this by setting the optional input &#60;code&#62;&#38;#39;PlotScale&#38;#39;, source_mag * [-1, 1]&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Hammerben1 on "How to simulate high pressure field pattern with spherical source?"</title>
			<link>http://www.k-wave.org/forum/topic/how-to-simulate-high-pressure-field-pattern-with-spherical-source#post-6314</link>
			<pubDate>Tue, 06 Mar 2018 19:28:30 +0000</pubDate>
			<dc:creator>Hammerben1</dc:creator>
			<guid isPermaLink="false">6314@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi!&#60;br /&#62;
I just started learning KWAVE since last week. I am trying to build a spherical source to model our single element, point focused transducer. I did that. But the problem is when I bump up the peak amplitude of the source sine wave to 2MPa, which is what we expect the transducer to achieve, the simulation is just pure black... like it's been overwhelmed...&#60;/p&#62;
&#60;p&#62;How to solve this problem?&#60;/p&#62;
&#60;p&#62;I attached my code here:&#60;br /&#62;
---------------------------------------&#60;br /&#62;
% Simulating Transducer Field Patterns Example&#60;br /&#62;
%&#60;br /&#62;
% This example demonstrates the use of k-Wave to compute the field pattern&#60;br /&#62;
% generated by a curved single element transducer in two dimensions. It&#60;br /&#62;
% builds on the Monopole Point Source In A Homogeneous Propagation Medium&#60;br /&#62;
% Example.&#60;br /&#62;
%&#60;br /&#62;
% author: Bradley Treeby&#60;br /&#62;
% date: 10th December 2009&#60;br /&#62;
% last update: 4th May 2017&#60;br /&#62;
%&#60;br /&#62;
% This function is part of the k-Wave Toolbox (&#60;a href=&#34;http://www.k-wave.org&#34; rel=&#34;nofollow&#34;&#62;http://www.k-wave.org&#60;/a&#62;)&#60;br /&#62;
% Copyright (C) 2009-2017 Bradley Treeby&#60;/p&#62;
&#60;p&#62;% This file is part of k-Wave. k-Wave is free software: you can&#60;br /&#62;
% redistribute it and/or modify it under the terms of the GNU Lesser&#60;br /&#62;
% General Public License as published by the Free Software Foundation,&#60;br /&#62;
% either version 3 of the License, or (at your option) any later version.&#60;br /&#62;
%&#60;br /&#62;
% k-Wave is distributed in the hope that it will be useful, but WITHOUT ANY&#60;br /&#62;
% WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS&#60;br /&#62;
% FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for&#60;br /&#62;
% more details.&#60;br /&#62;
%&#60;br /&#62;
% You should have received a copy of the GNU Lesser General Public License&#60;br /&#62;
% along with k-Wave. If not, see &#38;lt;http://www.gnu.org/licenses/&#38;gt;. &#60;/p&#62;
&#60;p&#62;clearvars;&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% SIMULATION&#60;br /&#62;
% =========================================================================&#60;br /&#62;
a=1;&#60;br /&#62;
% create the computational grid&#60;br /&#62;
Nx = 216/2*a;           % number of grid points in the x (row) direction&#60;br /&#62;
Ny = 216*a;           % number of grid points in the y (column) direction&#60;br /&#62;
dx = 50e-3/Nx;    	% grid point spacing in the x direction [m]&#60;br /&#62;
dy = dx;            % grid point spacing in the y direction [m]&#60;br /&#62;
kgrid = kWaveGrid(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;br /&#62;
medium.sound_speed = 1500 * ones(Nx, Ny);   % [m/s]&#60;br /&#62;
medium.sound_speed(:, Ny/4:Ny/4+10) = 1644;       % [m/s]&#60;br /&#62;
medium.density = 1000 * ones(Nx, Ny);       % [kg/m^3]&#60;br /&#62;
medium.density(:, Ny/4:Ny/4+10) = 1038;          % [kg/m^3]&#60;br /&#62;
medium.alpha_coeff = 0.75*ones(Nx,Ny);  % [dB/(MHz^y cm)]&#60;br /&#62;
medium.alpha_coeff(:,Ny/4:Ny/4+10) = 2.24;&#60;br /&#62;
medium.alpha_power = 1.5;&#60;br /&#62;
% create the time array&#60;br /&#62;
kgrid.makeTime(medium.sound_speed);&#60;/p&#62;
&#60;p&#62;% define a curved transducer element&#60;br /&#62;
arc_pos = [Nx/2, 1];         % [grid points]&#60;br /&#62;
radius = 56*a;                % [grid points]&#60;br /&#62;
diameter = 111;              % [grid points]&#60;br /&#62;
focus_pos = [Nx/2, Nx/2];   % [grid points]&#60;br /&#62;
source.p_mask = makeArc([Nx, Ny], arc_pos, radius, diameter, focus_pos);&#60;/p&#62;
&#60;p&#62;% define a time varying sinusoidal source&#60;br /&#62;
source_freq = 0.2e6;       % [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 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 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;br /&#62;
% % define a single sensor point&#60;br /&#62;
% sensor.mask = zeros(Nx, Ny);&#60;br /&#62;
% sensor.mask(Nx/2, Ny/4) = 1;&#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','p_final', 'p_max', 'p_rms'};&#60;/p&#62;
&#60;p&#62;% assign the input options&#60;br /&#62;
input_args = {'DisplayMask', display_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, [-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('RMS Pressure');&#60;br /&#62;
scaleFig(2, 1);&#60;/p&#62;
&#60;p&#62;[t_sc, scale, prefix] = scaleSI(max(kgrid.t_array(:)));&#60;br /&#62;
figure&#60;/p&#62;
&#60;p&#62;%source signal amplitude&#60;br /&#62;
% subplot(2, 1, 1);&#60;br /&#62;
% plot(kgrid.t_array * scale, source.p, 'k-');&#60;br /&#62;
% xlabel(['Time [' prefix 's]']);&#60;br /&#62;
% ylabel('Signal Amplitude');&#60;br /&#62;
% axis tight;&#60;br /&#62;
% title('Input Pressure Signal');&#60;br /&#62;
%&#60;br /&#62;
% subplot(2, 1, 2);&#60;br /&#62;
% plot(kgrid.t_array * scale, sensor_data.p, 'r-');&#60;br /&#62;
% xlabel(['Time [' prefix 's]']);&#60;br /&#62;
% ylabel('Signal Amplitude');&#60;br /&#62;
% axis tight;&#60;br /&#62;
% title('Sensor Pressure Signal');&#60;br /&#62;
%
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
