MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
gwf-vsc.f90
Go to the documentation of this file.
1! Viscosity Package for representing variable-viscosity groundwater flow
2
4
5 use kindmodule, only: dp, i4b
14 use tdismodule, only: kper, kstp
16 use basedismodule, only: disbasetype
18 use listsmodule, only: basemodellist
19
20 implicit none
21
22 private
23 public :: gwfvsctype
24 public :: vsc_cr
25
27 real(dp), dimension(:), pointer :: conc => null() !< pointer to concentration array
28 integer(I4B), dimension(:), pointer :: icbund => null() !< store pointer to gwt ibound array
30
32 integer(I4B), pointer :: thermivisc => null() !< viscosity formulation flag (1:Linear, 2:Nonlinear)
33 integer(I4B), pointer :: idxtmpr => null() !< if greater than 0 then an index for identifying whether the "species" array is temperature
34 integer(I4B), pointer :: ioutvisc => null() !< unit number for saving viscosity
35 integer(I4B), pointer :: iconcset => null() !< if 1 then conc points to a gwt (or gwe) model%x array
36 integer(I4B), pointer :: ireadelev => null() !< if 1 then elev has been allocated and filled
37 integer(I4B), dimension(:), pointer, contiguous :: ivisc => null() !< viscosity formulation flag for each species (1:Linear, 2:Nonlinear)
38 real(dp), pointer :: viscref => null() !< reference fluid viscosity
39 real(dp), dimension(:), pointer, contiguous :: visc => null() !< viscosity
40 real(dp), dimension(:), pointer, contiguous :: elev => null() !< cell center elevation (optional; if not specified, then use (top+bot)/2)
41 integer(I4B), dimension(:), pointer :: ibound => null() !< store pointer to ibound
42
43 integer(I4B), pointer :: nviscspecies => null() !< number of concentration species used in viscosity equation
44 real(dp), dimension(:), pointer, contiguous :: dviscdc => null() !< linear change in viscosity with change in concentration
45 real(dp), dimension(:), pointer, contiguous :: cviscref => null() !< reference concentration used in viscosity equation
46 real(dp), dimension(:), pointer, contiguous :: ctemp => null() !< temporary array of size (nviscspec) to pass to calc_visc_x
47 character(len=LENMODELNAME), dimension(:), allocatable :: cmodelname !< names of gwt (or gwe) models used in viscosity equation
48 character(len=LENAUXNAME), dimension(:), allocatable :: cauxspeciesname !< names of aux columns used in viscosity equation
49 character(len=LENAUXNAME) :: name_temp_spec = 'TEMPERATURE'
50 !
51 ! -- Viscosity constants
52 real(dp), pointer :: a2 => null() !< an empirical parameter specified by the user for calculating viscosity
53 real(dp), pointer :: a3 => null() !< an empirical parameter specified by the user for calculating viscosity
54 real(dp), pointer :: a4 => null() !< an empirical parameter specified by the user for calculating viscosity
55
56 type(concentrationpointer), allocatable, dimension(:) :: modelconc !< concentration (or temperature) pointer for each solute (or heat) transport model
57
58 real(dp), dimension(:), pointer, contiguous :: k11 => null() !< NPF hydraulic conductivity; if anisotropic, then this is Kx prior to rotation
59 real(dp), dimension(:), pointer, contiguous :: k22 => null() !< NPF hydraulic conductivity; if specified then this is Ky prior to rotation
60 real(dp), dimension(:), pointer, contiguous :: k33 => null() !< NPF hydraulic conductivity; if specified then this is Kz prior to rotation
61 real(dp), dimension(:), pointer, contiguous :: k11input => null() !< NPF hydraulic conductivity before VSC adjustment, including TVK changes
62 real(dp), dimension(:), pointer, contiguous :: k22input => null() !< NPF hydraulic conductivity before VSC adjustment, including TVK changes
63 real(dp), dimension(:), pointer, contiguous :: k33input => null() !< NPF hydraulic conductivity before VSC adjustment, including TVK changes
64 integer(I4B), pointer :: kchangeper => null() ! last stress period in which any node K (or K22, or K33) values were changed (0 if unchanged from start of simulation)
65 integer(I4B), pointer :: kchangestp => null() ! last time step in which any node K (or K22, or K33) values were changed (0 if unchanged from start of simulation)
66 integer(I4B), dimension(:), pointer, contiguous :: nodekchange => null() ! grid array of flags indicating for each node whether its K (or K22, or K33) value changed (1) at (kchangeper, kchangestp) or not (0)
67
68 contains
69
70 procedure :: vsc_df
71 procedure :: vsc_ar
72 procedure, public :: vsc_ar_bnd
73 procedure :: vsc_rp
74 procedure :: vsc_ad
75 procedure, public :: vsc_ad_bnd
76 procedure :: vsc_ot_dv
77 procedure :: vsc_da
78 procedure, private :: vsc_calcvisc
79 procedure :: allocate_scalars
80 procedure, private :: allocate_arrays
81 procedure, private :: source_options
82 procedure, private :: set_options
83 procedure, private :: log_options
84 procedure, private :: source_dimensions
85 procedure, private :: source_packagedata
86 procedure, private :: set_packagedata
87 procedure, private :: set_npf_pointers
88 procedure, public :: update_k_with_vsc
89 procedure, private :: vsc_set_changed_at
90 procedure, public :: calc_q_visc
91 procedure, public :: get_visc_ratio
93 end type gwfvsctype
94
95contains
96
97 !> @brief Generic function to calculate changes in fluid viscosity using a
98 !! linear formulation
99 !<
100 function calc_visc(ivisc, viscref, dviscdc, cviscref, conc, &
101 a2, a3, a4) result(visc)
102 ! -- dummy
103 integer(I4B), dimension(:), intent(in) :: ivisc
104 real(dp), intent(in) :: viscref
105 real(dp), dimension(:), intent(in) :: dviscdc
106 real(dp), dimension(:), intent(in) :: cviscref
107 real(dp), dimension(:), intent(in) :: conc
108 real(dp), intent(in) :: a2, a3, a4
109 ! -- return
110 real(dp) :: visc
111 ! -- local
112 integer(I4B) :: nviscspec
113 integer(I4B) :: i
114 real(dp) :: mu_t
115 real(dp) :: expon
116 !
117 nviscspec = size(dviscdc)
118 visc = viscref
119 !
120 do i = 1, nviscspec
121 if (ivisc(i) == 1) then
122 visc = visc + dviscdc(i) * (conc(i) - cviscref(i))
123 else
124 expon = -1 * a3 * ((conc(i) - cviscref(i)) / &
125 ((conc(i) + a4) * (cviscref(i) + a4)))
126 mu_t = viscref * a2**expon
127 ! Order matters!! (This assumes we apply the temperature correction after
128 ! accounting for solute concentrations)
129 ! If a nonlinear correction is applied, then b/c it takes into account
130 ! viscref, need to subtract it in this case
131 ! At most, there will only ever be 1 nonlinear correction
132 visc = (visc - viscref) + mu_t
133 end if
134 ! end if
135 end do
136 end function calc_visc
137
138 !> @brief Create a new package object
139 !!
140 !! Create a new VSC Package object.
141 !<
142 subroutine vsc_cr(vscobj, name_model, input_mempath, inunit, iout)
143 ! -- dummy
144 type(gwfvsctype), pointer :: vscobj
145 character(len=*), intent(in) :: name_model
146 character(len=*), intent(in) :: input_mempath
147 integer(I4B), intent(in) :: inunit
148 integer(I4B), intent(in) :: iout
149 !
150 ! -- Create the object
151 allocate (vscobj)
152 !
153 ! -- create name and memory path
154 call vscobj%set_names(1, name_model, 'VSC', 'VSC', input_mempath)
155 !
156 ! -- Allocate scalars
157 call vscobj%allocate_scalars()
158 !
159 ! -- Set variables
160 vscobj%inunit = inunit
161 vscobj%iout = iout
162 end subroutine vsc_cr
163
164 !> @brief Define viscosity package options and dimensions
165 !!
166 !! Define viscosity package options and dimensions
167 !<
168 subroutine vsc_df(this, dis, vsc_input)
169 ! -- dummy
170 class(gwfvsctype) :: this !< this viscosity package
171 class(disbasetype), pointer, intent(in) :: dis !< pointer to discretization
172 type(gwfvscinputdatatype), optional, intent(in) :: vsc_input !< optional vsc input data, otherwise read from file
173 ! -- formats
174 character(len=*), parameter :: fmtvsc = &
175 "(1x,/1x,'VSC -- Viscosity Package, version 1, 11/15/2022', &
176 &' input read from mempath: ', a, /)"
177 !
178 ! --print a message identifying the viscosity package
179 write (this%iout, fmtvsc) this%input_mempath
180 !
181 ! -- store pointers to arguments that were passed in
182 this%dis => dis
183 !
184 if (.not. present(vsc_input)) then
185 !
186 ! -- Read viscosity options
187 call this%source_options()
188 !
189 ! -- Read viscosity dimensions
190 call this%source_dimensions()
191 else
192 ! set from input data instead
193 call this%set_options(vsc_input)
194 this%nviscspecies = vsc_input%nviscspecies
195 end if
196 !
197 ! -- Allocate arrays
198 call this%allocate_arrays(dis%nodes)
199 !
200 if (.not. present(vsc_input)) then
201 !
202 ! -- Read viscosity packagedata
203 call this%source_packagedata()
204 else
205 ! set from input data instead
206 call this%set_packagedata(vsc_input)
207 end if
208 end subroutine vsc_df
209
210 !> @brief Allocate and read method for viscosity package
211 !!
212 !! Generic method to allocate and read static data for the viscosity
213 !! package available within the GWF model type.
214 !<
215 subroutine vsc_ar(this, ibound)
216 ! -- dummy
217 class(gwfvsctype) :: this
218 integer(I4B), dimension(:), pointer :: ibound
219 !
220 ! -- store pointers to arguments that were passed in
221 this%ibound => ibound
222 !
223 ! -- Set pointers to npf variables
224 call this%set_npf_pointers()
225 end subroutine vsc_ar
226
227 !> @brief Activate viscosity in advanced packages
228 !!
229 !! Viscosity ar_bnd routine to activate viscosity in the advanced
230 !! packages. This routine is called from gwf_ar() as it moves through each
231 !! package
232 !<
233 subroutine vsc_ar_bnd(this, packobj)
234 ! -- modules
235 use bndmodule, only: bndtype
236 use drnmodule, only: drntype
237 use ghbmodule, only: ghbtype
238 use rivmodule, only: rivtype
239 use lakmodule, only: laktype
240 use sfrmodule, only: sfrtype
241 use mawmodule, only: mawtype
242 ! -- dummy
243 class(gwfvsctype) :: this
244 class(bndtype), pointer :: packobj
245 !
246 ! -- Add density terms based on boundary package type
247 select case (packobj%filtyp)
248 case ('DRN')
249 !
250 ! -- activate viscosity for the drain package
251 select type (packobj)
252 type is (drntype)
253 call packobj%bnd_activate_viscosity()
254 end select
255 case ('GHB')
256 !
257 ! -- activate viscosity for the drain package
258 select type (packobj)
259 type is (ghbtype)
260 call packobj%bnd_activate_viscosity()
261 end select
262 case ('RIV')
263 !
264 ! -- activate viscosity for the drain package
265 select type (packobj)
266 type is (rivtype)
267 call packobj%bnd_activate_viscosity()
268 end select
269 case ('LAK')
270 !
271 ! -- activate viscosity for lake package
272 select type (packobj)
273 type is (laktype)
274 call packobj%lak_activate_viscosity()
275 end select
276 case ('SFR')
277 !
278 ! -- activate viscosity for sfr package
279 select type (packobj)
280 type is (sfrtype)
281 call packobj%sfr_activate_viscosity()
282 end select
283 case ('MAW')
284 !
285 ! -- activate viscosity for maw package
286 select type (packobj)
287 type is (mawtype)
288 call packobj%maw_activate_viscosity()
289 end select
290 case default
291 !
292 ! -- nothing
293 end select
294 end subroutine vsc_ar_bnd
295
296 !> @brief Set pointers to NPF variables
297 !!
298 !! Set array and variable pointers from the NPF
299 !! package for access by VSC.
300 !<
301 subroutine set_npf_pointers(this)
302 ! -- dummy
303 class(gwfvsctype) :: this
304 ! -- local
305 character(len=LENMEMPATH) :: npfMemoryPath
306 !
307 ! -- Set pointers to other package variables
308 ! -- NPF
309 npfmemorypath = create_mem_path(this%name_model, 'NPF')
310 call mem_setptr(this%k11, 'K11', npfmemorypath)
311 call mem_setptr(this%k22, 'K22', npfmemorypath)
312 call mem_setptr(this%k33, 'K33', npfmemorypath)
313 call mem_setptr(this%k11input, 'K11INPUT', npfmemorypath)
314 call mem_setptr(this%k22input, 'K22INPUT', npfmemorypath)
315 call mem_setptr(this%k33input, 'K33INPUT', npfmemorypath)
316 call mem_setptr(this%kchangeper, 'KCHANGEPER', npfmemorypath)
317 call mem_setptr(this%kchangestp, 'KCHANGESTP', npfmemorypath)
318 call mem_setptr(this%nodekchange, 'NODEKCHANGE', npfmemorypath)
319 end subroutine set_npf_pointers
320
321 !> @brief Read new period data in viscosity package
322 !!
323 !! Method to read and prepare period data for the VSC package.
324 !<
325 subroutine vsc_rp(this)
326 ! -- modules
327 use tdismodule, only: kstp, kper
328 ! -- dummy
329 class(gwfvsctype) :: this
330 ! -- local
331 integer(I4B) :: i
332 ! -- formats
333 character(len=*), parameter :: fmtc = &
334 "('Viscosity Package does not have a concentration set &
335 &for species ',i0,'. One or more model names may be specified &
336 &incorrectly in the PACKAGEDATA block or a GWF-GWT exchange may need &
337 &to be activated.')"
338 !
339 ! -- Check to make sure all concentration pointers have been set
340 if (kstp * kper == 1) then
341 do i = 1, this%nviscspecies
342 if (.not. associated(this%modelconc(i)%conc)) then
343 write (errmsg, fmtc) i
344 call store_error(errmsg)
345 end if
346 end do
347 if (count_errors() > 0) then
348 call store_error_filename(this%input_fname)
349 end if
350 end if
351 end subroutine vsc_rp
352
353 !> @brief Advance the viscosity package
354 !!
355 !! Advance data in the VSC package. The method sets or advances time series,
356 !! time array series, and observation data.
357 !<
358 subroutine vsc_ad(this)
359 ! -- dummy
360 class(gwfvsctype) :: this
361 !
362 ! -- update viscosity using the latest concentration/temperature
363 call this%vsc_calcvisc()
364 end subroutine vsc_ad
365
366 !> @brief Advance the boundary packages when viscosity is active
367 !!
368 !! Update the conductance values associate with inflow from a boundary
369 !! when VSC package is active.
370 !<
371 subroutine vsc_ad_bnd(this, packobj, hnew)
372 ! -- modules
373 use bndmodule, only: bndtype
374 ! -- dummy
375 class(gwfvsctype) :: this
376 class(bndtype), pointer :: packobj
377 real(DP), intent(in), dimension(:) :: hnew
378 ! -- local
379 integer(I4B) :: i, j
380 integer(I4B) :: n, locvisc, locelev
381 integer(I4B), dimension(:), allocatable :: locconc
382 !
383 ! -- initialize
384 locvisc = 0
385 locelev = 0
386 allocate (locconc(this%nviscspecies))
387 locconc(:) = 0
388 !
389 ! -- Add viscosity terms for conductance-dependent boundaries
390 do n = 1, packobj%naux
391 if (packobj%auxname(n) == 'VISCOSITY') then
392 locvisc = n
393 else if (packobj%auxname(n) == 'ELEVATION') then
394 locelev = n
395 end if
396 end do
397 !
398 ! -- find aux columns for conc (or temp.) that affect viscosity
399 do i = 1, this%nviscspecies
400 locconc(i) = 0
401 do j = 1, packobj%naux
402 if (this%cauxspeciesname(i) == packobj%auxname(j)) then
403 locconc(i) = j
404 exit
405 end if
406 end do
407 if (locconc(i) == 0) then
408 ! -- one not found, so don't use and mark all as 0
409 locconc(:) = 0
410 exit
411 end if
412 end do
413 !
414 ! -- apply viscosity terms to inflow from boundary based on package type
415 select case (packobj%filtyp)
416 case ('GHB', 'DRN', 'RIV')
417 !
418 ! -- general head, drain, and river boundary
419 call vsc_ad_standard_bnd(packobj, hnew, this%visc, this%viscref, &
420 locelev, locvisc, locconc, this%dviscdc, &
421 this%cviscref, this%ivisc, this%a2, this%a3, &
422 this%a4, this%ctemp)
423 case ('LAK')
424 !
425 ! -- lake
426 ! Update 'viscratios' internal to lak such that they are
427 ! automatically applied in the LAK calc_cond() routine
428 call vsc_ad_lak(packobj, this%visc, this%viscref, this%elev, locvisc, &
429 locconc, this%dviscdc, this%cviscref, this%ivisc, &
430 this%a2, this%a3, this%a4, this%ctemp)
431 case ('SFR')
432 !
433 ! -- streamflow routing
434 ! Update 'viscratios' internal to sfr such that they are
435 ! automatically applied in the SFR calc_cond() routine
436 call vsc_ad_sfr(packobj, this%visc, this%viscref, this%elev, locvisc, &
437 locconc, this%dviscdc, this%cviscref, this%ivisc, &
438 this%a2, this%a3, this%a4, this%ctemp)
439 case ('MAW')
440 !
441 ! -- multi-aquifer well
442 call vsc_ad_maw(packobj, this%visc, this%viscref, this%elev, locvisc, &
443 locconc, this%dviscdc, this%cviscref, this%ivisc, &
444 this%a2, this%a3, this%a4, this%ctemp)
445 case ('UZF')
446 !
447 ! -- unsaturated-zone flow
448 case default
449 !
450 ! -- nothing
451 end select
452 !
453 ! -- deallocate
454 deallocate (locconc)
455 end subroutine vsc_ad_bnd
456
457 !> @brief advance ghb, drn and riv while accounting for viscosity
458 !!
459 !! Set the viscosity ratio that the package applies to each boundary
460 !! conductance
461 !<
462 subroutine vsc_ad_standard_bnd(packobj, hnew, visc, viscref, locelev, &
463 locvisc, locconc, dviscdc, cviscref, &
464 ivisc, a2, a3, a4, ctemp)
465 ! -- modules
466 use bndmodule, only: bndtype
467 class(bndtype), pointer :: packobj
468 ! -- dummy
469 real(DP), intent(in), dimension(:) :: hnew
470 real(DP), intent(in), dimension(:) :: visc
471 real(DP), intent(in) :: a2, a3, a4
472 real(DP), intent(in) :: viscref
473 integer(I4B), intent(in) :: locelev
474 integer(I4B), intent(in) :: locvisc
475 integer(I4B), dimension(:), intent(in) :: locconc
476 integer(I4B), dimension(:), intent(in) :: ivisc
477 real(DP), dimension(:), intent(in) :: dviscdc
478 real(DP), dimension(:), intent(in) :: cviscref
479 real(DP), dimension(:), intent(inout) :: ctemp
480 ! -- local
481 integer(I4B) :: n
482 real(DP) :: viscbnd
483 !
484 ! -- Set the viscosity ratio for each boundary
485 do n = 1, packobj%nbound
486 !
487 ! -- calculate the viscosity associated with the boundary
488 viscbnd = calc_bnd_viscosity(n, locvisc, locconc, viscref, dviscdc, &
489 cviscref, ctemp, ivisc, a2, a3, a4, &
490 packobj%auxvar)
491 !
492 ! -- viscosity ratio applied to the boundary conductance
493 packobj%viscratio(n) = calc_vsc_ratio(viscref, viscbnd)
494 end do
495 end subroutine vsc_ad_standard_bnd
496
497 !> @brief Update sfr-related viscosity ratios
498 !!
499 !! When the viscosity package is active, update the viscosity ratio that is
500 !! applied to the hydraulic conductivity specified in the SFR package
501 !<
502 subroutine vsc_ad_sfr(packobj, visc, viscref, elev, locvisc, locconc, &
503 dviscdc, cviscref, ivisc, a2, a3, a4, ctemp)
504 ! -- modules
505 use bndmodule, only: bndtype
506 use sfrmodule, only: sfrtype
507 class(bndtype), pointer :: packobj
508 ! -- dummy
509 real(DP), intent(in) :: viscref
510 real(DP), intent(in) :: a2, a3, a4
511 integer(I4B), intent(in) :: locvisc
512 integer(I4B), dimension(:), intent(in) :: locconc
513 integer(I4B), dimension(:), intent(in) :: ivisc
514 real(DP), dimension(:), intent(in) :: visc
515 real(DP), dimension(:), intent(in) :: elev
516 real(DP), dimension(:), intent(in) :: dviscdc
517 real(DP), dimension(:), intent(in) :: cviscref
518 real(DP), dimension(:), intent(inout) :: ctemp
519 ! -- local
520 integer(I4B) :: n
521 integer(I4B) :: node
522 real(DP) :: viscsfr
523 !
524 ! -- update viscosity ratios for updating hyd. cond (and conductance)
525 select type (packobj)
526 type is (sfrtype)
527 do n = 1, packobj%nbound
528 !
529 ! -- get gwf node number
530 node = packobj%nodelist(n)
531 !
532 ! -- Check if boundary cell is active, cycle if not
533 if (packobj%ibound(node) <= 0) cycle
534 !
535 ! --
536 !
537 ! -- calculate the viscosity associated with the boundary
538 viscsfr = calc_bnd_viscosity(n, locvisc, locconc, viscref, dviscdc, &
539 cviscref, ctemp, ivisc, a2, a3, a4, &
540 packobj%auxvar)
541 !
542 ! -- fill sfr relative viscosity into column 1 of viscratios
543 packobj%viscratios(1, n) = calc_vsc_ratio(viscref, viscsfr)
544 !
545 ! -- fill gwf relative viscosity into column 2 of viscratios
546 packobj%viscratios(2, n) = calc_vsc_ratio(viscref, visc(node))
547 end do
548 end select
549 end subroutine vsc_ad_sfr
550
551 !> @brief Update lak-related viscosity ratios
552 !!
553 !! When the viscosity package is active, update the viscosity ratio that is
554 !! applied to the lakebed conductance calculated in the LAK package
555 !<
556 subroutine vsc_ad_lak(packobj, visc, viscref, elev, locvisc, locconc, &
557 dviscdc, cviscref, ivisc, a2, a3, a4, ctemp)
558 ! -- modules
559 use bndmodule, only: bndtype
560 use lakmodule, only: laktype
561 class(bndtype), pointer :: packobj
562 ! -- dummy
563 real(DP), intent(in) :: viscref
564 real(DP), intent(in) :: a2, a3, a4
565 integer(I4B), intent(in) :: locvisc
566 integer(I4B), dimension(:), intent(in) :: locconc
567 integer(I4B), dimension(:), intent(in) :: ivisc
568 real(DP), dimension(:), intent(in) :: visc
569 real(DP), dimension(:), intent(in) :: elev
570 real(DP), dimension(:), intent(in) :: dviscdc
571 real(DP), dimension(:), intent(in) :: cviscref
572 real(DP), dimension(:), intent(inout) :: ctemp
573 ! -- local
574 integer(I4B) :: n
575 integer(I4B) :: node
576 real(DP) :: visclak
577 !
578 ! -- update viscosity ratios for updating hyd. cond (and conductance)
579 select type (packobj)
580 type is (laktype)
581 do n = 1, packobj%nbound
582 !
583 ! -- get gwf node number
584 node = packobj%nodelist(n)
585 !
586 ! -- Check if boundary cell is active, cycle if not
587 if (packobj%ibound(node) <= 0) cycle
588 !
589 ! --
590 !
591 ! -- calculate the viscosity associated with the boundary
592 visclak = calc_bnd_viscosity(n, locvisc, locconc, viscref, dviscdc, &
593 cviscref, ctemp, ivisc, a2, a3, a4, &
594 packobj%auxvar)
595 !
596 ! -- fill lak relative viscosity into column 1 of viscratios
597 packobj%viscratios(1, n) = calc_vsc_ratio(viscref, visclak)
598 !
599 ! -- fill gwf relative viscosity into column 2 of viscratios
600 packobj%viscratios(2, n) = calc_vsc_ratio(viscref, visc(node))
601 end do
602 end select
603 end subroutine vsc_ad_lak
604
605 !> @brief Update maw-related viscosity ratios
606 !!
607 !! When the viscosity package is active, update the viscosity ratio that is
608 !! applied to the conductance calculated in the MAW package
609 !<
610 subroutine vsc_ad_maw(packobj, visc, viscref, elev, locvisc, locconc, &
611 dviscdc, cviscref, ivisc, a2, a3, a4, ctemp)
612 ! -- modules
613 use bndmodule, only: bndtype
614 use mawmodule, only: mawtype
615 class(bndtype), pointer :: packobj
616 ! -- dummy
617 real(DP), intent(in) :: viscref
618 real(DP), intent(in) :: a2, a3, a4
619 integer(I4B), intent(in) :: locvisc
620 integer(I4B), dimension(:), intent(in) :: locconc
621 integer(I4B), dimension(:), intent(in) :: ivisc
622 real(DP), dimension(:), intent(in) :: visc
623 real(DP), dimension(:), intent(in) :: elev
624 real(DP), dimension(:), intent(in) :: dviscdc
625 real(DP), dimension(:), intent(in) :: cviscref
626 real(DP), dimension(:), intent(inout) :: ctemp
627 ! -- local
628 integer(I4B) :: n
629 integer(I4B) :: node
630 real(DP) :: viscmaw
631 !
632 ! -- update viscosity ratios for updating hyd. cond (and conductance)
633 select type (packobj)
634 type is (mawtype)
635 do n = 1, packobj%nbound
636 !
637 ! -- get gwf node number
638 node = packobj%nodelist(n)
639 !
640 ! -- Check if boundary cell is active, cycle if not
641 if (packobj%ibound(node) <= 0) cycle
642 !
643 ! --
644 !
645 ! -- calculate the viscosity associated with the boundary
646 viscmaw = calc_bnd_viscosity(n, locvisc, locconc, viscref, dviscdc, &
647 cviscref, ctemp, ivisc, a2, a3, a4, &
648 packobj%auxvar)
649 !
650 ! -- fill lak relative viscosity into column 1 of viscratios
651 packobj%viscratios(1, n) = calc_vsc_ratio(viscref, viscmaw)
652 !
653 ! -- fill gwf relative viscosity into column 2 of viscratios
654 packobj%viscratios(2, n) = calc_vsc_ratio(viscref, visc(node))
655 end do
656 end select
657 end subroutine vsc_ad_maw
658
659 !> @brief calculate and return the viscosity ratio
660 !<
661 function calc_vsc_ratio(viscref, bndvisc) result(viscratio)
662 ! -- dummy
663 real(dp), intent(in) :: viscref
664 real(dp), intent(in) :: bndvisc
665 ! -- local
666 real(dp) :: viscratio
667 !
668 viscratio = viscref / bndvisc
669 end function calc_vsc_ratio
670
671 !> @brief Calculate the boundary viscosity
672 !!
673 !! Return the viscosity of the boundary package using one of
674 !! the options in the following order of priority:
675 !! 1. Assign as aux variable in column with name 'VISCOSITY'
676 !! 2. Calculate using viscosity equation and nviscspecies aux columns
677 !! 3. If neither of those, then assign as viscref !!
678 !<
679 function calc_bnd_viscosity(n, locvisc, locconc, viscref, dviscdc, cviscref, &
680 ctemp, ivisc, a2, a3, a4, auxvar) result(viscbnd)
681 ! -- modules
682 ! -- dummy
683 integer(I4B), intent(in) :: n
684 integer(I4B), intent(in) :: locvisc
685 real(dp), intent(in) :: a2, a3, a4
686 integer(I4B), dimension(:), intent(in) :: ivisc
687 integer(I4B), dimension(:), intent(in) :: locconc
688 real(dp), intent(in) :: viscref
689 real(dp), dimension(:), intent(in) :: dviscdc
690 real(dp), dimension(:), intent(in) :: cviscref
691 real(dp), dimension(:), intent(inout) :: ctemp
692 real(dp), dimension(:, :), intent(in) :: auxvar
693 ! -- Return
694 real(dp) :: viscbnd
695 ! -- local
696 integer(I4B) :: i
697 !
698 ! -- assign boundary viscosity based on one of three options
699 if (locvisc > 0) then
700 ! -- assign viscosity to an aux column named 'VISCOSITY'
701 viscbnd = auxvar(locvisc, n)
702 else if (locconc(1) > 0) then
703 ! -- calculate viscosity using one or more concentration auxcolumns
704 do i = 1, size(locconc)
705 ctemp(i) = dzero
706 if (locconc(i) > 0) then
707 ctemp(i) = auxvar(locconc(i), n)
708 end if
709 end do
710 viscbnd = calc_visc(ivisc, viscref, dviscdc, cviscref, ctemp, a2, a3, a4)
711 else
712 ! -- neither of the above, so assign as viscref
713 viscbnd = viscref
714 end if
715 end function calc_bnd_viscosity
716
717 !> @brief Calculate the viscosity ratio
718 !!
719 !! Calculate the viscosity ratio applied to the hydraulic characteristic
720 !! provided by the user. The viscosity ratio is applicable only
721 !! when the hydraulic characteristic is specified as positive and will not
722 !! be applied when the hydchr is negative
723 !<
724 subroutine get_visc_ratio(this, n, m, gwhdn, gwhdm, viscratio)
725 ! -- modules
726 use constantsmodule, only: done
727 ! -- dummy
728 class(gwfvsctype) :: this
729 integer(I4B), intent(in) :: n, m
730 real(DP), intent(in) :: gwhdn, gwhdm
731 real(DP), intent(inout) :: viscratio
732 ! -- loca
733 integer(I4B) :: cellid
734 !
735 viscratio = done
736 if (gwhdm > gwhdn) then
737 cellid = m
738 else if (gwhdn >= gwhdm) then
739 cellid = n
740 end if
741 call this%calc_q_visc(cellid, viscratio)
742 end subroutine get_visc_ratio
743
744 !> @brief Account for viscosity in the aquifer hydraulic flow barriers
745 !!
746 !! Will return the viscosity associated with the upgradient node (cell)
747 !! to the HFB package for adjusting the hydraulic characteristic (hydchr)
748 !! of the barrier
749 !<
750 subroutine calc_q_visc(this, cellid, viscratio)
751 ! -- dummy variables
752 class(gwfvsctype) :: this
753 integer(I4B), intent(in) :: cellid
754 ! -- Return
755 real(DP), intent(inout) :: viscratio
756 ! -- local
757 real(DP) :: visc
758 !
759 ! -- Retrieve viscosity for the passed node number
760 visc = this%visc(cellid)
761 !
762 ! -- Calculate the viscosity ratio for the
763 viscratio = calc_vsc_ratio(this%viscref, visc)
764 end subroutine calc_q_visc
765
766 !> @brief Appled the viscosity ratio (mu_o/mu) to the hydraulic conductivity
767 !!
768 !! This routine called after updating the viscosity values using the latest
769 !! concentration and/or temperature values. The ratio mu_o/mu, reference
770 !! viscosity divided by the updated viscosity value, is multiplied by K
771 !! for each cell.
772 !<
773 subroutine update_k_with_vsc(this)
774 ! -- dummy
775 class(gwfvsctype) :: this
776 ! -- local
777 integer(I4B) :: n
778 real(DP) :: viscratio
779 !
780 ! -- For viscosity-based K's, apply change of K to K11 by starting with
781 ! K before VSC adjustment (including TVK changes) and not the K's
782 ! leftover from the last viscosity update.
783 do n = 1, this%dis%nodes
784 call this%calc_q_visc(n, viscratio)
785 this%k11(n) = this%k11input(n) * viscratio
786 this%k22(n) = this%k22input(n) * viscratio
787 this%k33(n) = this%k33input(n) * viscratio
788 this%nodekchange(n) = 1
789 end do
790 !
791 ! -- Flag kchange
792 call this%vsc_set_changed_at(kper, kstp)
793 end subroutine update_k_with_vsc
794
795 !> @brief Mark K changes as having occurred at (kper, kstp)
796 !!
797 !! Procedure called by VSC code when K updated due to viscosity changes.
798 !! K values changed at (kper, kstp).
799 !<
800 subroutine vsc_set_changed_at(this, kper, kstp)
801 ! -- dummy variables
802 class(gwfvsctype) :: this
803 integer(I4B), intent(in) :: kper
804 integer(I4B), intent(in) :: kstp
805 !
806 this%kchangeper = kper
807 this%kchangestp = kstp
808 end subroutine vsc_set_changed_at
809
810 !> @brief Output viscosity package dependent-variable terms.
811 !!
812 !! Save calculated viscosity array to binary file
813 !<
814 subroutine vsc_ot_dv(this, idvfl)
815 ! -- dummy
816 class(gwfvsctype) :: this
817 integer(I4B), intent(in) :: idvfl
818 ! -- local
819 character(len=1) :: cdatafmp = ' ', editdesc = ' '
820 integer(I4B) :: ibinun
821 integer(I4B) :: iprint
822 integer(I4B) :: nvaluesp
823 integer(I4B) :: nwidthp
824 real(DP) :: dinact
825 !
826 ! -- Set unit number for viscosity output
827 if (this%ioutvisc /= 0) then
828 ibinun = 1
829 else
830 ibinun = 0
831 end if
832 if (idvfl == 0) ibinun = 0
833 !
834 ! -- save viscosity array
835 if (ibinun /= 0) then
836 iprint = 0
837 dinact = dhnoflo
838 !
839 ! -- write viscosity to binary file
840 if (this%ioutvisc /= 0) then
841 ibinun = this%ioutvisc
842 call this%dis%record_array(this%visc, this%iout, iprint, ibinun, &
843 ' VISCOSITY', cdatafmp, nvaluesp, &
844 nwidthp, editdesc, dinact)
845 end if
846 end if
847 end subroutine vsc_ot_dv
848
849 !> @brief Deallocate viscosity package memory
850 !!
851 !! Deallocate viscosity package scalars and arrays.
852 !<
853 subroutine vsc_da(this)
854 ! -- dummy
855 class(gwfvsctype) :: this
856 !
857 ! -- Deallocate arrays if package was active
858 if (this%inunit > 0) then
859 call mem_deallocate(this%visc)
860 call mem_deallocate(this%ivisc)
861 call mem_deallocate(this%dviscdc)
862 call mem_deallocate(this%cviscref)
863 call mem_deallocate(this%ctemp)
864 deallocate (this%cmodelname)
865 deallocate (this%cauxspeciesname)
866 deallocate (this%modelconc)
867 end if
868 !
869 ! -- Scalars
870 call mem_deallocate(this%thermivisc)
871 call mem_deallocate(this%idxtmpr)
872 call mem_deallocate(this%ioutvisc)
873 call mem_deallocate(this%ireadelev)
874 call mem_deallocate(this%iconcset)
875 call mem_deallocate(this%viscref)
876 call mem_deallocate(this%nviscspecies)
877 call mem_deallocate(this%a2)
878 call mem_deallocate(this%a3)
879 call mem_deallocate(this%a4)
880 !
881 ! -- Nullify pointers to other package variables
882 nullify (this%k11)
883 nullify (this%k22)
884 nullify (this%k33)
885 nullify (this%k11input)
886 nullify (this%k22input)
887 nullify (this%k33input)
888 nullify (this%kchangeper)
889 nullify (this%kchangestp)
890 nullify (this%nodekchange)
891 !
892 ! -- deallocate parent
893 call this%NumericalPackageType%da()
894 end subroutine vsc_da
895
896 !> @brief Source dimensions for package
897 !<
898 subroutine source_dimensions(this)
899 ! -- modules
902 ! -- dummy
903 class(gwfvsctype), intent(inout) :: this
904 ! -- local
905 type(gwfvscparamfoundtype) :: found
906
907 ! update defaults from input context
908 call mem_set_value(this%nviscspecies, 'NVISCSPECIES', this%input_mempath, &
909 found%nviscspecies)
910
911 ! log dimensions
912 write (this%iout, '(/1x,a)') 'Processing VSC DIMENSIONS block'
913 write (this%iout, '(4x,a,i0)') 'NVISCSPECIES = ', this%nviscspecies
914 write (this%iout, '(1x,a)') 'End of VSC DIMENSIONS block'
915
916 ! check dimension
917 if (this%nviscspecies < 1) then
918 call store_error('NVISCSPECIES must be greater than zero.')
919 call store_error_filename(this%input_fname)
920 end if
921 end subroutine source_dimensions
922
923 !> @brief source packagedata for package
924 !<
925 subroutine source_packagedata(this)
926 ! -- modules
930 ! -- dummy
931 class(gwfvsctype), intent(inout) :: this
932 integer(I4B), dimension(:), pointer, contiguous :: iviscspec
933 type(characterstringtype), dimension(:), pointer, &
934 contiguous :: modelnames, auxspeciesnames
935 real(DP), dimension(:), pointer, contiguous :: dviscdc, cviscref
936 integer(I4B), dimension(:), allocatable :: itemp
937 character(len=LINELENGTH) :: modelname, auxspeciesname, line
938 character(len=10) :: c10
939 character(len=16) :: c16
940 integer(I4B) :: n
941 ! -- format
942 character(len=*), parameter :: fmterr = &
943 "('Invalid value for IRHOSPEC (',i0,') detected in VSC Package. &
944 &IRHOSPEC must be > 0 and <= NVISCSPECIES, and duplicate values &
945 &are not allowed.')"
946
947 ! initialize
948 allocate (itemp(this%nviscspecies))
949 itemp(:) = 0
950
951 ! set input context pointers
952 call mem_setptr(iviscspec, 'IVISCSPEC', this%input_mempath)
953 call mem_setptr(dviscdc, 'DVISCDC', this%input_mempath)
954 call mem_setptr(cviscref, 'CVISCREF', this%input_mempath)
955 call mem_setptr(modelnames, 'MODELNAME', this%input_mempath)
956 call mem_setptr(auxspeciesnames, 'AUXSPECIESNAME', this%input_mempath)
957
958 ! process package data
959 do n = 1, size(iviscspec)
960 modelname = modelnames(n)
961 auxspeciesname = auxspeciesnames(n)
962
963 if (iviscspec(n) < 1 .or. iviscspec(n) > this%nviscspecies) then
964 write (errmsg, fmterr) iviscspec(n)
965 call store_error(errmsg)
966 end if
967 if (itemp(iviscspec(n)) /= 0) then
968 write (errmsg, fmterr) iviscspec(n)
969 call store_error(errmsg)
970 end if
971 itemp(iviscspec(n)) = 1
972 !
973 this%dviscdc(iviscspec(n)) = dviscdc(n)
974 this%cviscref(iviscspec(n)) = cviscref(n)
975 this%cmodelname(iviscspec(n)) = trim(modelname)
976 this%cauxspeciesname(iviscspec(n)) = trim(auxspeciesname)
977 !
978 if (auxspeciesname == this%name_temp_spec) then
979 if (this%idxtmpr > 0) then
980 write (errmsg, '(a)') 'More than one species in VSC input identified &
981 &as '//trim(this%name_temp_spec)//'. Only one species may be &
982 &designated to represent temperature.'
983 call store_error(errmsg)
984 else
985 this%idxtmpr = iviscspec(n)
986 if (this%thermivisc == 2) then
987 this%ivisc(iviscspec(n)) = 2
988 end if
989 end if
990 end if
991 end do
992
993 ! Check for errors.
994 if (count_errors() > 0) then
995 call store_error_filename(this%input_fname)
996 end if
997
998 ! log package data
999 write (this%iout, '(/,1x,a)') 'Processing VSC PACKAGEDATA block'
1000
1001 ! write packagedata information
1002 write (this%iout, '(1x,a)') 'Summary of species information in VSC Package'
1003 write (this%iout, '(1a11,5a17)') &
1004 'Species', 'DVISCDC', 'CVISCREF', 'Model', 'AUXSPECIESNAME'
1005 do n = 1, this%nviscspecies
1006 write (c10, '(i0)') n
1007 line = ' '//adjustr(c10)
1008
1009 write (c16, '(g15.6)') this%dviscdc(n)
1010 line = trim(line)//' '//adjustr(c16)
1011 write (c16, '(g15.6)') this%cviscref(n)
1012 line = trim(line)//' '//adjustr(c16)
1013 write (c16, '(a)') this%cmodelname(n)
1014 line = trim(line)//' '//adjustr(c16)
1015 write (c16, '(a)') this%cauxspeciesname(n)
1016 line = trim(line)//' '//adjustr(c16)
1017 write (this%iout, '(a)') trim(line)
1018 end do
1019
1020 write (this%iout, '(1x,a)') 'End of VSC PACKAGEDATA block'
1021
1022 ! deallocate
1023 deallocate (itemp)
1024
1025 call memorystore_release('IVISCSPEC', this%input_mempath)
1026 call memorystore_release('DVISCDC', this%input_mempath)
1027 call memorystore_release('CVISCREF', this%input_mempath)
1028 call memorystore_release('MODELNAME', this%input_mempath)
1029 call memorystore_release('AUXSPECIESNAME', this%input_mempath)
1030 end subroutine source_packagedata
1031
1032 !> @brief Sets package data instead of reading from file
1033 !<
1034 subroutine set_packagedata(this, input_data)
1035 ! -- dummy
1036 class(gwfvsctype) :: this !< this vscoancy pkg
1037 type(gwfvscinputdatatype), intent(in) :: input_data !< the input data to be set
1038 ! -- local
1039 integer(I4B) :: ispec
1040 !
1041 do ispec = 1, this%nviscspecies
1042 this%dviscdc(ispec) = input_data%dviscdc(ispec)
1043 this%cviscref(ispec) = input_data%cviscref(ispec)
1044 this%cmodelname(ispec) = input_data%cmodelname(ispec)
1045 this%cauxspeciesname(ispec) = input_data%cauxspeciesname(ispec)
1046 end do
1047 end subroutine set_packagedata
1048
1049 !> @brief Calculate fluid viscosity
1050 !!
1051 !! Calculates fluid viscosity based on concentration or
1052 !! temperature
1053 !<
1054 subroutine vsc_calcvisc(this)
1055 ! -- dummy
1056 class(gwfvsctype) :: this
1057 ! -- local
1058 integer(I4B) :: n
1059 integer(I4B) :: i
1060 !
1061 ! -- Calculate the viscosity using the specified concentration and/or
1062 ! temperature arrays
1063 do n = 1, this%dis%nodes
1064 do i = 1, this%nviscspecies
1065 if (this%modelconc(i)%icbund(n) == 0) then
1066 this%ctemp(i) = dzero
1067 else
1068 this%ctemp(i) = this%modelconc(i)%conc(n)
1069 end if
1070 end do
1071 !
1072 this%visc(n) = calc_visc(this%ivisc, this%viscref, this%dviscdc, &
1073 this%cviscref, this%ctemp, this%a2, &
1074 this%a3, this%a4)
1075 end do
1076 end subroutine vsc_calcvisc
1077
1078 !> @brief Allocate scalars
1079 !!
1080 !! Allocate and initialize scalars for the VSC package. The base model
1081 !! allocate scalars method is also called.
1082 !<
1083 subroutine allocate_scalars(this)
1084 ! -- modules
1085 use constantsmodule, only: dzero, dten, dep3
1086 ! -- dummy
1087 class(gwfvsctype) :: this
1088 !
1089 ! -- allocate scalars in NumericalPackageType
1090 call this%NumericalPackageType%allocate_scalars()
1091 !
1092 ! -- Allocate
1093 call mem_allocate(this%thermivisc, 'THERMIVISC', this%memoryPath)
1094 call mem_allocate(this%idxtmpr, 'IDXTMPR', this%memoryPath)
1095 call mem_allocate(this%ioutvisc, 'IOUTVISC', this%memoryPath)
1096 call mem_allocate(this%ireadelev, 'IREADELEV', this%memoryPath)
1097 call mem_allocate(this%iconcset, 'ICONCSET', this%memoryPath)
1098 call mem_allocate(this%viscref, 'VISCREF', this%memoryPath)
1099 call mem_allocate(this%a2, 'A2', this%memoryPath)
1100 call mem_allocate(this%a3, 'A3', this%memoryPath)
1101 call mem_allocate(this%a4, 'A4', this%memoryPath)
1102 !
1103 call mem_allocate(this%nviscspecies, 'NVISCSPECIES', this%memoryPath)
1104 !
1105 ! -- Initialize
1106 this%thermivisc = 0
1107 this%idxtmpr = 0
1108 this%ioutvisc = 0
1109 this%ireadelev = 0
1110 this%iconcset = 0
1111 this%viscref = dep3
1112 this%A2 = dten
1113 this%A3 = 248.37_dp
1114 this%A4 = 133.15_dp
1115 !
1116 this%nviscspecies = 0
1117 end subroutine allocate_scalars
1118
1119 !> @brief Allocate arrays
1120 !!
1121 !! Allocate and initialize arrays for the VSC package.
1122 !<
1123 subroutine allocate_arrays(this, nodes)
1124 ! -- dummy
1125 class(gwfvsctype) :: this
1126 integer(I4B), intent(in) :: nodes
1127 ! -- local
1128 integer(I4B) :: i
1129 !
1130 ! -- Allocate
1131 call mem_allocate(this%visc, nodes, 'VISC', this%memoryPath)
1132 call mem_allocate(this%ivisc, this%nviscspecies, 'IVISC', this%memoryPath)
1133 call mem_allocate(this%dviscdc, this%nviscspecies, 'DRHODC', &
1134 this%memoryPath)
1135 call mem_allocate(this%cviscref, this%nviscspecies, 'CRHOREF', &
1136 this%memoryPath)
1137 call mem_allocate(this%ctemp, this%nviscspecies, 'CTEMP', this%memoryPath)
1138 allocate (this%cmodelname(this%nviscspecies))
1139 allocate (this%cauxspeciesname(this%nviscspecies))
1140 allocate (this%modelconc(this%nviscspecies))
1141 !
1142 ! -- Initialize
1143 do i = 1, nodes
1144 this%visc(i) = this%viscref
1145 end do
1146 !
1147 ! -- Initialize nviscspecies arrays
1148 do i = 1, this%nviscspecies
1149 this%ivisc(i) = 1
1150 this%dviscdc(i) = dzero
1151 this%cviscref(i) = dzero
1152 this%ctemp(i) = dzero
1153 this%cmodelname(i) = ''
1154 this%cauxspeciesname(i) = ''
1155 end do
1156 end subroutine allocate_arrays
1157
1158 !> @brief Source VSC options
1159 !<
1160 subroutine source_options(this)
1161 ! -- modules
1162 use constantsmodule, only: lenvarname
1164 use openspecmodule, only: access, form
1167 ! -- dummy
1168 class(gwfvsctype), intent(inout) :: this
1169 ! -- local
1170 character(len=LENVARNAME), dimension(2) :: thermal_form = &
1171 &[character(len=LENVARNAME) :: 'LINEAR', 'NONLINEAR']
1172 character(len=linelength) :: viscosityfile
1173 type(gwfvscparamfoundtype) :: found
1174
1175 ! initialize variables
1176 viscosityfile = ''
1177
1178 ! update defaults from input context
1179 call mem_set_value(this%viscref, 'VISCREF', this%input_mempath, &
1180 found%viscref)
1181 call mem_set_value(viscosityfile, 'VISCOSITYFILE', this%input_mempath, &
1182 found%viscosityfile)
1183 call mem_set_value(this%name_temp_spec, 'TEMP_SPECNAME', this%input_mempath, &
1184 found%temp_specname)
1185 call mem_set_value(this%thermivisc, 'THERMAL_FORM', this%input_mempath, &
1186 thermal_form, found%thermal_form)
1187 call mem_set_value(this%a2, 'THERMAL_A2', this%input_mempath, &
1188 found%thermal_a2)
1189 call mem_set_value(this%a3, 'THERMAL_A3', this%input_mempath, &
1190 found%thermal_a3)
1191 call mem_set_value(this%a4, 'THERMAL_A4', this%input_mempath, &
1192 found%thermal_a4)
1193
1194 ! fileout options
1195 if (found%viscosityfile) then
1196 this%ioutvisc = getunit()
1197 call openfile(this%ioutvisc, this%iout, viscosityfile, 'DATA(BINARY)', &
1198 form, access, 'REPLACE')
1199 end if
1200
1201 ! -- verify THERMAL_FORM input value is supported
1202 if (found%thermal_form) then
1203 if (this%thermivisc == 0) then
1204 call store_error('Unrecognized input value for THERMAL_FORM option.')
1205 call store_error_filename(this%input_fname)
1206 end if
1207 end if
1208
1209 ! set warnings and errors
1210 if (this%thermivisc == 1) then
1211 if (this%a2 == 0.0) then
1212 write (errmsg, '(a)') 'LINEAR option selected for varying &
1213 &viscosity with temperature, but A1, a surrogate for &
1214 &dVISC/dT, set equal to 0.0'
1215 call store_error(errmsg)
1216 call store_error_filename(this%input_fname)
1217 end if
1218 end if
1219 if (this%thermivisc > 1) then
1220 if (this%a2 == 0) then
1221 write (warnmsg, '(a)') 'NONLINEAR option selected for &
1222 &varying viscosity with temperature, but A2 set equal to &
1223 &zero which may lead to unintended values for viscosity'
1225 end if
1226 if (this%a3 == 0) then
1227 write (warnmsg, '(a)') 'NONLINEAR option selected for &
1228 &varying viscosity with temperature,, but A3 set equal to &
1229 &zero which may lead to unintended values for viscosity'
1231 end if
1232 if (this%a4 == 0) then
1233 write (warnmsg, '(a)') 'NONLINEAR option selected for &
1234 &varying viscosity with temperature, BUT A4 SET EQUAL TO &
1235 &zero which may lead to unintended values for viscosity'
1237 end if
1238 end if
1239
1240 ! log options
1241 call this%log_options(found, viscosityfile)
1242 end subroutine source_options
1243
1244 !> @brief log VSC options
1245 !<
1246 subroutine log_options(this, found, viscosityfile)
1247 ! -- modules
1249 ! -- dummy variables
1250 class(gwfvsctype), intent(inout) :: this
1251 type(gwfvscparamfoundtype), intent(in) :: found
1252 character(len=*), intent(in) :: viscosityfile
1253 ! -- local variables
1254 ! -- formats
1255 character(len=*), parameter :: fmtfileout = &
1256 "(4x, 'VSC', 1x, a, 1x, 'Will be saved to file: ', &
1257 &a, ' opened on unit: ', I7)"
1258 character(len=*), parameter :: fmtlinear = &
1259 "(4x,'Viscosity will vary linearly with temperature &
1260 &change ')"
1261 character(len=*), parameter :: fmtnonlinear = &
1262 "(4x,'Viscosity will vary non-linearly with temperature &
1263 &change ')"
1264
1265 write (this%iout, '(1x,a)') 'Processing VSC OPTIONS block'
1266
1267 if (found%viscref) then
1268 write (this%iout, '(4x,a,1pg15.6)') &
1269 'Reference viscosity has been set to: ', this%viscref
1270 end if
1271 if (found%viscosityfile) then
1272 write (this%iout, fmtfileout) &
1273 'VISCOSITY', trim(viscosityfile), this%ioutvisc
1274 end if
1275 if (found%temp_specname) then
1276 write (this%iout, '(4x, a)') 'Temperature species name set to: '// &
1277 trim(this%name_temp_spec)
1278 end if
1279 if (found%thermal_form) then
1280 select case (this%thermivisc)
1281 case (1)
1282 write (this%iout, fmtlinear)
1283 case (2)
1284 write (this%iout, fmtnonlinear)
1285 end select
1286 end if
1287 if (found%thermal_a2) then
1288 if (this%thermivisc == 2) then
1289 write (this%iout, '(4x,a,1pg15.6)') &
1290 'A2 in nonlinear viscosity formulation has been set to: ', &
1291 this%a2
1292 else
1293 write (this%iout, '(4x,a,/,4x,a,/,4x,a)') 'THERMAL_A2 specified by user &
1294 &in VSC Package input file. LINEAR viscosity ', 'formulation also &
1295 &specified. THERMAL_A2 will not affect ', 'viscosity calculations.'
1296 end if
1297 end if
1298 if (found%thermal_a3) then
1299 if (this%thermivisc == 2) then
1300 write (this%iout, '(4x,a,1pg15.6)') &
1301 'A3 in nonlinear viscosity formulation has been set to: ', &
1302 this%a3
1303 else
1304 write (this%iout, '(4x,a,/,4x,a,/,4x,a)') 'THERMAL_A3 specified by user &
1305 &in VSC Package input file. LINEAR viscosity ', 'formulation also &
1306 &specified. THERMAL_A3 will not affect ', 'viscosity calculations.'
1307 end if
1308 end if
1309 if (found%thermal_a4) then
1310 if (this%thermivisc == 2) then
1311 write (this%iout, '(4x,a,1pg15.6)') &
1312 'A4 in nonlinear viscosity formulation has been set to: ', &
1313 this%a4
1314 else
1315 write (this%iout, '(4x,a,/,4x,a,/,4x,a)') 'THERMAL_A4 specified by user &
1316 &in VSC Package input file. LINEAR viscosity ', 'formulation also &
1317 &specified. THERMAL_A4 will not affect ', 'viscosity calculations.'
1318 end if
1319 end if
1320
1321 write (this%iout, '(1x,a)') 'end of VSC options block'
1322 end subroutine log_options
1323
1324 !> @brief Sets options as opposed to reading them from a file
1325 !<
1326 subroutine set_options(this, input_data)
1327 ! -- dummy
1328 class(gwfvsctype) :: this
1329 type(gwfvscinputdatatype), intent(in) :: input_data !< the input data to be set
1330 !
1331 this%viscref = input_data%viscref
1332 end subroutine set_options
1333
1334 !> @brief Set pointers to concentration(s)
1335 !!
1336 !! Pass in a gwt model name, concentration array, and ibound,
1337 !! and store a pointer to these in the VSC package so that
1338 !! viscosity can be calculated from them. This routine is called
1339 !! from the gwfgwt exchange in the exg_ar() method.
1340 !<
1341 subroutine set_concentration_pointer(this, modelname, conc, icbund, istmpr)
1342 ! -- dummy
1343 class(gwfvsctype) :: this
1344 character(len=LENMODELNAME), intent(in) :: modelname
1345 real(DP), dimension(:), pointer :: conc
1346 integer(I4B), dimension(:), pointer :: icbund
1347 integer(I4B), optional, intent(in) :: istmpr
1348 ! -- local
1349 integer(I4B) :: i
1350 logical :: found
1351 !
1352 this%iconcset = 1
1353 found = .false.
1354 do i = 1, this%nviscspecies
1355 if (this%cmodelname(i) == modelname) then
1356 this%modelconc(i)%conc => conc
1357 this%modelconc(i)%icbund => icbund
1358 found = .true.
1359 exit
1360 end if
1361 end do
1362 end subroutine set_concentration_pointer
1363
1364end module gwfvscmodule
This module contains the base boundary package.
This module contains simulation constants.
Definition Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition Constants.f90:45
real(dp), parameter dep3
real constant 1000
Definition Constants.f90:88
integer(i4b), parameter lenmodelname
maximum length of the model name
Definition Constants.f90:22
real(dp), parameter dhnoflo
real no flow constant
Definition Constants.f90:93
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition Constants.f90:17
real(dp), parameter dhalf
real constant 1/2
Definition Constants.f90:68
integer(i4b), parameter lenauxname
maximum length of a aux variable
Definition Constants.f90:35
real(dp), parameter dzero
real constant zero
Definition Constants.f90:65
real(dp), parameter dten
real constant 10
Definition Constants.f90:84
integer(i4b), parameter maxcharlen
maximum length of char string
Definition Constants.f90:47
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition Constants.f90:27
real(dp), parameter done
real constant 1
Definition Constants.f90:76
subroutine source_options(this)
Source VSC options.
Definition gwf-vsc.f90:1161
subroutine vsc_da(this)
Deallocate viscosity package memory.
Definition gwf-vsc.f90:854
subroutine allocate_arrays(this, nodes)
Allocate arrays.
Definition gwf-vsc.f90:1124
subroutine, public vsc_cr(vscobj, name_model, input_mempath, inunit, iout)
Create a new package object.
Definition gwf-vsc.f90:143
subroutine vsc_set_changed_at(this, kper, kstp)
Mark K changes as having occurred at (kper, kstp).
Definition gwf-vsc.f90:801
subroutine update_k_with_vsc(this)
Appled the viscosity ratio (mu_o/mu) to the hydraulic conductivity.
Definition gwf-vsc.f90:774
subroutine vsc_ad_standard_bnd(packobj, hnew, visc, viscref, locelev, locvisc, locconc, dviscdc, cviscref, ivisc, a2, a3, a4, ctemp)
advance ghb, drn and riv while accounting for viscosity
Definition gwf-vsc.f90:465
subroutine allocate_scalars(this)
Allocate scalars.
Definition gwf-vsc.f90:1084
subroutine vsc_ad_lak(packobj, visc, viscref, elev, locvisc, locconc, dviscdc, cviscref, ivisc, a2, a3, a4, ctemp)
Update lak-related viscosity ratios.
Definition gwf-vsc.f90:558
subroutine calc_q_visc(this, cellid, viscratio)
Account for viscosity in the aquifer hydraulic flow barriers.
Definition gwf-vsc.f90:751
real(dp) function calc_vsc_ratio(viscref, bndvisc)
calculate and return the viscosity ratio
Definition gwf-vsc.f90:662
subroutine source_packagedata(this)
source packagedata for package
Definition gwf-vsc.f90:926
subroutine vsc_calcvisc(this)
Calculate fluid viscosity.
Definition gwf-vsc.f90:1055
subroutine vsc_ad(this)
Advance the viscosity package.
Definition gwf-vsc.f90:359
subroutine vsc_ot_dv(this, idvfl)
Output viscosity package dependent-variable terms.
Definition gwf-vsc.f90:815
real(dp) function calc_bnd_viscosity(n, locvisc, locconc, viscref, dviscdc, cviscref, ctemp, ivisc, a2, a3, a4, auxvar)
Calculate the boundary viscosity.
Definition gwf-vsc.f90:681
subroutine vsc_ar_bnd(this, packobj)
Activate viscosity in advanced packages.
Definition gwf-vsc.f90:234
subroutine set_packagedata(this, input_data)
Sets package data instead of reading from file.
Definition gwf-vsc.f90:1035
subroutine vsc_df(this, dis, vsc_input)
Define viscosity package options and dimensions.
Definition gwf-vsc.f90:169
subroutine vsc_ad_sfr(packobj, visc, viscref, elev, locvisc, locconc, dviscdc, cviscref, ivisc, a2, a3, a4, ctemp)
Update sfr-related viscosity ratios.
Definition gwf-vsc.f90:504
subroutine source_dimensions(this)
Source dimensions for package.
Definition gwf-vsc.f90:899
subroutine vsc_ar(this, ibound)
Allocate and read method for viscosity package.
Definition gwf-vsc.f90:216
subroutine set_options(this, input_data)
Sets options as opposed to reading them from a file.
Definition gwf-vsc.f90:1327
subroutine vsc_rp(this)
Read new period data in viscosity package.
Definition gwf-vsc.f90:326
subroutine vsc_ad_bnd(this, packobj, hnew)
Advance the boundary packages when viscosity is active.
Definition gwf-vsc.f90:372
subroutine get_visc_ratio(this, n, m, gwhdn, gwhdm, viscratio)
Calculate the viscosity ratio.
Definition gwf-vsc.f90:725
subroutine set_npf_pointers(this)
Set pointers to NPF variables.
Definition gwf-vsc.f90:302
subroutine vsc_ad_maw(packobj, visc, viscref, elev, locvisc, locconc, dviscdc, cviscref, ivisc, a2, a3, a4, ctemp)
Update maw-related viscosity ratios.
Definition gwf-vsc.f90:612
subroutine log_options(this, found, viscosityfile)
log VSC options
Definition gwf-vsc.f90:1247
subroutine set_concentration_pointer(this, modelname, conc, icbund, istmpr)
Set pointers to concentration(s).
Definition gwf-vsc.f90:1342
real(dp) function calc_visc(ivisc, viscref, dviscdc, cviscref, conc, a2, a3, a4)
Generic function to calculate changes in fluid viscosity using a linear formulation.
Definition gwf-vsc.f90:102
integer(i4b) function, public getunit()
Get a free unit number.
subroutine, public openfile(iu, iout, fname, ftype, fmtarg_opt, accarg_opt, filstat_opt, mode_opt)
Open a file.
This module defines variable data types.
Definition kind.f90:8
type(listtype), public basemodellist
Definition mf6lists.f90:16
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
subroutine, public memorystore_release(varname, memory_path)
Release a single variable from the memory store.
This module contains the base numerical package type.
character(len=20) access
Definition OpenSpec.f90:7
character(len=20) form
Definition OpenSpec.f90:7
This module contains the SFR package methods.
Definition gwf-sfr.f90:7
This module contains simulation methods.
Definition Sim.f90:10
subroutine, public store_warning(msg, substring)
Store warning message.
Definition Sim.f90:241
subroutine, public store_error(msg, terminate)
Store an error message.
Definition Sim.f90:94
integer(i4b) function, public count_errors()
Return number of errors.
Definition Sim.f90:60
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition Sim.f90:208
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
character(len=maxcharlen) warnmsg
warning message string
integer(i4b) iout
file unit number for simulation output
character(len=lenmempath), pointer input_mempath
input context mempath for tdis
Definition tdis.f90:45
integer(i4b), pointer, public kstp
current time step number
Definition tdis.f90:27
integer(i4b), pointer, public kper
current stress period number
Definition tdis.f90:26
This class is used to store a single deferred-length character string. It was designed to work in an ...
Data structure to transfer input configuration to the.