Hi Brad
thanks for the tips.
Here I plot with PMLAlpha set to 0,
https://dl.dropboxusercontent.com/u/581753/onewave_PMLAlphastudy.png
It looks PML effect, doesn't it?
How could I avoid it or at least mitigate it?
I am struggling to get my simulation run as further away possible in terms of x distance from the source and with larger domains that drop effect already starts at ca half of the x length (the code below is an example simulation, my actual simulations are a bit more sophisticated generating nonlinear effects).
My dt is in the order of microseconds, as seen in the text in the figure; number of time points is 6161.
Thanks
Mathias
clear all;
% =========================================================================
% grid
% =========================================================================
% long_grid flag to select between a computational with a long x-axis (1)
% and a short x-axis (0).
PML_X_SIZE = 100; % [grid points]
PML_Y_SIZE = 10; % [grid points]
Nx = 2048 - 2*PML_X_SIZE; % number of grid points in the x (row)
%10368
Ny = 32 - 2*PML_Y_SIZE; % number of grid points in y (column)
dx = 2e-3; % grid point spacing in x [m]
dy = 2e-3; % grid point spacing in y [m]
kgrid = makeGrid(Nx, dx, Ny, dy);
% =========================================================================
% define the properties of the propagation medium
% =========================================================================
medium.sound_speed = 343; % [m/s]
medium.alpha_coeff = 0.01*2.4e-7; % [dB/(MHz^y cm)]
medium.alpha_power = 1.44;
medium.density = 1.25; % [kg/m3]
medium.BonA = 0.4;
% =========================================================================
% create the time array
% =========================================================================
CLF = 0.14;
[kgrid.t_array, dt] = makeTime(kgrid, medium.sound_speed);
% =========================================================================
% select geometry of the source: line
% =========================================================================
source.p_mask = zeros(Nx,Ny);
source.p_mask(1,Ny/2-5:Ny/2+5) = 1;
num_elements = sum(sum(source.p_mask));
% =========================================================================
% define input signal to transducers: sin()
% =========================================================================
source_mag1 = 0.01; % [Pa]
source_freq1 = 70e3; % [Hz]
signal1 = source_mag1*sin(2*pi*source_freq1*kgrid.t_array);
input_signal = signal1;
source.p = input_signal;
% =========================================================================
% options for solver
% =========================================================================
display_mask = source.p_mask;
% sensor mask
sensor.mask = ones(Nx,Ny);
% assign the input options
input_args = {'DataCast','double','DisplayMask', source.p_mask, ...
'PMLSize', [PML_X_SIZE, PML_Y_SIZE],...
'PMLInside', false, 'PlotPML', true,...
'PlotScale', [-2*source_mag1, 2*source_mag1]};
% =========================================================================
% solver
% =========================================================================
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, input_args{:});
%% ========================================================================
% AXIAL PRESSURE, FFT of discrete frequencies along central array axis
% =========================================================================
sensor_data = reshape(sensor_data, [Nx, Ny, kgrid.Nt]);
sensor_data_axial=sensor_data(:,end/2,:);
nfft = 2^nextpow2(1/dt/1e3);
[freq, amp_spect] = spect(sensor_data_axial, 1/dt, 'Dim', 3,'FFTLength',nfft);
[f1_value, f1_index] = findClosest(freq, source_freq1);
% extract the amplitude at the source frequency and store
beam_pattern_f1 = amp_spect(:, :, f1_index);
figure
semilogx((kgrid.x_vec - min(kgrid.x_vec(:)))*1e3,20*log10(beam_pattern_f1./20e-6),'b')
ylabel('Pressure magnitude [dB re 20e-6 Pa]');
xlabel('x-position on axis [mm]');
titles=...
sprintf...
(['f1=%d kHz, mag1=%g dB (%g Pa),'...
'Nx=%d, Ny=%d, \n CLF=%g,'...
' dx=%g mm, dy=%g mm, dt=%g s, PMLx=%d, PMLy=%d.']...
,source_freq1/1e3,round(20*log10(source_mag1/2e-5)),...
source_mag1,Nx,Ny,CLF,dx*1e3,dy*1e3,...
dt,PML_X_SIZE,PML_Y_SIZE);
title(titles)