I have looking into the effect of the size of the source for the output signal for giving input chirp signal.
I am getting quite different output signal why? here is the code.
clear all;clc;close all
% set the size of the perfectly matched layer (PML)
PML_X_SIZE = 20; % [grid points]
PML_Y_SIZE = 20; % [grid points]
% set total number of grid points not including the PML
Nx = 128 - 2*PML_X_SIZE; % [grid points]
Ny = 128 - 2*PML_Y_SIZE; % [grid points]
% set desired grid size in the x-direction not including the PML
x = 25e-3; % [m]
% calculate the spacing between the grid points
dx = x/Nx; % [m]
dy = dx; % [m]
% create the k-space grid
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;
% create the time array
[kgrid.t_array, dt] = makeTime(kgrid, medium.sound_speed,[], 100e-6);
% define a single source point
source.p_mask = zeros(Nx, Ny);
source.p_mask(end - Nx/4, Ny/2) =1;
% define a time varying sinusoidal source
source_freq1 = 0.5e6; % [Hz]
source_freq2=4e6;
source_mag = 2; % [Pa]
%input_signal =sin(2*pi*source_freq1*kgrid.t_array);%
input_signal=my_chirp(kgrid.t_array,source_freq1,source_freq2,100e-6);
source.p = source_mag*input_signal;
%%
% filter the source to remove high frequencies not supported by the grid
source.p = filterTimeSeries(kgrid, medium, source.p);
% define a single sensor point
sensor.mask = zeros(Nx, Ny);
sensor.mask(Nx/4, Ny/2) = 1;
% define the acoustic parameters to record
sensor.record = {'p', 'p_final'};
% % run the simulation
sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor);
%%
% plot the final wave-field
figure;
imagesc(kgrid.y_vec*1e3, kgrid.x_vec*1e3, sensor_data.p_final + source.p_mask + sensor.mask, [-1 1]);
colormap(getColorMap);
ylabel('x-position [mm]');
xlabel('y-position [mm]');
axis image;
% plot the simulated sensor data
figure(1);
[t_sc, scale, prefix] = scaleSI(max(kgrid.t_array(:)));
subplot(2, 1, 1), plot(kgrid.t_array*scale, source.p, 'k-');grid on
xlabel(['Time [' prefix 's]']);
ylabel('Signal Amplitude');
axis tight;
title('Input Pressure Signal');
subplot(2, 1, 2), plot(kgrid.t_array*scale, sensor_data.p, 'r-');grid on;
xlabel(['Time [' prefix 's]']);
ylabel('Signal Amplitude');
axis tight;
title('Sensor Pressure Signal');
%%
figure(2)
[f_input, as_input] = spect([input_signal, zeros(1, 2*length(input_signal))], 1/kgrid.dt);
subplot(211),plot(f_input/1e6, as_input./max(as_input(:)), 'k-');
title('spectrum of chirp input signal')
xlabel('frequency MHz')
ylabel('normalized value')
axis('tight')
[f_input, as_input] = spect([source.p, zeros(1, 2*length(source.p))], 1/kgrid.dt);
subplot(223),plot(f_input/1e6, as_input./max(as_input(:)), 'k-');
title('spectrum of source signal')
xlabel('frequency MHz')
ylabel('normalized value')
axis('tight')
[f_output, as_output] = spect([sensor_data.p, zeros(1, 2*length(sensor_data.p))], 1/kgrid.dt);
subplot(224),plot(f_output/1e6, as_output./max(as_output(:)), 'r-');
title('spectrum of sensor output signal')
xlabel('frequency MHz')
ylabel('normalized value')
axis('tight')
display(dx)
But for smaller size (i am taking 1 grid size) i am getting output signal increases with the frequency. but for lager size( for grid size 3 to 5) i am getting output signal amplitude decreases with the frequency (that what we expect).