<?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: Strange behavior with source.u_mask and dirichlet boundary conditions</title>
		<link>http://www.k-wave.org/forum/topic/strange-behavior-with-sourceu_mask-and-dirichlet-boundary-conditions</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Tue, 12 May 2026 23:07:58 +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/strange-behavior-with-sourceu_mask-and-dirichlet-boundary-conditions" rel="self" type="application/rss+xml" />

		<item>
			<title>Bradley Treeby on "Strange behavior with source.u_mask and dirichlet boundary conditions"</title>
			<link>http://www.k-wave.org/forum/topic/strange-behavior-with-sourceu_mask-and-dirichlet-boundary-conditions#post-6624</link>
			<pubDate>Tue, 30 Oct 2018 20:26:10 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">6624@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi NikiKeyz,&#60;/p&#62;
&#60;p&#62;Thanks for posting your solution. Using separate masks was something we considered when first writing k-Wave, but in the end we thought the sources would always be used at the same time. You're actually the first person to ask for it. In principle, it's easy to implement, but every option has to be rolled out across the code base and maintained, etc. We'll add it to the development list for discussion.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>NikiKeyz on "Strange behavior with source.u_mask and dirichlet boundary conditions"</title>
			<link>http://www.k-wave.org/forum/topic/strange-behavior-with-sourceu_mask-and-dirichlet-boundary-conditions#post-6619</link>
			<pubDate>Mon, 29 Oct 2018 13:27:34 +0000</pubDate>
			<dc:creator>NikiKeyz</dc:creator>
			<guid isPermaLink="false">6619@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;I managed to modify K-Wave source code to use independent ux_mask and uy_mask. It seems to work as desired now.&#60;br /&#62;
This way time step can be significantly increased opposed to use of &#34;real&#34; density/speed. And simulation runs more than 10 times faster on my configuration this way.&#60;br /&#62;
Would be nice to have this feature in future K-Wave releases. Especially for 3D C++/CUDA. Thanks!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>NikiKeyz on "Strange behavior with source.u_mask and dirichlet boundary conditions"</title>
			<link>http://www.k-wave.org/forum/topic/strange-behavior-with-sourceu_mask-and-dirichlet-boundary-conditions#post-6603</link>
			<pubDate>Tue, 23 Oct 2018 18:30:46 +0000</pubDate>
			<dc:creator>NikiKeyz</dc:creator>
			<guid isPermaLink="false">6603@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Well, ok these are not bugs, sorry.&#60;/p&#62;
&#60;p&#62;1) source.ux and source.uy must be defined for every time step:&#60;br /&#62;
&#60;code&#62;source.ux(1:nnz(source.u_mask),1:kgrid.Nt)=zeros(kgrid.Nt);&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;2) Since u_mask is one for both ux and uy we can't set only ux to zero and leave uy without boundary condition at some grid points. That's why bottom and right sides scatter as intended and left and top sides give artifacts. Is there any way to overcome this?&#60;/p&#62;
&#60;p&#62;Thanks!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>NikiKeyz on "Strange behavior with source.u_mask and dirichlet boundary conditions"</title>
			<link>http://www.k-wave.org/forum/topic/strange-behavior-with-sourceu_mask-and-dirichlet-boundary-conditions#post-6602</link>
			<pubDate>Tue, 23 Oct 2018 17:42:54 +0000</pubDate>
			<dc:creator>NikiKeyz</dc:creator>
			<guid isPermaLink="false">6602@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi!&#60;br /&#62;
I am trying to model acoustic scattering in air from rigid surface. I've tried couple of methods before with small luck. I tried to set almost 0 sound speed for scattering surface which was fine and fast but there was significant phase shift. Second approach was to use density, sound speed and alpha coeff of real material. Works nice, but this way time step have to be quite small to avoid &#34;explosion&#34;. And while I need to make thousands of evaluations this scheme is too slow.&#60;/p&#62;
&#60;p&#62;Finally I discovered idea to set dirichlet conditions for velocity to 0. This scheme works fast and seems to give realistic enough scattering with correct phase.&#60;br /&#62;
But after some tests I discovered 2 strange things:&#60;br /&#62;
1) After some simulation time passes dirichlet conditions go away and waves just propagate from that moment as if u_mask was zero matrix.&#60;br /&#62;
2) Some strange vibrations occur on the left side of scattering surface. Strange thing that this effect is not symmetrical as there is nothing like that on the right side of the sample.&#60;/p&#62;
&#60;p&#62;Here is my code:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;% create the computational grid
Nx = 160;           % number of grid points in the x (row) direction
Ny = 160;           % number of grid points in the y (column) direction
dx = 0.025;        % grid point spacing in the x direction [m]
dy = 0.025;        % grid point spacing in the y direction [m]
kgrid = makeGrid(Nx, dx, Ny, dy);

% define the properties of the propagation medium
medium.sound_speed = 345*ones(Nx,Ny); 	% [m/s] Air
medium.alpha_coeff = 1.1795*ones(Nx,Ny);  % [dB/(MHz^y cm)]
medium.alpha_power = 1.4484; %Air (?)
medium.density = 1.1864; %kg/m3 Air
PML_x=20;
PML_y=20;

% create the time array
dt = 1.5e-5;
total_time = 0.05;
kgrid.t_array = 0:dt:total_time;

% define source point(s)
source.p_mask = zeros(Nx, Ny);
source.p_mask(Nx/2,Ny/2) = 1;

% define Ricker source
fcent = 1500;
t0 = 0.002;
source_amp = 0.18e-2;
source.p = source_amp*-sqrt(2)*pi*fcent*((sqrt(2)*pi*fcent*(kgrid.t_array-t0)).^2 - 1) ...
    .*exp(-0.5*(sqrt(2)*pi*fcent*(kgrid.t_array-t0)).^2);

% Filter
source_notfiltered = source.p;
medium_filter.sound_speed=345;
source.p = filterTimeSeries(kgrid, medium_filter, source.p);

source.u_mask = zeros(Nx, Ny);
source.u_mode=&#38;#39;dirichlet&#38;#39;;
source.u_mask(PML_x+1:PML_x+8,PML_y+1:Ny-PML_y-1)=1;
source.ux(1:nnz(source.u_mask))=0;
source.uy(1:nnz(source.u_mask))=0;

sensor.mask = [0;0];
sensor.record = {&#38;#39;p_rms&#38;#39;};

sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, &#38;#39;DataCast&#38;#39;, &#38;#39;gpuArray-single&#38;#39;, ...
            &#38;#39;PlotScale&#38;#39;, [-0.1, 0.1], &#38;#39;PlotSim&#38;#39;, true, &#38;#39;DataRecast&#38;#39;, true, &#38;#39;LogScale&#38;#39;, true, &#38;#39;PMLSize&#38;#39;,[PML_x,PML_y]);&#60;/code&#62;&#60;/pre&#62;</description>
		</item>

	</channel>
</rss>
