A general note about the code is to have 5 MHz as the tone_burst.
Mix different materials in the grid.
I wrote the code for the above general points and the code looks like this:
When you run it, you will see the source move from bottom to top in addition to moving from top to bottom.
How do you solve this?
% three Ultrafinedust in u_mask code
clear all
clc
% create the computational grid
Nx = 300; % [grid points]
Ny = 300; % [grid points]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dx = 6.86e-6; % [m] %% See changes.
dy = 6.86e-6; % [m] %% See changes.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
kgrid = makeGrid(Nx, dx, Ny, dy);
% define the compressional sound speed [m/s]
medium.sound_speed_compression = 343*ones(Nx, Ny);
% define the shear sound speed [m/s]
medium.sound_speed_shear = 0*ones(Nx, Ny);
% define the mass density [kg/m?3]
medium.density = 1.2754*ones(Nx, Ny);
medium.density(150,50) = 2650;
medium.density(150,100) = 2650;
medium.density(150,150) = 2650;
medium.density(150,200) = 2650;
medium.density(150,250) = 2650;
% define the absorption coefficients [dB/(MHz?2 cm)]
medium.alpha_coeff_compression = 0;
medium.alpha_coeff_shear = 0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Create the time array (Refer to Manual Page 31)
kgrid.t_array = makeTime(kgrid, medium.sound_speed_compression, 0.05, 9e-6);
%kgrid.t_array = makeTime(kgrid, medium.sound_speed_compression, CFL, t_end);
% See this addition.
% 0.1 is the CFL number, and 10e-6 is the t_end (total time duration).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% define a tone burst and assign it to the x-direction particle velocity
source.u_mask = zeros(Nx,Ny);
source.u_mask(5,:) = 1;
source.u_mode = 'additive';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dt = kgrid.t_array(2)-kgrid.t_array(1) ; %[Hz] %%%%
% See changes.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sampling_freq = 1/dt; % [Hz]
tone_burst_freq = 5e6; % [Hz]
tone_burst_cycles = 3;
source.ux = toneBurst(sampling_freq, tone_burst_freq, tone_burst_cycles);
source.uy = toneBurst(sampling_freq, tone_burst_freq, tone_burst_cycles);
toneBurst(sampling_freq, tone_burst_freq, tone_burst_cycles, 'Plot', true);
% define a 2D binary sensor mask in the shape of a line
x_offset = 25; % [grid points]
width = 50; % [grid points]
sensor.mask = zeros(Nx, Ny);
sensor.mask(Nx-1, 1:Ny) = 1;
% run the simulation
sensor_data = pstdElastic2D(kgrid, medium, source, sensor);