<?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: MGCain</title>
		<link><a href='http://www.k-wave.org/forum/profile/mgcain'>mgcain</a></link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 09:15:30 +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>MGCain on "Simulate ultrasound pressure on piezoelectric inclusions in medium"</title>
			<link>http://www.k-wave.org/forum/topic/simulate-ultrasound-pressure-on-piezoelectric-inclusions-in-medium#post-7582</link>
			<pubDate>Mon, 08 Jun 2020 14:12:57 +0000</pubDate>
			<dc:creator>MGCain</dc:creator>
			<guid isPermaLink="false">7582@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Thanks for this Brad. I will explore simulation with k-wave to determine pressure fields and model the piezo response analytically. I can also use COMSOL later on if necessary. Thanks again.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Simulate ultrasound pressure on piezoelectric inclusions in medium"</title>
			<link>http://www.k-wave.org/forum/topic/simulate-ultrasound-pressure-on-piezoelectric-inclusions-in-medium#post-7571</link>
			<pubDate>Sat, 06 Jun 2020 18:43:11 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">7571@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi MGCain,&#60;/p&#62;
&#60;p&#62;If you're interested in small inclusions and coupling with piezoelectricity, k-Wave is probably not the right tool. A finite-element model that allows you to compute coupled physics might be the way to go.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>MGCain on "Simulate ultrasound pressure on piezoelectric inclusions in medium"</title>
			<link>http://www.k-wave.org/forum/topic/simulate-ultrasound-pressure-on-piezoelectric-inclusions-in-medium#post-7537</link>
			<pubDate>Mon, 01 Jun 2020 14:58:05 +0000</pubDate>
			<dc:creator>MGCain</dc:creator>
			<guid isPermaLink="false">7537@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi,&#60;br /&#62;
I am interested in using k-wave to sinmulate an ultrasound pressure wave on dispersed micron-sized inclusions of piezoelectric material inside a polymer matrix. In the simplest formalism I could launch a plane wave at one edge and measure pressure at all points inside my 3D volume. From pressure I can deduce the piezo response (I expect!). Any advice please on the specific approach/ example set I could start to explore? Thanks.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>rainbowwhale on "Simulation of a flat reflector"</title>
			<link>http://www.k-wave.org/forum/topic/simulation-of-a-flat-reflector#post-7374</link>
			<pubDate>Tue, 07 Apr 2020 03:24:36 +0000</pubDate>
			<dc:creator>rainbowwhale</dc:creator>
			<guid isPermaLink="false">7374@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;CFL number should be calculated using highest speed of sound.&#60;br /&#62;
By using highest speed of sound, current CFL number is about 4.13.&#60;br /&#62;
I tried using dt as 0.05/(PPP*F0) which has CFL number of about 0.2 and it worked.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Ryuji on "Simulation of a flat reflector"</title>
			<link>http://www.k-wave.org/forum/topic/simulation-of-a-flat-reflector#post-7363</link>
			<pubDate>Sat, 04 Apr 2020 02:07:08 +0000</pubDate>
			<dc:creator>Ryuji</dc:creator>
			<guid isPermaLink="false">7363@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi, thanks for providing the great library.&#60;br /&#62;
