# FEM - lax friedrichs two step method

• blizzard12345
In summary, the conversation was about a code written by the speaker that follows the Lax Friedrichs two step technique for solving hyperbolic partial differential equations. The code calculates the stability CFL condition, calculates half step values for height and velocity, and then uses those values to calculate full time step values. Finally, the code updates the values and plots them. The source for the Lax Friedrich method was also mentioned.
blizzard12345
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-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

plot(x,H,'r'); hold on endThis code is based on the Lax Friedrichs two step technique. The first step is a calculation of the stability CFL condition to ensure that the numerical method is stable. This is done by calculating the maximum wave speed in the domain and setting the time step size, dt, according to the CFL condition (dt/dx)*(velocity + root(2*g)). The second step is to calculate the half step values for the height and velocity in the domain. This is done by using the couple_one and couple_two functions to calculate the values at each point. The third step is to calculate the full time step values for the height and velocity in the domain using the half step values from the previous step. This is done by subtracting (dt/dx)*(h_half(i+1) - h_half(i)) from the height and (dt/dx)*(uh_half(i+1) - uh_half(i)) from the velocity. Finally, the fourth step is to update the height and velocity values in the domain and plot them. The values are updated by setting the H and UH vectors equal to the h and uh vectors and then plotting the values in the H vector. Overall, this code follows the steps of the Lax Friedrichs two step technique for solving hyperbolic partial differential equations numerically.

## 1. What is the FEM - Lax Friedrichs two step method?

The FEM - Lax Friedrichs two step method is a numerical method used to solve partial differential equations (PDEs). It is a finite element method (FEM) that combines the Lax-Friedrichs method, a finite volume method, with a two-step time discretization scheme. It is often used in fluid dynamics and other fields of physics and engineering.

## 2. How does the FEM - Lax Friedrichs two step method work?

The FEM - Lax Friedrichs two step method works by first discretizing the PDE into smaller subproblems, also known as elements. Then, the Lax-Friedrichs method is used to approximate the solution at each time step within each element. Finally, a two-step time discretization scheme is used to update the solution at each time step. This process is repeated until the desired accuracy is achieved.

## 3. What are the advantages of using the FEM - Lax Friedrichs two step method?

One of the main advantages of the FEM - Lax Friedrichs two step method is its ability to handle complex geometries and boundary conditions. It also offers high accuracy and stability, making it suitable for a wide range of PDE problems. Additionally, it is computationally efficient and can be easily implemented in computer programs.

## 4. Are there any limitations to the FEM - Lax Friedrichs two step method?

Like any numerical method, the FEM - Lax Friedrichs two step method has its limitations. It may not always provide the most accurate solution, especially for problems with strong shocks or discontinuities. It also requires a significant amount of computational resources, which can make it impractical for some problems.

## 5. How is the FEM - Lax Friedrichs two step method used in real-world applications?

The FEM - Lax Friedrichs two step method is commonly used in various fields of physics and engineering, such as fluid dynamics, solid mechanics, and heat transfer. It has been applied to study the flow of air over aircraft wings, the behavior of fluids in pipes, and the heat transfer in electronic devices. It is also used in the design of structures and materials in civil and mechanical engineering.

Replies
7
Views
2K
Replies
3
Views
2K
Replies
2
Views
2K
Replies
2
Views
2K
Replies
1
Views
1K
Replies
65
Views
3K
Replies
23
Views
4K
Replies
9
Views
2K
Replies
1
Views
4K
Replies
1
Views
2K