<?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; User Favorites: Kalunga</title>
		<link><a href='http://www.k-wave.org/forum/profile/kalunga'>kalunga</a></link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Tue, 12 May 2026 23:08:28 +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/profile/" rel="self" type="application/rss+xml" />

		<item>
			<title>Seneca on "Ultrasound transducer as sensor."</title>
			<link>http://www.k-wave.org/forum/topic/ultrasound-transducer-as-sensor#post-6576</link>
			<pubDate>Wed, 12 Sep 2018 21:10:30 +0000</pubDate>
			<dc:creator>Seneca</dc:creator>
			<guid isPermaLink="false">6576@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Dear all,&#60;/p&#62;
&#60;p&#62;I found the answer here: &#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://www.k-wave.org/forum/topic/3d-simulations-output-with-gpu&#34; rel=&#34;nofollow&#34;&#62;http://www.k-wave.org/forum/topic/3d-simulations-output-with-gpu&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Best regards
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Seneca on "Ultrasound transducer as sensor."</title>
			<link>http://www.k-wave.org/forum/topic/ultrasound-transducer-as-sensor#post-6575</link>
			<pubDate>Wed, 05 Sep 2018 16:01:07 +0000</pubDate>
			<dc:creator>Seneca</dc:creator>
			<guid isPermaLink="false">6575@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Dear all,&#60;/p&#62;
&#60;p&#62;I am performing some simulations using k-wave. Normally I used sensor instead of ultrasound transducer array.&#60;br /&#62;
If I run the 'example_us_transducer_as_sensor' my final data is always: &#60;/p&#62;
&#60;p&#62;sensor_data = number_of_activeElements*time_vector; Which is fine for me, because I can visualize each single line in function of time.&#60;/p&#62;
&#60;p&#62;Nevertheless, if I perform the simulation saving in the GPU, I do not have the same output as sensor_data. I obtain something like:&#60;/p&#62;
&#60;p&#62;data_sensor = X*number_of_activeElements*time_vector; if I use 10 active elements I have something like: sensor_data = 120*time_vector. Where X in this case is 12.&#60;/p&#62;
&#60;p&#62;Is it possible to run a simulation in the GPU and only have the pressure recorded in the active elements of the sensor?&#60;/p&#62;
&#60;p&#62;Best
&#60;/p&#62;</description>
		</item>
		<item>
			<title>HannaB on "3D simulations output with GPU"</title>
			<link>http://www.k-wave.org/forum/topic/3d-simulations-output-with-gpu#post-6200</link>
			<pubDate>Wed, 08 Nov 2017 14:47:55 +0000</pubDate>
			<dc:creator>HannaB</dc:creator>
			<guid isPermaLink="false">6200@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Brad&#60;br /&#62;
Couldn't have been more helpful, thanks a lot !!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "3D simulations output with GPU"</title>
			<link>http://www.k-wave.org/forum/topic/3d-simulations-output-with-gpu#post-6198</link>
			<pubDate>Wed, 08 Nov 2017 13:45:13 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">6198@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Hanna,&#60;/p&#62;
&#60;p&#62;When you use an object of the &#60;code&#62;kWaveTransducer&#60;/code&#62; class as the sensor, the MATLAB implementation of &#60;code&#62;kspaceFirstOrder3D&#60;/code&#62; will automatically average the signals across the grid points belonging to each transducer element using the appropriate delays. The output &#60;code&#62;sensor_data&#60;/code&#62; will then contain as many time series as there are transducer elements.&#60;/p&#62;
&#60;p&#62;This behaviour is not implemented in the C++ code, so instead the output &#60;code&#62;sensor_data&#60;/code&#62; will contain as many time series as the number of grid points that form the transducer. However, you can combine the data after the simulation using the &#60;code&#62;combine_sensor_data&#60;/code&#62; of the &#60;code&#62;kWaveTransducer&#60;/code&#62; class to give you the same output as when using the MATLAB code.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>HannaB on "3D simulations output with GPU"</title>
			<link>http://www.k-wave.org/forum/topic/3d-simulations-output-with-gpu#post-6197</link>
			<pubDate>Wed, 08 Nov 2017 11:58:25 +0000</pubDate>
			<dc:creator>HannaB</dc:creator>
			<guid isPermaLink="false">6197@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Update: I think I understood the point but still have questions.&#60;/p&#62;