I would like to simulate a small 40kHz-ultrasound transducer with a flat reflector in 3D.&#60;br /&#62;
When I set the medium heterogeneous (air and acrylic), I cannot see any propagation even in the air. Is this because of the large change in impedance? I would appreciate it if you could tell me how to make my code work.&#60;br /&#62;
Thanks advance!&#60;/p&#62;
&#60;p&#62;Best regards,&#60;br /&#62;
Ryuji&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% sorce code&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;clear all;&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% DEFINE LITERALS&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% select which code to run&#60;br /&#62;
%   1: MATLAB CPU code&#60;br /&#62;
%   2: MATLAB GPU code&#60;br /&#62;
%   3: C++ code&#60;br /&#62;
MODEL           = 2;&#60;/p&#62;
&#60;p&#62;% scale parameter (changes the resolution of the simulation)&#60;br /&#62;
SC              = 1;&#60;/p&#62;
&#60;p&#62;% grid parameters&#60;br /&#62;
PML_SIZE        = 10;                    % size of the perfectly matched layer [grid points]&#60;br /&#62;
Nx              = 128*SC - 2*PML_SIZE;   % number of grid points in the x direction&#60;br /&#62;
Ny              = 64*SC - 2*PML_SIZE;   % number of grid points in the y direction&#60;br /&#62;
Nz              = 64*SC - 2*PML_SIZE;   % number of grid points in the z direction&#60;/p&#62;
&#60;p&#62;% sampling parameters&#60;br /&#62;
PPW             = 10*SC;	% points per wavelength (this defines the grid size)&#60;br /&#62;
PPP             = 10*SC;    % points per period (this defines the CFL)&#60;br /&#62;
T_END           = 1e-3;     % total compute time [s] (this must be long enough to reach steady state)&#60;br /&#62;
RECORD_PERIODS  = 2;        % number of periods to record&#60;/p&#62;
&#60;p&#62;% medium parameters&#60;br /&#62;
C0              = 346;      % sound speed [m/s]&#60;br /&#62;
RHO0            = 1.2;      % density [kg/m^3]&#60;br /&#62;
CR              = 1.43e3;   % sound speed in the reflector [m/s]&#60;br /&#62;
RHOR            = 1.18e3;   % density of the reflector [kg/m^3]&#60;/p&#62;
&#60;p&#62;% source parameters&#60;br /&#62;
F0              = 40e3;     % source frequency [Hz]&#60;br /&#62;
SOURCE_RADIUS   = 5e-3;     % piston radius [m]&#60;br /&#62;
SOURCE_MAG      = 0.5e6;    % source pressure [Pa]&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% CREATE GRID&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% calculate the grid spacing based on the PPW and F0&#60;br /&#62;
dx = C0 / (PPW * F0);   % [m]&#60;br /&#62;
dt = 1 / (PPP*F0);      % [s]&#60;br /&#62;
SOURCE_RADIUS = SOURCE_RADIUS / dx;&#60;/p&#62;
&#60;p&#62;% calculate the CFL&#60;br /&#62;
disp(['CFL = ' num2str(C0*dt/dx)]);&#60;/p&#62;
&#60;p&#62;% create the computational grid&#60;br /&#62;
kgrid = makeGrid(Nx, dx, Ny, dx, Nz, dx);&#60;/p&#62;
&#60;p&#62;% create the time array&#60;br /&#62;
kgrid.t_array = 0:dt:T_END;&#60;/p&#62;
&#60;p&#62;% assign medium properties&#60;br /&#62;
% medium.sound_speed = C0;&#60;br /&#62;
% medium.density = RHO0;&#60;br /&#62;
medium.sound_speed = C0 * ones(Nx, Ny, Nz);&#60;br /&#62;
medium.density = RHO0 * ones(Nx, Ny, Nz);&#60;br /&#62;
% assign reflector properties&#60;br /&#62;
medium.sound_speed(Nx, :, :) = CR;&#60;br /&#62;
medium.density(Nx, :, :) = RHOR;&#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;% =========================================================================&#60;br /&#62;
% CREATE SOURCE&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% create piston source mask&#60;br /&#62;
piston = makeDisc(Ny, Nz, Ny/2, Nz/2, SOURCE_RADIUS);&#60;br /&#62;
source.p_mask = zeros(Nx, Ny, Nz);&#60;br /&#62;
source.p_mask(1, :, :) = piston;&#60;/p&#62;
&#60;p&#62;% create time varying source&#60;br /&#62;
source.p = SOURCE_MAG * sin(2*pi*F0*kgrid.t_array);&#60;/p&#62;
&#60;p&#62;% filter source with up-ramp&#60;br /&#62;
ramp_length = round((2*pi/F0)/dt);&#60;br /&#62;
ramp = (-cos( (0:(ramp_length-1))*pi/ramp_length ) + 1)/2;&#60;br /&#62;
source.p(1:ramp_length) = ramp .* source.p(1:ramp_length);&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% CREATE SENSOR MASK&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% set sensor mask to record central axis, not including the source point&#60;br /&#62;
% sensor.mask = zeros(Nx, Ny, Nz);&#60;br /&#62;
% sensor.mask(2:end, Ny/2, Nz/2) = 1;&#60;br /&#62;
sensor.mask = [2, 1, Nz/2, Nx, Ny, Nz/2].';&#60;/p&#62;
&#60;p&#62;% record the maximum pressure&#60;br /&#62;
sensor.record = {'p', 'p_rms'};&#60;/p&#62;
&#60;p&#62;% average only the final few periods when the field is in steady state&#60;br /&#62;
sensor.record_start_index = kgrid.Nt - RECORD_PERIODS*PPP + 1;&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% RUN k-WAVE SIMULATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% run code&#60;br /&#62;
switch MODEL&#60;br /&#62;
    case 1&#60;br /&#62;
        % MATLAB CPU&#60;br /&#62;
        sensor_data = kspaceFirstOrder3D(kgrid, medium, source, sensor, ...&#60;br /&#62;
            'DataCast', 'single', 'PMLInside', false, ...&#60;br /&#62;
            'DisplayMask', source.p_mask, 'PlotScale', [-1, 1]*SOURCE_MAG);&#60;br /&#62;
    case 2&#60;br /&#62;
        % MATLAB GPU&#60;br /&#62;
        sensor_data = kspaceFirstOrder3D(kgrid, medium, source, sensor, ...&#60;br /&#62;
            'DataCast', 'gpuArray-single', 'PMLInside', false, ...&#60;br /&#62;
            'DisplayMask', source.p_mask, 'PlotScale', [-1, 1]*SOURCE_MAG);&#60;br /&#62;
    case 3&#60;br /&#62;
        % C++&#60;br /&#62;
        sensor_data = kspaceFirstOrder3DC(kgrid, medium, source, sensor, 'PMLInside', false);&#60;/p&#62;
