31 character(len=LENBUDTXT),
dimension(NBDITEMS) ::
budtxt
32 data budtxt/
' STORAGE-CELLBLK',
' DECAY-AQUEOUS'/
41 real(dp),
pointer :: cpw => null()
42 real(dp),
pointer :: rhow => null()
43 real(dp),
dimension(:),
pointer,
contiguous :: cps => null()
44 real(dp),
dimension(:),
pointer,
contiguous :: rhos => null()
45 real(dp),
dimension(:),
pointer,
contiguous :: porosity => null()
46 real(dp),
dimension(:),
pointer,
contiguous :: ratesto => null()
49 integer(I4B),
pointer :: idcy => null()
50 integer(I4B),
pointer :: ilhv => null()
51 real(dp),
dimension(:),
pointer,
contiguous :: decay => null()
52 real(dp),
dimension(:),
pointer,
contiguous :: ratedcy => null()
53 real(dp),
dimension(:),
pointer,
contiguous :: decaylast => null()
56 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound => null()
59 real(dp),
pointer :: latheatvap => null()
60 real(dp),
pointer :: eqnsclfac => null()
88 subroutine est_cr(estobj, name_model, inunit, iout, fmi, eqnsclfac, gwecommon)
91 character(len=*),
intent(in) :: name_model
92 integer(I4B),
intent(in) :: inunit
93 integer(I4B),
intent(in) :: iout
95 real(dp),
intent(in),
pointer :: eqnsclfac
102 call estobj%set_names(1, name_model,
'EST',
'EST')
105 call estobj%allocate_scalars()
108 estobj%inunit = inunit
111 estobj%eqnsclfac => eqnsclfac
112 estobj%gwecommon => gwecommon
115 call estobj%parser%Initialize(estobj%inunit, estobj%iout)
131 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound
134 character(len=*),
parameter :: fmtest = &
135 "(1x,/1x,'EST -- ENERGY STORAGE AND TRANSFER PACKAGE, VERSION 1, &
136 &7/29/2020 INPUT READ FROM UNIT ', i0, //)"
139 write (this%iout, fmtest) this%inunit
142 call this%read_options()
146 this%ibound => ibound
149 call this%allocate_arrays(dis%nodes)
152 call this%read_data()
155 call this%read_packagedata()
158 if (this%ilhv == 1)
then
159 call this%gwecommon%set_gwe_dat_ptrs(this%rhow, this%cpw, this%rhow, &
160 this%cpw, this%latheatvap)
162 call this%gwecommon%set_gwe_dat_ptrs(this%rhow, this%cpw, this%rhow, &
174 subroutine est_fc(this, nodes, cold, nja, matrix_sln, idxglo, cnew, &
179 integer,
intent(in) :: nodes
180 real(DP),
intent(in),
dimension(nodes) :: cold
181 integer(I4B),
intent(in) :: nja
183 integer(I4B),
intent(in),
dimension(nja) :: idxglo
184 real(DP),
intent(inout),
dimension(nodes) :: rhs
185 real(DP),
intent(in),
dimension(nodes) :: cnew
186 integer(I4B),
intent(in) :: kiter
190 call this%est_fc_sto(nodes, cold, nja, matrix_sln, idxglo, rhs)
193 if (this%idcy /= 0)
then
194 call this%est_fc_dcy(nodes, cold, cnew, nja, matrix_sln, idxglo, &
206 subroutine est_fc_sto(this, nodes, cold, nja, matrix_sln, idxglo, rhs)
211 integer,
intent(in) :: nodes
212 real(DP),
intent(in),
dimension(nodes) :: cold
213 integer(I4B),
intent(in) :: nja
215 integer(I4B),
intent(in),
dimension(nja) :: idxglo
216 real(DP),
intent(inout),
dimension(nodes) :: rhs
218 integer(I4B) :: n, idiag
220 real(DP) :: hhcof, rrhs
221 real(DP) :: vnew, vold, vcell, vsolid, term
227 do n = 1, this%dis%nodes
230 if (this%ibound(n) <= 0) cycle
233 vcell = this%dis%area(n) * (this%dis%top(n) - this%dis%bot(n))
234 vnew = vcell * this%fmi%gwfsat(n) * this%porosity(n)
236 if (this%fmi%igwfstrgss /= 0) vold = vold + this%fmi%gwfstrgss(n) *
delt
237 if (this%fmi%igwfstrgsy /= 0) vold = vold + this%fmi%gwfstrgsy(n) *
delt
238 vsolid = vcell * (
done - this%porosity(n))
241 term = (this%rhos(n) * this%cps(n)) * vsolid
242 hhcof = -(this%eqnsclfac * vnew + term) * tled
243 rrhs = -(this%eqnsclfac * vold + term) * tled * cold(n)
244 idiag = this%dis%con%ia(n)
245 call matrix_sln%add_value_pos(idxglo(idiag), hhcof)
246 rhs(n) = rhs(n) + rrhs
257 subroutine est_fc_dcy(this, nodes, cold, cnew, nja, matrix_sln, &
263 integer,
intent(in) :: nodes
264 real(DP),
intent(in),
dimension(nodes) :: cold
265 real(DP),
intent(in),
dimension(nodes) :: cnew
266 integer(I4B),
intent(in) :: nja
268 integer(I4B),
intent(in),
dimension(nja) :: idxglo
269 real(DP),
intent(inout),
dimension(nodes) :: rhs
270 integer(I4B),
intent(in) :: kiter
272 integer(I4B) :: n, idiag
273 real(DP) :: hhcof, rrhs
276 real(DP) :: decay_rate
279 do n = 1, this%dis%nodes
282 if (this%ibound(n) <= 0) cycle
285 vcell = this%dis%area(n) * (this%dis%top(n) - this%dis%bot(n))
286 swtpdt = this%fmi%gwfsat(n)
289 idiag = this%dis%con%ia(n)
290 if (this%idcy == 1)
then
294 hhcof = -this%decay(n) * vcell * swtpdt * this%porosity(n) &
296 call matrix_sln%add_value_pos(idxglo(idiag), hhcof)
297 elseif (this%idcy == 2)
then
302 kiter, cold(n), cnew(n),
delt)
305 this%decaylast(n) = decay_rate
306 rrhs = decay_rate * vcell * swtpdt * this%porosity(n)
307 rhs(n) = rhs(n) + rrhs
320 subroutine est_cq(this, nodes, cnew, cold, flowja)
324 integer(I4B),
intent(in) :: nodes
325 real(DP),
intent(in),
dimension(nodes) :: cnew
326 real(DP),
intent(in),
dimension(nodes) :: cold
327 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
331 call this%est_cq_sto(nodes, cnew, cold, flowja)
334 if (this%idcy /= 0)
then
335 call this%est_cq_dcy(nodes, cnew, cold, flowja)
351 integer(I4B),
intent(in) :: nodes
352 real(DP),
intent(in),
dimension(nodes) :: cnew
353 real(DP),
intent(in),
dimension(nodes) :: cold
354 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
357 integer(I4B) :: idiag
360 real(DP) :: vwatnew, vwatold, vcell, vsolid, term
361 real(DP) :: hhcof, rrhs
368 this%ratesto(n) =
dzero
371 if (this%ibound(n) <= 0) cycle
374 vcell = this%dis%area(n) * (this%dis%top(n) - this%dis%bot(n))
375 vwatnew = vcell * this%fmi%gwfsat(n) * this%porosity(n)
377 if (this%fmi%igwfstrgss /= 0) vwatold = vwatold + this%fmi%gwfstrgss(n) &
379 if (this%fmi%igwfstrgsy /= 0) vwatold = vwatold + this%fmi%gwfstrgsy(n) &
381 vsolid = vcell * (
done - this%porosity(n))
384 term = (this%rhos(n) * this%cps(n)) * vsolid
385 hhcof = -(this%eqnsclfac * vwatnew + term) * tled
386 rrhs = -(this%eqnsclfac * vwatold + term) * tled * cold(n)
387 rate = hhcof * cnew(n) - rrhs
388 this%ratesto(n) = rate
389 idiag = this%dis%con%ia(n)
390 flowja(idiag) = flowja(idiag) + rate
406 integer(I4B),
intent(in) :: nodes
407 real(DP),
intent(in),
dimension(nodes) :: cnew
408 real(DP),
intent(in),
dimension(nodes) :: cold
409 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
412 integer(I4B) :: idiag
415 real(DP) :: hhcof, rrhs
417 real(DP) :: decay_rate
425 this%ratedcy(n) =
dzero
426 if (this%ibound(n) <= 0) cycle
429 vcell = this%dis%area(n) * (this%dis%top(n) - this%dis%bot(n))
430 swtpdt = this%fmi%gwfsat(n)
436 if (this%idcy == 1)
then
437 hhcof = -this%decay(n) * vcell * swtpdt * this%porosity(n) &
439 elseif (this%idcy == 2)
then
441 0, cold(n), cnew(n),
delt)
442 rrhs = decay_rate * vcell * swtpdt * this%porosity(n)
444 rate = hhcof * cnew(n) - rrhs
445 this%ratedcy(n) = rate
446 idiag = this%dis%con%ia(n)
447 flowja(idiag) = flowja(idiag) + rate
459 subroutine est_bd(this, isuppress_output, model_budget)
465 integer(I4B),
intent(in) :: isuppress_output
466 type(
budgettype),
intent(inout) :: model_budget
473 call model_budget%addentry(rin, rout,
delt,
budtxt(1), &
474 isuppress_output, rowlabel=this%packName)
477 if (this%idcy /= 0)
then
479 call model_budget%addentry(rin, rout,
delt,
budtxt(2), &
480 isuppress_output, rowlabel=this%packName)
494 integer(I4B),
intent(in) :: icbcfl
495 integer(I4B),
intent(in) :: icbcun
497 integer(I4B) :: ibinun
499 integer(I4B) :: iprint, nvaluesp, nwidthp
500 character(len=1) :: cdatafmp =
' ', editdesc =
' '
504 if (this%ipakcb < 0)
then
506 elseif (this%ipakcb == 0)
then
511 if (icbcfl == 0) ibinun = 0
514 if (ibinun /= 0)
then
519 call this%dis%record_array(this%ratesto, this%iout, iprint, -ibinun, &
520 budtxt(1), cdatafmp, nvaluesp, &
521 nwidthp, editdesc, dinact)
524 if (this%idcy /= 0) &
525 call this%dis%record_array(this%ratedcy, this%iout, iprint, -ibinun, &
526 budtxt(2), cdatafmp, nvaluesp, &
527 nwidthp, editdesc, dinact)
545 if (this%inunit > 0)
then
558 this%ibound => null()
565 call this%NumericalPackageType%da()
583 call this%NumericalPackageType%allocate_scalars()
588 call mem_allocate(this%latheatvap,
'LATHEATVAP', this%memoryPath)
595 this%latheatvap =
dzero
613 integer(I4B),
intent(in) :: nodes
619 call mem_allocate(this%porosity, nodes,
'POROSITY', this%memoryPath)
620 call mem_allocate(this%ratesto, nodes,
'RATESTO', this%memoryPath)
621 call mem_allocate(this%cps, nodes,
'CPS', this%memoryPath)
622 call mem_allocate(this%rhos, nodes,
'RHOS', this%memoryPath)
625 if (this%idcy == 0)
then
626 call mem_allocate(this%ratedcy, 1,
'RATEDCY', this%memoryPath)
627 call mem_allocate(this%decay, 1,
'DECAY', this%memoryPath)
628 call mem_allocate(this%decaylast, 1,
'DECAYLAST', this%memoryPath)
630 call mem_allocate(this%ratedcy, this%dis%nodes,
'RATEDCY', this%memoryPath)
631 call mem_allocate(this%decay, nodes,
'DECAY', this%memoryPath)
632 call mem_allocate(this%decaylast, nodes,
'DECAYLAST', this%memoryPath)
637 this%porosity(n) =
dzero
638 this%ratesto(n) =
dzero
642 do n = 1,
size(this%decay)
643 this%decay(n) =
dzero
644 this%ratedcy(n) =
dzero
645 this%decaylast(n) =
dzero
662 character(len=LINELENGTH) :: keyword
664 logical :: isfound, endOfBlock
666 character(len=*),
parameter :: fmtisvflow = &
667 &
"(4x,'CELL-BY-CELL FLOW INFORMATION WILL BE SAVED TO BINARY "// &
668 &
"FILE WHENEVER ICBCFL IS NOT ZERO.')"
669 character(len=*),
parameter :: fmtidcy1 = &
670 "(4x,'FIRST-ORDER DECAY IS ACTIVE. ')"
671 character(len=*),
parameter :: fmtidcy2 = &
672 "(4x,'ZERO-ORDER DECAY IS ACTIVE. ')"
673 character(len=*),
parameter :: fmtilhv = &
674 "(4x,'LATENT HEAT OF VAPORIZATION WILL BE &
675 &USED IN EVAPORATION CALCULATIONS.')"
678 call this%parser%GetBlock(
'OPTIONS', isfound, ierr, blockrequired=.false., &
679 supportopenclose=.true.)
683 write (this%iout,
'(1x,a)')
'PROCESSING ENERGY STORAGE AND TRANSFER OPTIONS'
685 call this%parser%GetNextLine(endofblock)
687 call this%parser%GetStringCaps(keyword)
688 select case (keyword)
691 write (this%iout, fmtisvflow)
692 case (
'FIRST_ORDER_DECAY')
694 write (this%iout, fmtidcy1)
695 case (
'ZERO_ORDER_DECAY')
697 write (this%iout, fmtidcy2)
698 case (
'LATENT_HEAT_VAPORIZATION')
700 write (this%iout, fmtilhv)
702 write (
errmsg,
'(a,a)')
'UNKNOWN EST OPTION: ', trim(keyword)
704 call this%parser%StoreErrorUnit()
707 write (this%iout,
'(1x,a)')
'END OF ENERGY STORAGE AND TRANSFER OPTIONS'
725 character(len=LINELENGTH) :: keyword
726 character(len=:),
allocatable :: line
727 integer(I4B) :: istart, istop, lloc, ierr
728 logical :: isfound, endOfBlock
729 logical,
dimension(4) :: lname
730 character(len=24),
dimension(4) :: aname
733 data aname(1)/
' MOBILE DOMAIN POROSITY'/
734 data aname(2)/
' DECAY RATE'/
735 data aname(3)/
' HEAT CAPACITY OF SOLIDS'/
736 data aname(4)/
' DENSITY OF SOLIDS'/
743 call this%parser%GetBlock(
'GRIDDATA', isfound, ierr)
745 write (this%iout,
'(1x,a)')
'PROCESSING GRIDDATA'
747 call this%parser%GetNextLine(endofblock)
749 call this%parser%GetStringCaps(keyword)
750 call this%parser%GetRemainingLine(line)
752 select case (keyword)
754 call this%dis%read_grid_array(line, lloc, istart, istop, this%iout, &
755 this%parser%iuactive, this%porosity, &
759 if (this%idcy == 0) &
761 trim(this%memoryPath))
762 call this%dis%read_grid_array(line, lloc, istart, istop, this%iout, &
763 this%parser%iuactive, this%decay, &
767 call this%dis%read_grid_array(line, lloc, istart, istop, this%iout, &
768 this%parser%iuactive, this%cps, &
772 call this%dis%read_grid_array(line, lloc, istart, istop, this%iout, &
773 this%parser%iuactive, this%rhos, &
777 write (
errmsg,
'(a,a)')
'UNKNOWN GRIDDATA TAG: ', trim(keyword)
779 call this%parser%StoreErrorUnit()
782 write (this%iout,
'(1x,a)')
'END PROCESSING GRIDDATA'
784 write (
errmsg,
'(a)')
'REQUIRED GRIDDATA BLOCK NOT FOUND.'
786 call this%parser%StoreErrorUnit()
790 if (.not. lname(1))
then
791 write (
errmsg,
'(a)')
'POROSITY NOT SPECIFIED IN GRIDDATA BLOCK.'
794 if (.not. lname(3))
then
795 write (
errmsg,
'(a)')
'CPS NOT SPECIFIED IN GRIDDATA BLOCK.'
798 if (.not. lname(4))
then
799 write (
errmsg,
'(a)')
'RHOS NOT SPECIFIED IN GRIDDATA BLOCK.'
804 if (this%idcy > 0)
then
805 if (.not. lname(2))
then
806 write (
errmsg,
'(a)')
'FIRST OR ZERO ORDER DECAY IS &
807 &ACTIVE BUT THE FIRST RATE COEFFICIENT IS NOT SPECIFIED. DECAY &
808 &MUST BE SPECIFIED IN GRIDDATA BLOCK.'
813 write (
warnmsg,
'(a)')
'FIRST OR ZERO ORER DECAY &
814 &IS NOT ACTIVE BUT DECAY WAS SPECIFIED. DECAY WILL &
815 &HAVE NO AFFECT ON SIMULATION RESULTS.'
817 write (this%iout,
'(1x,a)')
'WARNING. '//
warnmsg
823 call this%parser%StoreErrorUnit()
840 logical :: endOfBlock
843 call this%parser%GetBlock(
'PACKAGEDATA', isfound, ierr, &
844 supportopenclose=.true.)
848 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%packName))// &
851 call this%parser%GetNextLine(endofblock)
857 this%cpw = this%parser%GetDouble()
858 this%rhow = this%parser%GetDouble()
875 cold, cnew, delt)
result(decay_rate)
877 real(dp),
intent(in) :: decay_rate_usr
878 real(dp),
intent(in) :: decay_rate_last
879 integer(I4B),
intent(in) :: kiter
880 real(dp),
intent(in) :: cold
881 real(dp),
intent(in) :: cnew
882 real(dp),
intent(in) :: delt
884 real(dp) :: decay_rate
887 if (decay_rate_usr <
dzero)
then
890 decay_rate = decay_rate_usr
897 decay_rate = min(decay_rate_usr, cold / delt)
899 decay_rate = decay_rate_last
900 if (cnew <
dzero)
then
901 decay_rate = decay_rate_last + cnew / delt
902 else if (cnew > cold)
then
903 decay_rate = decay_rate_last + cnew / delt
905 decay_rate = min(decay_rate_usr, decay_rate)
907 decay_rate = max(decay_rate,
dzero)
This module contains the BudgetModule.
subroutine, public rate_accumulator(flow, rin, rout)
@ brief Rate accumulator subroutine
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
real(dp), parameter dhalf
real constant 1/2
real(dp), parameter dzero
real constant zero
real(dp), parameter dtwo
real constant 2
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
real(dp), parameter done
real constant 1
– @ brief Energy Storage and Transfer (EST) Module
subroutine est_fc_dcy(this, nodes, cold, cnew, nja, matrix_sln, idxglo, rhs, kiter)
@ brief Fill decay coefficient method for package
subroutine read_packagedata(this)
@ brief Read data for package
subroutine est_cq_sto(this, nodes, cnew, cold, flowja)
@ brief Calculate storage terms for package
integer(i4b), parameter nbditems
subroutine est_cq_dcy(this, nodes, cnew, cold, flowja)
@ brief Calculate decay terms for package
character(len=lenbudtxt), dimension(nbditems) budtxt
subroutine est_fc_sto(this, nodes, cold, nja, matrix_sln, idxglo, rhs)
@ brief Fill storage coefficient method for package
real(dp) function get_zero_order_decay(decay_rate_usr, decay_rate_last, kiter, cold, cnew, delt)
@ brief Calculate zero-order decay rate and constrain if necessary
subroutine allocate_scalars(this)
@ brief Allocate scalar variables for package
subroutine est_ar(this, dis, ibound)
@ brief Allocate and read method for package
subroutine est_fc(this, nodes, cold, nja, matrix_sln, idxglo, cnew, rhs, kiter)
@ brief Fill coefficient method for package
subroutine allocate_arrays(this, nodes)
@ brief Allocate arrays for package
subroutine, public est_cr(estobj, name_model, inunit, iout, fmi, eqnsclfac, gwecommon)
@ brief Create a new EST package object
subroutine est_cq(this, nodes, cnew, cold, flowja)
@ brief Calculate flows for package
subroutine est_bd(this, isuppress_output, model_budget)
@ brief Calculate budget terms for package
subroutine read_data(this)
@ brief Read data for package
subroutine est_da(this)
Deallocate memory.
subroutine read_options(this)
@ brief Read options for package
subroutine est_ot_flow(this, icbcfl, icbcun)
@ brief Output flow terms for package
This module defines variable data types.
This module contains the base numerical package type.
This module contains simulation methods.
subroutine, public store_warning(msg, substring)
Store warning message.
subroutine, public store_error(msg, terminate)
Store an error message.
integer(i4b) function, public count_errors()
Return number of errors.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
character(len=maxcharlen) warnmsg
warning message string
real(dp), pointer, public delt
length of the current time step
Derived type for the Budget object.
@ brief Energy storage and transfer