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),
pointer :: latheatvap => null()
44 real(dp),
dimension(:),
pointer,
contiguous :: cps => null()
45 real(dp),
dimension(:),
pointer,
contiguous :: rhos => null()
46 real(dp),
dimension(:),
pointer,
contiguous :: porosity => null()
47 real(dp),
dimension(:),
pointer,
contiguous :: ratesto => null()
50 integer(I4B),
pointer :: idcy => 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 :: eqnsclfac => null()
86 subroutine est_cr(estobj, name_model, inunit, iout, fmi, eqnsclfac, gwecommon)
89 character(len=*),
intent(in) :: name_model
90 integer(I4B),
intent(in) :: inunit
91 integer(I4B),
intent(in) :: iout
93 real(dp),
intent(in),
pointer :: eqnsclfac
100 call estobj%set_names(1, name_model,
'EST',
'EST')
103 call estobj%allocate_scalars()
106 estobj%inunit = inunit
109 estobj%eqnsclfac => eqnsclfac
110 estobj%gwecommon => gwecommon
113 call estobj%parser%Initialize(estobj%inunit, estobj%iout)
126 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound
128 character(len=*),
parameter :: fmtest = &
129 "(1x,/1x,'EST -- ENERGY STORAGE AND TRANSFER PACKAGE, VERSION 1, &
130 &7/29/2020 INPUT READ FROM UNIT ', i0, //)"
133 write (this%iout, fmtest) this%inunit
136 call this%read_options()
140 this%ibound => ibound
143 call this%allocate_arrays(dis%nodes)
146 call this%read_data()
149 call this%gwecommon%set_gwe_dat_ptrs(this%rhow, this%cpw, this%latheatvap, &
157 subroutine est_fc(this, nodes, cold, nja, matrix_sln, idxglo, cnew, &
162 integer,
intent(in) :: nodes
163 real(DP),
intent(in),
dimension(nodes) :: cold
164 integer(I4B),
intent(in) :: nja
166 integer(I4B),
intent(in),
dimension(nja) :: idxglo
167 real(DP),
intent(inout),
dimension(nodes) :: rhs
168 real(DP),
intent(in),
dimension(nodes) :: cnew
169 integer(I4B),
intent(in) :: kiter
173 call this%est_fc_sto(nodes, cold, nja, matrix_sln, idxglo, rhs)
176 if (this%idcy /= 0)
then
177 call this%est_fc_dcy(nodes, cold, cnew, nja, matrix_sln, idxglo, &
186 subroutine est_fc_sto(this, nodes, cold, nja, matrix_sln, idxglo, rhs)
191 integer,
intent(in) :: nodes
192 real(DP),
intent(in),
dimension(nodes) :: cold
193 integer(I4B),
intent(in) :: nja
195 integer(I4B),
intent(in),
dimension(nja) :: idxglo
196 real(DP),
intent(inout),
dimension(nodes) :: rhs
198 integer(I4B) :: n, idiag
200 real(DP) :: hhcof, rrhs
201 real(DP) :: vnew, vold, vcell, vsolid, term
207 do n = 1, this%dis%nodes
210 if (this%ibound(n) <= 0) cycle
213 vcell = this%dis%area(n) * (this%dis%top(n) - this%dis%bot(n))
214 vnew = vcell * this%fmi%gwfsat(n) * this%porosity(n)
216 if (this%fmi%igwfstrgss /= 0) vold = vold + this%fmi%gwfstrgss(n) *
delt
217 if (this%fmi%igwfstrgsy /= 0) vold = vold + this%fmi%gwfstrgsy(n) *
delt
218 vsolid = vcell * (
done - this%porosity(n))
221 term = (this%rhos(n) * this%cps(n)) * vsolid
222 hhcof = -(this%eqnsclfac * vnew + term) * tled
223 rrhs = -(this%eqnsclfac * vold + term) * tled * cold(n)
224 idiag = this%dis%con%ia(n)
225 call matrix_sln%add_value_pos(idxglo(idiag), hhcof)
226 rhs(n) = rhs(n) + rrhs
234 subroutine est_fc_dcy(this, nodes, cold, cnew, nja, matrix_sln, &
240 integer,
intent(in) :: nodes
241 real(DP),
intent(in),
dimension(nodes) :: cold
242 real(DP),
intent(in),
dimension(nodes) :: cnew
243 integer(I4B),
intent(in) :: nja
245 integer(I4B),
intent(in),
dimension(nja) :: idxglo
246 real(DP),
intent(inout),
dimension(nodes) :: rhs
247 integer(I4B),
intent(in) :: kiter
249 integer(I4B) :: n, idiag
250 real(DP) :: hhcof, rrhs
253 real(DP) :: decay_rate
256 do n = 1, this%dis%nodes
259 if (this%ibound(n) <= 0) cycle
262 vcell = this%dis%area(n) * (this%dis%top(n) - this%dis%bot(n))
263 swtpdt = this%fmi%gwfsat(n)
266 idiag = this%dis%con%ia(n)
267 if (this%idcy == 1)
then
271 hhcof = -this%decay(n) * vcell * swtpdt * this%porosity(n) &
273 call matrix_sln%add_value_pos(idxglo(idiag), hhcof)
274 elseif (this%idcy == 2)
then
279 kiter, cold(n), cnew(n),
delt)
282 this%decaylast(n) = decay_rate
283 rrhs = decay_rate * vcell * swtpdt * this%porosity(n)
284 rhs(n) = rhs(n) + rrhs
294 subroutine est_cq(this, nodes, cnew, cold, flowja)
298 integer(I4B),
intent(in) :: nodes
299 real(DP),
intent(in),
dimension(nodes) :: cnew
300 real(DP),
intent(in),
dimension(nodes) :: cold
301 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
305 call this%est_cq_sto(nodes, cnew, cold, flowja)
308 if (this%idcy /= 0)
then
309 call this%est_cq_dcy(nodes, cnew, cold, flowja)
322 integer(I4B),
intent(in) :: nodes
323 real(DP),
intent(in),
dimension(nodes) :: cnew
324 real(DP),
intent(in),
dimension(nodes) :: cold
325 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
328 integer(I4B) :: idiag
331 real(DP) :: vwatnew, vwatold, vcell, vsolid, term
332 real(DP) :: hhcof, rrhs
339 this%ratesto(n) =
dzero
342 if (this%ibound(n) <= 0) cycle
345 vcell = this%dis%area(n) * (this%dis%top(n) - this%dis%bot(n))
346 vwatnew = vcell * this%fmi%gwfsat(n) * this%porosity(n)
348 if (this%fmi%igwfstrgss /= 0) vwatold = vwatold + this%fmi%gwfstrgss(n) &
350 if (this%fmi%igwfstrgsy /= 0) vwatold = vwatold + this%fmi%gwfstrgsy(n) &
352 vsolid = vcell * (
done - this%porosity(n))
355 term = (this%rhos(n) * this%cps(n)) * vsolid
356 hhcof = -(this%eqnsclfac * vwatnew + term) * tled
357 rrhs = -(this%eqnsclfac * vwatold + term) * tled * cold(n)
358 rate = hhcof * cnew(n) - rrhs
359 this%ratesto(n) = rate
360 idiag = this%dis%con%ia(n)
361 flowja(idiag) = flowja(idiag) + rate
374 integer(I4B),
intent(in) :: nodes
375 real(DP),
intent(in),
dimension(nodes) :: cnew
376 real(DP),
intent(in),
dimension(nodes) :: cold
377 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
380 integer(I4B) :: idiag
383 real(DP) :: hhcof, rrhs
385 real(DP) :: decay_rate
393 this%ratedcy(n) =
dzero
394 if (this%ibound(n) <= 0) cycle
397 vcell = this%dis%area(n) * (this%dis%top(n) - this%dis%bot(n))
398 swtpdt = this%fmi%gwfsat(n)
404 if (this%idcy == 1)
then
405 hhcof = -this%decay(n) * vcell * swtpdt * this%porosity(n) &
407 elseif (this%idcy == 2)
then
409 0, cold(n), cnew(n),
delt)
410 rrhs = decay_rate * vcell * swtpdt * this%porosity(n)
412 rate = hhcof * cnew(n) - rrhs
413 this%ratedcy(n) = rate
414 idiag = this%dis%con%ia(n)
415 flowja(idiag) = flowja(idiag) + rate
424 subroutine est_bd(this, isuppress_output, model_budget)
430 integer(I4B),
intent(in) :: isuppress_output
431 type(
budgettype),
intent(inout) :: model_budget
438 call model_budget%addentry(rin, rout,
delt,
budtxt(1), &
439 isuppress_output, rowlabel=this%packName)
442 if (this%idcy /= 0)
then
444 call model_budget%addentry(rin, rout,
delt,
budtxt(2), &
445 isuppress_output, rowlabel=this%packName)
456 integer(I4B),
intent(in) :: icbcfl
457 integer(I4B),
intent(in) :: icbcun
459 integer(I4B) :: ibinun
461 integer(I4B) :: iprint, nvaluesp, nwidthp
462 character(len=1) :: cdatafmp =
' ', editdesc =
' '
466 if (this%ipakcb < 0)
then
468 elseif (this%ipakcb == 0)
then
473 if (icbcfl == 0) ibinun = 0
476 if (ibinun /= 0)
then
481 call this%dis%record_array(this%ratesto, this%iout, iprint, -ibinun, &
482 budtxt(1), cdatafmp, nvaluesp, &
483 nwidthp, editdesc, dinact)
486 if (this%idcy /= 0) &
487 call this%dis%record_array(this%ratedcy, this%iout, iprint, -ibinun, &
488 budtxt(2), cdatafmp, nvaluesp, &
489 nwidthp, editdesc, dinact)
504 if (this%inunit > 0)
then
516 this%ibound => null()
523 call this%NumericalPackageType%da()
538 call this%NumericalPackageType%allocate_scalars()
543 call mem_allocate(this%latheatvap,
'LATHEATVAP', this%memoryPath)
549 this%latheatvap =
dzero
563 integer(I4B),
intent(in) :: nodes
569 call mem_allocate(this%porosity, nodes,
'POROSITY', this%memoryPath)
570 call mem_allocate(this%ratesto, nodes,
'RATESTO', this%memoryPath)
571 call mem_allocate(this%cps, nodes,
'CPS', this%memoryPath)
572 call mem_allocate(this%rhos, nodes,
'RHOS', this%memoryPath)
575 if (this%idcy == 0)
then
576 call mem_allocate(this%ratedcy, 1,
'RATEDCY', this%memoryPath)
577 call mem_allocate(this%decay, 1,
'DECAY', this%memoryPath)
578 call mem_allocate(this%decaylast, 1,
'DECAYLAST', this%memoryPath)
580 call mem_allocate(this%ratedcy, this%dis%nodes,
'RATEDCY', this%memoryPath)
581 call mem_allocate(this%decay, nodes,
'DECAY', this%memoryPath)
582 call mem_allocate(this%decaylast, nodes,
'DECAYLAST', this%memoryPath)
587 this%porosity(n) =
dzero
588 this%ratesto(n) =
dzero
592 do n = 1,
size(this%decay)
593 this%decay(n) =
dzero
594 this%ratedcy(n) =
dzero
595 this%decaylast(n) =
dzero
609 character(len=LINELENGTH) :: keyword
611 logical :: isfound, endOfBlock
613 character(len=*),
parameter :: fmtisvflow = &
614 &
"(4x,'CELL-BY-CELL FLOW INFORMATION WILL BE SAVED TO BINARY "// &
615 &
"FILE WHENEVER ICBCFL IS NOT ZERO.')"
616 character(len=*),
parameter :: fmtidcy1 = &
617 "(4x,'FIRST-ORDER DECAY IS ACTIVE. ')"
618 character(len=*),
parameter :: fmtidcy2 = &
619 "(4x,'ZERO-ORDER DECAY IS ACTIVE. ')"
622 call this%parser%GetBlock(
'OPTIONS', isfound, ierr, blockrequired=.false., &
623 supportopenclose=.true.)
627 write (this%iout,
'(1x,a)')
'PROCESSING ENERGY STORAGE AND TRANSFER OPTIONS'
629 call this%parser%GetNextLine(endofblock)
631 call this%parser%GetStringCaps(keyword)
632 select case (keyword)
635 write (this%iout, fmtisvflow)
636 case (
'FIRST_ORDER_DECAY')
638 write (this%iout, fmtidcy1)
639 case (
'ZERO_ORDER_DECAY')
641 write (this%iout, fmtidcy2)
642 case (
'HEAT_CAPACITY_WATER')
643 this%cpw = this%parser%GetDouble()
644 if (this%cpw <= 0.0)
then
645 write (
errmsg,
'(a)')
'Specified value for the heat capacity of &
646 &water must be greater than 0.0.'
648 call this%parser%StoreErrorUnit()
650 write (this%iout,
'(4x,a,1pg15.6)') &
651 'Heat capacity of the water has been set to: ', &
654 case (
'DENSITY_WATER')
655 this%rhow = this%parser%GetDouble()
656 if (this%rhow <= 0.0)
then
657 write (
errmsg,
'(a)')
'Specified value for the density of &
658 &water must be greater than 0.0.'
660 call this%parser%StoreErrorUnit()
662 write (this%iout,
'(4x,a,1pg15.6)') &
663 'Density of the water has been set to: ', &
666 case (
'LATENT_HEAT_VAPORIZATION')
667 this%latheatvap = this%parser%GetDouble()
668 write (this%iout,
'(4x,a,1pg15.6)') &
669 'Latent heat of vaporization of the water has been set to: ', &
672 write (
errmsg,
'(a,a)')
'Unknown EST option: ', trim(keyword)
674 call this%parser%StoreErrorUnit()
677 write (this%iout,
'(1x,a)')
'END OF ENERGY STORAGE AND TRANSFER OPTIONS'
692 character(len=LINELENGTH) :: keyword
693 character(len=:),
allocatable :: line
694 integer(I4B) :: istart, istop, lloc, ierr
695 logical :: isfound, endOfBlock
696 logical,
dimension(4) :: lname
697 character(len=24),
dimension(4) :: aname
700 data aname(1)/
' MOBILE DOMAIN POROSITY'/
701 data aname(2)/
' DECAY RATE'/
702 data aname(3)/
' HEAT CAPACITY OF SOLIDS'/
703 data aname(4)/
' DENSITY OF SOLIDS'/
710 call this%parser%GetBlock(
'GRIDDATA', isfound, ierr)
712 write (this%iout,
'(1x,a)')
'PROCESSING GRIDDATA'
714 call this%parser%GetNextLine(endofblock)
716 call this%parser%GetStringCaps(keyword)
717 call this%parser%GetRemainingLine(line)
719 select case (keyword)
721 call this%dis%read_grid_array(line, lloc, istart, istop, this%iout, &
722 this%parser%iuactive, this%porosity, &
726 if (this%idcy == 0) &
728 trim(this%memoryPath))
729 call this%dis%read_grid_array(line, lloc, istart, istop, this%iout, &
730 this%parser%iuactive, this%decay, &
733 case (
'HEAT_CAPACITY_SOLID')
734 call this%dis%read_grid_array(line, lloc, istart, istop, this%iout, &
735 this%parser%iuactive, this%cps, &
738 case (
'DENSITY_SOLID')
739 call this%dis%read_grid_array(line, lloc, istart, istop, this%iout, &
740 this%parser%iuactive, this%rhos, &
744 write (
errmsg,
'(a,a)')
'Unknown griddata tag: ', trim(keyword)
746 call this%parser%StoreErrorUnit()
749 write (this%iout,
'(1x,a)')
'END PROCESSING GRIDDATA'
751 write (
errmsg,
'(a)')
'Required griddata block not found.'
753 call this%parser%StoreErrorUnit()
757 if (.not. lname(1))
then
758 write (
errmsg,
'(a)')
'Porosity not specified in griddata block.'
761 if (.not. lname(3))
then
762 write (
errmsg,
'(a)')
'HEAT_CAPACITY_SOLID not specified in griddata block.'
765 if (.not. lname(4))
then
766 write (
errmsg,
'(a)')
'DENSITY_SOLID not specified in griddata block.'
771 if (this%idcy > 0)
then
772 if (.not. lname(2))
then
773 write (
errmsg,
'(a)')
'First or zero order decay is &
774 &active but the first rate coefficient is not specified. Decay &
775 &must be specified in griddata block.'
780 write (
warnmsg,
'(a)')
'First or zero orer decay &
781 &is not active but decay was specified. Decay will &
782 &have no affect on simulation results.'
784 write (this%iout,
'(1x,a)')
'WARNING. '//
warnmsg
790 call this%parser%StoreErrorUnit()
803 cold, cnew, delt)
result(decay_rate)
805 real(dp),
intent(in) :: decay_rate_usr
806 real(dp),
intent(in) :: decay_rate_last
807 integer(I4B),
intent(in) :: kiter
808 real(dp),
intent(in) :: cold
809 real(dp),
intent(in) :: cnew
810 real(dp),
intent(in) :: delt
812 real(dp) :: decay_rate
815 if (decay_rate_usr <
dzero)
then
818 decay_rate = decay_rate_usr
825 decay_rate = min(decay_rate_usr, cold / delt)
827 decay_rate = decay_rate_last
828 if (cnew <
dzero)
then
829 decay_rate = decay_rate_last + cnew / delt
830 else if (cnew > cold)
then
831 decay_rate = decay_rate_last + cnew / delt
833 decay_rate = min(decay_rate_usr, decay_rate)
835 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 dep3
real constant 1000
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 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