<?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: Dirichlet condition doesnt work as expected</title>
		<link>http://www.k-wave.org/forum/topic/dirichlet-condition-doesnt-work-as-expected</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 05:18:52 +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/dirichlet-condition-doesnt-work-as-expected" rel="self" type="application/rss+xml" />

		<item>
			<title>Bradley Treeby on "Dirichlet condition doesnt work as expected"</title>
			<link>http://www.k-wave.org/forum/topic/dirichlet-condition-doesnt-work-as-expected#post-7212</link>
			<pubDate>Tue, 11 Feb 2020 12:00:44 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">7212@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi grabka,&#60;/p&#62;
&#60;p&#62;I haven't quite managed to get to the bottom of your problem yet. First, I don't think you're plotting the same point. So I changed &#60;code&#62;sensor.mask = source.u_mask;&#60;/code&#62; and then plotted&#60;/p&#62;
&#60;p&#62;&#60;code&#62;plot(kgrid.t_array, sensor_data.uz(1,:), kgrid.t_array, source.uz(1,:))&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;If you set the shear sound speed to zero, everything works as expected. However, when the shear speed is non-zero, the input and output don't agree. I'll keep digging and come back to you. &#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>grabka on "Dirichlet condition doesnt work as expected"</title>
			<link>http://www.k-wave.org/forum/topic/dirichlet-condition-doesnt-work-as-expected#post-7133</link>
			<pubDate>Thu, 21 Nov 2019 23:31:11 +0000</pubDate>
			<dc:creator>grabka</dc:creator>
			<guid isPermaLink="false">7133@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hello.&#60;br /&#62;
I have set up a simulation with homogeneous viscoelastic material and excite by a Velocity Gauss impulse in the middle. I have noticed that the velocities at the source positions are not equal to the defined ones, although I have defined dirichlet conditions.  Why is that?&#60;/p&#62;
&#60;p&#62;In the manual it states: ‘dirichlet’: at each time step, the input pressure and velocity values are used to replace the existing values&#60;/p&#62;
&#60;p&#62;Here my code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;%% variables
f_max = 300; %[Hz]
%%  create the computational grid
spacing = 5e-3;
x_size = 0.15;            %[m] total size x-direction
y_size = 0.15;            %[m] total size y-direction
z_size = 0.014;           %[m] total size z-direction
dx = spacing;             % grid point spacing in the x direction [m]
dy = spacing;             % grid point spacing in the y direction [m]
dz = spacing;             % grid point spacing in the z direction [m]
Nx = ceil(x_size/dx)+2;   % number of grid points in the x direction
Ny = ceil(y_size/dy)+2;   % number of grid points in the y direction
Nz = ceil(z_size/dz)+2    % number of grid points in the z direction
disp(&#38;#39;Number of grid points: &#38;#39;); disp(Nx*Ny*Nz);
kgrid = kWaveGrid(Nx, dx, Ny, dy, Nz, dz);
%% simulation time and step size
dt = 0.1 * spacing / 1440.3;    % CFL*dx/c_max CFL 0.3 default
t_end = 0.5/300;                % [s]
kgrid.t_array = 0:dt:t_end;
%% define the properties of the propagation medium
medium.sound_speed_compression = ones(Nx,Ny,Nz) * 1440.3;    % [m/s]
medium.sound_speed_shear = ones(Nx,Ny,Nz) * 201.74;          % [m/s]
medium.alpha_coeff_compression = ones(Nx,Ny,Nz) * 0.5;       % [10–3 m–1]
medium.alpha_coeff_shear = ones(Nx,Ny,Nz) * 0.5;             % [10–3 m–1]
medium.density = ones(Nx,Ny,Nz) * 923.47;                    % [kg/m^3]
%% define the source
% define a square source element
source_radius = 0.005/dx;  % [grid points]
source.u_mask = zeros(Nx,Ny,Nz);
source.u_mask(Nx/2 - source_radius:Nx/2 + source_radius, Ny/2 - source_radius:Ny/2 + source_radius, Nz) = 1;
nbr_of_sources = sum(source.u_mask,&#38;quot;all&#38;quot;);
% define a gaussian impulse
pos = gaussmf(kgrid.t_array, [t_end/20 t_end/6]);
vel_gaussian = [0 diff(pos)/dt];
source.uz = repelem(vel_gaussian,nbr_of_sources, 1);
source.u_mode= &#38;#39;dirichlet&#38;#39;;
%% define sensor
sensor.mask = ones(Nx, Ny, Nz);
%% run the simulation
sensor.record = {&#38;#39;u&#38;#39;} % u particle velocity
PML_size=5;             % size of the PML in grid points
input_args = {&#38;#39;PMLSize&#38;#39;, PML_size, &#38;#39;PlotPML&#38;#39;, true, &#38;#39;PMLInside&#38;#39;, false};
sensor_data = pstdElastic3D(kgrid, medium, source, sensor, input_args{:});&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;plotting the input vs ouput at sensor position gives different plots:&#60;br /&#62;
plot(kgrid.t_array, sensor_data.uz(4659,:), kgrid.t_array, source.uz(1,:))
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