&#60;p&#62;The width of one element is 5 in grid units, and its length is 10 in grid units. The output signal given by kspacefirstorder3dg seems to give the RF coming from each grid point composing each element of the transducer. Is that right? &#60;/p&#62;
&#60;p&#62;Is there a way to ask for only 64 signals in the output? Or do I have to code the summation for each element of my transducer myself? &#60;/p&#62;
&#60;p&#62;Therefore, is it a summation of the RF from each grid points of the element that is done in kspacefirstorder3d? Or is it a mean? &#60;/p&#62;
&#60;p&#62;Thanks for your answers,&#60;/p&#62;
&#60;p&#62;Hanna
&#60;/p&#62;</description>
		</item>
		<item>
			<title>HannaB on "3D simulations output with GPU"</title>
			<link>http://www.k-wave.org/forum/topic/3d-simulations-output-with-gpu#post-6196</link>
			<pubDate>Wed, 08 Nov 2017 11:35:45 +0000</pubDate>
			<dc:creator>HannaB</dc:creator>
			<guid isPermaLink="false">6196@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello, &#60;/p&#62;
&#60;p&#62;I have a 3d simulation working fine with kspacefirstorder3D, but taking few hours to complete. I am trying to improve the code by running it on my GPU.&#60;br /&#62;
I only change on my code the function - replaced by kspacefirstorder3DG.&#60;br /&#62;
I don't understand how to control what happens inside this function which seems to do something different than before.&#60;/p&#62;
&#60;p&#62;- 'kspacefirstorder3D' code gives me sensor data of 64 (elements) by 4468 (time) &#60;/p&#62;
&#60;p&#62;- 'kspacefirstorder3DG' code gives me sensor data of 3200 by 4468. By plotting the RF I understood where the 3200 comes from:&#60;br /&#62;
3200 = 64 (elements) * 5 (size of element in kgrid) * 10 (repetitions of the simulation)&#60;/p&#62;
&#60;p&#62;Here are my points :&#60;br /&#62;
1) Why is the simulation repeated 10 times? How can I ask for only one?&#60;br /&#62;
2) Why do I have 5 signals per element and not only one? Can I change this in the inputs? (I guess I can fix this by summing the 5 signals for each element, but how come it is different from kspacefirstorder3d?..)&#60;/p&#62;
&#60;p&#62;Thank you very much for your answers and advice,&#60;br /&#62;
All the best,&#60;/p&#62;
&#60;p&#62;Hanna&#60;/p&#62;
&#60;p&#62;PS: The transducer is defined with kWaveTransducer.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Simulation of ultrasound propagating from soft tissue to air"</title>
			<link>http://www.k-wave.org/forum/topic/simulation-of-ultrasound-propagating-from-soft-tissue-to-air#post-5450</link>
			<pubDate>Tue, 05 Apr 2016 08:55:34 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">5450@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Jingba,&#60;/p&#62;
&#60;p&#62;First, it's worth pointing out that the situation you are simulating has an impedance mismatch on the order of 1e6, which makes it challenging to deal with computationally. The NaNs are because the code is unstable with the grid parameters you have used. &#60;/p&#62;
&#60;p&#62;There are a few problems with your code:&#60;/p&#62;
&#60;p&#62;(1) The definition of dx should use the minimum sound speed in the medium, which in your case will be air (not 1500 m/s). You can still use the sound speed in tissue to define your value of &#60;code&#62;t_end&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;(2) The CFL needs to be reduced for the code to be stable. Something like the following should work&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;% create the time array
t_end = (Nx*dx)*1.5/c0_tissue;     % [s]
CFL = 0.05;
kgrid.t_array = makeTime(kgrid, c0_tissue, CFL, t_end);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;(3) You should be aware of the frequency content of your source, and the maximum frequency you have chosen for the grid. If you plot the frequency spectrum of &#60;code&#62;transducer_TX.input_signal&#60;/code&#62;, you will see that it has energy above your chosen maximum frequency. You could either increase the maximum frequency, reduce the source frequency, or remove the unsupported frequencies using &#60;code&#62;filterTimeSeries&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;Hope that helps,&#60;/p&#62;
&#60;p&#62;Brad
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bowen Jing on "Simulation of ultrasound propagating from soft tissue to air"</title>
			<link>http://www.k-wave.org/forum/topic/simulation-of-ultrasound-propagating-from-soft-tissue-to-air#post-5431</link>
			<pubDate>Fri, 18 Mar 2016 08:36:15 +0000</pubDate>
			<dc:creator>Bowen Jing</dc:creator>
			<guid isPermaLink="false">5431@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;I am trying to model the reflection and refraction of ultrasound at a interface between soft tissue and air. The sound speed and density of air are 340 m/s and 1.29 Kg/m3 respectively. the size of the interface is much larger than the wavelength of ultrasound source. ultrasound frequency is on the order of 10 MHz.&#60;br /&#62;
