<?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: Simulating plane wave ultrasound propagation through homogeneous medium (water)</title>
		<link>http://www.k-wave.org/forum/topic/simulating-plane-wave-ultrasound-propagation-through-homogeneous-medium-water</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 02:33:56 +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/simulating-plane-wave-ultrasound-propagation-through-homogeneous-medium-water" rel="self" type="application/rss+xml" />

		<item>
			<title>Bradley Treeby on "Simulating plane wave ultrasound propagation through homogeneous medium (water)"</title>
			<link>http://www.k-wave.org/forum/topic/simulating-plane-wave-ultrasound-propagation-through-homogeneous-medium-water#post-6229</link>
			<pubDate>Tue, 12 Dec 2017 22:12:47 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">6229@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi maktjik,&#60;/p&#62;
&#60;p&#62;It seems that the &#60;code&#62;&#38;#39;PlotLayout&#38;#39;&#60;/code&#62; option doesn't work when the plotted components of the matrices are homogeneous (contain a single value). I will look into fixing this for an upcoming release.&#60;/p&#62;
&#60;p&#62;Kind regards,&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>maktjik on "Simulating plane wave ultrasound propagation through homogeneous medium (water)"</title>
			<link>http://www.k-wave.org/forum/topic/simulating-plane-wave-ultrasound-propagation-through-homogeneous-medium-water#post-6191</link>
			<pubDate>Tue, 07 Nov 2017 05:02:01 +0000</pubDate>
			<dc:creator>maktjik</dc:creator>
			<guid isPermaLink="false">6191@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Dear Dr. Treeby and Dr. Cox,&#60;/p&#62;
&#60;p&#62;Like, my previous question in:&#60;br /&#62;
&#60;a href=&#34;http://www.k-wave.org/forum/topic/understanding-speed-of-sound-of-the-medium#post-6190&#34; rel=&#34;nofollow&#34;&#62;http://www.k-wave.org/forum/topic/understanding-speed-of-sound-of-the-medium#post-6190&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;For the 2nd case, I want to simulate plane wave ultrasound (128 elements array) propagation through homogeneous medium (water)that I generate by integrating 2D images (see the 2nd section of my code and the link for the image source).&#60;/p&#62;
&#60;p&#62;For this simulation, I got an error that said:&#60;br /&#62;
Error using matlab.graphics.axis.Axes/set&#60;/p&#62;
&#60;p&#62;and a warning: MATLAB has disabled some advanced graphics rendering featuresby switching to software openGL.&#60;/p&#62;
&#60;p&#62;By the way, I use MATLAB 2016a version.&#60;/p&#62;
&#60;p&#62;Thank you.&#60;/p&#62;
&#60;p&#62;Here is my code:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;% =========================================================================
% ULTRASOUND SIMULATION
% Linear array transducer (128 element)
% Transmit: Planewave, 128 active elements
% Receive : 128 active elements
% Medium  : water (256 x 512 x 256)
% =========================================================================

clear all;

%simulation setting
data_cast = &#38;#39;single&#38;#39;;

% run the simulation
% true  : run the simulation
% false : load previous results from disk
run_simulation = true;

% =========================================================================
% DEFINE THE K-WAVE GRID
% =========================================================================

% set the size of the perfectly matched layer (PML)
PML_X_SIZE = 10;            % [grid points]
PML_Y_SIZE = 10;            % [grid points]
PML_Z_SIZE = 10;            % [grid points]

% set total number of grid points not including the PML
Nx = 256 - 2*PML_X_SIZE;   % [grid points]
Ny = 512 - 2*PML_Y_SIZE;   % [grid points]
Nz = 256 - 2*PML_Z_SIZE;   % [grid points]

% set desired grid size in the x-direction not including the PML
x = 38e-3;                  % [m]
y = 50e-3;                  % [m]
z = 38e-3;                  % [m]

% calculate the spacing between the grid points
dx = z/Nz;                % [m]
dy = dx;                  % [m]
dz = dx;                  % [m]

% create the k-space grid
kgrid = makeGrid(Nx, dx, Ny, dy, Nz, dz);

% =========================================================================
% DEFINE THE MEDIUM PARAMETERS
% =========================================================================

c0 = 1498;                    % c in water [m/s]
rho0 = 1000;                  % density of water [kg/m^3]

% create the time array
t_end = (Nx*dx)*2.2/c0;                % [s]
kgrid.t_array = makeTime(kgrid, c0, [], t_end);

% =========================================================================
% DEFINE THE INPUT SIGNAL
% =========================================================================

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

% create the input signal using toneBurst
input_signal = toneBurst(1/kgrid.dt, tone_burst_freq, tone_burst_cycles);

% 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*rho0)).*input_signal;

% =========================================================================
% DEFINE THE ULTRASOUND TRANSDUCER [SOURCE AND SENSOR]
% =========================================================================

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

% calculate the width of the transducer in grid points
transducer_width = transducer.number_elements*transducer.element_width ...
    + (transducer.number_elements - 1)*transducer.element_spacing;

% use this to position the transducer in the middle of the computational grid
transducer.position = round([1, Ny/2 - transducer_width/2, Nz/2 - transducer.element_length/2]);

transducer.sound_speed = c0;               % sound speed [m/s]
transducer.elevation_focus_distance = 16e-3;  % focus distance in the elevation plane [m]

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

% define the transducer elements that are currently active
number_active_elements = 128;
transducer.active_elements = ones(transducer.number_elements, 1);

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

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

% print out transducer properties
transducer.properties;

% =========================================================================
% DEFINE THE MEDIUM PROPERTIES
% =========================================================================

% define a random distribution of scatterers for the medium
background_map_mean = 1;
background_map_std = 0.008;

% % define the properties of the propagation medium
load c_water_171106;
medium.sound_speed = c_water_171106;      % [m/s]

load rho_water_171106;
medium.density = rho_water_171106;        % [kg/m^3]

% =========================================================================
% RUN THE SIMULATION
% =========================================================================

% set the input settings
% plot medium map
input_args = {...
    &#38;#39;PlotLayout&#38;#39;, true, &#38;#39;PMLInside&#38;#39;, false, &#38;#39;PlotSim&#38;#39;, false, &#38;#39;PMLSize&#38;#39;, [PML_X_SIZE, PML_Y_SIZE, PML_Z_SIZE], ...
    &#38;#39;DataCast&#38;#39;, data_cast};

% run the simulation if set to true, otherwise, load previous results from disk
if run_simulation

   RF_data_PW_water_171107 = kspaceFirstOrder3D(kgrid, medium, transducer, transducer, input_args{:});

   % save the scan lines to disk
   save RF_data_PW_water_171107 RF_data_PW_water_171107;
else
%    % load the scan lines from disk
   load RF_data_PW_water_171107
end&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;=============================================================&#60;/p&#62;
&#60;p&#62;and this is the code for creating the medium:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;clear all
close all

[data]=imread(&#38;#39;water_2D.bmp&#38;#39;);
data_bw=double(data(:,:,1));

[xx,yy]=size(data_bw);
clear data

for i=1:xx
    for j=1:yy
        if data_bw(i,j)==1
            c(i,j)=1498;       % average c  of the medium (phantom and water) [m/s]
            rho(i,j)=1000;     % average density  of the medium (phantom and water) [kg/m^3]
        elseif data_bw(i,j)==0
            c(i,j)=1498;       % c in water [m/s]
            rho(i,j)=1000;     % density of water [kg/m^3]
        end;
    end;
end;

cit_3d=zeros(xx,yy,492);

for i=1:492
    c_3d(:,:,i)=c;
    rho_3d(:,:,i)=rho;
end;

n=zeros(236,492,236);
m=zeros(236,492,236);

[x,y,z]=size(n);

for i=1:x
    for j=1:y
        for k=1:z
            c_water_171106(i,j,k)=c_3d(i,k,j);
            rho_water_171106(i,j,k)=rho_3d(i,k,j);
        end
    end
end

save c_water_171106  c_water_171106
save rho_water_171106  rho_water_171106&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;==========================================================&#60;br /&#62;
and here is the image:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://drive.google.com/file/d/1may-MoszFDxJgkQpyW6mjoD57Rs9LJJ0/view?usp=sharing&#34; rel=&#34;nofollow&#34;&#62;https://drive.google.com/file/d/1may-MoszFDxJgkQpyW6mjoD57Rs9LJJ0/view?usp=sharing&#60;/a&#62;
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
