plotInLoop.m%% ___________________create a new instance of class ch23d_________________________
% clear all
% close all
clc
obj = chi3D('tag','PPLN example','inloopFun','plotInLoop(obj,Eftfxfy_e,k)');
%% ___________________computational parameters_____________________________________
obj( 'Nx',32,'xWindow',0.0005,...
'Ny',1 ,'yWindow',0.0005,... %use Ny=1 for 2+1D, Ny=2^N for 3+1d
'Nt',2048, 'tWindow',3e-12,'shiftFreqWindow',0,...
'Nz',1000, 'propagationLength', 1e-3,...
'GPUOn',0, 'abortIntensity', inf,...
'showResultEach',100, 'showProgress',1);
obj( 'material','LNcMgO','theta',1.5708,'phi',0,'plane','YZ','temperature',20);
% Ni=10;
% pol=linspace(6.3085,6.3092,Ni).*1e-6;
% for i=1:Ni
% obj.showProgress(i,Ni,2)
PP=6.30882e-6;%pol(i);%6.29831e-6;%-0.01e-6;
stepsEachPeriode=4;
Nz=round(obj.simProp.propagationLength/(PP))*stepsEachPeriode; %find number of periodes Nz within the propagation length
deff1=24e-12.*repmat([ones(1,stepsEachPeriode/2) -ones(1,stepsEachPeriode/2)],[1 Nz/stepsEachPeriode]); %deff vector with Nz/2 periodes and Nz domains
% stepSize = PP/stepsEachPeriode.*repmat(1,[1 Nz]); %rms %stepSize vector for each of the Nz propagation steps -> the stepSize can be chirped or with a random distribution
% stepSize = PP/stepsEachPeriode.*repmat(1,[1 Nz]).*(1+randn(1,Nz)*5e-2/stepsEachPeriode); %5%rms %stepSize vector for each of the Nz propagation steps -> the stepSize can be chirped or with a random distribution
%%
ADlength= 0.2;
chirp = 0.4;
chirpAD = 5*chirp;
stepSize = PP/stepsEachPeriode.*fliplr(repmat(1,[1 Nz]).*(1+[linspace(-chirpAD,-chirp,round(Nz*ADlength)),linspace(-chirp,chirp,Nz-2*round(Nz*ADlength)),linspace(chirp,chirpAD,round(Nz*ADlength))]./stepsEachPeriode)); %1%chrip +linear apodization %stepSize vector for each of the Nz propagation steps -> the stepSize can be chirped or with a random distribution
figure(1),plot(stepSize)
%%
stepSize(end)=stepSize(end)-(sum(stepSize)-obj.simProp.propagationLength); %modify last step in order to match the crystal size (propagation length)
obj( 'Nz',Nz,'stepSize',stepSize,...
'deff1',0 ,'eoo',0,'oeo',0,'ooo',0,...
'deff2',deff1 ,'oee',0,'eeo',0,'eee',1);
%% ______________________________input pulse definition______________________________
obj({ 'pulse1','EorI',10e-9,'polarization','e','centerWavelength',1.03e-06,...
'pulseDuration',50e-15,'beamShape_t','gauss',...
'beamRadius_x',0.0001,'beamRadius_y',0.0001,... %please choose a reasonable values in y
});
%% ______________________________detector properties________________________________
obj.detectors = rmfield(obj.detectors,fieldnames(obj.detectors)); %delete default detectors
obj.detectors.IR.plotIntegratedProfiles=1;
obj.detectors.IR.polarization='e';
obj.detectors.IR.ftlim=[3e8/1.1e-6,3e8/0.96e-6];
obj.detectors.IR.alpha=0;
obj.detectors.SHG.plotIntegratedProfiles=1;
obj.detectors.SHG.polarization='e';
obj.detectors.SHG.ftlim=[3e8/0.55e-6,3e8/0.48e-6];
obj.detectors.SHG.alpha=0;
%% ______________________________run simulation__________________________________
[E_ftfxfy_o,E_ftfxfy_e]=run(obj,{'pulse1'});
% E(i)=obj.simResults.SHG.PulseEnergy(end)
% figure(111),plot(pol(1:i),E,'.-'),drawnow
% end
Tino Lang