&#60;p&#62;    otherwise&#60;/p&#62;
&#60;p&#62;end&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% ANALYTICAL SOLUTION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% calculate the wavenumber&#60;br /&#62;
k = 2*pi*F0./C0;&#60;/p&#62;
&#60;p&#62;% define radius and axis&#60;br /&#62;
a = SOURCE_RADIUS*dx;&#60;br /&#62;
x = (kgrid.x_vec(2:end, :) - min(kgrid.x_vec(:)));&#60;/p&#62;
&#60;p&#62;% calculate the analytical solution for a piston in an infinite baffle&#60;br /&#62;
% for comparison (Eq 5-7.3 in Pierce)&#60;br /&#62;
r_a = sqrt(x.^2 + a^2);&#60;br /&#62;
p_ref = SOURCE_MAG*abs(-2i*exp(1i*k*(x+r_a)/2).*sin((k*r_a - k*x)/2));&#60;/p&#62;
&#60;p&#62;% =========================================================================&#60;br /&#62;
% VISUALISATION&#60;br /&#62;
% =========================================================================&#60;/p&#62;
&#60;p&#62;% plot the pressure along the focal axis of the piston&#60;br /&#62;
figure;&#60;br /&#62;
plot(sensor_data.p(end,:), 'bx');&#60;/p&#62;
&#60;p&#62;img = gather(sensor_data.p_rms);&#60;br /&#62;
image(img, 'CDataMapping', 'scaled')&#60;br /&#62;
daspect([1 1 1])&#60;br /&#62;
colormap default&#60;br /&#62;
colorbar
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Planewave simulation"</title>
			<link>http://www.k-wave.org/forum/topic/planewave-simulation#post-5481</link>
			<pubDate>Fri, 29 Apr 2016 10:47:03 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">5481@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Rajesh,&#60;/p&#62;
