9 module subroutine csub_delay_head_check(this, ib)
11 class(GwfCsubType),
intent(inout) :: this
12 integer(I4B),
intent(in) :: ib
14 integer(I4B) :: iviolate
15 integer(I4B) :: idelay
25 idelay = this%idelay(ib)
26 node = this%nodelist(ib)
29 idelaycells:
do n = 1, this%ndelaycells
30 z = this%dbz(n, idelay)
31 h = this%dbh(n, idelay)
32 dzhalf = dhalf * this%dbdzini(1, idelay)
35 if (this%stoiconv(node) == 0)
then
38 this%idb_nconv_count(1) = this%idb_nconv_count(1) + 1
44 if (iviolate > 0)
then
48 end subroutine csub_delay_head_check
51 module subroutine csub_delay_sln(this, ib, hcell, update)
53 class(GwfCsubType),
intent(inout) :: this
54 integer(I4B),
intent(in) :: ib
55 real(DP),
intent(in) :: hcell
56 logical(LGP),
intent(in),
optional :: update
60 logical(LGP) :: lupdate
64 integer(I4B) :: idelay
68 real(DP),
parameter :: dclose = dhundred * dprec
71 if (
present(update))
then
78 call this%csub_delay_calc_stress(ib, hcell)
81 if (count_errors() > 0)
then
82 call store_error_filename(this%input_fname)
86 if (this%thickini(ib) > dzero)
then
89 idelay = this%idelay(ib)
94 call this%csub_delay_assemble(ib, hcell)
98 this%dbal, this%dbad, this%dbau, &
99 this%dbrhs, this%dbdh, this%dbaw)
103 do n = 1, this%ndelaycells
104 dh = this%dbdh(n) - this%dbh(n, idelay)
105 if (abs(dh) > abs(dhmax))
then
108 this%dbdhmax(idelay) = dhmax
112 this%dbh(n, idelay) = this%dbdh(n)
116 call this%csub_delay_calc_stress(ib, hcell)
119 if (abs(dhmax) < dclose)
then
121 else if (iter /= 1)
then
122 if (abs(dhmax) - abs(dhmax0) < dprec)
then
132 end subroutine csub_delay_sln
135 module subroutine csub_delay_init_zcell(this, ib)
137 class(GwfCsubType),
intent(inout) :: this
138 integer(I4B),
intent(in) :: ib
142 integer(I4B) :: idelay
154 idelay = this%idelay(ib)
155 node = this%nodelist(ib)
156 b = this%thickini(ib)
157 bot = this%dis%bot(node)
163 znode = this%csub_calc_znode(top, bot, hbar)
164 dz = dhalf * this%dbdzini(1, idelay)
171 do n = 1, this%ndelaycells
174 this%dbz(n, idelay) = z
178 if (abs(zr) < dz)
then
181 this%dbrelz(n, idelay) = zr
184 end subroutine csub_delay_init_zcell
187 module subroutine csub_delay_calc_stress(this, ib, hcell)
189 class(GwfCsubType),
intent(inout) :: this
190 integer(I4B),
intent(in) :: ib
191 real(DP),
intent(in) :: hcell
194 integer(I4B) :: idelay
211 idelay = this%idelay(ib)
212 node = this%nodelist(ib)
213 sigma = this%cg_gs(node)
214 topaq = this%dis%top(node)
215 botaq = this%dis%bot(node)
216 dzhalf = dhalf * this%dbdzini(1, idelay)
217 top = this%dbz(1, idelay) + dzhalf
220 hbar = squadratic0sp(hcell, botaq, this%satomega)
225 if (hcell < top)
then
226 sadd = ((top - hbar) * sgm) + ((hbar - botaq) * sgs)
228 sadd = (top - botaq) * sgs
233 do n = 1, this%ndelaycells
234 h = this%dbh(n, idelay)
237 z = this%dbz(n, idelay)
242 hbar = squadratic0sp(h, bot, this%satomega)
246 sadd = ((top - hbar) * sgm) + ((hbar - bot) * sgs)
248 sadd = (top - bot) * sgs
252 this%dbgeo(n, idelay) = sigma
253 this%dbes(n, idelay) = sigma - phead
255 end subroutine csub_delay_calc_stress
258 module subroutine csub_delay_calc_ssksske(this, ib, n, hcell, ssk, sske, &
261 class(GwfCsubType),
intent(inout) :: this
262 integer(I4B),
intent(in) :: ib
263 integer(I4B),
intent(in) :: n
264 real(DP),
intent(in) :: hcell
265 real(DP),
intent(inout) :: ssk
266 real(DP),
intent(inout) :: sske
267 real(DP),
intent(out),
optional :: dsskde
268 real(DP),
intent(out),
optional :: wfac
270 integer(I4B) :: idelay
271 integer(I4B) :: ielastic
298 idelay = this%idelay(ib)
299 ielastic = this%ielastic(ib)
302 if (this%lhead_based .EQV. .true.)
then
308 node = this%nodelist(ib)
309 theta = this%dbthetaini(n, idelay)
312 topcell = this%dis%top(node)
313 botcell = this%dis%bot(node)
316 hbarcell = squadratic0sp(hcell, botcell, this%satomega)
320 zcell = this%csub_calc_znode(topcell, botcell, hbarcell)
323 zcenter = zcell + this%dbrelz(n, idelay)
324 dzhalf = dhalf * this%dbdzini(1, idelay)
325 top = zcenter + dzhalf
326 bot = zcenter - dzhalf
327 h = this%dbh(n, idelay)
330 hbar = squadratic0sp(h, bot, this%satomega)
334 znode = this%csub_calc_znode(top, bot, hbar)
338 zbot = this%dbz(n, idelay) - dzhalf
341 es = this%dbes(n, idelay)
342 es0 = this%dbes0(n, idelay)
347 call this%csub_calc_sfacts(node, zbot, znode, theta, es, es0, &
348 this%dbgeo(n, idelay), f)
350 this%idbconvert(n, idelay) = 0
351 sske = f * this%rci(ib)
352 ssk = f * this%rci(ib)
353 if (
present(dsskde)) dsskde = dzero
357 if (
present(wfac)) wfac = dzero
358 if (ielastic == 0)
then
359 es = this%dbes(n, idelay)
360 pcs = this%dbpcs(n, idelay)
363 if (this%pcsomega > dzero .and. pcs > dzero)
then
366 estop = pcs + this%pcsomega * pcs
367 w = squadraticsaturation(estop, pcs, es)
368 ssk = f * (this%rci(ib) + w * (this%ci(ib) - this%rci(ib)))
369 if (w > dhalf) this%idbconvert(n, idelay) = 1
370 if (
present(wfac)) wfac = w
371 if (
present(dsskde))
then
372 dwde = squadraticsaturationderivative(estop, pcs, es)
373 dsskde = f * (this%ci(ib) - this%rci(ib)) * dwde
378 this%idbconvert(n, idelay) = 1
379 ssk = f * this%ci(ib)
380 if (
present(wfac)) wfac = done
384 end subroutine csub_delay_calc_ssksske
387 module subroutine csub_delay_assemble(this, ib, hcell)
389 class(GwfCsubType),
intent(inout) :: this
390 integer(I4B),
intent(in) :: ib
391 real(DP),
intent(in) :: hcell
400 do n = 1, this%ndelaycells
403 if (this%inewton == 0)
then
404 call this%csub_delay_assemble_fc(ib, n, hcell, aii, au, al, r)
406 call this%csub_delay_assemble_fn(ib, n, hcell, aii, au, al, r)
415 end subroutine csub_delay_assemble
418 module subroutine csub_delay_assemble_fc(this, ib, n, hcell, aii, au, al, r)
422 class(GwfCsubType),
intent(inout) :: this
423 integer(I4B),
intent(in) :: ib
424 integer(I4B),
intent(in) :: n
425 real(DP),
intent(in) :: hcell
426 real(DP),
intent(inout) :: aii
427 real(DP),
intent(inout) :: au
428 real(DP),
intent(inout) :: al
429 real(DP),
intent(inout) :: r
432 integer(I4B) :: idelay
433 integer(I4B) :: ielastic
469 idelay = this%idelay(ib)
470 ielastic = this%ielastic(ib)
471 node = this%nodelist(ib)
472 dzini = this%dbdzini(1, idelay)
473 dzhalf = dhalf * dzini
475 c = this%kv(ib) / dzini
483 if (n == 1 .or. n == this%ndelaycells)
then
494 if (n < this%ndelaycells)
then
499 z = this%dbz(n, idelay)
502 h = this%dbh(n, idelay)
503 h0 = this%dbh0(n, idelay)
504 dz = this%dbdz(n, idelay)
505 dz0 = this%dbdz0(n, idelay)
506 theta = this%dbtheta(n, idelay)
507 theta0 = this%dbtheta0(n, idelay)
510 hbar = squadratic0sp(h, zbot, this%satomega)
513 call this%csub_delay_calc_sat(node, idelay, n, h, h0, dsn, dsn0)
516 call this%csub_delay_calc_ssksske(ib, n, hcell, ssk, sske)
520 gs = this%dbgeo(n, idelay)
521 es0 = this%dbes0(n, idelay)
522 pcs = this%dbpcs(n, idelay)
523 aii = aii - smult * dsn * ssk
524 if (ielastic /= 0)
then
526 (dsn * ssk * (gs + zbot) - dsn0 * sske * es0)
529 (dsn * ssk * (gs + zbot - pcs) + dsn0 * sske * (pcs - es0))
533 r = r + smult * dsn * ssk * (h - hbar)
536 wcf = this%brg * tled
537 wc = dz * wcf * theta
538 wc0 = dz0 * wcf * theta0
540 r = r - dsn0 * wc0 * h0
541 end subroutine csub_delay_assemble_fc
544 module subroutine csub_delay_assemble_fn(this, ib, n, hcell, aii, au, al, r)
548 class(GwfCsubType),
intent(inout) :: this
549 integer(I4B),
intent(in) :: ib
550 integer(I4B),
intent(in) :: n
551 real(DP),
intent(in) :: hcell
552 real(DP),
intent(inout) :: aii
553 real(DP),
intent(inout) :: au
554 real(DP),
intent(inout) :: al
555 real(DP),
intent(inout) :: r
558 integer(I4B) :: idelay
559 integer(I4B) :: ielastic
602 idelay = this%idelay(ib)
603 ielastic = this%ielastic(ib)
604 node = this%nodelist(ib)
605 dzini = this%dbdzini(1, idelay)
606 dzhalf = dhalf * dzini
608 c = this%kv(ib) / dzini
616 if (n == 1 .or. n == this%ndelaycells)
then
627 if (n < this%ndelaycells)
then
632 z = this%dbz(n, idelay)
635 h = this%dbh(n, idelay)
636 h0 = this%dbh0(n, idelay)
637 dz = this%dbdz(n, idelay)
638 dz0 = this%dbdz0(n, idelay)
639 theta = this%dbtheta(n, idelay)
640 theta0 = this%dbtheta0(n, idelay)
643 hbar = squadratic0sp(h, zbot, this%satomega)
646 hbarderv = squadratic0spderivative(h, zbot, this%satomega)
649 call this%csub_delay_calc_sat(node, idelay, n, h, h0, dsn, dsn0)
652 dsnderv = this%csub_delay_calc_sat_derivative(node, idelay, n, hcell)
655 call this%csub_delay_calc_ssksske(ib, n, hcell, ssk, sske, dsskde)
659 gs = this%dbgeo(n, idelay)
660 es0 = this%dbes0(n, idelay)
661 pcs = this%dbpcs(n, idelay)
662 if (ielastic /= 0)
then
663 qsto = smult * (dsn * ssk * (gs - hbar + zbot) - dsn0 * sske * es0)
664 stoderv = -smult * dsn * ssk * hbarderv + &
665 smult * ssk * (gs - hbar + zbot) * dsnderv
667 qsto = smult * (dsn * ssk * (gs - hbar + zbot - pcs) + &
668 dsn0 * sske * (pcs - es0))
669 stoderv = -smult * dsn * ssk * hbarderv + &
670 smult * ssk * (gs - hbar + zbot - pcs) * dsnderv
673 stoderv = stoderv - &
674 smult * dsn * dsskde * hbarderv * (gs - hbar + zbot - pcs)
678 if (this%ieslag /= 0)
then
679 if (ielastic /= 0)
then
680 stoderv = stoderv - smult * sske * es0 * dsnderv
682 stoderv = stoderv + smult * sske * (pcs - es0) * dsnderv
688 r = r - qsto + stoderv * h
691 wcf = this%brg * tled
692 wc = dz * wcf * theta
693 wc0 = dz0 * wcf * theta0
694 qwc = dsn0 * wc0 * h0 - dsn * wc * h
695 wcderv = -dsn * wc - wc * h * dsnderv
698 if (this%ieslag /= 0)
then
699 wcderv = wcderv + wc0 * h0 * dsnderv
704 r = r - qwc + wcderv * h
705 end subroutine csub_delay_assemble_fn
708 module subroutine csub_delay_calc_sat(this, node, idelay, n, hcell, &
709 hcellold, snnew, snold)
711 class(GwfCsubType),
intent(inout) :: this
712 integer(I4B),
intent(in) :: node
713 integer(I4B),
intent(in) :: idelay
714 integer(I4B),
intent(in) :: n
715 real(DP),
intent(in) :: hcell
716 real(DP),
intent(in) :: hcellold
717 real(DP),
intent(inout) :: snnew
718 real(DP),
intent(inout) :: snold
725 if (this%stoiconv(node) /= 0)
then
726 dzhalf = dhalf * this%dbdzini(n, idelay)
727 top = this%dbz(n, idelay) + dzhalf
728 bot = this%dbz(n, idelay) - dzhalf
729 snnew = squadraticsaturation(top, bot, hcell, this%satomega)
730 snold = squadraticsaturation(top, bot, hcellold, this%satomega)
735 if (this%ieslag /= 0)
then
738 end subroutine csub_delay_calc_sat
741 module function csub_delay_calc_sat_derivative(this, node, idelay, n, &
742 hcell) result(satderv)
744 class(GwfCsubType),
intent(inout) :: this
745 integer(I4B),
intent(in) :: node
746 integer(I4B),
intent(in) :: idelay
747 integer(I4B),
intent(in) :: n
748 real(DP),
intent(in) :: hcell
755 if (this%stoiconv(node) /= 0)
then
756 dzhalf = dhalf * this%dbdzini(n, idelay)
757 top = this%dbz(n, idelay) + dzhalf
758 bot = this%dbz(n, idelay) - dzhalf
759 satderv = squadraticsaturationderivative(top, bot, hcell, this%satomega)
763 end function csub_delay_calc_sat_derivative
766 module subroutine csub_delay_calc_dstor(this, ib, hcell, stoe, stoi)
768 class(GwfCsubType),
intent(inout) :: this
769 integer(I4B),
intent(in) :: ib
770 real(DP),
intent(in) :: hcell
771 real(DP),
intent(inout) :: stoe
772 real(DP),
intent(inout) :: stoi
774 integer(I4B) :: idelay
775 integer(I4B) :: ielastic
796 idelay = this%idelay(ib)
797 ielastic = this%ielastic(ib)
798 node = this%nodelist(ib)
805 if (this%thickini(ib) > dzero)
then
806 fmult = this%dbdzini(1, idelay)
807 dzhalf = dhalf * this%dbdzini(1, idelay)
808 do n = 1, this%ndelaycells
809 call this%csub_delay_calc_ssksske(ib, n, hcell, ssk, sske, wfac=wfac)
810 z = this%dbz(n, idelay)
812 h = this%dbh(n, idelay)
813 h0 = this%dbh0(n, idelay)
814 call this%csub_delay_calc_sat(node, idelay, n, h, h0, dsn, dsn0)
815 hbar = squadratic0sp(h, zbot, this%satomega)
816 if (ielastic /= 0)
then
817 v1 = dsn * ssk * (this%dbgeo(n, idelay) - hbar + zbot) - &
818 dsn0 * sske * this%dbes0(n, idelay)
821 v1 = dsn * ssk * (this%dbgeo(n, idelay) - hbar + zbot - &
822 this%dbpcs(n, idelay))
823 v2 = dsn0 * sske * (this%dbpcs(n, idelay) - this%dbes0(n, idelay))
829 stoi = stoi + wfac * v1 * fmult
830 stoe = stoe + ((done - wfac) * v1 + v2) * fmult
833 ske = ske + sske * fmult
834 sk = sk + ssk * fmult
841 end subroutine csub_delay_calc_dstor
844 module subroutine csub_delay_calc_wcomp(this, ib, dwc)
848 class(GwfCsubType),
intent(inout) :: this
849 integer(I4B),
intent(in) :: ib
850 real(DP),
intent(inout) :: dwc
852 integer(I4B) :: idelay
870 if (this%thickini(ib) > dzero)
then
871 idelay = this%idelay(ib)
872 node = this%nodelist(ib)
874 do n = 1, this%ndelaycells
875 h = this%dbh(n, idelay)
876 h0 = this%dbh0(n, idelay)
877 dz = this%dbdz(n, idelay)
878 dz0 = this%dbdz0(n, idelay)
879 call this%csub_delay_calc_sat(node, idelay, n, h, h0, dsn, dsn0)
880 wc = dz * this%brg * this%dbtheta(n, idelay)
881 wc0 = dz0 * this%brg * this%dbtheta0(n, idelay)
882 v = dsn0 * wc0 * h0 - dsn * wc * h
886 end subroutine csub_delay_calc_wcomp
889 module subroutine csub_delay_calc_comp(this, ib, hcell, hcellold, comp, &
892 class(GwfCsubType),
intent(inout) :: this
893 integer(I4B),
intent(in) :: ib
894 real(DP),
intent(in) :: hcell
895 real(DP),
intent(in) :: hcellold
896 real(DP),
intent(inout) :: comp
897 real(DP),
intent(inout) :: compi
898 real(DP),
intent(inout) :: compe
900 integer(I4B) :: idelay
901 integer(I4B) :: ielastic
919 idelay = this%idelay(ib)
920 ielastic = this%ielastic(ib)
921 node = this%nodelist(ib)
927 call this%csub_calc_sat(node, hcell, hcellold, snnew, snold)
930 if (this%thickini(ib) > dzero)
then
931 fmult = this%dbdzini(1, idelay)
932 do n = 1, this%ndelaycells
933 h = this%dbh(n, idelay)
934 h0 = this%dbh0(n, idelay)
935 call this%csub_delay_calc_sat(node, idelay, n, h, h0, dsn, dsn0)
936 call this%csub_delay_calc_ssksske(ib, n, hcell, ssk, sske, wfac=wfac)
937 if (ielastic /= 0)
then
938 v1 = dsn * ssk * this%dbes(n, idelay) - sske * this%dbes0(n, idelay)
941 v1 = dsn * ssk * (this%dbes(n, idelay) - this%dbpcs(n, idelay))
942 v2 = dsn0 * sske * (this%dbpcs(n, idelay) - this%dbes0(n, idelay))
944 v = (v1 + v2) * fmult
948 this%dbcomp(n, idelay) = v * snnew
953 compi = compi + wfac * v1 * fmult
954 compe = compe + ((done - wfac) * v1 + v2) * fmult
959 comp = comp * this%rnb(ib)
960 compi = compi * this%rnb(ib)
961 compe = compe * this%rnb(ib)
962 end subroutine csub_delay_calc_comp
965 module subroutine csub_delay_update(this, ib)
967 class(GwfCsubType),
intent(inout) :: this
968 integer(I4B),
intent(in) :: ib
970 integer(I4B) :: idelay
979 idelay = this%idelay(ib)
985 do n = 1, this%ndelaycells
988 comp = this%dbtcomp(n, idelay) + this%dbcomp(n, idelay)
992 comp = comp / this%rnb(ib)
995 if (abs(comp) > dzero)
then
996 thick = this%dbdzini(n, idelay)
997 theta = this%dbthetaini(n, idelay)
998 call compact_layer(comp, thick, theta)
999 if (thick <= dzero)
then
1000 write (errmsg,
'(2(a,i0),a,g0,a)') &
1001 'Adjusted thickness for delay interbed (', ib, &
1002 ') cell (', n,
') is less than or equal to 0 (', thick,
').'
1003 call store_error(errmsg)
1005 if (theta <= dzero)
then
1006 write (errmsg,
'(2(a,i0),a,g0,a)') &
1007 'Adjusted theta for delay interbed (', ib, &
1008 ') cell (', n,
'is less than or equal to 0 (', theta,
').'
1009 call store_error(errmsg)
1011 this%dbdz(n, idelay) = thick
1012 this%dbtheta(n, idelay) = theta
1013 tthick = tthick + thick
1014 wtheta = wtheta + thick * theta
1016 thick = this%dbdz(n, idelay)
1017 theta = this%dbtheta(n, idelay)
1018 tthick = tthick + thick
1019 wtheta = wtheta + thick * theta
1025 if (tthick > dzero)
then
1026 wtheta = wtheta / tthick
1031 this%thick(ib) = tthick
1032 this%theta(ib) = wtheta
1033 end subroutine csub_delay_update
1036 module subroutine csub_delay_fc(this, ib, hcof, rhs)
1038 class(GwfCsubType),
intent(inout) :: this
1039 integer(I4B),
intent(in) :: ib
1040 real(DP),
intent(inout) :: hcof
1041 real(DP),
intent(inout) :: rhs
1043 integer(I4B) :: idelay
1048 idelay = this%idelay(ib)
1051 if (this%thickini(ib) > dzero)
then
1053 c1 = dtwo * this%kv(ib) / this%dbdzini(1, idelay)
1054 rhs = -c1 * this%dbh(1, idelay)
1056 this%kv(ib) / this%dbdzini(this%ndelaycells, idelay)
1057 rhs = rhs - c2 * this%dbh(this%ndelaycells, idelay)
1060 end subroutine csub_delay_fc
1063 module function csub_calc_delay_flow(this, ib, n, hcell) result(q)
1065 class(GwfCsubType),
intent(inout) :: this
1066 integer(I4B),
intent(in) :: ib
1067 integer(I4B),
intent(in) :: n
1068 real(DP),
intent(in) :: hcell
1071 integer(I4B) :: idelay
1075 idelay = this%idelay(ib)
1076 c = dtwo * this%kv(ib) / this%dbdzini(n, idelay)
1077 q = c * (hcell - this%dbh(n, idelay))
1078 end function csub_calc_delay_flow
1080end submodule gwfcsubmoduledelay
This module contains the CSUB package methods.
subroutine, public solve_tridiagonal(n, tl, td, tu, b, x, w)
Solve a tridiagonal system with the Thomas algorithm.
real(dp), pointer, public delt
length of the current time step