Hi,
Here is my code to put one source and two sensors in a line of the medium. The question is why my source wave always appear in my opposite boundary no matter which location I put for source. I know we should put the source out of the PML, but even when I put PML as 0, it still run to opposite boundary first. Could anyone help me to understand the prinple of the model I hope the source running from left to right and not suddenly appeared in the opposite way. Thanks.
Here is my code:
clc
clear
close all
% =========================================================================
% SIMULATION
% =========================================================================
% create the computational grid
Nx = 60; % number of grid points= in the x (row) direction
Ny = 120; % number of grid points in the y (column) direction
dx = 1e-3; % grid point spacing in the x direction [m] 1mm
dy = 1e-3; % grid point spacing in the y direction [m]
kgrid = makeGrid(Nx, dx, Ny, dy);
% define the properties of the propagation medium
medium.sound_speed = 1500; % [m/s]
% set the CFL
cfl = 0.05;
% set end time
t_end = 50e-6; % end at 100s
% create the time array
[kgrid.t_array, dt] = makeTime(kgrid, medium.sound_speed, cfl, t_end);
% define a single source point
source.p_mask = zeros(Nx, Ny);
source.p_mask(Nx/2, 2) = 1;
% define a time varying sinusoidal source
source_freq = 1e6; % [Hz]
source_mag = 2; % [Pa]
t_array = [0:0.1e-6:0.1e-4];
source.p = source_mag*sin(source_freq*t_array);
% filter the source to remove high frequencies not supported by the grid
source.p = filterTimeSeries(kgrid, medium, source.p);
plot(t_array*1e6, source.p)
% define a single sensor point
sensor.mask = zeros(Nx, Ny);
sensor.mask(Nx/2, Ny/2) = 1;
sensor.mask(Nx/2, Ny-10) = 1;
% define the acoustic parameters to record
sensor.record = {'p'};
% define the properties of the PML to allow plane wave propagation
pml_alpha = 0; %
pml_size = [0, 0];
% set the input arguments
input_args = {'PlotScale', 'auto', 'PMLSize', pml_size,...
'PMLAlpha', pml_alpha, 'PlotPML', true, 'PlotLayout', true};
% run the simulation
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});
%%
% =========================================================================
% VISUALISATION
% =========================================================================
% plot the sensor data
figure;
subplot(2, 1, 1)
stackedPlot(kgrid.t_array*1e6, sensor_data.p(1,:));
ylim([-2 2])
xlabel('Time [\mus]');
subplot(2, 1, 2)
stackedPlot(kgrid.t_array*1e6, sensor_data.p(2,:));
ylim([-2 2])
xlabel('Time [\mus]');