Hi Brad,

Thanks for this helpful comment. But then I don't understand, why my code doesn't work.

I have a rectangular region of 100 nm in a gold sample. In this region the pressure should start at 0.5 and increase exponantially within a time constant of 5 ps to a saturation value of 1.

I think my code should give this, but there are several things which I don't understand.

(i) The initial pressure isn't 0.5, but something around 0.036 even though the first column values in the source.p variable are 0.5.

(ii) The pressure doesn't increase to twice the starting value, even though the exp-function should provide that.

Here is my code

%% create the computational grid

Nx = 8000;

dx = 1e-10;

kgrid = kWaveGrid(Nx,dx);

%% define the properties of the propagation medium

medium.sound_speed = 3390 * ones(Nx,1);

medium.density = 19300 * ones(Nx,1);

gamma_ratio = 0.5; % ratio of the Grüneisen parameters

tau = 5e-12; % time constant of exponential growth

%% define the time array

t_end = 100e-12;

kgrid.t_array = 0:1e-15:t_end;

%% initial pressure distribution

source.p_mask =zeros(Nx,1);

source.p_mask(1501:2500) = 1; % create the 100 nm region

TimeVector = kgrid.t_array;

TimeEFun = (1+(gamma_ratio-1)*exp(-TimeVector/tau)); % definition of the exp-Fkt

dTimeEFun = diff(TimeEFun); % calculate the difference for adding at later t

source.p = zeros (1000, size(TimeVector,2));

source.p(:,1) = (1+(gamma_ratio-1)); % assign starting value

for i = 1:1000 % assign values for later t

source.p(i,2:end) = source.p(i,1)*dTimeEFun;

end

sensor.mask = zeros(Nx,1);

sensor.mask(5000:7500) = 1;

%% run the simulation

sensor_data = kspaceFirstOrder1D(kgrid, medium, source, sensor, 'PlotLayout', true);

Best regards,

Brifa