However, the ultrasound echo received by the linear transducer is a matrix of NaN (not a number). The Matlab code is shown below. I don't know why it didn't work out.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;clc
clear all
close all
% simulation settings
DATA_CAST       = &#38;#39;double&#38;#39;;     % set to &#38;#39;single&#38;#39; or &#38;#39;gpuArray-single&#38;#39; to speed up computations

%% 

========================================================================

=
% DEFINE THE K-WAVE GRID
% 

========================================================================

=
% compute grid spacing based on a desired x_size and f_max
x_size = 50e-3;             % [m] desired domain size on x direction (depth...)
c0_min = 1500;              % [m/s] 

f_max = 15e6;               % [Hz] maximum frequency of ultrasound interested
points_per_wavelength = 2;
dx = c0_min/(points_per_wavelength*f_max); % [m]
dy = dx;                    % [m]
dz = dx;                    % [m]
pml_x_size = 20;            % [grid points]
pml_y_size = 20;            % [grid points]
pml_z_size = 20;            % [grid points]

Nx_at_smallest_prime_factor = 256;
Ny_at_smallest_prime_factor = 128;
Nz_at_smallest_prime_factor = 128;
% set number of grid points not including the PML
Nx = Nx_at_smallest_prime_factor - 2*pml_x_size;   % [grid points]
Ny = Ny_at_smallest_prime_factor - 2*pml_y_size;   % [grid points]
Nz = Nz_at_smallest_prime_factor - 2*pml_z_size;   % [grid points]

% create the k-space grid
kgrid = makeGrid(Nx, dx, Ny, dy, Nz, dz);
% create the time array
t_end = (Nx*dx)*1.5/c0_min;     % [s]
kgrid.t_array = makeTime(kgrid, c0_min, [], t_end);
%% 

========================================================================

=
% DEFINE THE MEDIUM PARAMETERS
% 

========================================================================

=
% define the properties of the air

c0_air = 340;                   % [m/s]

rho0_air = 1.29;                % [kg/m^3]

% medium.alpha_coeff = 0.75; 	% [dB/(MHz^y cm)]
% medium.alpha_power = 1.5;
% medium.BonA = 6;
medium.sound_speed = c0_air*ones(Nx, Ny, Nz);
medium.density = rho0_air*ones(Nx, Ny, Nz);

% define the properties of the soft tissue
c0_tissue = 1540;                   % [m/s]
rho0_tissue = 1000;                % [kg/m^3]

std = 0.005;
speed_map_tissue = c0_tissue*(ones(Nx, Ny, Nz) + std*randn(Nx, Ny, Nz));
density_map_tissue = rho0_tissue*(ones(Nx, Ny, Nz) + std*randn(Nx, Ny, Nz));

% define the region of tissue

region_tissue = zeros(Nx, Ny, Nz);

radius = Nx/2 -10;
for i = 1:Nz
    region_tissue(:,:,i) = makeDisc(Nx, Ny, 1, Ny/2, radius);
end

% define the properties of tissue
medium.sound_speed(region_tissue == 1) = speed_map_tissue(region_tissue == 1);
medium.density(region_tissue == 1) = density_map_tissue(region_tissue == 1);
% show the sound speed map of compound medium, the air and tissue
figure
imagesc(medium.sound_speed(:,:,44)) 

