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.(adsbygoogle = window.adsbygoogle || []).push({});

thanks for any help in advance kyle :)

source for lax Friedrich method: http://www.scribd.com/doc/49845422/33/Lax-Wendroﬀ-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

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# FEM - lax friedrichs two step method

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

Loading...

Similar Threads for friedrichs step method | Date |
---|---|

A Intermediate Axis Theorem - Lyapunov's Indirect Method | Mar 20, 2018 |

System of ODEs with RK4 & step doubling in Fortran : damping | Nov 12, 2015 |

Steps to solving L{u(t−2)e3t}? | May 31, 2015 |

First-Order Equations: don't understand a simplification step | Feb 5, 2015 |

Solving PDE with smoothing - Time step Query | Dec 3, 2014 |

**Physics Forums - The Fusion of Science and Community**