MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
uzf-waves.f90
Go to the documentation of this file.
1!> @brief Kinematic wave routing through the unsaturated zone
2!<
3submodule(uzfcellgroupmodule) uzfcellgroupwaves
4contains
5
6 !> @brief Reset waves to default values at start of simulation
7 !<
8 module procedure setwaves
9 ! -- local
10 real(DP) :: bottom, top
11 integer(I4B) :: j
12 real(DP) :: thick
13 !
14 this%flux_to_wt(icell) = dzero
15 this%nwaves(icell) = 1
16 thick = this%celtop(icell) - this%water_table(icell)
17 do j = 1, this%nwaves_max
18 this%wave_depth(j, icell) = dzero
19 this%wave_theta(j, icell) = this%theta_res(icell)
20 end do
21 !
22 ! -- initialize waves for first stress period
23 if (thick > dzero) then
24 this%wave_depth(1, icell) = thick
25 this%wave_theta(1, icell) = this%theta_init(icell)
26 top = this%wave_theta(1, icell) - this%theta_res(icell)
27 if (top < dzero) top = dzero
28 bottom = this%theta_sat(icell) - this%theta_res(icell)
29 if (bottom < dzero) bottom = dzero
30 this%wave_flux(1, icell) = this%vks(icell) &
31 * (top / bottom)**this%bc_eps(icell)
32 if (this%wave_theta(1, icell) < this%theta_res(icell)) &
33 this%wave_theta(1, icell) = this%theta_res(icell)
34 !
35 ! -- calculate water stored in the unsaturated zone
36 if (top > dzero) then
37 this%wave_speed(1, icell) = dzero
38 else
39 this%wave_flux(1, icell) = dzero
40 this%wave_speed(1, icell) = dzero
41 end if
42 !
43 ! no unsaturated zone
44 else
45 this%wave_flux(1, icell) = dzero
46 this%wave_depth(1, icell) = dzero
47 this%wave_speed(1, icell) = dzero
48 this%wave_theta(1, icell) = this%theta_res(icell)
49 end if
50 end procedure setwaves
51
52 !> @brief Prepare and route waves over time step
53 !<
54 module procedure routewaves
55 ! -- local
56 real(DP) :: thick, thickold
57 integer(I4B) :: idelt, j, ik
58 !
59 this%flux_to_wt(icell) = dzero
60 this%et_uz(icell) = dzero
61 thick = this%celtop(icell) - this%water_table(icell)
62 thickold = this%celtop(icell) - this%water_table_old(icell)
63 !
64 ! -- no uz, clear waves
65 if (thickold < dzero) then
66 do j = 1, this%nwaves(icell)
67 this%wave_theta(j, icell) = this%theta_res(icell)
68 this%wave_depth(j, icell) = dzero
69 this%wave_speed(j, icell) = dzero
70 this%wave_flux(j, icell) = dzero
71 end do
72 this%nwaves(icell) = 1
73 end if
74 idelt = 1
75 do ik = 1, idelt
76 call this%uzflow(thick, thickold, delt, ietflag, icell, ierr)
77 if (ierr > 0) return
78 totfluxtot = totfluxtot + this%flux_to_wt(icell)
79 end do
80 end procedure routewaves
81
82 !> @brief Move waves within a cell by shft positions
83 !!
84 !! Waves strt to stp are overwritten by the waves shft positions away.
85 !! cntr is the loop increment; it must run the loop in the direction that
86 !! keeps the source ahead of the destination.
87 !<
88 module procedure shift_waves
89 ! -- local
90 integer(I4B) :: j
91 !
92 do j = strt, stp, cntr
93 this%wave_theta(j, icell) = this%wave_theta(j + shft, icell)
94 this%wave_depth(j, icell) = this%wave_depth(j + shft, icell)
95 this%wave_flux(j, icell) = this%wave_flux(j + shft, icell)
96 this%wave_speed(j, icell) = this%wave_speed(j + shft, icell)
97 end do
98 end procedure shift_waves
99
100 !> @brief Save the wave train of one cell into a snapshot
101 !<
102 module procedure store_waves
103 ! -- local
104 integer(I4B) :: j
105 !
106 do j = 1, this%nwaves(icell)
107 store%theta(j) = this%wave_theta(j, icell)
108 store%depth(j) = this%wave_depth(j, icell)
109 store%flux(j) = this%wave_flux(j, icell)
110 store%speed(j) = this%wave_speed(j, icell)
111 end do
112 store%nwaves = this%nwaves(icell)
113 end procedure store_waves
114
115 !> @brief Restore the wave train of one cell from a snapshot
116 !<
117 module procedure load_waves
118 ! -- local
119 integer(I4B) :: j
120 !
121 do j = 1, store%nwaves
122 this%wave_theta(j, icell) = store%theta(j)
123 this%wave_depth(j, icell) = store%depth(j)
124 this%wave_flux(j, icell) = store%flux(j)
125 this%wave_speed(j, icell) = store%speed(j)
126 end do
127 this%nwaves(icell) = store%nwaves
128 end procedure load_waves
129
130 !> @brief Method of Characteristics solution for kinematic wave equation
131 !<
132 module procedure uzflow
133 ! -- local
134 real(DP) :: dflux_surf, time, eps_thick, eps_flux
135 real(DP) :: thetadif, thetab, fluxb, oldsflx
136 integer(I4B) :: trail_added, single_wave
137 !
138 time = dzero
139 this%flux_to_wt(icell) = dzero
140 trail_added = 0
141 oldsflx = this%wave_flux(this%nwaves(icell), icell)
142 call factors(eps_thick, eps_flux)
143 !
144 ! -- check for falling or rising water table
145 if ((thick - thickold) > eps_thick) then
146 thetadif = abs(this%wave_theta(1, icell) - this%theta_res(icell))
147 if (thetadif > dem6) then
148 call this%shift_waves(icell, -1, &
149 this%nwaves(icell) + 1, 2, -1)
150 if (this%wave_depth(2, icell) < dem30) &
151 this%wave_depth(2, icell) = (this%ntrailwaves + dtwo) * dem6
152 if (this%wave_theta(2, icell) > this%theta_res(icell)) then
153 this%wave_speed(2, icell) = &
154 this%wave_flux(2, icell) / &
155 (this%wave_theta(2, icell) - this%theta_res(icell))
156 else
157 this%wave_speed(2, icell) = dzero
158 end if
159 this%wave_theta(1, icell) = this%theta_res(icell)
160 this%wave_flux(1, icell) = dzero
161 this%wave_speed(1, icell) = dzero
162 this%wave_depth(1, icell) = thick
163 this%nwaves(icell) = this%nwaves(icell) + 1
164 if (this%nwaves(icell) >= this%nwaves_max) then
165 ! -- too many waves error
166 ierr = 1
167 return
168 end if
169 else
170 this%wave_depth(1, icell) = thick
171 end if
172 end if
173 thetab = this%wave_theta(1, icell)
174 fluxb = this%wave_flux(1, icell)
175 this%flux_to_wt(icell) = dzero
176 single_wave = 0
177 dflux_surf = (this%surf_infil(icell) - this%wave_flux(this%nwaves(icell), &
178 icell))
179 !
180 ! -- increase new waves in infiltration changes
181 if (dflux_surf > eps_flux .OR. dflux_surf < -eps_flux) then
182 this%nwaves(icell) = this%nwaves(icell) + 1
183 if (this%nwaves(icell) >= this%nwaves_max) then
184 !
185 ! -- too many waves error
186 ierr = 1
187 return
188 end if
189 else if (this%nwaves(icell) == 1) then
190 single_wave = 1
191 end if
192 if (this%nwaves(icell) > 1) then
193 if (dflux_surf < -eps_flux) then
194 call this%trailwav(icell, ierr)
195 if (ierr > 0) return
196 trail_added = 1
197 end if
198 call this%leadwav(time, single_wave, trail_added, thetab, fluxb, dflux_surf, &
199 eps_flux, delt, icell)
200 end if
201 if (single_wave == 1) then
202 this%flux_to_wt(icell) = this%flux_to_wt(icell) + &
203 (delt - time) * this%wave_flux(1, icell)
204 time = dzero
205 single_wave = 0
206 end if
207 !
208 ! -- simulate et
209 if (ietflag > 0) call this%uzet(icell, delt, ietflag, ierr)
210 if (ierr > 0) return
211 end procedure uzflow
212
213 !> @brief Calculate unit specific tolerances
214 !<
215 module procedure factors
216 ! -- local
217 real(DP) :: factor1
218 real(DP) :: factor2
219 !
220 factor1 = done
221 factor2 = done
222 eps_thick = dem9
223 eps_flux = dem9
224 if (itmuni == 1) then
225 factor1 = done / 86400.d0
226 else if (itmuni == 2) then
227 factor1 = done / 1440.d0
228 else if (itmuni == 3) then
229 factor1 = done / 24.0d0
230 else if (itmuni == 5) then
231 factor1 = 365.0d0
232 end if
233 factor2 = done / 0.3048
234 eps_thick = eps_thick * factor1 * factor2
235 eps_flux = eps_flux * factor1 * factor2
236 end procedure factors
237
238 !> @brief Create and set trail waves
239 !<
240 module procedure trailwav
241 ! -- local
242 real(DP) :: theta_surf, theta_step, ftrail, eps_m1
243 real(DP) :: dtheta_inv
244 real(DP) :: sat
245 real(DP) :: flux1, flux2, theta1, theta2
246 real(DP) :: fnuminc
247 integer(I4B) :: j, jj, jk, nwaves_m1
248 !
249 eps_m1 = dble(this%bc_eps(icell)) - done
250 dtheta_inv = done / (this%theta_sat(icell) - this%theta_res(icell))
251 nwaves_m1 = this%nwaves(icell) - 1
252 !
253 ! -- initialize trailwaves
254 sat = (this%surf_infil(icell) / this%vks(icell))**(done / this%bc_eps(icell))
255 theta_surf = (sat * (this%theta_sat(icell) - this%theta_res(icell))) + &
256 this%theta_res(icell)
257 if (this%wave_theta(nwaves_m1, icell) - theta_surf > dem9) then
258 fnuminc = dzero
259 do jk = 1, this%ntrailwaves
260 fnuminc = fnuminc + float(jk)
261 end do
262 theta_step = (this%wave_theta(nwaves_m1, &
263 icell) - theta_surf) / (fnuminc - done)
264 jj = this%ntrailwaves
265 ftrail = dble(this%ntrailwaves) + done
266 do j = this%nwaves(icell), this%nwaves(icell) + this%ntrailwaves - 1
267 if (j > this%nwaves_max) then
268 ! -- too many waves error
269 ierr = 1
270 return
271 end if
272 if (j > this%nwaves(icell)) then
273 this%wave_theta(j, icell) = this%wave_theta(j - 1, icell) &
274 - ((ftrail - float(jj)) * theta_step)
275 else
276 this%wave_theta(j, icell) = this%wave_theta(j - 1, icell) - dem9
277 end if
278 jj = jj - 1
279 if (this%wave_theta(j, icell) <= this%theta_res(icell) + dem9) &
280 this%wave_theta(j, icell) = this%theta_res(icell) + dem9
281 sat = (this%wave_theta(j, icell) - this%theta_res(icell)) * dtheta_inv
282 this%wave_flux(j, icell) = this%vks(icell) * (sat**this%bc_eps(icell))
283 theta2 = this%wave_theta(j - 1, icell)
284 flux2 = this%wave_flux(j - 1, icell)
285 flux1 = this%wave_flux(j, icell)
286 theta1 = this%wave_theta(j, icell)
287 this%wave_speed(j, icell) = &
288 leadspeed(theta1, theta2, flux1, flux2, this%theta_sat(icell), &
289 this%theta_res(icell), this%bc_eps(icell), this%vks(icell))
290 this%wave_depth(j, icell) = dzero
291 if (j == this%nwaves(icell)) then
292 this%wave_depth(j, icell) = this%wave_depth(j, icell) + &
293 (this%ntrailwaves + 1) * dem9
294 else
295 this%wave_depth(j, icell) = this%wave_depth(j - 1, icell) - dem9
296 end if
297 end do
298 this%nwaves(icell) = this%nwaves(icell) + this%ntrailwaves - 1
299 if (this%nwaves(icell) >= this%nwaves_max) then
300 ! -- too many waves error
301 ierr = 1
302 return
303 end if
304 else
305 this%wave_theta(this%nwaves(icell), icell) = &
306 this%wave_theta(this%nwaves(icell) - 1, icell)
307 this%wave_depth(this%nwaves(icell), icell) = dzero
308 sat = (this%wave_theta(this%nwaves(icell), icell) - &
309 this%theta_res(icell)) * dtheta_inv
310 this%wave_flux(this%nwaves(icell), icell) = &
311 this%vks(icell) * (sat**this%bc_eps(icell))
312 ! -- the water content difference across the new wave is too small
313 ! for a finite difference speed, so use the flux derivative at the
314 ! preceding water content, as in MODFLOW-NWT
315 if (sat < dem30) sat = dzero
316 this%wave_speed(this%nwaves(icell), icell) = &
317 this%bc_eps(icell) * this%vks(icell) * dtheta_inv * (sat**eps_m1)
318 this%wave_theta(this%nwaves(icell), icell) = theta_surf
319 end if
320 end procedure trailwav
321
322 !> @brief Create a lead wave and route over time step
323 !<
324 module procedure leadwav
325 ! -- local
326 real(DP) :: dt_to_bottom, dt_first, fcheck
327 real(DP) :: eps_m1, time_new, bottom, time_left
328 real(DP) :: dtheta_inv, diff, flux_bot_prev
329 real(DP) :: flux1, flux2, theta1, theta2, ftest
330 integer(I4B) :: wave_exited, iremove, j, jmerge
331 integer(I4B) :: nwavp1, j_first
332 !
333 ftest = dzero
334 eps_m1 = dble(this%bc_eps(icell)) - done
335 dtheta_inv = done / (this%theta_sat(icell) - this%theta_res(icell))
336 !
337 ! -- initialize new wave
338 if (trail_added == 0) then
339 if (dflux_surf > eps_flux) then
340 this%wave_flux(this%nwaves(icell), icell) = this%surf_infil(icell)
341 if (this%wave_flux(this%nwaves(icell), icell) < dem30) &
342 this%wave_flux(this%nwaves(icell), icell) = dzero
343 this%wave_theta(this%nwaves(icell), icell) = &
344 (((this%wave_flux(this%nwaves(icell), icell) / this%vks(icell))** &
345 (done / this%bc_eps(icell))) * &
346 (this%theta_sat(icell) - this%theta_res(icell))) + &
347 this%theta_res(icell)
348 theta2 = this%wave_theta(this%nwaves(icell), icell)
349 flux2 = this%wave_flux(this%nwaves(icell), icell)
350 flux1 = this%wave_flux(this%nwaves(icell) - 1, icell)
351 theta1 = this%wave_theta(this%nwaves(icell) - 1, icell)
352 this%wave_speed(this%nwaves(icell), icell) = &
353 leadspeed(theta1, theta2, flux1, flux2, this%theta_sat(icell), &
354 this%theta_res(icell), this%bc_eps(icell), this%vks(icell))
355 this%wave_depth(this%nwaves(icell), icell) = dzero
356 end if
357 end if
358 !
359 ! -- route all waves and interception of waves over times step
360 diff = done
361 time_left = dzero
362 wave_exited = 0
363 flux_bot_prev = this%wave_flux(1, icell)
364 if (this%nwaves(icell) == 0) single_wave = 1
365 if (single_wave /= 1) then
366 do while (diff > dem6)
367 nwavp1 = this%nwaves(icell) + 1
368 time_left = delt - time
369 do j = 1, this%nwaves(icell)
370 this%overtake_time(j) = dep20
371 this%wave_merges(j) = 0
372 end do
373 dt_first = time_left
374 if (this%nwaves(icell) > 2) then
375 j = 2
376 !
377 ! -- calculate time until wave overtakes wave ahead
378 nwavp1 = this%nwaves(icell) + 1
379 do while (j < nwavp1)
380 ftest = this%wave_speed(j - 1, icell) - this%wave_speed(j, icell)
381 if (abs(ftest) > dem30) then
382 this%overtake_time(j) = (this%wave_depth(j, icell) - &
383 this%wave_depth(j - 1, icell)) / ftest
384 if (this%overtake_time(j) < dem30) this%overtake_time(j) = dep20
385 end if
386 j = j + 1
387 end do
388 end if
389 !
390 ! - calc time until wave reaches bottom of cell
391 dt_to_bottom = dep20
392 if (this%nwaves(icell) > 1) then
393 if (this%wave_speed(2, icell) > dzero) then
394 bottom = this%wave_speed(2, icell)
395 if (bottom < dem15) bottom = dem15
396 dt_to_bottom = (this%wave_depth(1, icell) - &
397 this%wave_depth(2, icell)) / bottom
398 if (dt_to_bottom < dzero) dt_to_bottom = dem12
399 end if
400 end if
401 !
402 ! -- calc time for wave interception
403 j_first = 0
404 do j = this%nwaves(icell), 3, -1
405 if (dt_first - this%overtake_time(j) > -dem9) then
406 this%wave_merges(j) = 1
407 j_first = j
408 dt_first = this%overtake_time(j)
409 end if
410 end do
411 do j = 3, this%nwaves(icell)
412 if (dt_first - this%overtake_time(j) < dem9) then
413 if (j /= j_first) this%wave_merges(j) = 0
414 end if
415 end do
416 !
417 ! -- what happens first, waves hits bottom or interception
418 iremove = 0
419 time_new = time
420 fcheck = (time + dt_first) - delt
421 if (dt_first < dem7) fcheck = -done
422 if (dt_to_bottom < dt_first .AND. time + dt_to_bottom < delt) then
423 j = 2
424 do while (j < nwavp1)
425 !
426 ! -- route waves
427 this%wave_depth(j, icell) = this%wave_depth(j, icell) + &
428 this%wave_speed(j, icell) * dt_to_bottom
429 j = j + 1
430 end do
431 fluxb = this%wave_flux(2, icell)
432 thetab = this%wave_theta(2, icell)
433 wave_exited = 1
434 call this%shift_waves(icell, 1, 1, &
435 this%nwaves(icell) - 1, 1)
436 iremove = 1
437 time_new = time + dt_to_bottom
438 this%wave_speed(1, icell) = dzero
439 !
440 ! -- do waves intercept before end of time step
441 else if (fcheck < dzero .AND. this%nwaves(icell) > 2) then
442 j = 2
443 do while (j < nwavp1)
444 this%wave_depth(j, icell) = this%wave_depth(j, icell) + &
445 this%wave_speed(j, icell) * dt_first
446 j = j + 1
447 end do
448 !
449 ! -- combine waves that intercept, remove a wave
450 j = 3
451 jmerge = j
452 do while (j < this%nwaves(icell) + 1)
453 if (this%wave_merges(j) == 1) then
454 jmerge = j
455 theta2 = this%wave_theta(j, icell)
456 flux2 = this%wave_flux(j, icell)
457 if (j == 3) then
458 flux1 = fluxb
459 theta1 = thetab
460 else
461 flux1 = this%wave_flux(j - 2, icell)
462 theta1 = this%wave_theta(j - 2, icell)
463 end if
464 this%wave_speed(j, icell) = &
465 leadspeed(theta1, theta2, flux1, flux2, this%theta_sat(icell), &
466 this%theta_res(icell), this%bc_eps(icell), &
467 this%vks(icell))
468 !
469 ! -- update waves
470 call this%shift_waves(icell, 1, jmerge - 1, &
471 this%nwaves(icell) - 1, 1)
472 jmerge = this%nwaves(icell) + 1
473 iremove = iremove + 1
474 end if
475 j = j + 1
476 end do
477 time_new = time_new + dt_first
478 !
479 ! -- calc. total flux to bottom during remaining time in step
480 else
481 j = 2
482 do while (j < nwavp1)
483 this%wave_depth(j, icell) = this%wave_depth(j, icell) + &
484 this%wave_speed(j, icell) * time_left
485 j = j + 1
486 end do
487 time_new = delt
488 end if
489 this%flux_to_wt(icell) = this%flux_to_wt(icell) + flux_bot_prev &
490 * (time_new - time)
491 if (wave_exited == 1) then
492 flux_bot_prev = this%wave_flux(1, icell)
493 wave_exited = 0
494 end if
495 !
496 ! -- remove dead waves
497 this%nwaves(icell) = this%nwaves(icell) - iremove
498 time = time_new
499 diff = delt - time
500 if (this%nwaves(icell) == 1) then
501 single_wave = 1
502 exit
503 end if
504 end do
505 end if
506 end procedure leadwav
507
508 !> @brief Sums up mobile water over depth interval
509 !<
510 module procedure unsat_stor
511 ! -- local
512 real(DP) :: fm
513 integer(I4B) :: jabove, j, nwaves_m1
514 !
515 fm = dzero
516 jabove = this%nwaves(icell) + 1
517 nwaves_m1 = this%nwaves(icell) - 1
518 if (d1 > this%wave_depth(1, icell)) d1 = this%wave_depth(1, icell)
519 !
520 ! -- jabove is the deepest wave lying above depth d1. Wave depth decreases
521 ! with index, so the first wave that qualifies is the one wanted.
522 do j = 1, this%nwaves(icell)
523 if (this%wave_depth(j, icell) - d1 < -dem30) then
524 jabove = j
525 exit
526 end if
527 end do
528 if (jabove > this%nwaves(icell)) then
529 fm = fm + (this%wave_theta(this%nwaves(icell), &
530 icell) - this%theta_res(icell)) * d1
531 elseif (this%nwaves(icell) > 1) then
532 if (jabove > 1) then
533 fm = fm + (this%wave_theta(jabove - 1, icell) - this%theta_res(icell)) &
534 * (d1 - this%wave_depth(jabove, icell))
535 end if
536 do j = jabove, nwaves_m1
537 fm = fm + (this%wave_theta(j, icell) - this%theta_res(icell)) &
538 * (this%wave_depth(j, icell) &
539 - this%wave_depth(j + 1, icell))
540 end do
541 fm = fm + (this%wave_theta(this%nwaves(icell), icell) - &
542 this%theta_res(icell)) * &
543 this%wave_depth(this%nwaves(icell), icell)
544 else
545 fm = fm + (this%wave_theta(1, icell) - this%theta_res(icell)) * d1
546 end if
547 unsat_stor = fm
548 end procedure unsat_stor
549
550 !> @brief Update to new state of uz at end of time step
551 !<
552 module procedure update_wav
553 ! -- local
554 real(DP) :: bot, depthsave, top
555 real(DP) :: thick, dtheta_inv
556 integer(I4B) :: nwaves_hold, j, jabove
557 !
558 bot = this%water_table(icell)
559 top = this%celtop(icell)
560 thick = top - bot
561 nwaves_hold = this%nwaves(icell)
562 if (itest == 1) then
563 this%wave_flux(1, icell) = dzero
564 this%wave_theta(1, icell) = this%theta_res(icell)
565 return
566 end if
567 if (iss == 1) then
568 if (this%theta_sat(icell) - this%theta_res(icell) < dem7) then
569 dtheta_inv = done / dem7
570 else
571 dtheta_inv = done / (this%theta_sat(icell) - this%theta_res(icell))
572 end if
573 this%flux_to_wt(icell) = this%surf_infil(icell) * delt
574 this%water_table_old(icell) = this%water_table(icell)
575 this%wave_theta(1, icell) = this%theta_init(icell)
576 this%wave_flux(1, icell) = &
577 this%vks(icell) * (((this%wave_theta(1, icell) - this%theta_res(icell)) &
578 * dtheta_inv)**this%bc_eps(icell))
579 this%wave_depth(1, icell) = thick
580 this%wave_speed(1, icell) = thick
581 this%nwaves(icell) = 1
582 else
583 !
584 ! -- water table rises through waves
585 if (this%water_table(icell) - this%water_table_old(icell) > dem30) then
586 depthsave = this%wave_depth(1, icell)
587 jabove = 0
588 do j = 1, this%nwaves(icell)
589 if (this%wave_depth(j, icell) - thick < -dem30) then
590 jabove = j
591 exit
592 end if
593 end do
594 this%wave_depth(1, icell) = thick
595 if (jabove > 1) then
596 this%wave_speed(1, icell) = dzero
597 this%nwaves(icell) = this%nwaves(icell) - jabove + 2
598 this%wave_theta(1, icell) = this%wave_theta(jabove - 1, icell)
599 this%wave_flux(1, icell) = this%wave_flux(jabove - 1, icell)
600 if (jabove > 2) call this%shift_waves(icell, jabove - 2, 2, &
601 nwaves_hold - (jabove - 2), 1)
602 elseif (jabove == 0) then
603 this%wave_speed(1, icell) = dzero
604 this%wave_theta(1, icell) = this%wave_theta(this%nwaves(icell), icell)
605 this%wave_flux(1, icell) = this%wave_flux(this%nwaves(icell), icell)
606 this%nwaves(icell) = 1
607 end if
608 end if
609 !
610 ! -- calculate new unsat. storage
611 if (thick <= dzero) then
612 this%wave_speed(1, icell) = dzero
613 this%nwaves(icell) = 1
614 this%wave_theta(1, icell) = this%theta_res(icell)
615 this%wave_flux(1, icell) = dzero
616 end if
617 this%water_table_old(icell) = this%water_table(icell)
618 end if
619 end procedure update_wav
620
621 !> @brief Calculate recharge due to a rise in the gwf head
622 !<
623 module procedure uz_rise
624 ! -- local
625 real(DP) :: fm1, fm2, d1
626 !
627 if (this%water_table(icell) - this%water_table_old(icell) > dem30) then
628 d1 = this%celtop(icell) - this%water_table_old(icell)
629 fm1 = this%unsat_stor(icell, d1)
630 d1 = this%celtop(icell) - this%water_table(icell)
631 fm2 = this%unsat_stor(icell, d1)
632 totfluxtot = totfluxtot + (fm1 - fm2)
633 end if
634 end procedure uz_rise
635
636 !> @brief Determine the water content at a specific depth
637 !!
638 !! Because UZF-calculated waves are internal to UZF objects, different water
639 !! contents exists at different depths.
640 !<
641 module procedure get_water_content_at_depth
642 ! -- local
643 real(DP) :: d1
644 real(DP) :: d2
645 real(DP) :: f1
646 real(DP) :: f2
647 !
648 if (this%water_table(icell) < this%celtop(icell)) then
649 if (this%celtop(icell) - depth > this%water_table(icell)) then
650 d1 = depth - dem3
651 d2 = depth + dem3
652 f1 = this%unsat_stor(icell, d1)
653 f2 = this%unsat_stor(icell, d2)
654 theta_at_depth = this%theta_res(icell) + (f2 - f1) / (d2 - d1)
655 else
656 theta_at_depth = this%theta_sat(icell)
657 end if
658 else
659 theta_at_depth = this%theta_sat(icell)
660 end if
661 end procedure get_water_content_at_depth
662
663 !> @brief Calculate and return the cell-based water content value
664 !<
665 module procedure get_wcnew
666 ! -- local
667 real(DP) :: top
668 real(DP) :: bot
669 real(DP) :: theta_r
670 real(DP) :: thk
671 real(DP) :: hgwf
672 real(DP) :: fm
673 real(DP) :: d
674 !
675 hgwf = this%water_table(icell)
676 top = this%celtop(icell)
677 bot = this%celbot(icell)
678 thk = top - max(bot, hgwf)
679 if (thk > dzero) then
680 theta_r = this%theta_res(icell)
681 d = thk
682 fm = this%unsat_stor(icell, d)
683 watercontent = fm / thk
684 watercontent = watercontent + theta_r
685 else
686 watercontent = dzero
687 end if
688 end procedure get_wcnew
689
690 !> @brief Calculates waves speed from dflux/dtheta
691 !<
692 module procedure leadspeed
693 ! -- local
694 real(DP) :: comp1, comp2, thsrinv, epsfksths
695 real(DP) :: eps_m1, fhold, comp3
696 !
697 comp1 = theta2 - theta1
698 comp2 = abs(flux2 - flux1)
699 comp3 = theta1 - thtr
700 if (comp2 < dem15) flux2 = flux1 + dem15
701 if (abs(comp1) < dem30) then
702 eps_m1 = eps - done
703 thsrinv = done / (thts - thtr)
704 epsfksths = eps * vks * thsrinv
705 fhold = dem30
706 if (comp3 > dem30) fhold = (comp3 * thsrinv)**eps
707 if (fhold < dem30) fhold = dem30
708 leadspeed = epsfksths * (fhold**eps_m1)
709 else
710 leadspeed = (flux2 - flux1) / (theta2 - theta1)
711 end if
712 if (leadspeed < dem30) leadspeed = dem30
713 end procedure leadspeed
714
715end submodule uzfcellgroupwaves
Unsaturated zone flow by the method of characteristics.