%% 

========================================================================

=
% DEFINE THE INPUT SIGNAL
% 

========================================================================

=

% define properties of the input signal
source_strength = 1e6;    	% [Pa]
tone_burst_freq = 12e6; 	% [Hz]
tone_burst_cycles = 2;

% create the input signal using toneBurst
input_signal = toneBurst(1/kgrid.dt, tone_burst_freq, tone_burst_cycles,...
    &#38;#39;Envelope&#38;#39;, &#38;#39;Gaussian&#38;#39;, &#38;#39;Plot&#38;#39;,true);

% scale the source magnitude by the source_strength divided by the
% impedance (the source is assigned to the particle velocity)
input_signal = (source_strength./(c0_tissue*rho0_tissue)).*input_signal;

%% 

========================================================================

=
% DEFINE THE TX TRANSDUCER
% 

========================================================================

=

% the linear array transducer for TX

transducer_TX.number_elements = 32;   % total number of transducer elements
transducer_TX.element_width = 2 ;     % width of each element [grid points]
transducer_TX.element_length = 20 ;	% length of each element [grid points]
transducer_TX.element_spacing = 0;  	% spacing (kerf  width) between the elements [grid points]
transducer_TX.radius = inf;            % radius of curvature of the transducer [m]

transducer_width_TX = transducer_TX.number_elements*transducer_TX.element_width ...
    + (transducer_TX.number_elements - 1)*transducer_TX.element_spacing;

% transducer_TX.position: X = 1
transducer_TX.position = round([1, Ny/2 - transducer_width_TX/2, Nz/2 - 

transducer_TX.element_length/2]);

% properties used to derive the beamforming delays
transducer_TX.sound_speed = 1540;              % sound speed [m/s]
transducer_TX.focus_distance = inf;          % focus distance [m]
transducer_TX.elevation_focus_distance = 20e-3;% focus distance in the elevation plane [m]
transducer_TX.steering_angle = 0;              % steering angle [degrees]

% apodization
transducer_TX.transmit_apodization = &#38;#39;Rectangular&#38;#39;;
transducer_TX.receive_apodization = &#38;#39;Rectangular&#38;#39;;

% use all the element to TX
transducer_TX.active_elements = ones(transducer_TX.number_elements, 1);

% append input signal used to drive the transducer
transducer_TX.input_signal = input_signal;

% create the transducer using the defined settings
transducer_TX_class = makeTransducer(kgrid, transducer_TX);

transducer_TX_class.properties
transducer_TX_class.plot

%% 

========================================================================

=
% RUN THE SIMULATION
% 

========================================================================

=

% set the input settings

input_args = {&#38;#39;PMLInside&#38;#39;, false, &#38;#39;PMLSize&#38;#39;, [pml_x_size, pml_y_size, pml_z_size],...
 &#38;#39;DataCast&#38;#39;, DATA_CAST};
[sensor_data] = kspaceFirstOrder3D(kgrid, medium, transducer_TX_class, transducer_TX_class, 

input_args{:});

element_data = transducer_TX_class.combine_sensor_data(sensor_data);

save element_data.mat element_data&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>DNF on "Spurious wave generation in absorbing media"</title>
			<link>http://www.k-wave.org/forum/topic/spurious-wave-generation-in-absorbing-media#post-4984</link>
			<pubDate>Mon, 09 Feb 2015 15:04:54 +0000</pubDate>
			<dc:creator>DNF</dc:creator>
			<guid isPermaLink="false">4984@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Thank you, Bradley. At this point, it isn't terribly urgent to get the files quickly, but I am very interested in the content.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Spurious wave generation in absorbing media"</title>
			<link>http://www.k-wave.org/forum/topic/spurious-wave-generation-in-absorbing-media#post-4975</link>
			<pubDate>Wed, 04 Feb 2015 23:46:05 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">4975@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi DNF,&#60;/p&#62;
&#60;p&#62;If you capture the time-varying pressure over a 2D plane, and then enforce this as a Dirichlet boundary condition in the next simulation, this is sufficient (you don't also need particle velocity). However, the problem is that if you are enforcing a boundary condition, any waves that are reflected from heterogeneities will again be reflected from the plane over which you are enforcing the boundary condition (with an amplitude dependent on the exact value of pressure you happen to be enforcing at that time). This means your simulations results will not match the non-split case.&#60;/p&#62;
&#60;p&#62;I'm currently away for a meeting, but when I'm back at my desk, I'll tidy up the codes and email them to you.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>DNF on "Spurious wave generation in absorbing media"</title>
			<link>http://www.k-wave.org/forum/topic/spurious-wave-generation-in-absorbing-media#post-4963</link>
			<pubDate>Wed, 28 Jan 2015 09:38:27 +0000</pubDate>
			<dc:creator>DNF</dc:creator>
			<guid isPermaLink="false">4963@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Thank you, Bradley.&#60;/p&#62;
&#60;p&#62;I am interested both in the elastic code, and in the SimSonic wrapper you mentioned previously.&#60;/p&#62;
&#60;p&#62;As for splitting the simulation, I would have thought that recording the pressure field a slightly before the first interface, then re-transmitting it into the layered structure (with much higher sampling), and then recording the pressure again, I would be able to capture multiple reflections. Anyway, is capturing the pressure sufficient? Are not the particle velocities required?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Spurious wave generation in absorbing media"</title>
			<link>http://www.k-wave.org/forum/topic/spurious-wave-generation-in-absorbing-media#post-4960</link>
			<pubDate>Fri, 23 Jan 2015 17:46:44 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">4960@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi DNF,&#60;/p&#62;
&#60;p&#62;The function &#60;code&#62;kspaceElastic2D&#60;/code&#62; is a k-space code for elastic media with power law absorption, as discussed in &#60;a href=&#34;http://www.homepages.ucl.ac.uk/~rmapbtr/papers/JOURN_23_2014_Treeby_JASA_PowerLawAbsorptionElastic.pdf&#34;&#62;this paper&#60;/a&#62;. This model is still under development, so is not in the current release code. At the moment, there is only a 2D version and no PML is implemented. However, I'd be happy to send you a copy to try out if that's helpful.&#60;/p&#62;
&#60;p&#62;If you are only interested in the first transmitted wave, then dividing your simulation into chunks in this way will work. If you record the pressure field over a plane in the first simulation, you can enforce this as a Dirichlet boundary condition in the next simulation. However, keep in mind that you will not be able to model multiple reflections, etc.&#60;/p&#62;
&#60;p&#62;If you are using the C++ code, there is a checkpoint-restart facility that can be easily used (see the &#60;a href=&#34;http://www.k-wave.org/doxygen/index.html&#34;&#62;doxygen documentation&#60;/a&#62; for more details). Unfortunately, the same facility doesn't exist in the MATLAB code at the moment&#60;/p&#62;
&#60;p&#62;Hope that helps,&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>DNF on "Spurious wave generation in absorbing media"</title>
			<link>http://www.k-wave.org/forum/topic/spurious-wave-generation-in-absorbing-media#post-4956</link>
			<pubDate>Fri, 23 Jan 2015 09:01:06 +0000</pubDate>
			<dc:creator>DNF</dc:creator>
			<guid isPermaLink="false">4956@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Thanks for looking into this.&#60;/p&#62;
&#60;p&#62;Now, &#60;code&#62;pstdElastic2D&#60;/code&#62; is not not a k-space method, as you say, but I recently came over a reference to a function &#60;code&#62;kspaceElastic2D&#60;/code&#62;, inside the script &#60;code&#62;kspaceFirstOrder_inputChecking&#60;/code&#62; (line 45). Is that code which is under development?&#60;/p&#62;
&#60;p&#62;I am considering splitting up the calculation into several chunks. Since I have a layered structure, I thought it might be possible to propagate in one homogeneous layer, save the state, propagate across a boundary with higher sampling, save the state, etc. Might this be a viable approach? &#60;/p&#62;
&#60;p&#62;Is it easy or even possible to save the state of the simulation? This would also enable me to pause and resume the simulation, or interrupt/fail while keeping the results up to that point, which is something I miss a bit.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Spurious wave generation in absorbing media"</title>
			<link>http://www.k-wave.org/forum/topic/spurious-wave-generation-in-absorbing-media#post-4945</link>
			<pubDate>Thu, 22 Jan 2015 16:28:49 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">4945@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi DNF,&#60;/p&#62;
&#60;p&#62;Unfortunately, I haven't managed to get to the bottom of the behaviour you have observed. It seems to be related the fractional absorption operator in the case &#60;code&#62;medium.alpha_power&#60;/code&#62; is not equal to 2, and &#60;code&#62;medium.alpha_coeff&#60;/code&#62; is high. Using &#60;code&#62;medium.alpha_mode = &#38;#39;no_absorption&#38;#39;&#60;/code&#62; causes the effect to disappear, so it doesn't appear to be related to the dispersion term. It's possible it's related the particle velocity used in the absorption term being temporally offset by dt/2 from the acoustic density to which it's added. I will keep digging.&#60;/p&#62;
&#60;p&#62;In the elastic case, my guess is you're just seeing classic instability. Unfortunately, we have not derived a closed form expression for stability in the absorbing elastic case using the PSTD model. However, remember the elastic code &#60;code&#62;pstdElastic2D&#60;/code&#62; does not use a k-space corrected time-stepping scheme, so is not unconditionally stable. You will need to use a smaller time step than in the associated fluid case, both to achieve stability, and to avoid numerical dispersion from the time-stepping scheme.&#60;/p&#62;
&#60;p&#62;One point to note, if you are interested in modelling very strong impedance discontinuities, spectral methods might not be your best choice. In &#60;a href=&#34;http://www.k-wave.org/papers/2014-Robertson-IEEEIUS.pdf&#34;&#62;this paper&#60;/a&#62; there is a plot of the accuracy in the reflection coefficient versus the strength of the discontinuity. Roughly speaking, as the code stands, for contrasts stronger than 4:1, finite difference methods will give you more accurate reflection coefficients. If your domain size isn't very large (so the accumulation of dispersion error isn't a problem), you might be better served using a tool like &#60;a href=&#34;http://www.simsonic.fr&#34;&#62;SimSonic&#60;/a&#62;.&#60;/p&#62;
&#60;p&#62;The only other thing to mention is that when viewing the simulations with a log scale, small-scale behaviour becomes magnified. Given the perfectly matched layer will only be accurate to a few decimal places at best, in some cases the spurious waves you have observed might not be a problem.&#60;/p&#62;
&#60;p&#62;Hope that helps,&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>DNF on "Spurious wave generation in absorbing media"</title>
			<link>http://www.k-wave.org/forum/topic/spurious-wave-generation-in-absorbing-media#post-4938</link>
			<pubDate>Fri, 16 Jan 2015 09:32:59 +0000</pubDate>
			<dc:creator>DNF</dc:creator>
			<guid isPermaLink="false">4938@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Yes, I am aware of the basic reason why this happens. But absorption and the choice of alpha_power can increase the effect dramatically. The effect is very noticeable. Even using 30-40 points per wavelength, it is still clearly present. I am in a situation where a 1D simulation can take up to 20 hours on a new and powerful pc.&#60;/p&#62;
&#60;p&#62;And in the elastic simulations, as I said, the effect grows without bounds, eventually completely drowning out the real solution.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ouelletn on "Spurious wave generation in absorbing media"</title>
			<link>http://www.k-wave.org/forum/topic/spurious-wave-generation-in-absorbing-media#post-4937</link>
			<pubDate>Thu, 15 Jan 2015 16:09:15 +0000</pubDate>
			<dc:creator>ouelletn</dc:creator>
			<guid isPermaLink="false">4937@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Run the 1D code for a very short time and stop it. If you zoom into the actual wave you should notice that the wave is undergoing a ringing effect that extends into the second media. This ringing effect is inherent of the high discontinuities in your simulation and a limitation of expressing the wave as a Fourier series. &#60;/p&#62;
&#60;p&#62;The only way to minimize this is to increase the number of grid points within the simulations.Changing the frequency distribution of the impulse may also help reduce this effect. You should consider mostly if this is necessary for your simulation, as the amplitude of this effect is fairly low and may not influence any statements made about the effect of the layers.&#60;br /&#62;
-Andrew
&#60;/p&#62;</description>
		</item>
		<item>
			<title>DNF on "Spurious wave generation in absorbing media"</title>
			<link>http://www.k-wave.org/forum/topic/spurious-wave-generation-in-absorbing-media#post-4934</link>
			<pubDate>Wed, 14 Jan 2015 11:06:52 +0000</pubDate>
			<dc:creator>DNF</dc:creator>
			<guid isPermaLink="false">4934@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;This effect is also visible in the 2D version of the code.&#60;/p&#62;
&#60;p&#62;Worse, when using &#60;code&#62;pstdElastic2D.m&#60;/code&#62; with strong impedance contrasts, spurious waves are generated that in some cases grow exponentially and without bound, to the point that they reach a value of &#60;code&#62;inf&#60;/code&#62;, causing the visualization to give an error. Both spurious shear and pressure waves are generated, and grow wildly.&#60;/p&#62;
&#60;p&#62;This happens even when I use no absorption at all.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>DNF on "Spurious wave generation in absorbing media"</title>
			<link>http://www.k-wave.org/forum/topic/spurious-wave-generation-in-absorbing-media#post-4925</link>
			<pubDate>Mon, 05 Jan 2015 10:42:52 +0000</pubDate>
			<dc:creator>DNF</dc:creator>
			<guid isPermaLink="false">4925@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I am using k-Wave to simulate wave propagation in strongly contrasting media. A strange effect shows up during propagation when there is strong absorption. The attached figure illustrates the effect: Shortly after starting the excitation, and before the pulse arrives, a wave is generated inside the neighbouring layer.&#60;/p&#62;
&#60;p&#62;The magnitude of this effect is apparently influenced by several factors:&#60;br /&#62;
* The level of absorption — more absorption _increases_ the effect, contrary to my intuition.&#60;br /&#62;
* The distance from the source to the medium interface.&#60;br /&#62;
* The number of layers in the total medium (four layers is worse than three).&#60;br /&#62;
* When the wave reaches the PML it gets even worse.&#60;br /&#62;
* Using a power law exponent of 2 seems to remove the problem (this was pointed out to me by Dr. Treeby.)&#60;/p&#62;
&#60;p&#62;I can reduce the effect by increasing the temporal and spatial sampling rates, but some times even using 40 points per wavelength and a timestep less than a 1ns is not good enough for a transmit frequency of 500kHz.&#60;/p&#62;
&#60;p&#62;I have enclosed an example script that illustrates the effect. It seems that the effect gets worse at some ’sweet spot’ of combined impedances and layer thicknesses, which I cannot quite re-create.&#60;/p&#62;
&#60;p&#62;My questions:&#60;br /&#62;
* Do you see why this is happening? Could there be a bug in the absorption implementation, or is this more or less expected behaviour?&#60;br /&#62;
* What can I do to reduce this effect? For certain geometries, cranking up the sampling rates leads to 20h+ long 1D simulation.&#60;/p&#62;
&#60;p&#62;Here's an example script:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;%%
% This example shows a strange effect where a spurious wave is generated inside a
% medium layer before the excitation wave arrives in that layer.
%
% This happens when there is strong absorption inside one of the layers (e.g. 10dB/cm/MHz), and the
% effect is smaller when the absorption is reduced (e.g. to 1dB/cm/MHz). Tweaking the
% geometry in various ways also seems to change the effect, having four layers seems
% to be worse than having three layers, and the thickness of the various layers also
% make a difference.
%
% The effect can be reduced by reducing the timestep, but sometimes to extreme levels.

%% Geometry
padding = 5e-3;
Lx = [6,2,10,20]*1e-3;

%% Material properties
c = [600, 3000, 6000, 3000];
rho = [200, 2000, 8000, 2000];
attn = [0.2, 10, 0.05, 0.1];
% attn = [0.2, 1.0, 0.05, 0.1]; % reducing the absorption reduces the effect
attn_power = 1.0; % changing it to 2.0 removes the problem

useattn = true;

%% Transmit pulse
Npulse = 2;
fc = 0.5e6;

%% Computational grid
ppw = 20; % points per wavelength
cfl = 0.1; % Courant-Friedrich-Lewy

% grid size
dx = min(c)/(ppw*fc);
Nx = ceil(sum([Lx,padding])/dx);
kgrid = makeGrid(Nx,dx);

% index positions of interfaces
ind = round(cumsum([padding,Lx(1:end-1)])/dx);

medium = struct();
% sound velocity
medium.sound_speed = c(1) + zeros(Nx,1);
for jj = 2:length(ind),
    medium.sound_speed(ind(jj):end) = c(jj);
end

% density
medium.density = rho(1) + zeros(Nx,1);
for jj = 2:length(ind),
    medium.density(ind(jj):end) = rho(2);
end

% attenuation
if useattn,
    medium.alpha_coeff = attn(1) + zeros(Nx,1);
    for jj = 2:length(ind),
        medium.alpha_coeff(ind(jj):end) = attn(jj);
    end

    medium.alpha_power = attn_power;
    medium.alpha_mode = &#38;#39;no_dispersion&#38;#39;;
end

[kgrid.t_array,dt] = makeTime(kgrid,medium.sound_speed,cfl);

%% Transducer
Amp = 1e-6;
source = struct();
source.u_mask = zeros(Nx,1);
source.u_mask(ind(1)) = 1;
source.ux = -Amp*toneBurst(1/kgrid.dt,fc,Npulse,&#38;#39;Envelope&#38;#39;,&#38;#39;Gaussian&#38;#39;);

sensor = struct();
sensorind = ind(1):10:Nx;
sensor.mask = zeros(Nx,1);
sensor.mask(sensorind) = 1;
sensor.record = {&#38;#39;p&#38;#39;};

% display
display_mask = zeros(Nx,1);
display_mask(ind) = 1;

%% 1D sim
args = {&#38;#39;DataCast&#38;#39;,&#38;#39;double&#38;#39;, ...
    &#38;#39;LogScale&#38;#39;,true, ...
    &#38;#39;DisplayMask&#38;#39;,display_mask, ...
    &#38;#39;PMLSize&#38;#39;,ppw*2, ... % 2 wavelengths
    &#38;#39;PMLInside&#38;#39;,false, ...
    &#38;#39;PlotPML&#38;#39;,false, ...
    &#38;#39;PlotSim&#38;#39;,true};
data = kspaceFirstOrder1D(kgrid,medium,source,sensor,args{:});&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>sheun on "problem saving .h5 for c++ simulation"</title>
			<link>http://www.k-wave.org/forum/topic/problem-saving-h5-for-c-simulation#post-4298</link>
			<pubDate>Tue, 04 Feb 2014 02:10:53 +0000</pubDate>
			<dc:creator>sheun</dc:creator>
			<guid isPermaLink="false">4298@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Sorry to bother you. It was my mistake.&#60;/p&#62;
&#60;p&#62;Thanks for the help though!!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "problem saving .h5 for c++ simulation"</title>
			<link>http://www.k-wave.org/forum/topic/problem-saving-h5-for-c-simulation#post-4296</link>
			<pubDate>Mon, 03 Feb 2014 09:49:11 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">4296@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi sheun,&#60;/p&#62;
&#60;p&#62;If you use the option &#60;code&#62;&#38;#39;SaveToDisk&#60;/code&#62;' the simulation isn't actually run (it stops after the input data is saved to disk), so no output is returned, hence the error message.&#60;/p&#62;
&#60;p&#62;You should either use:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;kspaceFirstOrder3D(kgrid, medium, source, sensor, &#38;#39;SaveToDisk&#38;#39;, filetype, input_args{:});&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;and then call the C++ code yourself from the command line, or:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;sensor_data = kspaceFirstOrder3DC(kgrid, medium, source, sensor, input_args{:});&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;and let the wrapper function …3DC add the &#60;code&#62;&#38;#39;SaveToDisk&#60;/code&#62;' argument and call the C++ code for you.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
