There is a way to plot, save, calculate, ... everything you want during the simulation using the inloopFun property in obj.simProp
Here an example:
obj = chi3D();
obj('inloopFun','myfun'); %the string in obj.simProp.inloopFun defines an external function which will be called during each loop of the simulation
and here an example for myfun.m:
function myfun()
% evalin('caller', 'who') %you can figure out which internal variables are used in the code if you set a break here during calling your simulation and execute evalin('caller', 'who')
k=evalin('caller', 'k');disp(k) %k is an integer control variable of the simulation loop, e.g. for k=1:N,...,end
obj=evalin('caller', 'obj'); % current chi3D object within the loop
E_ftfxfy=evalin('caller', 'Eftfxfy_o'); % ordinary complex field after k loops
if(~mod(k,10)) % to speed up the simulation
[I_freq,I_lam,Phase,GD,GDD]=obj.getSpectrum(E_ftfxfy,'alpha',obj.beamProp.alpha_x_pulse2) ; % alpha is the propagation angle of the spectral components of interest. Only needed for phase, GD, GDD,...
figure(111)
yyaxis left
plot(obj.constVect.lambda,I_lam./max(I_lam))
xlim([450e-9 550e-9])
ylabel('Spectral Intensity (norm.)')
xlabel('Wavelength (nm)')
yyaxis right
plot(obj.constVect.lambda,GDD*1e30)
ylabel('GDD (fs2)')
end
Tino Lang