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, hnew, this%dense, this%elev, this%denseref, &
353 locelev, locdense, locconc, this%drhodc, this%crhoref, &
354 this%ctemp, this%iform)
358 call buy_cf_riv(packobj, hnew, this%dense, this%elev, this%denseref, &
359 locelev, locdense, locconc, this%drhodc, this%crhoref, &
360 this%ctemp, this%iform)
364 call buy_cf_drn(packobj, hnew, 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, hnew, dense, elev, denseref, locelev, &
436 locdense, locconc, drhodc, crhoref, ctemp, &
441 class(
bndtype),
pointer :: packobj
443 real(DP),
intent(in),
dimension(:) :: hnew
444 real(DP),
intent(in),
dimension(:) :: dense
445 real(DP),
intent(in),
dimension(:) :: elev
446 real(DP),
intent(in) :: denseref
447 integer(I4B),
intent(in) :: locelev
448 integer(I4B),
intent(in) :: locdense
449 integer(I4B),
dimension(:),
intent(in) :: locconc
450 real(DP),
dimension(:),
intent(in) :: drhodc
451 real(DP),
dimension(:),
intent(in) :: crhoref
452 real(DP),
dimension(:),
intent(inout) :: ctemp
453 integer(I4B),
intent(in) :: iform
461 real(DP) :: hcofterm, rhsterm
464 select type (packobj)
466 do n = 1, packobj%nbound
467 node = packobj%nodelist(n)
468 if (packobj%ibound(node) <= 0) cycle
472 drhodc, crhoref, ctemp, packobj%auxvar)
476 if (locelev > 0) elevghb = packobj%auxvar(locelev, n)
479 hghb = packobj%bhead(n)
480 cond = packobj%cond(n)
484 elevghb, elev(node), hghb, hnew(node), &
485 cond, iform, rhsterm, hcofterm)
486 packobj%hcof(n) = packobj%hcof(n) + hcofterm
487 packobj%rhs(n) = packobj%rhs(n) - rhsterm
496 elevghb, elevnode, hghb, hnode, &
497 cond, iform, rhsterm, hcofterm)
499 real(DP),
intent(in) :: denseref
500 real(DP),
intent(in) :: denseghb
501 real(DP),
intent(in) :: densenode
502 real(DP),
intent(in) :: elevghb
503 real(DP),
intent(in) :: elevnode
504 real(DP),
intent(in) :: hghb
505 real(DP),
intent(in) :: hnode
506 real(DP),
intent(in) :: cond
507 integer(I4B),
intent(in) :: iform
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
525 hcofterm = hcofterm +
dhalf * cond * t2
529 rhsterm = cond * t1 * hghb
530 rhsterm = rhsterm - cond * t2 * avgelev
531 rhsterm = rhsterm +
dhalf * cond * t2 * hghb
535 rhsterm = rhsterm +
dhalf * cond * t2 * hnode
541 subroutine buy_cf_riv(packobj, hnew, dense, elev, denseref, locelev, &
542 locdense, locconc, drhodc, crhoref, ctemp, &
547 class(
bndtype),
pointer :: packobj
549 real(DP),
intent(in),
dimension(:) :: hnew
550 real(DP),
intent(in),
dimension(:) :: dense
551 real(DP),
intent(in),
dimension(:) :: elev
552 real(DP),
intent(in) :: denseref
553 integer(I4B),
intent(in) :: locelev
554 integer(I4B),
intent(in) :: locdense
555 integer(I4B),
dimension(:),
intent(in) :: locconc
556 real(DP),
dimension(:),
intent(in) :: drhodc
557 real(DP),
dimension(:),
intent(in) :: crhoref
558 real(DP),
dimension(:),
intent(inout) :: ctemp
559 integer(I4B),
intent(in) :: iform
572 select type (packobj)
574 do n = 1, packobj%nbound
575 node = packobj%nodelist(n)
576 if (packobj%ibound(node) <= 0) cycle
580 drhodc, crhoref, ctemp, packobj%auxvar)
584 if (locelev > 0) elevriv = packobj%auxvar(locelev, n)
587 hriv = packobj%stage(n)
588 cond = packobj%cond(n)
589 rbot = packobj%rbot(n)
592 if (hnew(node) > rbot)
then
596 elevriv, elev(node), hriv, hnew(node), &
597 cond, iform, rhsterm, hcofterm)
600 rhsterm = cond * (denseriv / denseref -
done) * (hriv - rbot)
604 packobj%hcof(n) = packobj%hcof(n) + hcofterm
605 packobj%rhs(n) = packobj%rhs(n) - rhsterm
616 class(
bndtype),
pointer :: packobj
618 real(DP),
intent(in),
dimension(:) :: hnew
619 real(DP),
intent(in),
dimension(:) :: dense
620 real(DP),
intent(in) :: denseref
631 select type (packobj)
633 do n = 1, packobj%nbound
634 node = packobj%nodelist(n)
635 if (packobj%ibound(node) <= 0) cycle
637 hbnd = packobj%elev(n)
638 cond = packobj%cond(n)
639 if (hnew(node) > hbnd)
then
640 hcofterm = -cond * (rho / denseref -
done)
641 rhsterm = hcofterm * hbnd
642 packobj%hcof(n) = packobj%hcof(n) + hcofterm
643 packobj%rhs(n) = packobj%rhs(n) + rhsterm
653 subroutine buy_cf_lak(packobj, hnew, dense, elev, denseref, locdense, &
654 locconc, drhodc, crhoref, ctemp, iform)
658 class(
bndtype),
pointer :: packobj
660 real(DP),
intent(in),
dimension(:) :: hnew
661 real(DP),
intent(in),
dimension(:) :: dense
662 real(DP),
intent(in),
dimension(:) :: elev
663 real(DP),
intent(in) :: denseref
664 integer(I4B),
intent(in) :: locdense
665 integer(I4B),
dimension(:),
intent(in) :: locconc
666 real(DP),
dimension(:),
intent(in) :: drhodc
667 real(DP),
dimension(:),
intent(in) :: crhoref
668 real(DP),
dimension(:),
intent(inout) :: ctemp
669 integer(I4B),
intent(in) :: iform
677 select type (packobj)
679 do n = 1, packobj%nbound
682 node = packobj%nodelist(n)
683 if (packobj%ibound(node) <= 0) cycle
687 drhodc, crhoref, ctemp, packobj%auxvar)
690 packobj%denseterms(1, n) = denselak / denseref
693 packobj%denseterms(2, n) = dense(node) / denseref
696 packobj%denseterms(3, n) = elev(node)
706 subroutine buy_cf_sfr(packobj, hnew, dense, elev, denseref, locdense, &
707 locconc, drhodc, crhoref, ctemp, iform)
711 class(
bndtype),
pointer :: packobj
713 real(DP),
intent(in),
dimension(:) :: hnew
714 real(DP),
intent(in),
dimension(:) :: dense
715 real(DP),
intent(in),
dimension(:) :: elev
716 real(DP),
intent(in) :: denseref
717 integer(I4B),
intent(in) :: locdense
718 integer(I4B),
dimension(:),
intent(in) :: locconc
719 real(DP),
dimension(:),
intent(in) :: drhodc
720 real(DP),
dimension(:),
intent(in) :: crhoref
721 real(DP),
dimension(:),
intent(inout) :: ctemp
722 integer(I4B),
intent(in) :: iform
730 select type (packobj)
732 do n = 1, packobj%nbound
735 node = packobj%nodelist(n)
736 if (packobj%ibound(node) <= 0) cycle
740 drhodc, crhoref, ctemp, packobj%auxvar)
743 packobj%denseterms(1, n) = densesfr / denseref
746 packobj%denseterms(2, n) = dense(node) / denseref
749 packobj%denseterms(3, n) = elev(node)
759 subroutine buy_cf_maw(packobj, hnew, dense, elev, denseref, locdense, &
760 locconc, drhodc, crhoref, ctemp, iform)
764 class(
bndtype),
pointer :: packobj
766 real(DP),
intent(in),
dimension(:) :: hnew
767 real(DP),
intent(in),
dimension(:) :: dense
768 real(DP),
intent(in),
dimension(:) :: elev
769 real(DP),
intent(in) :: denseref
770 integer(I4B),
intent(in) :: locdense
771 integer(I4B),
dimension(:),
intent(in) :: locconc
772 real(DP),
dimension(:),
intent(in) :: drhodc
773 real(DP),
dimension(:),
intent(in) :: crhoref
774 real(DP),
dimension(:),
intent(inout) :: ctemp
775 integer(I4B),
intent(in) :: iform
783 select type (packobj)
785 do n = 1, packobj%nbound
788 node = packobj%nodelist(n)
789 if (packobj%ibound(node) <= 0) cycle
793 drhodc, crhoref, ctemp, packobj%auxvar)
796 packobj%denseterms(1, n) = densemaw / denseref
799 packobj%denseterms(2, n) = dense(node) / denseref
802 packobj%denseterms(3, n) = elev(node)
810 subroutine buy_fc(this, kiter, matrix_sln, idxglo, rhs, hnew)
813 integer(I4B) :: kiter
815 integer(I4B),
intent(in),
dimension(:) :: idxglo
816 real(DP),
dimension(:),
intent(inout) :: rhs
817 real(DP),
intent(inout),
dimension(:) :: hnew
819 integer(I4B) :: n, m, ipos, idiag
820 real(DP) :: rhsterm, amatnn, amatnm
827 do n = 1, this%dis%nodes
828 if (this%ibound(n) == 0) cycle
829 idiag = this%dis%con%ia(n)
830 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
831 m = this%dis%con%ja(ipos)
832 if (this%ibound(m) == 0) cycle
833 if (this%iform == 0)
then
834 call this%calcbuy(n, m, ipos, hnew(n), hnew(m), rhsterm)
836 call this%calchhterms(n, m, ipos, hnew(n), hnew(m), rhsterm, &
841 rhs(n) = rhs(n) - rhsterm
842 call matrix_sln%add_value_pos(idxglo(idiag), -amatnn)
843 call matrix_sln%add_value_pos(idxglo(ipos), amatnm)
853 integer(I4B),
intent(in) :: idvfl
855 character(len=1) :: cdatafmp =
' ', editdesc =
' '
856 integer(I4B) :: ibinun
857 integer(I4B) :: iprint
858 integer(I4B) :: nvaluesp
859 integer(I4B) :: nwidthp
863 if (this%ioutdense /= 0)
then
868 if (idvfl == 0) ibinun = 0
871 if (ibinun /= 0)
then
876 if (this%ioutdense /= 0)
then
877 ibinun = this%ioutdense
878 call this%dis%record_array(this%dense, this%iout, iprint, ibinun, &
879 ' DENSITY', cdatafmp, nvaluesp, &
880 nwidthp, editdesc, dinact)
890 real(DP),
intent(in),
dimension(:) :: hnew
891 real(DP),
intent(inout),
dimension(:) :: flowja
892 integer(I4B) :: n, m, ipos
894 real(DP) :: rhsterm, amatnn, amatnm
897 do n = 1, this%dis%nodes
898 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
899 m = this%dis%con%ja(ipos)
901 if (this%iform == 0)
then
903 call this%calcbuy(n, m, ipos, hnew(n), hnew(m), deltaq)
906 call this%calchhterms(n, m, ipos, hnew(n), hnew(m), rhsterm, &
908 deltaq = amatnm * hnew(m) - amatnn * hnew(n) + rhsterm
910 flowja(ipos) = flowja(ipos) + deltaq
911 flowja(this%dis%con%isym(ipos)) = flowja(this%dis%con%isym(ipos)) - &
924 if (this%inunit > 0)
then
931 deallocate (this%cmodelname)
932 deallocate (this%cauxspeciesname)
933 deallocate (this%modelconc)
947 call this%NumericalPackageType%da()
962 call mem_set_value(this%nrhospecies,
'NRHOSPECIES', this%input_mempath, &
965 write (this%iout,
'(/1x,a)')
'Processing BUY DIMENSIONS block'
966 write (this%iout,
'(4x,a,i0)')
'NRHOSPECIES = ', this%nrhospecies
967 write (this%iout,
'(1x,a)')
'End of BUY DIMENSIONS block'
970 if (this%nrhospecies < 1)
then
971 call store_error(
'NRHOSPECIES must be greater than zero.')
986 integer(I4B),
dimension(:),
pointer,
contiguous :: irhospec
988 contiguous :: modelnames, auxspeciesnames
989 real(DP),
dimension(:),
pointer,
contiguous :: drhodc, crhoref
990 integer(I4B),
dimension(:),
allocatable :: itemp
991 character(len=LINELENGTH) :: modelname, auxspeciesname, line, errmsg
992 character(len=10) :: c10
993 character(len=16) :: c16
996 character(len=*),
parameter :: fmterr = &
997 "('Invalid value for IRHOSPEC (',i0,') detected in BUY Package. &
998 &IRHOSPEC must be > 0 and <= NRHOSPECIES, and duplicate values &
1002 allocate (itemp(this%nrhospecies))
1006 call mem_setptr(irhospec,
'IRHOSPEC', this%input_mempath)
1007 call mem_setptr(drhodc,
'DRHODC', this%input_mempath)
1008 call mem_setptr(crhoref,
'CRHOREF', this%input_mempath)
1009 call mem_setptr(modelnames,
'MODELNAME', this%input_mempath)
1010 call mem_setptr(auxspeciesnames,
'AUXSPECIESNAME', this%input_mempath)
1013 do n = 1,
size(irhospec)
1014 modelname = modelnames(n)
1015 auxspeciesname = auxspeciesnames(n)
1017 if (irhospec(n) < 1 .or. irhospec(n) > this%nrhospecies)
then
1018 write (errmsg, fmterr) irhospec(n)
1021 if (itemp(irhospec(n)) /= 0)
then
1022 write (errmsg, fmterr) irhospec(n)
1025 itemp(irhospec(n)) = 1
1027 this%drhodc(irhospec(n)) = drhodc(n)
1028 this%crhoref(irhospec(n)) = crhoref(n)
1029 this%cmodelname(irhospec(n)) = trim(modelname)
1030 this%cauxspeciesname(irhospec(n)) = trim(auxspeciesname)
1039 write (this%iout,
'(/,1x,a)')
'Processing BUY PACKAGEDATA block'
1042 write (this%iout,
'(1x,a)')
'Summary of species information in BUY Package'
1043 write (this%iout,
'(1a11, 4a17)') &
1044 'SPECIES',
'DRHODC',
'CRHOREF',
'MODEL', &
1046 do n = 1, this%nrhospecies
1047 write (c10,
'(i0)') n
1048 line =
' '//adjustr(c10)
1049 write (c16,
'(g15.6)') this%drhodc(n)
1050 line = trim(line)//
' '//adjustr(c16)
1051 write (c16,
'(g15.6)') this%crhoref(n)
1052 line = trim(line)//
' '//adjustr(c16)
1053 write (c16,
'(a)') this%cmodelname(n)
1054 line = trim(line)//
' '//adjustr(c16)
1055 write (c16,
'(a)') this%cauxspeciesname(n)
1056 line = trim(line)//
' '//adjustr(c16)
1057 write (this%iout,
'(a)') trim(line)
1060 write (this%iout,
'(1x,a)')
'End of BUY PACKAGEDATA block'
1078 integer(I4B) :: ispec
1080 do ispec = 1, this%nrhospecies
1081 this%drhodc(ispec) = input_data%drhodc(ispec)
1082 this%crhoref(ispec) = input_data%crhoref(ispec)
1083 this%cmodelname(ispec) = input_data%cmodelname(ispec)
1084 this%cauxspeciesname(ispec) = input_data%cauxspeciesname(ispec)
1095 integer(I4B),
intent(in) :: n
1096 integer(I4B),
intent(in) :: m
1097 integer(I4B),
intent(in) :: icon
1098 real(DP),
intent(in) :: hn
1099 real(DP),
intent(in) :: hm
1100 real(DP),
intent(inout) :: buy
1103 real(DP) :: densen, densem, cl1, cl2, avgdense, wt, elevn, elevm, &
1109 densen = this%dense(n)
1110 densem = this%dense(m)
1112 cl1 = this%dis%con%cl1(this%dis%con%jas(icon))
1113 cl2 = this%dis%con%cl2(this%dis%con%jas(icon))
1115 cl1 = this%dis%con%cl2(this%dis%con%jas(icon))
1116 cl2 = this%dis%con%cl1(this%dis%con%jas(icon))
1118 wt = cl1 / (cl1 + cl2)
1119 avgdense = wt * densen + (
done - wt) * densem
1122 if (this%ireadelev == 0)
then
1123 tp = this%dis%top(n)
1124 bt = this%dis%bot(n)
1125 elevn = bt +
dhalf * this%npf%sat(n) * (tp - bt)
1126 tp = this%dis%top(m)
1127 bt = this%dis%bot(m)
1128 elevm = bt +
dhalf * this%npf%sat(m) * (tp - bt)
1130 elevn = this%elev(n)
1131 elevm = this%elev(m)
1134 ihc = this%dis%con%ihc(this%dis%con%jas(icon))
1135 hyn = this%npf%hy_eff(n, m, ihc, ipos=icon)
1136 hym = this%npf%hy_eff(m, n, ihc, ipos=icon)
1139 if (this%dis%con%ihc(this%dis%con%jas(icon)) == 0)
then
1140 cond =
vcond(this%ibound(n), this%ibound(m), &
1141 this%npf%icelltype(n), this%npf%icelltype(m), &
1143 this%npf%ivarcv, this%npf%idewatcv, &
1144 this%npf%condsat(this%dis%con%jas(icon)), hn, hm, &
1146 this%npf%sat(n), this%npf%sat(m), &
1147 this%dis%top(n), this%dis%top(m), &
1148 this%dis%bot(n), this%dis%bot(m), &
1149 this%dis%con%hwva(this%dis%con%jas(icon)))
1151 cond =
hcond(this%ibound(n), this%ibound(m), &
1152 this%npf%icelltype(n), this%npf%icelltype(m), &
1154 this%dis%con%ihc(this%dis%con%jas(icon)), &
1155 this%npf%icellavg, &
1156 this%npf%condsat(this%dis%con%jas(icon)), &
1157 hn, hm, this%npf%sat(n), this%npf%sat(m), &
1159 this%dis%top(n), this%dis%top(m), &
1160 this%dis%bot(n), this%dis%bot(m), &
1161 this%dis%con%cl1(this%dis%con%jas(icon)), &
1162 this%dis%con%cl2(this%dis%con%jas(icon)), &
1163 this%dis%con%hwva(this%dis%con%jas(icon)))
1167 buy = cond * (avgdense - this%denseref) / this%denseref * (elevm - elevn)
1172 subroutine calchhterms(this, n, m, icon, hn, hm, rhsterm, amatnn, amatnm)
1177 integer(I4B),
intent(in) :: n
1178 integer(I4B),
intent(in) :: m
1179 integer(I4B),
intent(in) :: icon
1180 real(DP),
intent(in) :: hn
1181 real(DP),
intent(in) :: hm
1182 real(DP),
intent(inout) :: rhsterm
1183 real(DP),
intent(inout) :: amatnn
1184 real(DP),
intent(inout) :: amatnm
1187 real(DP) :: densen, densem, cl1, cl2, avgdense, wt, elevn, elevm, cond
1188 real(DP) :: rhonormn, rhonormm
1196 densen = this%dense(n)
1197 densem = this%dense(m)
1199 cl1 = this%dis%con%cl1(this%dis%con%jas(icon))
1200 cl2 = this%dis%con%cl2(this%dis%con%jas(icon))
1202 cl1 = this%dis%con%cl2(this%dis%con%jas(icon))
1203 cl2 = this%dis%con%cl1(this%dis%con%jas(icon))
1205 wt = cl1 / (cl1 + cl2)
1206 avgdense = wt * densen + (1.0 - wt) * densem
1209 elevn = this%elev(n)
1210 elevm = this%elev(m)
1211 elevnm = (
done - wt) * elevn + wt * elevm
1213 ihc = this%dis%con%ihc(this%dis%con%jas(icon))
1214 hyn = this%npf%hy_eff(n, m, ihc, ipos=icon)
1215 hym = this%npf%hy_eff(m, n, ihc, ipos=icon)
1219 cond =
vcond(this%ibound(n), this%ibound(m), &
1220 this%npf%icelltype(n), this%npf%icelltype(m), &
1222 this%npf%ivarcv, this%npf%idewatcv, &
1223 this%npf%condsat(this%dis%con%jas(icon)), hn, hm, &
1225 this%npf%sat(n), this%npf%sat(m), &
1226 this%dis%top(n), this%dis%top(m), &
1227 this%dis%bot(n), this%dis%bot(m), &
1228 this%dis%con%hwva(this%dis%con%jas(icon)))
1230 cond =
hcond(this%ibound(n), this%ibound(m), &
1231 this%npf%icelltype(n), this%npf%icelltype(m), &
1233 this%dis%con%ihc(this%dis%con%jas(icon)), &
1234 this%npf%icellavg, &
1235 this%npf%condsat(this%dis%con%jas(icon)), &
1236 hn, hm, this%npf%sat(n), this%npf%sat(m), &
1238 this%dis%top(n), this%dis%top(m), &
1239 this%dis%bot(n), this%dis%bot(m), &
1240 this%dis%con%cl1(this%dis%con%jas(icon)), &
1241 this%dis%con%cl2(this%dis%con%jas(icon)), &
1242 this%dis%con%hwva(this%dis%con%jas(icon)))
1246 rhonormn = densen / this%denseref
1247 rhonormm = densem / this%denseref
1248 rhoterm = wt * rhonormn + (
done - wt) * rhonormm
1249 amatnn = cond * (rhoterm -
done)
1251 rhsterm = -cond * (rhonormm - rhonormn) * elevnm
1252 if (this%iform == 1)
then
1254 hphi = (
done - wt) * hn + wt * hm
1255 rhsterm = rhsterm + cond * hphi * (rhonormm - rhonormn)
1258 amatnn = amatnn - cond * (
done - wt) * (rhonormm - rhonormn)
1259 amatnm = amatnm + cond * wt * (rhonormm - rhonormn)
1274 do n = 1, this%dis%nodes
1275 do i = 1, this%nrhospecies
1276 if (this%modelconc(i)%icbund(n) == 0)
then
1277 this%ctemp(i) =
dzero
1279 this%ctemp(i) = this%modelconc(i)%conc(n)
1282 this%dense(n) =
calcdens(this%denseref, this%drhodc, this%crhoref, &
1294 real(DP) :: tp, bt, frac
1297 do n = 1, this%dis%nodes
1298 tp = this%dis%top(n)
1299 bt = this%dis%bot(n)
1300 frac = this%npf%sat(n)
1301 this%elev(n) = bt +
dhalf * frac * (tp - bt)
1315 call this%NumericalPackageType%allocate_scalars()
1318 call mem_allocate(this%ioutdense,
'IOUTDENSE', this%memoryPath)
1319 call mem_allocate(this%iform,
'IFORM', this%memoryPath)
1320 call mem_allocate(this%ireadelev,
'IREADELEV', this%memoryPath)
1321 call mem_allocate(this%ireadconcbuy,
'IREADCONCBUY', this%memoryPath)
1322 call mem_allocate(this%iconcset,
'ICONCSET', this%memoryPath)
1323 call mem_allocate(this%denseref,
'DENSEREF', this%memoryPath)
1325 call mem_allocate(this%nrhospecies,
'NRHOSPECIES', this%memoryPath)
1331 this%ireadconcbuy = 0
1332 this%denseref = 1000.d0
1334 this%nrhospecies = 0
1346 integer(I4B),
intent(in) :: nodes
1351 call mem_allocate(this%dense, nodes,
'DENSE', this%memoryPath)
1352 call mem_allocate(this%concbuy, 0,
'CONCBUY', this%memoryPath)
1353 call mem_allocate(this%elev, nodes,
'ELEV', this%memoryPath)
1354 call mem_allocate(this%drhodc, this%nrhospecies,
'DRHODC', this%memoryPath)
1355 call mem_allocate(this%crhoref, this%nrhospecies,
'CRHOREF', this%memoryPath)
1356 call mem_allocate(this%ctemp, this%nrhospecies,
'CTEMP', this%memoryPath)
1357 allocate (this%cmodelname(this%nrhospecies))
1358 allocate (this%cauxspeciesname(this%nrhospecies))
1359 allocate (this%modelconc(this%nrhospecies))
1363 this%dense(i) = this%denseref
1364 this%elev(i) =
dzero
1368 do i = 1, this%nrhospecies
1369 this%drhodc(i) =
dzero
1370 this%crhoref(i) =
dzero
1371 this%ctemp(i) =
dzero
1372 this%cmodelname(i) =
''
1373 this%cauxspeciesname(i) =
''
1388 character(len=LINELENGTH) :: densityfile
1395 call mem_set_value(this%iform,
'HHFORM_RHS', this%input_mempath, &
1397 call mem_set_value(this%denseref,
'DENSEREF', this%input_mempath, &
1399 call mem_set_value(this%iform,
'DEV_EFH_FORM', this%input_mempath, &
1401 call mem_set_value(densityfile,
'DENSITYFILE', this%input_mempath, &
1405 if (found%hhform_rhs) this%iasym = 0
1406 if (found%dev_efh_form)
then
1412 if (found%densityfile)
then
1414 call openfile(this%ioutdense, this%iout, densityfile,
'DATA(BINARY)', &
1419 call this%log_options(found, densityfile)
1430 character(len=*),
intent(in) :: densityfile
1433 character(len=*),
parameter :: fmtfileout = &
1434 "(4x, 'BUY ', 1x, a, 1x, ' will be saved to file: ', &
1435 &a, ' opened on unit: ', I7)"
1437 write (this%iout,
'(1x,a)')
'Processing BUY OPTIONS block'
1439 if (found%hhform_rhs)
then
1440 write (this%iout,
'(4x,a)') &
1441 'Hydraulic head formulation set to right-hand side'
1443 if (found%denseref)
then
1444 write (this%iout,
'(4x,a,1pg15.6)') &
1445 'Reference density has been set to: ', this%denseref
1447 if (found%dev_efh_form)
then
1448 write (this%iout,
'(4x,a)') &
1449 'Formulation set to equivalent freshwater head'
1451 if (found%densityfile)
then
1452 write (this%iout, fmtfileout) &
1453 'DENSITY', trim(densityfile), this%ioutdense
1456 write (this%iout,
'(1x,a)')
'End of BUY OPTIONS block'
1466 this%iform = input_data%iform
1467 this%denseref = input_data%denseref
1471 if (this%iform == 0 .or. this%iform == 1)
then
1485 character(len=LENMODELNAME),
intent(in) :: modelname
1486 real(DP),
dimension(:),
pointer :: conc
1487 integer(I4B),
dimension(:),
pointer :: icbund
1494 do i = 1, this%nrhospecies
1495 if (this%cmodelname(i) == modelname)
then
1496 this%modelconc(i)%conc => conc
1497 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 calc_ghb_hcof_rhs_terms(denseref, denseghb, densenode, elevghb, elevnode, hghb, hnode, cond, iform, rhsterm, hcofterm)
Calculate density hcof and rhs terms for ghb conditions.
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 buy_cf_riv(packobj, hnew, dense, elev, denseref, locelev, locdense, locconc, drhodc, crhoref, ctemp, iform)
Fill riv coefficients.
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 buy_cf_ghb(packobj, hnew, dense, elev, denseref, locelev, locdense, locconc, drhodc, crhoref, ctemp, iform)
Fill ghb coefficients.
subroutine buy_ar(this, npf, ibound)
Allocate and Read.
subroutine buy_da(this)
Deallocate.
subroutine buy_cf_drn(packobj, hnew, dense, denseref)
Fill drn 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 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 ...