Notices
Results 1 to 2 of 2

Thread: Insert Quantum Equation In Matlab

  1. #1 Insert Quantum Equation In Matlab 
    New Member
    Join Date
    Feb 2009
    Posts
    2
    Hi everyone,
    i have a difficult exercise in matlab and i need your help if anyone knows.
    The idea of this exercise is to insert a theoretical equation Cdot in Matlab.With the results which it'll give me,i want to create a theoretical graph with axis x(v) and y(Cdot).Finally this graph i want to compare it with one experimental graph which i have.Summary,my goal is to find the best combination of ndot,M,edot in which the theoretical graph to be quite similar to experimental graph(sorry for my bad English).

    The equation which i have is:
    a=1/(1+exp((E - Vdot)/(k*T)))
    b=(G*Ndot)/sqrt((pi*M)/2)
    c=exp(-2((E + Edot + Vdot)/M)^2)
    Cdot=q*A*L∂/∂v∫a*b*c dE

    where Vdot=v/L and M=de(this name i gave it in my code).The integral i want to be [0,+inf] with respect to E.
    The total equation which i want to insert in matlab is Total=Cdot1+Cdot2+C.
    Cdot1,Cdot2 are 2 different distrubutions and
    C=A*(sqrt((q*ep*e0*Nd)./(2*(Vbi-v-k*T))))

    Now the code which i thought is:
    Firstly,i make 2 m-files with names integral1,integral2 which has this function(everything i do here is the same with m-file integral2):

    Code:
    function subtotal1=integral1(ndot1,de1,v1)
    
    A=12.56e-4;  %this value is static,not change
    L=0.44;         %this value is static,not change
    G=2;             %this value is static,not change
    T=300.0;       %this value is static,not change
    q=1.6e-19;    %this value is static,not change   
    k=8.62e-5;    %this value is static,not change(Boltzman)   
    Edot1=-0.3;   %between -0.6-0.6    
    syms E;           %(define) E
    
    
    a=1/(1+exp((E-(v/L))/(k*T)));
    b=(G*ndot1)./(sqrt((pi*de1)/2));
    ek8eths1=((E+Edot1+(v/L))/de1).^2;
    c=exp(-2*ek8eths1);
    final1=a.*c*b;
    
    inline_final1 = vectorize (inline (char (final1)));
    subtotal1 = quad (inline_final1,0,1e13);
    My problem is the last 2 lines.I'm not sure if this is the best way to find the integral.Also,if i try quad (inline_final1,0,inf) then all the values are NaN.Why?

    The 2nd code is an m-file with name derivative.
    Code:
    clear all
    clc
    A=12.56e-4;
    L=0.44;
    q=1.6e-19;
    ep=13;
    e0=8.85e-14;
    Nd=2e15;
    Vbi=2;
    k=8.62e-5;
    T=300.0;
    i=1;
    
    %1st distribution
    ndot1=3e10;
    de1=0.1;
    %2nd distribution
    ndot2=9e10;
    de2=0.1;
    v=-12:0.05:1.5;
    C=A*(sqrt((q*ep*e0*Nd)./(2*(Vbi-v-k*T))));
    
       for i=1:1; 
       for j=1:length(v)    
        fintegrals1(j,i)=integral1(ndot1(i),de1(i),v(j));
        fintegrals2(j,i)=integral2(ndot2(i),de2(i),v(j));
    end
    end
    
    deriv1=-(diff(fintegrals1))./0.05;  % (Q2-Q1)/(V2-V1)
    deriv2=-(diff( fintegrals2))./0.05;
    total1=deriv1.*(q*A*L);
    total2=deriv2.*(q*A*L);
    C=C.';       %1x280 to 280x1
    totaly=C+total1+total2;
    path(path,'c:\thodoris')          %here i have the experimental values
    load askisi2.txt           
    plot(askisi2(:,1),askisi2(:,2),v,totaly)
    title('Ari8mitikh Epilisi')
    xlabel('V')
    ylabel('Col')
    legend('peiramatiki','8ewritiki')
    This is the huge code which i thought.Maybe when you see that you have headache.
    But my really problem is how to calculate the integral and about that i need your help if anyone knows.
    Thank You!!


    Reply With Quote  
     

  2.  
     

  3. #2  
    Forum Freshman holysword's Avatar
    Join Date
    Apr 2008
    Posts
    41
    This is the huge code which i thought.Maybe when you see that you have headache.
    Actually I've seen bigger... much bigger XD

    First suggestion, you can use latex commands in this forum, so if I got it right your formulas are:




    Consult this link to get som tips about latex using here.

    But my really problem is how to calculate the integral and about that i need your help if anyone knows.
    Well, as long as I know quad does not support infinite interval. If you're sure that this function drops quickly, you should try quadgk instead.

    One more thing about yout function declaration, I'm not sure if vectorize is the best choice... You can for instance put something like
    Code:
    @(x)4*x-3
    to evaluate the function with as variable. Anyway, just a wondering...


    "Nolite arbitrari quia venerim mittere pacem in terram non veni pacem mittere sed gladium"
    Yeshua Ha Mashiach
    Reply With Quote  
     

Bookmarks
Bookmarks
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •