<?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: stress source lingers</title>
		<link>http://www.k-wave.org/forum/topic/stress-source-lingers</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Tue, 12 May 2026 23:29:16 +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/stress-source-lingers" rel="self" type="application/rss+xml" />

		<item>
			<title>ad000000 on "stress source lingers"</title>
			<link>http://www.k-wave.org/forum/topic/stress-source-lingers#post-6415</link>
			<pubDate>Mon, 16 Apr 2018 20:21:50 +0000</pubDate>
			<dc:creator>ad000000</dc:creator>
			<guid isPermaLink="false">6415@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Oops.  Thanks.&#60;br /&#62;
function myLine=myMakeLine(kgrid,lineStart,lineEnd);&#60;br /&#62;
% function to make a line for K-wave, given cartesion input points.&#60;/p&#62;
&#60;p&#62;    [lineStartGrid(1) lineStartGrid(2)] =cartPt2Grid(kgrid,lineStart);&#60;br /&#62;
    [lineEndGrid(1) lineEndGrid(2)]=cartPt2Grid(kgrid,lineEnd);&#60;br /&#62;
    myLine=makeLine(kgrid.Nx,kgrid.Ny,lineStartGrid,lineEndGrid);
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bencox on "stress source lingers"</title>
			<link>http://www.k-wave.org/forum/topic/stress-source-lingers#post-6411</link>
			<pubDate>Thu, 12 Apr 2018 20:38:43 +0000</pubDate>
			<dc:creator>bencox</dc:creator>
			<guid isPermaLink="false">6411@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi ad000000,&#60;/p&#62;
&#60;p&#62;I can't run your code as you have some homemade functions in there, but I recall seeing something similar in the past. Paste up your other functions and we'll take a look.&#60;/p&#62;
&#60;p&#62;Best wishes,&#60;br /&#62;
Ben
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ad000000 on "stress source lingers"</title>
			<link>http://www.k-wave.org/forum/topic/stress-source-lingers#post-6387</link>
			<pubDate>Sat, 07 Apr 2018 02:48:49 +0000</pubDate>
			<dc:creator>ad000000</dc:creator>
			<guid isPermaLink="false">6387@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi. I made a linear stress source, to launch a plane wave at a hole to observe scattering.  The source excitation is a wavelet.  For some reason the simulation yields a finite stress (and velocity) along this line for the duration of the simulation.  The BC's are normal (not Dirichlet).  Any ideas?&#60;br /&#62;
