I did the following simulation:
Nx=64;
Ny=64;
Nz=64;
dx=1e-3;
dy=1e-3;
dz=1e-3;
kgrid=makeGrid(Nx,dx,Ny,dy,Nx,dz);
medium.sound_speed=1500*ones(Nx,Ny,Nz); % sound speed in water
medium.density=1000*ones(Nx,Ny,Nz); % water density
medium.sound_speed(:,:,50:64)=343; % sound speed in air
medium.density(:,:,50:64)=1.2; % air density
source.p0=makeBall(Nx,Ny,Nz,32,32,32,10);
sensor.mask=[makeCartCircle(15e-3, 100);zeros(1,100)];
input_args = {'Smooth', false,'CartInterp', 'nearest', 'DisplayMask','off', 'PMLInside', true, 'PMLSize', 10, 'PlotPML', false, 'PlotSim', false, 'DataCast', 'gsingle'};
p=kspaceFirstOrder3D(kgrid,medium,source,sensor,input_args{:});
Without smoothing the medium, the simulated pressure 'p' is blowing up, and if I smoothed the medium by setting the 'input_args' as
input_args = {'Smooth', [false,true,true],'CartInterp', 'nearest', 'DisplayMask','off', 'PMLInside', true, 'PMLSize', 10, 'PlotPML', false, 'PlotSim', false, 'DataCast', 'gsingle'};
Then 'p' looks reasonable. So I am wondering if this means that the medium needs to be smoothed if the variation of sound speed/density is very large.