<?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: Questions about the code for defining the attenuation and the simulation error.</title>
		<link>http://www.k-wave.org/forum/topic/questions-about-the-code-for-defining-the-attenuation-and-the-simulation-error</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 06:46:24 +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/questions-about-the-code-for-defining-the-attenuation-and-the-simulation-error" rel="self" type="application/rss+xml" />

		<item>
			<title>saya mizutani on "Questions about the code for defining the attenuation and the simulation error."</title>
			<link>http://www.k-wave.org/forum/topic/questions-about-the-code-for-defining-the-attenuation-and-the-simulation-error#post-7819</link>
			<pubDate>Sat, 12 Sep 2020 13:33:42 +0000</pubDate>
			<dc:creator>saya mizutani</dc:creator>
			<guid isPermaLink="false">7819@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Thank you very much, Brad.&#60;/p&#62;
&#60;p&#62;Saya
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Questions about the code for defining the attenuation and the simulation error."</title>
			<link>http://www.k-wave.org/forum/topic/questions-about-the-code-for-defining-the-attenuation-and-the-simulation-error#post-7817</link>
			<pubDate>Fri, 11 Sep 2020 18:06:35 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">7817@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;You can set medium.alpha_coeff as a matrix in the same way as medium.sound_speed etc. Note that medium.alpha_power must be a scalar.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>saya mizutani on "Questions about the code for defining the attenuation and the simulation error."</title>
			<link>http://www.k-wave.org/forum/topic/questions-about-the-code-for-defining-the-attenuation-and-the-simulation-error#post-7816</link>
			<pubDate>Fri, 11 Sep 2020 16:10:16 +0000</pubDate>
			<dc:creator>saya mizutani</dc:creator>
			<guid isPermaLink="false">7816@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Brad,&#60;/p&#62;
&#60;p&#62;Thank you for your reply.I'm sorry for missing the description what BWI is.&#60;br /&#62;
I just tried to run the simulation after fixing the time step and it worked!&#60;br /&#62;
I really appreciate your helpful advice.&#60;/p&#62;
&#60;p&#62;I actually have one more question.&#60;br /&#62;
I would like to set the different attenuation coefficients for each region. Is there any instruction for that? (Could I do that?)&#60;/p&#62;
&#60;p&#62;Saya
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Questions about the code for defining the attenuation and the simulation error."</title>
			<link>http://www.k-wave.org/forum/topic/questions-about-the-code-for-defining-the-attenuation-and-the-simulation-error#post-7802</link>
			<pubDate>Fri, 11 Sep 2020 09:52:04 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">7802@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Saya,&#60;/p&#62;
&#60;p&#62;I can't run your code (it's missing what BWI is), but I'm guessing it's because the simulation becomes unstable. Try reducing the CFL / size of the time step. You can check for the maximum stable time step using &#60;code&#62;checkStability&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;Brad
&#60;/p&#62;</description>
		</item>
		<item>
			<title>saya mizutani on "Questions about the code for defining the attenuation and the simulation error."</title>
			<link>http://www.k-wave.org/forum/topic/questions-about-the-code-for-defining-the-attenuation-and-the-simulation-error#post-7778</link>
			<pubDate>Sat, 29 Aug 2020 06:10:51 +0000</pubDate>
			<dc:creator>saya mizutani</dc:creator>
			<guid isPermaLink="false">7778@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi, Thank you for letting me use the amazing toolbox.&#60;br /&#62;
I have a question.&#60;/p&#62;
&#60;p&#62;Is it right that all I have to do for defining the attenuation parameters in the simulation is adding the following two codes after defining the sound speeds?&#60;/p&#62;
&#60;p&#62;medium.alpha_coeff = 2;                     % [dB/(MHz^y cm)]&#60;br /&#62;
medium.alpha_power = 1.05;   &#60;/p&#62;
&#60;p&#62;Without the attenuation definition, the simulation works. However, once I defined the attenuation parameters, it doesn't work because of these errors.&#60;br /&#62;
----------------------------------------------------------------------------------&#60;br /&#62;
error : waitbar (line 100)&#60;br /&#62;
The second argument must be a message string or a handle to an existing waitbar.&#60;/p&#62;
&#60;p&#62;error : kspaceFirstOrder2D (line 964)&#60;br /&#62;
        waitbar(t_index / kgrid.Nt, pbar);&#60;br /&#62;
