Hi,
I want to calculate a AS field using a line source(disk source in 3D) with time varying signal.
I got same result using kspaceFirstOrderAS and kspaceFirstOrderASC as
But the result seems wrong using kspaceFirstOrder-CUDA.exe. (I change kspaceFirstOrderASC to kspaceFirstOderASG)
My code is here:
clear;
%% signal parameters
freq = 100e3; %[Hz]
p0 = 10; %[Pa]
%% medium (water / linear)
medium.sound_speed = 1500; %[m/s]
medium.density = 1000; %[kg/m^3]
%% grids
dx = medium.sound_speed / (freq * 10);
Nx = 512;
Ny = 128;
xMax = Nx * dx;
yMax = Ny * dx;
kgrid = kWaveGrid(Nx, dx, Ny, dx);
kgrid.makeTime(medium.sound_speed, 0.3, (sqrt(xMax^2 + yMax^2)/medium.sound_speed + 1e-3) * 1.01);
%% source
source.p_mask = zeros(Nx, Ny);
source.p_mask(21, 1:round(0.1/dx + 1)) = 1;
source.p = p0 * sin(2*pi*freq * kgrid.t_array);
%% sensor
sensor.mask = zeros(Nx, Ny);
sensor.mask(21:Nx-20, 1) = 1;
%% RUN
sensor_data = kspaceFirstOrderAS(kgrid, medium, source, sensor, 'DataCast', 'gpuArray-single', 'DataRecast', true, 'PlotScale', [-p0, p0]);
%sensor_data = kspaceFirstOrderASG(kgrid, medium, source, sensor, 'DataCast', 'gpuArray-single', 'DataRecast', true, 'PlotScale', [-p0, p0]);
%% plot
figure;
data = sensor_data(:, end-round(1e-3/kgrid.dt-1) : end);
semilogy((0:Nx-41)*dx, rms(data, 2));
I change functon kspaceFirstOrderASC to kspaceFirstOrderASG to call kspaceFirstOrder-CUDA.exe
function sensor_data = kspaceFirstOrderASG(varargin)
if ~any(strcmp('FunctionName', varargin))
varargin = [varargin {'FunctionName', 'kspaceFirstOrderAS'}];
end
% Check for the binary name input. If not defined, set the default name of
% the GPU binary
if ~any(strcmp('BinaryName', varargin))
if isunix
varargin = [varargin {'BinaryName', 'kspaceFirstOrder-CUDA'}];
else
varargin = [varargin {'BinaryName', 'kspaceFirstOrder-CUDA.exe'}];
end
end