&#60;p&#62;From memory you can set both of these values to inf to use an unfocused transducer. Alternatively, you could also create the source and sensor masks manually (i.e., set &#60;code&#62;source.p_mask&#60;/code&#62; and &#60;code&#62;sensor.mask&#60;/code&#62; rather than using the &#60;code&#62;kWaveTransducer&#60;/code&#62; class), and define a single source time series to drive all of the elements.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Particle acoustophoresis at &#34;larger&#34; scales using ultrasonic waves"</title>
			<link>http://www.k-wave.org/forum/topic/particle-acoustophoresis-at-larger-scales-using-ultrasonic-waves#post-5478</link>
			<pubDate>Fri, 29 Apr 2016 10:35:37 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">5478@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Andres,&#60;/p&#62;
&#60;p&#62;The main challenge with any grid based method (including k-Wave) is the accuracy with which you represent the heterogeneous structure of the material on the discrete grid. In some cases, the actual structure isn't that important, just the statistical effect it has on the propagating wave field. k-Wave doesn't have a problem with this type of geometry per-se, but you might want to perform a convergence study. That is, check to what degree the simulation output depends on the grid discretisation. If you want another model to compare to, you could also try &#60;a href=&#34;http://www.simsonic.fr/&#34;&#62;SimSonic&#60;/a&#62;. I've got a wrapper function that lets you call SimSonic2D with k-Wave inputs if that is helpful.&#60;/p&#62;
&#60;p&#62;Regarding elastic vs fluid simulation, I don't have much experience with the situation you are interested in, but if the media can support shear, then an elastic simulation is probably necessary. In any case, it should be easy enough to run the simulation with the k-Wave fluid and elastic codes and compare the results.&#60;/p&#62;
&#60;p&#62;Hope that helps,&#60;/p&#62;
&#60;p&#62;Brad
&#60;/p&#62;</description>
		</item>
		<item>
			<title>rajeshlvvl on "Planewave simulation"</title>
			<link>http://www.k-wave.org/forum/topic/planewave-simulation#post-5472</link>
			<pubDate>Mon, 18 Apr 2016 04:32:17 +0000</pubDate>
			<dc:creator>rajeshlvvl</dc:creator>
			<guid isPermaLink="false">5472@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Brad,&#60;/p&#62;
&#60;p&#62;We aretrying to simulate planewave propagation in a medium using 3D model. The way we are trying to generate a planewave is by giving very high values for azimuthal focus and elevation focus as below. Is the approach right? Or is there any other way to generate them?&#60;/p&#62;
&#60;p&#62;Thanks&#60;br /&#62;
-Rajesh &#60;/p&#62;
&#60;p&#62;transducer.focus_distance = 3000000e-3;          % focus distance [m]&#60;br /&#62;
transducer.elevation_focus_distance = 3000000e-3;% focus distance in the elevation plane [m]&#60;br /&#62;
transducer.steering_angle = 0;      % steering angle [degrees]&#60;br /&#62;
transducer.steering_angle_max = 0;  % maximum steering angle [degrees]&#60;/p&#62;
&#60;p&#62;% apodization&#60;br /&#62;
transducer.transmit_apodization = 'Rectangular';&#60;br /&#62;
transducer.receive_apodization = 'Rectangular';&#60;br /&#62;
transducer.active_elements = ones(transducer.number_elements, 1);&#60;br /&#62;
transducer.input_signal = input_signal;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>AndresMM on "Particle acoustophoresis at &#34;larger&#34; scales using ultrasonic waves"</title>
			<link>http://www.k-wave.org/forum/topic/particle-acoustophoresis-at-larger-scales-using-ultrasonic-waves#post-5457</link>
			<pubDate>Fri, 08 Apr 2016 09:23:12 +0000</pubDate>
			<dc:creator>AndresMM</dc:creator>
			<guid isPermaLink="false">5457@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi everyone,&#60;/p&#62;
