Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help with FDTD (2,4) program

Status
Not open for further replies.

kotsoss

Newbie level 4
Newbie level 4
Joined
Apr 20, 2013
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,315
Hi, I think that my fdtd program doesnt work properly. It is 4th order in space and 2nd order in time.
In 2th order in space my programworks correct.

Code:
L=100;
i=zeros(1,L);
v=zeros(1,L;

dz=0.01;
c=0.1;
l=250;


dt=dz*sqrt(l*c);




for n=1:2000
   t=n*dt;

    
    for k=1:L-1   
        if k==1
           v(k)=v(k)-dt/(c*dz)*(i(k+1)-i(k));
        elseif k==L-1
            v(k)=v(k)-dt/(c*dz)*(i(k+1)-i(k));
        
        else
            v(k)=v(k)-(((6/7)*dt)/(c*24*dz))*(i(k-1)-(27*i(k))+(27*i(k+1))-i(k+2));
        end
    end
    
    

    v(1)=sin(2*pi*t);
 
    v(st)=0;          
  
  
    for k=2:L
        if k==2
            i(k)=i(k)-dt/(l*dz)*(v(k)-v(k-1));
        elseif k==st
            i(k)=i(k)-dt/(l*dz)*(v(k)-v(k-1));
        else
            i(k)=i(k)-(((6/7)*dt)/(l*24*dz))*(v(k-2)-(27*v(k-1))+(27*v(k))-v(k+1));
        end
    end
    

    plot(v);
    axis([1 L -3 3]);
    
    frame = getframe;
   
end


Anyone knows whats wrong?

Anyone have a 4th order in space fdtd code? I searched and I didnt find anything.:cry:

Here is the results (in the red circle u can see the error):
 

Attachments

  • χωρίς τίτλο.JPG
    χωρίς τίτλο.JPG
    12.3 KB · Views: 90

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top