<?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: xiufeng</title>
		<link><a href='http://www.k-wave.org/forum/profile/xiufeng'>xiufeng</a></link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 01:53:13 +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>bencox on "Comparison of source.p and source.p0"</title>
			<link>http://www.k-wave.org/forum/topic/comparison-of-sourcep-and-sourcep0#post-8411</link>
			<pubDate>Thu, 06 Jan 2022 17:17:40 +0000</pubDate>
			<dc:creator>bencox</dc:creator>
			<guid isPermaLink="false">8411@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi xiufeng, &#60;/p&#62;
&#60;p&#62;Time-varying simulations require a scaling factor which is set to be accurate for long duration pulses. Have a look here:&#60;br /&#62;
&#60;a href=&#34;http://www.k-wave.org/forum/topic/using-sourcep-to-specify-pressure-distribution#post-4181&#34;&#62;http://www.k-wave.org/forum/topic/using-sourcep-to-specify-pressure-distribution#post-4181&#60;/a&#62; and here &#60;a href=&#34;http://www.k-wave.org/forum/topic/what-the-soucep-mean#post-7224&#34;&#62;http://www.k-wave.org/forum/topic/what-the-soucep-mean#post-7224&#60;/a&#62;.&#60;/p&#62;
&#60;p&#62;Simulations using an initial pressure distribution don't have a scaling factor.&#60;/p&#62;
&#60;p&#62;Hope that helps.&#60;br /&#62;
Ben
&#60;/p&#62;</description>
		</item>
		<item>
			<title>xiufeng on "Comparison of source.p and source.p0"</title>
			<link>http://www.k-wave.org/forum/topic/comparison-of-sourcep-and-sourcep0#post-8322</link>
			<pubDate>Thu, 30 Sep 2021 17:49:33 +0000</pubDate>
			<dc:creator>xiufeng</dc:creator>
			<guid isPermaLink="false">8322@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Here's my code:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;% Monopole Point Source In A Homogeneous Propagation Medium Example
%
% This example provides a simple demonstration of using k-Wave for the
% simulation and detection of a time varying pressure source within a
% two-dimensional homogeneous propagation medium.  It builds on the
% Homogeneous Propagation Medium and Recording The Particle Velocity
% examples.
%
% author: Bradley Treeby
% date: 2nd December 2009
% last update: 4th May 2017
%
% 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;)
% Copyright (C) 2009-2017 Bradley Treeby

% This file is part of k-Wave. k-Wave is free software: you can
% redistribute it and/or modify it under the terms of the GNU Lesser
% General Public License as published by the Free Software Foundation,
% either version 3 of the License, or (at your option) any later version.
%
% k-Wave is distributed in the hope that it will be useful, but WITHOUT ANY
% WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
% FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
% more details.
%
% You should have received a copy of the GNU Lesser General Public License
% along with k-Wave. If not, see &#38;lt;http://www.gnu.org/licenses/&#38;gt;. 

clearvars;

% =========================================================================
% SIMULATION
% =========================================================================

% create the computational grid
Nx = 64;           % number of grid points in the x (row) direction
Ny = 64;           % number of grid points in the y (column) direction
Nz = 64;
dx0 = 50e-3/Nx/2;    	% grid point spacing in the x direction [m]
dx = dx0/1.2;
dy = dx;            % grid point spacing in the y direction [m]
dz=dx;
kgrid = kWaveGrid(Nx, dx, Ny, dy,Nz,dz);

% define the properties of the propagation medium
medium.sound_speed = 1500;  % [m/s]
%  medium.alpha_coeff = 0.75;  % [dB/(MHz^y cm)]
%  medium.alpha_power = 1.5;

% create the time array
%kgrid.makeTime(medium.sound_speed);
kgrid.setTime(400,40e-9/0.6);
% define a single source point
filter_lim=1e-3;%small values will be assigned to be 0, or, no source.
spatial_grid = zeros(Nx,Ny,Nz);
spatial_grid(Nx/2, Ny/2, Nz/4) = 1;
%Although a point source is more illustative, it will be hard to define it
%in simulation, so we first smooth it twice to get rid of small holes and ignore small values.
 %spatial_smooth = spatial_grid;
