HW-9

advertisement
Spring 2010 CIVL 7170 HW#9 (Developed by Dr. Clement, Email: clement@auburn.edu)
Revised (May 10, 2013)
1) Use a finite volume type code (flux based code) to solve the advection equation for a system
with C =1 at x = 0; IC = 0 at all X; v = 1; delx = 0.5, L = 100 cm. Predict the concentration profiles
at 5, 10, 15 and 20 days using an explicit method with backward difference fluxes. Use delt
corresponding to Courant number = 1, and Courant 0.5. Notice Courant 0.5 will have a diffusive
solution.
2) Solve the above problem for using Lax Friedrich fluxes and present the results
3) Solve the above problem using Lax Wendroff fluxes and present the results
4) Do your own research to develop a better finite volume scheme to solve the advection
equation. A combination of LF and LW schemes might work better and also there are other flux
schemes available in the literature. Furthermore, flux-limiter schemes (e.g., TVD methods) that
limit oscillations are also available. Google or do some research and find a scheme of your
choice, describe it, write a program and present the results.
5) Use the Operator-Split method to solve the following problem (same as the previous HW
problem) and compare your results against analytical solution.
Problem data: Solve the advection equation for a system with C =1 at x = 0; IC = 0 at all X; v =
1; delx = 0.5; L = 100 cm; D = 0.3 cm2/day; delt = 0.1. Predict the concentration profiles at 5,
10, 20, and 80 days. Compare your results against the analytical solution.
Dim c(51) As Single, pc(51) As Single, fim As Single, fip As Single
Dim delx As Single, delt As Single, v As Single, Iflag As Integer
Dim nx As Integer, nt As Integer, i As Integer, it As Integer
Dim fipLf As Single, fimLf As Single, fipLwf As Single, fimLwf As Single
Dim ccp As Single, ccm As Single
Iflag = 3 ‘ Flag for method- 1 backward explicit flux, 2 Lax Friedrich, 3 Lax-Wendroff
v=1
delt = 0.5
delx = 1
nx = 51
nt = 25
For i = 1 To nx
c(i) = 0#
pc(i) = 0#
Next i
'Boundary conditions
c(1) = 10#
pc(1) = 10#
1
Spring 2010 CIVL 7170 HW#9 (Developed by Dr. Clement, Email: clement@auburn.edu)
For it = 1 To nt
If (Iflag = 1) Then
'Backward difference approx for the fluxes
For i = 2 To nx - 1
fip = v * pc(i)
fim = v * pc(i - 1)
c(i) = pc(i) - (delt / delx) * (fip - fim)
Next i
ElseIf (Iflag = 2) Then
'Lax-Friderich flux
For i = 2 To nx - 1
fipLf = 0.5 * (v * pc(i) + v * pc(i + 1)) + (0.5 * delx / delt) * (pc(i) - pc(i + 1))
fimLf = ???
c(i) = pc(i) - (delt / delx) * (fipLf - fimLf)
Next i
ElseIf (Iflag = 3) Then
'Lax-Wendroff flux
For i = 2 To nx - 1
ccp = 0.5 * (pc(i) - pc(i + 1)) + (0.5 * delt / delx) * (v * pc(i) - v * pc(i + 1))
fipLwf = v * ccp
ccm = ???
fimLwf = v * ccm
c(i) = ???
Next i
End If
For i = 2 To nx - 1 'Advancing the time step
pc(i) = c(i)
Next i
Next it 'Next time
For i = 1 To nx
Cells(i, 1) = i
Cells(i, 2) = pc(i)
Next i
2
Download