Tuesday, April 21, 2009

Afflux and Backwater

As water engineers we often know terms of 'backwater' rather than 'afflux'. Why?. Don't be confused!
In hydrology, afflux is defined as a rise in the water level immediately upstream of and due to a natural or artificial obstruction. Backwater is a consequence of afflux, in other words the afflux brings 'backwater effect'.

Friday, April 10, 2009

TVD Scheme for SUIKOU-2D v2.0

TVD stands for Total Variation Diminishing, a scheme to eliminate the numerical oscillations or commonly occurred in the explicit numerical methods when they are approaching the high gradient regions. The mathematical expressions of TVD can be reviewed here. I am not going to explain detail about TVD but systematically outlining its implementation to the current version of SUIKOU-2D.
As in previous post, SUIKOU-2D v1.0 was developed to solve full set of Shallow Water Equations (SWEs) using the explicit MacCormack Method . Artificial viscosity (AV) scheme, a control of numerical dissipations to handle shock waves was added. AV is acting as a fashioned approach where the viscosity/turbulence parameters are given as fixed values to all computational steps. It takes series of iterations to get a convergence result. Several improvement efforts has been sought and now it's being altered by TVD scheme in the latest codes of SUIKO-2D. The convergence is quite faster compared to previous one. The general computation blocks are drawn as below figure.

In SUIKOU v2.0 a five-points symmetric TVD term has been used to remove the numerical oscillations and calculated after the corrector step.

where r( ) is scalar product of two vector Ui+1/2 and Ui-1/2 within the point brackets below:

in which U=(h,u,v)

these scalar products can be rewritten in detail as

The function G( ) is defined as

while the flux limiter is:

and C variable is a function of courant number, Cr
The imaginary grid points of above variables are described as below:

Back to AV, it's obviously seen that it is likely a simple model of TVD. The corrections are only made on the basis of water depth, h, whilst TVD deploys all flow variables (u,v,h) to furnish final results.

Wednesday, April 8, 2009

Numerical treatment of the source terms in SUIKOU-2D v2.0

The history of the numerical treatment of hydrodynamic model is extremely long and has been provided a lot of variance in the numerical approaches. Commonly, the flooding models are simplified by elimination the source terms. In consequences they are limited to simulate bore propagation or flash flood occurred in dambreak events.

Using TVD-MacCORMACK, a two-stage scheme gives a benefit where source terms can be easily treated and preserves that whole scheme has second order accuracy in both time and space. However, if the bottom topography shows strong variation it is required a special treatment of the source terms to eliminate or reduce the artificial numerical error caused by adding TVD corrections to the MacCORMACK. The treatment of source terms related to strong bed slope is adopted here.

to be continued ....

Saturday, April 4, 2009

Visualize results with Gnuplot

This article is briefly showing a hands-on guide to turn the output data of SUIKOU-2D into professional-looking graphs with Gnuplot, a freely distributed plotting tool.

According to FAQ 1.7, Gnuplot is freeware in the sense that you don't have to pay for it. However, it is not freeware in the sense that you would be allowed to distribute a modified version of your gnuplot freely.

The program could be downloaded here. Please read and accept the Copyrights to use it. Basically, Gnuplot is a command line driven plotting tool with extensive supports for many types of plots in either 2D and 3D with capabilities to draw using lines, points, boxes, contours, vector fields, surfaces, and various associated text, but it would be very nice to be able to have the FORTRAN codes to continue execution without fires it up in the command-line mode.

By inserting the below fortran code in SUIKOU-2D.for, it automatically displays interactive plots at the end of running program. Control plots could be managed by user in a separate text file of gnuport.txt, a compilation of selected shell scripts. It only requires "wgnuplot.exe" (1,906KB) that must be copied into folder where SUIKOU-2D.for is otherwise the plots won't be displayed.

Here is the Fortran code with an example of main program to call.
$freeform
program gnuport
call porting_gnuplot ( 'gnuport.txt' )
stop ''
end

subroutine porting_gnuplot(console)
character (len=100) command
character (len=*) console
integer status

integer system
write (command, *) 'wgnuplot ' // trim (console)
status=system(trim(command))
if (status.eq.0) then
write (*,*)

write ( *, '(a)' ) ' Normally end.'
else
write(*,*)
write ( *, '(a)' ) ' Fatal error!'

stop ''
end if

return
end

and a simple example of gnuport.txt
unset key
set title "Visualization with Gnuplot" font "Times-Roman,14"
set size ratio 0.35
set ticslevel 0
set ztics 5

set noxtics
set noytics
set zrange [0:10]
set xlabel "x-grid"
set ylabel "y-grid"

set cbtics 5
set cblabel "water depth (m)" offset character -2,0
set cbrange [0:10]
set palette rgbformulae 3,0,13
splot "y0004.gnu" matrix with pm3d

pause -1

set size ratio 1.35
set view map

splot "y0004.gnu" matrix with pm3d
pause -1
set view map
set contour base

set palette rgbformulae 3,0,13
set cbtics 5

set cbrange [0:10]
unset surface
splot "y0004.gnu" matrix with lines palette
pause -1
a=0.01
plot "u0004.gnu" using 1:2:(a*$3):(a*$4) with vector
pause -1


Screenshots:





It's a simple work to make fruitful life, isn't? :)

Link:
http://gnuplot.sourceforge.net/demo/