&#60;p&#62;I am trying to model the acoustophoretic effect of ultrasound excitation on a column of water containing a particle bed with sizes in the range of 20-90 micrometers. To do this I want to find the  pressure and speed time-averaged effects (P_rms and U_rms) and calculate the Gorkov potential, its gradient and obtain the acoustic radiation forces field. My idea is to afterwards couple this force field to an external CFD simulation and see how different sized particles will behave under different flow conditions. Something similar has already been done for microfluidic setups (&#60;a href=&#34;http://pubs.rsc.org/en/content/articlelanding/2012/lc/c2lc40733g#&#34; rel=&#34;nofollow&#34;&#62;http://pubs.rsc.org/en/content/articlelanding/2012/lc/c2lc40733g#&#60;/a&#62;!divAbstract) or (&#60;a href=&#34;http://pubs.rsc.org/en/content/articlelanding/2015/lc/c5lc00866b#&#34; rel=&#34;nofollow&#34;&#62;http://pubs.rsc.org/en/content/articlelanding/2015/lc/c5lc00866b#&#60;/a&#62;!divAbstract) (However they used a FEM simulation, COMSOL multi-physics).&#60;/p&#62;
&#60;p&#62;I want to use kwave for the steps of finding P_rms and U_rms for my geometry. However I have some doubts regarding the modeling of the particle bed. What I have done so far is create a porous bed on the bottom of the column. My 2D-mask looks like this &#60;a href=&#34;http://imgur.com/a/vpy1B&#34; rel=&#34;nofollow&#34;&#62;http://imgur.com/a/vpy1B&#60;/a&#62; , where the transducer is the top small line and is in direct contact with the main medium (water), the vertical lines are the tank walls (PMMA), and the bottom is a steel bottom (which acts as a  wave reflector).&#60;/p&#62;
&#60;p&#62;- How well can KWave manage such a &#34;complex&#34; geometry including holes and porosities?&#60;br /&#62;
- Am I right in believing that an elastic simulation is strictly necessary to find the resulting P_rms and U_rms of the geometry?&#60;br /&#62;
- Would you have any advice regarding the problem in general?&#60;/p&#62;
&#60;p&#62;Cheers,&#60;br /&#62;
Andrés
&#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>radel on "Piezoelectric propagation"</title>
			<link>http://www.k-wave.org/forum/topic/piezoelectric-propagation#post-5327</link>
			<pubDate>Thu, 26 Nov 2015 03:35:19 +0000</pubDate>
			<dc:creator>radel</dc:creator>
			<guid isPermaLink="false">5327@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Thanks Brad. For the time being I will work with the elastic models, approximating a piezoelectric material.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Piezoelectric propagation"</title>
			<link>http://www.k-wave.org/forum/topic/piezoelectric-propagation#post-5323</link>
			<pubDate>Tue, 24 Nov 2015 15:24:42 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">5323@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Radel,&#60;/p&#62;
&#60;p&#62;k-Wave can model the propagation of elastic waves within solid materials (using &#60;code&#62;pstdElastic2D&#60;/code&#62; and &#60;code&#62;pstdElastic3D&#60;/code&#62;). However, it doesn't include a model of piezoelectricity if that's what you are interested in simulating.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>radel on "Piezoelectric propagation"</title>
			<link>http://www.k-wave.org/forum/topic/piezoelectric-propagation#post-5318</link>
			<pubDate>Tue, 24 Nov 2015 03:23:56 +0000</pubDate>
			<dc:creator>radel</dc:creator>
			<guid isPermaLink="false">5318@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi All,&#60;/p&#62;
&#60;p&#62;Is it possible to simulate acoustic wave propagation in a piezoelectric material (anisotropic-Lithium niobate) using K-wave?&#60;/p&#62;
&#60;p&#62;Thanks in advance!&#60;/p&#62;
&#60;p&#62;Regards,&#60;br /&#62;
Radel
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Setting Incident Intensity of Acoustic Plane Wave"</title>
			<link>http://www.k-wave.org/forum/topic/setting-incident-intensity-of-acoustic-plane-wave#post-4568</link>
			<pubDate>Tue, 10 Jun 2014 11:12:40 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">4568@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Jon,&#60;/p&#62;
