Hello,
I’m basically new with k-wave and I’m trying to figure out how it works. For the moment, I would simply like to simulate the pressure field radiated by a squared-piston. At first, I tried with a pressure source, which seems to work quite well.
But for the purpose of my study I rather want to use velocity inputs. But when I run the same piece of code with source.ux, the simulation seems to diverge (Picture below)
If I normalize my input velocity by the acoustic impedance of the medium, let say 1.5e6, the computation seems to go quite well (Picture below)
What is surprising to me is the fact that the computed pressure at my sensor location is the same in both cases, ignoring the scaling factor (result in the latter case has been multiplied by 1.5e6) (Figure below)
How is this possible? Is it a display problem? Thank you for your help
clear all;
f0=1e6;
lambda=1500/f0;
% create the computational grid
dx = 0.1e-3; % grid point spacing in the x direction [m]
dy = 0.1e-3; % grid point spacing in the y direction [m]
dz = 0.1e-3;
d_field_x = 10e-3;
d_field_y = 5e-3;
d_field_z = 5e-3;
Nx = 2^nextpow2(ceil(d_field_x/dx)); % number of grid points in the x (row) direction
Ny = 2^nextpow2(ceil(d_field_y/dy)); % number of grid points in the y (column) direction
Nz = 2^nextpow2(ceil(d_field_z/dz));
kgrid = makeGrid(Nx, dx, Ny, dy,Nz,dz);
% define the properties of the propagation medium
medium.sound_speed = 1500*ones(Nx, Ny,Nz); % [m/s]
medium.density = 1000*ones(Nx, Ny,Nz); % [kg/m^3]
kgrid.t_array = makeTime(kgrid,medium.sound_speed);
fech=1./kgrid.dt;
% creation of the velocity input
t=0:kgrid.dt:5/f0;
sig=10e-9*sin(2*pi*f0*t);
sig2=[zeros(1,10) sig zeros(1,10)].*blackman(numel([zeros(1,10) sig zeros(1,10)])).';
vit=diff(sig2)/kgrid.dt;
source.ux = vit; %case 1
% source.ux = vit/(1.5e6); %case 2
source.u_mask = zeros(Nx,Ny,Nz);
source.u_mask(25,[-2:2]+Ny/2,[-2:2]+Nz/2)=1;
sensor.mask = zeros(Nx,Ny,Nz);
sensor.mask(50,Ny/2,Nz/2) = 1;
sensor.record={'p'};
% define the input arguments
input_args = {'PlotPML', false, 'RecordMovie', false, 'MovieName', 'example_movie_1', 'PlotFreq', 5, 'MovieArgs', {'fps', 30},'LogScale',true,'PlotLayout',false, 'DisplayMask',sensor.mask};
% run the simulation
pressure=kspaceFirstOrder3D(kgrid, medium, source,sensor, input_args{:});