├── FreeOpticalProject ├── Accurate_Short_Fiber_Simulations │ ├── Examples │ │ ├── Fig_1a_1b_and_3.m │ │ ├── Fig_4d.m │ │ ├── Fig_6_c.m │ │ ├── Fig_6a.m │ │ └── Fig_6b.m │ ├── Saved_Files │ │ ├── beta0s400B.mat │ │ └── tetas400B.mat │ ├── Solvers_NLSE_with_PMD │ │ ├── SSFM_for_CNLSE_withPMD.m │ │ └── SSFM_for_CNLSE_withPMD_without_ER_terms.m │ └── Visularizers │ │ ├── createFig1a.m │ │ ├── createFig1b.m │ │ ├── createFig3.m │ │ ├── createFig6b.m │ │ └── createFig6c.m ├── Broadband_FWM_products │ ├── Fig1.m │ ├── UPM.m │ ├── plotwav.m │ └── resolution.m ├── Dynamic_EDFA.mdl ├── Isotropic_Fiber_Simulations │ ├── Examples │ │ ├── Fig2a.m │ │ ├── Fig2b.m │ │ ├── Fig2c.m │ │ ├── Fig3a.m │ │ ├── Fig3b.m │ │ ├── Fig4a.m │ │ └── Fig4b.m │ ├── Solvers │ │ └── SSFM_for_CNLSE.m │ └── Visualizers │ │ └── createfigure.m ├── Optimized_GNLSE_Solvers │ ├── IP_CQEM_FD.m │ ├── IP_CQEM_TD.m │ ├── IP_LEM_FD.m │ ├── IP_LEM_TD.m │ ├── Supercontinuum_Generation.asv │ └── Supercontinuum_Generation.m ├── Rieznik_Thesis_Generate_Figures │ ├── Figures │ │ ├── Figure_11_a.m │ │ ├── Figure_11_b.m │ │ ├── Figure_11_c.m │ │ ├── Figure_12_a.m │ │ ├── Figure_12_b.m │ │ ├── Figure_13_a.m │ │ ├── Figure_13_b.m │ │ ├── Figure_15d.m │ │ ├── Figure_16_a.m │ │ ├── Figure_16_b.m │ │ ├── Figure_16_c.m │ │ ├── Figure_3_Second_Order_Soliton.m │ │ ├── Figure_4_First_Order_Soliton_Collision.m │ │ ├── Figure_5a_WDM_System.m │ │ ├── Figure_5b_WDM_System.m │ │ └── Figures_8_e_14.m │ ├── Saved_Files │ │ ├── analitical_8_channels_10km.mat │ │ ├── analitical_8_channels_50km.mat │ │ ├── analitical_collision.mat │ │ ├── beta0s400B.mat │ │ ├── input_8_channels.mat │ │ └── tetas400B.mat │ ├── Solvers │ │ ├── LEM_SSFM.m │ │ ├── NLPR_SSFM.m │ │ ├── SSFM_for_CNLSE.m │ │ ├── SSFM_for_CNLSE_withPMD.m │ │ ├── SSFM_for_CNLSE_withPMD_without_ER_terms.m │ │ ├── UPM_SSFM.m │ │ └── WOM_SSFM.m │ └── Visualizers │ │ ├── createFig1a.m │ │ ├── createFig1b.m │ │ ├── createFig3.m │ │ ├── createFig6b.m │ │ ├── createFig6c.m │ │ └── createfigure.m └── Soliton_In_PCF │ ├── Frequencies_for_beta2.mat │ ├── SSFM_with_Raman.m │ ├── SSFM_with_Raman_ASE.m │ ├── SSFM_with_Raman_ASE.m~ │ ├── Soliton_in_PCF.m │ ├── Soliton_in_PCF.m~ │ ├── Soliton_in_PCF_betaw.m │ ├── UPM_SSFM.m │ └── beta2w_Thz.mat ├── NLSEmagic ├── NLSE1D_TAKE_STEPS_2SHOC.mexw32 ├── NLSE1D_TAKE_STEPS_2SHOC_CUDA_D.mexw32 ├── NLSE1D_TAKE_STEPS_2SHOC_CUDA_F.mexw32 ├── NLSE1D_TAKE_STEPS_2SHOC_F.mexw32 ├── NLSE1D_TAKE_STEPS_CD.mexw32 ├── NLSE1D_TAKE_STEPS_CD_CUDA_D.mexw32 ├── NLSE1D_TAKE_STEPS_CD_CUDA_F.mexw32 ├── NLSE1D_TAKE_STEPS_CD_F.mexw32 ├── NLSEmagic1D.m ├── README_B.txt └── getCudaInfo.mexw32 ├── README.md ├── Thumbs.db ├── matlab.mat ├── ssprop-3.0.1 ├── ChangeLog.txt ├── examples │ ├── README.txt │ ├── allexamples.m │ ├── fig3_1.asv │ ├── fig3_1.m │ ├── fig3_6.m │ ├── fig3_7.m │ ├── fig4_10.asv │ ├── fig4_10.m │ ├── fig4_11.m │ ├── fig4_12.m │ ├── fig4_14.m │ ├── fig4_15.asv │ ├── fig4_15.m │ ├── fig4_16.m │ ├── fig4_17.asv │ ├── fig4_17.m │ ├── fig4_18.m │ ├── fig4_4.asv │ ├── fig4_4.m │ ├── fig4_5.m │ ├── fig4_7.asv │ ├── fig4_7.m │ ├── fig4_8.m │ ├── fig5_14.m │ ├── fig5_15.m │ ├── fig5_16.m │ ├── fig5_17.m │ ├── fig5_18.m │ ├── fig5_19.m │ ├── fig5_21.m │ ├── fig5_4.m │ ├── fig5_5.m │ ├── fig5_7.m │ ├── fig5_9.asv │ ├── fig5_9.m │ └── splitsteptest.m ├── gpl.txt ├── ssfm.asv ├── ssfm.m ├── ssprop.m ├── sspropc.m ├── sspropv.m ├── sspropvc.m ├── ssrklem.asv ├── ssrklem.m └── tools │ ├── filter_gaus.m │ ├── filter_rect.m │ ├── fwhm.m │ ├── gaussian.m │ ├── ramanhR.asv │ ├── ramanhR.m │ ├── ramanhR_1989.m │ ├── sechpulse.m │ ├── solitonpulse.m │ ├── stokes.m │ └── wspace.m ├── testforfopa.m ├── 光学仿真 ├── 3 │ ├── FOPA.m │ ├── FOPA_ASE.asv │ ├── FOPA_ASE.m │ ├── FOPA_Gain.asv │ ├── FOPA_Gain.m │ ├── OPA_G_Spectrum │ │ ├── Gain.fig │ │ └── Gain.m │ ├── SSFM_Fiber.asv │ └── SSFM_Fiber.m ├── 4 │ ├── ASE_Filter.asv │ ├── ASE_Filter.m │ ├── EDFAs Dynamic │ │ ├── Analytical solution for the dynamic behavior of EDFA.pdf │ │ └── Dynamic_EDFA.mdl │ ├── OSA_Resol.m │ ├── Test_OSA.m │ └── modInt.m └── 5 │ ├── AML Dispersion │ ├── Dispersion.m │ ├── Main.m │ ├── SSFM_SMF.m │ ├── amp_simp1.m │ ├── filter_gaus.m │ ├── fwhm.m │ ├── gain_saturated.m │ ├── modInt.m │ ├── modInt_theory.m │ └── walkoff.m │ ├── Active Mode-Locking │ ├── AmpSimpNonoise.m │ ├── MLLsimple.m │ ├── MLLsimpleDetune.m │ ├── amp_simp.m │ ├── filter_gaus.m │ ├── fwhm.m │ ├── gain_saturated.m │ ├── modInt.m │ └── modInt_theory.m │ ├── CWFOPO │ ├── FOPO.m │ ├── GainS.m │ ├── SSFM_FOPA.m │ ├── SSFM_SMF.m │ ├── filter_gaus.m │ ├── fwhm.m │ ├── modInt.m │ ├── modInt_theory.m │ └── walkoff.m │ └── PulsedFOPO │ ├── FOPA.m │ ├── FOPO.m │ ├── SSFM_DCF.m │ ├── SSFM_FOPA.m │ ├── SSFM_SMF.m │ ├── XPM_FOPO.m │ └── fwhm.m ├── 光谱仪输出图片处理 ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png ├── 7.png ├── 8.png ├── imageprocess.m └── main.m ├── 数值分析 ├── 3.bmp ├── Thumbs.db ├── chapter3.asv ├── chapter3.m ├── chapter3_8.asv ├── chapter3_8.m ├── image_cpr.asv ├── image_cpr.m ├── jacobi_svd.asv ├── jacobi_svd.m ├── lena.bmp ├── lena.jpg ├── lena2.jpg ├── main.asv ├── main.m ├── project1_wxj.m ├── simulation.asv ├── simulation.m ├── simulation2.asv ├── simulation2.m ├── simulation3.asv ├── simulation3.m └── test.m └── 时间透镜 └── yidayixiao_Gausse.m /FreeOpticalProject/Accurate_Short_Fiber_Simulations/Saved_Files/beta0s400B.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Accurate_Short_Fiber_Simulations/Saved_Files/beta0s400B.mat -------------------------------------------------------------------------------- /FreeOpticalProject/Accurate_Short_Fiber_Simulations/Saved_Files/tetas400B.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Accurate_Short_Fiber_Simulations/Saved_Files/tetas400B.mat -------------------------------------------------------------------------------- /FreeOpticalProject/Accurate_Short_Fiber_Simulations/Solvers_NLSE_with_PMD/SSFM_for_CNLSE_withPMD_without_ER_terms.m: -------------------------------------------------------------------------------- 1 | function [u1x,u1y] = UPMPol(u0x,u0y,dt,dz,nz,alphax,alphay,betapx,betapy,gamma,correlationlength,angles,tetas,beta0s,beta1s); 2 | 3 | nt = length(u0x); 4 | w = 2*pi*[(0:nt/2-1),(-nt/2:-1)]'/(dt*nt); 5 | 6 | linearoperatorx = -alphax/2; 7 | for ii = 0:length(betapx)-1; 8 | linearoperatorx = linearoperatorx - j*betapx(ii+1)*(w).^ii/factorial(ii); 9 | end 10 | 11 | linearoperatory = -alphay/2; 12 | for ii = 0:length(betapy)-1; 13 | linearoperatory = linearoperatory - j*betapy(ii+1)*(w).^ii/factorial(ii); 14 | end 15 | 16 | u1x = u0x; 17 | ufftx = fft(u0x); 18 | 19 | u1y = u0y; 20 | uffty = fft(u0y); 21 | 22 | fiberlength = nz*dz; 23 | propagedlength =0; 24 | auxlength = 0; 25 | 26 | jj=1; 27 | 28 | fprintf(1, '\nSimulation running... '); 29 | while propagedlength < fiberlength, 30 | % the next "if" and the variable "auxlenght" are used to check 31 | % if the correlation length was riched 32 | if (auxlength >= correlationlength | auxlength ==0), 33 | auxlength = 0; 34 | 35 | 36 | angle = angles(jj); 37 | teta = tetas(jj); 38 | ufftxaux = ufftx * cos(teta) - uffty * sin(teta)*exp(-i*angle); 39 | ufftyaux = ufftx * sin(teta)*exp(i*angle) + uffty * cos(teta); 40 | ufftx = ufftxaux; 41 | uffty = ufftyaux; 42 | 43 | betapx(1) = -beta0s(jj); % observe that b0x and b0y are defined such that b0x = -b0y = -beta0s(1) 44 | betapy(1) = beta0s(jj); 45 | betapx(2) = -beta1s(jj); % tha same as above for beta1x and beta1y 46 | betapy(2) = beta1s(jj); 47 | 48 | jj=jj+1; % I increase the value of jj so in the next time the correlation length is reached, different pseudo-random variables are taken 49 | 50 | linearoperatorx = -alphax/2; % in the lines bellow I define the linear operators again using the new beta0s and beta1s 51 | for ii = 0:length(betapx)-1; 52 | linearoperatorx = linearoperatorx - j*betapx(ii+1)*(w).^ii/factorial(ii); 53 | end 54 | linearoperatory = -alphay/2; 55 | for ii = 0:length(betapy)-1; 56 | linearoperatory = linearoperatory - j*betapy(ii+1)*(w).^ii/factorial(ii); 57 | end 58 | end % here ends the "if" part that is done just at each correlation length. 59 | 60 | %Performing the SSFM with the given dz 61 | %------linear propagation until dz/2------------ 62 | halfstepx = exp(linearoperatorx*dz/2); 63 | uhalfx = ifft(halfstepx.*ufftx); 64 | 65 | halfstepy = exp(linearoperatory*dz/2); 66 | uhalfy = ifft(halfstepy.*uffty); 67 | 68 | %------non linear propagation in dz------------ 69 | u1x = uhalfx .* exp(-j*gamma*( (abs(uhalfx).^2) + ((2/3)*abs(uhalfy).^2) )*dz); 70 | u1y = uhalfy .* exp(-j*gamma*( (abs(uhalfy).^2) + ((2/3)*abs(uhalfx).^2) )*dz); 71 | 72 | %------linear propagation from dz until dz------------ 73 | ufftx = halfstepx.*fft(u1x); 74 | uffty = halfstepy.*fft(u1y); 75 | %----------------------------------------------------- 76 | auxlength = auxlength + dz; 77 | propagedlength = propagedlength + dz; 78 | fprintf(1, '\b\b\b\b\b\b%5.1f%%', propagedlength * 100.0 /fiberlength ); 79 | end 80 | 81 | u1x = ifft(ufftx); 82 | u1y = ifft(uffty); 83 | 84 | -------------------------------------------------------------------------------- /FreeOpticalProject/Accurate_Short_Fiber_Simulations/Visularizers/createFig1a.m: -------------------------------------------------------------------------------- 1 | function createfigure(x1, y1, y2) 2 | %CREATEFIGURE(X1,Y1,Y2) 3 | % X1: vector of x data 4 | % Y1: vector of y data 5 | % Y2: vector of y data 6 | 7 | % Auto-generated by MATLAB on 18-Oct-2007 10:54:52 8 | 9 | %% Create figure 10 | figure1 = figure('FileName','C:\Documents and Settings\pessoal\Meus documentos\ssf\IncludingPolarization\Short_Fiber_OPAs\Article\Definitivos\Fig1a.fig'); 11 | 12 | %% Create axes 13 | axes1 = axes(... 14 | 'FontSize',12,... 15 | 'FontWeight','bold',... 16 | 'XGrid','on',... 17 | 'XTick',[0 40 80 120 160 200],... 18 | 'YGrid','on',... 19 | 'Parent',figure1); 20 | xlabel(axes1,'fiber length (m)'); 21 | ylabel(axes1,'angle rotation (rad)'); 22 | hold(axes1,'all'); 23 | 24 | %% Create plot 25 | plot1 = plot(x1,y1,'LineWidth',3); 26 | 27 | %% Create plot 28 | plot2 = plot(... 29 | x1,y2,... 30 | 'Color',[0.8314 0.8157 0.7843],... 31 | 'LineWidth',3); 32 | 33 | -------------------------------------------------------------------------------- /FreeOpticalProject/Accurate_Short_Fiber_Simulations/Visularizers/createFig1b.m: -------------------------------------------------------------------------------- 1 | function createfigure(x1, y1, y2) 2 | %CREATEFIGURE(X1,Y1,Y2) 3 | % X1: vector of x data 4 | % Y1: vector of y data 5 | % Y2: vector of y data 6 | 7 | % Auto-generated by MATLAB on 24-Oct-2007 00:58:04 8 | 9 | %% Create figure 10 | figure1 = figure('FileName','C:\Documents and Settings\pessoal\Meus documentos\ssf\IncludingPolarization\Short_Fiber_OPAs\Article\Definitivos\Fig1b.fig'); 11 | 12 | %% Create axes 13 | axes1 = axes(... 14 | 'FontSize',12,... 15 | 'FontWeight','bold',... 16 | 'XGrid','on',... 17 | 'XTick',[0 40 80 120 160 200],... 18 | 'YGrid','on',... 19 | 'Parent',figure1); 20 | xlabel(axes1,'fiber length(m)'); 21 | ylabel(axes1,'\Deltan'); 22 | hold(axes1,'all'); 23 | 24 | %% Create plot 25 | plot1 = plot(x1,y1,'LineWidth',3); 26 | 27 | %% Create plot 28 | plot2 = plot(... 29 | x1,y2,... 30 | 'Color',[1 0 0],... 31 | 'LineStyle','--',... 32 | 'LineWidth',3); 33 | 34 | -------------------------------------------------------------------------------- /FreeOpticalProject/Accurate_Short_Fiber_Simulations/Visularizers/createFig3.m: -------------------------------------------------------------------------------- 1 | function createFig3(x1, y1, y2) 2 | %CREATEFIGURE(X1,Y1,Y2) 3 | % X1: vector of x data 4 | % Y1: vector of y data 5 | % Y2: vector of y data 6 | 7 | % Auto-generated by MATLAB on 18-Oct-2007 10:56:50 8 | 9 | %% Create figure 10 | figure1 = figure('FileName','C:\Documents and Settings\pessoal\Meus documentos\ssf\IncludingPolarization\Short_Fiber_OPAs\Article\Definitivos\Fig3.fig'); 11 | 12 | %% Create axes 13 | axes1 = axes(... 14 | 'FontSize',12,... 15 | 'FontWeight','bold',... 16 | 'XTick',[1470 1500 1540 1580 1620 1640],... 17 | 'YTick',[0 2 4 6 8 10 12 14 16 18],... 18 | 'Parent',figure1); 19 | xlim(axes1,[1470 1640]); 20 | xlabel(axes1,'\lambda (nm)'); 21 | ylabel(axes1,'Gain (dB)'); 22 | grid(axes1,'on'); 23 | hold(axes1,'all'); 24 | 25 | %% Create plot 26 | plot1 = plot(x1,y1,'LineWidth',3); 27 | 28 | %% Create plot 29 | plot2 = plot(... 30 | x1,y2,... 31 | 'Color',[0.8314 0.8157 0.7843],... 32 | 'LineWidth',3); 33 | 34 | -------------------------------------------------------------------------------- /FreeOpticalProject/Accurate_Short_Fiber_Simulations/Visularizers/createFig6b.m: -------------------------------------------------------------------------------- 1 | function createFig6b(x1, y1, y2) 2 | %CREATEFIGURE(X1,Y1,Y2) 3 | % X1: vector of x data 4 | % Y1: vector of y data 5 | % Y2: vector of y data 6 | 7 | % Auto-generated by MATLAB on 18-Oct-2007 10:56:50 8 | 9 | %% Create figure 10 | figure1 = figure('FileName','C:\Documents and Settings\pessoal\Meus documentos\ssf\IncludingPolarization\Short_Fiber_OPAs\Article\Definitivos\Fig3.fig'); 11 | 12 | %% Create axes 13 | axes1 = axes(... 14 | 'FontSize',12,... 15 | 'FontWeight','bold',... 16 | 'XTick',[1400:50:1700],... 17 | 'YTick',[0 2 4 6 8 10 12 14 16 18],... 18 | 'Parent',figure1); 19 | xlim(axes1,[1400 1700]); 20 | xlabel(axes1,'\lambda (nm)'); 21 | ylabel(axes1,'Gain (dB)'); 22 | grid(axes1,'on'); 23 | hold(axes1,'all'); 24 | 25 | %% Create plot 26 | plot1 = plot(x1,y1,'LineWidth',3); 27 | 28 | %% Create plot 29 | plot2 = plot(... 30 | x1,y2,... 31 | 'Color',[0.8314 0.8157 0.7843],... 32 | 'LineWidth',3); 33 | 34 | -------------------------------------------------------------------------------- /FreeOpticalProject/Accurate_Short_Fiber_Simulations/Visularizers/createFig6c.m: -------------------------------------------------------------------------------- 1 | function createFig6b(x1, y1, y2) 2 | %CREATEFIGURE(X1,Y1,Y2) 3 | % X1: vector of x data 4 | % Y1: vector of y data 5 | % Y2: vector of y data 6 | 7 | % Auto-generated by MATLAB on 18-Oct-2007 10:56:50 8 | 9 | %% Create figure 10 | figure1 = figure('FileName','C:\Documents and Settings\pessoal\Meus documentos\ssf\IncludingPolarization\Short_Fiber_OPAs\Article\Definitivos\Fig3.fig'); 11 | 12 | %% Create axes 13 | axes1 = axes(... 14 | 'FontSize',12,... 15 | 'FontWeight','bold',... 16 | 'XTick',[1300:100:1850],... 17 | 'YTick',[0 2 4 6 8 10 12 14 16 18],... 18 | 'Parent',figure1); 19 | xlim(axes1,[1300 1850]); 20 | xlabel(axes1,'\lambda (nm)'); 21 | ylabel(axes1,'Gain (dB)'); 22 | grid(axes1,'on'); 23 | hold(axes1,'all'); 24 | 25 | %% Create plot 26 | plot1 = plot(x1,y1,'LineWidth',3); 27 | 28 | %% Create plot 29 | plot2 = plot(... 30 | x1,y2,... 31 | 'Color',[0.8314 0.8157 0.7843],... 32 | 'LineWidth',3); 33 | 34 | -------------------------------------------------------------------------------- /FreeOpticalProject/Broadband_FWM_products/Fig1.m: -------------------------------------------------------------------------------- 1 | clear all 2 | format long e 3 | 4 | fprintf(1,'\nStart "Simulation of broadband FWM cascade"'); 5 | 6 | % CONSTANTS 7 | 8 | c = 299792458; % speed of light (m/s) 9 | 10 | % NUMERICAL PARAMETERS 11 | 12 | nt = 2^15; % number of points in FFT 13 | dt = 200/nt; % time step (ps) 14 | L = 3; % fiber length (m) CHANGE HERE TO GENERATE THE SPECTRA IN FIG1a!! 15 | 16 | % OPTICAL PARAMETERS 17 | gamma = 10/1000; % W^-1 m^-1 18 | S0 = 0.075/1000; % ps/nm^2/m CHANGE HERE TO GENERATE THE SPECTRA IN FIG1b!! 19 | 20 | lamdapump1 = 1555; % nm 21 | lamdapump2 = 1563; % nm 22 | lamdazero = 1550; % nm 23 | FrequencyZeroForSimulartion=(c/lamdapump1+c/lamdapump2)/2; % Ghz 24 | LamdaZeroForSimulartion=c/FrequencyZeroForSimulartion; % Ghz 25 | 26 | beta1 = 0; % ps/m 27 | beta2 = 0; % ps^2/m 28 | beta3 = S0*lamdazero^4/(4*pi^2*(c/1000)^2); % ps^3/m 29 | beta4 = 1e-7; % ps^4/m 30 | alpha = 0; % 1/m 31 | 32 | DeltaW = 2*pi*c*(lamdazero-LamdaZeroForSimulartion)/lamdazero/LamdaZeroForSimulartion; % GHz 33 | 34 | beta2 = beta3*DeltaW/1000; % ps^2/m 35 | 36 | % CALCULATED QUANTITIES 37 | 38 | T = nt*dt; % FFT window size (ps) 39 | t = ((1:nt)'-(nt+1)/2)*dt; % vector of t values (ps) 40 | w = 2*pi*[(0:nt/2-1),(-nt/2:-1)]'/T; % vector of w values (rad/ps) 41 | v = 1000*[(0:nt/2-1),(-nt/2:-1)]'/T; % vector of v values (GHz) 42 | vs = fftshift(v); % swap halves for plotting 43 | vw = [c ./ (v + c/LamdaZeroForSimulartion)]'; % wavelengths (nm) 44 | 45 | betap = [0 beta1 beta2 beta3 beta4]'; % polynomial beta coefs 46 | 47 | %STARTING FIELD 48 | fprintf(1,'\n\n\nConstructing input field'); 49 | 50 | %------pumps------------------------------------------------------------ 51 | power1 = 100; % W 52 | power2 = 100; % W 53 | up1 = (power1*ones(nt,1)).^0.5; % W^0.5 54 | up2 = (power2*ones(nt,1)).^0.5; % W^0.5 55 | 56 | %--------noise---------------------------------------------------------- 57 | 58 | noise_powerx= 1e-6;% in W (change here to change the noise power) 59 | noise_resx= 12.5;% in GHz (change here to change the bandwidth at which the noise power is given) 60 | noise = randn(length(t),1).*(noise_powerx*1000/dt/noise_resx).^0.5.*exp(i*2*pi*rand(length(t),1)); 61 | 62 | 63 | %-------Construct input field: noise and pumps------------------------------------------- 64 | 65 | signalandpumpfrequencies = c ./[lamdapump1 lamdapump2 LamdaZeroForSimulartion]; 66 | 67 | deltavi1 = signalandpumpfrequencies(3) - signalandpumpfrequencies(1); 68 | deltavi2 = signalandpumpfrequencies(3)-signalandpumpfrequencies (2); 69 | 70 | [aux1a,aux1b] = min(abs(v - deltavi1)); 71 | [aux2a,aux2b] = min(abs(v - deltavi2)); 72 | 73 | u0 = noise + up1.*exp(-j*2*pi*1e-3*v(aux1b)*t) + up2.*exp(-j*2*pi*1e-3*(v(aux1b)+ 1000)*t); 74 | 75 | %---------------------------------------------------------------------- 76 | 77 | %PROPAGATE 78 | fprintf(1,'\n\nProapagation using the SSFM'); 79 | tx=cputime; 80 | u = UPM(u0,dt,L,1,alpha,betap,gamma,1e-4); 81 | fprintf(1,'\n\nSSFM completed in (%.2f s)\n',cputime-tx); 82 | 83 | 84 | %----OSA output ----------------------------------- 85 | res =12.5; %RB in GHz 86 | [slotfreq,powerinres] = resolution(u,vs,res,nt,dt); 87 | 88 | figure(1) 89 | plotwav(powerinres.^0.5,LamdaZeroForSimulartion,slotfreq,1000,LamdaZeroForSimulartion) -------------------------------------------------------------------------------- /FreeOpticalProject/Broadband_FWM_products/UPM.m: -------------------------------------------------------------------------------- 1 | function u1 = UPM(u0,dt,dz,nz,alpha,betap,gamma,tol); 2 | 3 | 4 | % This function solves the nonlinear Schrodinger equation for 5 | % pulse propagation in an optical fiber using the split-step 6 | % Fourier method described in: 7 | % 8 | % A. A. Rieznik, T. Tolisano, F. A. Callegari, D. F. Grosz, and H. L. Fragnito, 9 | % "Uncertainty relation for the optimization of optical-fiber transmission 10 | % systems simulations," Opt. Express 13, 3822-3834 (2005). 11 | % http://www.opticsexpress.org/abstract.cfm?URI=OPEX-13-10-3822 12 | % 13 | % USAGE 14 | % 15 | % u1 = ssprop(u0,dt,dz,nz,alpha,betap,gamma); 16 | % u1 = ssprop(u0,dt,dz,nz,alpha,betap,gamma,tol); 17 | % 18 | % INPUT 19 | % 20 | % u0 - starting field amplitude (vector) 21 | % dt - time step 22 | % dz - propagation stepsize 23 | % nz - number of steps to take, ie, ztotal = dz*nz 24 | % alpha - power loss coefficient, ie, P=P0*exp(-alpha*z) 25 | % betap - dispersion polynomial coefs, [beta_0 ... beta_m] 26 | % gamma - nonlinearity coefficient 27 | % tol - convergence tolerance (default = 1e-5) 28 | % 29 | % OUTPUT 30 | % 31 | % u1 - field at the output 32 | % 33 | % NOTES The dimensions of the input and output quantities can 34 | % be anything, as long as they are self consistent. E.g., if 35 | % |u|^2 has dimensions of Watts and dz has dimensions of 36 | % meters, then gamma should be specified in W^-1*m^-1. 37 | % Similarly, if dt is given in picoseconds, and dz is given in 38 | % meters, then beta(n) should have dimensions of ps^(n-1)/m. 39 | 40 | if (nargin<8) 41 | tol = 1e-3; 42 | end 43 | 44 | nt = length(u0); 45 | w = 2*pi*[(0:nt/2-1),(-nt/2:-1)]'/(dt*nt); 46 | 47 | linearoperator = -alpha/2; 48 | for ii = 0:length(betap)-1; 49 | linearoperator = linearoperator - j*betap(ii+1)*(w).^ii/factorial(ii); 50 | end 51 | 52 | lineraoperatorwithoutloss = linearoperator + alpha/2; 53 | 54 | u1 = u0; 55 | ufft = fft(u0); 56 | 57 | fiberlength = nz*dz; 58 | propagedlength =0; 59 | 60 | fprintf(1, '\nSimulation running... '); 61 | 62 | 63 | while propagedlength < fiberlength, 64 | 65 | Et = sum(abs(u1).^2); 66 | meanN = sum( gamma*(abs(u1).^4) ) / Et; 67 | aux = ( gamma * (abs(u1).^2) - meanN ).^2; 68 | deltaN = sqrt(sum( aux.*abs(u1).^2 ) / Et); 69 | 70 | Ef = sum(abs(ufft).^2); 71 | meanD = sum( j*lineraoperatorwithoutloss.*(abs(ufft).^2) ) / Ef; 72 | aux = ( j*lineraoperatorwithoutloss - meanD ).^2; 73 | deltaD = sqrt(sum( aux.*abs(ufft).^2 ) / Ef); 74 | 75 | 76 | dz = (tol^(1/2))*sqrt(1 / (deltaD*deltaN)); 77 | 78 | if (dz + propagedlength) > fiberlength, 79 | dz = fiberlength - propagedlength; 80 | end 81 | 82 | halfstep = exp(linearoperator*dz/2); 83 | uhalf = ifft(halfstep.*ufft); 84 | 85 | u1 = uhalf .* exp(-j*gamma*(abs(uhalf).^2 )*dz); 86 | ufft = halfstep.*fft(u1); 87 | 88 | propagedlength = propagedlength + dz; 89 | fprintf(1, '\b\b\b\b\b\b%5.1f%%', propagedlength * 100.0 /fiberlength ); 90 | end 91 | 92 | ux = ifft(ufft); 93 | u1=ux; 94 | 95 | 96 | -------------------------------------------------------------------------------- /FreeOpticalProject/Broadband_FWM_products/plotwav.m: -------------------------------------------------------------------------------- 1 | function f = plotwav(u,lambda,v,range,vwcenterplot) 2 | 3 | % This function graphs u^2 (in dBm) vs wavelenght for a given 4 | % value of wavelenght for the zero spectral component 5 | % of u (lambda). The frequencies and v are required. 6 | % 7 | % INPUTS 8 | % 9 | % u - input field (W^0.5) 10 | % lambda - wavelength of the zero frequency (nm) 11 | % v - frequencies at which u is given (GHz) 12 | % range - range for plot (nm) 13 | % vwcenterplot - center wavelength for plot (nm) 14 | % 15 | % OUTPUTS 16 | % Plot wavelength vs u^2 (nm vs dBm) 17 | % Exported files of input and output signal 18 | 19 | c = 299792458; % speed of light (m/s) 20 | vw = [c ./ (v + c/lambda)]'; % wavelengths (nm) 21 | nt = length(u); 22 | 23 | aux = vw - vwcenterplot; 24 | iv = find( abs(aux) < range); 25 | plot(vw(iv),10*log10( 1000 * u(iv).^2),'.-' ); 26 | grid on; 27 | xlabel ('\lambda (nm)'); 28 | ylabel ('|U(z,\nu)|^2 (dBm)'); 29 | title ('Spectra'); -------------------------------------------------------------------------------- /FreeOpticalProject/Broadband_FWM_products/resolution.m: -------------------------------------------------------------------------------- 1 | function [slotfreq,powerinres] = resolution(u0,vs,res,nt,dt) 2 | 3 | % This function gives the total (sum) of u0 in a badwidth res. 4 | % It also gives the centerfrequency of the interval at which 5 | % the sum was done(slotfreq). The frequency 0 is always forced 6 | % to appear in alotfreq and the other frequencies are at steps 7 | % +res and -res from 0. vs are the frequencies of fft(u0). 8 | % 9 | % INPUTS 10 | % 11 | % u0 - initial field (W^.5) 12 | % vs - frequencies of fft(u0) in Ghz 13 | % res - the required resolution bandwidth (Ghz) 14 | % nt - length(u0) 15 | % dt - distance between two sucesive points 16 | % 17 | % OUTPUTS 18 | % 19 | % slotfreq - center frequencies of each interval in which the sum is done (GHz) 20 | % powerinres - total power (fft(u0))^2 of each interval with bandwidth res (W) 21 | 22 | pointsperslot = res*nt*dt/1000; 23 | spectralpower = fftshift((abs(fft(u0)).^2)/nt^2); 24 | slotfreq = [(0:res:max(vs)),(-res:-res:min(vs))]; % vector of center freq of each slot (GHz) 25 | slotfreq = sort(slotfreq); 26 | 27 | if min(vs) < min(slotfreq)-res/2 28 | startcountat = max(find(vs < (min(slotfreq)-res/2))); 29 | else 30 | aux1=[]; 31 | for i=2:length(slotfreq)-1, 32 | aux1(i-1) = slotfreq(i); 33 | end 34 | slotfreq = aux1; 35 | startcountat = max(find(vs < (min(slotfreq)-res/2))); 36 | end 37 | 38 | powerinres=[]; 39 | aux=0; 40 | for j = 0:length(slotfreq)-1, 41 | for i =1:floor(pointsperslot), 42 | aux = aux + spectralpower(startcountat + floor(j*pointsperslot) + i); 43 | end 44 | aux = aux + (pointsperslot - floor(pointsperslot))*spectralpower(startcountat + floor(j*pointsperslot)); 45 | powerinres(j+1) = aux; 46 | aux=0; 47 | end -------------------------------------------------------------------------------- /FreeOpticalProject/Isotropic_Fiber_Simulations/Solvers/SSFM_for_CNLSE.m: -------------------------------------------------------------------------------- 1 | function [u1x,u1y] = SSFM_for_CNLSE(u0x,u0y,dt,dz,nz,alphax,alphay,betapx,betapy,gamma); 2 | 3 | nt = length(u0x); % nt is the number of point 4 | w = 2*pi*[(0:nt/2-1),(-nt/2:-1)]'/(dt*nt); %constructing used frequencies 5 | 6 | linearoperatorx = -alphax/2; % in the lines above are constructed the linear operator in X and Y. Observe that for the 7 | for ii = 0:length(betapx)-1; % first propagation until correlation lenght beta0x=beta0y=0. 8 | linearoperatorx = linearoperatorx - j*betapx(ii+1)*(w).^ii/factorial(ii); 9 | end 10 | 11 | linearoperatory = -alphay/2; 12 | for ii = 0:length(betapy)-1; 13 | linearoperatory = linearoperatory - j*betapy(ii+1)*(w).^ii/factorial(ii); 14 | end 15 | 16 | u1x = u0x; 17 | ufftx = fft(u0x); 18 | 19 | u1y = u0y; 20 | uffty = fft(u0y); 21 | 22 | fiberlength = nz*dz; 23 | propagedlength = 0; 24 | 25 | 26 | fprintf(1, '\nSimulation running... '); 27 | for i=1:nz, 28 | 29 | %Performing the SSFM with the given dz 30 | %------linear propagation until dz/2------------ 31 | halfstepx = exp(linearoperatorx*dz/2); 32 | uhalfx = ifft(halfstepx.*ufftx); 33 | 34 | halfstepy = exp(linearoperatory*dz/2); 35 | uhalfy = ifft(halfstepy.*uffty); 36 | 37 | uhalfxaux = uhalfx; 38 | uhalfx = (uhalfxaux + j*uhalfy)/sqrt(2); % transforming into a CP basis 39 | uhalfy = (uhalfxaux - j*uhalfy)/sqrt(2); % transforming into a CP basis 40 | 41 | 42 | u1x = uhalfx .* exp(-j*gamma*(2/3)*( (abs(uhalfx).^2) + (2*abs(uhalfy).^2) )*dz); % non linear propagation in CP basis 43 | u1y = uhalfy .* exp(-j*gamma*(2/3)*( (abs(uhalfy).^2) + (2*abs(uhalfx).^2) )*dz); % non linear propagation in CP basis 44 | 45 | u1xaux = u1x; 46 | u1x = (u1xaux + u1y)/sqrt(2); % transforming into a LP basis 47 | u1y = -j*(u1xaux - u1y)/sqrt(2); % transforming into a LP basis 48 | 49 | %------linear propagation from dz/2 to dz------------ 50 | ufftx = halfstepx.*fft(u1x); % 51 | uffty = halfstepy.*fft(u1y); 52 | 53 | propagedlength = propagedlength + dz; 54 | propagatededlength = propagedlength ; 55 | fprintf(1, '\b\b\b\b\b\b%5.1f%%', propagedlength * 100.0 /fiberlength ); 56 | 57 | end 58 | 59 | u1x = ifft(ufftx); 60 | u1y = ifft(uffty); 61 | 62 | -------------------------------------------------------------------------------- /FreeOpticalProject/Isotropic_Fiber_Simulations/Visualizers/createfigure.m: -------------------------------------------------------------------------------- 1 | function createfigure(x1, y1, y2) 2 | %CREATEFIGURE(X1,Y1,Y2) 3 | % X1: vector of x data 4 | % Y1: vector of y data 5 | % Y2: vector of y data 6 | 7 | % Auto-generated by MATLAB on 23-Aug-2007 22:15:52 8 | 9 | %% Create figure 10 | figure1 = figure('FileName','C:\Documents and Settings\pessoal\Meus documentos\ssf\IncludingPolarization\JOSABwithMarhic\Final_Versions_For_Free_Optics\Fig2a.fig'); 11 | 12 | %% Create axes 13 | axes1 = axes(... 14 | 'FontSize',12,... 15 | 'FontWeight','bold',... 16 | 'Parent',figure1); 17 | xlim(axes1,[1470 1630]); 18 | xlabel(axes1,'\lambda (nm)'); 19 | ylabel(axes1,'Gain (dB)'); 20 | grid(axes1,'on'); 21 | hold(axes1,'all'); 22 | 23 | %% Create plot 24 | plot1 = plot(... 25 | x1,y1,... 26 | 'LineWidth',3,... 27 | 'Marker','.'); 28 | 29 | %% Create plot 30 | plot2 = plot(... 31 | x1,y2,... 32 | 'Color',[0.502 0.502 0.502],... 33 | 'LineStyle',':',... 34 | 'LineWidth',4,... 35 | 'MarkerEdgeColor',[0.8314 0.8157 0.7843],... 36 | 'MarkerFaceColor',[0.502 0.502 0.502]); 37 | 38 | -------------------------------------------------------------------------------- /FreeOpticalProject/Optimized_GNLSE_Solvers/Supercontinuum_Generation.asv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Optimized_GNLSE_Solvers/Supercontinuum_Generation.asv -------------------------------------------------------------------------------- /FreeOpticalProject/Optimized_GNLSE_Solvers/Supercontinuum_Generation.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Optimized_GNLSE_Solvers/Supercontinuum_Generation.m -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Figures/Figure_15d.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Figures/Figure_15d.m -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Figures/Figure_16_a.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Figures/Figure_16_a.m -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Figures/Figure_16_b.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Figures/Figure_16_b.m -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Figures/Figure_16_c.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Figures/Figure_16_c.m -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Figures/Figure_3_Second_Order_Soliton.m: -------------------------------------------------------------------------------- 1 | clear all 2 | format long e 3 | fprintf(1,'\n----------------------------------------------'); 4 | fprintf(1,'\nSimulation of Second-Order Soliton Propagation'); 5 | 6 | % PARAMETERS 7 | 8 | A = 2; 9 | ni = 0.44; % ps^-1 10 | gamma = 2.2; % W^-1 * km^-1 11 | duration = 1/ni; %ps 12 | nt = 2^10; % = 1024 13 | beta2 = -0.1; % ps^2/m 14 | time = 50; % ps 15 | dt = time/nt; % ps 16 | t = -time/2:dt:(time/2-dt); % ps 17 | 18 | LD = duration^2/-beta2; 19 | 20 | u0 = (A*ni*sqrt(abs(beta2)/gamma)*sech(ni*t))'; %initial field shape in W^0.5 21 | 22 | alpha = 0; 23 | betap = [0 0 beta2]'; 24 | 25 | 26 | % PR0PAGATE finding numerical solution 27 | tx=cputime; 28 | dz = 10; 29 | tol= 10^-7; %change here to change the achieved accuracy 30 | nz = 8.113617390469509e+001/dz; 31 | fprintf(1,'\n\nProapagation using the SSFM started'); 32 | [u,number_of_FFTs] = UPM_SSFM(u0,dt,dz,nz,alpha,betap,gamma,tol); 33 | % [u,number_of_FFTs] = LEM_SSFM(u0,dt,dz,nz,alpha,betap,gamma,tol); 34 | % [u,number_of_FFTs] = NLPR_SSFM(u0,dt,dz,nz,alpha,betap,gamma,tol); 35 | fprintf(1,'\nSSFM completed in (%.2f s)\n',cputime-tx); 36 | 37 | 38 | 39 | % Calculating analitical solution 40 | LD = ni^-2/-beta2; 41 | period=pi*ni^-2/(2*-beta2); 42 | length = period; 43 | qsi = length/LD; 44 | tao = t/ni^-1; 45 | 46 | num = 4*(cosh(3*tao) + 3*exp(4*j*qsi)*cosh(tao)).*exp(j*qsi/2); 47 | den = cosh(4*tao)+4*cosh(2*tao)+3*cos(4*qsi); 48 | u_analitic = num./den; 49 | u_analitic = u_analitic./(gamma*LD)^0.5; 50 | 51 | 52 | % Calculating global error 53 | globalerror = sqrt(sum(abs(u_analitic-u').^2) / sum(abs(u_analitic).^2)) 54 | 55 | % giving the number of FFTs performed 56 | number_of_FFTs 57 | 58 | fprintf(1,'----------------------------------------------'); 59 | fprintf(1,'\n'); 60 | 61 | % PLOT OUTPUT 62 | figure(1); 63 | plot (t,abs(u0).^2,'*-',t,abs(u).^2,'o-'); 64 | grid on; 65 | xlabel ('t (ps)'); 66 | ylabel ('|u(z,t)|^2 (W)'); 67 | title ('Initial (blue) and Final (green) Pulse Shapes'); 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Figures/Figure_4_First_Order_Soliton_Collision.m: -------------------------------------------------------------------------------- 1 | clear all 2 | format long e 3 | fprintf(1,'\n----------------------------------------------'); 4 | fprintf(1,'\nSimulation of First Order Solitons Collision'); 5 | 6 | % PARAMETERS 7 | A = 1; 8 | ni = 0.44; 9 | gamma = 2.2; 10 | nt = 3072; 11 | beta2 = -0.1; 12 | dt = 400/nt; 13 | t = -200:dt:(200-dt); %time in ps 14 | 15 | u1 = (A*ni*sqrt(abs(beta2)/gamma)*sech(ni*t))'; 16 | u2 = (A*ni*sqrt(abs(beta2)/gamma)*sech(ni*(t-100)))'; 17 | 18 | u0 = u1 + u2.*exp(j*2*pi*1e-3*800*t'); 19 | 20 | alpha = 0; 21 | betap = [0 0 beta2]'; 22 | 23 | % PROPAGATE 24 | tx=cputime; 25 | dz =10; 26 | tol= (10^-5); 27 | nz = 400/dz; 28 | fprintf(1,'\n\nProapagation using the SSFM started'); 29 | [u,number_of_FFTs] = UPM_SSFM(u0,dt,dz,nz,alpha,betap,gamma,tol); 30 | % [u,number_of_FFTs] = LEM_SSFM(u0,dt,dz,nz,alpha,betap,gamma,tol); 31 | % [u,number_of_FFTs] = NLPR_SSFM(u0,dt,dz,nz,alpha,betap,gamma,tol); 32 | fprintf(1,'\nSSFM completed in (%.2f s)\n',cputime-tx); 33 | 34 | % Calculating global error 35 | load analitical_collision; 36 | globalerror = sqrt(sum(abs(analitical_collision-u).^2) / sum(abs(analitical_collision).^2)) 37 | 38 | % giving the number of FFTs performed 39 | number_of_FFTs 40 | 41 | fprintf(1,'----------------------------------------------'); 42 | fprintf(1,'\n'); 43 | 44 | % PLOT OUTPUT 45 | 46 | figure(1); 47 | plot (t,abs(u0).^2,'*-',t,abs(u).^2,'o-'); 48 | grid on; 49 | xlabel ('t (ps)'); 50 | ylabel ('|u(z,t)|^2 (W)'); 51 | title ('Initial (blue) and Final (red) Pulse Shapes'); 52 | -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Figures/Figure_5a_WDM_System.m: -------------------------------------------------------------------------------- 1 | clear all 2 | format long e 3 | fprintf(1,'\n----------------------------------------------'); 4 | fprintf(1,'\nSimulation of 8-channels WDM System'); 5 | 6 | % CONSTANTS 7 | 8 | c = 299792458; % speed of light (m/s) 9 | 10 | % NUMERICAL PARAMETERS 11 | 12 | bits = 2^5; % bits number 13 | nperbit = 2^11; 14 | nt = bits*nperbit; % number of points in FFT 15 | dt = bits*100/nt; % time step (ps) 16 | dz = 10; % distance stepsize (m) 17 | nz = 10000/dz; % number of z-steps 18 | tol = 1e-3; % error tolerance 19 | 20 | % OPTICAL PARAMETERS 21 | 22 | beta2 = -6e-006; % ps^2/m 23 | gamma = 2/1000; % W^-1 m^-1 24 | alpha = 0; 25 | 26 | % CALCULATED QUANTITIES 27 | 28 | T = nt*dt; % FFT window size (ps) 29 | t = ((1:nt)'-(nt+1)/2)*dt; % vector of t values (ps) 30 | w = 2*pi*[(0:nt/2-1),(-nt/2:-1)]'/T; % vector of w values (rad/ps) 31 | v = 1000*[(0:nt/2-1),(-nt/2:-1)]'/T; % vector of v values (GHz) 32 | vs = fftshift(v); % swap halves for plotting 33 | betap = [0 0 0 0.1/1000 -4e-7]'; % polynomial beta coefs 34 | 35 | 36 | load input_8_channels; 37 | u0 = input_8_channels; 38 | 39 | %------------------PROPAG-------------------------------- 40 | %PROPAGATE 41 | 42 | tx=cputime; 43 | tol = 10^-0; %change here to change the achieved accuracy 44 | fprintf(1,'\n\nProapagation using the SSFM started'); 45 | [u,number_of_FFTs] = UPM_SSFM(u0,dt,dz,nz,alpha,betap,gamma,tol); 46 | % [u,number_of_FFTs] = LEM_SSFM(u0,dt,dz,nz,alpha,betap,gamma,tol); 47 | % [u,number_of_FFTs] = WOM_SSFM(u0,dt,dz,nz,alpha,betap,gamma,tol); 48 | fprintf(1,'\nSSFM completed in (%.2f s)\n',cputime-tx); 49 | 50 | % giving the number of FFTs performed 51 | number_of_FFTs 52 | % Calculating global error 53 | load analitical_8_channels_10km; 54 | globalerror = sqrt(sum(abs(analitical_8_channels_10km-u).^2) / sum(abs(analitical_8_channels_10km).^2)) 55 | 56 | fprintf(1,'----------------------------------------------'); 57 | fprintf(1,'\n'); -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Figures/Figure_5b_WDM_System.m: -------------------------------------------------------------------------------- 1 | clear all 2 | format long e 3 | fprintf(1,'\n----------------------------------------------'); 4 | fprintf(1,'\nSimulation of 8-channels WDM System'); 5 | 6 | % CONSTANTS 7 | 8 | c = 299792458; % speed of light (m/s) 9 | 10 | % NUMERICAL PARAMETERS 11 | 12 | bits = 2^5; % bits number 13 | nperbit = 2^11; 14 | nt = bits*nperbit; % number of points in FFT 15 | dt = bits*100/nt; % time step (ps) 16 | dz = 10; % distance stepsize (m) 17 | nz = 50000/dz; % number of z-steps 18 | tol = 1e-3; % error tolerance 19 | 20 | % OPTICAL PARAMETERS 21 | 22 | beta2 = -6e-006; % ps^2/m 23 | gamma = 2/1000; % W^-1 m^-1 24 | alpha = 0; 25 | 26 | % CALCULATED QUANTITIES 27 | 28 | T = nt*dt; % FFT window size (ps) 29 | t = ((1:nt)'-(nt+1)/2)*dt; % vector of t values (ps) 30 | w = 2*pi*[(0:nt/2-1),(-nt/2:-1)]'/T; % vector of w values (rad/ps) 31 | v = 1000*[(0:nt/2-1),(-nt/2:-1)]'/T; % vector of v values (GHz) 32 | vs = fftshift(v); % swap halves for plotting 33 | betap = [0 0 0 0.1/1000 -4e-7]'; % polynomial beta coefs 34 | 35 | 36 | load input_8_channels; 37 | u0 = input_8_channels; 38 | 39 | %------------------PROPAG-------------------------------- 40 | %PROPAGATE 41 | 42 | tx=cputime; 43 | tol = 10^-0; %change here to change the achieved accuracy 44 | fprintf(1,'\n\nProapagation using the SSFM started'); 45 | [u,number_of_FFTs] = UPM_SSFM(u0,dt,dz,nz,alpha,betap,gamma,tol); 46 | % [u,number_of_FFTs] = LEM_SSFM(u0,dt,dz,nz,alpha,betap,gamma,tol); 47 | % [u,number_of_FFTs] = NLPR_SSFM(u0,dt,dz,nz,alpha,betap,gamma,tol); 48 | fprintf(1,'\nSSFM completed in (%.2f s)\n',cputime-tx); 49 | 50 | % giving the number of FFTs performed 51 | number_of_FFTs 52 | % Calculating global error 53 | % load analitical_8_channels_50km; 54 | % globalerror = sqrt(sum(abs(analitical_8_channels_50km-u).^2) / sum(abs(analitical_8_channels_50km).^2)) 55 | load analitical_8_channels_50km; 56 | globalerror = sqrt(sum(abs(analitical_8_channels_50km-u).^2) / sum(abs(analitical_8_channels_50km).^2)) 57 | 58 | fprintf(1,'----------------------------------------------'); 59 | fprintf(1,'\n'); -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Figures/Figures_8_e_14.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Figures/Figures_8_e_14.m -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Saved_Files/analitical_8_channels_10km.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Saved_Files/analitical_8_channels_10km.mat -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Saved_Files/analitical_8_channels_50km.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Saved_Files/analitical_8_channels_50km.mat -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Saved_Files/analitical_collision.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Saved_Files/analitical_collision.mat -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Saved_Files/beta0s400B.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Saved_Files/beta0s400B.mat -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Saved_Files/input_8_channels.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Saved_Files/input_8_channels.mat -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Saved_Files/tetas400B.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Saved_Files/tetas400B.mat -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Solvers/NLPR_SSFM.m: -------------------------------------------------------------------------------- 1 | function [u1,number_of_FFTs] = ssprop(u0,dt,dz,nz,alpha,betap,gamma,tol); 2 | 3 | % This function solves the nonlinear Schrodinger equation for 4 | % pulse propagation in an optical fiber using the split-step 5 | % Fourier method according to the non-linear phase rotation criterion. 6 | % 7 | % USAGE 8 | % 9 | % u1 = ssprop(u0,dt,dz,nz,alpha,betap,gamma); 10 | % u1 = ssprop(u0,dt,dz,nz,alpha,betap,gamma,tol); 11 | % 12 | % INPUT 13 | % 14 | % u0 - starting field amplitude (vector) 15 | % dt - time step 16 | % dz - propagation stepsize 17 | % nz - number of steps to take, ie, ztotal = dz*nz 18 | % alpha - power loss coefficient, ie, P=P0*exp(-alpha*z) 19 | % betap - dispersion polynomial coefs, [beta_0 ... beta_m] 20 | % gamma - nonlinearity coefficient 21 | % tol - convergence tolerance (default = 1e-5) 22 | % 23 | % OUTPUT 24 | % 25 | % u1 - field at the output 26 | % number_of_FFTs - number of Fast Fourier Transforms performed during the 27 | % propagation 28 | % 29 | % NOTES The dimensions of the input and output quantities can 30 | % be anything, as long as they are self consistent. E.g., if 31 | % |u|^2 has dimensions of Watts and dz has dimensions of 32 | % meters, then gamma should be specified in W^-1*m^-1. 33 | % Similarly, if dt is given in picoseconds, and dz is given in 34 | % meters, then beta(n) should have dimensions of ps^(n-1)/m. 35 | 36 | if (nargin<8) 37 | tol = 1e-5; 38 | end 39 | 40 | nt = length(u0); 41 | w = 2*pi*[(0:nt/2-1),(-nt/2:-1)]'/(dt*nt); 42 | 43 | % constructing linear operator 44 | linearoperator = -alpha/2; 45 | for ii = 0:length(betap)-1; 46 | linearoperator = linearoperator - j*betap(ii+1)*(w).^ii/factorial(ii); 47 | end 48 | 49 | u1 = u0; 50 | nf = 0; % parameter to save the number of FFTs 51 | ufft = fft(u0); nf = nf + 1; 52 | 53 | fiberlength = nz*dz; 54 | propagedlength =0; 55 | 56 | % Performig the SSFM according to the NLPR method spatial-step size 57 | fprintf(1, '\nSimulation running... '); 58 | while propagedlength < fiberlength, 59 | dz = tol/(gamma * max(abs(u1).^2)); 60 | if (dz + propagedlength) > fiberlength, 61 | dz = fiberlength - propagedlength; 62 | end 63 | halfstep = exp(linearoperator*dz/2); 64 | uhalf = ifft(halfstep.*ufft); nf = nf + 1; 65 | 66 | u1 = uhalf .* exp(-j*gamma*(abs(uhalf).^2 )*dz); 67 | ufft = halfstep.*fft(u1); nf = nf + 1; 68 | u1 = ifft(ufft); nf = nf + 1; 69 | 70 | propagedlength = propagedlength + dz; 71 | fprintf(1, '\b\b\b\b\b\b%5.1f%%', propagedlength * 100.0 /fiberlength ); 72 | end 73 | 74 | % giving output parameters 75 | u1 = ifft(ufft); 76 | number_of_FFTs = nf; 77 | 78 | -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Solvers/SSFM_for_CNLSE.m: -------------------------------------------------------------------------------- 1 | function [u1x,u1y] = SSFM_for_CNLSE(u0x,u0y,dt,dz,nz,alphax,alphay,betapx,betapy,gamma); 2 | 3 | nt = length(u0x); % nt is the number of point 4 | w = 2*pi*[(0:nt/2-1),(-nt/2:-1)]'/(dt*nt); %constructing used frequencies 5 | 6 | linearoperatorx = -alphax/2; % in the lines above are constructed the linear operator in X and Y. Observe that for the 7 | for ii = 0:length(betapx)-1; % first propagation until correlation lenght beta0x=beta0y=0. 8 | linearoperatorx = linearoperatorx - j*betapx(ii+1)*(w).^ii/factorial(ii); 9 | end 10 | 11 | linearoperatory = -alphay/2; 12 | for ii = 0:length(betapy)-1; 13 | linearoperatory = linearoperatory - j*betapy(ii+1)*(w).^ii/factorial(ii); 14 | end 15 | 16 | u1x = u0x; 17 | ufftx = fft(u0x); 18 | 19 | u1y = u0y; 20 | uffty = fft(u0y); 21 | 22 | fiberlength = nz*dz; 23 | propagedlength = 0; 24 | 25 | 26 | fprintf(1, '\nSimulation running... '); 27 | for i=1:nz, 28 | 29 | %Performing the SSFM with the given dz 30 | %------linear propagation until dz/2------------ 31 | halfstepx = exp(linearoperatorx*dz/2); 32 | uhalfx = ifft(halfstepx.*ufftx); 33 | 34 | halfstepy = exp(linearoperatory*dz/2); 35 | uhalfy = ifft(halfstepy.*uffty); 36 | 37 | uhalfxaux = uhalfx; 38 | uhalfx = (uhalfxaux + j*uhalfy)/sqrt(2); % transforming into a CP basis 39 | uhalfy = (uhalfxaux - j*uhalfy)/sqrt(2); % transforming into a CP basis 40 | 41 | 42 | u1x = uhalfx .* exp(-j*gamma*(2/3)*( (abs(uhalfx).^2) + (2*abs(uhalfy).^2) )*dz); % non linear propagation in CP basis 43 | u1y = uhalfy .* exp(-j*gamma*(2/3)*( (abs(uhalfy).^2) + (2*abs(uhalfx).^2) )*dz); % non linear propagation in CP basis 44 | 45 | u1xaux = u1x; 46 | u1x = (u1xaux + u1y)/sqrt(2); % transforming into a LP basis 47 | u1y = -j*(u1xaux - u1y)/sqrt(2); % transforming into a LP basis 48 | 49 | %------linear propagation from dz/2 to dz------------ 50 | ufftx = halfstepx.*fft(u1x); % 51 | uffty = halfstepy.*fft(u1y); 52 | 53 | propagedlength = propagedlength + dz; 54 | propagatededlength = propagedlength ; 55 | fprintf(1, '\b\b\b\b\b\b%5.1f%%', propagedlength * 100.0 /fiberlength ); 56 | 57 | end 58 | 59 | u1x = ifft(ufftx); 60 | u1y = ifft(uffty); 61 | 62 | -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Solvers/SSFM_for_CNLSE_withPMD.m: -------------------------------------------------------------------------------- 1 | function [u1x,u1y] = UPMPol(u0x,u0y,dt,dz,nz,alphax,alphay,betapx,betapy,gamma,correlationlength,angles,tetas,beta0s,beta1s); 2 | 3 | nt = length(u0x); % nt is the number of point 4 | w = 2*pi*[(0:nt/2-1),(-nt/2:-1)]'/(dt*nt); %constructing used frequencies 5 | 6 | linearoperatorx = -alphax/2; % in the lines above are constructed the linear operator in X and Y. 7 | for ii = 0:length(betapx)-1; 8 | linearoperatorx = linearoperatorx - j*betapx(ii+1)*(w).^ii/factorial(ii); 9 | end 10 | 11 | linearoperatory = -alphay/2; 12 | for ii = 0:length(betapy)-1; 13 | linearoperatory = linearoperatory - j*betapy(ii+1)*(w).^ii/factorial(ii); 14 | end 15 | 16 | u1x = u0x; 17 | ufftx = fft(u0x); 18 | 19 | u1y = u0y; 20 | uffty = fft(u0y); 21 | 22 | fiberlength = nz*dz; 23 | propagedlength =0; 24 | auxlength = 0; 25 | jj=1; % it will be used to choise the correct input angles, tetas, beta0s and beta1s 26 | 27 | fprintf(1, '\nSimulation running... '); 28 | while propagedlength < fiberlength, 29 | 30 | 31 | %------the next "if" and the variable "auxlenght" are used to check if 32 | %the correlation length was riched 33 | if (auxlength >= correlationlength | auxlength ==0), 34 | auxlength = 0; 35 | 36 | angle = angles(jj); 37 | teta = tetas(jj); 38 | ufftxaux = ufftx * cos(teta) - uffty * sin(teta)*exp(-i*angle); 39 | ufftyaux = ufftx * sin(teta)*exp(i*angle) + uffty * cos(teta); 40 | ufftx = ufftxaux; 41 | uffty = ufftyaux; 42 | 43 | betapx(1) = -beta0s(jj); % observe that b0x and b0y are defined such that b0x = -b0y = -beta0s(1) 44 | betapy(1) = beta0s(jj); 45 | betapx(2) = -beta1s(jj); % tha same as above for beta1x and beta1y 46 | betapy(2) = beta1s(jj); 47 | 48 | jj=jj+1; % I increase the value of jj so in the next time the correlation length is reached, different pseudo-random variables are taken 49 | 50 | linearoperatorx = -alphax/2; % in the lines bellow I define the linear operators again using the new beta0s and beta1s 51 | for ii = 0:length(betapx)-1; 52 | linearoperatorx = linearoperatorx - j*betapx(ii+1)*(w).^ii/factorial(ii); 53 | end 54 | linearoperatory = -alphay/2; 55 | for ii = 0:length(betapy)-1; 56 | linearoperatory = linearoperatory - j*betapy(ii+1)*(w).^ii/factorial(ii); 57 | end 58 | end % here ends the "if" part that is done just at each correlation length. 59 | 60 | %Performing the SSFM with the given dz 61 | %------linear propagation until dz/2------------ 62 | halfstepx = exp(linearoperatorx*dz/2); 63 | uhalfx = ifft(halfstepx.*ufftx); 64 | 65 | halfstepy = exp(linearoperatory*dz/2); 66 | uhalfy = ifft(halfstepy.*uffty); 67 | %-----------transforming into a CP basis------------------------------ 68 | uhalfxaux = uhalfx; 69 | uhalfx = (uhalfxaux + j*uhalfy)/sqrt(2); 70 | uhalfy = (uhalfxaux - j*uhalfy)/sqrt(2); 71 | 72 | %------non linear propagation in dz------------ 73 | u1x = uhalfx .* exp(-j*gamma*(2/3)*( (abs(uhalfx).^2) + (2*abs(uhalfy).^2) )*dz); % non linear propagation in CP basis 74 | u1y = uhalfy .* exp(-j*gamma*(2/3)*( (abs(uhalfy).^2) + (2*abs(uhalfx).^2) )*dz); % non linear propagation in CP basis 75 | 76 | %-----------transforming into a LP basis--------------------------------- 77 | u1xaux = u1x; 78 | u1x = (u1xaux + u1y)/sqrt(2); % transforming into a LP basis 79 | u1y = -j*(u1xaux - u1y)/sqrt(2); % transforming into a LP basis 80 | 81 | %------linear propagation from dz/2 to dz------------ 82 | ufftx = halfstepx.*fft(u1x); % 83 | uffty = halfstepy.*fft(u1y); 84 | %---------------------------------------------------- 85 | auxlength = auxlength + dz; 86 | propagedlength = propagedlength + dz; 87 | fprintf(1, '\b\b\b\b\b\b%5.1f%%', propagedlength * 100.0 /fiberlength ); 88 | end 89 | 90 | u1x = ifft(ufftx); 91 | u1y = ifft(uffty); 92 | 93 | -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Solvers/SSFM_for_CNLSE_withPMD_without_ER_terms.m: -------------------------------------------------------------------------------- 1 | function [u1x,u1y] = UPMPol(u0x,u0y,dt,dz,nz,alphax,alphay,betapx,betapy,gamma,correlationlength,angles,tetas,beta0s,beta1s); 2 | 3 | nt = length(u0x); 4 | w = 2*pi*[(0:nt/2-1),(-nt/2:-1)]'/(dt*nt); 5 | 6 | linearoperatorx = -alphax/2; 7 | for ii = 0:length(betapx)-1; 8 | linearoperatorx = linearoperatorx - j*betapx(ii+1)*(w).^ii/factorial(ii); 9 | end 10 | 11 | linearoperatory = -alphay/2; 12 | for ii = 0:length(betapy)-1; 13 | linearoperatory = linearoperatory - j*betapy(ii+1)*(w).^ii/factorial(ii); 14 | end 15 | 16 | u1x = u0x; 17 | ufftx = fft(u0x); 18 | 19 | u1y = u0y; 20 | uffty = fft(u0y); 21 | 22 | fiberlength = nz*dz; 23 | propagedlength =0; 24 | auxlength = 0; 25 | 26 | jj=1; 27 | 28 | fprintf(1, '\nSimulation running... '); 29 | while propagedlength < fiberlength, 30 | % the next "if" and the variable "auxlenght" are used to check 31 | % if the correlation length was riched 32 | if (auxlength >= correlationlength | auxlength ==0), 33 | auxlength = 0; 34 | 35 | 36 | angle = angles(jj); 37 | teta = tetas(jj); 38 | ufftxaux = ufftx * cos(teta) - uffty * sin(teta)*exp(-i*angle); 39 | ufftyaux = ufftx * sin(teta)*exp(i*angle) + uffty * cos(teta); 40 | ufftx = ufftxaux; 41 | uffty = ufftyaux; 42 | 43 | betapx(1) = -beta0s(jj); % observe that b0x and b0y are defined such that b0x = -b0y = -beta0s(1) 44 | betapy(1) = beta0s(jj); 45 | betapx(2) = -beta1s(jj); % tha same as above for beta1x and beta1y 46 | betapy(2) = beta1s(jj); 47 | 48 | jj=jj+1; % I increase the value of jj so in the next time the correlation length is reached, different pseudo-random variables are taken 49 | 50 | linearoperatorx = -alphax/2; % in the lines bellow I define the linear operators again using the new beta0s and beta1s 51 | for ii = 0:length(betapx)-1; 52 | linearoperatorx = linearoperatorx - j*betapx(ii+1)*(w).^ii/factorial(ii); 53 | end 54 | linearoperatory = -alphay/2; 55 | for ii = 0:length(betapy)-1; 56 | linearoperatory = linearoperatory - j*betapy(ii+1)*(w).^ii/factorial(ii); 57 | end 58 | end % here ends the "if" part that is done just at each correlation length. 59 | 60 | %Performing the SSFM with the given dz 61 | %------linear propagation until dz/2------------ 62 | halfstepx = exp(linearoperatorx*dz/2); 63 | uhalfx = ifft(halfstepx.*ufftx); 64 | 65 | halfstepy = exp(linearoperatory*dz/2); 66 | uhalfy = ifft(halfstepy.*uffty); 67 | 68 | %------non linear propagation in dz------------ 69 | u1x = uhalfx .* exp(-j*gamma*( (abs(uhalfx).^2) + ((2/3)*abs(uhalfy).^2) )*dz); 70 | u1y = uhalfy .* exp(-j*gamma*( (abs(uhalfy).^2) + ((2/3)*abs(uhalfx).^2) )*dz); 71 | 72 | %------linear propagation from dz until dz------------ 73 | ufftx = halfstepx.*fft(u1x); 74 | uffty = halfstepy.*fft(u1y); 75 | %----------------------------------------------------- 76 | auxlength = auxlength + dz; 77 | propagedlength = propagedlength + dz; 78 | fprintf(1, '\b\b\b\b\b\b%5.1f%%', propagedlength * 100.0 /fiberlength ); 79 | end 80 | 81 | u1x = ifft(ufftx); 82 | u1y = ifft(uffty); 83 | 84 | -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Solvers/UPM_SSFM.m: -------------------------------------------------------------------------------- 1 | function [u1,number_of_FFTs] = UPM_SSFM(u0,dt,dz,nz,alpha,betap,gamma,tol); 2 | 3 | % This function solves the nonlinear Schrodinger equation for 4 | % pulse propagation in an optical fiber using the split-step 5 | % Fourier method described in: 6 | % 7 | % A. A. Rieznik, T. Tolisano, F. A. Callegari, D. F. Grosz, and H. L. Fragnito, 8 | % "Uncertainty relation for the optimization of optical-fiber transmission 9 | % systems simulations," Opt. Express 13, 3822-3834 (2005). 10 | % http://www.opticsexpress.org/abstract.cfm?URI=OPEX-13-10-3822 11 | % 12 | % USAGE 13 | % 14 | % u1 = ssprop(u0,dt,dz,nz,alpha,betap,gamma); 15 | % u1 = ssprop(u0,dt,dz,nz,alpha,betap,gamma,tol); 16 | % 17 | % INPUT 18 | % 19 | % u0 - starting field amplitude (vector) 20 | % dt - time step 21 | % dz - propagation stepsize 22 | % nz - number of steps to take, ie, ztotal = dz*nz 23 | % alpha - power loss coefficient, ie, P=P0*exp(-alpha*z) 24 | % betap - dispersion polynomial coefs, [beta_0 ... beta_m] 25 | % gamma - nonlinearity coefficient 26 | % tol - convergence tolerance (default = 1e-5) 27 | % 28 | % OUTPUT 29 | % 30 | % u1 - field at the output 31 | % number_of_FFTs - number of Fast Fourier Transforms performed during the 32 | % propagation 33 | % 34 | % NOTES The dimensions of the input and output quantities can 35 | % be anything, as long as they are self consistent. E.g., if 36 | % |u|^2 has dimensions of Watts and dz has dimensions of 37 | % meters, then gamma should be specified in W^-1*m^-1. 38 | % Similarly, if dt is given in picoseconds, and dz is given in 39 | % meters, then beta(n) should have dimensions of ps^(n-1)/m. 40 | 41 | 42 | if (nargin<8) 43 | tol = 1e-3; 44 | end 45 | 46 | nt = length(u0); 47 | w = 2*pi*[(0:nt/2-1),(-nt/2:-1)]'/(dt*nt); 48 | 49 | % constructing linear operator 50 | linearoperator = -alpha/2; 51 | for ii = 0:length(betap)-1; 52 | linearoperator = linearoperator - j*betap(ii+1)*(w).^ii/factorial(ii); 53 | end 54 | 55 | u1 = u0; 56 | nf = 0; % parameter to save the number of FFTs 57 | ufft = fft(u0); nf = nf + 1; 58 | 59 | fiberlength = nz*dz; 60 | propagedlength =0; 61 | 62 | % Performig the SSFM according to the UPM spatial-step size 63 | fprintf(1, '\nSimulation running... '); 64 | while propagedlength < fiberlength, 65 | Et = sum(abs(u1).^2); 66 | meanN = sum( gamma*(abs(u1).^4) ) / Et; 67 | aux = ( gamma * (abs(u1).^2) - meanN ).^2; 68 | deltaN = sqrt(sum( aux.*abs(u1).^2 ) / Et); 69 | 70 | Ef = sum(abs(ufft).^2); 71 | meanD = sum( j*linearoperator.*(abs(ufft).^2) ) / Ef; 72 | aux = ( j*linearoperator - meanD ).^2; 73 | deltaD = sqrt(sum( aux.*abs(ufft).^2 ) / Ef); 74 | 75 | 76 | dz = (tol^(1/3)) * sqrt(1 / (deltaD*deltaN)); 77 | 78 | if (dz + propagedlength) > fiberlength, 79 | dz = fiberlength - propagedlength; 80 | end 81 | 82 | halfstep = exp(linearoperator*dz/2); 83 | uhalf = ifft(halfstep.*ufft); nf = nf + 1; 84 | 85 | u1 = uhalf .* exp(-j*gamma*(abs(uhalf).^2 )*dz); 86 | ufft = halfstep.*fft(u1); nf = nf + 1; 87 | propagedlength = propagedlength + dz; 88 | fprintf(1, '\b\b\b\b\b\b%5.1f%%', propagedlength * 100.0 /fiberlength ); 89 | end 90 | 91 | % giving output parameters 92 | u1 = ifft(ufft); 93 | number_of_FFTs = nf; 94 | 95 | 96 | -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Solvers/WOM_SSFM.m: -------------------------------------------------------------------------------- 1 | function [u1,number_of_FFTs] = ssprop(u0,dt,dz,nz,alpha,betap,gamma,tol); 2 | 3 | 4 | if (nargin<8) 5 | tol = 1e-3; 6 | end 7 | 8 | propagedlength = 0; 9 | fiberlength = dz*nz; 10 | 11 | nt = length(u0); 12 | w = 2*pi*[(0:nt/2-1),(-nt/2:-1)]'/(dt*nt); 13 | 14 | halfstep = -alpha/2; 15 | for ii = 0:length(betap)-1; 16 | halfstep = halfstep - j*betap(ii+1)*(w).^ii/factorial(ii); 17 | end 18 | halfstep = exp(halfstep*dz/2); 19 | 20 | nf = 0; 21 | ufft = fft(u0); nf = nf + 1; 22 | 23 | fprintf(1, '\nSimulation running... '); 24 | for iz = 1:nz, 25 | uhalf = ifft(halfstep.*ufft); nf = nf + 1; 26 | uv = uhalf .* exp(-j*gamma*(abs(uhalf).^2)*dz); 27 | ufft = halfstep.*fft(uv); nf = nf + 1; 28 | propagedlength = propagedlength + dz; 29 | fprintf(1, '\b\b\b\b\b\b%5.1f%%', propagedlength * 100.0 /fiberlength ); 30 | end 31 | 32 | if propagedlength < fiberlength, 33 | dz = fiberlength - propagedlength; 34 | uhalf = ifft(halfstep.*ufft); nf = nf + 1; 35 | uv = uhalf .* exp(-j*gamma*(abs(uhalf).^2)*dz); 36 | ufft = halfstep.*fft(uv); nf = nf + 1; 37 | propagedlength = propagedlength + dz; 38 | fprintf(1, '\b\b\b\b\b\b%5.1f%%', propagedlength * 100.0 /fiberlength ); 39 | end 40 | 41 | u1 = ifft(ufft); 42 | number_of_FFTs = nf; 43 | 44 | % load propaged2; 45 | % globalerror = sqrt(sum(abs(propaged2-ux).^2) / sum(abs(propaged2).^2)) 46 | % u1=ux; 47 | -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Visualizers/createFig1a.m: -------------------------------------------------------------------------------- 1 | function createfigure(x1, y1, y2) 2 | %CREATEFIGURE(X1,Y1,Y2) 3 | % X1: vector of x data 4 | % Y1: vector of y data 5 | % Y2: vector of y data 6 | 7 | % Auto-generated by MATLAB on 18-Oct-2007 10:54:52 8 | 9 | %% Create figure 10 | figure1 = figure('FileName','C:\Documents and Settings\pessoal\Meus documentos\ssf\IncludingPolarization\Short_Fiber_OPAs\Article\Definitivos\Fig1a.fig'); 11 | 12 | %% Create axes 13 | axes1 = axes(... 14 | 'FontSize',12,... 15 | 'FontWeight','bold',... 16 | 'XGrid','on',... 17 | 'XTick',[0 40 80 120 160 200],... 18 | 'YGrid','on',... 19 | 'Parent',figure1); 20 | xlabel(axes1,'fiber length (m)'); 21 | ylabel(axes1,'angle rotation (rad)'); 22 | hold(axes1,'all'); 23 | 24 | %% Create plot 25 | plot1 = plot(x1,y1,'LineWidth',3); 26 | 27 | %% Create plot 28 | plot2 = plot(... 29 | x1,y2,... 30 | 'Color',[0.8314 0.8157 0.7843],... 31 | 'LineWidth',3); 32 | 33 | -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Visualizers/createFig1b.m: -------------------------------------------------------------------------------- 1 | function createfigure(x1, y1, y2) 2 | %CREATEFIGURE(X1,Y1,Y2) 3 | % X1: vector of x data 4 | % Y1: vector of y data 5 | % Y2: vector of y data 6 | 7 | % Auto-generated by MATLAB on 24-Oct-2007 00:58:04 8 | 9 | %% Create figure 10 | figure1 = figure('FileName','C:\Documents and Settings\pessoal\Meus documentos\ssf\IncludingPolarization\Short_Fiber_OPAs\Article\Definitivos\Fig1b.fig'); 11 | 12 | %% Create axes 13 | axes1 = axes(... 14 | 'FontSize',12,... 15 | 'FontWeight','bold',... 16 | 'XGrid','on',... 17 | 'XTick',[0 40 80 120 160 200],... 18 | 'YGrid','on',... 19 | 'Parent',figure1); 20 | xlabel(axes1,'fiber length(m)'); 21 | ylabel(axes1,'\Deltan'); 22 | hold(axes1,'all'); 23 | 24 | %% Create plot 25 | plot1 = plot(x1,y1,'LineWidth',3); 26 | 27 | %% Create plot 28 | plot2 = plot(... 29 | x1,y2,... 30 | 'Color',[1 0 0],... 31 | 'LineStyle','--',... 32 | 'LineWidth',3); 33 | 34 | -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Visualizers/createFig3.m: -------------------------------------------------------------------------------- 1 | function createFig3(x1, y1, y2) 2 | %CREATEFIGURE(X1,Y1,Y2) 3 | % X1: vector of x data 4 | % Y1: vector of y data 5 | % Y2: vector of y data 6 | 7 | % Auto-generated by MATLAB on 18-Oct-2007 10:56:50 8 | 9 | %% Create figure 10 | figure1 = figure('FileName','C:\Documents and Settings\pessoal\Meus documentos\ssf\IncludingPolarization\Short_Fiber_OPAs\Article\Definitivos\Fig3.fig'); 11 | 12 | %% Create axes 13 | axes1 = axes(... 14 | 'FontSize',12,... 15 | 'FontWeight','bold',... 16 | 'XTick',[1470 1500 1540 1580 1620 1640],... 17 | 'YTick',[0 2 4 6 8 10 12 14 16 18],... 18 | 'Parent',figure1); 19 | xlim(axes1,[1470 1640]); 20 | xlabel(axes1,'\lambda (nm)'); 21 | ylabel(axes1,'Gain (dB)'); 22 | grid(axes1,'on'); 23 | hold(axes1,'all'); 24 | 25 | %% Create plot 26 | plot1 = plot(x1,y1,'LineWidth',3); 27 | 28 | %% Create plot 29 | plot2 = plot(... 30 | x1,y2,... 31 | 'Color',[0.8314 0.8157 0.7843],... 32 | 'LineWidth',3); 33 | 34 | -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Visualizers/createFig6b.m: -------------------------------------------------------------------------------- 1 | function createFig6b(x1, y1, y2) 2 | %CREATEFIGURE(X1,Y1,Y2) 3 | % X1: vector of x data 4 | % Y1: vector of y data 5 | % Y2: vector of y data 6 | 7 | % Auto-generated by MATLAB on 18-Oct-2007 10:56:50 8 | 9 | %% Create figure 10 | figure1 = figure('FileName','C:\Documents and Settings\pessoal\Meus documentos\ssf\IncludingPolarization\Short_Fiber_OPAs\Article\Definitivos\Fig3.fig'); 11 | 12 | %% Create axes 13 | axes1 = axes(... 14 | 'FontSize',12,... 15 | 'FontWeight','bold',... 16 | 'XTick',[1400:50:1700],... 17 | 'YTick',[0 2 4 6 8 10 12 14 16 18],... 18 | 'Parent',figure1); 19 | xlim(axes1,[1400 1700]); 20 | xlabel(axes1,'\lambda (nm)'); 21 | ylabel(axes1,'Gain (dB)'); 22 | grid(axes1,'on'); 23 | hold(axes1,'all'); 24 | 25 | %% Create plot 26 | plot1 = plot(x1,y1,'LineWidth',3); 27 | 28 | %% Create plot 29 | plot2 = plot(... 30 | x1,y2,... 31 | 'Color',[0.8314 0.8157 0.7843],... 32 | 'LineWidth',3); 33 | 34 | -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Visualizers/createFig6c.m: -------------------------------------------------------------------------------- 1 | function createFig6b(x1, y1, y2) 2 | %CREATEFIGURE(X1,Y1,Y2) 3 | % X1: vector of x data 4 | % Y1: vector of y data 5 | % Y2: vector of y data 6 | 7 | % Auto-generated by MATLAB on 18-Oct-2007 10:56:50 8 | 9 | %% Create figure 10 | figure1 = figure('FileName','C:\Documents and Settings\pessoal\Meus documentos\ssf\IncludingPolarization\Short_Fiber_OPAs\Article\Definitivos\Fig3.fig'); 11 | 12 | %% Create axes 13 | axes1 = axes(... 14 | 'FontSize',12,... 15 | 'FontWeight','bold',... 16 | 'XTick',[1300:100:1850],... 17 | 'YTick',[0 2 4 6 8 10 12 14 16 18],... 18 | 'Parent',figure1); 19 | xlim(axes1,[1300 1850]); 20 | xlabel(axes1,'\lambda (nm)'); 21 | ylabel(axes1,'Gain (dB)'); 22 | grid(axes1,'on'); 23 | hold(axes1,'all'); 24 | 25 | %% Create plot 26 | plot1 = plot(x1,y1,'LineWidth',3); 27 | 28 | %% Create plot 29 | plot2 = plot(... 30 | x1,y2,... 31 | 'Color',[0.8314 0.8157 0.7843],... 32 | 'LineWidth',3); 33 | 34 | -------------------------------------------------------------------------------- /FreeOpticalProject/Rieznik_Thesis_Generate_Figures/Visualizers/createfigure.m: -------------------------------------------------------------------------------- 1 | function createfigure(x1, y1, y2) 2 | %CREATEFIGURE(X1,Y1,Y2) 3 | % X1: vector of x data 4 | % Y1: vector of y data 5 | % Y2: vector of y data 6 | 7 | % Auto-generated by MATLAB on 23-Aug-2007 22:15:52 8 | 9 | %% Create figure 10 | figure1 = figure('FileName','C:\Documents and Settings\pessoal\Meus documentos\ssf\IncludingPolarization\JOSABwithMarhic\Final_Versions_For_Free_Optics\Fig2a.fig'); 11 | 12 | %% Create axes 13 | axes1 = axes(... 14 | 'FontSize',12,... 15 | 'FontWeight','bold',... 16 | 'Parent',figure1); 17 | xlim(axes1,[1470 1630]); 18 | xlabel(axes1,'\lambda (nm)'); 19 | ylabel(axes1,'Gain (dB)'); 20 | grid(axes1,'on'); 21 | hold(axes1,'all'); 22 | 23 | %% Create plot 24 | plot1 = plot(... 25 | x1,y1,... 26 | 'LineWidth',3,... 27 | 'Marker','.'); 28 | 29 | %% Create plot 30 | plot2 = plot(... 31 | x1,y2,... 32 | 'Color',[0.502 0.502 0.502],... 33 | 'LineStyle',':',... 34 | 'LineWidth',4,... 35 | 'MarkerEdgeColor',[0.8314 0.8157 0.7843],... 36 | 'MarkerFaceColor',[0.502 0.502 0.502]); 37 | 38 | -------------------------------------------------------------------------------- /FreeOpticalProject/Soliton_In_PCF/Frequencies_for_beta2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Soliton_In_PCF/Frequencies_for_beta2.mat -------------------------------------------------------------------------------- /FreeOpticalProject/Soliton_In_PCF/UPM_SSFM.m: -------------------------------------------------------------------------------- 1 | function u1= UPM_SSFM(u0,dt,dz,nz,alpha,betap,gamma,tol) 2 | 3 | % This function solves the nonlinear Schrodinger equation for 4 | % pulse propagation in an optical fiber using the split-step 5 | % Fourier method described in: 6 | % 7 | % A. A. Rieznik, T. Tolisano, F. A. Callegari, D. F. Grosz, and H. L. Fragnito, 8 | % "Uncertainty relation for the optimization of optical-fiber transmission 9 | % systems simulations," Opt. Express 13, 3822-3834 (2005). 10 | % http://www.opticsexpress.org/abstract.cfm?URI=OPEX-13-10-3822 11 | % 12 | % USAGE 13 | % 14 | % u1 = ssprop(u0,dt,dz,nz,alpha,betap,gamma); 15 | % u1 = ssprop(u0,dt,dz,nz,alpha,betap,gamma,tol); 16 | % 17 | % INPUT 18 | % 19 | % u0 - starting field amplitude (vector) 20 | % dt - time step 21 | % dz - propagation stepsize 22 | % nz - number of steps to take, ie, ztotal = dz*nz 23 | % alpha - power loss coefficient, ie, P=P0*exp(-alpha*z) 24 | % betap - dispersion polynomial coefs, [beta_0 ... beta_m], or beta(w) 25 | % gamma - nonlinearity coefficient 26 | % tol - convergence tolerance (default = 1e-5) 27 | % 28 | % OUTPUT 29 | % 30 | % u1 - field at the output 31 | % number_of_FFTs - number of Fast Fourier Transforms performed during the 32 | % propagation 33 | % 34 | % NOTES The dimensions of the input and output quantities can 35 | % be anything, as long as they are self consistent. E.g., if 36 | % |u|^2 has dimensions of Watts and dz has dimensions of 37 | % meters, then gamma should be specified in W^-1*m^-1. 38 | % Similarly, if dt is given in picoseconds, and dz is given in 39 | % meters, then beta(n) should have dimensions of ps^(n-1)/m. 40 | 41 | 42 | if (nargin<8) 43 | tol = 1e-3; 44 | end 45 | 46 | nt = length(u0); 47 | w = 2*pi*[(0:nt/2-1),(-nt/2:-1)]'/(dt*nt); 48 | 49 | % constructing linear operator 50 | linearoperator = -alpha/2; 51 | if (length(betap) == nt) % If the user manually specifies beta(w) 52 | linearoperator = linearoperator - j*betap; 53 | linearoperator = fftshift(linearoperator); 54 | else 55 | for ii = 0:length(betap)-1; 56 | linearoperator = linearoperator - j*betap(ii+1)*(w).^ii/factorial(ii); 57 | end 58 | linearoperator = conj(linearoperator'); 59 | end 60 | 61 | 62 | u1 = u0; 63 | ufft = fft(u0); 64 | 65 | fiberlength = nz*dz; 66 | propagedlength =0; 67 | 68 | % Performig the SSFM according to the UPM spatial-step size 69 | fprintf(1, '\nSimulation running... '); 70 | while propagedlength < fiberlength, 71 | % calculating dz at each interaction 72 | Et = sum(abs(u1).^2); 73 | meanN = sum( gamma*(abs(u1).^4) ) / Et; 74 | aux = ( gamma * (abs(u1).^2) - meanN ).^2; 75 | deltaN = sqrt(sum( aux.*abs(u1).^2 ) / Et); 76 | 77 | Ef = sum(abs(ufft).^2); 78 | meanD = sum( j*linearoperator.*(abs(ufft).^2) ) / Ef; 79 | aux = ( j*linearoperator - meanD ).^2; 80 | deltaD = sqrt(sum( aux.*abs(ufft).^2 ) / Ef); 81 | 82 | 83 | dz = (tol^(1/3)) * sqrt(1 / (deltaD*deltaN)); 84 | % end of dz calculation at each inteaction 85 | 86 | if (dz + propagedlength) > fiberlength, 87 | dz = fiberlength - propagedlength; 88 | end 89 | 90 | % First linear parte (until dz/2) 91 | halfstep = exp(linearoperator*dz/2); 92 | uhalf = ifft(halfstep.*ufft); 93 | % non linear part 94 | u1 = uhalf .* exp(-j*gamma*(abs(uhalf).^2 )*dz); 95 | % Second linear part 96 | ufft = halfstep.*fft(u1); 97 | 98 | propagedlength = propagedlength + dz; 99 | fprintf(1, '\b\b\b\b\b\b%5.1f%%', propagedlength * 100.0 /fiberlength ); 100 | end 101 | 102 | % giving output parameters 103 | u1 = ifft(ufft); 104 | 105 | 106 | -------------------------------------------------------------------------------- /FreeOpticalProject/Soliton_In_PCF/beta2w_Thz.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/FreeOpticalProject/Soliton_In_PCF/beta2w_Thz.mat -------------------------------------------------------------------------------- /NLSEmagic/NLSE1D_TAKE_STEPS_2SHOC.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/NLSEmagic/NLSE1D_TAKE_STEPS_2SHOC.mexw32 -------------------------------------------------------------------------------- /NLSEmagic/NLSE1D_TAKE_STEPS_2SHOC_CUDA_D.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/NLSEmagic/NLSE1D_TAKE_STEPS_2SHOC_CUDA_D.mexw32 -------------------------------------------------------------------------------- /NLSEmagic/NLSE1D_TAKE_STEPS_2SHOC_CUDA_F.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/NLSEmagic/NLSE1D_TAKE_STEPS_2SHOC_CUDA_F.mexw32 -------------------------------------------------------------------------------- /NLSEmagic/NLSE1D_TAKE_STEPS_2SHOC_F.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/NLSEmagic/NLSE1D_TAKE_STEPS_2SHOC_F.mexw32 -------------------------------------------------------------------------------- /NLSEmagic/NLSE1D_TAKE_STEPS_CD.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/NLSEmagic/NLSE1D_TAKE_STEPS_CD.mexw32 -------------------------------------------------------------------------------- /NLSEmagic/NLSE1D_TAKE_STEPS_CD_CUDA_D.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/NLSEmagic/NLSE1D_TAKE_STEPS_CD_CUDA_D.mexw32 -------------------------------------------------------------------------------- /NLSEmagic/NLSE1D_TAKE_STEPS_CD_CUDA_F.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/NLSEmagic/NLSE1D_TAKE_STEPS_CD_CUDA_F.mexw32 -------------------------------------------------------------------------------- /NLSEmagic/NLSE1D_TAKE_STEPS_CD_F.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/NLSEmagic/NLSE1D_TAKE_STEPS_CD_F.mexw32 -------------------------------------------------------------------------------- /NLSEmagic/NLSEmagic1D.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/NLSEmagic/NLSEmagic1D.m -------------------------------------------------------------------------------- /NLSEmagic/README_B.txt: -------------------------------------------------------------------------------- 1 | NLSEmagic1D Binaries Readme 2 | ---------------------------- 3 | NLSE1D_TAKE_STEPS_XX_XX.cX 4 | Program to integrate a chunk of time steps of the 1D Nonlinear Shrodinger Equation 5 | i*Ut + a*Uxx - V(x)*U + s*|U|^2*U = 0 6 | 7 | Ronald M Caplan 8 | Computational Science Research Center 9 | San Diego State University 10 | 11 | INPUT: 12 | (U,V,s,a,h2,BC,chunk_size,k) 13 | U = Current solution matrix 14 | V = External Potential matrix 15 | s = Nonlinearity paramater 16 | a = Laplacian paramater 17 | h2 = Spatial step size squared (h^2) 18 | BC = Boundary condition selection switch: 1: Dirchilet 2: MSD 3: Lap=0 4: One-sided diff 19 | chunk_size = Number of time steps to take 20 | k = Time step size 21 | 22 | OUTPUT: 23 | U: New solution matrix 24 | 25 | Typical call: 26 | U = NLSE1D_TAKE_STEPS_CD(U,V,s,a,h^2,BC,chunk_size,k); 27 | 28 | ------------------------------------- 29 | 30 | Basic installation instructions (for Windows and Linux): 31 | 1) Extract all files in this zip file into a directory of your choice. 32 | 2) Run MATLAB and change the directory to where you unzipped the files. 33 | 3) Now you can run NLSEmagic1D. 34 | 35 | Alter the m file NLSEmagic1D.m to run your own simulations. 36 | 37 | For examples on how to plot, save movies/images, run timings, etc. 38 | see the full research script code package of NLSE1D at www.nlsemagic.com. 39 | 40 | ------------------------------------------------------------------------- 41 | Disclaimer - This code is given as "as is" and is not guaranteed at all 42 | and I take no liability for any damage it may cause. Feel 43 | free to distribute the code as long as you keep the authors 44 | name in it. If you use these codes, the author would appreciate 45 | your acknowledging having done so in any reports, publications, etc. 46 | resulting from their use. 47 | Also, donations are welcome at www.nlsemagic.com. 48 | -------------------------------------------------------------------------------- /NLSEmagic/getCudaInfo.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/NLSEmagic/getCudaInfo.mexw32 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MATLAB 2 | ====== 3 | 4 | numerical simulations 5 | -------------------------------------------------------------------------------- /Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/Thumbs.db -------------------------------------------------------------------------------- /matlab.mat: -------------------------------------------------------------------------------- 1 | MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Tue Oct 30 19:50:13 2012 IM -------------------------------------------------------------------------------- /ssprop-3.0.1/ChangeLog.txt: -------------------------------------------------------------------------------- 1 | ************************************************************ 2 | Version 3.0.1 3 | ************************************************************ 4 | 5 | Corrected a few bugs in the m-file sspropv.m (vector split-step 6 | routine): Renamed the variable "pol" to "psp" to match function 7 | declaration, removed extraneous isscalar() line from code. 8 | Updated the m-files to correctly refer to the two methods as 9 | either 'circular' or 'elliptical'. 10 | 11 | There were no changes made to the compiled code. 12 | 13 | ************************************************************ 14 | Version 3.0 15 | ************************************************************ 16 | 17 | This version now includes a vector version of the code, which 18 | allows one to simulate effects like PDL, PMD, birefringence, 19 | nonlinear polarization rotation, and cross-polarization 20 | modulation. The scalar routines are largely unmodified. 21 | 22 | Code has been updated to use the latest FFTW 3.1.2 routines. 23 | 24 | ************************************************************ 25 | Version 2.0.2 26 | ************************************************************ 27 | 28 | This version introduces no changes to the core calculation 29 | routine, only in the associated utilities and examples. 30 | 31 | Fixed bug in solitonpulse utility. This utility program was 32 | incorrectly implementing the chirp factor for chirped pulses. 33 | 34 | The examples directory now includes 28 files that reproduce many 35 | of the simulation results presented in chapters 3..5 of 36 | G. P. Agrawal's text, Nonlinear Fiber Optics (3rd ed.) 37 | 38 | ************************************************************ 39 | Version 2.0.1 40 | ************************************************************ 41 | 42 | Added utility file wspace.m that produces a vector of angular 43 | frequencies for use with the FFT routines 44 | 45 | sspropc now recognizes empty ([]) arguments for toptical and 46 | traman. This allows the user to specify maxiter and tol while 47 | leaving toptical and traman unspecified. 48 | 49 | Added support for frequency-dependent loss alpha(w). If the 50 | input parameter alpha is a vector with the same length as u0, 51 | then it is treated as a frequency-dependent loss coefficient. 52 | Otherwise if alpha is a scalar, then all frequency components 53 | have the same loss. 54 | 55 | Added support for arbitrary specification of dispersion function 56 | beta(w). If beta is a vector with the same length as u0, then it 57 | is regarded as a direct specification of the propagation 58 | constant. Otherwise, beta is interpreted as the Taylor-series 59 | coefficients of the dispersion polynomial. 60 | 61 | ************************************************************ 62 | Version 2.0 63 | ************************************************************ 64 | 65 | sspropc now uses FFTW 3.1 routines 66 | 67 | single- and double- precision versions can be compiled from the 68 | same source file. Use -DSINGLEPREC when compiling to build 69 | single-precision (float) version. 70 | 71 | wisdom file is renamed to "fftw-wisdom.dat" and 72 | "fftwf-wisdom.dat" for double and single-precision routines 73 | respectively. 74 | 75 | wisdom file is not automatically saved when you exit from the 76 | program. User must save the file manually. 77 | 78 | Added special command-line arguments for specifying the FFTW 79 | planner method. (-estimate, -exhaustive, -measure, -patient), 80 | default method is patient. 81 | 82 | Added special command-line arguments for controlling wisdom: 83 | (-savewisdom, -loadwisdom, -forgetwisdom) 84 | 85 | Memory allocation hooks are no longer needed with this version of 86 | FFTW 3.1 87 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/README.txt: -------------------------------------------------------------------------------- 1 | The example files in this directory illustrate how to use SSPROP 2 | to simulate linear and nonlinear propagation in fiber. The 3 | examples reproduce many of the numerical results that are 4 | presented in Govind. P. Agrawal's text, "Nonlinear Fiber Optics". 5 | 6 | In addition to sspropc, these example routines use the utility 7 | routines that are provided in the tools directory. It is 8 | recommended that you add this directory in addition to the main 9 | ssprop directory to your Matlab path before running the 10 | examples. -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/allexamples.m: -------------------------------------------------------------------------------- 1 | clear all; close all; fig3_1; pause; 2 | clear all; close all; fig3_3; pause; 3 | clear all; close all; fig3_4; pause; 4 | clear all; close all; fig3_6; pause; 5 | clear all; close all; fig3_7; pause; 6 | clear all; close all; fig4_4; pause; 7 | clear all; close all; fig4_5; pause; 8 | clear all; close all; fig4_7; pause; 9 | clear all; close all; fig4_8; pause; 10 | clear all; close all; fig4_10; pause; 11 | clear all; close all; fig4_11; pause; 12 | clear all; close all; fig4_12; pause; 13 | clear all; close all; fig4_14; pause; 14 | clear all; close all; fig4_15; pause; 15 | clear all; close all; fig4_16; pause; 16 | clear all; close all; fig4_17; pause; 17 | clear all; close all; fig4_18; pause; 18 | clear all; close all; fig5_4; pause; 19 | clear all; close all; fig5_5; pause; 20 | clear all; close all; fig5_7; pause; 21 | clear all; close all; fig5_9; pause; 22 | clear all; close all; fig5_14; pause; 23 | clear all; close all; fig5_15; pause; 24 | clear all; close all; fig5_16; pause; 25 | clear all; close all; fig5_17; pause; 26 | clear all; close all; fig5_18; pause; 27 | clear all; close all; fig5_19; pause; 28 | clear all; close all; fig5_21; -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig3_1.asv: -------------------------------------------------------------------------------- 1 | clear;close all;clc; 2 | T = 32; % time window (period) 3 | nt = 2^12; % number of points 4 | dt = T/nt; % timestep (dt) 5 | t = ((1-nt)/2:(nt-1)/2)*dt; % time vector 6 | 7 | dz = 1; % total distance per step 8 | nz = 4; % total number of steps 9 | 10 | betap = [0,0,1]; % dispersion polynomial 11 | gamma = 0; 12 | u = zeros(length(t),nz+1); 13 | 14 | u(:,1) = gaussian(t,0,2*sqrt(log(2)),1,1); 15 | tic; 16 | for ii = 1:nz 17 | u(:,ii+1) = ssfm(u(:,ii),dt,dz,1,0,betap,gamma,); 18 | %u(:,ii+1) = sspropv(u(:,ii),u(:,ii),dt,dz,1,0,0,betap,betap,gamma); 19 | end 20 | toc; 21 | ann_string = cell(size(u,2),1); 22 | for i = 1:size(u,2) 23 | ann_string{i} = ['z/L_D = ',num2str(i-1)]; 24 | end 25 | 26 | figure; 27 | plot(t,abs(u).^2); 28 | xlim([-8 8]); 29 | xlabel ('(t-\beta_1z)/T_0'); 30 | ylabel ('|u(z,t)|^2/P_0'); 31 | legend(ann_string); 32 | 33 | figure; 34 | omega = wspace(t); 35 | subplot(2,1,1); 36 | plot(fftshift(omega)./(2*pi), fftshift(abs(dt*ifft(u)*nt/sqrt(2*pi)).^2)); 37 | axis([-5 5 0 inf]); 38 | xlabel('\omega'); 39 | ylabel('|u(\omega)|^2/P_0'); 40 | subplot(2,1,2); 41 | pu = unwrap(angle(fftshift((dt*ifft(u)*nt/sqrt(2*pi))))); 42 | plot(fftshift(omega)./(2*pi), pu(:,1:2)); 43 | hold on; 44 | plot(fftshift(omega)./(2*pi), pu(:,2)-pu(:,1),'--r'); 45 | axis([-1 1 -inf inf]); 46 | xlabel('\omega'); 47 | legend('\phi(0,\omega)','\phi(L_D,\omega)','\phi(L_D,\omega)-\phi(0,\omega)') 48 | 49 | figure; 50 | [~,phi] = gradient(unwrap(angle(u))); 51 | plot(t,-phi./repmat(gradient(omega),1,size(u,2))); 52 | axis([-5 5 -1 1]); 53 | legend(ann_string); 54 | xlabel('T/T_0'); 55 | ylabel('-\partial\phi/\partialT'); -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig3_1.m: -------------------------------------------------------------------------------- 1 | clear;close all;clc; 2 | T = 32; % time window (period) 3 | nt = 2^10; % number of points 4 | dt = T/nt; % timestep (dt) 5 | t = ((1-nt)/2:(nt-1)/2)*dt; % time vector 6 | 7 | dz = 1; % total distance per step 8 | nz = 4; % total number of steps 9 | 10 | betap = [0,0,1]; % dispersion polynomial 11 | gamma = 0; 12 | u = zeros(length(t),nz+1); 13 | 14 | u(:,1) = gaussian(t,0,2*sqrt(log(2)),1,1); 15 | tic; 16 | for ii = 1:nz 17 | %u(:,ii+1) = ssprop(u(:,ii),dt,dz,1,0,betap,gamma,10,1e-4); 18 | %u(:,ii+1) = sspropv(u(:,ii),u(:,ii),dt,dz,1,0,0,betap,betap,gamma); 19 | end 20 | toc; 21 | ann_string = cell(size(u,2),1); 22 | for i = 1:size(u,2) 23 | ann_string{i} = ['z/L_D = ',num2str(i-1)]; 24 | end 25 | 26 | figure; 27 | plot(t,abs(u).^2); 28 | xlim([-8 8]); 29 | xlabel ('(t-\beta_1z)/T_0'); 30 | ylabel ('|u(z,t)|^2/P_0'); 31 | legend(ann_string); 32 | 33 | figure; 34 | omega = wspace(t); 35 | subplot(2,1,1); 36 | plot(fftshift(omega)./(2*pi), fftshift(abs(dt*ifft(u)*nt/sqrt(2*pi)).^2)); 37 | axis([-5 5 0 inf]); 38 | xlabel('\omega'); 39 | ylabel('|u(\omega)|^2/P_0'); 40 | subplot(2,1,2); 41 | pu = unwrap(angle(fftshift((dt*ifft(u)*nt/sqrt(2*pi))))); 42 | plot(fftshift(omega)./(2*pi), pu(:,1:2)); 43 | hold on; 44 | plot(fftshift(omega)./(2*pi), pu(:,2)-pu(:,1),'--r'); 45 | axis([-1 1 -inf inf]); 46 | xlabel('\omega'); 47 | legend('\phi(0,\omega)','\phi(L_D,\omega)','\phi(L_D,\omega)-\phi(0,\omega)') 48 | 49 | figure; 50 | [~,phi] = gradient(unwrap(angle(u))); 51 | plot(t,-phi./repmat(gradient(omega),1,size(u,2))); 52 | axis([-5 5 -1 1]); 53 | legend(ann_string); 54 | xlabel('T/T_0'); 55 | ylabel('-\partial\phi/\partialT'); -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig3_6.m: -------------------------------------------------------------------------------- 1 | clear all;close all;clc; 2 | T = 48; % time window (period) 3 | nt = 2^10; % number of points 4 | dt = T/nt; % timestep (dt) 5 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 6 | 7 | dz = 1; % total distance per step 8 | nz = 5; 9 | u0 = gaussian(t,0,2*sqrt(log(2))); 10 | 11 | betap = [0,0,0,1]; % dispersion polynomial 12 | u1 = ssrklem(u0,dt,dz,nz,0,betap,0); 13 | %u1 = ssfm(u0,dt,dz,nz,0,betap,0,3e-15); 14 | 15 | betap = [0,0,1,1]; % dispersion polynomial 16 | u2 = ssrklem(u0,dt,dz,nz,0,betap,0); 17 | %u2 = ssfm(u0,dt,dz,nz,0,betap,0,3e-15); 18 | 19 | plot(t,abs(u0).^2,':',... 20 | t,abs(u1).^2,'-',... 21 | t,abs(u2).^2,'--'); 22 | xlim([-12 12]); 23 | xlabel ('(t-\beta_1z)/T_0'); 24 | ylabel ('|u(z,t)|^2/P_0'); 25 | legend('original pulse','\beta_2=0,\beta_3=1','\beta_2=1,\beta_3=1'); 26 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig3_7.m: -------------------------------------------------------------------------------- 1 | clear;close all;clc; 2 | T = 200; % time window (period) 3 | nt = 2^12; % number of points 4 | dt = T/nt; % timestep (dt) 5 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 6 | 7 | z = 6; % total distance 8 | nz = 50; % total number of steps 9 | dz = z/nz; % total distance per step 10 | 11 | betap = [0,0,0,1]; % dispersion polynomial 12 | 13 | zv = (dz)*(0:nz); 14 | u = zeros(length(t),nz+1); 15 | 16 | u(:,1) = gaussian(t,0,2*sqrt(log(2)),1,3); 17 | tic; 18 | for ii = 1:nz, 19 | u(:,ii+1) = ssprop(u(:,ii),dt,dz,1,0,betap,0); 20 | end 21 | toc; 22 | mesh(zv,t,abs(u).^2,... 23 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 24 | set(gca,'YDir', 'reverse'); 25 | hidden off; 26 | xlim([0 6]); 27 | ylim([-20 20]); 28 | xlabel ('Z/L_d'); 29 | ylabel ('(t-\beta_1z)/T_0'); 30 | zlabel ('|u(z,t)|^2/P_0'); 31 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_10.asv: -------------------------------------------------------------------------------- 1 | T = 100; % time window (period) 2 | nt = 2^12; % number of points 3 | dt = T/nt; % timestep (dt) 4 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 5 | w = wspace(T,nt); % angular frequency vector 6 | vs = fftshift(w/(2*pi)); % shifted for plotting 7 | 8 | z = 0.1; % total distance 9 | nz = 50; % total number of steps 10 | nplot = 5; % number of plots to make 11 | n1 = round(nz/nplot); % number of steps per plot 12 | nz = n1*nplot; % total number of steps (revised) 13 | dz = z/nz; % step-size 14 | 15 | betap = [0,0,+1]; % dispersion polynomial 16 | 17 | u0 = gaussian(t,0,2*sqrt(log(2))); % u0 = exp(-t.^2/2); 18 | 19 | zv = (z/nplot)*(0:nplot); 20 | u = zeros(length(t),length(zv)); 21 | U = zeros(length(t),length(zv)); 22 | 23 | u(:,1) = u0; 24 | U(:,1) = fftshift(abs(dt*ifft(u(:,1))*nt/sqrt(2*pi)).^2); 25 | 26 | for ii = 1:nplot, 27 | u(:,ii+1) = ssprop(u(:,ii),dt,dz,n1,0,betap,30^2); 28 | U(:,ii+1) = fftshift(abs(dt*fft(u(:,ii+1))/sqrt(2*pi)).^2); 29 | end 30 | 31 | mesh(zv,t,abs(u).^2,... 32 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 33 | set(gca,'YDir','reverse'); 34 | hidden off; 35 | xlim([0 0.1]); 36 | ylim([-8 8]); 37 | xlabel ('Z/L_d'); 38 | ylabel ('(t-\beta_1z)/T_0'); 39 | zlabel ('|u(z,t)|^2/P_0'); 40 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_10.m: -------------------------------------------------------------------------------- 1 | T = 100; % time window (period) 2 | nt = 2^12; % number of points 3 | dt = T/nt; % timestep (dt) 4 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 5 | w = wspace(T,nt); % angular frequency vector 6 | vs = fftshift(w/(2*pi)); % shifted for plotting 7 | 8 | z = 0.1; % total distance 9 | nz = 50; % total number of steps 10 | nplot = 5; % number of plots to make 11 | n1 = round(nz/nplot); % number of steps per plot 12 | nz = n1*nplot; % total number of steps (revised) 13 | dz = z/nz; % step-size 14 | 15 | betap = [0,0,+1]; % dispersion polynomial 16 | 17 | u0 = gaussian(t,0,2*sqrt(log(2))); % u0 = exp(-t.^2/2); 18 | 19 | zv = (z/nplot)*(0:nplot); 20 | u = zeros(length(t),length(zv)); 21 | U = zeros(length(t),length(zv)); 22 | 23 | u(:,1) = u0; 24 | U(:,1) = fftshift(abs(dt*ifft(u(:,1))*nt/sqrt(2*pi)).^2); 25 | 26 | for ii = 1:nplot, 27 | u(:,ii+1) = sspropc(u(:,ii),dt,dz,n1,0,betap,30^2); 28 | U(:,ii+1) = fftshift(abs(dt*ifft(u(:,ii+1))*nt/sqrt(2*pi)).^2); 29 | end 30 | 31 | mesh(zv,t,abs(u).^2,... 32 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 33 | set(gca,'YDir','reverse'); 34 | hidden off; 35 | xlim([0 0.1]); 36 | ylim([-8 8]); 37 | xlabel ('Z/L_d'); 38 | ylabel ('(t-\beta_1z)/T_0'); 39 | zlabel ('|u(z,t)|^2/P_0'); 40 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_11.m: -------------------------------------------------------------------------------- 1 | T = 100; % time window (period) 2 | nt = 2^12; % number of points 3 | dt = T/nt; % timestep (dt) 4 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 5 | w = wspace(T,nt); % angular frequency vector 6 | vs = fftshift(w/(2*pi)); % shifted for plotting 7 | 8 | z = 0.08; % total distance 9 | nz = 50; % total number of steps 10 | dz = z/nz; % step-size 11 | 12 | betap = [0,0,+1]; % dispersion polynomial 13 | 14 | u0 = gaussian(t,0,2*sqrt(log(2))); % u0 = exp(-t.^2/2); 15 | 16 | u = ssrklem(u0,dt,dz,dz*nz,0,betap,30^2); 17 | U = fftshift(abs(dt*ifft(u)*nt/sqrt(2*pi)).^2); 18 | 19 | subplot(121); 20 | plot(t,abs(u).^2); 21 | xlim([-5 5]); 22 | xlabel ('(t-\beta_1z)/T_0'); 23 | ylabel ('|u(z,t)|^2/P_0'); 24 | 25 | subplot(122); 26 | plot(vs,U); 27 | xlim([-10 10]); 28 | xlabel ('(\nu-\nu_0) T_0'); 29 | ylabel ('|U(z,\nu)|^2/P_0'); 30 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_12.m: -------------------------------------------------------------------------------- 1 | T = 100; % time window (period) 2 | nt = 2^12; % number of points 3 | dt = T/nt; % timestep (dt) 4 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 5 | w = wspace(T,nt); % angular frequency vector 6 | vs = fftshift(w/(2*pi)); % shifted for plotting 7 | 8 | z = 0.08; % total distance 9 | nz = 400; % total number of steps 10 | dz = z/nz; % step-size 11 | 12 | betap = [0,0,+1]; % dispersion polynomial 13 | 14 | u0 = gaussian(t,0,2*sqrt(log(2)),1,1,-20); 15 | 16 | u = sspropc(u0,dt,dz,nz,0,betap,30^2); 17 | U = fftshift(abs(dt*ifft(u)*nt/sqrt(2*pi)).^2); 18 | 19 | subplot(121); 20 | plot(t,abs(u).^2); 21 | xlim([-5 5]); 22 | xlabel ('(t-\beta_1z)/T_0'); 23 | ylabel ('|u(z,t)|^2/P_0'); 24 | 25 | subplot(122); 26 | plot(vs,U); 27 | xlim([-10 10]); 28 | xlabel ('(\nu-\nu_0) T_0'); 29 | ylabel ('|U(z,\nu)|^2/P_0'); 30 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_14.m: -------------------------------------------------------------------------------- 1 | T = 100; % time window (period) 2 | nt = 2^12; % number of points 3 | dt = T/nt; % timestep (dt) 4 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 5 | w = wspace(T,nt); % angular frequency vector 6 | vs = fftshift(w/(2*pi)); % shifted for plotting 7 | z = 5; % propagation distance 8 | nz = 2000; % number of steps 9 | dz = z/nz; % step size 10 | 11 | betap = [0,0,0,1]; % dispersion polynomial 12 | 13 | u0 = gaussian(t,0,2*sqrt(log(2))); % u0 = exp(-t.^2/2); 14 | 15 | u = sspropc(u0,dt,dz,nz,0,betap,1); 16 | U = fftshift(abs(dt*ifft(u)*nt/sqrt(2*pi)).^2); 17 | 18 | subplot(121); 19 | plot (t,abs(u).^2); 20 | xlim([-4 16]); 21 | xlabel ('(t-\beta_1z)/T_0'); 22 | ylabel ('|u(z,t)|^2/P_0'); 23 | 24 | subplot(122); 25 | plot (vs,U); 26 | xlim([-0.6 0.6]); 27 | xlabel ('(\nu-\nu_0) T_0'); 28 | ylabel ('|U(z,\nu)|^2/P_0'); 29 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_15.asv: -------------------------------------------------------------------------------- 1 | T = 100; 2 | nt = 2^12; 3 | dt = T/nt; 4 | t = ((1:nt)'-(nt+1)/2)*dt; 5 | w = wspace(T,nt); 6 | vs = fftshift(w/(2*pi)); 7 | z = 0.1; 8 | nz = 2000; 9 | dz = z/nz; 10 | 11 | betap = [0,0,0,1]; 12 | 13 | u0 = gaussian(t,0,2*sqrt(log(2))); 14 | 15 | u = ssprop(u0,dt,dz,nz,0,betap,-10^2); 16 | U = fftshift(abs(dt*ifft(u)*nt/sqrt(2*pi)).^2); 17 | 18 | subplot(121); 19 | plot (t,abs(u).^2); 20 | xlim([-2 4]); 21 | grid on; 22 | xlabel ('(t-\beta_1z)/T_0'); 23 | ylabel ('|u(z,t)|^2/P_0'); 24 | 25 | subplot(122); 26 | plot (vs,U); 27 | xlim([-4 4]); 28 | grid on; 29 | xlabel ('(\nu-\nu_0) T_0'); 30 | ylabel ('|U(z,\nu)|^2/P_0'); 31 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_15.m: -------------------------------------------------------------------------------- 1 | T = 100; 2 | nt = 2^12; 3 | dt = T/nt; 4 | t = ((1:nt)'-(nt+1)/2)*dt; 5 | w = wspace(T,nt); 6 | vs = fftshift(w/(2*pi)); 7 | z = 0.1; 8 | nz = 2000; 9 | dz = z/nz; 10 | 11 | betap = [0,0,0,1]; 12 | 13 | u0 = gaussian(t,0,2*sqrt(log(2))); 14 | 15 | u = sspropc(u0,dt,dz,nz,0,betap,10^2); 16 | U = fftshift(abs(dt*ifft(u)*nt/sqrt(2*pi)).^2); 17 | 18 | subplot(121); 19 | plot (t,abs(u).^2); 20 | xlim([-2 4]); 21 | grid on; 22 | xlabel ('(t-\beta_1z)/T_0'); 23 | ylabel ('|u(z,t)|^2/P_0'); 24 | 25 | subplot(122); 26 | plot (vs,U); 27 | xlim([-4 4]); 28 | grid on; 29 | xlabel ('(\nu-\nu_0) T_0'); 30 | ylabel ('|U(z,\nu)|^2/P_0'); 31 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_16.m: -------------------------------------------------------------------------------- 1 | T = 16; % FFT window size / rep rate 2 | nt = 2^10; % number of points in FFT 3 | dt = T/nt; % normalized time step 4 | z = 20; % total distance 5 | nz = 1000; % total number of steps 6 | nplot = 2; % number of plots to make 7 | n1 = round(nz/nplot); % number of steps per plot 8 | nz = n1*nplot; % total number of steps (revised) 9 | dz = z/nz; % step-size 10 | 11 | t = ((1:nt)'-(nt+1)/2)*dt; % vector of t values 12 | 13 | s = 0.01; % toptical/(2*pi*T0) 14 | 15 | zv = (z/nplot)*(0:nplot); 16 | u = zeros(length(t),length(zv)); 17 | U = zeros(length(t),length(zv)); 18 | 19 | u(:,1) = gaussian(t,0,2*(sqrt(log(2)))); 20 | U(:,1) = fftshift(abs(dt*ifft(u(:,1))*nt/sqrt(2*pi)).^2); 21 | 22 | for ii = 1:nplot, 23 | u(:,ii+1) = sspropc(u(:,ii),dt,dz,n1,0,0,1,0,2*pi*s); 24 | U(:,ii+1) = fftshift(abs(dt*ifft(u(:,ii+1))*nt/sqrt(2*pi)).^2); 25 | end 26 | 27 | plot (t,abs(u).^2); 28 | xlim([-3 3]); 29 | grid on; 30 | xlabel ('(t-\beta_1z)/T_0'); 31 | ylabel ('|u(z,t)|^2/P_0'); 32 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_17.asv: -------------------------------------------------------------------------------- 1 | T = 60; % FFT window size / rep rate 2 | nt = 2^12; % number of points in FFT 3 | dt = T/nt; % normalized time step 4 | z = 20; % total distance 5 | nz = 1000; % total number of steps 6 | dz = z/nz; % step-size 7 | 8 | t = ((1:nt)'-(nt+1)/2)*dt; % vector of t values 9 | w = wspace(t); % vector of w values 10 | vs = fftshift(w/(2*pi)); % used for plotting 11 | 12 | s = 0.01; % toptical/(2*pi*T0) 13 | 14 | u0 = gaussian(t,0,2*(sqrt(log(2)))); 15 | 16 | u = sspropc(u0,dt,dz,nz,0,0,1,1e-15,2*pi*s,10); 17 | U = fftshift(abs(dt*ifft(u)*nt/sqrt(2*pi)).^2); 18 | 19 | plot (vs,U); 20 | xlim([-4 6]); 21 | grid on; 22 | xlabel ('(\nu-\nu_0) T_0'); 23 | ylabel ('|U(z,\nu)|^2/P_0'); 24 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_17.m: -------------------------------------------------------------------------------- 1 | T = 60; % FFT window size / rep rate 2 | nt = 2^12; % number of points in FFT 3 | dt = T/nt; % normalized time step 4 | z = 20; % total distance 5 | nz = 100; % total number of steps 6 | dz = z/nz; % step-size 7 | 8 | t = ((1:nt)'-(nt+1)/2)*dt; % vector of t values 9 | w = wspace(t); % vector of w values 10 | vs = fftshift(w/(2*pi)); % used for plotting 11 | 12 | s = 0.01; % toptical/(2*pi*T0) 13 | 14 | u0 = gaussian(t,0,2*(sqrt(log(2)))); 15 | 16 | u = sspropc(u0,dt,dz,nz,0,0,1,0,2*pi*s,10); 17 | U = fftshift(abs(dt*ifft(u)*nt/sqrt(2*pi)).^2); 18 | 19 | plot (vs,U); 20 | xlim([-4 6]); 21 | grid on; 22 | xlabel ('(\nu-\nu_0) T_0'); 23 | ylabel ('|U(z,\nu)|^2/P_0'); 24 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_18.m: -------------------------------------------------------------------------------- 1 | T = 60; % FFT window size / rep rate 2 | nt = 2^12; % number of points in FFT 3 | dt = T/nt; % normalized time step 4 | z = 0.2; % total distance 5 | nz = 1000; % total number of steps 6 | dz = z/nz; % step-size 7 | 8 | t = ((1:nt)'-(nt+1)/2)*dt; % vector of t values 9 | w = wspace(t); % vector of w values 10 | vs = fftshift(w/(2*pi)); % used for plotting 11 | 12 | s = 0.01; % toptical/(2*pi*T0) 13 | betap = [0,0,1]; % dispersion 14 | 15 | u0 = gaussian(t,0,2*(sqrt(log(2)))); 16 | 17 | u1 = sspropc(u0,dt,dz,nz,0,betap,10^2,0,2*pi*s); 18 | U1 = fftshift(abs(dt*ifft(u1)*nt/sqrt(2*pi)).^2); 19 | 20 | u2 = ssprop(u1,dt,dz,nz,0,betap,10^2,0,2*pi*s); 21 | U2 = fftshift(abs(dt*ifft(u2)*nt/sqrt(2*pi)).^2); 22 | 23 | subplot(221); 24 | plot (t,abs(u1).^2); 25 | xlim([-6 6]); 26 | xlabel ('(t-\beta_1z)/T_0'); 27 | ylabel ('|u(z,t)|^2/P_0'); 28 | 29 | subplot(222); 30 | plot (vs,U1); 31 | xlim([-4 4]); 32 | xlabel ('(t-\beta_1z)/T_0'); 33 | ylabel ('|u(z,t)|^2/P_0'); 34 | 35 | subplot(223); 36 | plot (t,abs(u2).^2); 37 | xlim([-8 8]); 38 | xlabel ('(\nu-\nu_0) T_0'); 39 | ylabel ('|U(z,\nu)|^2/P_0'); 40 | 41 | subplot(224); 42 | plot (vs,U2); 43 | xlim([-4 4]); 44 | xlabel ('(\nu-\nu_0) T_0'); 45 | ylabel ('|U(z,\nu)|^2/P_0'); 46 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_4.asv: -------------------------------------------------------------------------------- 1 | clear;close all;clc; 2 | T = 200; % time window (period) 3 | nt = 2^14; % number of points 4 | dt = T/nt; % timestep (dt) 5 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 6 | w = wspace(T,nt); % angular frequency vector 7 | vs = fftshift(w/(2*pi)); % shifted for plotting 8 | 9 | z = 4.5*pi; % distance 10 | nz = 4; 11 | %for Guassian pulse 12 | u0 = gaussian(t,0,2*sqrt(log(2))); 13 | % Note: only one step (nz=1) is required: 14 | u = ssfm(u0,dt,z/nz,nz,0,0,1,); 15 | %[~,u] = sspropv(0*u0,1*u0,dt,z,1,0,0,0,0,1); 16 | U = fftshift(abs(dt*ifft(u)*nt/sqrt(2*pi)).^2); 17 | 18 | figure; % 19 | subplot(1,2,1); 20 | plot(t,abs(u).^2); 21 | subplot(1,2,2); 22 | plot (vs,U); 23 | xlim([-5 5]); 24 | xlabel ('(\nu-\nu_0) T_0'); 25 | ylabel ('|U(z,\nu)|^2/P_0'); 26 | title ('SPM Pulse Spectrum, Gaussian Pulse (m=1,C=0,\phi = 4.5\pi)'); 27 | 28 | % figure; %plot the SPM-induced phase shift 29 | % phi = unwrap(angle(u)); 30 | % subplot(1,2,1); 31 | % plot(t,phi); 32 | % axis([-5 5 -inf inf]); 33 | % xlabel('T/T_0'); 34 | % ylabel('\phi_N_L'); 35 | % subplot(1,2,2); 36 | % plot(t,-gradient(phi)./gradient(t)); 37 | % axis([-5 5 -20 20]); 38 | % xlabel('T/T_0'); 39 | % ylabel('-\partial\phi_N_L/\partialT'); 40 | 41 | 42 | 43 | %for super-Guassian pulse 44 | % u0 = gaussian(t,0,2*sqrt(log(2)),1,3); 45 | % [u]= ssprop(u0,dt,z,1,0,0,1); 46 | % U = fftshift(abs(dt*ifft(u)*nt/sqrt(2*pi)).^2); 47 | % 48 | % figure; 49 | % plot (vs,U); 50 | % xlim([-6 6]); 51 | % xlabel ('(\nu-\nu_0) T_0'); 52 | % ylabel ('|U(z,\nu)|^2/P_0'); 53 | % title ('SPM Pulse Spectrum, Gaussian Pulse (m=3,C=0,\phi = 4.5\pi)'); 54 | % 55 | % figure; %plot the SPM-induced phase shift 56 | % xlimit = 1.7; 57 | % phi = unwrap(angle(u)); 58 | % subplot(1,2,1); 59 | % plot(t,phi); 60 | % xlim([-xlimit xlimit]); 61 | % xlabel('T/T_0'); 62 | % ylabel('\phi_N_L'); 63 | % subplot(1,2,2); 64 | % plot(t,-gradient(phi)./gradient(t)); 65 | % xlim([-xlimit xlimit]); 66 | % xlabel('T/T_0'); 67 | % ylabel('-\partial\phi_N_L/\partialT'); 68 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_4.m: -------------------------------------------------------------------------------- 1 | clear;close all;clc; 2 | T = 200; % time window (period) 3 | nt = 2^14; % number of points 4 | dt = T/nt; % timestep (dt) 5 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 6 | w = wspace(T,nt); % angular frequency vector 7 | vs = fftshift(w/(2*pi)); % shifted for plotting 8 | 9 | z = 4.5*pi; % distance 10 | nz = 100; 11 | %for Guassian pulse 12 | u0 = gaussian(t,0,2*sqrt(log(2))); 13 | % Note: only one step (nz=1) is required: 14 | u = ssrklem(u0,dt,z/nz,z,0,0,1,0); 15 | %u = sspropc(u0,dt,z/nz,nz,0,0,1,0,3e-15); 16 | U = fftshift(abs(dt*ifft(u)*nt/sqrt(2*pi)).^2); 17 | 18 | 19 | figure; % 20 | subplot(1,2,1); 21 | plot(t,abs(u).^2); 22 | subplot(1,2,2); 23 | plot (vs,U); 24 | xlim([-5 5]); 25 | xlabel ('(\nu-\nu_0) T_0'); 26 | ylabel ('|U(z,\nu)|^2/P_0'); 27 | title ('SPM Pulse Spectrum, Gaussian Pulse (m=1,C=0,\phi = 4.5\pi)'); 28 | 29 | % figure; %plot the SPM-induced phase shift 30 | % phi = unwrap(angle(u)); 31 | % subplot(1,2,1); 32 | % plot(t,phi); 33 | % axis([-5 5 -inf inf]); 34 | % xlabel('T/T_0'); 35 | % ylabel('\phi_N_L'); 36 | % subplot(1,2,2); 37 | % plot(t,-gradient(phi)./gradient(t)); 38 | % axis([-5 5 -20 20]); 39 | % xlabel('T/T_0'); 40 | % ylabel('-\partial\phi_N_L/\partialT'); 41 | 42 | 43 | 44 | %for super-Guassian pulse 45 | % u0 = gaussian(t,0,2*sqrt(log(2)),1,3); 46 | % [u]= ssprop(u0,dt,z,1,0,0,1); 47 | % U = fftshift(abs(dt*ifft(u)*nt/sqrt(2*pi)).^2); 48 | % 49 | % figure; 50 | % plot (vs,U); 51 | % xlim([-6 6]); 52 | % xlabel ('(\nu-\nu_0) T_0'); 53 | % ylabel ('|U(z,\nu)|^2/P_0'); 54 | % title ('SPM Pulse Spectrum, Gaussian Pulse (m=3,C=0,\phi = 4.5\pi)'); 55 | % 56 | % figure; %plot the SPM-induced phase shift 57 | % xlimit = 1.7; 58 | % phi = unwrap(angle(u)); 59 | % subplot(1,2,1); 60 | % plot(t,phi); 61 | % xlim([-xlimit xlimit]); 62 | % xlabel('T/T_0'); 63 | % ylabel('\phi_N_L'); 64 | % subplot(1,2,2); 65 | % plot(t,-gradient(phi)./gradient(t)); 66 | % xlim([-xlimit xlimit]); 67 | % xlabel('T/T_0'); 68 | % ylabel('-\partial\phi_N_L/\partialT'); 69 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_5.m: -------------------------------------------------------------------------------- 1 | T = 200; % time window (period) 2 | nt = 2^14; % number of points 3 | dt = T/nt; % timestep (dt) 4 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 5 | w = wspace(T,nt); % angular frequency vector 6 | vs = fftshift(w/(2*pi)); % shifted for plotting 7 | 8 | z = 4.5*pi; % distance 9 | 10 | subplot(121); 11 | 12 | u0 = gaussian(t,0,2*sqrt(log(2)),1,1,10); 13 | 14 | u = ssrklem(u0,dt,z/10,z,0,0,1); % perform calculations 15 | U = fftshift(abs(dt*ifft(u)*nt/sqrt(2*pi)).^2); 16 | 17 | plot (vs,U); 18 | xlim([-5 5]); 19 | xlabel ('(\nu-\nu_0) T_0'); 20 | ylabel ('|U(z,\nu)|^2/P_0'); 21 | title ('SPM Pulse Spectrum, Gaussian Pulse (m=1,C=+10,\phi = 4.5\pi)'); 22 | 23 | subplot(122); 24 | 25 | u0 = gaussian(t,0,2*sqrt(log(2)),1,1,-10); 26 | 27 | u = ssrklem(u0,dt,z/10,z,0,0,1); % perform calculations 28 | U = fftshift(abs(dt*ifft(u)*nt/sqrt(2*pi)).^2); 29 | 30 | plot (vs,U); 31 | xlim([-6 6]); 32 | xlabel ('(\nu-\nu_0) T_0'); 33 | ylabel ('|U(z,\nu)|^2/P_0'); 34 | title ('SPM Pulse Spectrum, Gaussian Pulse (m=1,C=-10,\phi = 4.5\pi)'); 35 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_7.asv: -------------------------------------------------------------------------------- 1 | T = 100; % time window (period) 2 | nt = 2^12; % number of points 3 | dt = T/nt; % timestep (dt) 4 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 5 | w = wspace(T,nt); % angular frequency vector 6 | vs = fftshift(w/(2*pi)); % shifted for plotting 7 | 8 | z = 5; % total distance 9 | nz = 50; % total number of steps 10 | nplot = 5; % number of plots to make 11 | n1 = round(nz/nplot); % number of steps per plot 12 | nz = n1*nplot; % total number of steps (revised) 13 | dz = z/nz; % step-size 14 | 15 | betap = [0,0,+1]; % dispersion polynomial 16 | 17 | u0 = gaussian(t,0,2*sqrt(log(2))); % u0 = exp(-t.^2/2); 18 | 19 | zv = (z/nplot)*(0:nplot); 20 | u = zeros(length(t),length(zv)); 21 | U = zeros(length(t),length(zv)); 22 | 23 | u(:,1) = u0; 24 | U(:,1) = fftshift(abs(dt*ifft(u(:,1))*nt/sqrt(2*pi)).^2); 25 | 26 | for ii = 1:nplot, 27 | u(:,ii+1) = ssprop(u(:,ii),dt,dz,n1,0,betap,1); 28 | U(:,ii+1) = fftshift(abs(dt*fft(u(:,ii+1))/sqrt(2*pi)).^2); 29 | end 30 | 31 | subplot(211); 32 | mesh(zv,t,abs(u).^2, ... 33 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 34 | set(gca,'YDir','reverse'); 35 | hidden off; 36 | xlim([0 5]); 37 | ylim([-12 12]); 38 | xlabel ('Z/L_d'); 39 | ylabel ('(t-\beta_1z)/T_0'); 40 | zlabel ('|u(z,t)|^2/P_0'); 41 | 42 | subplot(212); 43 | mesh(zv,vs,U,... 44 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 45 | set(gca,'YDir','reverse'); 46 | hidden off; 47 | xlim([0 5]); 48 | ylim([-3 3]); 49 | xlabel ('Z/L_d'); 50 | ylabel ('(\nu-\nu_0) T_0'); 51 | zlabel ('|U(z,\nu)|^2/P_0'); 52 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_7.m: -------------------------------------------------------------------------------- 1 | T = 100; % time window (period) 2 | nt = 2^12; % number of points 3 | dt = T/nt; % timestep (dt) 4 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 5 | w = wspace(T,nt); % angular frequency vector 6 | vs = fftshift(w/(2*pi)); % shifted for plotting 7 | 8 | z = 5; % total distance 9 | nz = 50; % total number of steps 10 | nplot = 5; % number of plots to make 11 | n1 = round(nz/nplot); % number of steps per plot 12 | nz = n1*nplot; % total number of steps (revised) 13 | dz = z/nz; % step-size 14 | 15 | betap = [0,0,+1]; % dispersion polynomial 16 | 17 | u0 = gaussian(t,0,2*sqrt(log(2))); % u0 = exp(-t.^2/2); 18 | 19 | zv = (z/nplot)*(0:nplot); 20 | u = zeros(length(t),length(zv)); 21 | U = zeros(length(t),length(zv)); 22 | 23 | u(:,1) = u0; 24 | U(:,1) = fftshift(abs(dt*ifft(u(:,1))*nt/sqrt(2*pi)).^2); 25 | 26 | for ii = 1:nplot, 27 | u(:,ii+1) = sspropc(u(:,ii),dt,dz,n1,0,betap,1); 28 | U(:,ii+1) = fftshift(abs(dt*ifft(u(:,ii+1))*nt/sqrt(2*pi)).^2); 29 | end 30 | 31 | subplot(211); 32 | mesh(zv,t,abs(u).^2, ... 33 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 34 | set(gca,'YDir','reverse'); 35 | hidden off; 36 | xlim([0 5]); 37 | ylim([-12 12]); 38 | xlabel ('Z/L_d'); 39 | ylabel ('(t-\beta_1z)/T_0'); 40 | zlabel ('|u(z,t)|^2/P_0'); 41 | 42 | subplot(212); 43 | mesh(zv,vs,U,... 44 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 45 | set(gca,'YDir','reverse'); 46 | hidden off; 47 | xlim([0 5]); 48 | ylim([-3 3]); 49 | xlabel ('Z/L_d'); 50 | ylabel ('(\nu-\nu_0) T_0'); 51 | zlabel ('|U(z,\nu)|^2/P_0'); 52 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig4_8.m: -------------------------------------------------------------------------------- 1 | T = 100; % time window (period) 2 | nt = 2^12; % number of points 3 | dt = T/nt; % timestep (dt) 4 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 5 | w = wspace(T,nt); % angular frequency vector 6 | vs = fftshift(w/(2*pi)); % shifted for plotting 7 | 8 | z = 5; % total distance 9 | nz = 50; % total number of steps 10 | nplot = 5; % number of plots to make 11 | n1 = round(nz/nplot); % number of steps per plot 12 | nz = n1*nplot; % total number of steps (revised) 13 | dz = z/nz; % step-size 14 | 15 | betap = [0,0,-1]; % dispersion polynomial 16 | 17 | u0 = gaussian(t,0,2*sqrt(log(2))); % u0 = exp(-t.^2/2); 18 | 19 | zv = (z/nplot)*(0:nplot); 20 | u = zeros(length(t),length(zv)); 21 | U = zeros(length(t),length(zv)); 22 | 23 | u(:,1) = u0; 24 | U(:,1) = fftshift(abs(dt*ifft(u(:,1))*nt/sqrt(2*pi)).^2); 25 | 26 | for ii = 1:nplot, 27 | u(:,ii+1) = sspropc(u(:,ii),dt,dz,n1,0,betap,1); 28 | U(:,ii+1) = fftshift(abs(dt*ifft(u(:,ii+1))*nt/sqrt(2*pi)).^2); 29 | end 30 | 31 | subplot(211); 32 | mesh(zv,t,abs(u).^2,... 33 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 34 | set(gca,'YDir','reverse'); 35 | hidden off; 36 | xlim([0 5]); 37 | ylim([-12 12]); 38 | xlabel ('Z/L_d'); 39 | ylabel ('(t-\beta_1z)/T_0'); 40 | zlabel ('|u(z,t)|^2/P_0'); 41 | 42 | subplot(212); 43 | mesh(zv,vs,U,... 44 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 45 | set(gca,'YDir','reverse'); 46 | hidden off; 47 | xlim([0 5]); 48 | ylim([-3 3]); 49 | xlabel ('Z/L_d'); 50 | ylabel ('(\nu-\nu_0) T_0'); 51 | zlabel ('|U(z,\nu)|^2/P_0'); 52 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig5_14.m: -------------------------------------------------------------------------------- 1 | T = 30; % time window (period) 2 | nt = 2^10; % number of points 3 | dt = T/nt; % timestep (dt) 4 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 5 | 6 | z = 90; % total distance 7 | nz = 2000; % total number of steps 8 | nplot = 45; % number of plots to make 9 | n1 = round(nz/nplot); % number of steps per plot 10 | nz = n1*nplot; % total number of steps (revised) 11 | dz = z/nz; % step-size 12 | 13 | betap = [0,0,-1]; % dispersion polynomial 14 | q0 = 3.5; % separation between pulses 15 | 16 | subplot(221); 17 | 18 | theta = 0; 19 | r = 1; 20 | u0 = solitonpulse(t,-q0) + r*solitonpulse(t,+q0)*exp(i*theta); 21 | 22 | zv = (z/nplot)*(0:nplot); 23 | u = zeros(length(t),length(zv)); 24 | 25 | u(:,1) = u0; 26 | 27 | for ii = 1:nplot, 28 | u(:,ii+1) = sspropc(u(:,ii),dt,dz,n1,0,betap,1); 29 | end 30 | 31 | mesh(zv,t,abs(u).^2, ... 32 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 33 | xlim([0 90]); 34 | ylim([-8 8]); 35 | set(gca,'YDir', 'reverse'); 36 | view(-75,60); 37 | xlabel ('Z/Z_0'); 38 | ylabel ('(t-\beta_1z)/T_0'); 39 | zlabel ('|u(z,t)|^2/P_0'); 40 | 41 | subplot(222); 42 | 43 | theta = pi/4; 44 | r = 1; 45 | u0 = solitonpulse(t,-q0) + r*solitonpulse(t,+q0)*exp(i*theta); 46 | 47 | zv = (z/nplot)*(0:nplot); 48 | u = zeros(length(t),length(zv)); 49 | 50 | u(:,1) = u0; 51 | 52 | for ii = 1:nplot, 53 | u(:,ii+1) = sspropc(u(:,ii),dt,dz,n1,0,betap,1); 54 | end 55 | 56 | mesh(zv,t,abs(u).^2, ... 57 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 58 | xlim([0 90]); 59 | ylim([-8 8]); 60 | set(gca,'YDir', 'reverse'); 61 | view(-75,60); 62 | xlabel ('Z/Z_0'); 63 | ylabel ('(t-\beta_1z)/T_0'); 64 | zlabel ('|u(z,t)|^2/P_0'); 65 | 66 | subplot(223); 67 | 68 | theta = pi/2; 69 | r = 1; 70 | u0 = solitonpulse(t,-q0) + r*solitonpulse(t,+q0)*exp(i*theta); 71 | 72 | zv = (z/nplot)*(0:nplot); 73 | u = zeros(length(t),length(zv)); 74 | 75 | u(:,1) = u0; 76 | 77 | for ii = 1:nplot, 78 | u(:,ii+1) = sspropc(u(:,ii),dt,dz,n1,0,betap,1); 79 | end 80 | 81 | mesh(zv,t,abs(u).^2, ... 82 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 83 | xlim([0 90]); 84 | ylim([-8 8]); 85 | set(gca,'YDir', 'reverse'); 86 | view(-75,60); 87 | xlabel ('Z/Z_0'); 88 | ylabel ('(t-\beta_1z)/T_0'); 89 | zlabel ('|u(z,t)|^2/P_0'); 90 | 91 | subplot(224); 92 | 93 | theta = 0; 94 | r = 1.1; 95 | u0 = solitonpulse(t,-q0) + r*solitonpulse(t,+q0)*exp(i*theta); 96 | 97 | zv = (z/nplot)*(0:nplot); 98 | u = zeros(length(t),length(zv)); 99 | 100 | u(:,1) = u0; 101 | 102 | for ii = 1:nplot, 103 | u(:,ii+1) = sspropc(u(:,ii),dt,dz,n1,0,betap,1); 104 | end 105 | 106 | mesh(zv,t,abs(u).^2, ... 107 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 108 | xlim([0 90]); 109 | ylim([-8 8]); 110 | set(gca,'YDir', 'reverse'); 111 | view(-75,60); 112 | xlabel ('Z/Z_0'); 113 | ylabel ('(t-\beta_1z)/T_0'); 114 | zlabel ('|u(z,t)|^2/P_0'); 115 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig5_15.m: -------------------------------------------------------------------------------- 1 | T = 200; 2 | nt = 2^12; 3 | dt = T/nt; 4 | t = ((1:nt)'-(nt+1)/2)*dt; 5 | w = wspace(T,nt); 6 | vs = fftshift(w/(2*pi)); 7 | z = 3; 8 | nz = 200; 9 | dz = z/nz; 10 | 11 | betap = [0,0,0,1]; 12 | 13 | u0 = solitonpulse(t,0,1); 14 | U0 = fftshift(abs(dt*fft(u0)/sqrt(2*pi)).^2); 15 | 16 | u = sspropc(u0,dt,dz,nz,0,betap,2^2); 17 | U = fftshift(abs(dt*fft(u)/sqrt(2*pi)).^2); 18 | 19 | subplot(121); 20 | plot (t,abs(u0).^2,t,abs(u).^2); 21 | xlim([-10 20]); 22 | grid on; 23 | xlabel ('(t-\beta_1z)/T_0'); 24 | ylabel ('|u(z,t)|^2/P_0'); 25 | 26 | subplot(122); 27 | plot (vs,U0,vs,U); 28 | xlim([-0.8 0.8]); 29 | grid on; 30 | xlabel ('(\nu-\nu_0) T_0'); 31 | ylabel ('|U(z,\nu)|^2/P_0'); 32 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig5_16.m: -------------------------------------------------------------------------------- 1 | T = 16; % FFT window size / rep rate 2 | nt = 2^10; % number of points in FFT 3 | dt = T/nt; % normalized time step 4 | z = 10; % total distance 5 | nz = 1000; % total number of steps 6 | nplot = 2; % number of plots to make 7 | n1 = round(nz/nplot); % number of steps per plot 8 | nz = n1*nplot; % total number of steps (revised) 9 | dz = z/nz; % step-size 10 | 11 | t = ((1:nt)'-(nt+1)/2)*dt; % vector of t values 12 | 13 | s = 0.2; % toptical/(2*pi*T0) 14 | betap = [0,0,-1]; % dispersion 15 | 16 | zv = (z/nplot)*(0:nplot); 17 | u = zeros(length(t),length(zv)); 18 | 19 | u(:,1) = solitonpulse(t); 20 | 21 | for ii = 1:nplot, 22 | u(:,ii+1) = sspropc(u(:,ii),dt,dz,n1,0,betap,1,0,2*pi*s); 23 | end 24 | 25 | plot (t,abs(u).^2); 26 | xlim([-5 5]); 27 | grid on; 28 | xlabel ('(t-\beta_1z)/T_0'); 29 | ylabel ('|u(z,t)|^2/P_0'); 30 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig5_17.m: -------------------------------------------------------------------------------- 1 | T = 50; % FFT window size / rep rate 2 | nt = 2^10; % number of points in FFT 3 | dt = T/nt; % normalized time step 4 | z = 5*(pi/2); % total distance 5 | nz = 1000; % total number of steps 6 | nplot = 5; % number of plots to make 7 | n1 = round(nz/nplot); % number of steps per plot 8 | nz = n1*nplot; % total number of steps (revised) 9 | dz = z/nz; % step-size 10 | 11 | t = ((1:nt)'-(nt+1)/2)*dt; % vector of t values 12 | 13 | s = 0.2; % toptical/(2*pi*T0) 14 | betap = [0,0,-1]; % dispersion 15 | 16 | zv = (z/nplot)*(0:nplot); 17 | u = zeros(length(t),length(zv)); 18 | 19 | u(:,1) = solitonpulse(t,0,1,2); 20 | 21 | for ii = 1:nplot, 22 | u(:,ii+1) = sspropc(u(:,ii),dt,dz,n1,0,betap,1,0,2*pi*s); 23 | end 24 | 25 | mesh(zv/(pi/2),t,abs(u).^2, ... 26 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 27 | set(gca,'YDir','reverse'); 28 | hidden off; 29 | xlim([0 5]); 30 | ylim([-16 16]); 31 | xlabel ('Z/Z_0'); 32 | ylabel ('(t-\beta_1z)/T_0'); 33 | zlabel ('|u(z,t)|^2/P_0'); 34 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig5_18.m: -------------------------------------------------------------------------------- 1 | T = 50; % FFT window size / rep rate 2 | nt = 2^10; % number of points in FFT 3 | dt = T/nt; % normalized time step 4 | z = 5*(pi/2); % total distance 5 | nz = 1000; % total number of steps 6 | nplot = 5; % number of plots to make 7 | n1 = round(nz/nplot); % number of steps per plot 8 | nz = n1*nplot; % total number of steps (revised) 9 | dz = z/nz; % step-size 10 | 11 | t = ((1:nt)'-(nt+1)/2)*dt; % vector of t values 12 | 13 | tr = 0.01; % toptical/(2*pi*T0) 14 | betap = [0,0,-1]; % dispersion 15 | 16 | zv = (z/nplot)*(0:nplot); 17 | u = zeros(length(t),length(zv)); 18 | 19 | u(:,1) = solitonpulse(t,0,1,2); 20 | 21 | for ii = 1:nplot, 22 | u(:,ii+1) = sspropc(u(:,ii),dt,dz,n1,0,betap,1,tr); 23 | end 24 | 25 | mesh(zv/(pi/2),t,abs(u).^2, ... 26 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 27 | set(gca,'YDir', 'reverse'); 28 | hidden off; 29 | xlim([0 5]); 30 | ylim([-20 20]); 31 | xlabel ('Z/Z_0'); 32 | ylabel ('(t-\beta_1z)/T_0'); 33 | zlabel ('|u(z,t)|^2/P_0'); 34 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig5_19.m: -------------------------------------------------------------------------------- 1 | T =200; % FFT window size / rep rate 2 | nt = 2^12; % number of points in FFT 3 | dt = T/nt; % normalized time step 4 | z = 5*(pi/2); % total distance 5 | nz = 500; % total number of steps 6 | dz = z/nz; % step-size 7 | 8 | t = ((1:nt)'-(nt+1)/2)*dt; % vector of t values 9 | w = wspace(t); % vector of w values 10 | vs = fftshift(w/(2*pi)); % used for plotting 11 | 12 | tr = 0.01; % toptical/(2*pi*T0) 13 | betap = [0,0,-1]; % dispersion 14 | 15 | u0 = solitonpulse(t,0,1,2); 16 | U0 = fftshift(abs(dt*fft(u0)/sqrt(2*pi)).^2); 17 | 18 | u = sspropc(u0,dt,dz,nz,0,betap,1,tr); 19 | U = fftshift(abs(dt*fft(u)/sqrt(2*pi)).^2); 20 | 21 | plot (vs,U0,vs,U); 22 | xlim([-2 2]); 23 | grid on; 24 | xlabel ('(\nu-\nu_0) T_0'); 25 | ylabel ('|U(z,\nu)|^2/P_0'); 26 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig5_21.m: -------------------------------------------------------------------------------- 1 | clc; 2 | T = 100; % time window (period) 3 | nt = 2^12; % number of points 4 | dt = T/nt; % timestep (dt) 5 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 6 | w = wspace(T,nt); % angular frequency vector 7 | vs = fftshift(w/(2*pi)); % shifted for plotting 8 | 9 | z = 3*(pi/2); % total distance 10 | nz = 5000; % total number of steps 11 | nplot = 3; % number of plots to make 12 | n1 = round(nz/nplot); % number of steps per plot 13 | nz = n1*nplot; % total number of steps (revised) 14 | dz = z/nz; % step-size 15 | 16 | beta2 = -1; 17 | beta3 = .03; 18 | betap = [0,0,beta2,beta3]; % dispersion polynomial 19 | s = 0.05; 20 | tr = 0.1; 21 | N = 2; 22 | 23 | u0 = solitonpulse(t); 24 | 25 | zv = (z/nplot)*(0:nplot); 26 | u = zeros(length(t),length(zv)); 27 | U = zeros(length(t),length(zv)); 28 | 29 | u(:,1) = u0; 30 | U(:,1) = fftshift(abs(dt*fft(u(:,1))/sqrt(2*pi)).^2); 31 | 32 | for ii = 1:nplot, 33 | u(:,ii+1) = sspropc(u(:,ii),dt,dz,n1,0,betap,N^2,tr,2*pi*s); 34 | U(:,ii+1) = fftshift(abs(dt*fft(u(:,ii+1))/sqrt(2*pi)).^2); 35 | end 36 | 37 | subplot(211); 38 | mesh(zv/(pi/2),t,abs(u).^2, ... 39 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 40 | set(gca,'YDir', 'reverse'); 41 | hidden off; 42 | xlim([0 3]); 43 | ylim([-25 25]); 44 | xlabel ('Z/Z_0'); 45 | ylabel ('(t-\beta_1z)/T_0'); 46 | zlabel ('|u(z,t)|^2/P_0'); 47 | 48 | subplot(212); 49 | mesh(zv/(pi/2),vs,U, ... 50 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 51 | set(gca,'YDir', 'reverse'); 52 | hidden off; 53 | xlim([0 3]); 54 | ylim([-2 2]); 55 | xlabel ('Z/L_d'); 56 | ylabel ('(\nu-\nu_0) T_0'); 57 | zlabel ('|U(z,\nu)|^2/P_0'); 58 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig5_4.m: -------------------------------------------------------------------------------- 1 | T = 50; % time window (period) 2 | nt = 2^12; % number of points 3 | dt = T/nt; % timestep (dt) 4 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 5 | 6 | z = pi/2; % total distance 7 | nz = 500; % total number of steps 8 | nplot = 32; % number of plots to make 9 | n1 = round(nz/nplot); % number of steps per plot 10 | nz = n1*nplot; % total number of steps (revised) 11 | dz = z/nz; % step-size 12 | 13 | betap = [0,0,-1]; % dispersion polynomial 14 | 15 | zv = (z/nplot)*(0:nplot); 16 | u = zeros(length(t),length(zv)); 17 | U = zeros(length(t),length(zv)); 18 | 19 | u(:,1) = solitonpulse(t,0,1,3); % input pulse 20 | 21 | for ii = 1:nplot, 22 | u(:,ii+1) = ssprop(u(:,ii),dt,dz,n1,0,betap,1); 23 | end 24 | 25 | mesh(zv/(pi/2),t,abs(u).^2,... 26 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 27 | set(gca,'YDir','reverse'); 28 | xlim([0 1]); 29 | ylim([-5 5]); 30 | xlabel ('Z/Z_0'); 31 | ylabel ('(t-\beta_1z)/T_0'); 32 | zlabel ('|u(z,t)|^2/P_0'); 33 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig5_5.m: -------------------------------------------------------------------------------- 1 | T = 50; % time window (period) 2 | nt = 2^12; % number of points 3 | dt = T/nt; % timestep (dt) 4 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 5 | w = wspace(T,nt); % angular frequency vector 6 | vs = fftshift(w/(2*pi)); % shifted for plotting 7 | 8 | z = pi/2; % total distance 9 | nz = 500; % total number of steps 10 | nplot = 10; % number of plots to make 11 | n1 = round(nz/nplot); % number of steps per plot 12 | nz = n1*nplot; % total number of steps (revised) 13 | dz = z/nz; % step-size 14 | 15 | betap = [0,0,-1]; % dispersion polynomial 16 | 17 | zv = (z/nplot)*(0:nplot); 18 | u = zeros(length(t),length(zv)); 19 | U = zeros(length(t),length(zv)); 20 | 21 | u(:,1) = solitonpulse(t,0,1,3); % input pulse 22 | U(:,1) = fftshift(abs(dt*fft(u(:,1))/sqrt(2*pi)).^2); 23 | 24 | for ii = 1:nplot, 25 | u(:,ii+1) = sspropc(u(:,ii),dt,dz,n1,0,betap,1); 26 | U(:,ii+1) = fftshift(abs(dt*fft(u(:,ii+1))/sqrt(2*pi)).^2); 27 | end 28 | 29 | mesh(zv/(pi/2),vs,U,... 30 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 31 | set(gca,'YDir','reverse'); 32 | hidden off; 33 | xlim([0 1]); 34 | ylim([-5 5]); 35 | xlabel ('Z/Z_0'); 36 | ylabel ('(\nu-\nu_0) T_0'); 37 | zlabel ('|U(z,\nu)|^2/P_0'); 38 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig5_7.m: -------------------------------------------------------------------------------- 1 | T = 100; % time window (period) 2 | nt = 2^12; % number of points 3 | dt = T/nt; % timestep (dt) 4 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 5 | 6 | z = 18; % total distance 7 | nz = 500; % total number of steps 8 | nplot = 9; % number of plots to make 9 | n1 = round(nz/nplot); % number of steps per plot 10 | nz = n1*nplot; % total number of steps (revised) 11 | dz = z/nz; % step-size 12 | 13 | betap = [0,0,-1]; % dispersion polynomial 14 | 15 | zv = (z/nplot)*(0:nplot); 16 | u = zeros(length(t),length(zv)); 17 | U = zeros(length(t),length(zv)); 18 | 19 | u(:,1) = sechpulse(t,0,2*acosh(sqrt(2)),1,-0.5); 20 | 21 | for ii = 1:nplot, 22 | u(:,ii+1) = ssprop(u(:,ii),dt,dz,n1,0,betap,1); 23 | end 24 | 25 | h = mesh(zv,t,abs(u).^2,... 26 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 27 | set(gca,'YDir','reverse'); 28 | hidden off; 29 | xlim([0 18]); 30 | ylim([-16 16]); 31 | xlabel ('Z/Z_0'); 32 | ylabel ('(t-\beta_1z)/T_0'); 33 | zlabel ('|u(z,t)|^2/P_0'); 34 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig5_9.asv: -------------------------------------------------------------------------------- 1 | T = 50; % time window (period) 2 | nt = 2^12; % number of points 3 | dt = T/nt; % timestep (dt) 4 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 5 | w = wspace(T,nt); % angular frequency vector 6 | vs = fftshift(w/(2*pi)); % shifted for plotting 7 | 8 | z = 2*(pi/2); % total distance 9 | nz = 1000; % total number of steps 10 | nplot = 30; % number of plots to make 11 | n1 = round(nz/nplot); % number of steps per plot 12 | nz = n1*nplot; % total number of steps (revised) 13 | dz = z/nz; % step-size 14 | 15 | betap = [0,0,+1]; % dispersion polynomial 16 | 17 | u0 = 3*tanh(t).*exp(1i*pi*t/T); 18 | 19 | zv = (z/nplot)*(0:nplot); 20 | u = zeros(length(t),length(zv)); 21 | U = zeros(length(t),length(zv)); 22 | 23 | u(:,1) = u0; 24 | U(:,1) = fftshift(abs(dt*fft(u(:,1))/sqrt(2*pi)).^2); 25 | 26 | for ii = 1:nplot, 27 | u(:,ii+1) = sspropc(u(:,ii),dt,dz,n1,0,betap,1); 28 | U(:,ii+1) = fftshift(abs(dt*fft(u(:,ii+1))/sqrt(2*pi)).^2); 29 | end 30 | 31 | mesh(zv/(pi/2),t,abs(u).^2, ... 32 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 33 | xlim([0 2]); 34 | ylim([-15 15]); 35 | xlabel ('Z/Z_0'); 36 | ylabel ('(t-\beta_1z)/T_0'); 37 | zlabel ('|u(z,t)|^2/P_0'); 38 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/fig5_9.m: -------------------------------------------------------------------------------- 1 | T = 50; % time window (period) 2 | nt = 2^12; % number of points 3 | dt = T/nt; % timestep (dt) 4 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 5 | w = wspace(T,nt); % angular frequency vector 6 | vs = fftshift(w/(2*pi)); % shifted for plotting 7 | 8 | z = 2*(pi/2); % total distance 9 | nz = 1000; % total number of steps 10 | nplot = 30; % number of plots to make 11 | n1 = round(nz/nplot); % number of steps per plot 12 | nz = n1*nplot; % total number of steps (revised) 13 | dz = z/nz; % step-size 14 | 15 | betap = [0,0,+1]; % dispersion polynomial 16 | 17 | u0 = 3*tanh(t).*exp(1i*pi*t/T); 18 | 19 | zv = (z/nplot)*(0:nplot); 20 | u = zeros(length(t),length(zv)); 21 | U = zeros(length(t),length(zv)); 22 | 23 | u(:,1) = u0; 24 | U(:,1) = fftshift(abs(dt*fft(u(:,1))/sqrt(2*pi)).^2); 25 | 26 | for ii = 1:nplot, 27 | u(:,ii+1) = ssprop(u(:,ii),dt,dz,n1,0,betap,1); 28 | U(:,ii+1) = fftshift(abs(dt*fft(u(:,ii+1))/sqrt(2*pi)).^2); 29 | end 30 | 31 | mesh(zv/(pi/2),t,abs(u).^2, ... 32 | 'MeshStyle', 'col', 'EdgeColor', 'black'); 33 | xlim([0 2]); 34 | ylim([-15 15]); 35 | xlabel ('Z/Z_0'); 36 | ylabel ('(t-\beta_1z)/T_0'); 37 | zlabel ('|u(z,t)|^2/P_0'); 38 | -------------------------------------------------------------------------------- /ssprop-3.0.1/examples/splitsteptest.m: -------------------------------------------------------------------------------- 1 | % This m-file is designed as a test of the splitstep routine. 2 | % When it is working correctly, this should reproduce the results 3 | % of Agrawal, Fig. 4.14. Specifically, this routine simulates 4 | % the case of pulse propagation at the zero-dispersion point, in 5 | % the presence of nonlinearity. This test case was chosen 6 | % because both the output waveform and the output spectrum are 7 | % asymmetric, which allows one to identify sign errors in the 8 | % algorithms. 9 | 10 | T = 100; % time window 11 | nt = 2^12; % number of points 12 | dt = T/nt; % timestep 13 | t = ((1:nt)'-(nt+1)/2)*dt; % time vector 14 | w = wspace(T,nt); % angular frequency vector 15 | vs = fftshift(w/(2*pi)); % frequency (shifted for plotting) 16 | 17 | z = 5; % total distance 18 | nz = 2000; % number of steps 19 | dz = z/nz; % stepsize 20 | alpha = 0; % loss coefficient 21 | betap = [0,0,0,1]; % dispersion polynomial 22 | gamma = 1; % nonlinearity coefficient 23 | u0 = exp(-t.^2); % input pulse (Gaussian) 24 | 25 | tic; 26 | u = sspropc(u0,dt,dz,nz,alpha,betap,gamma); % propagate signal 27 | toc; 28 | 29 | subplot(211); 30 | plot (t,abs(u0).^2,t,abs(u).^2); 31 | xlim([-4 16]); 32 | grid on; 33 | xlabel ('(t-\beta_1z)/T_0'); 34 | ylabel ('|u(z,t)|^2/P_0'); 35 | title ('Initial and Final Pulse Shapes'); 36 | 37 | subplot(212); 38 | U0 = fftshift(abs(dt*fft(u0)/sqrt(2*pi)).^2); % input power spectrum 39 | U = fftshift(abs(dt*fft(u)/sqrt(2*pi)).^2); % output power spectrum 40 | plot (vs,U0,vs,U); 41 | xlim([-0.6 0.6]); 42 | grid on; 43 | xlabel ('(\nu-\nu_0) T_0'); 44 | ylabel ('|U(z,\nu)|^2/P_0'); 45 | title ('Initial and Final Pulse Spectra'); 46 | -------------------------------------------------------------------------------- /ssprop-3.0.1/ssfm.asv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/ssprop-3.0.1/ssfm.asv -------------------------------------------------------------------------------- /ssprop-3.0.1/ssfm.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/ssprop-3.0.1/ssfm.m -------------------------------------------------------------------------------- /ssprop-3.0.1/ssprop.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/ssprop-3.0.1/ssprop.m -------------------------------------------------------------------------------- /ssprop-3.0.1/sspropv.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/ssprop-3.0.1/sspropv.m -------------------------------------------------------------------------------- /ssprop-3.0.1/ssrklem.asv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/ssprop-3.0.1/ssrklem.asv -------------------------------------------------------------------------------- /ssprop-3.0.1/ssrklem.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/ssprop-3.0.1/ssrklem.m -------------------------------------------------------------------------------- /ssprop-3.0.1/tools/filter_gaus.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/ssprop-3.0.1/tools/filter_gaus.m -------------------------------------------------------------------------------- /ssprop-3.0.1/tools/filter_rect.m: -------------------------------------------------------------------------------- 1 | function Eout = filter_rect(Ein,f3dB) 2 | % filter_rect(Ein,f3dB) 3 | % filter the input signal with a rect function 4 | global Ts; 5 | 6 | N = size(Ein,1); 7 | % the k element in the Ein corresponds to the frequency of (k-N/2)/Ts/N 8 | k = wspace(2*pi,N); 9 | w = k/Ts/N; 10 | 11 | Eout = Ein.*(abs(w)<(f3dB/2)); 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /ssprop-3.0.1/tools/fwhm.m: -------------------------------------------------------------------------------- 1 | function [delta,t0] = fwhm(t,u,tr) 2 | 3 | % This function computes the intensity full-width at half maximum 4 | % (FWHM) of the periodic signal u. 5 | % 6 | % USAGE: 7 | % 8 | % delta = fwhm(t,u); 9 | % delta = fwhm(t,u,tr); 10 | % [delta,t0] = fwhm(t,u); 11 | % [delta,t0] = fwhm(t,u,tr); 12 | % 13 | % INPUT: 14 | % 15 | % t - vector of evenly spaced times 16 | % u - signal to compute the width of (assumed to be strictly 17 | % positive and periodic). 18 | % tr - if tr is a scalar, the function computes the FWHM of 19 | % the local maximum nearest to tr. If tr is a 2-vector, the 20 | % function finds the maximum which lies in the time range 21 | % specified by tr. If tr is not given, the function finds 22 | % the width of the tallest peak in the function u. 23 | % 24 | % OUTPUT: 25 | % 26 | % delta - the full-width at half maximum of u 27 | % t0 - (optional) the temporal location of the peak 28 | % 29 | % NOTES: 30 | % 31 | % u should be a strictly positive, real quantity, for example 32 | % a power or intensity. t should be a vector of evenly-spaced 33 | % points in time, representing one full period of a periodic 34 | % sequence. t and tr must have the same dimensions. 35 | 36 | nt = length(u); 37 | dt = diff(t(1:2)); 38 | %T = dt*nt; 39 | k0 = (1:nt)'; 40 | kl = [nt,1:nt-1]'; 41 | kr = [2:nt,1]'; 42 | 43 | if nargin < 3 44 | [~,ipeak] = max(u); 45 | else 46 | if length(tr) == 2 47 | kv = find(tr(1) < t & t < tr(2)); 48 | [~,ipeak] = max(u(kv)); 49 | ipeak = k0(kv(ipeak)); 50 | elseif length(tr) == 1 51 | itr = interp1(t,k0,tr); 52 | localmax = find(u(k0) >= u(kl) & u(k0) > u(kr)); 53 | idiff = mod(localmax - itr + nt/2 - 1, nt) - nt/2 + 1; 54 | [~,i] = min(abs(idiff)); 55 | ipeak = localmax(i); 56 | end 57 | end 58 | 59 | % 3 point quadratic fit to extract peak value 60 | 61 | pv = [kl(ipeak),k0(ipeak),kr(ipeak)]; 62 | coefs = polyfit((-1:1),[u(pv(1)),u(pv(2)),u(pv(3))],2); 63 | coefs1 = polyder(coefs); 64 | idt = roots(coefs1); 65 | t0 = t(ipeak) + idt*dt; 66 | umax = polyval(coefs,idt); 67 | 68 | % find first rising half-max point to left of ipeak 69 | 70 | irise = find(u(k0) <= umax/2 & u(kr) > umax/2); 71 | irise = irise + (umax/2 - u(k0(irise)))./(u(kr(irise)) - u(k0(irise))); 72 | irise = min(mod(ipeak-irise,nt)); 73 | 74 | % find first falling half-max point to right of ipeak 75 | 76 | ifall = find(u(k0) >= umax/2 & u(kr) < umax/2); 77 | ifall = ifall + (u(k0(ifall)) - umax/2)./(u(k0(ifall)) - u(kr(ifall))); 78 | ifall = min(mod(ifall-ipeak,nt)); 79 | 80 | delta = dt*(irise+ifall); 81 | -------------------------------------------------------------------------------- /ssprop-3.0.1/tools/gaussian.m: -------------------------------------------------------------------------------- 1 | function u = gaussian(t,t0,FWHM,P0,m,C) 2 | 3 | % This function computes a gaussian or supergaussian pulse with 4 | % the specified parameters: 5 | % 6 | % sqrt(P0) * exp{ -[(1+iC)/2] * [(t-t0)/T]^(2m) } 7 | % where T = FWHM/(2*sqrt(log(2))) 8 | % 9 | % USAGE: 10 | % 11 | % u = gaussian (t); 12 | % u = gaussian (t,t0); 13 | % u = gaussian (t,t0,FWHM); 14 | % u = gaussian (t,t0,FWHM,P0); 15 | % u = gaussian (t,t0,FWHM,P0,m); 16 | % u = gaussian (t,t0,FWHM,P0,m,C); 17 | % 18 | % INPUT: 19 | % 20 | % t vector of times at which to compute u 21 | % t0 center of pulse (default = 0) 22 | % FWHM full-width at half-intensity of pulse (default = 1) 23 | % P0 peak intensity (|u|^2 at t=t0) of pulse (default = 1) 24 | % m Gaussian order (default = 1) 25 | % C chirp parameter (default = 0) 26 | % 27 | % OUTPUT: 28 | % 29 | % u vector of the same size as t, representing pulse 30 | % amplitude 31 | % 32 | % NOTES: 33 | % 34 | % In order to produce a standard gaussian pulse of the form 35 | % exp(-t.^2/2), you can use: 36 | % 37 | % u = gaussian(t,0,2*sqrt(log(2))); 38 | 39 | if (nargin<6) 40 | C = 0; 41 | end 42 | if (nargin<5) 43 | m = 1; 44 | end 45 | if (nargin<4) 46 | P0 = 1; 47 | end 48 | if (nargin<3) 49 | FWHM = 1; 50 | end 51 | if (nargin<2) 52 | t0 = 0; 53 | end 54 | u = sqrt(P0)*pow2(-((1+1i*C)/2)*(2*(t-t0)/FWHM).^(2*m)); 55 | -------------------------------------------------------------------------------- /ssprop-3.0.1/tools/ramanhR.asv: -------------------------------------------------------------------------------- 1 | function hR =ramanhR(t) 2 | % This function computes the raman response function 3 | % 4 | % USAGE: 5 | % 6 | % u = ramanhR (t);t unit /ps 7 | 8 | tau1 = 12.2e-3; %ps 9 | tau2 = 32e-3; %ps 10 | taub = 96e-3; %ps 11 | fb = 0.21; 12 | tres = t-t(1); 13 | ha = ((tau1^2+tau2^2)/(tau1*tau2^2)).*sin(tres./tau1).*exp(-tres./tau2); 14 | hb=(2*taub-tres)./taub^2 .* exp(-tres./taub); 15 | hR=(1-fb).*taub.*ha + fb .* hb; 16 | 17 | 18 | %t1 = 12.2e-3; % raman parameter t1 [ps] 19 | %t2 = 32e-3; % raman parameter t2 [ps] 20 | tb = 96e-3; % ps 21 | fc = 0.04; 22 | fb = 0.21; 23 | fa = 1 - fc - fb; 24 | tres = t-t(1); % time starting in 0 25 | 26 | ha =((t1^2+t2^2)/(t1*t2^2)).*exp(-tres/t2).*sin(tres/t1); 27 | hb = ((2*tb - tres)./tb^2).*exp(-tres/tb); 28 | hr = (fa + fc)*ha + fb*hb; %Raman responce function (ps^-1) 29 | 30 | end -------------------------------------------------------------------------------- /ssprop-3.0.1/tools/ramanhR.m: -------------------------------------------------------------------------------- 1 | function hR =ramanhR(t) 2 | % This function computes the raman response function 3 | % 4 | % USAGE: 5 | % 6 | % u = ramanhR (t);t unit /ps 7 | 8 | tau1 = 12.2e-3; %ps 9 | tau2 = 32e-3; %ps 10 | taub = 96e-3; %ps 11 | fb = 0.21; 12 | tres = t-t(1); 13 | ha = ((tau1^2+tau2^2)/(tau1*tau2^2))*exp(-tres/tau2).*sin(tres/tau1); 14 | hb=(2*taub-tres)/taub^2 .* exp(-tres/taub); 15 | hR=(1-fb)*ha + fb * hb; 16 | 17 | end -------------------------------------------------------------------------------- /ssprop-3.0.1/tools/ramanhR_1989.m: -------------------------------------------------------------------------------- 1 | function hR =ramanhR_1989(t) 2 | % This function computes the raman response function 3 | % 4 | % USAGE: 5 | % 6 | % u = ramanhR (t);t unit /ps 7 | 8 | tau1 = 12.2e-3; %ps 9 | tau2 = 32e-3; %ps 10 | 11 | tres = t-t(1); 12 | hR = ((tau1^2+tau2^2)/(tau1*tau2^2))*exp(-tres/tau2).*sin(tres/tau1); 13 | end -------------------------------------------------------------------------------- /ssprop-3.0.1/tools/sechpulse.m: -------------------------------------------------------------------------------- 1 | function u = sechpulse(t,t0,FWHM,P0,C) 2 | 3 | % This function computes a hyperbolic secant pulse with the 4 | % specified parameters: 5 | % 6 | % sqrt(P0)*sech((t-t0)/T)*exp{-i(C/2)*[(t-t0)/T]^2} 7 | % where T = FWHM / (2*acosh(sqrt(2))) 8 | % 9 | % USAGE: 10 | % 11 | % u = sechpulse (t); 12 | % u = sechpulse (t,t0); 13 | % u = sechpulse (t,t0,FWHM); 14 | % u = sechpulse (t,t0,FWHM,P0); 15 | % u = sechpulse (t,t0,FWHM,P0,C); 16 | % 17 | % INPUT: 18 | % 19 | % t vector of times at which to compute u 20 | % t0 center of pulse (default = 0) 21 | % FWHM full-width at half-intensity of pulse (default = 1) 22 | % P0 peak intensity (|u|^2 at t=t0) of pulse (default = 1) 23 | % C chirp parameter (default = 0) 24 | % 25 | % OUTPUT: 26 | % 27 | % u vector of the same size as t, representing pulse 28 | % amplitude 29 | 30 | 31 | if (nargin<5) 32 | C = 0; 33 | end 34 | if (nargin<4) 35 | P0 = 1; 36 | end 37 | if (nargin<3) 38 | FWHM = 1; 39 | end 40 | if (nargin<2) 41 | t0 = 0; 42 | end 43 | 44 | T0 = FWHM/(2*acosh(sqrt(2))); 45 | u = sqrt(P0)*sech((t-t0)/T0).*exp(-1i*C*(t-t0).^2/(2*T0^2)); 46 | -------------------------------------------------------------------------------- /ssprop-3.0.1/tools/solitonpulse.m: -------------------------------------------------------------------------------- 1 | function u = solitonpulse(t,t0,epsilon,N) 2 | 3 | % This function computes a soliton (sech) amplitude pulse with 4 | % the following parameters: 5 | % 6 | % N*epsilon*sech(epsilon(t-t0)) 7 | % 8 | % USAGE: 9 | % 10 | % u = solitonpulse (t); 11 | % u = solitonpulse (t,t0); 12 | % u = solitonpulse (t,t0,epsilon); 13 | % u = solitonpulse (t,t0,epsilon,N); 14 | % 15 | % INPUT: 16 | % 17 | % t vector of times at which to compute u 18 | % t0 center of pulse (default = 0) 19 | % epsilon scale factor for solition (default = 1) 20 | % note: make epsilon=2*acosh(sqrt(2)) to get FWHM = 1 21 | % N soliton order (default = 1) 22 | % 23 | % OUTPUT: 24 | % 25 | % u vector of the same size as t, representing pulse 26 | % amplitude 27 | 28 | if (nargin<4) 29 | N = 1; 30 | end 31 | if (nargin<3) 32 | epsilon = 1; 33 | end 34 | if (nargin<2) 35 | t0 = 0; 36 | end 37 | 38 | u = N*epsilon*sech(epsilon*(t-t0)); 39 | 40 | -------------------------------------------------------------------------------- /ssprop-3.0.1/tools/stokes.m: -------------------------------------------------------------------------------- 1 | function [S0,S1,S2,S3] = stokes(ux,uy) 2 | 3 | S0 = abs(ux).^2 + abs(uy).^2; 4 | S1 = abs(ux).^2 - abs(uy).^2; 5 | S2 = 2*real(conj(ux).*uy); 6 | S3 = 2*imag(conj(ux).*uy); 7 | -------------------------------------------------------------------------------- /ssprop-3.0.1/tools/wspace.m: -------------------------------------------------------------------------------- 1 | function w = wspace(t,nt) 2 | 3 | % This function constructs a linearly-spaced vector of angular 4 | % frequencies that correspond to the points in an FFT spectrum. 5 | % The second half of the vector is aliased to negative 6 | % frequencies. 7 | % 8 | % USAGE 9 | % 10 | % w = wspace(tv); 11 | % w = wspace(t,nt); 12 | % 13 | % INPUT 14 | % 15 | % tv - vector of linearly-spaced time values 16 | % t - scalar representing the periodicity of the time sequence 17 | % nt - Number of points in time sequence 18 | % (should only be provided if first argument is scalar) 19 | % 20 | % OUTPUT 21 | % 22 | % w - vector of angular frequencies 23 | % 24 | % EXAMPLE 25 | % 26 | % t = linspace(-10,10,2048)'; % set up time vector 27 | % x = exp(-t.^2); % construct time sequence 28 | % w = wspace(t); % construct w vector 29 | % Xhat = fft(x); % calculate spectrum 30 | % plot(w,abs(Xhat)) % plot spectrum 31 | % 32 | % AUTHOR: Thomas E. Murphy (tem@umd.edu) 33 | 34 | if (nargin<2) 35 | nt = length(t); 36 | dt = t(2) - t(1); 37 | t = t(nt) - t(1) + dt; 38 | end 39 | 40 | if (nargin == 2) 41 | dt = t/nt; 42 | end 43 | 44 | w = 2*pi*(0:nt-1)'/t; 45 | kv = find(w >= pi/dt); 46 | w(kv) = w(kv) - 2*pi/dt; 47 | -------------------------------------------------------------------------------- /testforfopa.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/testforfopa.m -------------------------------------------------------------------------------- /光学仿真/3/FOPA.m: -------------------------------------------------------------------------------- 1 | clear all 2 | format long e 3 | global Ts; 4 | % Constant 5 | c_const = 299792458; % speed of light 6 | 7 | % Fiber Length 8 | dz = 15; % distance stepsize (m) 9 | nz = 10; % number of z-steps 10 | 11 | % Time parameters: 12 | n = 1024; % number of samples in a time period 13 | num = 127; % observed time period number 14 | N = n*num; % Total sampling points 15 | fm = 1e10; % repetition rate (Hz) 16 | Ts = 1/fm/n; % sampling distance (s) 17 | t = ((1:N)'-(N+1)/2)*Ts; % vector of t values (s) 18 | 19 | % Frequency parameters: 20 | dv = 1/Ts/N; % frequency resolution (Hz) 21 | v = [(0:N/2-1),(-N/2:-1)]'/(Ts*N); % vector of v values (Hz) 22 | vs = fftshift(v); % swap halves for plotting 23 | 24 | % Wavelength parameters: 25 | lamda0 = 1554.8e-9; % zero-dispersion wavelength (m) 26 | lamdaS = 1543.3e-9; % signal wavelength (m) 27 | lamdaP = 1556.5e-9; % pump wavelength (m) 28 | vw = fliplr(fftshift(c_const./(v + c_const/lamda0))'*1e9); % wavelengths vector (nm) 29 | 30 | % singal and pump power: 31 | Is = 0.001; % signal power (W) 32 | Ip = 1; % pump power (W) 33 | 34 | % Optical carrier 35 | deltavS = c_const/lamda0-c_const/lamdaS; % Hz 36 | [~,aux1b] = min(abs(v - deltavS)); 37 | CarrierS = exp(-1j*2*pi*v(aux1b)*t); 38 | deltavP = c_const/lamda0-c_const/lamdaP; % Hz 39 | [~,aux2b] = min(abs(v - deltavP)); 40 | CarrierP = exp(-1j*2*pi*v(aux2b)*t); 41 | 42 | % Coupled together 43 | Es = sqrt(Is).*CarrierS; 44 | Ep = sqrt(Ip).*CarrierP; 45 | Ein = Es + Ep; 46 | 47 | % Transmission in HNL-DSF 48 | Eout = SSFM_Fiber(Ein,dz,nz); 49 | 50 | spectraOUT = fliplr(fftshift((abs(fft(Eout)).^2)/N^2)'); % W 51 | S_dBm = 10*log10(spectraOUT); 52 | 53 | figure(1) 54 | plot(vw,S_dBm,'b'); 55 | axis([1510 1600 -100 0]); 56 | xlabel('Wavelength (nm)'); 57 | ylabel('Intensity (dBm)'); 58 | -------------------------------------------------------------------------------- /光学仿真/3/FOPA_ASE.asv: -------------------------------------------------------------------------------- 1 | clear;clc; 2 | format long e 3 | % Constant 4 | c_const = 299792458e-12; % speed of light m/ps 5 | tol = 1e-5; 6 | % Fiber Length 7 | dz = 1; % distance stepsize (m) 8 | nz = 20; % number of z-steps 9 | 10 | % Time parameters: 11 | n = 2^7; % number of samples in a time period (/ps) 12 | num = 2^8; % observed time period number (ps) 13 | N = n*num; % Total sampling points 14 | Ts = 1/n; % sampling distance (ps) 15 | t = ((1:N)'-(N+1)/2)*Ts; % vector of t values (ps) 16 | 17 | % Frequency parameters: 18 | dv = 1/num; % frequency resolution (THz) 19 | v = [(0:N/2-1),(-N/2:-1)]'/(Ts*N); % vector of v values (THz) 20 | vs = fftshift(v); % swap halves for plotting 21 | 22 | % Wavelength parameters: 23 | lamda0 = 1064.0e-9; % zero-dispersion wavelength (m) 24 | lamdaS = 1064.0e-9; % signal wavelength (m) 25 | lamdaP = 1064.5e-9; % pump wavelength (m) 26 | vw = flipud((c_const./(vs + c_const/lamda0))*1e9); % wavelengths vector (nm) 27 | 28 | % singal and pump power: 29 | Is =1e-9; % signal power (W) 30 | Ip = 80; % pump power (W) 31 | 32 | % Optical carrier 33 | deltavS = c_const/lamdaS-c_const/lamda0; % THz 34 | [~,aux1b] = min(abs(v - deltavS)); 35 | CarrierS = exp(-1j*2*pi*v(aux1b)*t); 36 | deltavP = c_const/lamdaP-c_const/lamda0; % THz 37 | [~,aux2b] = min(abs(v - deltavP)); 38 | CarrierP = exp(-1j*2*pi*v(aux2b)*t); 39 | beta = [0 0 8.19e-6 6.17e-5 -7.41e-8 -1.54e-11]; % ps^n/m 40 | % Coupled together 41 | %u0 = sechpulse(t,0,15,1,8); 42 | 43 | u0 = 1; 44 | Ep = sqrt(Ip).*u0.*CarrierP; 45 | Es = wgn(N,1,-40,'complex').*CarrierS; 46 | Ein = Es + Ep; 47 | 48 | % Transmission in HNL-DSF or PCF 49 | fprintf(1,'\n\nSimulation started'); 50 | fprintf(1,'\n\nplot'); 51 | nplot = 1; 52 | u = zeros(N,nplot+1); 53 | ufourier = zeros(N,nplot+1); 54 | u(:,1) = Ein; 55 | tic 56 | for ii = 1:nplot 57 | fprintf('\b\b\b\b%4.0f', ii); 58 | ufourier(:,ii) = fftshift(abs((ifft(u(:,ii))*N).^2/N^2)); 59 | u(:,ii+1) = ssrklem(u(:,ii),Ts,dz,dz*nz/nplot,1e-6,beta,1.5e-2,0*lamda0/c_const,tol); 60 | end 61 | ufourier(:,nplot+1) = fftshift(abs((ifft(u(:,ii))*N).^2/N^2)); 62 | 63 | tx = toc; 64 | fprintf('\n\nSimulation lasted (s) = %5.2f',tx); 65 | 66 | Eout = u(:,nplot+1); 67 | spectraOUT = flipud((abs(fftshift(ifft(Eout)*N)).^2)/N^2); % W 68 | S_dBm = 10*log10(spectraOUT); 69 | 70 | figure(1); 71 | plot(vw,S_dBm,'b'); 72 | axis([vw(1) vw(N) -100 0]); 73 | xlabel('Wavelength (nm)'); 74 | ylabel('Intensity (dBm)'); 75 | title_string = ['\lambda_p=',num2str(lamdaP*1e9,'%5.1fnm'),... 76 | ',L=',num2str(dz*nz,'%3.0fm'),... 77 | ',P_p_e_a_k=',num2str(Ip,'%2.0fW'),... 78 | ',tol=',num2str(tol,'%1.0e')]; 79 | title (title_string); 80 | % figure(2); 81 | % plot(t,abs(Eout).^2) 82 | % title (title_string); 83 | -------------------------------------------------------------------------------- /光学仿真/3/FOPA_ASE.m: -------------------------------------------------------------------------------- 1 | clear;clc; 2 | format long e 3 | % Constant 4 | c_const = 299792458e-12; % speed of light m/ps 5 | tol = 1e-5; 6 | % Fiber Length 7 | dz = 1; % distance stepsize (m) 8 | nz = 40; % number of z-steps 9 | 10 | % Time parameters: 11 | n = 2^7; % number of samples in a time period (/ps) 12 | num = 2^8; % observed time period number (ps) 13 | N = n*num; % Total sampling points 14 | Ts = 1/n; % sampling distance (ps) 15 | t = ((1:N)'-(N+1)/2)*Ts; % vector of t values (ps) 16 | 17 | % Frequency parameters: 18 | dv = 1/num; % frequency resolution (THz) 19 | v = [(0:N/2-1),(-N/2:-1)]'/(Ts*N); % vector of v values (THz) 20 | vs = fftshift(v); % swap halves for plotting 21 | 22 | % Wavelength parameters: 23 | lamda0 = 1064.0e-9; % zero-dispersion wavelength (m) 24 | lamdaS = 1064.0e-9; % signal wavelength (m) 25 | lamdaP = 1064.3e-9; % pump wavelength (m) 26 | vw = flipud((c_const./(vs + c_const/lamda0))*1e9); % wavelengths vector (nm) 27 | 28 | % singal and pump power: 29 | Is =1e-9; % signal power (W) 30 | Ip = 80; % pump power (W) 31 | 32 | % Optical carrier 33 | deltavS = c_const/lamdaS-c_const/lamda0; % THz 34 | [~,aux1b] = min(abs(v - deltavS)); 35 | CarrierS = exp(-1j*2*pi*v(aux1b)*t); 36 | deltavP = c_const/lamdaP-c_const/lamda0; % THz 37 | [~,aux2b] = min(abs(v - deltavP)); 38 | CarrierP = exp(-1j*2*pi*v(aux2b)*t); 39 | beta = [0 0 8.19e-6 0*6.17e-5 -7.41e-8 -1.54e-11]; % ps^n/m 40 | % Coupled together 41 | u0 = sechpulse(t,0,15,1,8.95); 42 | %u0 = gaussian(t,0,15,1,0) 43 | %u0 = 1; 44 | Ep = sqrt(Ip).*CarrierP.*u0; 45 | Es = wgn(N,1,-40,'complex').*CarrierS; 46 | Ein = Es + Ep; 47 | 48 | % Transmission in HNL-DSF or PCF 49 | fprintf(1,'\n\nSimulation started'); 50 | fprintf(1,'\n\nplot'); 51 | nplot = 1; 52 | u = zeros(N,nplot+1); 53 | ufourier = zeros(N,nplot+1); 54 | u(:,1) = Ein; 55 | tic 56 | for ii = 1:nplot 57 | fprintf('\b\b\b\b%4.0f', ii); 58 | ufourier(:,ii) = fftshift(abs((ifft(u(:,ii))*N).^2/N^2)); 59 | u(:,ii+1) = ssrklem(u(:,ii),Ts,dz,dz*nz/nplot,1e-6,beta,1.5e-2,0*lamda0/c_const,tol); 60 | end 61 | ufourier(:,nplot+1) = fftshift(abs((ifft(u(:,ii))*N).^2/N^2)); 62 | 63 | tx = toc; 64 | fprintf('\n\nSimulation lasted (s) = %5.2f',tx); 65 | 66 | Eout = u(:,nplot+1); 67 | spectraOUT = flipud((abs(fftshift(ifft(Eout)*N)).^2)/N^2); % W 68 | S_dBm = 10*log10(spectraOUT); 69 | 70 | figure(1); 71 | plot(vw,S_dBm,'b'); 72 | axis([vw(1) vw(N) -100 0]); 73 | xlabel('Wavelength (nm)'); 74 | ylabel('Intensity (dBm)'); 75 | title_string = ['\lambda_p=',num2str(lamdaP*1e9,'%5.1fnm'),... 76 | ',L=',num2str(dz*nz,'%3.0fm'),... 77 | ',P_p_e_a_k=',num2str(Ip,'%2.0fW'),... 78 | ',tol=',num2str(tol,'%1.0e')]; 79 | title (title_string); 80 | % figure(2); 81 | % plot(t,abs(Eout).^2) 82 | % title (title_string); 83 | -------------------------------------------------------------------------------- /光学仿真/3/FOPA_Gain.asv: -------------------------------------------------------------------------------- 1 | clear;clc; 2 | format long e 3 | % Constant 4 | c_const = 299792458e-12; % speed of light 5 | tol = 1e-5; 6 | % Fiber Length 7 | dz = 1; % distance stepsize (m) 8 | nz = 20; % number of z-steps 9 | 10 | % Time parameters: 11 | n = 2^11; % number of samples in a time period 12 | num = 2^5; % observed time period number 13 | N = n*num; % Total sampling points 14 | fm = 4e-2; % repetition rate (THz) 15 | Ts = 1/fm/n; % sampling distance (ps) 16 | t = ((1:N)'-(N+1)/2)*Ts; % vector of t values (ps) 17 | 18 | % Frequency parameters: 19 | dv = 1/Ts/N; % frequency resolution (THz) 20 | v = [(0:N/2-1),(-N/2:-1)]'/(Ts*N); % vector of v values (THz) 21 | vs = fftshift(v); % swap halves for plotting 22 | 23 | % Wavelength parameters: 24 | lamda0 = 1064.0e-9; % zero-dispersion wavelength (m) 25 | lamdaP = 1064.3e-9; % pump wavelength (m) 26 | vw = flipud(fftshift(c_const./(v + c_const/lamda0))*1e9); % wavelengths vector (nm) 27 | 28 | % singal and pump power: 29 | Is = 1e-9; % small signal power (W) 30 | Ip = 40; % pump power (W) 31 | 32 | % generation of comb like signal: 33 | gainpoints = 200; % number of gain points to be plotted 34 | stepfreq = floor(N/(gainpoints + 1)); % determines the indices of frequencies used for plot 35 | Es = zeros(N,1); 36 | 37 | for ii = 1:gainpoints; 38 | Es = Es + sqrt(Is).*exp(-1i*2*pi*vs(N/2 + stepfreq*(ii-gainpoints/2) - floor(stepfreq/2))*t); 39 | end 40 | 41 | % Optical carrier 42 | deltavP = c_const/lamdaP-c_const/lamda0; % Hz 43 | [~,aux2b] = min(abs(v - deltavP)); 44 | CarrierP = exp(-1j*2*pi*v(aux2b)*t); 45 | % Coupled together 46 | u0 = sechpulse(t,0,15,1,8.96); 47 | %Ep = sqrt(Ip).*u0.*CarrierP; 48 | Ep = sqrt(Ip).*CarrierP; 49 | Ein = Es + Ep; 50 | spectralpower0x = fftshift((abs(ifft(Ein)*N).^2)); % W 51 | 52 | % Transmission in HNL-DSF 53 | alpha = 1e-6; 54 | beta = [0 0 8.19e-6 6.17e-5 -7.41e-8 -1.54e-11]; 55 | gamma = 0.018; 56 | Eout = ssrklem(Ein,Ts,dz,dz*nz,alpha,beta,gamma,lamda0/c_const,tol); 57 | %Eout = SSFM_Fiber(Ein,dz,nz); 58 | spectralpowerx = fftshift((abs(ifft(Eout)*N).^2)); % W 59 | gains = spectralpowerx./spectralpower0x; 60 | 61 | % Select those discrete gain points 62 | selectedgains = zeros(gainpoints,1); 63 | selectedfreq = zeros(gainpoints,1); 64 | ii = 1:gainpoints; 65 | selectedfreq(ii) = vs(N/2 + stepfreq*(ii-gainpoints/2) - floor(stepfreq/2)); 66 | selectedgains(ii) = gains(N/2 + stepfreq*(ii-gainpoints/2) - floor(stepfreq/2)); 67 | 68 | 69 | % Visualization 70 | figure(1); 71 | vp = flipud((c_const./(selectedfreq + c_const/lamda0)).*1e9); % wavelengths for plot (nm) 72 | Gains_in_dB = flipud(10*log10(selectedgains)); 73 | 74 | plot(vp,Gains_in_dB,'r'); 75 | axis([vp(1) vp(gainpoints) -30 100]); 76 | xlabel('Wavelength (nm)'); 77 | ylabel('Gain (dB)'); 78 | title_string = ['\lambda_p=',num2str(lamdaP*1e9,'%5.1fnm'),... 79 | ',L=',num2str(dz*nz,'%3.0fm'),... 80 | ',P_p_e_a_k=',num2str(Ip,'%2.0fW'),... 81 | ',tol=',num2str(tol,'%1.0e')]; 82 | title (title_string); 83 | figure(2); 84 | plot(t,abs(Eout).^2) 85 | title (title_string); 86 | 87 | 88 | -------------------------------------------------------------------------------- /光学仿真/3/FOPA_Gain.m: -------------------------------------------------------------------------------- 1 | clear;clc; 2 | format long e 3 | % Constant 4 | c_const = 299792458e-12; % speed of light 5 | tol = 1e-5; 6 | % Fiber Length 7 | dz = 1; % distance stepsize (m) 8 | nz = 20; % number of z-steps 9 | 10 | % Time parameters: 11 | n = 2^8; % number of samples in a time period (/ps) 12 | num = 2^8; % observed time period number (ps) 13 | N = n*num; % Total sampling points 14 | Ts = 1/n; % sampling distance (ps) 15 | t = ((1:N)'-(N+1)/2)*Ts; % vector of t values (ps) 16 | 17 | % Frequency parameters: 18 | dv = 1/Ts/N; % frequency resolution (THz) 19 | v = [(0:N/2-1),(-N/2:-1)]'/(Ts*N); % vector of v values (THz) 20 | vs = fftshift(v); % swap halves for plotting 21 | 22 | % Wavelength parameters: 23 | lamda0 = 1064.0e-9; % zero-dispersion wavelength (m) 24 | lamdaP = 1064.3e-9; % pump wavelength (m) 25 | vw = flipud(fftshift(c_const./(v + c_const/lamda0))*1e9); % wavelengths vector (nm) 26 | 27 | % singal and pump power: 28 | Is = 1e-9; % small signal power (W) 29 | Ip = 20; % pump power (W) 30 | 31 | % generation of comb like signal: 32 | gainpoints = 200; % number of gain points to be plotted 33 | stepfreq = floor(N/(gainpoints + 1)); % determines the indices of frequencies used for plot 34 | Es = zeros(N,1); 35 | 36 | for ii = 1:gainpoints; 37 | Es = Es + sqrt(Is).*exp(-1i*2*pi*vs(N/2 + stepfreq*(ii-gainpoints/2) - floor(stepfreq/2))*t); 38 | end 39 | 40 | % Optical carrier 41 | deltavP = c_const/lamdaP-c_const/lamda0; % Hz 42 | [~,aux2b] = min(abs(v - deltavP)); 43 | CarrierP = exp(-1j*2*pi*v(aux2b)*t); 44 | % Coupled together 45 | u0 = sechpulse(t,0,15,1,8.96); 46 | %Ep = sqrt(Ip).*u0.*CarrierP; 47 | Ep = sqrt(Ip).*CarrierP; 48 | Ein = Es + Ep; 49 | spectralpower0x = fftshift((abs(ifft(Ein)*N).^2)); % W 50 | 51 | % Transmission in HNL-DSF 52 | alpha = 1e-6; 53 | beta = [0 0 8.19e-6 6.17e-5 -7.41e-8 -1.54e-11]; 54 | gamma = 0.018; 55 | Eout = ssrklem(Ein,Ts,dz,dz*nz,alpha,beta,gamma,lamda0/c_const,tol); 56 | %Eout = SSFM_Fiber(Ein,dz,nz); 57 | spectralpowerx = fftshift((abs(ifft(Eout)*N).^2)); % W 58 | gains = spectralpowerx./spectralpower0x; 59 | 60 | % Select those discrete gain points 61 | selectedgains = zeros(gainpoints,1); 62 | selectedfreq = zeros(gainpoints,1); 63 | ii = 1:gainpoints; 64 | selectedfreq(ii) = vs(N/2 + stepfreq*(ii-gainpoints/2) - floor(stepfreq/2)); 65 | selectedgains(ii) = gains(N/2 + stepfreq*(ii-gainpoints/2) - floor(stepfreq/2)); 66 | 67 | 68 | % Visualization 69 | figure(1); 70 | vp = flipud((c_const./(selectedfreq + c_const/lamda0)).*1e9); % wavelengths for plot (nm) 71 | Gains_in_dB = flipud(10*log10(selectedgains)); 72 | 73 | plot(vp,Gains_in_dB,'r'); 74 | axis([vp(1) vp(gainpoints) -30 100]); 75 | xlabel('Wavelength (nm)'); 76 | ylabel('Gain (dB)'); 77 | title_string = ['\lambda_p=',num2str(lamdaP*1e9,'%5.1fnm'),... 78 | ',L=',num2str(dz*nz,'%3.0fm'),... 79 | ',P_p_e_a_k=',num2str(Ip,'%2.0fW'),... 80 | ',tol=',num2str(tol,'%1.0e')]; 81 | title (title_string); 82 | figure(2); 83 | plot(t,abs(Eout).^2) 84 | title (title_string); 85 | 86 | 87 | -------------------------------------------------------------------------------- /光学仿真/3/OPA_G_Spectrum/Gain.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/光学仿真/3/OPA_G_Spectrum/Gain.fig -------------------------------------------------------------------------------- /光学仿真/3/SSFM_Fiber.asv: -------------------------------------------------------------------------------- 1 | function Eout = SSFM_Fiber(Ein,dz,nz) 2 | global Ts; % s 3 | 4 | % Fiber parameters 5 | gamma = 3e-2; % W^-1 m^-1 6 | beta1x = 0; % ps/m 7 | beta2x = 0; % ps^2/m 8 | beta3x = 5.67e-5; % ps^3/m 9 | beta4x = -2.43e-7; % ps^4/m 10 | betap = [0 beta1x beta2x beta3x beta4x]'; % Dispersion at lamda0 11 | alpha = 1e-4; % 1/m 12 | 13 | % Generate the dispersion operator 14 | N = length(Ein); % the number of point 15 | w = 2*pi*[(0:N/2-1),(-N/2:-1)]'/(Ts*N*1e12); %constructing used frequencies (rad.THz) 16 | linearoperatorx = -alpha/2; 17 | for ii = 0:length(betap)-1; 18 | linearoperatorx = linearoperatorx - 1j*betap(ii+1)*(w).^ii/factorial(ii); % (rad/m) 19 | end 20 | halfstepx = exp(linearoperatorx*dz/2); 21 | 22 | % The split-step Fourier method 23 | ufft = fft(Ein); 24 | for i=1:nz, 25 | % Dispersion in the first half distance dz/2 26 | uhalf = ifft(halfstepx.*ufft); 27 | % Add the nonlinear operator in the middle point 28 | u1 = uhalf.*exp(1j*gamma*(abs(uhalf).^2)*dz); 29 | % Dispersion in the second half distance dz/2 30 | ufft = halfstepx.*(fft(u1).*exp(1i)); % 31 | end 32 | Eout = ifft(ufft).*exp(1i); 33 | -------------------------------------------------------------------------------- /光学仿真/3/SSFM_Fiber.m: -------------------------------------------------------------------------------- 1 | function Eout = SSFM_Fiber(Ein,dz,nz) 2 | global Ts; % s 3 | 4 | % Fiber parameters 5 | gamma = 3e-2; % W^-1 m^-1 6 | beta1x = 0; % ps/m 7 | beta2x = 0; % ps^2/m 8 | beta3x = 5.67e-5; % ps^3/m 9 | beta4x = -2.43e-7; % ps^4/m 10 | betap = [0 beta1x beta2x beta3x beta4x]'; % Dispersion at lamda0 11 | alpha = 1e-4; % 1/m 12 | 13 | % Generate the dispersion operator 14 | N = length(Ein); % the number of point 15 | w = 2*pi*[(0:N/2-1),(-N/2:-1)]'/(Ts*N*1e12); %constructing used frequencies (rad.THz) 16 | linearoperatorx = -alpha/2; 17 | for ii = 0:length(betap)-1; 18 | linearoperatorx = linearoperatorx - 1j*betap(ii+1)*(w).^ii/factorial(ii); % (rad/m) 19 | end 20 | halfstepx = exp(linearoperatorx*dz/2); 21 | 22 | % The split-step Fourier method 23 | ufft = fft(Ein); 24 | for i=1:nz, 25 | % Dispersion in the first half distance dz/2 26 | uhalf = ifft(halfstepx.*ufft); 27 | % Add the nonlinear operator in the middle point 28 | u1 = uhalf.*exp(1j*gamma*(abs(uhalf).^2)*dz); 29 | % Dispersion in the second half distance dz/2 30 | ufft = halfstepx.*(fft(u1)); % 31 | end 32 | Eout = ifft(ufft); 33 | -------------------------------------------------------------------------------- /光学仿真/4/ASE_Filter.asv: -------------------------------------------------------------------------------- 1 | clear all 2 | format long e 3 | global Ts; 4 | % Constant 5 | c_const = 3e8; % speed of light 6 | 7 | % Time parameters: 8 | n = 1024; % number of samples in a time period 9 | num = 127; % observed time period number 10 | N = n*num; % Total sampling points 11 | fm = 1e10; % repetition rate (Hz) 12 | Ts = 1/fm/n; % sampling distance (s) 13 | t = ((1:N)'-(N+1)/2)*Ts; % vector of t values (s) 14 | 15 | % Frequency parameters: 16 | dv = 1/Ts/N; % frequency resolution (Hz) 17 | v = [(0:N/2-1),(-N/2:-1)]'/(Ts*N); % vector of v values (Hz) 18 | vs = fftshift(v); % swap halves for plotting 19 | 20 | % Wavelength parameters: 21 | lamda0 = 1554.8e-9; % reference wavelength (m) 22 | lamdaF = 1543.3e-9; % carrier wavelength (m) 23 | vw = fliplr(fftshift(c_const./(v + c_const/lamda0))'*1e9); % wavelengths vector (nm) 24 | 25 | % Filter bandwidth: 26 | lamda3dB = 13e-9; % m 27 | f3dB = lamda3dB*c_const/lamdaF^2; 28 | 29 | % Filter centra carrier 30 | deltavF = c_const/lamdaF-c_const/lamda0-; % Hz 31 | [~,aux1b] = min(abs(v - deltavF)); 32 | CarrierF = exp(-1j*2*pi*v(aux1b)*t); 33 | 34 | % White band noise 35 | Es = wgn(N,1,-40,'complex'); 36 | 37 | % Filter @ lamdaF 38 | Esf = conj(CarrierF).*Es; 39 | Ssf = fft(Esf,N); 40 | Ssf = filter_gaus(Ssf,f3dB,4); 41 | Eout = ifft(Ssf).*CarrierF; 42 | Spectrum = fliplr(fftshift((abs(fft(Eout)).^2)/N^2)'); 43 | S_dBm = 10*log10(Spectrum); 44 | 45 | % Drawing 46 | figure(1) 47 | plot(vw,S_dBm); 48 | axis([1520 1590 -inf -50]); 49 | xlabel('Wavelength (nm)'); 50 | ylabel('Intensity (dBm)'); 51 | -------------------------------------------------------------------------------- /光学仿真/4/ASE_Filter.m: -------------------------------------------------------------------------------- 1 | clear all 2 | format long e 3 | global Ts; 4 | % Constant 5 | c_const = 3e8; % speed of light 6 | 7 | % Time parameters: 8 | n = 1024; % number of samples in a time period 9 | num = 127; % observed time period number 10 | N = n*num; % Total sampling points 11 | fm = 1e10; % repetition rate (Hz) 12 | Ts = 1/fm/n; % sampling distance (s) 13 | t = ((1:N)'-(N+1)/2)*Ts; % vector of t values (s) 14 | 15 | % Frequency parameters: 16 | dv = 1/Ts/N; % frequency resolution (Hz) 17 | v = [(0:N/2-1),(-N/2:-1)]'/(Ts*N); % vector of v values (Hz) 18 | vs = fftshift(v); % swap halves for plotting 19 | 20 | % Wavelength parameters: 21 | lamda0 = 1554.8e-9; % reference wavelength (m) 22 | lamdaF = 1543.3e-9; % carrier wavelength (m) 23 | vw = fliplr(fftshift(c_const./(v + c_const/lamda0))'*1e9); % wavelengths vector (nm) 24 | 25 | % Filter bandwidth: 26 | lamda3dB = 10e-9; % m 27 | f3dB = lamda3dB*c_const/lamdaF^2; 28 | 29 | % Filter centra carrier 30 | deltavF = c_const/lamdaF-c_const/lamda0; % Hz 31 | [~,aux1b] = min(abs(v - deltavF)); 32 | CarrierF = exp(-1j*2*pi*v(aux1b)*t); 33 | 34 | % White band noise 35 | Es = wgn(N,1,-40,'complex'); 36 | 37 | % Filter @ lamdaF 38 | Esf = conj(CarrierF).*Es; 39 | Ssf = ifft(Esf,N)*N; 40 | Ssf = filter_gaus(Ssf,f3dB,4); 41 | %Ssf = filter_rect(Ssf,f3dB); 42 | Eout = fft(Ssf)/N.*CarrierF; 43 | Spectrum = fliplr(fftshift((abs(ifft(Eout)*N).^2)/N^2)'); 44 | S_dBm = 10*log10(Spectrum); 45 | 46 | % Drawing 47 | figure(1) 48 | plot(vw,S_dBm); 49 | axis([1520 1590 -inf 0]); 50 | xlabel('Wavelength (nm)'); 51 | ylabel('Intensity (dBm)'); 52 | -------------------------------------------------------------------------------- /光学仿真/4/EDFAs Dynamic/Analytical solution for the dynamic behavior of EDFA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/光学仿真/4/EDFAs Dynamic/Analytical solution for the dynamic behavior of EDFA.pdf -------------------------------------------------------------------------------- /光学仿真/4/OSA_Resol.m: -------------------------------------------------------------------------------- 1 | function [NW,NSpec] = OSA_Resol(w1,w2,OSpec,resol,lamda0) 2 | 3 | % wavelength unit is nm, and lamda0 unit is m 4 | 5 | global v c_const; 6 | 7 | NW = (w1:((w2-w1)/1000):w2); % nm 8 | a = size(OSpec,1); 9 | 10 | NSpec = zeros(a,1001); 11 | for ii = 1:1001 12 | f3dB = resol*c_const*1e9/NW(ii)^2; % Hz 13 | 14 | deltavN = c_const/lamda0-c_const/NW(ii)/1e-9; % Hz 15 | [~,aux1b] = min(abs(v - deltavN)); 16 | 17 | Spec = circshift(OSpec',-aux1b); 18 | for pp = 1:a 19 | Spec1 = filter_gaus(fftshift(Spec(:,pp)),f3dB,2); 20 | NSpec(pp,ii) = 10*log10(sum(Spec1)); 21 | end 22 | end -------------------------------------------------------------------------------- /光学仿真/4/Test_OSA.m: -------------------------------------------------------------------------------- 1 | clear all 2 | format long e 3 | global v c_const Ts; 4 | % Constant 5 | c_const = 3e8; % speed of light 6 | 7 | % Time parameters: 8 | n = 2048; % number of samples in a time period 9 | num = 64; % observed time period number 10 | N = n*num; % Total sampling points 11 | fm = 1e10; % repetition rate (Hz) 12 | Ts = 1/fm/n; % sampling distance (s) 13 | t = ((1:N)'-(N+1)/2)*Ts; % vector of t values (s) 14 | 15 | % Frequency parameters: 16 | dv = 1/Ts/N; % frequency resolution (Hz) 17 | v = [(0:N/2-1),(-N/2:-1)]'/(Ts*N); % vector of v values (Hz) 18 | vs = fftshift(v); % swap halves for plotting 19 | 20 | % Wavelength parameters: 21 | lamda0 = 1554.8e-9; % m 22 | lamdaS = 1543.3e-9; % m 23 | vw = fliplr(fftshift(c_const./(v + c_const/lamda0))'*1e9); % wavelengths (nm) 24 | 25 | % Generation of initial pulsed signal Es: 26 | Is = 1; % W 27 | Pulsewidth = 1e-12; % OPA pump pulsewidth (s) 28 | Base = exp(-2*log(2)*(t./Pulsewidth).^2); 29 | Shape = Base; 30 | for pp = 1:num-1 31 | Base = circshift(Base,n); 32 | Shape = Shape + Base; 33 | end 34 | 35 | % Optical carrier 36 | deltavS = c_const/lamda0-c_const/lamdaS; % Hz 37 | [~,aux1b] = min(abs(v - deltavS)); 38 | CarrierS = exp(-1j*2*pi*v(aux1b)*t); 39 | 40 | Es = sqrt(Is)*Shape.*CarrierS; 41 | spectralpower = fliplr(fftshift((abs(fft(Es)).^2)/N^2)'); % W 42 | S_dBm = 10*log10(spectralpower); 43 | [Wavel1,Spect1] = OSA_Resol(1535,1555,spectralpower,0.02,lamda0); 44 | [Wavel2,Spect2] = OSA_Resol(1535,1555,spectralpower,0.04,lamda0); 45 | [Wavel3,Spect3] = OSA_Resol(1535,1555,spectralpower,0.08,lamda0); 46 | 47 | % Figures 48 | figure(1) 49 | subplot(2,2,1); 50 | plot(vw,S_dBm,'b'); 51 | axis([1535 1555 -100 20]); 52 | xlabel('Wavelength (nm)'); 53 | ylabel('Intensity (dBm)'); 54 | title('Full resolution'); 55 | subplot(2,2,2); 56 | plot(Wavel1,Spect1,'b'); 57 | axis([1535 1555 -100 20]); 58 | xlabel('Wavelength (nm)'); 59 | ylabel('Intensity (dBm)'); 60 | title('0.02-nm resolution'); 61 | subplot(2,2,3); 62 | plot(Wavel2,Spect2,'b'); 63 | axis([1535 1555 -100 20]); 64 | xlabel('Wavelength (nm)'); 65 | ylabel('Intensity (dBm)'); 66 | title('0.04-nm resolution'); 67 | subplot(2,2,4); 68 | plot(Wavel3,Spect3,'b'); 69 | axis([1535 1555 -100 20]); 70 | xlabel('Wavelength (nm)'); 71 | ylabel('Intensity (dBm)'); 72 | title('0.08-nm resolution'); 73 | 74 | -------------------------------------------------------------------------------- /光学仿真/4/modInt.m: -------------------------------------------------------------------------------- 1 | function Eout = modInt(Ein,alpha,epsilon,m,fm,bias) 2 | % modInt(Ein,alpha,epsilon,m,fm) 3 | % Amplitude modulator model 4 | 5 | % modulator parameters 6 | % chirp alpha factor: alpha 7 | % extinction ratio: esilon (dB) 8 | 9 | % modulation parameters 10 | % modulation index: m 11 | % modulation frequency: fm 12 | % bias: 0:1 13 | 14 | global Ts; 15 | 16 | N = size(Ein,1); 17 | k = (1:N)'; 18 | Vm = m*cos(2*pi*fm*Ts*(k-N/2)); 19 | ext = 1 - 4/pi*atan(1/sqrt(10^(epsilon/10))); 20 | delta_phi = pi/4*(2-bias*2-ext*Vm); 21 | Eout = Ein.*cos(delta_phi).*exp(1i*alpha*delta_phi); 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /光学仿真/5/AML Dispersion/Dispersion.m: -------------------------------------------------------------------------------- 1 | % MLLsimple.m 2 | % simplemode of mode locked laser 3 | 4 | clear all 5 | close all 6 | 7 | global Ts; % sampling period 8 | global Fcar; % carrier frequency (optical frequency) 9 | c_const = 3e8; % speed of light 10 | 11 | n = 1024; % number of samples in a block 12 | num = 64; % observed time period number 13 | N = 1024*num; 14 | 15 | % Wavelength parameters: 16 | lamda0 = 1550e-9; % m 17 | lamdaC = 1550e-9; % m 18 | Fcar = c_const/lamdaC; % Hz 19 | deltav = c_const/lamda0-c_const/lamdaC; % Hz 20 | 21 | % Amplifier parameters: 22 | GssdB = 20; % (dB) 23 | PoutsatdB = 10; % (dBm) 24 | NF = 8; % (dB) 25 | 26 | % Fiber parameters: 27 | dz = 10; % distance stepsize (m) 28 | nz = 3; % number of z-steps 29 | 30 | % Filter bandwidth: 31 | lamda3dB = 1.2e-9; % m 32 | f3dB = lamda3dB*c_const/lamdaC^2; 33 | 34 | % Modulator parameter: 35 | alpha = -0.07; 36 | epsilon = 10; % (dB) extinction ratio 37 | 38 | % Modulation parameters: 39 | m = 0.5; % modulation index 40 | fm = 1e10; % modulation frequency (Hz) 41 | NHar = 1000; % harmonic order 42 | Ts = 1/fm/n; % recalculate Ts so that Tm = N*Ts (s) 43 | f_detune = 0; % detuned frequency (Hz) 44 | l_detune = c_const*NHar*f_detune/fm^2; % detuned cavity length (m) 45 | delay_per_pass = round(l_detune/c_const/Ts); 46 | 47 | % Frequency parameters: 48 | t = ((1:N)'-(N+1)/2)*Ts; % vector of t values (s) 49 | v = [(0:N/2-1),(-N/2:-1)]'/(Ts*N); % vector of v values (Hz) 50 | [aux1a,aux1b] = min(abs(v - deltav)); 51 | Carrier = exp(-1j*2*pi*v(aux1b)*t); 52 | 53 | % Loss: 54 | loss = 10; % dB 55 | atten = 1/10^(loss/20); 56 | 57 | % generation an initial block of signal Ein 58 | Ein = wgn(N,1,-40,'complex'); 59 | Eout = Ein; 60 | Eo = Ein; 61 | 62 | tx = cputime; 63 | N_pass = 100; 64 | for ii = 1:N_pass 65 | [Eo,G] = amp_simp1(Eo,GssdB,PoutsatdB,NF,num); 66 | Eo = Carrier.*Eo; 67 | Eo = SSFM_SMF(Eo,dz,nz); 68 | Eo = conj(Carrier).*Eo; 69 | Eo = fft(Eo,N); 70 | Eo = filter_gaus(Eo,f3dB,1); 71 | Eo = ifft(Eo); 72 | Eo = circshift(Eo,delay_per_pass); 73 | Eo = modInt(Eo(1:N),alpha,epsilon,m,fm,0.5); 74 | Eo = Eo*atten; 75 | % ------ End ------ output of the peak power 76 | if mod(ii,N_pass/50)==0 77 | Eout = [Eout , Eo]; 78 | end 79 | Eo = Eo + wgn(N,1,-40,'complex'); 80 | end 81 | 82 | Eout = Eout/atten; 83 | close all 84 | Iout = Eout.*conj(Eout); 85 | fprintf(1,'\nSimulation completed in (%.2f s)\n',cputime-tx); 86 | 87 | figure(1); 88 | mesh (Iout','meshstyle','row','facecolor','none'); 89 | axis tight; 90 | xlabel('T (0.1ps)'); 91 | ylabel('Pass number'); 92 | zlabel('Intensity (W)'); 93 | 94 | N1 = size(Eout,2); 95 | Kmag = 1; 96 | Nplot = 100; 97 | Eoutfreq = fft(Eout(:,N1),N*Kmag); 98 | Ioutfreq = Eoutfreq.*conj(Eoutfreq)/(N*Kmag)^2; 99 | vw = fftshift(c_const./(v + c_const/lamdaC))'*1e9; % wavelengths (nm) 100 | figure(2); 101 | subplot(2,1,2); 102 | plot(vw,fftshift(10*log(Ioutfreq))); 103 | axis([1549 1551 -200 -40]); 104 | xlabel('Wavelength (nm)'); 105 | ylabel('Intensity (dBm)'); 106 | 107 | %figure(3); 108 | subplot(2,1,1); 109 | Trace = Iout(:,N1); 110 | Ptime = Ts*(1:n)*1e12; 111 | for jj = 1:num 112 | hold on; 113 | plot(Ptime,Trace(n*(jj-1)+1:n*jj)); 114 | end 115 | axis([0 100 0 0.3]); 116 | xlabel('Time (ps)'); 117 | ylabel('Intensity (W)'); 118 | -------------------------------------------------------------------------------- /光学仿真/5/AML Dispersion/Main.m: -------------------------------------------------------------------------------- 1 | % MLLsimple.m 2 | % simplemode of mode locked laser 3 | 4 | clear all 5 | close all 6 | 7 | global Ts; % sampling period 8 | global Fcar; % carrier frequency (optical frequency) 9 | c_const = 3e8; % speed of light 10 | 11 | lamda = 1550e-9; % m 12 | Fcar = c_const/lamda; % Hz 13 | 14 | n = 1024; % number of samples in a block 15 | num = 11; % observed time period number 16 | N = 1024*num; 17 | 18 | % Amplifier parameters: 19 | GssdB = 20; % (dB) 20 | PoutsatdB = 10; % (dBm) 21 | NF = 8; % (dB) 22 | 23 | % Filter bandwidth: 24 | lamda3dB = 0.8e-9; % m 25 | f3dB = lamda3dB*c_const/lamda^2; 26 | 27 | % Modulator parameter: 28 | alpha = -0.07; 29 | epsilon = 40; % (dB) extinction ratio 30 | 31 | % Modulation parameters: 32 | m = 0.5; % modulation index 33 | fm = 1e10; % modulation frequency 34 | NHar = 100; % harmonic order 35 | Ts = 1/fm/n; % recalculate Ts so that Tm = N*Ts 36 | f_detune = 1e6; % detuned frequency 37 | delay_per_pass = round(NHar*f_detune/fm^2/Ts); 38 | 39 | % Loss: 40 | loss = 10; % dB 41 | atten = 1/10^(loss/20); 42 | 43 | % generation an initial block of signal Ein 44 | Ein = wgn(N,1,-40,'complex'); 45 | Eout = Ein; 46 | Eo = Ein; 47 | 48 | N_pass = 500; 49 | for ii = 1:N_pass 50 | [Eo,G] = amp_simp1(Eo,GssdB,PoutsatdB,NF,num); 51 | Eo = fft(Eo,N); 52 | Eo = filter_gaus(Eo,f3dB,1); 53 | Eo = ifft(Eo); 54 | Eo = circshift(Eo,delay_per_pass); 55 | Eo = modInt(Eo(1:N),alpha,epsilon,m,fm,0.5); 56 | Eo = Eo*atten; 57 | % ------ End ------ output of the peak power 58 | if mod(ii,N_pass/50)==0 59 | Eout = [Eout , Eo]; 60 | end 61 | Eo = Eo + wgn(N,1,-40,'complex'); 62 | end 63 | 64 | Eout = Eout/atten; 65 | close all 66 | Iout = Eout.*conj(Eout); 67 | 68 | %figure(1); 69 | %mesh (Iout','meshstyle','row','facecolor','none'); 70 | %axis tight; 71 | %xlabel('T (0.1ps)'); 72 | %ylabel('Pass number'); 73 | %zlabel('intensity (W)'); 74 | 75 | N1 = size(Eout,2); 76 | Kmag = 1; 77 | Nplot = 100; 78 | Eoutfreq = fft(Eout(:,N1),N*Kmag); 79 | Ioutfreq = Eoutfreq.*conj(Eoutfreq)/(N*Kmag)^2; 80 | figure(2); 81 | plot(fftshift(10*log(Ioutfreq))); 82 | %ind = (- Nplot/2 : Nplot/2); 83 | %freq = ind/Ts/N/Kmag; 84 | %ind = mod((ind + N*Kmag),N*Kmag) + 1; 85 | %plot(freq,Ioutfreq(ind)); 86 | 87 | figure(3); 88 | Trace = Iout(:,N1); 89 | for jj = 1:num 90 | hold on; 91 | plot(Trace(n*(jj-1)+1:n*jj)); 92 | end 93 | axis tight; 94 | xlabel('T (0.1ps)'); 95 | ylabel('intensity (W)'); 96 | -------------------------------------------------------------------------------- /光学仿真/5/AML Dispersion/SSFM_SMF.m: -------------------------------------------------------------------------------- 1 | function Eout = SSFM_SMF(Eo,dz,nz) 2 | 3 | global Ts; % s 4 | gamma = 1.4e-3; % W^-1 m^-1 5 | beta1x = 0; % ps/m 6 | beta2x = -2.16e-2; % ps^2/m 7 | beta3x = 1.29e-4; % ps^3/m 8 | beta4x = -3.67e-7; % ps^4/m 9 | betap = [0 beta1x beta2x beta3x beta4x]'; % @ 1550nm 10 | alpha = 1e-4; % 1/m 11 | 12 | N = length(Eo); % the number of point 13 | w = 2*pi*[(0:N/2-1),(-N/2:-1)]'/(Ts*N*1e12); %constructing used frequencies (rad.THz) 14 | 15 | linearoperatorx = -alpha/2; 16 | for ii = 0:length(betap)-1; 17 | linearoperatorx = linearoperatorx - 1j*betap(ii+1)*(w).^ii/factorial(ii); % (rad/m) 18 | end 19 | halfstepx = exp(linearoperatorx*dz/2); 20 | 21 | ufft = fft(Eo); 22 | for i=1:nz, 23 | %------linear propagation until dz/2------------ 24 | uhalf = ifft(halfstepx.*ufft); 25 | u1 = uhalf.*exp(-1j*gamma*(abs(uhalf).^2)*dz); % non linear propagation in CP basis 26 | %------linear propagation from dz/2 to dz------------ 27 | ufft = halfstepx.*fft(u1); % 28 | end 29 | Eout = ifft(ufft); 30 | -------------------------------------------------------------------------------- /光学仿真/5/AML Dispersion/amp_simp1.m: -------------------------------------------------------------------------------- 1 | function [Eout,gain] = amp_simp1(Ein,GssdB,PoutsatdB,NF,num) 2 | % amp_simp(Ein,GssdB,PoutsatdB,NF,num) 3 | % simple model of optical amplifier. The model includes the gain saturation and the ASE noise 4 | 5 | % amplifier parameters: 6 | % small signal gain: GssdB (dB) 7 | % output saturation power:PoutsatdB (dBm) 8 | % noise figure: NF (dB) 9 | 10 | % Simulation parameters: 11 | % Gain tolerance: tol, used as the threshold value to exit the gain calculation loop 12 | 13 | % The input is a column vector containing block N samples of the optical 14 | % signal sampling at the rate 1/Ts 15 | % The output is calculated using 16 | % Eout = Ein*sqrt(G) + Enoise 17 | % where: G is the saturation gain 18 | % G = Gss*exp(-(G-1)*Pin/Psat) (eq1) 19 | % Enoise id the complex noise with the noise power 20 | % Pase = (10^(NF/10))*(G-1)hf/2*BW; 21 | % BW = 1/Ts; 22 | 23 | global Ts; % sampling period 24 | global Fcar; 25 | h_plan = 6.626e-34; 26 | 27 | Gss = 10^(GssdB/10); 28 | Poutsat = (10^(PoutsatdB/10))/1000; 29 | Psat = Poutsat*(Gss-2)/Gss/log(2); 30 | % Pinsat = 2*Poutsat/Gss; 31 | 32 | N = size(Ein,1); 33 | n = N/num; 34 | 35 | Iin = Ein.*conj(Ein); 36 | BW = 1/Ts; 37 | FigNoise = 10^(NF/10); 38 | 39 | for ii = 1:num 40 | 41 | Pin = mean(Iin(n*(ii-1)+1:n*ii)); 42 | 43 | % numerical calculation of G from the equation G = (Gss - InG)*Psat/Pin + 1 44 | tol = 0.05; % tolerence for G calculation 45 | step = Gss/2; 46 | G = Gss; 47 | err = 10; 48 | while (err > tol) 49 | G1 = Gss*exp(-(G-1)*Pin/Psat); 50 | err = G1 - G; 51 | if err>0 52 | if step<0 53 | step = -step/2; 54 | end 55 | else 56 | if step>0 57 | step = -step/2; 58 | end 59 | err = -err; 60 | end 61 | G = G + step; 62 | end 63 | G = G - step; 64 | gain(ii) = G; 65 | Egain = sqrt(G)*Ein(n*(ii-1)+1:n*ii); 66 | 67 | Pase = (FigNoise*G-1)*h_plan*Fcar/2*BW; 68 | PasedB = 10*log10(Pase); 69 | 70 | Eout(n*(ii-1)+1:n*ii) = Egain + wgn(n,1,PasedB,'complex'); 71 | 72 | end 73 | Eout = Eout'; -------------------------------------------------------------------------------- /光学仿真/5/AML Dispersion/filter_gaus.m: -------------------------------------------------------------------------------- 1 | function Eout = filter_gaus(Ein,f3dB,n) 2 | % filter_gaus(Ein,f3dB,n) 3 | % filter the input signal with the n order gaussian filter 4 | 5 | % T(f) = exp(-log(sqrt(2))*(2/f3dB/Ts/N)^2n*(k.^2n)); 6 | 7 | global Ts; 8 | 9 | N = size(Ein,1); 10 | % the k element in the Ein corresponds to the frequency of (k-N/2)/Ts/N 11 | k = (1:N)-1; 12 | k(N/2+1:N) = k(N/2+1:N) - N; 13 | k = k'; 14 | 15 | n = 2*n; 16 | % Eout = Ein.*exp(-log(sqrt(2))*(2/f3dB/Ts/N)^n*(k.^n)); 17 | % n order of gaussian filter 18 | temp = log(sqrt(2))*(2/f3dB/Ts/N)^n; 19 | Eout = Ein.*exp(-temp*(k.^n)); % n order gaussian filter VPI 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /光学仿真/5/AML Dispersion/fwhm.m: -------------------------------------------------------------------------------- 1 | function width = fwhm(x) 2 | % return the Full Width at Half Maximum of the pulse x 3 | 4 | nsize = size(x,1); 5 | % half_peak = max(x)/2; 6 | [peak ind] = max(x); 7 | half_peak = peak/2; % 3dB 8 | for iii = 1:nsize-1 9 | if (x(iii)<=half_peak) && (x(iii+1)>half_peak) 10 | break; 11 | end 12 | end 13 | for jjj = ind:nsize-1 14 | if (x(jjj)>=half_peak) && (x(jjj+1) tol) 23 | G1 = Gss*exp(-(G-1)*Pin/Psat); 24 | err = G1 - G; 25 | if err>0 26 | if step<0 27 | step = -step/2; 28 | end 29 | else 30 | if step>0 31 | step = -step/2; 32 | end 33 | err = -err; 34 | end 35 | G = G + step; 36 | end 37 | G = G - step; 38 | gain = G; -------------------------------------------------------------------------------- /光学仿真/5/AML Dispersion/modInt.m: -------------------------------------------------------------------------------- 1 | function Eout = modInt(Ein,alpha,epsilon,m,fm,bias) 2 | % modIntQP(Ein,alpha,epsilon,m,fm) 3 | % intensity modulator model 4 | 5 | % modulator parameters 6 | % chirp alpha factor: alpha 7 | % extinction ratio: esilon (dB) 8 | % modulation parameters 9 | % modulation index: m 10 | % modulation frequency: fm 11 | % bias: 0:1 12 | 13 | global Ts; 14 | 15 | N = size(Ein,1); 16 | k = (1:N)'; 17 | Vm = m*cos(2*pi*fm*Ts*(k-N/2)); 18 | ext = 1 - 4/pi*atan(1/sqrt(10^(epsilon/10))); 19 | % delta_phi = pi/4*(1-ext*Vm); 20 | delta_phi = pi/4*(2-bias*2-ext*Vm); 21 | Eout = Ein.*cos(delta_phi).*exp(1i*alpha*delta_phi); 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /光学仿真/5/AML Dispersion/modInt_theory.m: -------------------------------------------------------------------------------- 1 | function Eout = modInt_theory(Ein,m,fm) 2 | % modInt_theory(Ein,m,fm) 3 | % intensity modulator model 4 | 5 | % modulator parameters 6 | % chirp alpha factor: alpha 7 | % extinction ratio: esilon (dB) 8 | % modulation parameters 9 | % modulation index: m 10 | % modulation frequency: fm 11 | 12 | global Ts; 13 | 14 | N = size(Ein,1); 15 | k = (1:N)'; 16 | Eout = Ein.*exp(-m/4*(2*pi*fm*Ts)^2*(k-N/2).*(k-N/2)); 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /光学仿真/5/AML Dispersion/walkoff.m: -------------------------------------------------------------------------------- 1 | 2 | clear all 3 | close all 4 | global Ts; 5 | 6 | % CONSTANTS 7 | c = 299792458; % speed of light (m/s) 8 | lamda_IN = 1550e-9; % m 9 | lamda0 = 1550e-9; % m 10 | 11 | % Fiber parameters: 12 | dz = 50; % distance stepsize (m) 13 | nz = 20; % number of z-steps 14 | Pulsewidth = 6e-12; % s 15 | diffe = 20e-12; % s 16 | 17 | % CALCULATED QUANTITIES 18 | N = 2^17; % number of points in FFT 19 | Ts = 5e-14; % time step (s) 20 | T = N*Ts; % FFT window size (s) 21 | t = ((1:N)'-(N+1)/2)*Ts; % vector of t values (s) 22 | v = [(0:N/2-1),(-N/2:-1)]'/T; % vector of v values (Hz) 23 | 24 | deltav = c/lamda0-c/lamda_IN; 25 | [aux1a,aux1b] = min(abs(v - deltav)); 26 | Ein = exp(-1j*2*pi*v(aux1b)*t).*(exp(-2*log(2)*(t./Pulsewidth).^2) + 0.6.*exp(-2*log(2)*((t-diffe)./Pulsewidth).^2)); 27 | Eout = SSFM_SMF(Ein,dz,nz); 28 | 29 | figure(1) 30 | subplot(2,1,1) 31 | plot(t*1e12,abs(Ein)); 32 | axis([-50 50 -inf inf]); 33 | subplot(2,1,2) 34 | plot(t*1e12,abs(Eout)); 35 | axis([-50 50 -inf inf]); 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /光学仿真/5/Active Mode-Locking/AmpSimpNonoise.m: -------------------------------------------------------------------------------- 1 | function [Eout,gain] = AmpSimpNonoise(Ein,GssdB,PoutsatdB) 2 | % amp_Simp(Ein,GssdB,PoutsatdB,NF) 3 | % simple model of optical amplifier. The model includes the gain saturation without noise 4 | 5 | % Amplifier parameters: 6 | % small signal gain: GssdB (dB) 7 | % output saturation power PoutsatdB (dBm) 8 | 9 | % The input is a column vector containing block N samples of the optical signal sampling at the rate 1/Ts 10 | % The output is calculated using 11 | % Eout = Ein*sqrt(G) 12 | % where: G is the saturated gain 13 | % G = Gss*exp(-(G-1)Pin/Psat) (eq1) 14 | 15 | Gss = 10^(GssdB/10); 16 | Poutsat = (10^(PoutsatdB/10))/1000; 17 | Psat = Poutsat*(Gss-2)/Gss/log(2); 18 | % Pinsat = 2*Poutsat/Gss; 19 | 20 | N = size(Ein,1); 21 | Pin = (sum(Ein.*conj(Ein))/N); 22 | 23 | % numerical calculation of G from the equation G = (Gss - InG)*Psat/Pin + 1 24 | tol = 0.05; % tolerence for G calculation 25 | step = Gss/2; 26 | G = Gss; 27 | err = 10; 28 | while (err > tol) 29 | G1 = Gss*exp(-(G-1)*Pin/Psat); 30 | err = G1 - G; 31 | if err>0 32 | if step<0 33 | step = -step/2; 34 | end 35 | else 36 | if step>0 37 | step = -step/2; 38 | end 39 | err = -err; 40 | end 41 | G = G + step; 42 | end 43 | G = G - step; 44 | 45 | Eout = sqrt(G)*Ein; 46 | gain = G; -------------------------------------------------------------------------------- /光学仿真/5/Active Mode-Locking/MLLsimple.m: -------------------------------------------------------------------------------- 1 | % MLLsimple.m 2 | % simplemode of mode locked laser 3 | 4 | clear all 5 | close all 6 | 7 | global Ts; % sampling period 8 | global Fcar; % carrier frequency (optical frequency) 9 | c_const = 3e8; % speed of light 10 | 11 | lamda = 1550e-9; % m 12 | Fcar = c_const/lamda; % Hz 13 | 14 | Ts = 1e-13; % s 15 | N = 1024; % number of samples in a block: Tblk = N * Ts = 102.4 ps 16 | 17 | % Amplifier parameters: 18 | GssdB = 20; % (dB) 19 | PoutsatdB = 10; % (dBm) 20 | NF = 8; % (dB) 21 | 22 | % Filter bandwidth: 23 | lamda3dB = 1e-9; % m 24 | f3dB = lamda3dB*c_const/lamda^2; 25 | 26 | % Modulator parameter: 27 | alpha = -0.07; 28 | epsilon = 40; % (dB) extinction ratio 29 | 30 | % Modulation parameters: 31 | m = 0.5; % modulation index 32 | fm = 1e10; % modulation frequency 33 | 34 | % Loss: 35 | loss = 10; % dB 36 | atten = 1/10^(loss/20); 37 | 38 | % generation an initial block of signal Ein 39 | % Ein = 1e-3*gausswin(N,2); 40 | Ein = wgn(N,1,-40,'complex'); 41 | 42 | Eout = Ein; 43 | Eo = Ein; 44 | N_pass = 500; 45 | for ii = 1:N_pass 46 | [Eo,G] = amp_simp(Eo,GssdB,PoutsatdB,NF); 47 | % [Eo,G] = AmpSimpNoise(Eo,GssdB,PoutsatdB); % no noise 48 | Eo = fft(Eo,N*4); 49 | % Eo = filter_bessel(Eo,f3dB,G); 50 | % Eo = filter_gaus1(Eo,f3dB); 51 | Eo = filter_gaus(Eo,f3dB,1); 52 | Eo = ifft(Eo); 53 | Eo = modInt(Eo(1:N),alpha,epsilon,m,fm,0.5); 54 | % Eo = modPhase(Eo(1:N),m,fm); 55 | Eo = Eo*atten; 56 | if mod(ii,10)==0 57 | Eout = [Eout , Eo]; 58 | end 59 | end 60 | 61 | Eout = Eout/atten; 62 | close all 63 | % mesh (abs(Eout'),'edgecolor','black','meshstyle','row','facecolor','none'); 64 | Iout = Eout.*conj(Eout); 65 | mesh (Iout','meshstyle','row','facecolor','none'); 66 | axis tight; 67 | % set(gca,'XTick',tt_mark); 68 | % set(gca,'XTickLable',tt_tick); 69 | % set(gca,'XDir','reverse'); 70 | xlabel('T (0.1ps)'); 71 | % set(gca,'YTick',yy_mark); 72 | % set(gca,'YTickLable',yy_tick); 73 | ylabel('Pass number'); 74 | zlabel('intensity (W)'); 75 | 76 | N1 = size(Eout,2); 77 | dPhi = angle(Eout(2:N,N1)) - angle(Eout(1:N-1,N1)); 78 | % figure (2); 79 | % plot(dPhi); 80 | 81 | Tp = fwhm(Iout(:,N1))*Ts; 82 | pulse_alpha = 2*log(2)/(Tp^2); 83 | pulse_beta = (dPhi(N/2+100) - dPhi(N/2 - 100))/200/Ts/Ts; 84 | chirp = pulse_beta/pulse_alpha; 85 | 86 | Kmag = 8; 87 | Nplot = 100; 88 | Eoutfreq = fft(Eout(:,N1),N*Kmag); 89 | Ioutfreq = Eoutfreq.*conj(Eoutfreq)/(N*Kmag)^2; 90 | figure(2); 91 | ind = (- Nplot/2 : Nplot/2); 92 | freq = ind/Ts/N/Kmag; 93 | ind = mod((ind + N*Kmag),N*Kmag) + 1; 94 | plot(freq,Ioutfreq(ind)); 95 | 96 | n = 1; 97 | n = 2*n; 98 | Tfil = exp(-log(2)*(2/f3dB*freq).^n); % n order gaussian 99 | % filter VPI 100 | Tfil = Tfil*max(Ioutfreq(ind)); 101 | hold on 102 | plot(freq,Tfil,'r'); 103 | 104 | % plot the gaussion fit curve 105 | % gaussionFit(Iout(:,N1)); 106 | 107 | pulseBW = fwhm(Ioutfreq(ind))/Ts/N/Kmag; 108 | Tp = fwhm(Iout(:,N1))*Ts; 109 | TBP = pulseBW*Tp; 110 | 111 | -------------------------------------------------------------------------------- /光学仿真/5/Active Mode-Locking/amp_simp.m: -------------------------------------------------------------------------------- 1 | function [Eout,gain] = amp_simp(Ein,GssdB,PoutsatdB,NF) 2 | % amp_simp(Ein,GssdB,PoutsatdB,NF) 3 | % simple model of optical amplifier. The model includes the gain saturation and the ASE noise 4 | 5 | % amplifier parameters: 6 | % small signal gain: GssdB (dB) 7 | % output saturation power:PoutsatdB (dBm) 8 | % noise figure: NF (dB) 9 | 10 | % Simulation parameters: 11 | % Gain tolerance: tol, used as the threshold value to exit the gain calculation loop 12 | 13 | % The input is a column vector containing block N samples of the optical 14 | % signal sampling at the rate 1/Ts 15 | % The output is calculated using 16 | % Eout = Ein*sqrt(G) + Enoise 17 | % where: G is the saturation gain 18 | % G = Gss*exp(-(G-1)*Pin/Psat) (eq1) 19 | % Enoise id the complex noise with the noise power 20 | % Pase = (10^(NF/10))*(G-1)hf/2*BW; 21 | % BW = 1/Ts; 22 | 23 | global Ts; % sampling period 24 | global Fcar; 25 | h_plan = 6.626e-34; 26 | 27 | Gss = 10^(GssdB/10); 28 | Poutsat = (10^(PoutsatdB/10))/1000; 29 | Psat = Poutsat*(Gss-2)/Gss/log(2); 30 | % Pinsat = 2*Poutsat/Gss; 31 | 32 | N = size(Ein,1); 33 | Pin = mean(Ein.*conj(Ein)); 34 | 35 | % numerical calculation of G from the equation G = (Gss - InG)*Psat/Pin + 1 36 | tol = 0.05; % tolerence for G calculation 37 | step = Gss/2; 38 | G = Gss; 39 | err = 10; 40 | while (err > tol) 41 | G1 = Gss*exp(-(G-1)*Pin/Psat); 42 | err = G1 - G; 43 | if err>0 44 | if step<0 45 | step = -step/2; 46 | end 47 | else 48 | if step>0 49 | step = -step/2; 50 | end 51 | err = -err; 52 | end 53 | G = G + step; 54 | end 55 | G = G - step; 56 | gain = G; 57 | Egain = sqrt(G)*Ein; 58 | 59 | BW = 1/Ts; 60 | FigNoise = 10^(NF/10); 61 | Pase = (FigNoise*G-1)*h_plan*Fcar/2*BW; 62 | PasedB = 10*log10(Pase); 63 | 64 | Eout = Egain + wgn(N,1,PasedB,'complex'); 65 | -------------------------------------------------------------------------------- /光学仿真/5/Active Mode-Locking/filter_gaus.m: -------------------------------------------------------------------------------- 1 | function Eout = filter_gaus(Ein,f3dB,n) 2 | % filter_gaus(Ein,f3dB,n) 3 | % filter the input signal with the n order gaussian filter 4 | 5 | % T(f) = exp(-log(sqrt(2))*(2/f3dB/Ts/N)^2n*(k.^2n)); 6 | 7 | global Ts; 8 | 9 | N = size(Ein,1); 10 | % the k element in the Ein corresponds to the frequency of (k-N/2)/Ts/N 11 | k = (1:N)-1; 12 | k(N/2+1:N) = k(N/2+1:N) - N; 13 | k = k'; 14 | 15 | n = 2*n; 16 | % Eout = Ein.*exp(-log(sqrt(2))*(2/f3dB/Ts/N)^n*(k.^n)); 17 | % n order of gaussian filter 18 | temp = log(sqrt(2))*(2/f3dB/Ts/N)^n; 19 | Eout = Ein.*exp(-temp*(k.^n)); % n order gaussian filter VPI 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /光学仿真/5/Active Mode-Locking/fwhm.m: -------------------------------------------------------------------------------- 1 | function width = fwhm(x) 2 | % return the Full Width at Half Maximum of the pulse x 3 | 4 | nsize = size(x,1); 5 | % half_peak = max(x)/2; 6 | [peak ind] = max(x); 7 | half_peak = peak/2; % 3dB 8 | for iii = 1:nsize-1 9 | if (x(iii)<=half_peak) && (x(iii+1)>half_peak) 10 | break; 11 | end 12 | end 13 | for jjj = ind:nsize-1 14 | if (x(jjj)>=half_peak) && (x(jjj+1) tol) 23 | G1 = Gss*exp(-(G-1)*Pin/Psat); 24 | err = G1 - G; 25 | if err>0 26 | if step<0 27 | step = -step/2; 28 | end 29 | else 30 | if step>0 31 | step = -step/2; 32 | end 33 | err = -err; 34 | end 35 | G = G + step; 36 | end 37 | G = G - step; 38 | gain = G; -------------------------------------------------------------------------------- /光学仿真/5/Active Mode-Locking/modInt.m: -------------------------------------------------------------------------------- 1 | function Eout = modInt(Ein,alpha,epsilon,m,fm,bias) 2 | % modIntQP(Ein,alpha,epsilon,m,fm) 3 | % intensity modulator model 4 | 5 | % modulator parameters 6 | % chirp alpha factor: alpha 7 | % extinction ratio: esilon (dB) 8 | % modulation parameters 9 | % modulation index: m 10 | % modulation frequency: fm 11 | % bias: 0:1 12 | 13 | global Ts; 14 | 15 | N = size(Ein,1); 16 | k = (1:N)'; 17 | Vm = m*cos(2*pi*fm*Ts*(k-N/2)); 18 | ext = 1 - 4/pi*atan(1/sqrt(10^(epsilon/10))); 19 | % delta_phi = pi/4*(1-ext*Vm); 20 | delta_phi = pi/4*(2-bias*2-ext*Vm); 21 | Eout = Ein.*cos(delta_phi).*exp(1i*alpha*delta_phi); 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /光学仿真/5/Active Mode-Locking/modInt_theory.m: -------------------------------------------------------------------------------- 1 | function Eout = modInt_theory(Ein,m,fm) 2 | % modInt_theory(Ein,m,fm) 3 | % intensity modulator model 4 | 5 | % modulator parameters 6 | % chirp alpha factor: alpha 7 | % extinction ratio: esilon (dB) 8 | % modulation parameters 9 | % modulation index: m 10 | % modulation frequency: fm 11 | 12 | global Ts; 13 | 14 | N = size(Ein,1); 15 | k = (1:N)'; 16 | Eout = Ein.*exp(-m/4*(2*pi*fm*Ts)^2*(k-N/2).*(k-N/2)); 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /光学仿真/5/CWFOPO/GainS.m: -------------------------------------------------------------------------------- 1 | clear all 2 | format long e 3 | global Ts; % s 4 | % CONSTANTS 5 | c_const = 3e8; % speed of light 6 | 7 | % NUMERICAL PARAMETERS 8 | n = 1024; % number of samples in a block 9 | num = 41; % observed time period number 10 | N = 1024*num; 11 | fm = 1e10; % modulation frequency (Hz) 12 | Ts = 1/fm/n; % recalculate Ts so that Tm = N*Ts (s) 13 | dzN = 15; % distance stepsize (m) 14 | nzN = 10; % number of z-steps 15 | 16 | % Wavelength parameters: 17 | lamda0 = 1554e-9; % m 18 | lamdaS = 1540e-9; % m 19 | lamdaP = 1556e-9; % m 20 | deltavP = c_const/lamda0-c_const/lamdaP; % Hz 21 | Ip = 0.60; % pump power (W) 22 | 23 | gainpoints = 200; % number of gain points to be plotted 24 | input_signal_power = 1e-9; % W 25 | 26 | % CALCULATED QUANTITIES 27 | t = ((1:N)'-(N+1)/2)*Ts; % vector of t values (s) 28 | v = [(0:N/2-1),(-N/2:-1)]'/(Ts*N); % vector of v values (Hz) 29 | vw = fftshift(c_const./(v + c_const/lamdaP))'*1e9; % wavelengths (nm) 30 | vs = fftshift(v); % swap halves for plotting 31 | 32 | % Frequency parameters: 33 | [aux2a,aux2b] = min(abs(v - deltavP)); 34 | CarrierP = exp(-1j*2*pi*v(aux2b)*t); 35 | Ep = sqrt(Ip)*CarrierP; 36 | 37 | %STARTING FIELD 38 | %------adding input pumps in time domain----------------------------------------------- 39 | stepfreq = floor(N/(gainpoints + 1)); % determines the indices of the frequencies used for plot 40 | Eo = zeros(N,1); 41 | for ii = 1:gainpoints/2; 42 | Eo = Eo + sqrt(input_signal_power).*exp(j*2*pi*vs(N/2 + stepfreq*ii)*t); 43 | Eo = Eo + sqrt(input_signal_power).*exp(j*2*pi*vs(N/2 - stepfreq*ii + floor(stepfreq/2))*t); 44 | end 45 | %PROPAGATE 46 | tx=cputime; 47 | Eout = SSFM_FOPA(Eo,Ep,dzN,nzN); 48 | fprintf(1,'\nCompleted in (%.2f s)\n',cputime-tx); 49 | 50 | %VISUALIZATION 51 | %----Plot Gain Using SSFM result--------------------------------------------- 52 | spectralpower0x = fftshift((abs(fft(Eo)).^2)/N^2); % W 53 | spectralpowerx = fftshift((abs(fft(Eout)).^2)/N^2); % W 54 | 55 | gains = spectralpowerx./spectralpower0x; 56 | selectedgains = []; 57 | selectedfreq = []; 58 | 59 | for ii = 1:gainpoints/2; 60 | selectedfreq = [selectedfreq, vs(N/2 - stepfreq*ii + floor(stepfreq/2))]; 61 | selectedgains = [selectedgains, gains(N/2 - stepfreq*ii + floor(stepfreq/2))]; 62 | end 63 | selectedfreq = sort(selectedfreq); 64 | selectedgains = selectedgains(length(selectedgains):-1:1); 65 | 66 | for ii = 1:gainpoints/2; 67 | selectedfreq = [selectedfreq, vs(N/2 + stepfreq*ii)]; 68 | selectedgains = [selectedgains, gains(N/2 + stepfreq*ii)]; 69 | end 70 | 71 | vp = [c_const./ (selectedfreq + c_const/lamda0)]'.*1e9; % wavelengths for plot (nm) 72 | Gains_in_dB = 10*log10(selectedgains); 73 | 74 | plot(vp,Gains_in_dB,'r'); 75 | axis([1523 1590 0 20]); 76 | xlabel('Wavelength (nm)'); 77 | ylabel('Gain (dB)'); -------------------------------------------------------------------------------- /光学仿真/5/CWFOPO/SSFM_FOPA.m: -------------------------------------------------------------------------------- 1 | function Eout = SSFM_FOPA(Es,Ep,dz,nz) 2 | 3 | global Ts; % s 4 | gamma = 3e-2; % W^-1 m^-1 5 | beta1x = 0; % ps/m 6 | beta2x = 0; % ps^2/m 7 | beta3x = 5.67e-5; % ps^3/m 8 | beta4x = -1.43e-7; % ps^4/m 9 | betap = [0 beta1x beta2x beta3x beta4x]'; % @ 1554nm 10 | alpha = 1e-4; % 1/m 11 | 12 | N = length(Es); % the number of point 13 | w = 2*pi*[(0:N/2-1),(-N/2:-1)]'/(Ts*N*1e12); %constructing used frequencies (rad.THz) 14 | 15 | linearoperatorx = -alpha/2; 16 | for ii = 0:length(betap)-1; 17 | linearoperatorx = linearoperatorx - 1j*betap(ii+1)*(w).^ii/factorial(ii); % (rad/m) 18 | end 19 | halfstepx = exp(linearoperatorx*dz/2); 20 | 21 | Ein = Ep + Es; 22 | ufft = fft(Ein); 23 | for i=1:nz, 24 | %------linear propagation until dz/2------------ 25 | uhalf = ifft(halfstepx.*ufft); 26 | u1 = uhalf.*exp(-1j*gamma*(abs(uhalf).^2)*dz); % non linear propagation in CP basis 27 | %------linear propagation from dz/2 to dz------------ 28 | ufft = halfstepx.*fft(u1); % 29 | end 30 | 31 | Eout = ifft(ufft); 32 | -------------------------------------------------------------------------------- /光学仿真/5/CWFOPO/SSFM_SMF.m: -------------------------------------------------------------------------------- 1 | function Eout = SSFM_SMF(Eo,dz,nz) 2 | 3 | global Ts; % s 4 | gamma = 1.4e-3; % W^-1 m^-1 5 | beta1x = 0; % ps/m 6 | beta2x = -2.16e-2; % ps^2/m 7 | beta3x = 1.29e-4; % ps^3/m 8 | beta4x = -3.67e-7; % ps^4/m 9 | betap = [0 beta1x beta2x beta3x beta4x]'; % @ 1550nm 10 | alpha = 1e-4; % 1/m 11 | 12 | N = length(Eo); % the number of point 13 | w = 2*pi*[(0:N/2-1),(-N/2:-1)]'/(Ts*N*1e12); %constructing used frequencies (rad.THz) 14 | 15 | linearoperatorx = -alpha/2; 16 | for ii = 0:length(betap)-1; 17 | linearoperatorx = linearoperatorx - 1j*betap(ii+1)*(w).^ii/factorial(ii); % (rad/m) 18 | end 19 | halfstepx = exp(linearoperatorx*dz/2); 20 | 21 | ufft = fft(Eo); 22 | for i=1:nz, 23 | %------linear propagation until dz/2------------ 24 | uhalf = ifft(halfstepx.*ufft); 25 | u1 = uhalf.*exp(-1j*gamma*(abs(uhalf).^2)*dz); % non linear propagation in CP basis 26 | %------linear propagation from dz/2 to dz------------ 27 | ufft = halfstepx.*fft(u1); % 28 | end 29 | Eout = ifft(ufft); 30 | -------------------------------------------------------------------------------- /光学仿真/5/CWFOPO/filter_gaus.m: -------------------------------------------------------------------------------- 1 | function Eout = filter_gaus(Ein,f3dB,n) 2 | % filter_gaus(Ein,f3dB,n) 3 | % filter the input signal with the n order gaussian filter 4 | 5 | % T(f) = exp(-log(sqrt(2))*(2/f3dB/Ts/N)^2n*(k.^2n)); 6 | 7 | global Ts; 8 | 9 | N = size(Ein,1); 10 | % the k element in the Ein corresponds to the frequency of (k-N/2)/Ts/N 11 | k = (1:N)-1; 12 | k(N/2+1:N) = k(N/2+1:N) - N; 13 | k = k'; 14 | 15 | n = 2*n; 16 | % Eout = Ein.*exp(-log(sqrt(2))*(2/f3dB/Ts/N)^n*(k.^n)); 17 | % n order of gaussian filter 18 | temp = log(sqrt(2))*(2/f3dB/Ts/N)^n; 19 | Eout = Ein.*exp(-temp*(k.^n)); % n order gaussian filter VPI 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /光学仿真/5/CWFOPO/fwhm.m: -------------------------------------------------------------------------------- 1 | function width = fwhm(x) 2 | % return the Full Width at Half Maximum of the pulse x 3 | 4 | nsize = size(x,1); 5 | % half_peak = max(x)/2; 6 | [peak ind] = max(x); 7 | half_peak = peak/2; % 3dB 8 | for iii = 1:nsize-1 9 | if (x(iii)<=half_peak) && (x(iii+1)>half_peak) 10 | break; 11 | end 12 | end 13 | for jjj = ind:nsize-1 14 | if (x(jjj)>=half_peak) && (x(jjj+1)half_peak) 10 | break; 11 | end 12 | end 13 | for jjj = ind:nsize-1 14 | if (x(jjj)>=half_peak) && (x(jjj+1)=100 && original_image(row,column,2)==0 ... 25 | && abs(original_image(row,column,3)-original_image(row,column,1))<=10 26 | new_curve(dots,1) = lamda_start + d_lamda*(column-x-1); 27 | new_curve(dots,2) = power_start + (y-row)*d_power; 28 | dots=dots+1; 29 | end 30 | end 31 | end 32 | new_curve = new_curve(any(new_curve,2),:); 33 | 34 | -------------------------------------------------------------------------------- /光谱仪输出图片处理/main.m: -------------------------------------------------------------------------------- 1 | clear all;close all;clc; 2 | a1 = imageprocess('1.png',1020,1060,-73.2,6.8,68,433); 3 | a2 = imageprocess('2.png',1020,1060,-72.4,7.6,68,433); 4 | a3 = imageprocess('3.png',1020,1060,-71.6,8.4,68,433); 5 | a4 = imageprocess('4.png',1020,1060,-68.8,11.2,68,433); 6 | a5 = imageprocess('5.png',1010,1070,-73.0,7.0,68,433); 7 | a6 = imageprocess('6.png',1020,1060,-70.8,9.2,68,433); 8 | a7 = imageprocess('7.png',1010,1070,-73.7,6.3,68,433); 9 | a8 = imageprocess('8.png',1010,1070,-73.1,6.9,68,433); 10 | 11 | figure;hold on; 12 | set(gca, 'FontName', 'Times New Roman','Box','on','linewidth',2); 13 | plot(a1(:,1),a1(:,2),'b--'); 14 | plot(a2(:,1),a2(:,2),'g-.'); 15 | plot(a3(:,1),a3(:,2),'r:'); 16 | plot(a4(:,1),a4(:,2),'k'); 17 | 18 | xlabel('wavelength/nm'); 19 | ylabel('power/dBm'); 20 | legend('P_p_u_m_p=10.1dBm','P_p_u_m_p=10.5dBm',... 21 | 'P_p_u_m_p=10.9dBm','P_p_u_m_p=12.6dBm'); 22 | 23 | figure;hold on; 24 | set(gca, 'FontName', 'Times New Roman','Box','on','linewidth',2); 25 | plot(a5(:,1),a5(:,2),'b--'); 26 | plot(a6(:,1),a6(:,2),'g-.'); 27 | plot(a7(:,1),a7(:,2),'r:'); 28 | plot(a8(:,1),a8(:,2),'k'); 29 | 30 | xlabel('wavelength/nm'); 31 | ylabel('power/dBm'); 32 | legend('\lambda_p_u_m_p=1041.2nm','\lambda_p_u_m_p=1042.2nm',... 33 | '\lambda_p_u_m_p=1044.2nm','\lambda_p_u_m_p=1045.4nm'); 34 | 35 | -------------------------------------------------------------------------------- /数值分析/3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/数值分析/3.bmp -------------------------------------------------------------------------------- /数值分析/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/数值分析/Thumbs.db -------------------------------------------------------------------------------- /数值分析/chapter3.asv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/数值分析/chapter3.asv -------------------------------------------------------------------------------- /数值分析/chapter3.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/数值分析/chapter3.m -------------------------------------------------------------------------------- /数值分析/chapter3_8.asv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/数值分析/chapter3_8.asv -------------------------------------------------------------------------------- /数值分析/chapter3_8.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/数值分析/chapter3_8.m -------------------------------------------------------------------------------- /数值分析/image_cpr.asv: -------------------------------------------------------------------------------- 1 | clear all;clc; 2 | Image=imread('lena.jpg'); 3 | 4 | Image=double(Image);imshow(Image); 5 | Size = size(Image); 6 | Image_cpr = uint8(zeros(Size)); 7 | M =40; 8 | U1 = zeros(Size(1),M,3); 9 | S1 = zeros(M,M,3); 10 | V1 = zeros(Size(2),M,3); 11 | for i = 1:3 12 | [U1(:,:,i),S1(:,:,i),V1(:,:,i)]=svds(Image(:,:,i),M); 13 | Image_cpr(:,:,i) = uint8(U1(:,:,i)*S1(:,:,i)*V1(:,:,i)'); 14 | end 15 | imwrite(Image_cpr,'lena2.jpg'); 16 | 17 | 18 | -------------------------------------------------------------------------------- /数值分析/image_cpr.m: -------------------------------------------------------------------------------- 1 | clear all;clc; 2 | Image=imread('lena.jpg'); 3 | Image=double(Image); 4 | Size = size(Image); 5 | Image_cpr = uint8(zeros(Size)); 6 | L =512; 7 | U1 = zeros(Size(1),L,3); 8 | S1 = zeros(L,L,3); 9 | V1 = zeros(Size(2),L,3); 10 | for i = 1:3 11 | [U1(:,:,i),S1(:,:,i),V1(:,:,i)]=svds(Image(:,:,i),L); 12 | Image_cpr(:,:,i) = U1(:,:,i)*S1(:,:,i)*V1(:,:,i)'; 13 | end 14 | imwrite(Image_cpr,'lena2.jpg'); 15 | imshow(Image_cpr); 16 | 17 | -------------------------------------------------------------------------------- /数值分析/jacobi_svd.asv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/数值分析/jacobi_svd.asv -------------------------------------------------------------------------------- /数值分析/jacobi_svd.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/数值分析/jacobi_svd.m -------------------------------------------------------------------------------- /数值分析/lena.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/数值分析/lena.bmp -------------------------------------------------------------------------------- /数值分析/lena.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/数值分析/lena.jpg -------------------------------------------------------------------------------- /数值分析/lena2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/数值分析/lena2.jpg -------------------------------------------------------------------------------- /数值分析/main.asv: -------------------------------------------------------------------------------- 1 | clc;clear all; 2 | M = 000; 3 | N = 6; 4 | NUM = 1; 5 | A = 10*rand(M,N,NUM); 6 | 7 | U1=zeros(M,N,NUM); U2=zeros(M,M,NUM); U3=zeros(M,N,NUM); 8 | V1=zeros(N,N,NUM); V2=zeros(N,N,NUM); V3=zeros(N,N,NUM); 9 | S1=zeros(N,N,NUM); S2=zeros(M,N,NUM); S3=zeros(N,N,NUM); 10 | 11 | tic; 12 | for i=1:NUM 13 | [U1(:,:,i),S1(:,:,i),V1(:,:,i)] =lansvd(A(:,:,i),N,'L'); 14 | end 15 | toc; 16 | 17 | tic; 18 | for i=1:NUM 19 | [U2(:,:,i),S2(:,:,i),V2(:,:,i)] = svd(A(:,:,i)); 20 | end 21 | toc; 22 | 23 | tic; 24 | for i=1:NUM 25 | % [U3(:,:,i),S3(:,:,i),V3(:,:,i)] = jacobi_svd(A(:,:,i)); 26 | end 27 | toc; 28 | 29 | norm(U1(:,:,1)*S1(:,:,1)*V1(:,:,1)'-A(:,:,1))/norm(A(:,:,1)) 30 | max(diag(S1(:,:,1)-S2(1:N,:,1))) 31 | % 32 | % norm(U3(:,:,1)*S3(:,:,1)*V3(:,:,1)'-A(:,:,1))/norm(A(:,:,1)) 33 | % max(diag(S3(:,:,1)-S2(1:N,:,1))) 34 | -------------------------------------------------------------------------------- /数值分析/main.m: -------------------------------------------------------------------------------- 1 | clc;clear all; 2 | M = 500; 3 | N = 400; 4 | NUM = 1; 5 | A = 10*rand(M,N,NUM); 6 | 7 | U1=zeros(M,N,NUM); U2=zeros(M,M,NUM); U3=zeros(M,N,NUM); 8 | V1=zeros(N,N,NUM); V2=zeros(N,N,NUM); V3=zeros(N,N,NUM); 9 | S1=zeros(N,N,NUM); S2=zeros(M,N,NUM); S3=zeros(N,N,NUM); 10 | 11 | tic; 12 | for i=1:NUM 13 | [U1(:,:,i),S1(:,:,i),V1(:,:,i)] =lansvd(A(:,:,i),N,'L'); 14 | end 15 | toc; 16 | 17 | tic; 18 | for i=1:NUM 19 | [U2(:,:,i),S2(:,:,i),V2(:,:,i)] = svd(A(:,:,i)); 20 | end 21 | toc; 22 | 23 | tic; 24 | for i=1:NUM 25 | [U3(:,:,i),S3(:,:,i),V3(:,:,i)] = jacobi_svd(A(:,:,i)); 26 | end 27 | toc; 28 | 29 | norm(U1(:,:,1)*S1(:,:,1)*V1(:,:,1)'-A(:,:,1))/norm(A(:,:,1)) 30 | max(diag(S1(:,:,1)-S2(1:N,:,1))) 31 | 32 | norm(U3(:,:,1)*S3(:,:,1)*V3(:,:,1)'-A(:,:,1))/norm(A(:,:,1)) 33 | max(diag(S3(:,:,1)-S2(1:N,:,1))) 34 | -------------------------------------------------------------------------------- /数值分析/project1_wxj.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/数值分析/project1_wxj.m -------------------------------------------------------------------------------- /数值分析/simulation.asv: -------------------------------------------------------------------------------- 1 | clear all; 2 | clc; 3 | T = 0; 4 | for i = 1:100 5 | N = randi(100,1,1e6); 6 | con = zeros(1,100); 7 | con(1)=1; 8 | flag = 0; 9 | num = 0; 10 | t = 0; 11 | while num < 99 12 | t=t+1; 13 | if N(t)==1 14 | num = num + flag; 15 | flag = 0; 16 | else 17 | if con(N(t))==1 18 | else 19 | con(N(t)) = (1 - flag); 20 | if flag==0 21 | flag = 1; 22 | con(N(t)) = 1; 23 | end 24 | end 25 | end 26 | end 27 | T = T + t; 28 | end 29 | disp(T/100) -------------------------------------------------------------------------------- /数值分析/simulation.m: -------------------------------------------------------------------------------- 1 | clear all; 2 | clc; 3 | cycle = 2000; 4 | T = zeros(1,cycle); 5 | for i = 1:cycle 6 | N = randi(100,1,1e6); 7 | con = zeros(1,100); 8 | con(1)=1; 9 | flag = 0; 10 | num = 0; 11 | t = 0; 12 | while num < 99 13 | t=t+1; 14 | if N(t)==1 15 | num = num + flag; 16 | flag = 0; 17 | else 18 | if con(N(t))==0 19 | if flag==0 20 | flag = 1; 21 | con(N(t)) = 1; 22 | end 23 | end 24 | end 25 | end 26 | T(i) = t; 27 | end 28 | disp(sum(T)/cycle); 29 | f = zeros(1,1e6); 30 | for i = 1:1e6 31 | f(i) = sum(T 1e-4 7 | tmp = (x1^2+x2^2+8)/10; 8 | x2 = (x1*x2^2+x1+8)/10; 9 | x1 = tmp; 10 | iratations = iratations + 1; 11 | end 12 | disp(iratations); -------------------------------------------------------------------------------- /时间透镜/yidayixiao_Gausse.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eeewxj/MATLAB/6114495dfeeb6a18ab41ebd339c3e2dfa7c85ba5/时间透镜/yidayixiao_Gausse.m --------------------------------------------------------------------------------