I want to apply the sin and chip signal at the source input . i am new to k wave and doing the simulation to see the nature of the output signal.
k-Wave
A MATLAB toolbox for the time-domain
simulation of acoustic wave fields
various input signal
(6 posts) (3 voices)-
Posted 9 years ago #
-
Hi jnawali123,
You can set the input signal with the variable
source.p
.
I encourage you to read the user manual (see documentation) and to check the examples, they will help you. Feel free to ask if you have specific questions (you can even post a minimum working example if you have problems).Best regards,
AnthonyPosted 9 years ago # -
Thanks Anthony
Yes the book is really good i have a trouble to apply
sensor_data=kspaceFirstOrder2D(kgrid, medium, source, sensor,'PlotScale',[-10 ,10]);
it doesnot give me the output plot with range -10 to 10Posted 9 years ago # -
Hi jnawali123,
Do you mean the plot during the simulation, or when you plot the returned
sensor_data
? The'PlotScale'
input only controls the plot scale used during the simulation.Brad.
Posted 9 years ago # -
Thanks Brad
I have a problem in the following code, for the rectangular pulse, i am getting unusual output pressure signal, i am running it to test for various kind of signal input. Can i apply similar technique for the chirp signal.
Here is my code for the rect as the input function.clear all
close all
sensor_radius = 2e-3; %[m]point sensor kept at a distance of 2 mm from the centre of the source.
ball_radius = 1e-3; %[m]source is a spherical ball of radius 1 mm.
pulsewidth_min = 0.1e-6; %min width of the pulse which excites the source.%-------------------------------------------------------------------------------
%create the computational grid
%-------------------------------------------------------------------------------
%makeGrid(Nx,dx,Ny,dy)% create the computational grid
dx = 0.025e-3; % grid point spacing in the x direction [m]
dy = dx; % grid point spacing in the y direction [m]
PMLe = 25*dx; %[no of grid points for PML*dx]
grig_length = (2*sensor_radius)+(2*PMLe); % total grid length in a particular direction [m]
Nx = grig_length/dx; % number of grid points in the x (row) direction
Ny = grig_length/dx; % number of grid points in the y (column) direction
%the nyquist requires two point per wavelength is necessary if we need to take
% x_size instead of Nx (then look details in the page 28)
kgrid=makeGrid(Nx,dx,Ny,dy);
% to see maximum spatial frequency type kgrid.k_max(details in the page 28)
%see how kspace looks like %imshow(kgrid.k,[])
% to make faster computation, grid points in the form of 2^(power)%--------------------------------------------------------------------------
%define the material property
%----------------------------------------------------------------------------medium.sound_speed=1500;
%--------------------------------------------------------------------------------
%time array
%---------------------------------------------------------------------------------
% if we need to set the final time
%kgrid.t_array=makeTime(kgrid,medium.sound_speed,[],t_end]
time.dt = pulsewidth_min/10; % sampling interval[s]
time.total = 6e-6 + sensor_radius/medium.sound_speed; % Total simulation time or the time taken by the wave to reach the transducer[s]
time.Nt = ceil(time.total/time.dt); % No of time steps[points]
time.t_array = 0:1:time.Nt-1; %time array having Nt time steps
time.t_array = time.t_array*time.dt;
kgrid.t_array=time.t_array;
%----------------------------------------------------------------------------------
%define the source pressure(requires sourc.p_mask and source.p
%----------------------------------------------------------------------------------
%--------------------------------------------------------------------------------
%source.p_mask
%---------------------------------------------------------------------------------------
% source.p_mask = zeros(Nx, Ny);
% source.p_mask(Nx/5, Ny/2) = 1;% create initial pressure distribution using makeDisc
disc_magnitude = 1; % [au]
disc_x_pos = Nx/2; % [grid points]
disc_y_pos = Ny/2; % [grid points]
disc_radius = 10; % [grid points]
disc_1 = disc_magnitude*makeDisc(Nx, Ny, disc_x_pos, disc_y_pos, disc_radius);
source.p_mask = disc_1;
%--------------------------------------------------------------------------------
%source.p for variable input signal
%---------------------------------------------------------------------------------------
pulse_width = [0.1e-6 0.2e-6 0.5e-6 1e-6 2e-6 4e-6];% array of the various pulse widths
% define a gaussian pulse sourcefor i=1:length(pulse_width)
% a=1e-6;
% b=a+pulse_width(i);
%source.p=rectangularPulse(a,b,kgrid.t_array);
source.p=rectpuls(kgrid.t_array,pulse_width(i));%filter the source to remove high frequencies not supported by the grid
source.p = filterTimeSeries(kgrid, medium, source.p);%--------------------------------------------------------------------------------
%define sensor
%-------------------------------------------------------------------------------
sensor.mask=zeros(Nx,Ny);
sensor.mask(Nx/5,Ny/2)=1;%---------------------------------------------------------------------------------
%run simulation
%--------------------------------------------------------------------------------------
sensor.record={'p','p_final'};sensor_data=kspaceFirstOrder2D(kgrid, medium, source, sensor);%,'PlotScale',[-10 ,10]);
%--------------------------------------------------------------------------
%results
%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;
[t_sc, scale, prefix] = scaleSI(max(kgrid.t_array(:)));subplot(2, 1, 1), plot(kgrid.t_array*scale, source.p, 'k-');
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-');
xlabel(['Time [' prefix 's]']);
ylabel('Signal Amplitude');
axis tight;
title('Sensor Pressure Signal');end
Kamal Jnawali
Posted 9 years ago # -
Hi Kamal,
Exactly what part of the output signal are you concerned about? At each edge of the square wave, you will generate a photoacoustic pulse, with the signal from the second edge the opposite polarity from the signal from the first edge. The shape of these signals in 2D is given by your first simulation (see also the Photoacoustic Waveforms in 1D, 2D and 3D Example).
Hope that helps,
Brad.
Posted 9 years ago #
Reply
You must log in to post.