&#60;p&#62;The behaviour you see is expected - what you are seeing is the underlying behaviour of the so-called band-limited interpolant. This is what is actually propagated by the simulation (see section III in &#60;a href=&#34;http://www.k-wave.org/papers/2011-Treeby-JASA.pdf&#34;&#62;this paper&#60;/a&#62; or Sec. 2.8 in the k-Wave manual if you want some more explanation). &#60;/p&#62;
&#60;p&#62;You only see it for the high-intensity simulation because the default plot scale is [-1, 1], while your pressure magnitude is ~1e5. If you add &#60;code&#62;&#38;#39;PlotScale&#38;#39;, [-source_mag, source_mag]&#60;/code&#62; to your optional inputs, you should see the same display (in the linear case) irrespective of your chosen intensity.&#60;/p&#62;
&#60;p&#62;Hope that helps,&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jrosenfield on "Setting Incident Intensity of Acoustic Plane Wave"</title>
			<link>http://www.k-wave.org/forum/topic/setting-incident-intensity-of-acoustic-plane-wave#post-4565</link>
			<pubDate>Mon, 09 Jun 2014 19:37:38 +0000</pubDate>
			<dc:creator>jrosenfield</dc:creator>
			<guid isPermaLink="false">4565@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Brad,&#60;/p&#62;
&#60;p&#62;You probably recall that you were helping me some time ago to simulate monochromatic plane waves propagating through simple phantoms. I would like to set my time-averaged incident intensity to be 1 W/cm^2 (1e4 W/m^2) in my current simulation. I am including the code for your reference. When I set the incident intensity to be very low (1e-4 W/m^2), the simulation visually appears to run correctly. However, if I set the incident intensity to be the desired 1e4 W/m^2, the simulation does not seem to run correctly. In particular, the movie of the 2D simulation appears to show that the pressure field propagates the entire length of the phantom in one time step, and drastic changes in pressure can be observed. You only have to look at the first few time steps to see this. Could you please run the attached code and let me know what might be causing the apparent instability in the higher-intensity simulation?&#60;/p&#62;
&#60;p&#62;Thanks for your help.&#60;/p&#62;
&#60;p&#62;Sincerely,&#60;/p&#62;
&#60;p&#62;Jon&#60;/p&#62;
&#60;p&#62;function planewave(distance)&#60;/p&#62;
&#60;p&#62;% distance defines lesion-to-detector distance (cm)&#60;/p&#62;
&#60;p&#62;dx = 1e-4; % grid point spacing in the x direction [meters]&#60;br /&#62;
dy = 1e-4; % grid point spacing in the y direction [meters]&#60;br /&#62;
Nx = 587; % number of pixels in x-direction&#60;br /&#62;
Ny = 500; % number of pixels in y-direction&#60;br /&#62;
kgrid = makeGrid(Nx, dx, Ny, dy); % make computational grid&#60;br /&#62;
middle = 294;&#60;br /&#62;
x0 = middle;&#60;br /&#62;
frequency = 3.81;&#60;/p&#62;
&#60;p&#62;% define properties of the lesion&#60;br /&#62;
y0 = round(500 - (distance*(1/100)*(1/dy)));&#60;br /&#62;
medium.sound_speed = 1550*makeDisc(Nx,Ny,x0,y0,6); % [m/s]&#60;br /&#62;
medium.density = 1040*makeDisc(Nx,Ny,x0,y0,6); % [kg/m^3]&#60;br /&#62;
medium.alpha_coeff = .570*(frequency^1.3)*makeDisc(Nx,Ny,x0,y0,6); % [dB/(MHz^y*cm)]&#60;br /&#62;
medium.alpha_power = 0; % value of power y&#60;br /&#62;
lesionmask = makeDisc(Nx,Ny,x0,y0,6);&#60;/p&#62;
&#60;p&#62;medium.sound_speed(medium.sound_speed==0) = 1550;&#60;br /&#62;
medium.density(medium.density==0) = 1015;&#60;br /&#62;
medium.alpha_coeff(medium.alpha_coeff==0) = ((0.25*0.158*(frequency^1.7))...&#60;br /&#62;
    + (0.75*0.870*(frequency^1.5)));&#60;br /&#62;