Thanks.&#60;/p&#62;
&#60;p&#62;CODE&#60;br /&#62;
% HoleScatter.m&#60;br /&#62;
% Launch a plane wave (shear of long) at a hole.&#60;/p&#62;
&#60;p&#62;clear source sensor medium kgrid&#60;br /&#62;
%=== define variables=====================&#60;/p&#62;
&#60;p&#62;freq=5e6;&#60;br /&#62;
epw=8;&#60;br /&#62;
cp=5850;&#60;br /&#62;
cs=3230;&#60;br /&#62;
rho=8030;&#60;br /&#62;
SDHdia=1.5e-3;&#60;br /&#62;
type='long';   %shear or long&#60;br /&#62;
dataInc=2;  % Data is stored every dataInc grid points&#60;/p&#62;
&#60;p&#62;%==define geometry (remember, horizontal is Y direction)==================&#60;br /&#62;
xlen=21e-3;&#60;br /&#62;
ylen=16e-3;&#60;br /&#62;
sdhXloc=0;&#60;br /&#62;
sdhYloc=2e-3;&#60;br /&#62;
srcYloc=-1e-3;   %this shortens travel time, as opposed to putting it at left of grid.&#60;/p&#62;
&#60;p&#62;% ====================  setup grid =========================================&#60;br /&#62;
lambda=cp/freq;&#60;br /&#62;
dx=lambda/epw;&#60;br /&#62;
dy=lambda/epw;&#60;/p&#62;
&#60;p&#62;Nx= ceil(xlen/dx);&#60;br /&#62;
Ny= ceil(ylen/dy);&#60;br /&#62;
kgrid = makeGrid(Nx, dx, Ny, dy);&#60;/p&#62;
&#60;p&#62;%====set up material regions and kgrid =========================================&#60;/p&#62;
&#60;p&#62;medium.sound_speed_compression =ones(kgrid.Nx, kgrid.Ny)*cp;&#60;br /&#62;
medium.sound_speed_shear =ones(kgrid.Nx, kgrid.Ny)*cs;&#60;br /&#62;
medium.alpha_coeff_compression = ones(kgrid.Nx, kgrid.Ny)*.3/(freq/1e6);   %to give dB/(MHz^2 cm)&#60;br /&#62;
medium.alpha_coeff_shear       = ones(kgrid.Nx, kgrid.Ny)*.3/(freq/1e6)*4;&#60;br /&#62;
medium.density=ones(kgrid.Nx, kgrid.Ny)*rho;&#60;/p&#62;
&#60;p&#62;SDHdiaGrid=SDHdia/dx;&#60;br /&#62;
[SDHcenterGridx,SDHcenterGridy]=cartPt2Grid(kgrid,[sdhXloc sdhYloc]);&#60;br /&#62;
disc = makeDisc(Nx, Ny, SDHcenterGridx, SDHcenterGridy, SDHdiaGrid/2);&#60;br /&#62;
medium.sound_speed_compression(disc == 1) = 2000;&#60;br /&#62;
medium.sound_speed_shear(disc == 1) = 1000;&#60;br /&#62;
medium.density(disc==1)=rho;60;&#60;br /&#62;
medium.alpha_coeff_compression(disc==1) = 1/(freq/1e6);   %to give dB/(MHz^2 cm)&#60;br /&#62;
medium.alpha_coeff_shear(disc==1)       = 4/(freq/1e6)*4; &#60;/p&#62;
&#60;p&#62;if strcmp(type,'shear');vel=cs;else vel=cp;end&#60;br /&#62;
t_end=(ylen/2+2*sdhYloc-srcYloc)/vel;&#60;br /&#62;
%if ReverseFire==1; t_end=t_end/2;end&#60;/p&#62;
&#60;p&#62;dt=.3*dx/(cp);     %set time steps (C should be Cmax)&#60;br /&#62;
kgrid.t_array = 0:dt:t_end;&#60;br /&#62;
Nt=length(kgrid.t_array);&#60;/p&#62;
&#60;p&#62;PML=20*dx;&#60;/p&#62;
&#60;p&#62;%======================= setup source ===================================================&#60;br /&#62;
signal = wavelet(freq,4,0,2/freq,kgrid.t_array);%*1/(rho*cs);&#60;/p&#62;
&#60;p&#62;source.s_mask=myMakeLine(kgrid,[-.495*xlen, srcYloc],[.495*xlen, srcYloc ]);&#60;br /&#62;
%source.s_mask=myMakeLine(kgrid,[-.495*xlen, srcYloc+3*SDHdia],[.495*xlen, srcYloc-3*SDHdia ]);&#60;br /&#62;
srcinds=find(source.s_mask==1);&#60;br /&#62;
if strcmp(type,'shear')&#60;br /&#62;
  source.sxy=repmat(signal,length(srcinds),1);&#60;br /&#62;
else&#60;br /&#62;
  source.syy=repmat(signal,length(srcinds),1);&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;% The following is an attempt to use Dirichlet BC to simulate hole.  Didn't work.&#60;br /&#62;
