25 real(dp),
dimension(:),
pointer :: conc => null()
26 integer(I4B),
dimension(:),
pointer :: icbund => null()
31 integer(I4B),
pointer :: ioutdense => null()
32 integer(I4B),
pointer :: iform => null()
33 integer(I4B),
pointer :: ireadelev => null()
34 integer(I4B),
pointer :: ireadconcbuy => null()
35 integer(I4B),
pointer :: iconcset => null()
36 real(dp),
pointer :: denseref => null()
37 real(dp),
dimension(:),
pointer,
contiguous :: dense => null()
38 real(dp),
dimension(:),
pointer,
contiguous :: concbuy => null()
39 real(dp),
dimension(:),
pointer,
contiguous :: elev => null()
40 integer(I4B),
dimension(:),
pointer :: ibound => null()
42 integer(I4B),
pointer :: nrhospecies => null()
43 real(dp),
dimension(:),
pointer,
contiguous :: drhodc => null()
44 real(dp),
dimension(:),
pointer,
contiguous :: crhoref => null()
45 real(dp),
dimension(:),
pointer,
contiguous :: ctemp => null()
46 character(len=LENMODELNAME),
dimension(:),
allocatable :: cmodelname
47 character(len=LENAUXNAME),
dimension(:),
allocatable :: cauxspeciesname
82 function calcdens(denseref, drhodc, crhoref, conc)
result(dense)
84 real(dp),
intent(in) :: denseref
85 real(dp),
dimension(:),
intent(in) :: drhodc
86 real(dp),
dimension(:),
intent(in) :: crhoref
87 real(dp),
dimension(:),
intent(in) :: conc
91 integer(I4B) :: nrhospec
94 nrhospec =
size(drhodc)
97 dense = dense + drhodc(i) * (conc(i) - crhoref(i))
103 subroutine buy_cr(buyobj, name_model, input_mempath, inunit, iout)
106 character(len=*),
intent(in) :: name_model
107 character(len=*),
intent(in) :: input_mempath
108 integer(I4B),
intent(in) :: inunit
109 integer(I4B),
intent(in) :: iout
115 call buyobj%set_names(1, name_model,
'BUY',
'BUY', input_mempath)
118 call buyobj%allocate_scalars()
121 buyobj%inunit = inunit
134 character(len=*),
parameter :: fmtbuy = &
135 "(1x,/1x,'BUY -- Buoyancy Package, Version 1, 5/16/2018', &
136 &' input read from mempath: ', a, /)"
139 if (.not.
present(buy_input))
then
140 write (this%iout, fmtbuy) this%input_mempath
146 if (.not.
present(buy_input))
then
149 call this%source_options()
152 call this%source_dimensions()
155 call this%set_options(buy_input)
156 this%nrhospecies = buy_input%nrhospecies
160 call this%allocate_arrays(dis%nodes)
162 if (.not.
present(buy_input))
then
165 call this%source_packagedata()
168 call this%set_packagedata(buy_input)
178 integer(I4B),
dimension(:),
pointer :: ibound
182 this%ibound => ibound
185 if (this%npf%ixt3d /= 0)
then
186 call store_error(
'Error in model '//trim(this%name_model)// &
187 '. The XT3D option cannot be used with the BUY Package.')
192 call this%buy_calcelev()
207 class(
bndtype),
pointer :: packobj
208 real(DP),
intent(in),
dimension(:) :: hnew
211 select case (packobj%filtyp)
215 select type (packobj)
217 call packobj%lak_activate_density()
223 select type (packobj)
225 call packobj%sfr_activate_density()
231 select type (packobj)
233 call packobj%maw_activate_density()
250 character(len=LINELENGTH) :: errmsg
253 character(len=*),
parameter :: fmtc = &
254 "('Buoyancy Package does not have a concentration set &
255 &for species ',i0,'. One or more model names may be specified &
256 &incorrectly in the PACKAGEDATA block or a gwf-gwt exchange may need &
261 do i = 1, this%nrhospecies
262 if (.not.
associated(this%modelconc(i)%conc))
then
263 write (errmsg, fmtc) i
280 call this%buy_calcdens()
288 integer(I4B) :: kiter
291 if (this%ireadelev == 0)
then
292 if (this%iform == 1 .or. this%iform == 2)
then
293 call this%buy_calcelev()
305 class(
bndtype),
pointer :: packobj
306 real(DP),
intent(in),
dimension(:) :: hnew
309 integer(I4B) :: n, locdense, locelev
310 integer(I4B),
dimension(:),
allocatable :: locconc
314 if (this%iform == 0)
return
319 allocate (locconc(this%nrhospecies))
323 do n = 1, packobj%naux
324 if (packobj%auxname(n) ==
'DENSITY')
then
326 else if (packobj%auxname(n) ==
'ELEVATION')
then
332 do i = 1, this%nrhospecies
334 do j = 1, packobj%naux
335 if (this%cauxspeciesname(i) == packobj%auxname(j))
then
340 if (locconc(i) == 0)
then
348 select case (packobj%filtyp)
352 call buy_cf_ghb(packobj, this%dense, this%elev, this%denseref, &
353 locelev, locdense, locconc, this%drhodc, this%crhoref, &
358 call buy_cf_riv(packobj, hnew, this%dense, this%elev, this%denseref, &
359 locelev, locdense, locconc, this%drhodc, this%crhoref, &
364 call buy_cf_drn(packobj, this%dense, this%denseref)
368 call buy_cf_lak(packobj, hnew, this%dense, this%elev, this%denseref, &
369 locdense, locconc, this%drhodc, this%crhoref, &
370 this%ctemp, this%iform)
374 call buy_cf_sfr(packobj, hnew, this%dense, this%elev, this%denseref, &
375 locdense, locconc, this%drhodc, this%crhoref, &
376 this%ctemp, this%iform)
380 call buy_cf_maw(packobj, hnew, this%dense, this%elev, this%denseref, &
381 locdense, locconc, this%drhodc, this%crhoref, &
382 this%ctemp, this%iform)
399 ctemp, auxvar)
result(densebnd)
401 integer(I4B),
intent(in) :: n
402 integer(I4B),
intent(in) :: locdense
403 integer(I4B),
dimension(:),
intent(in) :: locconc
404 real(dp),
intent(in) :: denseref
405 real(dp),
dimension(:),
intent(in) :: drhodc
406 real(dp),
dimension(:),
intent(in) :: crhoref
407 real(dp),
dimension(:),
intent(inout) :: ctemp
408 real(dp),
dimension(:, :),
intent(in) :: auxvar
415 if (locdense > 0)
then
417 densebnd = auxvar(locdense, n)
418 else if (locconc(1) > 0)
then
420 do i = 1,
size(locconc)
422 if (locconc(i) > 0)
then
423 ctemp(i) = auxvar(locconc(i), n)
426 densebnd =
calcdens(denseref, drhodc, crhoref, ctemp)
435 subroutine buy_cf_ghb(packobj, dense, elev, denseref, locelev, &
436 locdense, locconc, drhodc, crhoref, ctemp)
440 class(
bndtype),
pointer :: packobj
442 real(DP),
intent(in),
dimension(:) :: dense
443 real(DP),
intent(in),
dimension(:) :: elev
444 real(DP),
intent(in) :: denseref
445 integer(I4B),
intent(in) :: locelev
446 integer(I4B),
intent(in) :: locdense
447 integer(I4B),
dimension(:),
intent(in) :: locconc
448 real(DP),
dimension(:),
intent(in) :: drhodc
449 real(DP),
dimension(:),
intent(in) :: crhoref
450 real(DP),
dimension(:),
intent(inout) :: ctemp
458 real(DP) :: hcofterm, rhsterm
461 select type (packobj)
463 do n = 1, packobj%nbound
464 node = packobj%nodelist(n)
465 if (packobj%ibound(node) <= 0) cycle
469 drhodc, crhoref, ctemp, packobj%auxvar)
473 if (locelev > 0) elevghb = packobj%auxvar(locelev, n)
476 hghb = packobj%bhead(n)
477 cond = packobj%cond_mult(n)
481 elevghb, elev(node), hghb, cond, &
483 packobj%hcof(n) = packobj%hcof(n) + hcofterm
484 packobj%rhs(n) = packobj%rhs(n) - rhsterm
498 elevghb, elevnode, hghb, &
499 cond, rhsterm, hcofterm)
501 real(DP),
intent(in) :: denseref
502 real(DP),
intent(in) :: denseghb
503 real(DP),
intent(in) :: densenode
504 real(DP),
intent(in) :: elevghb
505 real(DP),
intent(in) :: elevnode
506 real(DP),
intent(in) :: hghb
507 real(DP),
intent(in) :: cond
508 real(DP),
intent(inout) :: rhsterm
509 real(DP),
intent(inout) :: hcofterm
512 real(DP) :: avgdense, avgelev
515 avgdense =
dhalf * denseghb +
dhalf * densenode
517 t1 = avgdense / denseref -
done
518 t2 = (denseghb - densenode) / denseref
521 hcofterm = -cond * t1
522 hcofterm = hcofterm +
dhalf * cond * t2
525 rhsterm = cond * t1 * hghb
526 rhsterm = rhsterm - cond * t2 * avgelev
527 rhsterm = rhsterm +
dhalf * cond * t2 * hghb
532 subroutine buy_cf_riv(packobj, hnew, dense, elev, denseref, locelev, &
533 locdense, locconc, drhodc, crhoref, ctemp)
537 class(
bndtype),
pointer :: packobj
539 real(DP),
intent(in),
dimension(:) :: hnew
540 real(DP),
intent(in),
dimension(:) :: dense
541 real(DP),
intent(in),
dimension(:) :: elev
542 real(DP),
intent(in) :: denseref
543 integer(I4B),
intent(in) :: locelev
544 integer(I4B),
intent(in) :: locdense
545 integer(I4B),
dimension(:),
intent(in) :: locconc
546 real(DP),
dimension(:),
intent(in) :: drhodc
547 real(DP),
dimension(:),
intent(in) :: crhoref
548 real(DP),
dimension(:),
intent(inout) :: ctemp
561 select type (packobj)
563 do n = 1, packobj%nbound
564 node = packobj%nodelist(n)
565 if (packobj%ibound(node) <= 0) cycle
569 drhodc, crhoref, ctemp, packobj%auxvar)
573 if (locelev > 0) elevriv = packobj%auxvar(locelev, n)
576 hriv = packobj%stage(n)
577 cond = packobj%cond_mult(n)
578 rbot = packobj%rbot(n)
581 if (hnew(node) > rbot)
then
585 elevriv, elev(node), hriv, cond, &
589 rhsterm = cond * (denseriv / denseref -
done) * (hriv - rbot)
593 packobj%hcof(n) = packobj%hcof(n) + hcofterm
594 packobj%rhs(n) = packobj%rhs(n) - rhsterm
605 class(
bndtype),
pointer :: packobj
607 real(DP),
intent(in),
dimension(:) :: dense
608 real(DP),
intent(in) :: denseref
615 select type (packobj)
617 do n = 1, packobj%nbound
618 node = packobj%nodelist(n)
619 if (packobj%ibound(node) <= 0) cycle
625 rho = dense(node) / denseref
626 packobj%hcof(n) = rho * packobj%hcof(n)
627 packobj%rhs(n) = rho * packobj%rhs(n)
636 subroutine buy_cf_lak(packobj, hnew, dense, elev, denseref, locdense, &
637 locconc, drhodc, crhoref, ctemp, iform)
641 class(
bndtype),
pointer :: packobj
643 real(DP),
intent(in),
dimension(:) :: hnew
644 real(DP),
intent(in),
dimension(:) :: dense
645 real(DP),
intent(in),
dimension(:) :: elev
646 real(DP),
intent(in) :: denseref
647 integer(I4B),
intent(in) :: locdense
648 integer(I4B),
dimension(:),
intent(in) :: locconc
649 real(DP),
dimension(:),
intent(in) :: drhodc
650 real(DP),
dimension(:),
intent(in) :: crhoref
651 real(DP),
dimension(:),
intent(inout) :: ctemp
652 integer(I4B),
intent(in) :: iform
660 select type (packobj)
662 do n = 1, packobj%nbound
665 node = packobj%nodelist(n)
666 if (packobj%ibound(node) <= 0) cycle
670 drhodc, crhoref, ctemp, packobj%auxvar)
673 packobj%denseterms(1, n) = denselak / denseref
676 packobj%denseterms(2, n) = dense(node) / denseref
679 packobj%denseterms(3, n) = elev(node)
689 subroutine buy_cf_sfr(packobj, hnew, dense, elev, denseref, locdense, &
690 locconc, drhodc, crhoref, ctemp, iform)
694 class(
bndtype),
pointer :: packobj
696 real(DP),
intent(in),
dimension(:) :: hnew
697 real(DP),
intent(in),
dimension(:) :: dense
698 real(DP),
intent(in),
dimension(:) :: elev
699 real(DP),
intent(in) :: denseref
700 integer(I4B),
intent(in) :: locdense
701 integer(I4B),
dimension(:),
intent(in) :: locconc
702 real(DP),
dimension(:),
intent(in) :: drhodc
703 real(DP),
dimension(:),
intent(in) :: crhoref
704 real(DP),
dimension(:),
intent(inout) :: ctemp
705 integer(I4B),
intent(in) :: iform
713 select type (packobj)
715 do n = 1, packobj%nbound
718 node = packobj%nodelist(n)
719 if (packobj%ibound(node) <= 0) cycle
723 drhodc, crhoref, ctemp, packobj%auxvar)
726 packobj%denseterms(1, n) = densesfr / denseref
729 packobj%denseterms(2, n) = dense(node) / denseref
732 packobj%denseterms(3, n) = elev(node)
742 subroutine buy_cf_maw(packobj, hnew, dense, elev, denseref, locdense, &
743 locconc, drhodc, crhoref, ctemp, iform)
747 class(
bndtype),
pointer :: packobj
749 real(DP),
intent(in),
dimension(:) :: hnew
750 real(DP),
intent(in),
dimension(:) :: dense
751 real(DP),
intent(in),
dimension(:) :: elev
752 real(DP),
intent(in) :: denseref
753 integer(I4B),
intent(in) :: locdense
754 integer(I4B),
dimension(:),
intent(in) :: locconc
755 real(DP),
dimension(:),
intent(in) :: drhodc
756 real(DP),
dimension(:),
intent(in) :: crhoref
757 real(DP),
dimension(:),
intent(inout) :: ctemp
758 integer(I4B),
intent(in) :: iform
766 select type (packobj)
768 do n = 1, packobj%nbound
771 node = packobj%nodelist(n)
772 if (packobj%ibound(node) <= 0) cycle
776 drhodc, crhoref, ctemp, packobj%auxvar)
779 packobj%denseterms(1, n) = densemaw / denseref
782 packobj%denseterms(2, n) = dense(node) / denseref
785 packobj%denseterms(3, n) = elev(node)
793 subroutine buy_fc(this, kiter, matrix_sln, idxglo, rhs, hnew)
796 integer(I4B) :: kiter
798 integer(I4B),
intent(in),
dimension(:) :: idxglo
799 real(DP),
dimension(:),
intent(inout) :: rhs
800 real(DP),
intent(inout),
dimension(:) :: hnew
802 integer(I4B) :: n, m, ipos, idiag
803 real(DP) :: rhsterm, amatnn, amatnm
810 do n = 1, this%dis%nodes
811 if (this%ibound(n) == 0) cycle
812 idiag = this%dis%con%ia(n)
813 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
814 m = this%dis%con%ja(ipos)
815 if (this%ibound(m) == 0) cycle
816 if (this%iform == 0)
then
817 call this%calcbuy(n, m, ipos, hnew(n), hnew(m), rhsterm)
819 call this%calchhterms(n, m, ipos, hnew(n), hnew(m), rhsterm, &
824 rhs(n) = rhs(n) - rhsterm
825 call matrix_sln%add_value_pos(idxglo(idiag), -amatnn)
826 call matrix_sln%add_value_pos(idxglo(ipos), amatnm)
836 integer(I4B),
intent(in) :: idvfl
838 character(len=1) :: cdatafmp =
' ', editdesc =
' '
839 integer(I4B) :: ibinun
840 integer(I4B) :: iprint
841 integer(I4B) :: nvaluesp
842 integer(I4B) :: nwidthp
846 if (this%ioutdense /= 0)
then
851 if (idvfl == 0) ibinun = 0
854 if (ibinun /= 0)
then
859 if (this%ioutdense /= 0)
then
860 ibinun = this%ioutdense
861 call this%dis%record_array(this%dense, this%iout, iprint, ibinun, &
862 ' DENSITY', cdatafmp, nvaluesp, &
863 nwidthp, editdesc, dinact)
873 real(DP),
intent(in),
dimension(:) :: hnew
874 real(DP),
intent(inout),
dimension(:) :: flowja
875 integer(I4B) :: n, m, ipos
877 real(DP) :: rhsterm, amatnn, amatnm
880 do n = 1, this%dis%nodes
881 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
882 m = this%dis%con%ja(ipos)
884 if (this%iform == 0)
then
886 call this%calcbuy(n, m, ipos, hnew(n), hnew(m), deltaq)
889 call this%calchhterms(n, m, ipos, hnew(n), hnew(m), rhsterm, &
891 deltaq = amatnm * hnew(m) - amatnn * hnew(n) + rhsterm
893 flowja(ipos) = flowja(ipos) + deltaq
894 flowja(this%dis%con%isym(ipos)) = flowja(this%dis%con%isym(ipos)) - &
907 if (this%inunit > 0)
then
914 deallocate (this%cmodelname)
915 deallocate (this%cauxspeciesname)
916 deallocate (this%modelconc)
930 call this%NumericalPackageType%da()
945 call mem_set_value(this%nrhospecies,
'NRHOSPECIES', this%input_mempath, &
948 write (this%iout,
'(/1x,a)')
'Processing BUY DIMENSIONS block'
949 write (this%iout,
'(4x,a,i0)')
'NRHOSPECIES = ', this%nrhospecies
950 write (this%iout,
'(1x,a)')
'End of BUY DIMENSIONS block'
953 if (this%nrhospecies < 1)
then
954 call store_error(
'NRHOSPECIES must be greater than zero.')
969 integer(I4B),
dimension(:),
pointer,
contiguous :: irhospec
971 contiguous :: modelnames, auxspeciesnames
972 real(DP),
dimension(:),
pointer,
contiguous :: drhodc, crhoref
973 integer(I4B),
dimension(:),
allocatable :: itemp
974 character(len=LINELENGTH) :: modelname, auxspeciesname, line, errmsg
975 character(len=10) :: c10
976 character(len=16) :: c16
979 character(len=*),
parameter :: fmterr = &
980 "('Invalid value for IRHOSPEC (',i0,') detected in BUY Package. &
981 &IRHOSPEC must be > 0 and <= NRHOSPECIES, and duplicate values &
985 allocate (itemp(this%nrhospecies))
989 call mem_setptr(irhospec,
'IRHOSPEC', this%input_mempath)
990 call mem_setptr(drhodc,
'DRHODC', this%input_mempath)
991 call mem_setptr(crhoref,
'CRHOREF', this%input_mempath)
992 call mem_setptr(modelnames,
'MODELNAME', this%input_mempath)
993 call mem_setptr(auxspeciesnames,
'AUXSPECIESNAME', this%input_mempath)
996 do n = 1,
size(irhospec)
997 modelname = modelnames(n)
998 auxspeciesname = auxspeciesnames(n)
1000 if (irhospec(n) < 1 .or. irhospec(n) > this%nrhospecies)
then
1001 write (errmsg, fmterr) irhospec(n)
1004 if (itemp(irhospec(n)) /= 0)
then
1005 write (errmsg, fmterr) irhospec(n)
1008 itemp(irhospec(n)) = 1
1010 this%drhodc(irhospec(n)) = drhodc(n)
1011 this%crhoref(irhospec(n)) = crhoref(n)
1012 this%cmodelname(irhospec(n)) = trim(modelname)
1013 this%cauxspeciesname(irhospec(n)) = trim(auxspeciesname)
1022 write (this%iout,
'(/,1x,a)')
'Processing BUY PACKAGEDATA block'
1025 write (this%iout,
'(1x,a)')
'Summary of species information in BUY Package'
1026 write (this%iout,
'(1a11, 4a17)') &
1027 'SPECIES',
'DRHODC',
'CRHOREF',
'MODEL', &
1029 do n = 1, this%nrhospecies
1030 write (c10,
'(i0)') n
1031 line =
' '//adjustr(c10)
1032 write (c16,
'(g15.6)') this%drhodc(n)
1033 line = trim(line)//
' '//adjustr(c16)
1034 write (c16,
'(g15.6)') this%crhoref(n)
1035 line = trim(line)//
' '//adjustr(c16)
1036 write (c16,
'(a)') this%cmodelname(n)
1037 line = trim(line)//
' '//adjustr(c16)
1038 write (c16,
'(a)') this%cauxspeciesname(n)
1039 line = trim(line)//
' '//adjustr(c16)
1040 write (this%iout,
'(a)') trim(line)
1043 write (this%iout,
'(1x,a)')
'End of BUY PACKAGEDATA block'
1061 integer(I4B) :: ispec
1063 do ispec = 1, this%nrhospecies
1064 this%drhodc(ispec) = input_data%drhodc(ispec)
1065 this%crhoref(ispec) = input_data%crhoref(ispec)
1066 this%cmodelname(ispec) = input_data%cmodelname(ispec)
1067 this%cauxspeciesname(ispec) = input_data%cauxspeciesname(ispec)
1078 integer(I4B),
intent(in) :: n
1079 integer(I4B),
intent(in) :: m
1080 integer(I4B),
intent(in) :: icon
1081 real(DP),
intent(in) :: hn
1082 real(DP),
intent(in) :: hm
1083 real(DP),
intent(inout) :: buy
1086 real(DP) :: densen, densem, cl1, cl2, avgdense, wt, elevn, elevm, &
1092 densen = this%dense(n)
1093 densem = this%dense(m)
1095 cl1 = this%dis%con%cl1(this%dis%con%jas(icon))
1096 cl2 = this%dis%con%cl2(this%dis%con%jas(icon))
1098 cl1 = this%dis%con%cl2(this%dis%con%jas(icon))
1099 cl2 = this%dis%con%cl1(this%dis%con%jas(icon))
1101 wt = cl1 / (cl1 + cl2)
1102 avgdense = wt * densen + (
done - wt) * densem
1105 if (this%ireadelev == 0)
then
1106 tp = this%dis%top(n)
1107 bt = this%dis%bot(n)
1108 elevn = bt +
dhalf * this%npf%sat(n) * (tp - bt)
1109 tp = this%dis%top(m)
1110 bt = this%dis%bot(m)
1111 elevm = bt +
dhalf * this%npf%sat(m) * (tp - bt)
1113 elevn = this%elev(n)
1114 elevm = this%elev(m)
1117 ihc = this%dis%con%ihc(this%dis%con%jas(icon))
1118 hyn = this%npf%hy_eff(n, m, ihc, ipos=icon)
1119 hym = this%npf%hy_eff(m, n, ihc, ipos=icon)
1122 if (this%dis%con%ihc(this%dis%con%jas(icon)) == 0)
then
1123 cond =
vcond(this%ibound(n), this%ibound(m), &
1124 this%npf%icelltype(n), this%npf%icelltype(m), &
1126 this%npf%ivarcv, this%npf%idewatcv, &
1127 this%npf%condsat(this%dis%con%jas(icon)), hn, hm, &
1129 this%npf%sat(n), this%npf%sat(m), &
1130 this%dis%top(n), this%dis%top(m), &
1131 this%dis%bot(n), this%dis%bot(m), &
1132 this%dis%con%hwva(this%dis%con%jas(icon)))
1134 cond =
hcond(this%ibound(n), this%ibound(m), &
1135 this%npf%icelltype(n), this%npf%icelltype(m), &
1137 this%dis%con%ihc(this%dis%con%jas(icon)), &
1138 this%npf%icellavg, &
1139 this%npf%condsat(this%dis%con%jas(icon)), &
1140 hn, hm, this%npf%sat(n), this%npf%sat(m), &
1142 this%dis%top(n), this%dis%top(m), &
1143 this%dis%bot(n), this%dis%bot(m), &
1144 this%dis%con%cl1(this%dis%con%jas(icon)), &
1145 this%dis%con%cl2(this%dis%con%jas(icon)), &
1146 this%dis%con%hwva(this%dis%con%jas(icon)))
1150 buy = cond * (avgdense - this%denseref) / this%denseref * (elevm - elevn)
1155 subroutine calchhterms(this, n, m, icon, hn, hm, rhsterm, amatnn, amatnm)
1160 integer(I4B),
intent(in) :: n
1161 integer(I4B),
intent(in) :: m
1162 integer(I4B),
intent(in) :: icon
1163 real(DP),
intent(in) :: hn
1164 real(DP),
intent(in) :: hm
1165 real(DP),
intent(inout) :: rhsterm
1166 real(DP),
intent(inout) :: amatnn
1167 real(DP),
intent(inout) :: amatnm
1170 real(DP) :: densen, densem, cl1, cl2, avgdense, wt, elevn, elevm, cond
1171 real(DP) :: rhonormn, rhonormm
1179 densen = this%dense(n)
1180 densem = this%dense(m)
1182 cl1 = this%dis%con%cl1(this%dis%con%jas(icon))
1183 cl2 = this%dis%con%cl2(this%dis%con%jas(icon))
1185 cl1 = this%dis%con%cl2(this%dis%con%jas(icon))
1186 cl2 = this%dis%con%cl1(this%dis%con%jas(icon))
1188 wt = cl1 / (cl1 + cl2)
1189 avgdense = wt * densen + (1.0 - wt) * densem
1192 elevn = this%elev(n)
1193 elevm = this%elev(m)
1194 elevnm = (
done - wt) * elevn + wt * elevm
1196 ihc = this%dis%con%ihc(this%dis%con%jas(icon))
1197 hyn = this%npf%hy_eff(n, m, ihc, ipos=icon)
1198 hym = this%npf%hy_eff(m, n, ihc, ipos=icon)
1202 cond =
vcond(this%ibound(n), this%ibound(m), &
1203 this%npf%icelltype(n), this%npf%icelltype(m), &
1205 this%npf%ivarcv, this%npf%idewatcv, &
1206 this%npf%condsat(this%dis%con%jas(icon)), hn, hm, &
1208 this%npf%sat(n), this%npf%sat(m), &
1209 this%dis%top(n), this%dis%top(m), &
1210 this%dis%bot(n), this%dis%bot(m), &
1211 this%dis%con%hwva(this%dis%con%jas(icon)))
1213 cond =
hcond(this%ibound(n), this%ibound(m), &
1214 this%npf%icelltype(n), this%npf%icelltype(m), &
1216 this%dis%con%ihc(this%dis%con%jas(icon)), &
1217 this%npf%icellavg, &
1218 this%npf%condsat(this%dis%con%jas(icon)), &
1219 hn, hm, this%npf%sat(n), this%npf%sat(m), &
1221 this%dis%top(n), this%dis%top(m), &
1222 this%dis%bot(n), this%dis%bot(m), &
1223 this%dis%con%cl1(this%dis%con%jas(icon)), &
1224 this%dis%con%cl2(this%dis%con%jas(icon)), &
1225 this%dis%con%hwva(this%dis%con%jas(icon)))
1229 rhonormn = densen / this%denseref
1230 rhonormm = densem / this%denseref
1231 rhoterm = wt * rhonormn + (
done - wt) * rhonormm
1232 amatnn = cond * (rhoterm -
done)
1234 rhsterm = -cond * (rhonormm - rhonormn) * elevnm
1235 if (this%iform == 1)
then
1237 hphi = (
done - wt) * hn + wt * hm
1238 rhsterm = rhsterm + cond * hphi * (rhonormm - rhonormn)
1241 amatnn = amatnn - cond * (
done - wt) * (rhonormm - rhonormn)
1242 amatnm = amatnm + cond * wt * (rhonormm - rhonormn)
1257 do n = 1, this%dis%nodes
1258 do i = 1, this%nrhospecies
1259 if (this%modelconc(i)%icbund(n) == 0)
then
1260 this%ctemp(i) =
dzero
1262 this%ctemp(i) = this%modelconc(i)%conc(n)
1265 this%dense(n) =
calcdens(this%denseref, this%drhodc, this%crhoref, &
1277 real(DP) :: tp, bt, frac
1280 do n = 1, this%dis%nodes
1281 tp = this%dis%top(n)
1282 bt = this%dis%bot(n)
1283 frac = this%npf%sat(n)
1284 this%elev(n) = bt +
dhalf * frac * (tp - bt)
1298 call this%NumericalPackageType%allocate_scalars()
1301 call mem_allocate(this%ioutdense,
'IOUTDENSE', this%memoryPath)
1302 call mem_allocate(this%iform,
'IFORM', this%memoryPath)
1303 call mem_allocate(this%ireadelev,
'IREADELEV', this%memoryPath)
1304 call mem_allocate(this%ireadconcbuy,
'IREADCONCBUY', this%memoryPath)
1305 call mem_allocate(this%iconcset,
'ICONCSET', this%memoryPath)
1306 call mem_allocate(this%denseref,
'DENSEREF', this%memoryPath)
1308 call mem_allocate(this%nrhospecies,
'NRHOSPECIES', this%memoryPath)
1314 this%ireadconcbuy = 0
1315 this%denseref = 1000.d0
1317 this%nrhospecies = 0
1329 integer(I4B),
intent(in) :: nodes
1334 call mem_allocate(this%dense, nodes,
'DENSE', this%memoryPath)
1335 call mem_allocate(this%concbuy, 0,
'CONCBUY', this%memoryPath)
1336 call mem_allocate(this%elev, nodes,
'ELEV', this%memoryPath)
1337 call mem_allocate(this%drhodc, this%nrhospecies,
'DRHODC', this%memoryPath)
1338 call mem_allocate(this%crhoref, this%nrhospecies,
'CRHOREF', this%memoryPath)
1339 call mem_allocate(this%ctemp, this%nrhospecies,
'CTEMP', this%memoryPath)
1340 allocate (this%cmodelname(this%nrhospecies))
1341 allocate (this%cauxspeciesname(this%nrhospecies))
1342 allocate (this%modelconc(this%nrhospecies))
1346 this%dense(i) = this%denseref
1347 this%elev(i) =
dzero
1351 do i = 1, this%nrhospecies
1352 this%drhodc(i) =
dzero
1353 this%crhoref(i) =
dzero
1354 this%ctemp(i) =
dzero
1355 this%cmodelname(i) =
''
1356 this%cauxspeciesname(i) =
''
1371 character(len=LINELENGTH) :: densityfile
1378 call mem_set_value(this%iform,
'HHFORM_RHS', this%input_mempath, &
1380 call mem_set_value(this%denseref,
'DENSEREF', this%input_mempath, &
1382 call mem_set_value(this%iform,
'DEV_EFH_FORM', this%input_mempath, &
1384 call mem_set_value(densityfile,
'DENSITYFILE', this%input_mempath, &
1388 if (found%hhform_rhs) this%iasym = 0
1389 if (found%dev_efh_form)
then
1395 if (found%densityfile)
then
1397 call openfile(this%ioutdense, this%iout, densityfile,
'DATA(BINARY)', &
1402 call this%log_options(found, densityfile)
1413 character(len=*),
intent(in) :: densityfile
1416 character(len=*),
parameter :: fmtfileout = &
1417 "(4x, 'BUY ', 1x, a, 1x, ' will be saved to file: ', &
1418 &a, ' opened on unit: ', I7)"
1420 write (this%iout,
'(1x,a)')
'Processing BUY OPTIONS block'
1422 if (found%hhform_rhs)
then
1423 write (this%iout,
'(4x,a)') &
1424 'Hydraulic head formulation set to right-hand side'
1426 if (found%denseref)
then
1427 write (this%iout,
'(4x,a,1pg15.6)') &
1428 'Reference density has been set to: ', this%denseref
1430 if (found%dev_efh_form)
then
1431 write (this%iout,
'(4x,a)') &
1432 'Formulation set to equivalent freshwater head'
1434 if (found%densityfile)
then
1435 write (this%iout, fmtfileout) &
1436 'DENSITY', trim(densityfile), this%ioutdense
1439 write (this%iout,
'(1x,a)')
'End of BUY OPTIONS block'
1449 this%iform = input_data%iform
1450 this%denseref = input_data%denseref
1454 if (this%iform == 0 .or. this%iform == 1)
then
1468 character(len=LENMODELNAME),
intent(in) :: modelname
1469 real(DP),
dimension(:),
pointer :: conc
1470 integer(I4B),
dimension(:),
pointer :: icbund
1477 do i = 1, this%nrhospecies
1478 if (this%cmodelname(i) == modelname)
then
1479 this%modelconc(i)%conc => conc
1480 this%modelconc(i)%icbund => icbund
This module contains the base boundary package.
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
integer(i4b), parameter lenmodelname
maximum length of the model name
real(dp), parameter dhnoflo
real no flow constant
real(dp), parameter dhalf
real constant 1/2
integer(i4b), parameter lenauxname
maximum length of a aux variable
real(dp), parameter dzero
real constant zero
integer(i4b), parameter maxcharlen
maximum length of char string
real(dp), parameter done
real constant 1
real(dp) function calcdens(denseref, drhodc, crhoref, conc)
Generic function to calculate fluid density from concentration.
subroutine buy_cf(this, kiter)
Fill coefficients.
subroutine buy_cf_bnd(this, packobj, hnew)
Fill coefficients.
subroutine buy_cf_lak(packobj, hnew, dense, elev, denseref, locdense, locconc, drhodc, crhoref, ctemp, iform)
Pass density information into lak package; density terms are calculated in the lake package as part o...
subroutine set_options(this, input_data)
Sets options as opposed to reading them from a file.
subroutine calchhterms(this, n, m, icon, hn, hm, rhsterm, amatnn, amatnm)
Calculate hydraulic head term for this connection.
subroutine buy_rp(this)
Check for new buy period data.
subroutine buy_cf_maw(packobj, hnew, dense, elev, denseref, locdense, locconc, drhodc, crhoref, ctemp, iform)
Pass density information into maw package; density terms are calculated in the maw package as part of...
subroutine buy_fc(this, kiter, matrix_sln, idxglo, rhs, hnew)
Fill coefficients.
subroutine, public buy_cr(buyobj, name_model, input_mempath, inunit, iout)
Create a new BUY object.
subroutine allocate_scalars(this)
Allocate scalars used by the package.
subroutine buy_cq(this, hnew, flowja)
Add buy term to flowja.
subroutine buy_calcelev(this)
Calculate cell elevations to use in density flow equations.
subroutine set_concentration_pointer(this, modelname, conc, icbund)
Pass in a gwt model name, concentration array and ibound, and store a pointer to these in the BUY pac...
subroutine set_packagedata(this, input_data)
Sets package data instead of reading from file.
subroutine buy_df(this, dis, buy_input)
Read options and package data, or set from argument.
subroutine source_dimensions(this)
@ brief Source dimensions for package
subroutine buy_cf_sfr(packobj, hnew, dense, elev, denseref, locdense, locconc, drhodc, crhoref, ctemp, iform)
Pass density information into sfr package; density terms are calculated in the sfr package as part of...
subroutine buy_ot_dv(this, idvfl)
Save density array to binary file.
real(dp) function get_bnd_density(n, locdense, locconc, denseref, drhodc, crhoref, ctemp, auxvar)
Return the density of the boundary package using one of several different options in the following or...
subroutine calc_ghb_hcof_rhs_terms(denseref, denseghb, densenode, elevghb, elevnode, hghb, cond, rhsterm, hcofterm)
Calculate density hcof and rhs terms for ghb conditions.
subroutine buy_ar(this, npf, ibound)
Allocate and Read.
subroutine buy_da(this)
Deallocate.
subroutine buy_cf_drn(packobj, dense, denseref)
Fill drn coefficients.
subroutine buy_cf_riv(packobj, hnew, dense, elev, denseref, locelev, locdense, locconc, drhodc, crhoref, ctemp)
Fill riv coefficients.
subroutine source_options(this)
@ brief Source input options
subroutine buy_ad(this)
Advance.
subroutine log_options(this, found, densityfile)
@ brief log input options
subroutine source_packagedata(this)
@ brief source packagedata for package
subroutine buy_cf_ghb(packobj, dense, elev, denseref, locelev, locdense, locconc, drhodc, crhoref, ctemp)
Fill ghb coefficients.
subroutine allocate_arrays(this, nodes)
Allocate arrays used by the package.
subroutine buy_ar_bnd(this, packobj, hnew)
Buoyancy ar_bnd routine to activate density in packages.
subroutine calcbuy(this, n, m, icon, hn, hm, buy)
Calculate buyancy term for this connection.
subroutine buy_calcdens(this)
calculate fluid density from concentration
This module contains stateless conductance functions.
real(dp) function, public hcond(ibdn, ibdm, ictn, ictm, iupstream, ihc, icellavg, condsat, hn, hm, satn, satm, hkn, hkm, topn, topm, botn, botm, cln, clm, fawidth)
Horizontal conductance between two cells.
real(dp) function, public vcond(ibdn, ibdm, ictn, ictm, inewton, ivarcv, idewatcv, condsat, hn, hm, vkn, vkm, satn, satm, topn, topm, botn, botm, flowarea)
Vertical conductance between two cells.
This module defines variable data types.
subroutine, public memorystore_release(varname, memory_path)
Release a single variable from the memory store.
This module contains the base numerical package type.
This module contains the SFR package methods.
This module contains simulation methods.
subroutine, public store_error(msg, terminate)
Store an error message.
integer(i4b) function, public count_errors()
Return number of errors.
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
integer(i4b), pointer, public kstp
current time step number
integer(i4b), pointer, public kper
current stress period number
This class is used to store a single deferred-length character string. It was designed to work in an ...