Hi,
I'm new to k-wave, and i'm trying now to simulate the recorded sound waves from a moving object in a room. As start point I have used the following code:
clear all;
% set the PML size
PML_size = 20;
% create the computational grid [ 3m by 3m domain ]
Nx = 128 - 2*PML_size; % number of grid points in the x (row) direction
Ny = 128 - 2*PML_size; % number of grid points in the y (column) direction
dx = 3/Nx; % grid point spacing in the x direction [m]
dy = 3/Ny; % grid point spacing in the y direction [m]
kgrid = makeGrid(Nx, dx, Ny, dy);
% define the properties of the propagation medium
c_air = 330; % [m/s] sound speed
rho_air = 1.225; % [kg/m^3] density
% define the properties of the object
c_object = 1000; % [m/s]
rho_object = 1000; % [kg/m^3]
thickness = 5; % [grid points]
% define the position of the object
object_y_pos = Ny/2;
object_x_pos = Nx/4;
object= zeros(Nx, Ny);
object(object_x_pos : end - end/4, object_y_pos : end - end/2 + thickness) = 1;
% assign the medium properties
medium.sound_speed = c_air*ones(Nx, Ny);
medium.sound_speed(object == 1) = c_object;
medium.density = rho_air*ones(Nx, Ny);
medium.density(object == 1) = rho_object;
% set the velocity of the moving object
obj_vel = 150; % [m/s]
% set the reference sound speed used in the k-space operator
medium.sound_speed_ref = c_air;
% create the time array
cfl = 0.2; %Courant-Friedrichs-Lewy number
t_end = 20e-3; % [s]
[kgrid.t_array, dt] = makeTime(kgrid, medium.sound_speed, cfl, t_end);
% define a time varying sinusoidal source
%source_freq = 1.5e3; % [Hz]
source_mag = 50; % [Pa]
%source.p = source_mag*sin(2*pi*source_freq*kgrid.t_array);
% define a tone burst
sampling_freq = 1/dt; % [Hz]
tone_burst_freq = 1.5e3; % [Hz]
tone_burst_cycles = 3;
source.p = source_mag*toneBurst(sampling_freq, tone_burst_freq, tone_burst_cycles);
% define a single source point
source.p_mask = zeros(Nx, Ny);
source.p_mask(end/2, end/4) = 1;
% define sensor point
sensor.mask = zeros(Nx, Ny);
sensor.mask(end/2, end/4) = 1;
display_mask = object + sensor.mask;
% define the acoustic parameters to record
%sensor.record = {'p'};
% run simulation
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor, ...
'PMLInside', false, 'PlotPML', false, 'PMLSize', PML_size, ...
'DisplayMask', display_mask, 'PlotScale', [-0.25, 0.25]*source_mag,...
'DataCast', 'single');
% plot the recorded data
figure;
subplot(2, 1, 1);
[t_sc scale prefix] = scaleSI(max(kgrid.t_array(:)));
plot(source.p, 'b-');
xlabel(['Time [' prefix 's]']);
ylabel('Signal Amplitude');
axis tight;
title('Source Pressure Signal');
subplot(2, 1, 2), plot(kgrid.t_array*scale, sensor_data, 'r-');
xlabel(['Time [' prefix 's]']);
ylabel('Signal Amplitude');
axis tight;
title('Sensor Pressure Signal');
and now I ca not know how to let the object move inside the computational grid. I will appreciate any help!
Best Regards