%discinds=find(disc==1);&#60;br /&#62;
%source.sxy=[source.sxy ;repmat(zeros(size(signal)),length(discinds),1)];&#60;br /&#62;
% source.u_mask=disc;&#60;br /&#62;
% source.u_mask(:,1)=1;&#60;br /&#62;
% srcinds=1:kgrid.Nx;&#60;br /&#62;
% source.uy=repmat(signal,length(srcinds),1);&#60;br /&#62;
% discinds=find(disc==1);&#60;br /&#62;
% source.uy=[source.uy ;repmat(zeros(size(signal)),length(discinds),1)];&#60;br /&#62;
% source.u_mode = 'dirichlet';&#60;/p&#62;
&#60;p&#62;%====setup sensor  =====================================================&#60;br /&#62;
sensor.mask=zeros(kgrid.Nx, kgrid.Ny);&#60;br /&#62;
sensor.mask(1:dataInc:kgrid.Nx,1:dataInc:kgrid.Ny)=1;&#60;br /&#62;
sensor.record = {'u'};  %{'p','p_max'};&#60;br /&#62;
sensor.record_start_index=round((sdhYloc-srcYloc-SDHdia)/vel/dt);&#60;/p&#62;
&#60;p&#62;%===== display_mask =========================================&#60;br /&#62;
display_mask=disc;&#60;/p&#62;
&#60;p&#62;%==================== RUN =================================================&#60;br /&#62;
figpos=get(0,'DefaultFigurePosition');&#60;br /&#62;
set(0,'DefaultFigurePosition',[340,275,980,735]);&#60;/p&#62;
&#60;p&#62;input_args = {'DisplayMask', display_mask, 'PMLInside', false, 'PlotPML', false,'PlotScale','auto','DataCast', 'single','RecordMovie',true,'MovieProfile','MPEG-4'};&#60;/p&#62;
&#60;p&#62;sensor_data = pstdElastic2D(kgrid, medium, source, sensor, input_args{:});&#60;br /&#62;
%sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});&#60;/p&#62;
&#60;p&#62;set(0,'DefaultFigurePosition',figpos);&#60;/p&#62;
&#60;p&#62;kmodel=sensor_data;&#60;br /&#62;
clear sensor_data medium source disc ;&#60;br /&#62;
kmodel.freq=freq;&#60;br /&#62;
kmodel.Nx=Nx;kmodel.Ny=Ny;&#60;br /&#62;
kmodel.x_vec=kgrid.x_vec;kmodel.y_vec=kgrid.y_vec;&#60;br /&#62;
kmodel.Nt=length(kgrid.t_array);&#60;br /&#62;
kmodel.epw=epw;&#60;/p&#62;
&#60;p&#62;%uall=sqrt(kmodel.ux_max_all.^2+kmodel.uy_max_all.^2);&#60;br /&#62;
u=sign(kmodel.uy).*sqrt(kmodel.ux.^2+kmodel.uy.^2);&#60;br /&#62;
uh=abs(hilbert(u'))';&#60;/p&#62;
&#60;p&#62;nox=ceil(kmodel.Nx/dataInc);noy=ceil(kmodel.Ny/dataInc);&#60;br /&#62;
dat=zeros(nox,noy);&#60;br /&#62;
for t=1:size(u,2);&#60;br /&#62;
    for j=1:nox&#60;br /&#62;
        for k=1:noy;&#60;br /&#62;
            dat(j,k,t)=uh((k-1)*nox+j,t);&#60;br /&#62;
            %dat(j,k,t)=u((k-1)*nox+j,t);&#60;br /&#62;
            %dat(j,k,t)=kmodel.ux((k-1)*nox+j,t);&#60;br /&#62;
        end&#60;br /&#62;
    end&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;% Record the movie&#60;br /&#62;
%maxdat=max(max(max(dat)));&#60;br /&#62;
%ax=[0 maxdat/500];&#60;br /&#62;
nframes=50;&#60;br /&#62;
Nsamps=size(kmodel.ux,2);&#60;br /&#62;
midframe=round(Nsamps/2);&#60;br /&#62;
step=floor((Nsamps-1)/nframes);&#60;br /&#62;
figure;imagesc(kmodel.y_vec,kmodel.x_vec,(dat(:,:,midframe)));axis equal;%caxis(ax)&#60;br /&#62;
set(gca,'nextplot','replacechildren');&#60;br /&#62;
maxax=max(caxis);&#60;br /&#62;
ax=[0 maxax/2];&#60;br /&#62;
for j= 1:nframes;&#60;br /&#62;
    t=1+(j-1)*step;&#60;br /&#62;
	imagesc(kmodel.y_vec,kmodel.x_vec,(dat(:,:,t)));caxis(ax)&#60;br /&#62;
	F(j) = getframe;&#60;br /&#62;
end&#60;br /&#62;
% Play the movie&#60;br /&#62;
movie(F,2,4)&#60;/p&#62;
&#60;p&#62;%kmodel.uall=uall;&#60;br /&#62;
kmodel.u=u;&#60;br /&#62;
clear  u&#60;br /&#62;
save kmodel.mat kmodel -v7.3&#60;/p&#62;
&#60;p&#62;%==============================&#60;br /&#62;
function myLine=myMakeLine(kgrid,lineStart,lineEnd);&#60;br /&#62;
% function to make a line for K-wave, given cartesion input points.&#60;/p&#62;
&#60;p&#62;    [lineStartGrid(1) lineStartGrid(2)] =cartPt2Grid(kgrid,lineStart);&#60;br /&#62;
    [lineEndGrid(1) lineEndGrid(2)]=cartPt2Grid(kgrid,lineEnd);&#60;br /&#62;
    myLine=makeLine(kgrid.Nx,kgrid.Ny,lineStartGrid,lineEndGrid);
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
