CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Shallow Water Equations - Lax Wendroff Method - FORTRAN Code (https://www.cfd-online.com/Forums/main/202365-shallow-water-equations-lax-wendroff-method-fortran-code.html)

aunmhd May 29, 2018 07:47

Shallow Water Equations - Lax Wendroff Method - FORTRAN Code
 
Hey everyone,

I'm writing a FORTRAN Code for simulating the propagation of shallow water waves (1D). The case is pretty simple: I have a wave generator on one end of the pool and a Wall boundary condition on another. I'm using the Lax Wendroff Method. The equations have the form:
!
! dh/dt + dA/dx = 0
!
! dA/dt + dB/dx = C

The difficulty which I am facing is the implementation of the Boundary Conditions for the half time steps. For this reason, I haven't been able to initiate wave propagation over the surface. Anybody with experience is welcome to comment so that I may share more detail and/or code.

FMDenaro May 29, 2018 10:28

Quote:

Originally Posted by aunmhd (Post 693882)
Hey everyone,

I'm writing a FORTRAN Code for simulating the propagation of shallow water waves (1D). The case is pretty simple: I have a wave generator on one end of the pool and a Wall boundary condition on another. I'm using the Lax Wendroff Method. The equations have the form:
!
! dh/dt + dA/dx = 0
!
! dA/dt + dB/dx = C

The difficulty which I am facing is the implementation of the Boundary Conditions for the half time steps. For this reason, I haven't been able to initiate wave propagation over the surface. Anybody with experience is welcome to comment so that I may share more detail and/or code.




How do you implement the LW method? Why have you needed about half stime step?

aunmhd May 29, 2018 16:31

Quote:

Originally Posted by FMDenaro (Post 693901)
How do you implement the LW method? Why have you needed about half stime step?

My wording was incorrect. Not half time step.
I have a wall boundary condition on the left. A wave generator on the right which generates a sine wave throughout the time domain. I have correctly applied the initial conditions: the initial water depth=1 and the initial velocity in water=0. The main part of the code for the Lax-Wendroffs two step method is attached below:

Code:

DO j=1,NT+1
    DO i=2,NX

BN(i-1,j)=(HN(i-1,j)*(UN(i-1,j))**2)+((g*(HN(i-1,j)**2))/2)
BN(i+1,j)=(HN(i+1,j)*(UN(i+1,j))**2)+((g*(HN(i+1,j)**2))/2)

CN(i,j)=(Cf*UN(i,j)*ABS(UN(i,j))*rho)/(2.0*W)

HN(NX+1,j)=H0+(Amplitude/2.0)*SIN((2.0*PI*T(j))/(T_LENGTH/10.0))
HNP102(1,j)=HN(1,j)-(DT/(2*DX))*(AN(2,j))                          !WALL BC
HNP102(i,j)=(0.5*(HN(i+1,j)+HN(i-1,j)))-((DT/(4*DX))*(AN(i+1,j)-AN(i-1,j)))


ANP102(NX+1,j)=AN(NX+1,j)-((DT/(2*DX))*(BN(NX+1,j)-BN(NX,j)))-((DT/2)*CN(NX+1,j))
ANP102(i,j)=0.5*(AN(i+1,j)+AN(i-1,j))-((DT/(4*DX))*(BN(i+1,j)-BN(i-1,j)))-((DT/2)*CN(i,j))

UNP102(i,j)=ANP102(i,j)/HNP102(i,j)

BNP102(i,j)=(HNP102(i,j)*(UNP102(i,j))**2)+((g*(HNP102(i,j)**2))/2)

CNP102(i,j)=(Cf*UNP102(i,j)*ABS(UNP102(i,j))*rho)/(2.0*W)

HNP1(1,j)=HN(1,j)-((DT/(2.0*DX))*ANP102(2,j))
HNP1(NX+1,j)=H0+(Amplitude/2.0)*SIN((2.0*PI*T(j))/(T_LENGTH/10.0)) 
HNP1(i,j)=HN(i,j)-(DT/(2.0*DX))*(ANP102(i+1,j)-ANP102(i-1,j))

BNP102(1,j)=(g*H0**2)/2.0
BNP102(NX+1,j)=(HNP102(NX+1,j)*UNP102(NX+1,j)**2)+((g*HNP102(NX+1,j)**2)/2)
ANP1(NX+1,j)=AN(NX+1,j)-(DT/(2*DX))*(BNP102(NX+1,j)-BNP102(NX,j))-        &
            (DT*CNP102(NX+1,j))

ANP1(i,j)=AN(i,j)-(DT/(2.0*DX))*(BNP102(i+1,j)-BNP102(i-1,j))-(CNP102(i,j)*DT)

UNP1(i,j)=ANP1(i,j)/HNP1(i,j)
    END DO
UNP1(i,j)=UN(i,j)
HNP1(i,j)=HN(i,j)
END DO


FMDenaro May 29, 2018 17:41

COuld you write exactly the PDE system with the BC.s?

aunmhd May 29, 2018 18:37

2 Attachment(s)
I have attached the System of PDES and BCs.
The wave generator is at N+1.


Attachment 63654 Attachment 63655

tafresh.university May 29, 2018 20:07

1 Attachment(s)
I want to solve this problem but I can’t because it is my first time that I am coding so I need help for solve
Anybody can help me??????
Attachment 63657
MATLAB or fortran
Please help me......

FMDenaro May 30, 2018 02:45

Quote:

Originally Posted by aunmhd (Post 693946)
I have attached the System of PDES and BCs.
The wave generator is at N+1.


Attachment 63654 Attachment 63655




I have asked for the PDE problem not the numerical method...

aunmhd May 30, 2018 12:38

1 Attachment(s)
The code I have written in the post above is incorrect. I have corrected it.
There is one problem I cannot solve.
The wall is a reflective boundary condition. The boundary condition which I have written in the attachments above is incorrect.
HNP1(1) ~ The water level at the wall must be assigned a value such that the wave is reflected off the wall.

Attachment 63684


All times are GMT -4. The time now is 17:00.