24小时热门版块排行榜    

查看: 763  |  回复: 5
【奖励】 本帖被评价2次,作者415131606增加金币 1.5
当前主题已经存档。

415131606

铁杆木虫 (文坛精英)


[资源] 【资源】分享一个脉冲的光线中传输的matlab程序

好多研1的同学,开始用matlab进行模拟的时候都没有学过matlab,下面这个程序为光脉冲在光纤中传输时程序,其中用到了傅里叶分步法,要用傅里叶分步法的同学也可以参考借鉴一下,还有这个程序也可以用来作为锁模的机理的前序,大家参考上面的程序很容易编出锁模的程序,希望对大家有帮助,最后用的是3D输出,大家也可以参考一下3D输出的具体写法!
       %===== Solving NLSE Using Split-step Fourier Method  (SSFM) =======
%  The NLSE is like thie:
%  Uz   =  i/2*Uxx - i*beta*U/(1+|U|^2)
%  U(z=0)= sqrt(0.11)*exp(-x.^2/0.85^2);  Gauss pulse
%******************************************************************
% Split-step fast foruier method
%                U(z+dz)=(L+N)U(z)     L and N are operators
%                L=i/2 * d/dx^2        Linear operator
%                N=-i*beta/(1+|U|^2)   Nonlinear operator
% Linear operator computation with fft in Fourier domain for speed
% Nonlinear operator computation in space domain
% step: 1.  U-->fft(U)   = ans
%       2.  L(dz/2).*ans
%       3.  ifft(ans)
%       4.  N(dz).*ans
%       5.  fft(ans)
%       6.  L(dz/2).*ans
%       7.  ifft(ans)     =U(z+dz)
% Calculate two times L(dz/2) can get a accuracy of  O(dz^3)
%******************************************************************
clear;
clc;

         

beta=1;  gamma=0;
%******************************************************************
% Set Space & Frequency Windows
%******************************************************************
nz = 3000;               
dz = 0.001;
Nstep = nz/10;  % For drawing waterfall lines
xmax = 10;  % x domain [-5,5]
nx = 2^9;  
dx = 2*xmax/nx;
x = (-xmax:dxxmax-dx))';
fk = 2*pi/dx;      
xl = length(x)/2;
k = (-xl*fk:fkxl-1)*fk)'/nx;  % frequency domain [-fk/2,fk/2]
%******************************************************************
% Initialization
%******************************************************************
u0 =sech(x);
u  = u0;

%******************************************************************
% Preplot
%******************************************************************
iplot = 1;
zplot(iplot) = 0;  
Uplot(:,iplot) = u.*conj(u);

%******************************************************************
% Linear & Nonlinear Operators
%******************************************************************
% in fourier domain
%******************************************************************
% Split-Step Fourier Method For NLS
%******************************************************************

   L=exp(i*dz/4*k.^2);
   
for m = 1:1:nz
%%%%%%%%%%% test for self-delfection%%%%%%%   
absu2=u.*conj(u);


%u2xtemp=diff(absu2)./diff(x);

%u2x(1)=u2xtemp(1);u2x(2:nx,1)=u2xtemp(1:nx-1);

Na=i*dz*beta*u.*conj(u); % in space domain

%Nb=-Na/beta*gamma.*u2x; % in space domain

%N=exp(Na+Nb);
N=exp(Na);


%%%%%%%%%%%%%%% end test%%%%%%%
      f = fftshift(fft(u));
      
      f = L.*f;
      
      
  uhalf = ifft(fftshift(f));
  
     ua = N.*uhalf;
   
         
      f = fftshift(fft(ua));
      
      
      f = L.*f;
      
      
   uend = ifft(fftshift(f));
   
% 梯形规则积分 两次迭代
     u2 = exp(i/2*dz*beta*(u.*conj(u)+uend.*conj(uend))).*uhalf;
     
      f = fftshift(fft(u2));
      
      
      f = L.*f;
     
      
  uend1 = ifft(fftshift(f));

     u3 = exp(i/2*dz*beta.*(u.*conj(u)+uend1.*conj(uend1))).*uhalf;
     
      f = fftshift(fft(u3));
     
      
      f = L.*f;
     
      u = ifft(fftshift(f));
      
      
      er=1e-4;
      
      u2a=uend1.*conj(uend1);
      
      u2b=u.*conj(u);
      
      if(abs(max(u2b-u2a))/max(u2b)) > er;
         
          disp('Reduce step length please');break;
         
      end
     
      
      

