10 module procedure sfr_calc_tvd
13 integer(I4B) :: igwfconn
41 d_old = max(this%stageold(n) - this%strtop(n), dzero)
42 a_old = this%calc_area_wet(n, d_old)
45 call this%sfr_calc_qman(n, d_old, q_out_old)
46 q_in_old = this%usinflowold(n)
49 call this%sfr_calc_celerity(n, q_out_old, celerity)
50 courant = celerity *
delt / this%length(n)
53 if (courant > dzero)
then
54 if (courant < this%crmin(n)) this%crmin(n) = courant
55 if (courant > this%crmax(n)) this%crmax(n) = courant
56 this%crsum(n) = this%crsum(n) + courant
57 this%crcnt(n) = this%crcnt(n) + 1
62 if (courant <= done)
then
63 iup = this%itvd_upstream(n)
65 q_in2_old = this%usinflowold(iup)
66 dq_loc = q_out_old - q_in_old
67 dq_up = q_in_old - q_in2_old
68 if (abs(dq_loc) > dem30)
then
71 phi = (r + abs(r)) / (done + abs(r))
73 q_tvd = q_out_old + dhalf * (done - courant) * phi * dq_loc
81 q_tvd = max(q_tvd, dzero)
84 q_in_new = qu + qi + qfrommvr
88 igwfconn = this%sfr_gwf_conn(n)
97 picard:
do i = 1, this%maxsfrpicard
98 if (igwfconn == 1)
then
99 call this%sfr_calc_qgwf(n, d1, hgwf, qgwf)
101 q_avail = q_in_new + q_lat
102 if (qgwf > q_avail) qgwf = q_avail
106 v_new = a_old * this%length(n) +
delt * (q_in_new + q_lat - qgwf - q_tvd)
107 if (v_new < dzero)
then
109 q_tvd = max(q_in_new + q_lat - qgwf + &
110 a_old * this%length(n) /
delt, dzero)
113 a_new = v_new / this%length(n)
117 if (d1 <= dzero .and. a_new > dzero)
then
118 d1 = a_new / max(this%station(this%iacross(n)), dem30)
120 newton_depth:
do j = 1, this%maxsfrit
121 res = this%calc_area_wet(n, d1) - a_new
122 tw = this%calc_top_width_wet(n, d1)
128 if (d1 < dzero) d1 = dzero
129 if (abs(res) < this%deps)
exit newton_depth
132 delh = abs(d1 - d1_old)
133 if (i > 1 .and. delh < this%dmaxchg)
exit picard
138 qd = max(q_tvd, dzero)
139 this%storage(n) = (a_old - a_new) * this%length(n) /
delt
143 end procedure sfr_calc_tvd
This module contains the SFR package methods.
real(dp), pointer, public delt
length of the current time step