Hi
I'm new to k-Wave and have a question about grid size
I made a source shaped in square with same size for different grid size.
I thought all cases have same area of source and result in same pressure magnitude
but small grid case which have more grid cells in source showed higher pressure.
Magnitude of pressure is proportional to the number of grid per length (not area!)
and thus increased linearly with respect to sqrt(number of grid in source area).
I have tried to use 'dirichlet' type source but showed same results.
--> There was an typo and with a correct command, 'dirichlet' type worked.
I'll appreciate your kind advises.
Thank you
%%
clearvars
clc
PML_Size = 20;
PML_Alpha = 2;
input_args = {'PMLSize', PML_Size, 'PMLInside', true, 'PMLAlpha', PML_Alpha};
%%
CFL = 0.15;
dG = 0.01*1e-3; % reference grid size
dt = CFL*dG/1500;
Nt = 5000;
Nx = 512;
Nz = 512;
pulse_Rect = conv(ones(1, ceil(40e-9/dt)), ones(1,7)/7);
Tx_Rect = [pulse_Rect, zeros(1, Nt - length(pulse_Rect))];
medium.sound_speed = 1500;
medium.density = 1000;
% number of grid per source (and sensor)
NG = [2, 4, 8, 16, 32, 64];
results = zeros(Nt, length(NG));
for k=1:length(NG)
dG = 0.16*1e-3/NG(k);
kgrid = kWaveGrid(Nx, dG, Nz, dG);
kgrid.dt = dt;
kgrid.Nt = Nt;
kgrid.t_array = (0:kgrid.Nt-1)*dt;
%source.p_mode = 'dirichlet';
source.p_mask = zeros(Nx, Nz);
source.p_mask((1:NG(k)) - 0.5*NG(k) + Nx/2, (1:NG(k)) - 0.5*NG(k) + Nz/2 - 3*NG(k)) = 1;
source.p = Tx_Rect;
sensor.mask = zeros(Nx, Nz);
sensor.mask((1:NG(k)) - 0.5*NG(k) + Nx/2, (1:NG(k)) - 0.5*NG(k) + Nz/2 + 3*NG(k)) = 1;
subplot(2, length(NG)+1, k)
imagesc(kgrid.x_vec, kgrid.y_vec, (source.p_mask-sensor.mask))
axis image
xlim([-1, 1]*0.9*1e-3)
ylim([-1, 1]*0.9*1e-3)
subplot(2, length(NG)+1, k + length(NG)+1)
imagesc(kgrid.x_vec, kgrid.y_vec, (source.p_mask-sensor.mask))
axis image
drawnow
data = kspaceFirstOrder2DG(kgrid, medium, source, sensor, input_args{:});
results(:,k) = mean(data, 1)';
end
subplot(2, length(NG)+1, length(NG) + 1)
plot(results)