----------------------------------------------------------------------------------&#60;br /&#62;
How can I solve it?&#60;br /&#62;
Let me put my simulation code below.&#60;br /&#62;
Thank you in advance.&#60;/p&#62;
&#60;p&#62;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%My code%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&#60;br /&#62;
% % Define sound speed at every grid points&#60;br /&#62;
sound_speed = 340; %[m/s] : base&#60;br /&#62;
medium.sound_speed = sound_speed * ones(Nx,Ny);      % 340 [m/s]&#60;br /&#62;
medium.sound_speed = medium.sound_speed + BWI * 1200; % 1540[m/s]&#60;br /&#62;
medium.sound_speed = medium.sound_speed + BWI1 * 102; % 1567[m/s]&#60;br /&#62;
medium.sound_speed = medium.sound_speed + BWI2 * 147; % 1612[m/s]&#60;br /&#62;
medium.sound_speed = medium.sound_speed + BWI3 * 147; % 1612[m/s]&#60;br /&#62;
medium.sound_speed = medium.sound_speed + BWI4 * 125; % 1590[m/s]&#60;br /&#62;
medium.sound_speed = medium.sound_speed + BWI5 * 35; % 1500[m/s]&#60;br /&#62;
medium.sound_speed = medium.sound_speed + BWI6 * 119; % 1584[m/s]&#60;br /&#62;
medium.sound_speed = medium.sound_speed + BWI7 * 119; % 1584[m/s]&#60;br /&#62;
medium.sound_speed = medium.sound_speed + BWI8 * 35; % 1575[m/s]&#60;br /&#62;
medium.sound_speed = medium.sound_speed - BWI9 * 110; % 1465[m/s]&#60;br /&#62;
medium.sound_speed = medium.sound_speed + BWI10 * 2060; % 3635[m/s]&#60;/p&#62;
&#60;p&#62;% medium.sound_speed = 1540 * ones(Nx,Ny);&#60;/p&#62;
&#60;p&#62;% create a duplicate of the propagation medium structure and append the&#60;br /&#62;
% absorption properties&#60;br /&#62;
medium.sound_speed_ref = 1540; %[m/s]&#60;br /&#62;
medium.alpha_coeff = 2;                     % [dB/(MHz^y cm)]&#60;br /&#62;
medium.alpha_power = 1.05;   &#60;/p&#62;
&#60;p&#62;% make time array&#60;br /&#62;
% t_end should be longer than Nx*dx/slowest_sound_speed&#60;br /&#62;
t_end = 4e-4;            % [s]&#60;br /&#62;
cfl = 1540*10^(-7)/dx;   % the basical sound speed is 1540 [m/s]&#60;br /&#62;
kgrid.makeTime(1540,cfl,t_end);&#60;/p&#62;
&#60;p&#62;% Define 1050[kg/m^3] as density at every grid points&#60;br /&#62;
medium.density = 1050 * ones(Nx, Ny);       % [kg/m^3]&#60;/p&#62;
&#60;p&#62;% % send the pulse&#60;br /&#62;
smask = zeros(Nx,Ny);&#60;br /&#62;
% cordination of the source&#60;br /&#62;
source_x = 0.0003; %[m]&#60;br /&#62;
source_y = -0.0096; %[m]&#60;br /&#62;
% % in case the number of grid points is odd&#60;br /&#62;
source_grid_x = round(Nx/2 + source_cordination_x/dx);&#60;br /&#62;
source_grid_y = round(Ny/2 + source_cordination_y/dy);&#60;/p&#62;
&#60;p&#62;source_cordination_x = kgrid.x(source_grid_x,source_grid_y);&#60;br /&#62;
source_cordination_y = kgrid.y(source_grid_x,source_grid_y);&#60;br /&#62;
smask(source_grid_x,source_grid_y) = 1;&#60;br /&#62;
source.p_mask = smask;&#60;/p&#62;
&#60;p&#62;source_strength = 10;          % [Pa]&#60;br /&#62;
tone_burst_freq = 1e6;        % [Hz]&#60;br /&#62;
tone_burst_cycles = 5;&#60;br /&#62;
sampling_freq = 1/kgrid.dt;&#60;br /&#62;
toneBurst(sampling_freq, tone_burst_freq, tone_burst_cycles, 'Plot', true);&#60;br /&#62;
% create the input signal using toneBurst&#60;br /&#62;
source.p = source_strength .* toneBurst(sampling_freq, tone_burst_freq, tone_burst_cycles);&#60;br /&#62;
source_capsule = source.p; &#60;/p&#62;
&#60;p&#62;[max_source,index_source] = max(source.p);&#60;/p&#62;
&#60;p&#62;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&#60;br /&#62;
%Define the sensor&#60;br /&#62;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&#60;br /&#62;
Edge = imread('Edge.jpg');&#60;br /&#62;
sp = Edge;&#60;br /&#62;
[row,col,v] = find(sp);&#60;br /&#62;
tx = kgrid.x(row,col);&#60;br /&#62;
ty = kgrid.y(row,col);&#60;br /&#62;
transx = tx(:,1);&#60;br /&#62;
transy = ty(1,:);&#60;br /&#62;
number_of_elements = size(v,1);&#60;br /&#62;
% define a centered circular sensor&#60;br /&#62;
sensor.mask = sp;&#60;/p&#62;
&#60;p&#62;% run the simulation with optional inputs for plotting the simulation&#60;br /&#62;
% layout in addition to removing the PML from the display&#60;br /&#62;
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, ...&#60;br /&#62;
    'PlotLayout', true, 'PlotPML', false, 'RecordMovie',true,'PlotSim',true,'DataCast','gpuArray-single');&#60;br /&#62;
sensor_data = gather(sensor_data);&#60;/p&#62;
&#60;p&#62;Saya Mizutani
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
