<?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: Failure using dirichlet source</title>
		<link>http://www.k-wave.org/forum/topic/failure-using-dirichlet-source</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Wed, 13 May 2026 00:59:55 +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/failure-using-dirichlet-source" rel="self" type="application/rss+xml" />

		<item>
			<title>Bradley Treeby on "Failure using dirichlet source"</title>
			<link>http://www.k-wave.org/forum/topic/failure-using-dirichlet-source#post-5999</link>
			<pubDate>Mon, 19 Jun 2017 21:02:01 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">5999@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Bill,&#60;/p&#62;
&#60;p&#62;Full-wave models like k-Wave that implement heterogeneities directly in the material properties (rather than as explicit boundary conditions) do not deal with with such strong density contrasts. If you're trying to model the response of a PZT transducer in air, k-Wave or other similar models are probably not the best tool. You'd be better served using a FEM model.&#60;/p&#62;
&#60;p&#62;Brad.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bwalker000 on "Failure using dirichlet source"</title>
			<link>http://www.k-wave.org/forum/topic/failure-using-dirichlet-source#post-5984</link>
			<pubDate>Wed, 14 Jun 2017 06:17:35 +0000</pubDate>
			<dc:creator>bwalker000</dc:creator>
			<guid isPermaLink="false">5984@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;The following code is numerically unstable and blows up. I'm not sure why.&#60;/p&#62;
