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

FEM - lax friedrichs two step method

  1. Mar 27, 2012 #1
    hi i have written a code which according to my tutor is the lax friedrichs two step technique , however i can't see how to show how i came across this code (i kinda changed random things and hoped at some point he would say its correct.

    thanks for any help in advance kyle :)

    source for lax Friedrich method: http://www.scribd.com/doc/49845422/33/Lax-Wendroff-Method (page 69, i understand that it is only showing the one step for this source)

    my code: (the program in question is a matlab script)



    while time <= output
    %calculate stability CFL condition to ensure stability
    %(dt/dx)*(velocity + root(2*g))
    wmax=0;
    for i = 1:nx
    w=abs(uh(i)/h(i)) + sqrt(h(i)*abs(g));
    if(wmax<w)wmax=w;
    end
    end
    dt=cfl*dx/wmax;
    time = time + dt;
    time
    %calculate half
    for i = 1:nx-1
    h_half(i+1) = 0.5*((couple_one(h(i+1),uh(i+1)) + couple_one(h(i),uh(i))) - ((dx/dt)*( h(i+1) - h(i) )));
    uh_half(i+1) = 0.5*((couple_two(h(i+1),uh(i+1),g) + couple_two(h(i),uh(i),g)) - ((dx/dt)*( uh(i+1) - uh(i) )));


    end
    %full time step calcs
    for i = 2:nx-1


    h(i) = h(i) - (dt/dx)*(h_half(i+1) - h_half(i));
    uh(i) = uh(i) - (dt/dx)*(uh_half(i+1) - uh_half(i));
    end
    %update big H ready for plot
    for i = 1:nx
    H(i) = h(i);
    UH(i) = uh(i);
    end
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: FEM - lax friedrichs two step method
Loading...