spatial_smooth = smooth(spatial_grid,true);%values range from 0 to 1
spatial_smooth(spatial_smooth&#38;lt;filter_lim)=0;
spatial_smooth = smooth(spatial_smooth,true);%values range from 0 to 1
spatial_smooth(spatial_smooth&#38;lt;filter_lim)=0;

spatial_bin=spatial_smooth;
spatial_bin(spatial_smooth&#38;gt;=filter_lim)=1;%only a binary mask is needed for time varying source.
% spatial_bin = spatial_grid;
source.p_mask = spatial_bin;

% define a time varying sinusoidal source
source_freq = 0.5e6;   % [Hz]
source_mag = 2;         % [Pa]
f0=source_freq;%center frequency
T0=1/f0;
w0 = 2*pi*f0;
alp = 1/(1*pi*T0);%atenuation coefficient, the width will be 4T0
t0 = 1*T0;%the position of the signal
t = kgrid.t_array;
%wt = cos(w0*(t-t0)) .* exp(-(pi*alp*(t-t0)).^2);
wt = toneBurst(1/kgrid.dt,f0,3,&#38;#39;SignalLength&#38;#39;,kgrid.Nt);
% filter the source to remove high frequencies not supported by the grid
wt = wt ./max(wt);
wt = filterTimeSeries(kgrid, medium, wt,&#38;#39;PlotSignals&#38;#39;,true,&#38;#39;ZeroPhase&#38;#39;,false);
source.p = source_mag * spatial_smooth(source.p_mask&#38;gt;0.5) * wt;%only none-zero point will be assigned a pressure

%source.p = source_mag * sin(2 * pi * source_freq * kgrid.t_array);
% define a single sensor point
sensor.mask = zeros(Nx, Ny,Nz);
sensor.mask(Nx/2, Ny/2,end-Nz/4-20) = 1;

% define the acoustic parameters to record
sensor.record = {&#38;#39;p&#38;#39;, &#38;#39;p_final&#38;#39;};

% run the simulation
sensor_data_tv = kspaceFirstOrder3D(kgrid, medium, source, sensor,&#38;#39;Smooth&#38;#39;,false,&#38;#39;PMLAlpha&#38;#39;, 2);

%%
Nt = kgrid.Nt;
%*kgrid.dt /(kgrid.dx/2/medium.sound_speed)
source.p0 = source_mag* spatial_smooth;
source = rmfield(source, &#38;#39;p&#38;#39;);
source = rmfield(source, &#38;#39;p_mask&#38;#39;);
%&#38;#39;Smooth&#38;#39; should be disabled, otherwise a point source would be spread in
%space
sensor_data_p0 = kspaceFirstOrder3D(kgrid, medium, source, sensor,&#38;#39;Smooth&#38;#39;,false,&#38;#39;PMLAlpha&#38;#39;, 2);
%sensor_data_p0 = kspaceSecondOrder(kgrid, medium, source, sensor,&#38;#39;Smooth&#38;#39;,false,&#38;#39;ExpandGrid&#38;#39;, true);
sensor_data_p0.p = sensor_data_p0.p;
wt_F = fft(wt);
sensor_data_p0_F = fft(sensor_data_p0.p);

sensor_data_p0_FF = sensor_data_p0_F.* wt_F;
sensor_data_p0_ff = real(ifft(sensor_data_p0_FF));

ratio = max(sensor_data_tv.p)./max(sensor_data_p0_ff);
fprintf(&#38;#39;The ratio of convolution to direct solver is:\t %.3f \n&#38;#39;,ratio);
fprintf(&#38;#39;The correction factor dt /(dx/2/c0) is: \t\t%.3f\n&#38;#39;,kgrid.dt /(kgrid.dx/2/medium.sound_speed));
%%

% =========================================================================
% VISUALISATION
% =========================================================================

%% plot the simulated sensor data
close all;
figure()

Fs = 1/kgrid.dt;
f=Fs/kgrid.Nt * (0:Nt/2)*1e-6;
subplot(411);
title(&#38;#39;Frequency response&#38;#39;);
plot(f, abs(wt_F(1:Nt/2+1)));
xlim([0,10]);
legend(&#38;#39;FFT of input time profile&#38;#39;)
subplot(412);
plot(f, abs(sensor_data_p0_F(1:Nt/2+1)));
xlim([0,10]);
legend(&#38;#39;Delta source response&#38;#39;)
subplot(413);
plot(f, abs(sensor_data_p0_FF(1:Nt/2+1)));
xlim([0,10]);
legend(&#38;#39;Multiplication response&#38;#39;)
subplot(414);
VF = fft(sensor_data_tv.p);
plot(f,abs(VF(1:Nt/2+1)));
xlim([0,10]);
legend(&#38;#39;Time varying source&#38;#39;)
xlabel(&#38;#39;Frequency [MHz]&#38;#39;);

figure;
[t_sc, scale, prefix] = scaleSI(max(kgrid.t_array(:))); 

 subplot(411);
 title(&#38;#39;time response&#38;#39;)
 plot(kgrid.t_array*scale,wt);legend(&#38;#39;Time profile of input pressure&#38;#39;)
 xlim([0 12]);
 subplot(412)
 plot(kgrid.t_array*scale, sensor_data_p0.p);legend(&#38;#39;Delta source response&#38;#39;);
  xlim([0 12]);
 subplot(413)
plot(kgrid.t_array*scale, sensor_data_p0_ff,&#38;#39;b-&#38;#39;);legend(&#38;#39;Multiplication response&#38;#39;)
 xlim([0 12]);
 subplot(414)
plot(kgrid.t_array * scale, sensor_data_tv.p);legend(&#38;#39;Time varying source&#38;#39;);
 xlim([0 12]);
xlabel([&#38;#39;Time [&#38;#39; prefix &#38;#39;s]&#38;#39;]);
ylabel(&#38;#39;Signal Amplitude&#38;#39;);&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>xiufeng on "Comparison of source.p and source.p0"</title>
			<link>http://www.k-wave.org/forum/topic/comparison-of-sourcep-and-sourcep0#post-8321</link>
			<pubDate>Thu, 30 Sep 2021 17:45:07 +0000</pubDate>
			<dc:creator>xiufeng</dc:creator>
			<guid isPermaLink="false">8321@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Bradley and Ben,&#60;/p&#62;
&#60;p&#62;I have such a question: I have a temporal-spatial varying source, which is actually a heating problem, and I want to get the pressure at the receiver side.&#60;/p&#62;
&#60;p&#62;I compared the results of the following:&#60;br /&#62;
First, I use kspaceFirstOrder3D by setting source.p=p(x,t) (I can get p(x,t) from the conversion of heat injection), to get the pressure at a receiving point p1(x,t);&#60;/p&#62;
&#60;p&#62;Secondly, I think I can solve the initial-value problem and convolve the result with the time curve of the source. So I separate the source into two parts: p(x,t)=p(x)s(t)=p(x)delta(t)*s(t)(*is temporal convolution). s(t) is only a time function applied to every spatial point.&#60;br /&#62;
So the pressure p0(x,t) due to p(x)delta(t) can be obtained by setting source.p0=p(x). And the final pressure p2(x,t)=p0(x,t)*s(t).&#60;/p&#62;
&#60;p&#62;I thought p2(x,t)==p1(x,t). However, I got p2(x,t)= 2dt/dx/c0*p1(x,t)(* is multiplication). They are not equal!&#60;/p&#62;
&#60;p&#62;Q1: So I don’t know which method I can trust to get the real pressure. How do you think of my calculation? &#60;/p&#62;
&#60;p&#62;Q2: What are the source terms (Sm in eq.2.9 in the manual) when giving source.p and source.p0? I know eq.2.19 and I also read &#60;a href=&#34;http://www.k-wave.org/forum/topic/using-sourcep-to-specify-pressure-distribution&#34; rel=&#34;nofollow&#34;&#62;http://www.k-wave.org/forum/topic/using-sourcep-to-specify-pressure-distribution&#60;/a&#62; , &#60;a href=&#34;http://www.k-wave.org/forum/topic/sourcep&#34; rel=&#34;nofollow&#34;&#62;http://www.k-wave.org/forum/topic/sourcep&#60;/a&#62; , and  &#60;a href=&#34;http://www.k-wave.org/forum/topic/thermoacoustic-simulation#post-44&#34; rel=&#34;nofollow&#34;&#62;http://www.k-wave.org/forum/topic/thermoacoustic-simulation#post-44&#60;/a&#62;, they give very useful information, but it seems not to lead to the above results. For the case source.p0[Pa], I think Sm=p0/c0^2*delta(t) [kg/m^3/s],in which delta is here to give the time term, and for the case source.p [Pa], Sm=2*dt/c0/dx*p [kg/m^3 !!]. The unit of Sm should be kg/m^3/s, unless source.p has the unit Pa/s.&#60;/p&#62;
&#60;p&#62;It worried me for two weeks now. I would be very happy to see your answers.&#60;/p&#62;
&#60;p&#62;Thank you very much.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