&#60;p&#62;The same code 'works' if I change to an additive source. That said, the pressures inside the additive source region are very inhomogeneous, which I do not understand.&#60;/p&#62;
&#60;p&#62;This instability doesn't make much sense to me and I'm having a hard time developing confidence in the model. Any feedback would be appreciated.&#60;/p&#62;
&#60;p&#62;Best,&#60;br /&#62;
Bill Walker&#60;/p&#62;
&#60;p&#62;clear&#60;/p&#62;
&#60;p&#62;cfl   = 0.1;    % Courant-Friedrichs-Lewy number&#60;/p&#62;
&#60;p&#62;%% Set geometry&#60;/p&#62;
&#60;p&#62;N = 64;&#60;br /&#62;
Nx = N;&#60;br /&#62;
Ny = Nx;&#60;br /&#62;
Nz = N;&#60;br /&#62;
dx = 0.2e-3;&#60;br /&#62;
dy = dx;&#60;br /&#62;
dz = dx;&#60;/p&#62;
&#60;p&#62;% number of samples for the lossy boundary layers&#60;br /&#62;
n_bnd = 6;&#60;/p&#62;
&#60;p&#62;%%&#60;/p&#62;
&#60;p&#62;x = ((-(Nx-1)/2):((Nx-1)/2))*dx;&#60;br /&#62;
y = x;&#60;br /&#62;
z = ((-(Nz-1)/2):((Nz-1)/2))*dx;&#60;br /&#62;
z = z;&#60;br /&#62;
[X,Y,Z] = meshgrid(x,y,z);&#60;br /&#62;
R = ((X).^2+(Y).^2).^0.5;&#60;/p&#62;
&#60;p&#62;kgrid = makeGrid(Nx, dx, Ny, dy, Nz, dz);    &#60;/p&#62;
&#60;p&#62;%% Set pulse characteristics and timing&#60;/p&#62;
&#60;p&#62;f0 = 0.5e6;&#60;br /&#62;
N_cycles = 8;&#60;br /&#62;
t_max = 20e-6;&#60;/p&#62;
&#60;p&#62;%% Define the object regions&#60;/p&#62;
&#60;p&#62;% PZT 5A Source&#60;br /&#62;
r0(1) = 3.29e-3 / 2;&#60;br /&#62;
r1(1) = 9e-3 / 2;&#60;br /&#62;
z0(1) = -1e-3;&#60;br /&#62;
z1(1) = 1e-3 + eps;&#60;br /&#62;
material(1) = 1;&#60;/p&#62;
&#60;p&#62;%% Fill out the geometry matrix&#60;br /&#62;
mat = zeros(size(X));&#60;/p&#62;
&#60;p&#62;for j = 1:length(material),&#60;br /&#62;
    ind = find((r0(j) &#38;lt; R) &#38;amp; (r1(j) &#38;gt;= R) &#38;amp; (z0(j) &#38;lt; Z) &#38;amp; (z1(j) &#38;gt;= Z));&#60;br /&#62;
    mat(ind) = material(j);&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;%% Set the material properties&#60;/p&#62;
&#60;p&#62;% define the properties of the surrounding medium&#60;br /&#62;
medium.sound_speed_compression = 2*2^2*330*ones(size(mat)); % [m/s]         ----- Made up&#60;br /&#62;
medium.sound_speed_shear = 0*ones(size(mat)); % [m/s]         ----- Made up&#60;br /&#62;
medium.density     = 1.225*ones(size(mat)); % [kg/m^3]   ----- Made up&#60;/p&#62;
&#60;p&#62;% define the properties of the PZT 5A&#60;br /&#62;
ind = find(mat == 1);&#60;br /&#62;
medium.sound_speed_compression(ind) = 4350;     % [m/s]  Szabo book&#60;br /&#62;
% poisson's ratio = 0.35&#60;br /&#62;
medium.sound_speed_shear(ind) = sqrt(1/(2*(1+0.35)))*4350;           % [m/s]&#60;br /&#62;
medium.density(ind)     = 7750;                 % [kg/m^3] Szabo book&#60;/p&#62;
&#60;p&#62;figure(1)&#60;br /&#62;
imagesc(squeeze(medium.density(:,Nx/2,:)));&#60;br /&#62;
axis equal&#60;br /&#62;
axis off&#60;/p&#62;
&#60;p&#62;%% Define the source&#60;/p&#62;
&#60;p&#62;% create the time array&#60;br /&#62;
[kgrid.t_array, dt] = makeTime(kgrid, max(medium.sound_speed_compression(:)), cfl, t_max);&#60;br /&#62;
clear kgrid.t_array&#60;br /&#62;
kgrid.t_array = 0:dt:t_max;&#60;/p&#62;
&#60;p&#62;% define a ring source element&#60;br /&#62;
source.u_mask = zeros(size(mat));&#60;br /&#62;
ind = find(mat == 1);&#60;br /&#62;
source.u_mask(ind) = 1;&#60;/p&#62;
&#60;p&#62;tone_burst_freq = f0;&#60;br /&#62;
tone_burst_cycles = N_cycles;&#60;br /&#62;
source_signal = sin(2*pi*tone_burst_freq*(0:dt:(tone_burst_cycles/tone_burst_freq)));&#60;br /&#62;
source_signal = source_signal.*hann(length(source_signal))';&#60;/p&#62;
&#60;p&#62;fir_coeff = fir1(128,1.5e6*dt*2,'low');&#60;br /&#62;
source_signal = conv(fir_coeff,source_signal);&#60;/p&#62;
&#60;p&#62;ind = find(mat == 1);&#60;br /&#62;
source.uz = zeros(length(ind),length(source_signal));&#60;br /&#62;
 for j = 1:length(ind),&#60;br /&#62;
     source.uz(j,:) = source_signal;&#60;br /&#62;
 end&#60;/p&#62;
&#60;p&#62;source.u_mode = 'dirichlet';&#60;/p&#62;
&#60;p&#62;    %% Define the sensor points&#60;br /&#62;
    % define a series of Cartesian points to collect the data&#60;/p&#62;
&#60;p&#62;    ind = find(abs(X - x(Nx/2)) &#38;lt; dx/2);&#60;/p&#62;
&#60;p&#62;    sensor.mask = [kgrid.x(ind)'; kgrid.y(ind)'; kgrid.z(ind)'];&#60;/p&#62;
&#60;p&#62;%% Clean up some more memory&#60;/p&#62;
&#60;p&#62;clear ind mat R&#60;/p&#62;
&#60;p&#62;%% compute the pressure field&#60;br /&#62;
% define the field parameters to record&#60;br /&#62;
sensor.record = {'p','u'};&#60;/p&#62;
&#60;p&#62;% input arguments&#60;br /&#62;
input_args = {'DisplayMask', source.u_mask, 'DataCast', 'single', 'CartInterp', 'nearest'};&#60;/p&#62;
&#60;p&#62;% run the simulation&#60;br /&#62;
sensor_data = pstdElastic3D(kgrid, medium, source, sensor, input_args{:});&#60;/p&#62;
&#60;p&#62;save(['simple_test'])&#60;/p&#62;
&#60;p&#62;close all
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
