Hi, the K-Wave is usefull toolbox.
I want to simulate a sensor is moving along a line same as "The Doppler Effect" example, but in our example source doesn't move and sensor moves.
how can i do it???
best regard
Hi, the K-Wave is usefull toolbox.
I want to simulate a sensor is moving along a line same as "The Doppler Effect" example, but in our example source doesn't move and sensor moves.
how can i do it???
best regard
One way would be to define a binary sensor mask that traces the complete path of your moving sensor. In post processing, you can then interpolate between the recorded data from position to position.
Brad.
hi, tanx for your answer.
I can’t show the sensor that moves. I want to calculate the pressure in each times on the direction, but I can’t.
Please check my source code!!
please help me. Please!!!
'clear all;
% =========================================================================
% SIMULATION
% =========================================================================
% create the computational grid
Nx = 64; % number of grid points in the x (row) direction
Ny = Nx*2; % number of grid points in the y (column) direction
dy = 20e-3/Ny; % grid point spacing in the y direction [m]
dx = dy; % grid point spacing in the x direction [m]
pml_size = 20; % [pixels]
kgrid = makeGrid(Nx, dx, Ny, dy);
% define the properties of the propagation medium
medium.sound_speed = 1500; % [m/s]
medium.alpha_coeff = 0.75; % [dB/(MHz^y cm)]
medium.alpha_power = 1.5;
% set the velocity of the moving source
source_vel = 150; % [m/s]
% set the relative x-position between the source and sensor
source_sensor_x_distance = 10; % [grid points]
% manually create the time array
dt = 20e-9; % [s]
t_end = (Ny - 2*pml_size - 2)*dy / source_vel;
kgrid.t_array = 0:dt:t_end;
% define a single source point
source_x_pos = 5; % [grid points]
source.p_mask = zeros(Nx, Ny);
source.p_mask(end - pml_size - source_x_pos - source_sensor_x_distance, end - pml_size - Ny/4) = 1;
% define a time varying sinusoidal source
source_freq = 0.75e6; % [Hz]
source_mag = 2; % [Pa]
source.p = source_mag*sin(2*pi*source_freq*kgrid.t_array);
% filter the source to remove high frequencies not supported by the grid
source.p = filterTimeSeries(kgrid, medium, source.p);
% define a large area detector
sensor.mask = zeros(Nx, Ny);
sensor.mask(end - pml_size - source_x_pos, 1 + pml_size:end - pml_size) = 1;
% preallocate an empty pressure source matrix
num_sensor_positions = sum(sensor.mask(:));
sensor.record = {'p_max','p'};
% assign the input options
display_mask = source.p_mask ;
input_args = {'DisplayMask', display_mask, 'PlotPML', false};
%run the simulation
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor,input_args{:});
%sensor_data.p_max = reshape(sensor_data.p_max,1,num_sensor_positions);
%make same size the sensor_data.p_max to source.p_mask
max_pressure = zeros(Nx,Ny);'
If you know the path of your sensor through the domain (and the dependence of this on time), you can use this information to extract a single time series from your recorded data. For example, if you know your sensor is at a particular position at time t_index = 1, you can extract the value for that time index from the neighbouring grid points using linear interpolation, and so on for t_index = 2, 3, 4...
For example, if you have recorded the field over entire domain, you can reshape the field at a particular time-step using something like:
p_field = reshape(sensor_data.p(:, t_index), [Nx, Ny]);
You can then extract the pressure at your moving sensor from this field using standard MATLAB interpolation tools and the current position of your sensor. Then continue to loop through the field for the entire simulation.
If you don't want to store the entire field and extract the values in post processing, you could also modify the source codes directly to do this at each time step.
Hope you can get it to work,
Brad.
can you send to me the correct code?? i need it!
best regard
You must log in to post.