MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
gwf-csub-delay.f90
Go to the documentation of this file.
1!> @brief CSUB package delay interbeds
2!<
3submodule(gwfcsubmodule) gwfcsubmoduledelay
5
6contains
7
8 ! -- documented on the GwfCsubType type-bound procedure in gwf-csub.f90
9 module subroutine csub_delay_head_check(this, ib)
10 ! -- dummy variables
11 class(GwfCsubType), intent(inout) :: this
12 integer(I4B), intent(in) :: ib !< interbed number
13 ! -- local variables
14 integer(I4B) :: iviolate
15 integer(I4B) :: idelay
16 integer(I4B) :: node
17 integer(I4B) :: n
18 real(DP) :: z
19 real(DP) :: h
20 real(DP) :: dzhalf
21 real(DP) :: ztop
22 !
23 ! -- initialize variables
24 iviolate = 0
25 idelay = this%idelay(ib)
26 node = this%nodelist(ib)
27 !
28 ! -- evaluate every delay cell
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)
33 !
34 ! -- non-convertible cell
35 if (this%stoiconv(node) == 0) then
36 ztop = z + dzhalf
37 if (h < ztop) then
38 this%idb_nconv_count(1) = this%idb_nconv_count(1) + 1
39 iviolate = 1
40 end if
41 end if
42 !
43 ! -- terminate the loop
44 if (iviolate > 0) then
45 exit idelaycells
46 end if
47 end do idelaycells
48 end subroutine csub_delay_head_check
49
50 ! -- documented on the GwfCsubType type-bound procedure in gwf-csub.f90
51 module subroutine csub_delay_sln(this, ib, hcell, update)
52 ! -- dummy variables
53 class(GwfCsubType), intent(inout) :: this
54 integer(I4B), intent(in) :: ib !< interbed number
55 real(DP), intent(in) :: hcell !< current head in a cell
56 logical(LGP), intent(in), optional :: update !< optional logical variable indicating
57 !! if the maximum head change variable
58 !! in a delay bed should be updated
59 ! -- local variables
60 logical(LGP) :: lupdate
61 integer(I4B) :: n
62 integer(I4B) :: icnvg
63 integer(I4B) :: iter
64 integer(I4B) :: idelay
65 real(DP) :: dh
66 real(DP) :: dhmax
67 real(DP) :: dhmax0
68 real(DP), parameter :: dclose = dhundred * dprec
69 !
70 ! -- initialize variables
71 if (present(update)) then
72 lupdate = update
73 else
74 lupdate = .true.
75 end if
76 !
77 ! -- calculate geostatic and effective stress for each delay bed cell
78 call this%csub_delay_calc_stress(ib, hcell)
79 !
80 ! -- terminate if the aquifer head is below the top of delay interbeds
81 if (count_errors() > 0) then
82 call store_error_filename(this%input_fname)
83 end if
84 !
85 ! -- solve for delay bed heads
86 if (this%thickini(ib) > dzero) then
87 icnvg = 0
88 iter = 0
89 idelay = this%idelay(ib)
90 do
91 iter = iter + 1
92 !
93 ! -- assemble coefficients
94 call this%csub_delay_assemble(ib, hcell)
95 !
96 ! -- solve for head change in delay interbed cells
97 call solve_tridiagonal(this%ndelaycells, &
98 this%dbal, this%dbad, this%dbau, &
99 this%dbrhs, this%dbdh, this%dbaw)
100 !
101 ! -- calculate maximum head change and update delay bed heads
102 dhmax = dzero
103 do n = 1, this%ndelaycells
104 dh = this%dbdh(n) - this%dbh(n, idelay)
105 if (abs(dh) > abs(dhmax)) then
106 dhmax = dh
107 if (lupdate) then
108 this%dbdhmax(idelay) = dhmax
109 end if
110 end if
111 ! -- update delay bed heads
112 this%dbh(n, idelay) = this%dbdh(n)
113 end do
114 !
115 ! -- update delay bed stresses
116 call this%csub_delay_calc_stress(ib, hcell)
117 !
118 ! -- check delay bed convergence
119 if (abs(dhmax) < dclose) then
120 icnvg = 1
121 else if (iter /= 1) then
122 if (abs(dhmax) - abs(dhmax0) < dprec) then
123 icnvg = 1
124 end if
125 end if
126 if (icnvg == 1) then
127 exit
128 end if
129 dhmax0 = dhmax
130 end do
131 end if
132 end subroutine csub_delay_sln
133
134 ! -- documented on the GwfCsubType type-bound procedure in gwf-csub.f90
135 module subroutine csub_delay_init_zcell(this, ib)
136 ! -- dummy variables
137 class(GwfCsubType), intent(inout) :: this
138 integer(I4B), intent(in) :: ib !< interbed number
139 ! -- local variables
140 integer(I4B) :: n
141 integer(I4B) :: node
142 integer(I4B) :: idelay
143 real(DP) :: bot
144 real(DP) :: top
145 real(DP) :: hbar
146 real(DP) :: znode
147 real(DP) :: dzz
148 real(DP) :: z
149 real(DP) :: zr
150 real(DP) :: b
151 real(DP) :: dz
152 !
153 ! -- initialize variables
154 idelay = this%idelay(ib)
155 node = this%nodelist(ib)
156 b = this%thickini(ib)
157 bot = this%dis%bot(node)
158 top = bot + b
159 hbar = top
160 !
161 ! -- calculate znode based on assumption that the delay bed bottom
162 ! is equal to the cell bottom
163 znode = this%csub_calc_znode(top, bot, hbar)
164 dz = dhalf * this%dbdzini(1, idelay)
165 dzz = dhalf * b
166 z = znode + dzz
167 zr = dzz
168 !
169 ! -- calculate z and z relative to znode for each delay
170 ! interbed node
171 do n = 1, this%ndelaycells
172 ! z of node relative to bottom of cell
173 z = z - dz
174 this%dbz(n, idelay) = z
175 z = z - dz
176 ! z relative to znode
177 zr = zr - dz
178 if (abs(zr) < dz) then
179 zr = dzero
180 end if
181 this%dbrelz(n, idelay) = zr
182 zr = zr - dz
183 end do
184 end subroutine csub_delay_init_zcell
185
186 ! -- documented on the GwfCsubType type-bound procedure in gwf-csub.f90
187 module subroutine csub_delay_calc_stress(this, ib, hcell)
188 ! -- dummy variables
189 class(GwfCsubType), intent(inout) :: this
190 integer(I4B), intent(in) :: ib !< interbed number
191 real(DP), intent(in) :: hcell !< current head in a cell
192 ! -- local variables
193 integer(I4B) :: n
194 integer(I4B) :: idelay
195 integer(I4B) :: node
196 real(DP) :: sigma
197 real(DP) :: topaq
198 real(DP) :: botaq
199 real(DP) :: dzhalf
200 real(DP) :: sadd
201 real(DP) :: sgm
202 real(DP) :: sgs
203 real(DP) :: h
204 real(DP) :: hbar
205 real(DP) :: z
206 real(DP) :: top
207 real(DP) :: bot
208 real(DP) :: phead
209 !
210 ! -- initialize variables
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
218 !
219 ! -- calculate corrected head (hbar)
220 hbar = squadratic0sp(hcell, botaq, this%satomega)
221 !
222 ! -- calculate the geostatic load in the cell at the top of the interbed.
223 sgm = this%sgm(node)
224 sgs = this%sgs(node)
225 if (hcell < top) then
226 sadd = ((top - hbar) * sgm) + ((hbar - botaq) * sgs)
227 else
228 sadd = (top - botaq) * sgs
229 end if
230 sigma = sigma - sadd
231 !
232 ! -- calculate geostatic and effective stress for each interbed node.
233 do n = 1, this%ndelaycells
234 h = this%dbh(n, idelay)
235 !
236 ! -- geostatic calculated at the bottom of the delay cell
237 z = this%dbz(n, idelay)
238 top = z + dzhalf
239 bot = z - dzhalf
240 !
241 ! -- calculate corrected head (hbar)
242 hbar = squadratic0sp(h, bot, this%satomega)
243 !
244 ! -- geostatic stress calculation
245 if (h < top) then
246 sadd = ((top - hbar) * sgm) + ((hbar - bot) * sgs)
247 else
248 sadd = (top - bot) * sgs
249 end if
250 sigma = sigma + sadd
251 phead = hbar - bot
252 this%dbgeo(n, idelay) = sigma
253 this%dbes(n, idelay) = sigma - phead
254 end do
255 end subroutine csub_delay_calc_stress
256
257 ! -- documented on the GwfCsubType type-bound procedure in gwf-csub.f90
258 module subroutine csub_delay_calc_ssksske(this, ib, n, hcell, ssk, sske, &
259 dsskde, wfac)
260 ! -- dummy variables
261 class(GwfCsubType), intent(inout) :: this
262 integer(I4B), intent(in) :: ib !< interbed number
263 integer(I4B), intent(in) :: n !< delay interbed cell number
264 real(DP), intent(in) :: hcell !< current head in a cell
265 real(DP), intent(inout) :: ssk !< delay interbed skeletal specific storage
266 real(DP), intent(inout) :: sske !< delay interbed elastic skeletal specific storage
267 real(DP), intent(out), optional :: dsskde !< d(ssk)/d(effective stress)
268 real(DP), intent(out), optional :: wfac !< inelastic weight (0 elastic, 1 inelastic) for the budget split
269 ! -- local variables
270 integer(I4B) :: idelay
271 integer(I4B) :: ielastic
272 integer(I4B) :: node
273 real(DP) :: topcell
274 real(DP) :: botcell
275 real(DP) :: hbarcell
276 real(DP) :: zcell
277 real(DP) :: zcenter
278 real(DP) :: dzhalf
279 real(DP) :: top
280 real(DP) :: bot
281 real(DP) :: h
282 real(DP) :: hbar
283 real(DP) :: znode
284 real(DP) :: zbot
285 real(DP) :: es
286 real(DP) :: es0
287 real(DP) :: theta
288 real(DP) :: f
289 real(DP) :: f0
290 real(DP) :: pcs
291 real(DP) :: estop
292 real(DP) :: w
293 real(DP) :: dwde
294 !
295 ! -- initialize variables
296 sske = dzero
297 ssk = dzero
298 idelay = this%idelay(ib)
299 ielastic = this%ielastic(ib)
300 !
301 ! -- calculate factor for the head-based case
302 if (this%lhead_based .EQV. .true.) then
303 f = done
304 f0 = f
305 !
306 ! -- calculate factor for the effective stress case
307 else
308 node = this%nodelist(ib)
309 theta = this%dbthetaini(n, idelay)
310 !
311 ! -- set top and bottom of layer
312 topcell = this%dis%top(node)
313 botcell = this%dis%bot(node)
314 !
315 ! -- calculate corrected head for the cell (hbarcell)
316 hbarcell = squadratic0sp(hcell, botcell, this%satomega)
317 !
318 ! -- set location of delay node relative to the center
319 ! of the cell based on current head
320 zcell = this%csub_calc_znode(topcell, botcell, hbarcell)
321 !
322 ! -- set variables for delay interbed zcell calculations
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)
328 !
329 ! -- calculate corrected head for the delay interbed cell (hbar)
330 hbar = squadratic0sp(h, bot, this%satomega)
331 !
332 ! -- calculate the center of the saturated portion of the
333 ! delay interbed cell
334 znode = this%csub_calc_znode(top, bot, hbar)
335 !
336 ! -- set reference point for bottom of delay interbed cell that is used to
337 ! scale the effective stress at the bottom of the delay interbed cell
338 zbot = this%dbz(n, idelay) - dzhalf
339 !
340 ! -- set the effective stress
341 es = this%dbes(n, idelay)
342 es0 = this%dbes0(n, idelay)
343 !
344 ! -- calculate the compression index factors for the delay
345 ! node relative to the center of the cell based on the
346 ! current and previous head
347 call this%csub_calc_sfacts(node, zbot, znode, theta, es, es0, &
348 this%dbgeo(n, idelay), f)
349 end if
350 this%idbconvert(n, idelay) = 0
351 sske = f * this%rci(ib)
352 ssk = f * this%rci(ib)
353 if (present(dsskde)) dsskde = dzero
354 ! -- wfac is the inelastic fraction of the storage change used to split the
355 ! reported elastic/inelastic budget; 0 while elastic, 1 once inelastic,
356 ! and equal to the smoothing weight w across the transition window
357 if (present(wfac)) wfac = dzero
358 if (ielastic == 0) then
359 es = this%dbes(n, idelay)
360 pcs = this%dbpcs(n, idelay)
361 ! -- require pcs > DZERO so the smoothing window (pcsomega * pcs) is
362 ! positive, as sQuadraticSaturation and its derivative need
363 if (this%pcsomega > dzero .and. pcs > dzero) then
364 ! -- blend elastic (rci) -> inelastic (ci) skeletal storage over a
365 ! window of pcsomega * pcs above pcs; w runs 0 (elastic) to 1 (inelastic)
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
374 end if
375 else
376 ! -- original hard elastic<->inelastic switch
377 if (es > pcs) then
378 this%idbconvert(n, idelay) = 1
379 ssk = f * this%ci(ib)
380 if (present(wfac)) wfac = done
381 end if
382 end if
383 end if
384 end subroutine csub_delay_calc_ssksske
385
386 ! -- documented on the GwfCsubType type-bound procedure in gwf-csub.f90
387 module subroutine csub_delay_assemble(this, ib, hcell)
388 ! -- dummy variables
389 class(GwfCsubType), intent(inout) :: this
390 integer(I4B), intent(in) :: ib !< interbed number
391 real(DP), intent(in) :: hcell !< current head in a cell
392 ! -- local variables
393 integer(I4B) :: n
394 real(DP) :: aii
395 real(DP) :: au
396 real(DP) :: al
397 real(DP) :: r
398 !
399 ! -- calculate matrix terms for each delay bed cell
400 do n = 1, this%ndelaycells
401 !
402 ! -- assemble terms
403 if (this%inewton == 0) then
404 call this%csub_delay_assemble_fc(ib, n, hcell, aii, au, al, r)
405 else
406 call this%csub_delay_assemble_fn(ib, n, hcell, aii, au, al, r)
407 end if
408 !
409 ! -- add terms
410 this%dbal(n) = al
411 this%dbau(n) = au
412 this%dbad(n) = aii
413 this%dbrhs(n) = r
414 end do
415 end subroutine csub_delay_assemble
416
417 ! -- documented on the GwfCsubType type-bound procedure in gwf-csub.f90
418 module subroutine csub_delay_assemble_fc(this, ib, n, hcell, aii, au, al, r)
419 ! -- modules
420 use tdismodule, only: delt
421 ! -- dummy variables
422 class(GwfCsubType), intent(inout) :: this
423 integer(I4B), intent(in) :: ib !< interbed number
424 integer(I4B), intent(in) :: n !< delay interbed cell number
425 real(DP), intent(in) :: hcell !< current head in a cell
426 real(DP), intent(inout) :: aii !< diagonal in the A matrix
427 real(DP), intent(inout) :: au !< upper term in the A matrix
428 real(DP), intent(inout) :: al !< lower term in the A matrix
429 real(DP), intent(inout) :: r !< right-hand side term
430 ! -- local variables
431 integer(I4B) :: node
432 integer(I4B) :: idelay
433 integer(I4B) :: ielastic
434 real(DP) :: dzini
435 real(DP) :: dzhalf
436 real(DP) :: c
437 real(DP) :: c2
438 real(DP) :: c3
439 real(DP) :: tled
440 real(DP) :: wcf
441 real(DP) :: smult
442 real(DP) :: sske
443 real(DP) :: ssk
444 real(DP) :: z
445 real(DP) :: ztop
446 real(DP) :: zbot
447 real(DP) :: dz
448 real(DP) :: dz0
449 real(DP) :: theta
450 real(DP) :: theta0
451 real(DP) :: dsn
452 real(DP) :: dsn0
453 real(DP) :: gs
454 real(DP) :: es0
455 real(DP) :: pcs
456 real(DP) :: wc
457 real(DP) :: wc0
458 real(DP) :: h
459 real(DP) :: h0
460 real(DP) :: hbar
461 !
462 ! -- initialize accumulators
463 aii = dzero
464 au = dzero
465 al = dzero
466 r = dzero
467 !
468 ! -- initialize local variables
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
474 tled = done / delt
475 c = this%kv(ib) / dzini
476 c2 = dtwo * c
477 c3 = dthree * c
478 !
479 ! -- add qdb terms
480 aii = aii - c2
481 !
482 ! -- top or bottom cell
483 if (n == 1 .or. n == this%ndelaycells) then
484 aii = aii - c
485 r = r - c2 * hcell
486 end if
487 !
488 ! -- lower qdb term
489 if (n > 1) then
490 al = c
491 end if
492 !
493 ! -- upper qdb term
494 if (n < this%ndelaycells) then
495 au = c
496 end if
497 !
498 ! -- current and previous delay cell states
499 z = this%dbz(n, idelay)
500 ztop = z + dzhalf
501 zbot = z - dzhalf
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)
508 !
509 ! -- calculate corrected head (hbar)
510 hbar = squadratic0sp(h, zbot, this%satomega)
511 !
512 ! -- calculate saturation
513 call this%csub_delay_calc_sat(node, idelay, n, h, h0, dsn, dsn0)
514 !
515 ! -- calculate ssk and sske
516 call this%csub_delay_calc_ssksske(ib, n, hcell, ssk, sske)
517 !
518 ! -- calculate and add storage terms
519 smult = dzini * tled
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
525 r = r - smult * &
526 (dsn * ssk * (gs + zbot) - dsn0 * sske * es0)
527 else
528 r = r - smult * &
529 (dsn * ssk * (gs + zbot - pcs) + dsn0 * sske * (pcs - es0))
530 end if
531 !
532 ! -- add storage correction term
533 r = r + smult * dsn * ssk * (h - hbar)
534 !
535 ! -- add water compressibility terms
536 wcf = this%brg * tled
537 wc = dz * wcf * theta
538 wc0 = dz0 * wcf * theta0
539 aii = aii - dsn * wc
540 r = r - dsn0 * wc0 * h0
541 end subroutine csub_delay_assemble_fc
542
543 ! -- documented on the GwfCsubType type-bound procedure in gwf-csub.f90
544 module subroutine csub_delay_assemble_fn(this, ib, n, hcell, aii, au, al, r)
545 ! -- modules
546 use tdismodule, only: delt
547 ! -- dummy variables
548 class(GwfCsubType), intent(inout) :: this
549 integer(I4B), intent(in) :: ib !< interbed number
550 integer(I4B), intent(in) :: n !< delay interbed cell number
551 real(DP), intent(in) :: hcell !< current head in a cell
552 real(DP), intent(inout) :: aii !< diagonal in the A matrix
553 real(DP), intent(inout) :: au !< upper term in the A matrix
554 real(DP), intent(inout) :: al !< lower term in the A matrix
555 real(DP), intent(inout) :: r !< right-hand side term
556 ! -- local variables
557 integer(I4B) :: node
558 integer(I4B) :: idelay
559 integer(I4B) :: ielastic
560 real(DP) :: dzini
561 real(DP) :: dzhalf
562 real(DP) :: c
563 real(DP) :: c2
564 real(DP) :: c3
565 real(DP) :: tled
566 real(DP) :: wcf
567 real(DP) :: smult
568 real(DP) :: sske
569 real(DP) :: ssk
570 real(DP) :: z
571 real(DP) :: ztop
572 real(DP) :: zbot
573 real(DP) :: dz
574 real(DP) :: dz0
575 real(DP) :: theta
576 real(DP) :: theta0
577 real(DP) :: dsn
578 real(DP) :: dsn0
579 real(DP) :: dsnderv
580 real(DP) :: wc
581 real(DP) :: wc0
582 real(DP) :: h
583 real(DP) :: h0
584 real(DP) :: hbar
585 real(DP) :: hbarderv
586 real(DP) :: gs
587 real(DP) :: es0
588 real(DP) :: pcs
589 real(DP) :: qsto
590 real(DP) :: stoderv
591 real(DP) :: dsskde
592 real(DP) :: qwc
593 real(DP) :: wcderv
594 !
595 ! -- initialize accumulators
596 aii = dzero
597 au = dzero
598 al = dzero
599 r = dzero
600 !
601 ! -- initialize local variables
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
607 tled = done / delt
608 c = this%kv(ib) / dzini
609 c2 = dtwo * c
610 c3 = dthree * c
611 !
612 ! -- add qdb terms
613 aii = aii - c2
614 !
615 ! -- top or bottom cell
616 if (n == 1 .or. n == this%ndelaycells) then
617 aii = aii - c
618 r = r - c2 * hcell
619 end if
620 !
621 ! -- lower qdb term
622 if (n > 1) then
623 al = c
624 end if
625 !
626 ! -- upper qdb term
627 if (n < this%ndelaycells) then
628 au = c
629 end if
630 !
631 ! -- current and previous delay cell states
632 z = this%dbz(n, idelay)
633 ztop = z + dzhalf
634 zbot = z - dzhalf
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)
641 !
642 ! -- calculate corrected head (hbar)
643 hbar = squadratic0sp(h, zbot, this%satomega)
644 !
645 ! -- calculate the derivative of the hbar functions
646 hbarderv = squadratic0spderivative(h, zbot, this%satomega)
647 !
648 ! -- calculate saturation
649 call this%csub_delay_calc_sat(node, idelay, n, h, h0, dsn, dsn0)
650 !
651 ! -- calculate the derivative of the saturation
652 dsnderv = this%csub_delay_calc_sat_derivative(node, idelay, n, hcell)
653 !
654 ! -- calculate ssk, sske, and the smoothing derivative dsskde
655 call this%csub_delay_calc_ssksske(ib, n, hcell, ssk, sske, dsskde)
656 !
657 ! -- calculate storage terms
658 smult = dzini * tled
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
666 else
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
671 ! -- derivative of ssk through the smoothed preconsolidation switch.
672 ! es = gs - hbar + zbot => d(es)/d(h) = -hbarderv
673 stoderv = stoderv - &
674 smult * dsn * dsskde * hbarderv * (gs - hbar + zbot - pcs)
675 end if
676 !
677 ! -- Add additional term if using lagged effective stress
678 if (this%ieslag /= 0) then
679 if (ielastic /= 0) then
680 stoderv = stoderv - smult * sske * es0 * dsnderv
681 else
682 stoderv = stoderv + smult * sske * (pcs - es0) * dsnderv
683 end if
684 end if
685 !
686 ! -- add newton-raphson storage terms
687 aii = aii + stoderv
688 r = r - qsto + stoderv * h
689 !
690 ! -- add water compressibility terms
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
696 !
697 ! -- Add additional term if using lagged effective stress
698 if (this%ieslag /= 0) then
699 wcderv = wcderv + wc0 * h0 * dsnderv
700 end if
701 !
702 ! -- add newton-raphson water compressibility terms
703 aii = aii + wcderv
704 r = r - qwc + wcderv * h
705 end subroutine csub_delay_assemble_fn
706
707 ! -- documented on the GwfCsubType type-bound procedure in gwf-csub.f90
708 module subroutine csub_delay_calc_sat(this, node, idelay, n, hcell, &
709 hcellold, snnew, snold)
710 ! -- dummy variables
711 class(GwfCsubType), intent(inout) :: this
712 integer(I4B), intent(in) :: node !< cell node number
713 integer(I4B), intent(in) :: idelay !< delay interbed number
714 integer(I4B), intent(in) :: n !< delay interbed cell number
715 real(DP), intent(in) :: hcell !< current head in delay interbed cell n
716 real(DP), intent(in) :: hcellold !< previous head in delay interbed cell n
717 real(DP), intent(inout) :: snnew !< current saturation in delay interbed cell n
718 real(DP), intent(inout) :: snold !< previous saturation in delay interbed cell n
719 ! -- local variables
720 real(DP) :: dzhalf
721 real(DP) :: top
722 real(DP) :: bot
723 !
724 ! -- calculate delay interbed cell saturation
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)
731 else
732 snnew = done
733 snold = done
734 end if
735 if (this%ieslag /= 0) then
736 snold = snnew
737 end if
738 end subroutine csub_delay_calc_sat
739
740 ! -- documented on the GwfCsubType type-bound procedure in gwf-csub.f90
741 module function csub_delay_calc_sat_derivative(this, node, idelay, n, &
742 hcell) result(satderv)
743 ! -- dummy variables
744 class(GwfCsubType), intent(inout) :: this
745 integer(I4B), intent(in) :: node !< cell node number
746 integer(I4B), intent(in) :: idelay !< delay interbed number
747 integer(I4B), intent(in) :: n !< delay interbed cell number
748 real(DP), intent(in) :: hcell !< current head in delay interbed cell n
749 real(DP) :: satderv
750 ! -- local variables
751 real(DP) :: dzhalf
752 real(DP) :: top
753 real(DP) :: bot
754
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)
760 else
761 satderv = dzero
762 end if
763 end function csub_delay_calc_sat_derivative
764
765 ! -- documented on the GwfCsubType type-bound procedure in gwf-csub.f90
766 module subroutine csub_delay_calc_dstor(this, ib, hcell, stoe, stoi)
767 ! -- dummy variables
768 class(GwfCsubType), intent(inout) :: this
769 integer(I4B), intent(in) :: ib !< interbed number
770 real(DP), intent(in) :: hcell !< current head in cell
771 real(DP), intent(inout) :: stoe !< current elastic storage change in delay interbed
772 real(DP), intent(inout) :: stoi !< current inelastic storage change in delay interbed
773 ! -- local variables
774 integer(I4B) :: idelay
775 integer(I4B) :: ielastic
776 integer(I4B) :: node
777 integer(I4B) :: n
778 real(DP) :: sske
779 real(DP) :: ssk
780 real(DP) :: wfac
781 real(DP) :: fmult
782 real(DP) :: v1
783 real(DP) :: v2
784 real(DP) :: ske
785 real(DP) :: sk
786 real(DP) :: z
787 real(DP) :: zbot
788 real(DP) :: h
789 real(DP) :: h0
790 real(DP) :: dsn
791 real(DP) :: dsn0
792 real(DP) :: hbar
793 real(DP) :: dzhalf
794 !
795 ! -- initialize variables
796 idelay = this%idelay(ib)
797 ielastic = this%ielastic(ib)
798 node = this%nodelist(ib)
799 stoe = dzero
800 stoi = dzero
801 ske = dzero
802 sk = dzero
803 !
804 !
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)
811 zbot = z - dzhalf
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)
819 v2 = dzero
820 else
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))
824 end if
825 !
826 ! -- split the storage change into inelastic and elastic components
827 ! weighted by wfac so the reported budget blends across the smoothed
828 ! transition; wfac is 0/1 for the hard switch, reproducing the split
829 stoi = stoi + wfac * v1 * fmult
830 stoe = stoe + ((done - wfac) * v1 + v2) * fmult
831 !
832 ! calculate inelastic and elastic storativity
833 ske = ske + sske * fmult
834 sk = sk + ssk * fmult
835 end do
836 end if
837 !
838 ! -- save ske and sk
839 this%ske(ib) = ske
840 this%sk(ib) = sk
841 end subroutine csub_delay_calc_dstor
842
843 ! -- documented on the GwfCsubType type-bound procedure in gwf-csub.f90
844 module subroutine csub_delay_calc_wcomp(this, ib, dwc)
845 ! -- modules
846 use tdismodule, only: delt
847 ! -- dummy variables
848 class(GwfCsubType), intent(inout) :: this
849 integer(I4B), intent(in) :: ib !< interbed number
850 real(DP), intent(inout) :: dwc !< current water compressibility change in delay interbed
851 ! -- local variables
852 integer(I4B) :: idelay
853 integer(I4B) :: node
854 integer(I4B) :: n
855 real(DP) :: tled
856 real(DP) :: h
857 real(DP) :: h0
858 real(DP) :: dz
859 real(DP) :: dz0
860 real(DP) :: dsn
861 real(DP) :: dsn0
862 real(DP) :: wc
863 real(DP) :: wc0
864 real(DP) :: v
865 !
866 ! -- initialize variables
867 dwc = dzero
868 !
869 !
870 if (this%thickini(ib) > dzero) then
871 idelay = this%idelay(ib)
872 node = this%nodelist(ib)
873 tled = done / delt
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
883 dwc = dwc + v * tled
884 end do
885 end if
886 end subroutine csub_delay_calc_wcomp
887
888 ! -- documented on the GwfCsubType type-bound procedure in gwf-csub.f90
889 module subroutine csub_delay_calc_comp(this, ib, hcell, hcellold, comp, &
890 compi, compe)
891 ! -- dummy variables
892 class(GwfCsubType), intent(inout) :: this
893 integer(I4B), intent(in) :: ib !< interbed number
894 real(DP), intent(in) :: hcell !< current head in cell
895 real(DP), intent(in) :: hcellold !< previous head in cell
896 real(DP), intent(inout) :: comp !< compaction in delay interbed
897 real(DP), intent(inout) :: compi !< inelastic compaction in delay interbed
898 real(DP), intent(inout) :: compe !< elastic compaction in delay interbed
899 ! -- local variables
900 integer(I4B) :: idelay
901 integer(I4B) :: ielastic
902 integer(I4B) :: node
903 integer(I4B) :: n
904 real(DP) :: snnew
905 real(DP) :: snold
906 real(DP) :: sske
907 real(DP) :: ssk
908 real(DP) :: wfac
909 real(DP) :: fmult
910 real(DP) :: h
911 real(DP) :: h0
912 real(DP) :: dsn
913 real(DP) :: dsn0
914 real(DP) :: v
915 real(DP) :: v1
916 real(DP) :: v2
917 !
918 ! -- initialize variables
919 idelay = this%idelay(ib)
920 ielastic = this%ielastic(ib)
921 node = this%nodelist(ib)
922 comp = dzero
923 compi = dzero
924 compe = dzero
925 !
926 ! -- calculate cell saturation
927 call this%csub_calc_sat(node, hcell, hcellold, snnew, snold)
928 !
929 ! -- calculate compaction
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)
939 v2 = dzero
940 else
941 v1 = dsn * ssk * (this%dbes(n, idelay) - this%dbpcs(n, idelay))
942 v2 = dsn0 * sske * (this%dbpcs(n, idelay) - this%dbes0(n, idelay))
943 end if
944 v = (v1 + v2) * fmult
945 comp = comp + v
946 !
947 ! -- save compaction data
948 this%dbcomp(n, idelay) = v * snnew
949 !
950 ! -- split compaction into inelastic and elastic components weighted by
951 ! wfac so the reported budget blends across the smoothed transition;
952 ! wfac is 0/1 for the hard switch, reproducing the original split
953 compi = compi + wfac * v1 * fmult
954 compe = compe + ((done - wfac) * v1 + v2) * fmult
955 end do
956 end if
957 !
958 ! -- fill compaction
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
963
964 ! -- documented on the GwfCsubType type-bound procedure in gwf-csub.f90
965 module subroutine csub_delay_update(this, ib)
966 ! -- dummy variables
967 class(GwfCsubType), intent(inout) :: this
968 integer(I4B), intent(in) :: ib !< interbed number
969 ! -- local variables
970 integer(I4B) :: idelay
971 integer(I4B) :: n
972 real(DP) :: comp
973 real(DP) :: thick
974 real(DP) :: theta
975 real(DP) :: tthick
976 real(DP) :: wtheta
977 !
978 ! -- initialize variables
979 idelay = this%idelay(ib)
980 comp = dzero
981 tthick = dzero
982 wtheta = dzero
983 !
984 !
985 do n = 1, this%ndelaycells
986 !
987 ! -- initialize compaction for delay cell
988 comp = this%dbtcomp(n, idelay) + this%dbcomp(n, idelay)
989 !
990 ! -- scale compaction by rnb to get the compaction for
991 ! the interbed system (as opposed to the full system)
992 comp = comp / this%rnb(ib)
993 !
994 ! -- update thickness and theta
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)
1004 end if
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)
1010 end if
1011 this%dbdz(n, idelay) = thick
1012 this%dbtheta(n, idelay) = theta
1013 tthick = tthick + thick
1014 wtheta = wtheta + thick * theta
1015 else
1016 thick = this%dbdz(n, idelay)
1017 theta = this%dbtheta(n, idelay)
1018 tthick = tthick + thick
1019 wtheta = wtheta + thick * theta
1020 end if
1021 end do
1022 !
1023 ! -- calculate thickness weighted theta and save thickness and weighted
1024 ! theta values for delay interbed
1025 if (tthick > dzero) then
1026 wtheta = wtheta / tthick
1027 else
1028 tthick = dzero
1029 wtheta = dzero
1030 end if
1031 this%thick(ib) = tthick
1032 this%theta(ib) = wtheta
1033 end subroutine csub_delay_update
1034
1035 ! -- documented on the GwfCsubType type-bound procedure in gwf-csub.f90
1036 module subroutine csub_delay_fc(this, ib, hcof, rhs)
1037 ! -- dummy variables
1038 class(GwfCsubType), intent(inout) :: this
1039 integer(I4B), intent(in) :: ib !< interbed number
1040 real(DP), intent(inout) :: hcof !< head dependent coefficient
1041 real(DP), intent(inout) :: rhs !< right-hand side
1042 ! -- local variables
1043 integer(I4B) :: idelay
1044 real(DP) :: c1
1045 real(DP) :: c2
1046 !
1047 ! -- initialize variables
1048 idelay = this%idelay(ib)
1049 hcof = dzero
1050 rhs = dzero
1051 if (this%thickini(ib) > dzero) then
1052 ! -- calculate terms for gwf matrix
1053 c1 = dtwo * this%kv(ib) / this%dbdzini(1, idelay)
1054 rhs = -c1 * this%dbh(1, idelay)
1055 c2 = dtwo * &
1056 this%kv(ib) / this%dbdzini(this%ndelaycells, idelay)
1057 rhs = rhs - c2 * this%dbh(this%ndelaycells, idelay)
1058 hcof = c1 + c2
1059 end if
1060 end subroutine csub_delay_fc
1061
1062 ! -- documented on the GwfCsubType type-bound procedure in gwf-csub.f90
1063 module function csub_calc_delay_flow(this, ib, n, hcell) result(q)
1064 ! -- dummy variables
1065 class(GwfCsubType), intent(inout) :: this
1066 integer(I4B), intent(in) :: ib !< interbed number
1067 integer(I4B), intent(in) :: n !< delay interbed cell
1068 real(DP), intent(in) :: hcell !< current head in cell
1069 real(DP) :: q
1070 ! -- local variables
1071 integer(I4B) :: idelay
1072 real(DP) :: c
1073 !
1074 ! -- calculate flow between delay interbed and GWF
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
1079
1080end submodule gwfcsubmoduledelay
This module contains the CSUB package methods.
Definition gwf-csub.f90:23
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
Definition tdis.f90:32