| tianmen |
2011-06-12 18:33 |
求解光孤子或超短脉冲耦合方程的Matlab程序
计算脉冲在非线性耦合器中演化的Matlab 程序 )}%O>% |WryBzZ>on % This Matlab script file solves the coupled nonlinear Schrodinger equations of ,6^znOt % soliton in 2 cores coupler. The output pulse evolution plot is shown in Fig.1 of j VgFZ, % Youfa Wang and Wenfeng Wang, “A simple and effective numerical method for nonlinear DciwQcG % pulse propagation in N-core optical couplers”, IEEE Photonics Technology lett. Vol.16, No.4, pp1077-1079, 2004 5qUTMT['T XZNY4/25G %fid=fopen('e21.dat','w'); ?Ucu#UO N = 128; % Number of Fourier modes (Time domain sampling points) YT/kC'A M1 =3000; % Total number of space steps y)c5u%( J =100; % Steps between output of space 4F3x@H' T =10; % length of time windows:T*T0 B\*@krI@ T0=0.1; % input pulse width |tzg:T; MN1=0; % initial value for the space output location . v@>JZC dt = T/N; % time step lOwS&4UT n = [-N/2:1:N/2-1]'; % Index S\6[EQ65 t = n.*dt; Nr<`Z u10=1.*sech(1*t); % input to waveguide1 amplitude: power=u10*u10 m4E)qCvy u20=u10.*0.0; % input to waveguide 2 L(>=BK* u1=u10; u2=u20; ^04Q %, U1 = u1; g42)7
U2 = u2; % Compute initial condition; save it in U 39F
Of ww = 4*n.*n*pi*pi/T/T; % Square of frequency. Note i^2=-1. l%z< (L5 w=2*pi*n./T; :4S%'d7 g=-i*ww./2; % w=2*pi*f*n./N, f=1/dt=N/T,so w=2*pi*n./T d1@%W;qX! L=4; % length of evoluation to compare with S. Trillo's paper ;;$# )b dz=L/M1; % space step, make sure nonlinear<0.05 /y7M lU9 for m1 = 1:1:M1 % Start space evolution Z}A%=Z\/3 u1 = exp(dz*i*(abs(u1).*abs(u1))).*u1; % 1st sSolve nonlinear part of NLS 7?gFy- u2 = exp(dz*i*(abs(u2).*abs(u2))).*u2; L\{IljA ca1 = fftshift(fft(u1)); % Take Fourier transform Cd79 tu| ca2 = fftshift(fft(u2)); d%I"/8-J c2=exp(g.*dz).*(ca2+i*1*ca1.*dz); % approximation S_T^G` [ c1=exp(g.*dz).*(ca1+i*1*ca2.*dz); % frequency domain phase shift b*fgv9Kh' u2 = ifft(fftshift(c2)); % Return to physical space :!;'J/B@.. u1 = ifft(fftshift(c1)); WnUweSdW if rem(m1,J) == 0 % Save output every J steps. 1
Q-bYJG U1 = [U1 u1]; % put solutions in U array f=!PllxL: U2=[U2 u2]; &0TVi MN1=[MN1 m1]; *rZ^^`4R z1=dz*MN1'; % output location rKHY?{! end c H-@V< end 'Djm0 hg=abs(U1').*abs(U1'); % for data write to excel ~1m2#> ha=[z1 hg]; % for data write to excel b?4/#&z] t1=[0 t']; C.^Ven hh=[t1' ha']; % for data write to excel file XS0xLt= %dlmwrite('aa',hh,'\t'); % save data in the excel format HBys figure(1) 0yx 3OY waterfall(t',z1',abs(U1').*abs(U1')) % t' is 1xn, z' is 1xm, and U1' is mxn 3lLMu B+ figure(2) _mS!XF~`P waterfall(t',z1',abs(U2').*abs(U2')) % t' is 1xn, z' is 1xm, and U1' is mxn ~m1P_`T 6ZgU"!|r 非线性超快脉冲耦合的数值方法的Matlab程序 {u!)y?}I- kY,U8a3! 在研究脉冲在非线性耦合器中的演变时,我们需要求解非线性偏微分方程组。在如下的论文中,我们提出了一种简洁的数值方法。 这里我们提供给大家用Matlab编写的计算程序。 TvNY:m6.% Youfa Wang and Wenfeng Wang, “A simple and effective numerical method for nonlinear pulse propagation in N-core optical couplers”, IEEE Photonics Technology lett. Vol.16, No.4, pp1077-1079, 2004 p2J|Hl| dt[k\ !-v L{l6Dd43q aw?=hXR! % This Matlab script file solves the nonlinear Schrodinger equations /:<IIqO. % for 3 cores nonlinear coupler. The output plot is shown in Fig.2 of ;Z j]~| % Youfa Wang and Wenfeng Wang, “A simple and effective numerical method for nonlinear bsxTqJ % pulse propagation in N-core optical couplers”, IEEE Photonics Technology lett. Vol.16, No.4, pp1077-1079, 2004 iyVB3:M
%dErnc$ C=1; G Ejd7s]C M1=120, % integer for amplitude lT\a2.E M3=5000; % integer for length of coupler j7FN\
cz N = 512; % Number of Fourier modes (Time domain sampling points) =.|J!x dz =3.14159/(sqrt(2.)*C)/M3; % length of coupler is divided into M3 segments, make sure nonlinearity<0.05. T,fI BD: T =40; % length of time:T*T0. #U=X NU}k dt = T/N; % time step <]C$xp<2 n = [-N/2:1:N/2-1]'; % Index k{tMzx]F__ t = n.*dt; )CI1; ww = 4*n.*n*pi*pi/T/T; % Square of frequency. Note i^2=-1. o ]Jv;Iy@? w=2*pi*n./T; |8%m.fY` g1=-i*ww./2; VN4yn| f/ g2=-i*ww./2; % w=2*pi*f*n./N, f=1/dt=N/T,so w=2*pi*n./TP=0; 2>}xhQJ g3=-i*ww./2; _ 46X%k P1=0; H7+Xs% P2=0; ?::NO Dg P3=1; RWgDD;&_[a P=0; &X9Z
W$C for m1=1:M1 c/L>>t p=0.032*m1; %input amplitude dk
QaM@ s10=p.*sech(p.*t); %input soliton pulse in waveguide 1 _qvK*nE s1=s10; ,=(Z00#( s20=0.*s10; %input in waveguide 2 M >:]lpRK s30=0.*s10; %input in waveguide 3 9/ SXs0 s2=s20; 6#}93Dgv4 s3=s30; oHM
] p10=dt*(sum(abs(s10').*abs(s10'))-0.5*(abs(s10(N,1)*s10(N,1))+abs(s10(1,1)*s10(1,1)))); >Sa*`q3J %energy in waveguide 1 G.+l7bnZM p20=dt*(sum(abs(s20').*abs(s20'))-0.5*(abs(s20(N,1)*s20(N,1))+abs(s20(1,1)*s20(1,1)))); kE.x+2 %energy in waveguide 2 l5Y/Ok0, p30=dt*(sum(abs(s30').*abs(s30'))-0.5*(abs(s30(N,1)*s30(N,1))+abs(s30(1,1)*s30(1,1)))); rzrl>9
h %energy in waveguide 3 M)?dEgU}M for m3 = 1:1:M3 % Start space evolution `=#01YX[0 s1 = exp(dz*i*(abs(s1).*abs(s1))).*s1; % 1st step, Solve nonlinear part of NLS oMcK`%ydm s2 = exp(dz*i*(abs(s2).*abs(s2))).*s2; YL
jHt\ s3 = exp(dz*i*(abs(s3).*abs(s3))).*s3; T0Yiayt sca1 = fftshift(fft(s1)); % Take Fourier transform :J}t&t sca2 = fftshift(fft(s2)); 2)?(R;$, sca3 = fftshift(fft(s3)); 6{x,*[v sc1=exp(g1.*dz).*(sca1+i*C*sca2.*dz); % 2nd step, frequency domain phase shift eZ a:o1y sc2=exp(g2.*dz).*(sca2+i*C*(sca1+sca3).*dz); 3qH QX?a sc3=exp(g3.*dz).*(sca3+i*C*sca2.*dz); /Y[~-Y+!, s3 = ifft(fftshift(sc3)); HQ9f ,< s2 = ifft(fftshift(sc2)); % Return to physical space d;tkJ2@NO s1 = ifft(fftshift(sc1)); HhA -[p end )T907I| p1=dt*(sum(abs(s1').*abs(s1'))-0.5*(abs(s1(N,1)*s1(N,1))+abs(s1(1,1)*s1(1,1)))); zWw2V}U! p2=dt*(sum(abs(s2').*abs(s2'))-0.5*(abs(s2(N,1)*s2(N,1))+abs(s2(1,1)*s2(1,1)))); & | |