DepthFromArea Function

private function DepthFromArea(A, B0, alpha) result(y)

returns water depth given wetted area (m) using Newton-Raphson.

References:

Todini, E. (2007) A mass conservative and water storage consistent variable parameter Muskingum-Cunge approach, Hydrol. Earth Syst. Sci.,1645-1659.

Arguments

Type IntentOptional Attributes Name
real(kind=float), intent(in) :: A

area (m2)

real(kind=float), intent(in) :: B0

bottom width, = 0 for triangular section (m)

real(kind=float), intent(in) :: alpha

angle formed by dykes over a horizontal plane (deg)

Return Value real(kind=float)


Variables

Type Visibility Attributes Name Initial
real(kind=float), public :: A0
real(kind=float), public :: calpha

cotangent of angle alpha

real(kind=float), public :: dAdy
integer, public :: i
integer, public :: maxiter = 100
real(kind=float), public :: tol = 0.001
real(kind=float), public :: y1

Source Code

FUNCTION DepthFromArea &
( A, B0, alpha ) &
RESULT (y)


IMPLICIT NONE

! Function arguments
! Arguments with intent(in):
REAL (KIND = float), INTENT (IN) :: A !!area (m2)
REAL (KIND = float), INTENT (IN) :: B0 !!bottom width, = 0 for  triangular  section (m)
REAL (KIND = float), INTENT (IN) :: alpha !!angle formed by dykes over a horizontal plane (deg)

! Arguments with intent(OUT):
REAL (KIND = float) :: y

!local declaration:
INTEGER :: i
INTEGER :: maxiter = 100
REAL (KIND = float) :: y1
REAL (KIND = float) :: A0
REAL (KIND = float) :: dAdy !first derivative
REAL (KIND = float) :: tol = 0.001
REAL (KIND = float) :: calpha !!cotangent of angle alpha

!------------end of declaration------------------------------------------------

calpha = 1. / TAN(alpha*degToRad)

!first guess, y = 1 m
y = 1.

DO i = 1, maxiter
  A0 = WettedArea ( y, B0, alpha )
  dAdy = calpha * y + (B0 + y * calpha)

  y1 = y -   (A0 - A) / dAdy
  
  !test conf
  IF ( ABS(y1 - y) / y <= tol) THEN !root found
    y = y1
    RETURN
  END IF 

  y = y1
END DO

RETURN

RETURN
END FUNCTION DepthFromArea