medium.alpha_power = 0; % value of power y&#60;/p&#62;
&#60;p&#62;% define sensor&#60;br /&#62;
sensor.mask = zeros(Nx,Ny);&#60;br /&#62;
sensor.mask(:,500) = 1;&#60;br /&#62;
sensor.record = {'p'};&#60;/p&#62;
&#60;p&#62;%define source&#60;br /&#62;
source.p_mask = zeros(Nx,Ny);&#60;br /&#62;
source.p_mask(:,1) = 1;&#60;br /&#62;
source_intensity = 1e-4; % [W/m^2]&#60;br /&#62;
rho0 = 1015; % [kg/m^3]&#60;br /&#62;
c0 = 1550; % [m/s]&#60;br /&#62;
source_mag = sqrt(2*source_intensity*rho0*c0); % [Pa]&#60;br /&#62;
source_freq = frequency*(1e6); % [Hz]&#60;/p&#62;
&#60;p&#62;% calculate the time length of one acoustic period&#60;br /&#62;
T = 1/source_freq;&#60;/p&#62;
&#60;p&#62;% create the time array using a nice number of points&#60;br /&#62;
points_per_period = 10;&#60;br /&#62;
dt = T/points_per_period;&#60;br /&#62;
t_end = (10/source_freq) + (3.4e-5);&#60;br /&#62;
kgrid.t_array = 0:dt:t_end;&#60;/p&#62;
&#60;p&#62;% define a time varying sinusoidal source&#60;/p&#62;
&#60;p&#62;source.p = source_mag*sin(2*pi*source_freq.*kgrid.t_array);&#60;/p&#62;
&#60;p&#62;% smooth startup using a cosine ramp&#60;br /&#62;
ramp_length = 40;&#60;br /&#62;
ramp = (-cos((0:(ramp_length-1))*pi/ramp_length ) + 1)/2;&#60;br /&#62;
source.p(1:length(ramp)) = source.p(1:length(ramp)) .* ramp;&#60;/p&#62;
&#60;p&#62;source.p = filterTimeSeries(kgrid, medium, source.p, 'PlotSpectrums', false, 'PPW', 2);&#60;/p&#62;
&#60;p&#62;num_cycles = 1;&#60;br /&#62;
sensor.record_start_index = kgrid.Nt - round(num_cycles * T / dt) + 1;&#60;/p&#62;
&#60;p&#62;medium.sound_speed = smooth(kgrid, medium.sound_speed, true);&#60;br /&#62;
medium.density = smooth(kgrid, medium.density, true);&#60;/p&#62;
&#60;p&#62;input_args = {'DisplayMask', (source.p_mask + sensor.mask + lesionmask), 'DataCast', 'single', 'PMLSize', [0, 20], 'PMLAlpha', [0, 2], 'PMLInside', false};&#60;/p&#62;
&#60;p&#62;sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});&#60;/p&#62;
&#60;p&#62;pressure = sensor_data.p;&#60;br /&#62;
pressure = pressure.^2;&#60;br /&#62;
pressure = transpose(pressure);&#60;br /&#62;
pressure = mean(pressure);&#60;br /&#62;
Iavg = pressure./(rho0*c0);&#60;br /&#62;
xaxis = -293*0.1:0.1:293*0.1;&#60;br /&#62;
plot(xaxis, Iavg)&#60;br /&#62;
xlabel('Lateral Position (mm)')&#60;br /&#62;
ylabel('Acoustic Intensity (W/m^2)')&#60;br /&#62;
hold on&#60;br /&#62;
end
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
