plotInLoop.m
%% ___________________create a new instance of class ch23d_________________________
obj = chi3D('tag','PPLN DFG example','inloopFun','plotInLoop(obj,Eftfxfy_e,k)');
%% ___________________computational parameters_____________________________________
obj( 'Nx',32,'xWindow',2e-3,...
'Ny',1 ,'yWindow',2e-3,... %use Ny=1 for 2+1D, Ny=2^N for 3+1d
'Nt',2048, 'tWindow',3e-12,'shiftFreqWindow',0,...
'Nz',1600, 'propagationLength', 5e-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=31.1512e-6;
stepsEachPeriode=round(obj.simProp.Nz/(obj.simProp.propagationLength/PP));
Nz=round(obj.simProp.propagationLength/(PP))*stepsEachPeriode; %find number of periodes Nz within the propagation length
deff1=19.5e-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.05; %apodization length
% chirp = 0.3;%periodic poling chirp
% chirpAD = 4*chirp;% chirp of periodic chirp in apodization range
% 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-stepsEachPeriode+1:end)=stepSize(end-stepsEachPeriode+1:end)-(sum(stepSize)-obj.simProp.propagationLength)/stepsEachPeriode; %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______________________________
R=0.7e-3;
obj({ 'pulse1','EorI',2e-6,'polarization','e','centerWavelength',1.054e-06,...
'pulseDuration',70e-15,'beamShape_t','gauss',...
'GDD',-25000e-30,...
'beamRadius_x',R,'beamRadius_y',R,... %please choose a reasonable values in y
});
obj({ 'pulse2','EorI',0.5e-9,'polarization','e',... 'centerWavelength',1.600e-06,'pulseDuration',15e-15,'beamShape_t','gauss',...
'GDD',2000e-30,...
'beamRadius_x',R,'beamRadius_y',R,... %please choose a reasonable values in y
});
%% ______________________________detector properties________________________________
obj.detectors = rmfield(obj.detectors,fieldnames(obj.detectors)); %delete default detectors
obj.detectors.pump.plotIntegratedProfiles=1;
obj.detectors.pump.polarization='e';
obj.detectors.pump.ftlim=[3e8/1.1e-6,3e8/1e-6];
obj.detectors.pump.alpha=0;
obj.detectors.signal.plotIntegratedProfiles=1;
obj.detectors.signal.polarization='e';
obj.detectors.signal.ftlim=[3e8/2.104e-6,3e8/1.1e-6];
obj.detectors.signal.alpha=0;
obj.detectors.idler.plotIntegratedProfiles=1;
obj.detectors.idler.polarization='e';
obj.detectors.idler.ftlim=[3e8/8e-6,3e8/2.104e-6];
obj.detectors.idler.alpha=0;
%% _________________________import seed spectrum ____________________
data=importdata('spectrum_seed.txt');
I_lam_start=obj.interpSpectrum(data.data(:,1),data.data(:,2));
%% ______________________________run simulation__________________________________
[~,E_ftfxfy_e]=run(obj,{'pulse1'},{'pulse2','Spectrum',I_lam_start});
Tino Lang