Hello Ben,
I have also included my full code for your reference. Initially i start when the source is in focus and then i start moving the source away from the detector and observe the changes.
Could you please help me out with the issues i have indicated in my previous post??
Nx=100; % Number of points in the grid along x-direction
Ny=100;
Nz=100;
dx=1e-3; % grid point spacing in x-direction
dy=dx;
dz=dx;
%properties of the medium
medium.sound_speed = 1500*ones(Nx, Ny,Nz); % speed of sound in water medium [m/s]
medium.sound_speed(:,1:12,:) = 343; % [m/s] speed of sound in air
medium.sound_speed(66:100,12:16,:) = 343;
medium.sound_speed(1:35,12:16,:) = 343;
medium.density = 1000*ones(Nx, Ny,Nz); % Density of water medium[kg/m^3]
medium.density(:,1:12,:) =1.225; % [kg/m^3] density of air medium
medium.density(66:100,12:16,:) =1.225;
medium.density(1:35,12:16,:) =1.225;
% computation settings
input_args = {'DataCast', 'single','PlotLayout',true,'PMLInside',false}; %% Speeds up the computation time
% create the computational grid
kgrid = makeGrid(Nx, dx, Ny, dy, Nz, dz);
% % create initial pressure distribution
source.p0= zeros (Nx,Ny,Nz);
source.p0 (49:51, 49:51,49:51) = 1; %% Everytime change the position along x in order move the source from the detector.
% % % % define a single sensor point
sphere_sz = 78;
sphere_radius = 38; %% Focal length of the transducer 38mm
sphere_height = 5.2; %% In order fix the width of the transducer (Dia of transducer is 25mm)
sphere = makeSphere(sphere_sz, sphere_sz, sphere_sz, sphere_radius);
% % carve most of the sphere off then add it to a mask of the correct size
sphere(:,sphere_height:end,:) = 0;
sensor.mask = zeros(Nx, Ny, Nz); %% Defining the mask to detect the signal
sensor.mask(Nx/8:Nx/8+sphere_sz-1, Ny/8:Ny/8+sphere_sz-1, Nz/8:Nz/8+sphere_sz-1 ) = sphere;
% run the simulation
sensor_data = kspaceFirstOrder3D(kgrid, medium, source, sensor, input_args{:});
% average the data recorded at each grid point to simulate the measured
% signal from a single element focussed detector. Gives the average value
% and directionality of signal15
sensor_data = sum(sensor_data, 1);
% we define the time array in terms of the grid points
[kgrid.t_array, dt] = makeTime(kgrid, medium.sound_speed); %creates evenly spaced time array for simulation
Nt = length(kgrid.t_array);
voxelPlot(sensor.mask+source.p0);
view([14,20]);
figure;
[t_sc, t_scale, t_prefix] = scaleSI(kgrid.t_array(end));
plot(kgrid.t_array*t_scale, sensor_data, '-');
xlabel(['Time [' t_prefix 's]']);
ylabel('Recorded Pressure');
set(gca, 'XLim', [0 30]);
title('Signal');
Thanks a lot,
Hussain