% For drawing 3-D graphic
      
    if (rem(m,Nstep) == 0)
        iplot=iplot+1;
        Uplot(:,iplot)=u.*conj(u);
        zplot(iplot) = m*dz;  
         
     
     
    end
end
waterfall(x,zplot,Uplot');

hidden off;
view(50,30);
title('Soliton Evolution');
xlabel('s','FontSize',18);
ylabel('\xi','FontSize',18);
zlabel('|U|^2','FontSize',14,'Rotation',0,'Position',[-xmax/1.5,-.1,max(u0)^2]);
回复此楼

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

415131606

铁杆木虫 (文坛精英)


不知道上面怎么出来两个
2楼2009-05-17 10:42:41
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

415131606

铁杆木虫 (文坛精英)


上面的表示的是: (的意思,默认成
3楼2009-05-17 10:43:56
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

redcrag

木虫 (著名写手)


★★★ 三星级,支持鼓励

就是非线性内容少了点,比如拉曼项等等
5楼2009-05-18 08:39:45
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xhdeng252

木虫 (正式写手)


程序出错了

Error: Missing variable or function.
6楼2009-05-21 09:56:02
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
简单回复
sunxiao4楼
2009-05-17 11:44   回复  
 up
相关版块跳转 我要订阅楼主 415131606 的主题更新
☆ 无星级 ★ 一星级 ★★★ 三星级 ★★★★★ 五星级
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[文学芳草园] 梦想 +5 myrtle 2026-08-26 5/250 2026-08-31 14:40 by hahaboy
[基金申请] 中青基了要发朋友圈吗? +7 349506619 2026-08-28 7/350 2026-08-31 13:39 by 冼亮淀粉酶
[基金申请] 国社科又开始会评了,不知道这次命运如何 +6 雨打竹帘 2026-08-30 10/500 2026-08-31 09:29 by huixian257
[基金申请] 能否申诉? +6 echo8914667 2026-08-30 7/350 2026-08-31 08:41 by kingkocxr
[基金申请] 面上意见出来了 +10 黄鸟于飞Chao 2026-08-29 19/950 2026-08-31 08:01 by blueearth171
[基金申请] 为什么到现在没收到通知? +5 tannykie 2026-08-29 5/250 2026-08-30 21:05 by purplejack
[基金申请] 麻烦专家们看看评委们的意见(F口面上) +6 gdd2018 2026-08-28 11/550 2026-08-30 08:58 by 超级无敌华子
[基金申请] 我就是申请一个面上项目而已,这评审意见是按照杰青的条件评的吧? +6 gouxfjh 2026-08-28 11/550 2026-08-30 07:57 by gouxfjh
[基金申请] 国自然面上复盘~欢迎讨论 (金币+15) +15 晴天加油 2026-08-26 16/800 2026-08-29 18:28 by symmetry
[基金申请] 为什么资助数各大高校都创新高,自己申请怎么就这么难 +12 Kittylucky 2026-08-27 13/650 2026-08-29 00:04 by superceng
[基金申请] 基金系统什么内容也没有 30+4 winsaint 2026-08-27 9/450 2026-08-28 11:06 by maolC
[基金申请] 怎么查啊 +6 huang1991js 2026-08-26 6/300 2026-08-28 08:42 by winsaint
[基金申请] 为什么 国际(地区)合作与交流项目 没有放榜? 10+3 majunge000 2026-08-26 11/550 2026-08-27 08:42 by 北京莱茵编辑
[基金申请] 为什么国自然不能直接公布 +4 bjdxyxy 2026-08-26 4/200 2026-08-26 13:12 by qingmu1201
[基金申请] 国际合作可查了,中了面上 (EPI+1)(金币+50) +18 Ldrop2023 2026-08-26 18/900 2026-08-26 11:15 by cmrandy
[基金申请] 系统进不去 +4 yanglien 2026-08-26 5/250 2026-08-26 11:10 by wenfengw83
[基金申请] 项目信息和经费信息在系统里都可以看到了 +6 wittyboy 2026-08-26 14/700 2026-08-26 10:55 by wittyboy
[基金申请] 牛来!米来!面来! +8 beefly 2026-08-26 8/400 2026-08-26 08:37 by xuzhipiao
[基金申请] 在坚冰还盖着北海的时候,我看到了怒放的梅花。 (金币+10) +6 ziyangfang 2026-08-25 9/450 2026-08-25 20:26 by huagongfeihu
[基金申请] 某些机构,以效率低为荣,以效率低作为存在感 +9 yuleib84 2026-08-25 10/500 2026-08-25 17:14 by alexon
信息提示
请填处理意见