Skip to content

Commit 300b21f

Browse files
refactor(swf-zdg): clean up flow calculation (#1932)
1 parent f3f6938 commit 300b21f

File tree

1 file changed

+15
-32
lines changed

1 file changed

+15
-32
lines changed

src/Model/SurfaceWaterFlow/swf-zdg.f90

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ module SwfZdgModule
6464
! -- methods for time series
6565
procedure, public :: bnd_rp_ts => zdg_rp_ts
6666
! -- private
67-
procedure, private :: get_cond
67+
procedure, private :: qcalc
6868
end type SwfZdgType
6969

7070
contains
@@ -315,7 +315,6 @@ subroutine zdg_cf(this)
315315
real(DP) :: qeps
316316
real(DP) :: absdhdxsq
317317
real(DP) :: depth
318-
real(DP) :: cond
319318
real(DP) :: derv
320319
real(DP) :: eps
321320
real(DP) :: range = 1.d-6
@@ -344,14 +343,11 @@ subroutine zdg_cf(this)
344343
depth = depth * smooth_factor
345344

346345
! -- calculate unperturbed q
347-
! TODO: UNITCONV?!
348-
cond = this%get_cond(i, depth, absdhdxsq, this%unitconv)
349-
q = -cond * this%slope(i)
346+
q = -this%qcalc(i, depth, this%unitconv)
350347

351348
! -- calculate perturbed q
352349
eps = get_perturbation(depth)
353-
cond = this%get_cond(i, depth + eps, absdhdxsq, this%unitconv)
354-
qeps = -cond * this%slope(i)
350+
qeps = -this%qcalc(i, depth + eps, this%unitconv)
355351

356352
! -- calculate derivative
357353
derv = (qeps - q) / eps
@@ -365,47 +361,34 @@ subroutine zdg_cf(this)
365361
return
366362
end subroutine zdg_cf
367363

368-
!> @brief Calculate conductance-like term
364+
! !> @brief Calculate flow
369365
!!
370-
!! Conductance normally has a dx term in the denominator
371-
!! but that is not included here, as the flow is calculated
372-
!! using Q = C * slope. The returned c value from this
373-
!! function has dimensions of L3/T.
374-
!!
375-
!<
376-
function get_cond(this, i, depth, absdhdxsq, unitconv) result(c)
377-
! -- modules
378-
! -- dummy
366+
!! Calculate volumetric flow rate for the zero-depth gradient
367+
!! condition. Flow is positive.
368+
! !<
369+
function qcalc(this, i, depth, unitconv) result(q)
370+
! dummy
379371
class(SwfZdgType) :: this
380372
integer(I4B), intent(in) :: i !< boundary number
381373
real(DP), intent(in) :: depth !< simulated depth (stage - elevation) in reach n for this iteration
382-
real(DP), intent(in) :: absdhdxsq !< absolute value of simulated hydraulic gradient
383374
real(DP), intent(in) :: unitconv !< conversion factor for roughness to length and time units of meters and seconds
384-
! -- local
375+
! return
376+
real(DP) :: q
377+
! local
385378
integer(I4B) :: idcxs
386-
real(DP) :: c
387379
real(DP) :: width
388380
real(DP) :: rough
389381
real(DP) :: slope
390-
real(DP) :: roughc
391-
real(DP) :: a
392-
real(DP) :: r
393382
real(DP) :: conveyance
394-
!
383+
395384
idcxs = this%idcxs(i)
396385
width = this%width(i)
397386
rough = this%rough(i)
398387
slope = this%slope(i)
399-
roughc = this%cxs%get_roughness(idcxs, width, depth, rough, &
400-
slope)
401-
a = this%cxs%get_area(idcxs, width, depth)
402-
r = this%cxs%get_hydraulic_radius(idcxs, width, depth, area=a)
403-
404-
!conveyance = a * r**DTWOTHIRDS / roughc
405388
conveyance = this%cxs%get_conveyance(idcxs, width, depth, rough)
406-
c = conveyance / absdhdxsq
389+
q = conveyance * slope**DHALF * unitconv
407390

408-
end function get_cond
391+
end function qcalc
409392

410393
!> @ brief Copy hcof and rhs terms into solution.
411394
!!

0 commit comments

Comments
 (0)