8 module procedure setwaves
10 real(DP) :: bottom, top
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)
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)
37 this%wave_speed(1, icell) = dzero
39 this%wave_flux(1, icell) = dzero
40 this%wave_speed(1, icell) = dzero
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)
50 end procedure setwaves
54 module procedure routewaves
56 real(DP) :: thick, thickold
57 integer(I4B) :: idelt, j, ik
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)
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
72 this%nwaves(icell) = 1
76 call this%uzflow(thick, thickold, delt, ietflag, icell, ierr)
78 totfluxtot = totfluxtot + this%flux_to_wt(icell)
80 end procedure routewaves
88 module procedure shift_waves
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)
98 end procedure shift_waves
102 module procedure store_waves
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)
112 store%nwaves = this%nwaves(icell)
113 end procedure store_waves
117 module procedure load_waves
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)
127 this%nwaves(icell) = store%nwaves
128 end procedure load_waves
132 module procedure uzflow
134 real(DP) :: dflux_surf, time, eps_thick, eps_flux
135 real(DP) :: thetadif, thetab, fluxb, oldsflx
136 integer(I4B) :: trail_added, single_wave
139 this%flux_to_wt(icell) = dzero
141 oldsflx = this%wave_flux(this%nwaves(icell), icell)
142 call factors(eps_thick, eps_flux)
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))
157 this%wave_speed(2, icell) = dzero
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
170 this%wave_depth(1, icell) = thick
173 thetab = this%wave_theta(1, icell)
174 fluxb = this%wave_flux(1, icell)
175 this%flux_to_wt(icell) = dzero
177 dflux_surf = (this%surf_infil(icell) - this%wave_flux(this%nwaves(icell), &
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
189 else if (this%nwaves(icell) == 1)
then
192 if (this%nwaves(icell) > 1)
then
193 if (dflux_surf < -eps_flux)
then
194 call this%trailwav(icell, ierr)
198 call this%leadwav(time, single_wave, trail_added, thetab, fluxb, dflux_surf, &
199 eps_flux, delt, icell)
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)
209 if (ietflag > 0)
call this%uzet(icell, delt, ietflag, ierr)
215 module procedure factors
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
233 factor2 = done / 0.3048
234 eps_thick = eps_thick * factor1 * factor2
235 eps_flux = eps_flux * factor1 * factor2
236 end procedure factors
240 module procedure trailwav
242 real(DP) :: theta_surf, theta_step, ftrail, eps_m1
243 real(DP) :: dtheta_inv
245 real(DP) :: flux1, flux2, theta1, theta2
247 integer(I4B) :: j, jj, jk, nwaves_m1
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
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
259 do jk = 1, this%ntrailwaves
260 fnuminc = fnuminc + float(jk)
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
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)
276 this%wave_theta(j, icell) = this%wave_theta(j - 1, icell) - dem9
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
295 this%wave_depth(j, icell) = this%wave_depth(j - 1, icell) - dem9
298 this%nwaves(icell) = this%nwaves(icell) + this%ntrailwaves - 1
299 if (this%nwaves(icell) >= this%nwaves_max)
then
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))
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
320 end procedure trailwav
324 module procedure leadwav
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
334 eps_m1 = dble(this%bc_eps(icell)) - done
335 dtheta_inv = done / (this%theta_sat(icell) - this%theta_res(icell))
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
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
374 if (this%nwaves(icell) > 2)
then
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
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
404 do j = this%nwaves(icell), 3, -1
405 if (dt_first - this%overtake_time(j) > -dem9)
then
406 this%wave_merges(j) = 1
408 dt_first = this%overtake_time(j)
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
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
424 do while (j < nwavp1)
427 this%wave_depth(j, icell) = this%wave_depth(j, icell) + &
428 this%wave_speed(j, icell) * dt_to_bottom
431 fluxb = this%wave_flux(2, icell)
432 thetab = this%wave_theta(2, icell)
434 call this%shift_waves(icell, 1, 1, &
435 this%nwaves(icell) - 1, 1)
437 time_new = time + dt_to_bottom
438 this%wave_speed(1, icell) = dzero
441 else if (fcheck < dzero .AND. this%nwaves(icell) > 2)
then
443 do while (j < nwavp1)
444 this%wave_depth(j, icell) = this%wave_depth(j, icell) + &
445 this%wave_speed(j, icell) * dt_first
452 do while (j < this%nwaves(icell) + 1)
453 if (this%wave_merges(j) == 1)
then
455 theta2 = this%wave_theta(j, icell)
456 flux2 = this%wave_flux(j, icell)
461 flux1 = this%wave_flux(j - 2, icell)
462 theta1 = this%wave_theta(j - 2, icell)
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), &
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
477 time_new = time_new + dt_first
482 do while (j < nwavp1)
483 this%wave_depth(j, icell) = this%wave_depth(j, icell) + &
484 this%wave_speed(j, icell) * time_left
489 this%flux_to_wt(icell) = this%flux_to_wt(icell) + flux_bot_prev &
491 if (wave_exited == 1)
then
492 flux_bot_prev = this%wave_flux(1, icell)
497 this%nwaves(icell) = this%nwaves(icell) - iremove
500 if (this%nwaves(icell) == 1)
then
506 end procedure leadwav
510 module procedure unsat_stor
513 integer(I4B) :: jabove, j, nwaves_m1
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)
522 do j = 1, this%nwaves(icell)
523 if (this%wave_depth(j, icell) - d1 < -dem30)
then
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
533 fm = fm + (this%wave_theta(jabove - 1, icell) - this%theta_res(icell)) &
534 * (d1 - this%wave_depth(jabove, icell))
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))
541 fm = fm + (this%wave_theta(this%nwaves(icell), icell) - &
542 this%theta_res(icell)) * &
543 this%wave_depth(this%nwaves(icell), icell)
545 fm = fm + (this%wave_theta(1, icell) - this%theta_res(icell)) * d1
548 end procedure unsat_stor
552 module procedure update_wav
554 real(DP) :: bot, depthsave, top
555 real(DP) :: thick, dtheta_inv
556 integer(I4B) :: nwaves_hold, j, jabove
558 bot = this%water_table(icell)
559 top = this%celtop(icell)
561 nwaves_hold = this%nwaves(icell)
563 this%wave_flux(1, icell) = dzero
564 this%wave_theta(1, icell) = this%theta_res(icell)
568 if (this%theta_sat(icell) - this%theta_res(icell) < dem7)
then
569 dtheta_inv = done / dem7
571 dtheta_inv = done / (this%theta_sat(icell) - this%theta_res(icell))
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
585 if (this%water_table(icell) - this%water_table_old(icell) > dem30)
then
586 depthsave = this%wave_depth(1, icell)
588 do j = 1, this%nwaves(icell)
589 if (this%wave_depth(j, icell) - thick < -dem30)
then
594 this%wave_depth(1, icell) = thick
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
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
617 this%water_table_old(icell) = this%water_table(icell)
619 end procedure update_wav
623 module procedure uz_rise
625 real(DP) :: fm1, fm2, d1
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)
634 end procedure uz_rise
641 module procedure get_water_content_at_depth
648 if (this%water_table(icell) < this%celtop(icell))
then
649 if (this%celtop(icell) - depth > this%water_table(icell))
then
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)
656 theta_at_depth = this%theta_sat(icell)
659 theta_at_depth = this%theta_sat(icell)
661 end procedure get_water_content_at_depth
665 module procedure get_wcnew
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)
682 fm = this%unsat_stor(icell, d)
683 watercontent = fm / thk
684 watercontent = watercontent + theta_r
688 end procedure get_wcnew
692 module procedure leadspeed
694 real(DP) :: comp1, comp2, thsrinv, epsfksths
695 real(DP) :: eps_m1, fhold, comp3
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
703 thsrinv = done / (thts - thtr)
704 epsfksths = eps * vks * thsrinv
706 if (comp3 > dem30) fhold = (comp3 * thsrinv)**eps
707 if (fhold < dem30) fhold = dem30
708 leadspeed = epsfksths * (fhold**eps_m1)
710 leadspeed = (flux2 - flux1) / (theta2 - theta1)
712 if (leadspeed < dem30) leadspeed = dem30
713 end procedure leadspeed
715end submodule uzfcellgroupwaves
Unsaturated zone flow by the method of characteristics.