Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Want MATLAB code

  1. Jul 19, 2010 #1
    Can any one help me by giving MATLAB code to simulate semiconductor laser rate equation by finite difference methord. i wrote a code but that was not working. so i need it badly. please help me.
     
    Last edited by a moderator: Jul 19, 2010
  2. jcsd
  3. Jul 19, 2010 #2

    berkeman

    User Avatar

    Staff: Mentor

    No, sorry. We do not do your schoolwork for you. Perhaps if you post your code (like you did in your other thread), we may be able to spot any errors....
     
  4. Jul 19, 2010 #3
    mmm=0;
    for nW=[1 3 5]
    mmm=mmm+1;
    mm=0;
    Lam=980e-9;
    q=1.6e-19;
    alpha=.2;
    Tn=1;
    Tp=2.8e1;
    G0=0.6;
    N0 = 1e24;
    h=6.6e-34;
    c=3e8;
    Gamma=1e-5;
    beta=1;
    epsilon=1e-12;
    Va=3.75e-14;
    Ith=((q*Va)/Tn)*(N0+(1/(Gamma*G0*Tp)));
    for I = 0.1e-3:0.1e-3:4.5e-3;
    mm=mm+1;
    tini=0;
    tfin=4e-9;
    dt=1e-12;
    m=0;
    N(1)=0;
    S(1)=0;
    for t=tini:dt:tfin
    m=m+1;
    delN=I/(q*Va)-N(m)/Tn-G0*(N(m)-N0)*S(m)/(1+epsilon*S(m));
    delS=S(m)+Gamma*beta*N(m)/Tn+Gamma*(N(m)-N0)*S(m)/(1+epsilon*S(m));

    N(m+1)=N(m)+dt*delN;
    S(m+1)=S(m)+dt*delS;
    P(m+1)=1000*Va*S(m)*h*c/(Lam*2*Gamma*Tp);
    tt(m+1)=t;

    end
    II(mm)=I*1e3;
    Po(mmm,mm)=sum(N(1:4000))/4000;
    N1(mmm,mm)=sum(N(1:4000)/4000);

    Po1(mmm,:)=P;
    Nt(mmm,:)=N;
    S1(mmm,:)=S;
    end
    end


    tt=tt*1e-9;
    figure(1)
    plot(tt,N);
    figure(2)
    plot(tt,S);
     
  5. Jul 20, 2010 #4

    berkeman

    User Avatar

    Staff: Mentor

    What is "not working"? You really need to be more clear in your posts here on the PF.
     
  6. Jul 20, 2010 #5
    Thank you. I solved the problem.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook