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))
    for i = 1:nx
    w=abs(uh(i)/h(i)) + sqrt(h(i)*abs(g));
    time = time + dt;
    %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) )));

    %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));
    %update big H ready for plot
    for i = 1:nx
    H(i) = h(i);
    UH(i) = uh(i);
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

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