From f9fda0dc0b17235fbd402f9b0abc2e9eef5233c1 Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Mon, 25 Nov 2024 16:18:56 -0800 Subject: [PATCH 01/22] fix(gwe-uze): stop simulation when multiple uze objects exist in one cell --- autotest/test_gwe_uze_auxmult.py | 470 ++++++++++++++++++++++++ doc/ReleaseNotes/develop.tex | 1 + doc/mf6io/gwe/uze.tex | 2 +- src/Model/GroundWaterEnergy/gwe-uze.f90 | 68 +++- src/Model/GroundWaterFlow/gwf-uzf.f90 | 2 +- 5 files changed, 538 insertions(+), 5 deletions(-) create mode 100644 autotest/test_gwe_uze_auxmult.py diff --git a/autotest/test_gwe_uze_auxmult.py b/autotest/test_gwe_uze_auxmult.py new file mode 100644 index 00000000000..defd5e7d890 --- /dev/null +++ b/autotest/test_gwe_uze_auxmult.py @@ -0,0 +1,470 @@ +""" +A simple test of confirm that when the auxmultname option is active in UZF, +UZE will stop with an error msg. Multiple UZF objects in a cell is not +supported in UZE. Two variations of the same test problem are scripted; the +first test combines GWF and GWE into a single simulation and should error out. +The second test splits GWF and GWE into two different simulations where the +simulation containing the GWE model should error out. +""" + +import flopy +import numpy as np + +cases = ["uzauxmlt-err", "uzauxmlt-fmi"] + +nouter, ninner = 100, 300 +hclose, rclose, relax = 1e-9, 1e-3, 0.97 + +uzarea_data = { + "uzf_pkdat": [ + [0, (0, 0, 3), 1, -1, 1.0, 1e-5, 0.2, 0.3, 0.25, 3.5, "uzf01"], + [1, (0, 0, 3), 1, -1, 1.0, 1e-5, 0.2, 0.3, 0.25, 3.5, "uzf01"], + [2, (0, 0, 4), 1, -1, 1.0, 1e-5, 0.2, 0.3, 0.25, 3.5, "uzf02"], + [3, (0, 0, 4), 1, -1, 1.0, 1e-5, 0.2, 0.3, 0.25, 3.5, "uzf02"], + [4, (0, 0, 5), 1, -1, 1.0, 1e-5, 0.2, 0.3, 0.25, 3.5, "uzf03"], + [5, (0, 0, 5), 1, -1, 1.0, 1e-5, 0.2, 0.3, 0.25, 3.5, "uzf03"], + [6, (0, 0, 6), 1, -1, 1.0, 1e-5, 0.2, 0.3, 0.25, 3.5, "uzf04"], + [7, (0, 0, 6), 1, -1, 1.0, 1e-5, 0.2, 0.3, 0.25, 3.5, "uzf04"], + ], + "auxmultval": 0.5, +} + +nlay, nrow, ncol = 3, 1, 10 +nper = 1 +perlen = [1.0] +nstp = [1] +tsmult = [1.0] + +delr = 100.0 +delc = 100.0 +strt = -9.0 + +strt_temp = 1.0 +dispersivity = 1.0 +cpw = 4180.0 +rhow = 1000.0 +cps = 800.0 +rhos = 2500.0 +prsity = 0.2 + + +def build_gwf(gwf, gwfname): + flopy.mf6.ModflowGwfdis( + gwf, + nlay=nlay, + nrow=nrow, + ncol=ncol, + delr=delr, + delc=delc, + top=0.0, + botm=[-10.0, -20.0, -30.0], + ) + + # initial conditions + flopy.mf6.ModflowGwfic(gwf, strt=strt) + + # node property flow + flopy.mf6.ModflowGwfnpf( + gwf, + save_flows=True, + save_specific_discharge=True, + save_saturation=True, + icelltype=1, + k=1.0e-4, + k22=1.0e-4, + k33=1.0e-5, + ) + + # aquifer storage + flopy.mf6.ModflowGwfsto( + gwf, + save_flows=True, + iconvert=1, + ss=1e-5, + sy=prsity, + transient=True, + ) + + # chd files + chdval = -9.0 + iface = 0 + temperature = 10.0 + chdspd = { + 0: [ + [(0, 0, 0), chdval, iface, temperature, "object0"], + [(0, 0, ncol - 1), chdval, iface, temperature, "object0"], + ] + } + flopy.mf6.ModflowGwfchd( + gwf, + auxiliary=["iface", "temperature"], + boundnames=True, + print_input=True, + save_flows=True, + stress_period_data=chdspd, + pname="CHD", + ) + + # transient uzf info + # ifno cellid landflg ivertcn surfdp vks thtr thts thti eps [bndnm] + uz_pkdat = uzarea_data["uzf_pkdat"] + + finf = 1.0 + extdp = 0.0 + extwc = 0.0 + pet = 0.0 + zero = 0.0 + auxmultval = uzarea_data["auxmultval"] + uzf_spd = { + 0: [ + [i, finf, pet, extdp, extwc, zero, zero, zero, auxmultval] + for i in np.arange(len(uz_pkdat)) + ] + } + + flopy.mf6.ModflowGwfuzf( + gwf, + print_input=True, + print_flows=True, + save_flows=True, + boundnames=True, + ntrailwaves=7, + nwavesets=40, + auxiliary="multiplier", + auxmultname="multiplier", + package_convergence_filerecord=f"{gwfname}.UzfConvergence.csv", + wc_filerecord=f"{gwfname}.wc", + nuzfcells=len(uz_pkdat), + packagedata=uz_pkdat, + perioddata=uzf_spd, + budget_filerecord=f"{gwfname}.uzf.bud", + pname="UZF", + filename=f"{gwfname}.uzf", + ) + + # output control + flopy.mf6.ModflowGwfoc( + gwf, + budget_filerecord=f"{gwfname}.cbc", + head_filerecord=f"{gwfname}.hds", + headprintrecord=[("COLUMNS", 10, "WIDTH", 15, "DIGITS", 6, "GENERAL")], + saverecord=[("HEAD", "ALL"), ("BUDGET", "ALL")], + printrecord=[("HEAD", "ALL"), ("BUDGET", "ALL")], + filename=f"{gwfname}.oc", + ) + + return gwf + + +def build_gwe(gwe, gwename, fmi=False): + # Instantiating MODFLOW 6 transport discretization package + flopy.mf6.ModflowGwedis( + gwe, + nogrb=True, + nlay=nlay, + nrow=nrow, + ncol=ncol, + delr=delr, + delc=delc, + top=0.0, + botm=[-10.0, -20.0, -30.0], + pname="DIS", + filename=f"{gwename}.dis", + ) + + # Instantiating MODFLOW 6 transport initial concentrations + flopy.mf6.ModflowGweic( + gwe, + strt=strt_temp, + pname="IC", + filename=f"{gwename}.ic", + ) + + # Instantiating MODFLOW 6 transport advection package + flopy.mf6.ModflowGweadv(gwe, scheme="TVD", pname="ADV", filename=f"{gwename}.adv") + + # Instantiating MODFLOW 6 transport dispersion package + flopy.mf6.ModflowGwecnd( + gwe, + xt3d_off=False, + alh=dispersivity, + ath1=dispersivity, + ktw=0.5918 * 86400, + kts=0.2700 * 86400, + pname="CND", + filename=f"{gwename}.cnd", + ) + + # Instantiating MODFLOW 6 transport mass storage package + flopy.mf6.ModflowGweest( + gwe, + save_flows=True, + porosity=prsity, + heat_capacity_water=cpw, + density_water=rhow, + heat_capacity_solid=cps, + density_solid=rhos, + pname="EST", + filename=f"{gwename}.est", + ) + + # Instantiating MODFLOW 6 transport source-sink mixing package + srctype = "AUX" + auxname = "TEMPERATURE" + pname = ["CHD"] + # Inpput to SSM is: + sources = [[itm, srctype, auxname] for itm in pname] + + flopy.mf6.ModflowGwessm( + gwe, + sources=sources, + pname="SSM", + filename=f"{gwename}.ssm", + ) + + # Instantiating MODFLOW 6 energy transport source-sink mixing package + uz_pkdat = uzarea_data["uzf_pkdat"] + uzepackagedata = [(ct, 1.0) for ct, iuz in enumerate(uz_pkdat)] + uzeperioddata = { + 0: [[ct, "INFILTRATION", 1.0] for ct, itm in enumerate(uz_pkdat)], + } + + flopy.mf6.ModflowGweuze( + gwe, + flow_package_name="UZF", + boundnames=False, + save_flows=True, + print_input=True, + print_flows=True, + print_temperature=True, + temperature_filerecord=gwename + ".uze.bin", + budget_filerecord=gwename + ".uze.bud", + packagedata=uzepackagedata, + uzeperioddata=uzeperioddata, + pname="UZE", + filename=f"{gwename}.uze", + ) + + # Instantiate MODFLOW 6 heat transport output control package + flopy.mf6.ModflowGweoc( + gwe, + pname="OC", + budget_filerecord=f"{gwename}.cbc", + temperature_filerecord=f"{gwename}.ucn", + temperatureprintrecord=[("COLUMNS", 10, "WIDTH", 15, "DIGITS", 6, "GENERAL")], + saverecord=[("TEMPERATURE", "ALL"), ("BUDGET", "ALL")], + printrecord=[("TEMPERATURE", "ALL"), ("BUDGET", "ALL")], + filename=f"{gwename}.oc", + ) + + if fmi: + gwfname = gwename.replace("gwe", "gwf") + pd = [ + ("GWFHEAD", gwfname + ".hds", None), + ("GWFBUDGET", gwfname + ".cbc", None), + ("UZF", gwfname + ".uzf.bud", None), + ] + fmi = flopy.mf6.ModflowGwefmi(gwe, packagedata=pd) + + return gwe + + +def build_single_sim(idx, ws, exe): + name = cases[idx] + gwfname = "gwf-" + name + gwename = "gwe-" + name + + tdis_rc = [] + for i in range(nper): + tdis_rc.append((perlen[i], nstp[i], tsmult[i])) + + # build MODFLOW 6 files + sim = flopy.mf6.MFSimulation(sim_name=name, version="mf6", exe_name=exe, sim_ws=ws) + + # create tdis package + flopy.mf6.ModflowTdis(sim, time_units="DAYS", nper=nper, perioddata=tdis_rc) + + # create gwf model + gwf = flopy.mf6.ModflowGwf( + sim, modelname=gwfname, newtonoptions="NEWTON", save_flows=True + ) + + # build out gwf model + gwf = build_gwf(gwf, gwfname) + + # create iterative model solution and register the gwf model with it + ims = flopy.mf6.ModflowIms( + sim, + print_option="SUMMARY", + complexity="MODERATE", + outer_dvclose=hclose, + outer_maximum=nouter, + under_relaxation="DBD", + inner_maximum=ninner, + inner_dvclose=hclose, + rcloserecord=rclose, + linear_acceleration="BICGSTAB", + scaling_method="NONE", + reordering_method="NONE", + relaxation_factor=relax, + ) + sim.register_ims_package(ims, [gwf.name]) + + # ---------------------------------- + # Instantiating MODFLOW 6 GWE model + # ---------------------------------- + gwe = flopy.mf6.ModflowGwe(sim, modelname=gwename, model_nam_file=f"{gwename}.nam") + gwe.name_file.save_flows = True + + # build out gwe model + gwe = build_gwe(gwe, gwename) + + imsgwe = flopy.mf6.ModflowIms( + sim, + print_option="SUMMARY", + outer_dvclose=hclose, + outer_maximum=nouter, + under_relaxation="NONE", + inner_maximum=ninner, + inner_dvclose=hclose, + rcloserecord=rclose, + linear_acceleration="BICGSTAB", + scaling_method="NONE", + reordering_method="NONE", + relaxation_factor=relax, + filename=f"{gwename}.ims", + ) + sim.register_ims_package(imsgwe, [gwe.name]) + + # Instantiate Gwf-Gwe Exchange package + flopy.mf6.ModflowGwfgwe( + sim, + exgtype="GWF6-GWE6", + exgmnamea=gwfname, + exgmnameb=gwename, + filename=f"{gwename}.gwfgwe", + ) + + return sim + + +def run_single_sim(dir, exe): + idx = 0 + sim = build_single_sim(idx, dir, exe) + sim.write_simulation() + success, buff = sim.run_simulation(silent=False) + errmsg = f"simulation should terminate with error message, but " f"did not.\n{buff}" + assert not success, errmsg + + +def build_gwf_sim_only(idx, dir, exe): + name = cases[idx] + gwfname = "gwf-" + name + + tdis_rc = [] + for i in range(nper): + tdis_rc.append((perlen[i], nstp[i], tsmult[i])) + + # build MODFLOW 6 files + sim = flopy.mf6.MFSimulation(sim_name=name, version="mf6", exe_name=exe, sim_ws=dir) + + # create tdis package + flopy.mf6.ModflowTdis(sim, time_units="DAYS", nper=nper, perioddata=tdis_rc) + + # create gwf model + gwf = flopy.mf6.ModflowGwf( + sim, modelname=gwfname, newtonoptions="NEWTON", save_flows=True + ) + + # build out gwf model + gwf = build_gwf(gwf, gwfname) + + # create iterative model solution and register the gwf model with it + ims = flopy.mf6.ModflowIms( + sim, + print_option="SUMMARY", + complexity="MODERATE", + outer_dvclose=hclose, + outer_maximum=nouter, + under_relaxation="DBD", + inner_maximum=ninner, + inner_dvclose=hclose, + rcloserecord=rclose, + linear_acceleration="BICGSTAB", + scaling_method="NONE", + reordering_method="NONE", + relaxation_factor=relax, + ) + sim.register_ims_package(ims, [gwf.name]) + + return sim + + +def build_gwe_sim_only(idx, dir, exe): + name = cases[idx] + gwename = "gwe-" + name + + tdis_rc = [] + for i in range(nper): + tdis_rc.append((perlen[i], nstp[i], tsmult[i])) + + # build MODFLOW 6 files + sim = flopy.mf6.MFSimulation(sim_name=name, version="mf6", exe_name=exe, sim_ws=dir) + + # create tdis package + flopy.mf6.ModflowTdis(sim, time_units="DAYS", nper=nper, perioddata=tdis_rc) + + # create gwf model + gwe = flopy.mf6.ModflowGwe( + sim, modelname=gwename, model_nam_file=f"{gwename}.nam", save_flows=True + ) + gwe = build_gwe(gwe, gwename, fmi=True) + + imsgwe = flopy.mf6.ModflowIms( + sim, + print_option="SUMMARY", + outer_dvclose=hclose, + outer_maximum=nouter, + under_relaxation="NONE", + inner_maximum=ninner, + inner_dvclose=hclose, + rcloserecord=rclose, + linear_acceleration="BICGSTAB", + scaling_method="NONE", + reordering_method="NONE", + relaxation_factor=relax, + filename=f"{gwename}.ims", + ) + sim.register_ims_package(imsgwe, [gwe.name]) + + return sim + + +def run_separate_sims(dir, exe): + idx = 1 + sim = build_gwf_sim_only(idx, dir, exe) + sim.write_simulation() + success, buff = sim.run_simulation(silent=False) + + # So long as the flow simulation ran successfully, then run GWE' + errmsg = "GWF only simulation did not run and should have" + assert success, errmsg + sim = build_gwe_sim_only(idx, dir, exe) + sim.write_simulation() + success, buff = sim.run_simulation(silent=False) + errmsg = ( + f"GWE simulation should terminate with error message, but " f"did not.\n{buff}" + ) + assert not success, errmsg + + +def test_auxmultname(function_tmpdir, targets): + # Whether running the GWF & GWE model in a single sim or + # in separate sims via FMI, both should error out, which is + # how the assertion statements are constructed. + # Start with check where both GWF and GWE are in same simulation + run_single_sim(str(function_tmpdir), targets["mf6"]) + + # Next, separate GWF and GWE models into 2 different simulations + # and ensure MF quits with error message + run_separate_sims(str(function_tmpdir), targets["mf6"]) diff --git a/doc/ReleaseNotes/develop.tex b/doc/ReleaseNotes/develop.tex index 8cc90434af0..93bf9a85d08 100644 --- a/doc/ReleaseNotes/develop.tex +++ b/doc/ReleaseNotes/develop.tex @@ -49,6 +49,7 @@ \item When the SQUARE\_GWET option was invoked in the UZF options block, evapotranspiration from the water table (GWET) was calculated incorrectly. Instead of acting as a sink, the calculated evapotranspiration flux was added as a source of water. The applied fix ensures that groundwater evapotranspiration is removed from the water table and as a result the GWET values are accumulated as outflows in the budget table. \item The number of characters used to represent integers and floating point numbers in MODFLOW input files was restricted to 30. The program was modified to accept any number of characters provided the number is valid. This may be useful for parameter estimation programs that use character substitution to create new input files. \item A string to character array conversion function in the BMI interface could fail on Apple silicon macOS with recent versions of GNU Fortran, producing array extent errors at runtime. This has been fixed by properly specifying the intent of a dummy argument in the relevant function. + \item The UZF Package will facilitate UZF objects with areas less than the area of the host cell. However, within the GWE model type, the UZE package will not work properly when the area of UZF objects is not equal to the area of the host cell. New code was added to ensure that the area of each UZF object is equal to that of the host grid cell. When this condition is not satisfied, the new code will stop the simulation with an error message indicating which cell is in violation. % \item xxx \end{itemize} diff --git a/doc/mf6io/gwe/uze.tex b/doc/mf6io/gwe/uze.tex index 1e65d5bbd11..255348d9a28 100644 --- a/doc/mf6io/gwe/uze.tex +++ b/doc/mf6io/gwe/uze.tex @@ -1,6 +1,6 @@ Unsaturated Zone Energy Transport (UZE) Package information is read from the file that is specified by ``UZE6'' as the file type. There can be as many UZE Packages as necessary for a GWE model. Each UZE Package is designed to work with flows from a corresponding GWF UZF Package. By default \mf uses the UZE package name to determine which UZF Package corresponds to the UZE Package. Therefore, the package name of the UZE Package (as specified in the GWE name file) must match with the name of the corresponding UZF Package (as specified in the GWF name file). Alternatively, the name of the flow package can be specified using the FLOW\_PACKAGE\_NAME keyword in the options block. The GWE UZE Package cannot be used without a corresponding GWF UZF Package. -The UZE Package does not have a dimensions block; instead, dimensions for the UZE Package are set using the dimensions from the corresponding UZF Package. For example, the UZF Package requires specification of the number of cells (NUZFCELLS). UZE sets the number of UZE cells equal to NUZFCELLS. Therefore, the PACKAGEDATA block below must have NUZFCELLS entries in it. +The UZE Package does not have a dimensions block; instead, dimensions for the UZE Package are set using the dimensions from the corresponding UZF Package. For example, the UZF Package requires specification of the number of cells (NUZFCELLS). UZE sets the number of UZE cells equal to NUZFCELLS. Therefore, the PACKAGEDATA block below must have NUZFCELLS entries in it. Because of how UZE is formulated, only one UZE object per grid cell is permitted. If more than one UZE object is discovered in a grid cell, GWE will exit with an error message. To disable multiple UZE objects in a grid cell, remove the AUXMULTNAME keyword from the OPTIONS block of the corresponding UZF input file. \vspace{5mm} \subsubsection{Structure of Blocks} diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index a6bf10dce25..f7e2058dd65 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -82,6 +82,8 @@ module GweUzeModule procedure :: bnd_ac => uze_ac procedure :: bnd_mc => uze_mc procedure :: get_mvr_depvar + procedure, private :: stop_if_multi_uzobj_in_cell + procedure, private :: too_many_uzobjs end type GweUzeType @@ -156,22 +158,28 @@ subroutine find_uze_package(this) ! -- dummy class(GweUzeType) :: this ! -- local - character(len=LINELENGTH) :: errmsg class(BndType), pointer :: packobj - integer(I4B) :: ip, icount + integer(I4B) :: ip, icount, nuz integer(I4B) :: nbudterm + character(len=LINELENGTH) :: errmsg logical :: found ! ! -- Initialize found to false, and error later if flow package cannot ! be found found = .false. ! + nuz = 1 + ! ! -- If user is specifying flows in a binary budget file, then set up ! the budget file reader, otherwise set a pointer to the flow package ! budobj if (this%fmi%flows_from_file) then call this%fmi%set_aptbudobj_pointer(this%flowpackagename, this%flowbudptr) - if (associated(this%flowbudptr)) found = .true. + if (associated(this%flowbudptr)) then + found = .true. + nuz = this%flowbudptr%budterm(nuz)%maxlist + call this%stop_if_multi_uzobj_in_cell(nuz) + end if ! else if (associated(this%fmi%gwfbndlist)) then @@ -190,6 +198,11 @@ subroutine find_uze_package(this) this%flowbudptr => packobj%budobj end select end if + ! + ! -- Error if option for multiple UZF objects per cell is in use + if (packobj%iauxmultcol > 0) then + call this%too_many_uzobjs() + end if if (found) exit end do end if @@ -1293,6 +1306,55 @@ subroutine uze_bd_obs(this, obstypeid, jj, v, found) end select end subroutine uze_bd_obs + !> @brief Stop simulation when multiple UZF objects discovered in cell + !! + !! GWE equilibrates the temperature of a UZE object with the host cell. + !! This is accomplished through the use of a residual term in the energy + !! balance of each cell. As a result, GWE, specifically UZE, does not + !! support multiple UZE objects within a given cell, requiring the code + !! to exit with an appropriate message. + !< + subroutine stop_if_multi_uzobj_in_cell(this, nuz) + ! -- modules + use ConstantsModule, only: IZERO + ! -- dummy + class(GweUzeType) :: this + integer(I4B) :: nuz + ! -- local + integer(I4B) :: n, iloc + integer(I4B), dimension(:), allocatable :: dup_chk + character(len=LINELENGTH) :: errmsg + ! + allocate (dup_chk(nuz)) + do n = 1, nuz + dup_chk(n) = IZERO + end do + ! + ! -- add explanation + do n = 1, nuz + if (this%flowbudptr%budterm(1)%id2(n) /= IZERO) then + call this%too_many_uzobjs() + end if + iloc = this%flowbudptr%budterm(1)%id2(n) + dup_chk(iloc) = 1 + end do + end subroutine stop_if_multi_uzobj_in_cell + + !> @brief Print and store error msg for too many UZF/UZE objs in cell + !< + subroutine too_many_uzobjs(this) + ! -- dummy + class(GweUzeType) :: this + ! -- local + character(len=LINELENGTH) :: errmsg + ! + write (errmsg, '(a)') 'UZE does not support the use of multiple UZF & + &objects in a cell. Check use of AUXMULTNAME & + &option in UZF package.' + call store_error(errmsg) + call this%parser%StoreErrorUnit() + end subroutine too_many_uzobjs + !> @brief Sets the stress period attributes for keyword use. !< subroutine uze_set_stressperiod(this, itemno, keyword, found) diff --git a/src/Model/GroundWaterFlow/gwf-uzf.f90 b/src/Model/GroundWaterFlow/gwf-uzf.f90 index 184c925138a..49b9783383b 100644 --- a/src/Model/GroundWaterFlow/gwf-uzf.f90 +++ b/src/Model/GroundWaterFlow/gwf-uzf.f90 @@ -2032,7 +2032,7 @@ subroutine read_cell_properties(this) end do ! ! -- do an initial evaluation of the sum of uzfarea relative to the - ! GWF cell area in the case that there is more than one UZF cell + ! GWF cell area in the case that there is more than one UZF object ! in a GWF cell and a auxmult value is not being applied to the ! calculate the UZF cell area from the GWF cell area. if (this%imaxcellcnt > 1 .and. this%iauxmultcol < 1) then From a3d362161c3154297bb142c94d2527af2ced85e4 Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Mon, 25 Nov 2024 16:39:15 -0800 Subject: [PATCH 02/22] remove unused variable --- src/Model/GroundWaterEnergy/gwe-uze.f90 | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index f7e2058dd65..69965659b47 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -1323,7 +1323,6 @@ subroutine stop_if_multi_uzobj_in_cell(this, nuz) ! -- local integer(I4B) :: n, iloc integer(I4B), dimension(:), allocatable :: dup_chk - character(len=LINELENGTH) :: errmsg ! allocate (dup_chk(nuz)) do n = 1, nuz From afb6b03b7202007ef9c6d402ca18e7f66ef45b60 Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Tue, 26 Nov 2024 09:23:57 -0800 Subject: [PATCH 03/22] apply review comments --- autotest/test_gwe_uze_auxmult.py | 14 ++++++- src/Model/GroundWaterEnergy/gwe-uze.f90 | 49 +++++++++++++------------ 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/autotest/test_gwe_uze_auxmult.py b/autotest/test_gwe_uze_auxmult.py index defd5e7d890..307a953786b 100644 --- a/autotest/test_gwe_uze_auxmult.py +++ b/autotest/test_gwe_uze_auxmult.py @@ -47,10 +47,15 @@ rhos = 2500.0 prsity = 0.2 +idomain = np.ones((nlay, nrow, ncol)) +idomain[0, 0, 0] = 0 +idomain[0, 0, ncol - 1] = 0 + def build_gwf(gwf, gwfname): flopy.mf6.ModflowGwfdis( gwf, + nogrb=True, nlay=nlay, nrow=nrow, ncol=ncol, @@ -58,6 +63,7 @@ def build_gwf(gwf, gwfname): delc=delc, top=0.0, botm=[-10.0, -20.0, -30.0], + idomain=idomain, ) # initial conditions @@ -91,8 +97,8 @@ def build_gwf(gwf, gwfname): temperature = 10.0 chdspd = { 0: [ - [(0, 0, 0), chdval, iface, temperature, "object0"], - [(0, 0, ncol - 1), chdval, iface, temperature, "object0"], + [(2, 0, 0), chdval, iface, temperature, "object0"], + [(2, 0, ncol - 1), chdval, iface, temperature, "object0"], ] } flopy.mf6.ModflowGwfchd( @@ -169,6 +175,7 @@ def build_gwe(gwe, gwename, fmi=False): top=0.0, botm=[-10.0, -20.0, -30.0], pname="DIS", + idomain=idomain, filename=f"{gwename}.dis", ) @@ -468,3 +475,6 @@ def test_auxmultname(function_tmpdir, targets): # Next, separate GWF and GWE models into 2 different simulations # and ensure MF quits with error message run_separate_sims(str(function_tmpdir), targets["mf6"]) + + +run_separate_sims(r"c:\temp\test_auxmult", "mf6.exe") diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index 69965659b47..24a34b87ec3 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -82,8 +82,8 @@ module GweUzeModule procedure :: bnd_ac => uze_ac procedure :: bnd_mc => uze_mc procedure :: get_mvr_depvar - procedure, private :: stop_if_multi_uzobj_in_cell - procedure, private :: too_many_uzobjs + procedure, private :: duplicate_chk + procedure, private :: print_uz_err end type GweUzeType @@ -177,8 +177,6 @@ subroutine find_uze_package(this) call this%fmi%set_aptbudobj_pointer(this%flowpackagename, this%flowbudptr) if (associated(this%flowbudptr)) then found = .true. - nuz = this%flowbudptr%budterm(nuz)%maxlist - call this%stop_if_multi_uzobj_in_cell(nuz) end if ! else @@ -198,11 +196,6 @@ subroutine find_uze_package(this) this%flowbudptr => packobj%budobj end select end if - ! - ! -- Error if option for multiple UZF objects per cell is in use - if (packobj%iauxmultcol > 0) then - call this%too_many_uzobjs() - end if if (found) exit end do end if @@ -216,6 +209,10 @@ subroutine find_uze_package(this) call this%parser%StoreErrorUnit() end if ! + ! -- Check for multiple UZF objects per cell, if found report to user + nuz = this%flowbudptr%budterm(nuz)%maxlist + call this%duplicate_chk(nuz) + ! ! -- Allocate space for idxbudssm, which indicates whether this is a ! special budget term or one that is a general source and sink nbudterm = this%flowbudptr%nbudterm @@ -1314,45 +1311,51 @@ end subroutine uze_bd_obs !! support multiple UZE objects within a given cell, requiring the code !! to exit with an appropriate message. !< - subroutine stop_if_multi_uzobj_in_cell(this, nuz) + subroutine duplicate_chk(this, nuz) ! -- modules use ConstantsModule, only: IZERO ! -- dummy class(GweUzeType) :: this integer(I4B) :: nuz ! -- local - integer(I4B) :: n, iloc + integer(I4B) :: n, iloc, ncell integer(I4B), dimension(:), allocatable :: dup_chk ! - allocate (dup_chk(nuz)) - do n = 1, nuz + ncell = this%dis%nodes + allocate (dup_chk(ncell)) + do n = 1, ncell dup_chk(n) = IZERO end do ! - ! -- add explanation + ! -- cycle through uze objects, stop at first occurence of more than one + ! uze object in a cell do n = 1, nuz - if (this%flowbudptr%budterm(1)%id2(n) /= IZERO) then - call this%too_many_uzobjs() - end if iloc = this%flowbudptr%budterm(1)%id2(n) + if (dup_chk(iloc) /= IZERO) then + call this%print_uz_err(iloc) + end if dup_chk(iloc) = 1 end do - end subroutine stop_if_multi_uzobj_in_cell + end subroutine duplicate_chk !> @brief Print and store error msg for too many UZF/UZE objs in cell !< - subroutine too_many_uzobjs(this) + subroutine print_uz_err(this, iloc) ! -- dummy class(GweUzeType) :: this + integer(I4B) :: iloc ! -- local character(len=LINELENGTH) :: errmsg + character(len=30) :: nodestr ! - write (errmsg, '(a)') 'UZE does not support the use of multiple UZF & - &objects in a cell. Check use of AUXMULTNAME & - &option in UZF package.' + call this%dis%noder_to_string(iloc, nodestr) + write (errmsg, '(3a)') & + 'More than one UZF object was found in cell ', trim(adjustl(nodestr)), & + '. UZE will only work with one UZE object per grid cell. Check use of & + &AUXMULTNAME option in UZF package.' call store_error(errmsg) call this%parser%StoreErrorUnit() - end subroutine too_many_uzobjs + end subroutine print_uz_err !> @brief Sets the stress period attributes for keyword use. !< From 072caa39c91092b3c4837053a49d6605652b5b4c Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Tue, 26 Nov 2024 09:26:02 -0800 Subject: [PATCH 04/22] fix spelling mistake --- src/Model/GroundWaterEnergy/gwe-uze.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index 24a34b87ec3..67b51628019 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -1327,7 +1327,7 @@ subroutine duplicate_chk(this, nuz) dup_chk(n) = IZERO end do ! - ! -- cycle through uze objects, stop at first occurence of more than one + ! -- cycle through uze objects, stop at first occurrence of more than one ! uze object in a cell do n = 1, nuz iloc = this%flowbudptr%budterm(1)%id2(n) From 0dfbec512023fe5b1ab00f5e94f97d646bc6fcbe Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Tue, 26 Nov 2024 09:49:15 -0800 Subject: [PATCH 05/22] remove leftover line from local testing --- autotest/test_gwe_uze_auxmult.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/autotest/test_gwe_uze_auxmult.py b/autotest/test_gwe_uze_auxmult.py index 307a953786b..2bb421db4dd 100644 --- a/autotest/test_gwe_uze_auxmult.py +++ b/autotest/test_gwe_uze_auxmult.py @@ -475,6 +475,3 @@ def test_auxmultname(function_tmpdir, targets): # Next, separate GWF and GWE models into 2 different simulations # and ensure MF quits with error message run_separate_sims(str(function_tmpdir), targets["mf6"]) - - -run_separate_sims(r"c:\temp\test_auxmult", "mf6.exe") From 705848514e7c226252ab992143de8f3940f7ebbe Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Tue, 26 Nov 2024 16:08:43 -0800 Subject: [PATCH 06/22] adopting a more robust approach to this issue. Instead of checking indices, comparing the area of individual UZF objects to the area of the host cell. They should be equal --- autotest/test_gwe_uze_auxmult.py | 7 +-- doc/mf6io/gwe/uze.tex | 2 +- src/Model/GroundWaterEnergy/gwe-uze.f90 | 67 ++++++++++++++----------- src/Model/GroundWaterFlow/gwf-uzf.f90 | 3 +- 4 files changed, 44 insertions(+), 35 deletions(-) diff --git a/autotest/test_gwe_uze_auxmult.py b/autotest/test_gwe_uze_auxmult.py index 2bb421db4dd..d419f39da0f 100644 --- a/autotest/test_gwe_uze_auxmult.py +++ b/autotest/test_gwe_uze_auxmult.py @@ -1,10 +1,11 @@ """ A simple test of confirm that when the auxmultname option is active in UZF, -UZE will stop with an error msg. Multiple UZF objects in a cell is not -supported in UZE. Two variations of the same test problem are scripted; the +UZE will stop with an error msg. UZF objects must have the same area as the +host cell. If this condition is violoated, the code exits with an +appropriate message. Two variations of the same test problem are scripted; the first test combines GWF and GWE into a single simulation and should error out. The second test splits GWF and GWE into two different simulations where the -simulation containing the GWE model should error out. +simulation containing the GWE model should also error out. """ import flopy diff --git a/doc/mf6io/gwe/uze.tex b/doc/mf6io/gwe/uze.tex index 255348d9a28..c0981185beb 100644 --- a/doc/mf6io/gwe/uze.tex +++ b/doc/mf6io/gwe/uze.tex @@ -1,6 +1,6 @@ Unsaturated Zone Energy Transport (UZE) Package information is read from the file that is specified by ``UZE6'' as the file type. There can be as many UZE Packages as necessary for a GWE model. Each UZE Package is designed to work with flows from a corresponding GWF UZF Package. By default \mf uses the UZE package name to determine which UZF Package corresponds to the UZE Package. Therefore, the package name of the UZE Package (as specified in the GWE name file) must match with the name of the corresponding UZF Package (as specified in the GWF name file). Alternatively, the name of the flow package can be specified using the FLOW\_PACKAGE\_NAME keyword in the options block. The GWE UZE Package cannot be used without a corresponding GWF UZF Package. -The UZE Package does not have a dimensions block; instead, dimensions for the UZE Package are set using the dimensions from the corresponding UZF Package. For example, the UZF Package requires specification of the number of cells (NUZFCELLS). UZE sets the number of UZE cells equal to NUZFCELLS. Therefore, the PACKAGEDATA block below must have NUZFCELLS entries in it. Because of how UZE is formulated, only one UZE object per grid cell is permitted. If more than one UZE object is discovered in a grid cell, GWE will exit with an error message. To disable multiple UZE objects in a grid cell, remove the AUXMULTNAME keyword from the OPTIONS block of the corresponding UZF input file. +The UZE Package does not have a dimensions block; instead, dimensions for the UZE Package are set using the dimensions from the corresponding UZF Package. For example, the UZF Package requires specification of the number of cells (NUZFCELLS). UZE sets the number of UZE cells equal to NUZFCELLS. Therefore, the PACKAGEDATA block below must have NUZFCELLS entries in it. UZE assumes that the area of the corresponding UZF object is equal to the area of the host grid cell. The GWE model will exit with an error message indicating which cell is in violation of this condition. If this error condition occurs, users can disable the AUXMULTNAME option in the OPTIONS block of the corresponding UZF input file. Users should not create two (or more) UZF objects in the same cell using multiple UZF input packages. \vspace{5mm} \subsubsection{Structure of Blocks} diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index 67b51628019..9d6c37d404e 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -161,6 +161,7 @@ subroutine find_uze_package(this) class(BndType), pointer :: packobj integer(I4B) :: ip, icount, nuz integer(I4B) :: nbudterm + integer(I4B) :: idxbudgwf character(len=LINELENGTH) :: errmsg logical :: found ! @@ -209,13 +210,18 @@ subroutine find_uze_package(this) call this%parser%StoreErrorUnit() end if ! - ! -- Check for multiple UZF objects per cell, if found report to user - nuz = this%flowbudptr%budterm(nuz)%maxlist - call this%duplicate_chk(nuz) + ! Check for multiple UZF objects per cell, if found report to user + ! Determine index of 'gwf' entry in flowbudptr since the variable + ! this%idxbudgwf has not been set yet + nbudterm = this%tspapttype%flowbudptr%nbudterm + do idxbudgwf = 1, nbudterm + if (this%flowbudptr%budterm(idxbudgwf)%flowtype == ' GWF') exit + end do + nuz = this%flowbudptr%budterm(idxbudgwf)%maxlist + call this%duplicate_chk(nuz, idxbudgwf) ! ! -- Allocate space for idxbudssm, which indicates whether this is a ! special budget term or one that is a general source and sink - nbudterm = this%flowbudptr%nbudterm call mem_allocate(this%idxbudssm, nbudterm, 'IDXBUDSSM', this%memoryPath) ! ! -- Process budget terms and identify special budget terms @@ -1303,42 +1309,42 @@ subroutine uze_bd_obs(this, obstypeid, jj, v, found) end select end subroutine uze_bd_obs - !> @brief Stop simulation when multiple UZF objects discovered in cell + !> @brief Stop simulation when UZF object area is not equal to the cell area !! - !! GWE equilibrates the temperature of a UZE object with the host cell. - !! This is accomplished through the use of a residual term in the energy - !! balance of each cell. As a result, GWE, specifically UZE, does not - !! support multiple UZE objects within a given cell, requiring the code - !! to exit with an appropriate message. + !! GWE equilibrates the temperature of a UZE object with the host cell. UZE + !! assumes that the area associated with a specific UZE object is equal to + !! the area of the host cell. When this condition is not true, the code + !! exits with an appropriate message. !< - subroutine duplicate_chk(this, nuz) + subroutine duplicate_chk(this, nuz, idxbudgwf) ! -- modules use ConstantsModule, only: IZERO + use MathUtilModule, only: is_close ! -- dummy class(GweUzeType) :: this integer(I4B) :: nuz + integer(I4B) :: idxbudgwf ! -- local - integer(I4B) :: n, iloc, ncell - integer(I4B), dimension(:), allocatable :: dup_chk - ! - ncell = this%dis%nodes - allocate (dup_chk(ncell)) - do n = 1, ncell - dup_chk(n) = IZERO - end do - ! - ! -- cycle through uze objects, stop at first occurrence of more than one - ! uze object in a cell + integer(I4B) :: n + integer(I4B) :: igwfnode + real(DP) :: carea + real(DP) :: uzarea + + ! cycle through uze objects, stop at first occurrence of more than one + ! uze object in a cell do n = 1, nuz - iloc = this%flowbudptr%budterm(1)%id2(n) - if (dup_chk(iloc) /= IZERO) then - call this%print_uz_err(iloc) + igwfnode = this%flowbudptr%budterm(idxbudgwf)%id2(n) + carea = this%dis%area(igwfnode) + uzarea = this%flowbudptr%budterm(idxbudgwf)%auxvar(1, n) + ! compare areas + if (.not. is_close(carea, uzarea)) then + call this%print_uz_err(igwfnode) end if - dup_chk(iloc) = 1 end do end subroutine duplicate_chk - !> @brief Print and store error msg for too many UZF/UZE objs in cell + !> @brief Print and store error msg indicating area of UZF object is not + !! equal to that of the host cell !< subroutine print_uz_err(this, iloc) ! -- dummy @@ -1350,9 +1356,10 @@ subroutine print_uz_err(this, iloc) ! call this%dis%noder_to_string(iloc, nodestr) write (errmsg, '(3a)') & - 'More than one UZF object was found in cell ', trim(adjustl(nodestr)), & - '. UZE will only work with one UZE object per grid cell. Check use of & - &AUXMULTNAME option in UZF package.' + 'In a GWE model, the area of every UZF object must be equal to that of & + &the host cell. This condition is violated in cell ', & + trim(adjustl(nodestr)), '. Check use of AUXMULTNAME option in UZF & + &package.' call store_error(errmsg) call this%parser%StoreErrorUnit() end subroutine print_uz_err diff --git a/src/Model/GroundWaterFlow/gwf-uzf.f90 b/src/Model/GroundWaterFlow/gwf-uzf.f90 index 49b9783383b..f0daab4f64f 100644 --- a/src/Model/GroundWaterFlow/gwf-uzf.f90 +++ b/src/Model/GroundWaterFlow/gwf-uzf.f90 @@ -2798,7 +2798,8 @@ subroutine uzf_setup_budobj(this) q = DZERO do n = 1, this%nodes n2 = this%igwfnode(n) - call this%budobj%budterm(idx)%update_term(n, n2, q) + this%qauxcbc(1) = this%uzfobj%uzfarea(n) + call this%budobj%budterm(idx)%update_term(n, n2, q, this%qauxcbc) end do ! ! -- From 8411e170042db08c3fb33809f7ca85d71294c2d0 Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Tue, 26 Nov 2024 16:16:20 -0800 Subject: [PATCH 07/22] fprettify --- src/Model/GroundWaterFlow/gwf-uzf.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/GroundWaterFlow/gwf-uzf.f90 b/src/Model/GroundWaterFlow/gwf-uzf.f90 index f0daab4f64f..00f7910b3f7 100644 --- a/src/Model/GroundWaterFlow/gwf-uzf.f90 +++ b/src/Model/GroundWaterFlow/gwf-uzf.f90 @@ -2798,7 +2798,7 @@ subroutine uzf_setup_budobj(this) q = DZERO do n = 1, this%nodes n2 = this%igwfnode(n) - this%qauxcbc(1) = this%uzfobj%uzfarea(n) + this%qauxcbc(1) = this%uzfobj%uzfarea(n) call this%budobj%budterm(idx)%update_term(n, n2, q, this%qauxcbc) end do ! From f8814fcd4a847860f7ad614cebda235ba574f5e1 Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Tue, 26 Nov 2024 16:36:49 -0800 Subject: [PATCH 08/22] spelling --- autotest/test_gwe_uze_auxmult.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autotest/test_gwe_uze_auxmult.py b/autotest/test_gwe_uze_auxmult.py index d419f39da0f..4ba56635265 100644 --- a/autotest/test_gwe_uze_auxmult.py +++ b/autotest/test_gwe_uze_auxmult.py @@ -1,7 +1,7 @@ """ A simple test of confirm that when the auxmultname option is active in UZF, UZE will stop with an error msg. UZF objects must have the same area as the -host cell. If this condition is violoated, the code exits with an +host cell. If this condition is violated, the code exits with an appropriate message. Two variations of the same test problem are scripted; the first test combines GWF and GWE into a single simulation and should error out. The second test splits GWF and GWE into two different simulations where the From a9ee02a4bdb6281fd3255760a1f5e5abaf21ccb0 Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Wed, 27 Nov 2024 10:38:29 -0800 Subject: [PATCH 09/22] rename func --- src/Model/GroundWaterEnergy/gwe-uze.f90 | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index 9d6c37d404e..978a5af0ca4 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -82,7 +82,7 @@ module GweUzeModule procedure :: bnd_ac => uze_ac procedure :: bnd_mc => uze_mc procedure :: get_mvr_depvar - procedure, private :: duplicate_chk + procedure, private :: uzarea_chk procedure, private :: print_uz_err end type GweUzeType @@ -169,8 +169,6 @@ subroutine find_uze_package(this) ! be found found = .false. ! - nuz = 1 - ! ! -- If user is specifying flows in a binary budget file, then set up ! the budget file reader, otherwise set a pointer to the flow package ! budobj @@ -218,7 +216,7 @@ subroutine find_uze_package(this) if (this%flowbudptr%budterm(idxbudgwf)%flowtype == ' GWF') exit end do nuz = this%flowbudptr%budterm(idxbudgwf)%maxlist - call this%duplicate_chk(nuz, idxbudgwf) + call this%uzarea_chk(nuz, idxbudgwf) ! ! -- Allocate space for idxbudssm, which indicates whether this is a ! special budget term or one that is a general source and sink @@ -1316,7 +1314,7 @@ end subroutine uze_bd_obs !! the area of the host cell. When this condition is not true, the code !! exits with an appropriate message. !< - subroutine duplicate_chk(this, nuz, idxbudgwf) + subroutine uzarea_chk(this, nuz, idxbudgwf) ! -- modules use ConstantsModule, only: IZERO use MathUtilModule, only: is_close @@ -1341,7 +1339,7 @@ subroutine duplicate_chk(this, nuz, idxbudgwf) call this%print_uz_err(igwfnode) end if end do - end subroutine duplicate_chk + end subroutine uzarea_chk !> @brief Print and store error msg indicating area of UZF object is not !! equal to that of the host cell From d7d8d03546e69738159bffd5a891af6843fdbcf3 Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Sat, 30 Nov 2024 08:16:15 -0800 Subject: [PATCH 10/22] update description of new test --- autotest/test_gwe_uze_auxmult.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autotest/test_gwe_uze_auxmult.py b/autotest/test_gwe_uze_auxmult.py index 4ba56635265..bb013b3fd99 100644 --- a/autotest/test_gwe_uze_auxmult.py +++ b/autotest/test_gwe_uze_auxmult.py @@ -4,8 +4,8 @@ host cell. If this condition is violated, the code exits with an appropriate message. Two variations of the same test problem are scripted; the first test combines GWF and GWE into a single simulation and should error out. -The second test splits GWF and GWE into two different simulations where the -simulation containing the GWE model should also error out. +The second test splits GWF and GWE into two different simulations connected +via FMI and the simulation containing the GWE model also should error out. """ import flopy From 09e6064d5185940f10bb7d1e430d340b4a6bfe1f Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Mon, 2 Dec 2024 08:33:15 -0800 Subject: [PATCH 11/22] breakthrough --- src/Model/GroundWaterEnergy/gwe-uze.f90 | 44 +++++++++++++++++++++++++ src/Model/GroundWaterFlow/gwf-uzf.f90 | 19 +++++++++++ src/Model/TransportModel/tsp-apt.f90 | 10 ++++++ 3 files changed, 73 insertions(+) diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index 978a5af0ca4..6a2dc89ec2f 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -79,6 +79,7 @@ module GweUzeModule procedure :: pak_rp_obs => uze_rp_obs procedure :: pak_bd_obs => uze_bd_obs procedure :: pak_set_stressperiod => uze_set_stressperiod + procedure :: apt_chk_aux_area => uze_chk_aux_area procedure :: bnd_ac => uze_ac procedure :: bnd_mc => uze_mc procedure :: get_mvr_depvar @@ -279,6 +280,49 @@ subroutine find_uze_package(this) this%idxbudtheq = this%flowbudptr%nbudterm + 1 end subroutine find_uze_package + subroutine uze_rp(this) + ! -- dummy + class(GweUzeType), intent(inout) :: this + ! -- local + integer(I4B) :: nuz + integer(I4B) :: idxbudgwf + integer(I4B) :: nbudterm + ! + ! Check for multiple UZF objects per cell, if found report to user + ! Determine index of 'gwf' entry in flowbudptr since the variable + ! this%idxbudgwf has not been set yet + nbudterm = this%tspapttype%flowbudptr%nbudterm + do idxbudgwf = 1, nbudterm + if (this%flowbudptr%budterm(idxbudgwf)%flowtype == ' GWF') exit + end do + nuz = this%flowbudptr%budterm(idxbudgwf)%maxlist + call this%uzarea_chk(nuz, idxbudgwf) + ! + ! -- call parent _rp routines + call this%TspAptType%bnd_rp() + end subroutine uze_rp + + !> @brief Check to ensure auxillary areas equal respective cell areas + !< + subroutine uze_chk_aux_area(this) + ! -- dummy + class(GweUzeType), intent(inout) :: this + ! -- local + integer(I4B) :: nuz + integer(I4B) :: idxbudgwf + integer(I4B) :: nbudterm + ! + ! if discrepancy in areas found, report to user + ! Determine index of 'gwf' entry in flowbudptr since the variable + ! this%idxbudgwf has not been set yet + nbudterm = this%tspapttype%flowbudptr%nbudterm + do idxbudgwf = 1, nbudterm + if (this%flowbudptr%budterm(idxbudgwf)%flowtype == ' GWF') exit + end do + nuz = this%flowbudptr%budterm(idxbudgwf)%maxlist + call this%uzarea_chk(nuz, idxbudgwf) + end subroutine uze_chk_aux_area + !> @brief Add package connection to matrix. !! !! Overrides apt_ac to fold the UZE heat balance terms into the row diff --git a/src/Model/GroundWaterFlow/gwf-uzf.f90 b/src/Model/GroundWaterFlow/gwf-uzf.f90 index 00f7910b3f7..e1d1d08664b 100644 --- a/src/Model/GroundWaterFlow/gwf-uzf.f90 +++ b/src/Model/GroundWaterFlow/gwf-uzf.f90 @@ -649,6 +649,9 @@ subroutine uzf_rp(this) integer(I4B) :: j integer(I4B) :: jj integer(I4B) :: ierr + integer(I4B) :: idxbudgwf + integer(I4B) :: nbudterm + real(DP) :: rval1 real(DP), pointer :: bndElem => null() ! -- table output character(len=20) :: cellid @@ -915,6 +918,22 @@ subroutine uzf_rp(this) ! ! -- Save old ss flag this%issflagold = this%issflag + ! + ! -- Update uzf area + if (this%iauxmultcol > 0) then + nbudterm = this%budobj%nbudterm + do idxbudgwf = 1, nbudterm + if (this%budobj%budterm(idxbudgwf)%flowtype == ' GWF') exit + end do + + do i = 1, this%nodes + if (this%noupdateauxvar(this%iauxmultcol) /= 0) cycle + this%auxvar(this%iauxmultcol, i) = this%uauxvar(this%iauxmultcol, i) + rval1 = this%uauxvar(this%iauxmultcol, i) + call this%uzfobj%setdatauzfarea(i, rval1) + this%budobj%budterm(idxbudgwf)%auxvar(1, i) = this%uzfobj%uzfarea(i) + end do + end if end subroutine uzf_rp !> @brief Advance UZF Package diff --git a/src/Model/TransportModel/tsp-apt.f90 b/src/Model/TransportModel/tsp-apt.f90 index e8f03957c34..2fc7acf9fb9 100644 --- a/src/Model/TransportModel/tsp-apt.f90 +++ b/src/Model/TransportModel/tsp-apt.f90 @@ -136,6 +136,7 @@ module TspAptModule procedure :: bnd_reset => apt_reset procedure :: bnd_fc => apt_fc procedure, public :: apt_fc_expanded ! Made public for uze + procedure, public :: apt_chk_aux_area ! Made public for uze procedure :: pak_fc_expanded procedure, private :: apt_fc_nonexpanded procedure, public :: apt_cfupdate ! Made public for uze @@ -383,6 +384,9 @@ subroutine apt_rp(this) character(len=*), parameter :: fmtlsp = & &"(1X,/1X,'REUSING ',A,'S FROM LAST STRESS PERIOD')" ! + ! -- run aux area check (for uze) + call this%apt_chk_aux_area() + ! ! -- set nbound to maxbound this%nbound = this%maxbound ! @@ -479,6 +483,12 @@ subroutine apt_rp(this) end do end subroutine apt_rp + subroutine apt_chk_aux_area(this) + ! -- dummy + class(TspAptType), intent(inout) :: this + ! function available for override by packages + end subroutine apt_chk_aux_area + !> @brief Advanced package transport set stress period routine. !! !! Set a stress period attribute for an advanced transport package feature From e3f545feca70e2d1788091f6d5e06676839ebaa6 Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Mon, 2 Dec 2024 08:36:02 -0800 Subject: [PATCH 12/22] spelling --- src/Model/GroundWaterEnergy/gwe-uze.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index 6a2dc89ec2f..22fa0b26685 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -302,7 +302,7 @@ subroutine uze_rp(this) call this%TspAptType%bnd_rp() end subroutine uze_rp - !> @brief Check to ensure auxillary areas equal respective cell areas + !> @brief Check to ensure auxilary areas equal respective cell areas !< subroutine uze_chk_aux_area(this) ! -- dummy From f9ca8150ff09f0c4fc1fcf947ca5491e19ba704e Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Mon, 2 Dec 2024 08:38:10 -0800 Subject: [PATCH 13/22] same mistake twice in a row --- src/Model/GroundWaterEnergy/gwe-uze.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index 22fa0b26685..6adcee74baa 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -302,7 +302,7 @@ subroutine uze_rp(this) call this%TspAptType%bnd_rp() end subroutine uze_rp - !> @brief Check to ensure auxilary areas equal respective cell areas + !> @brief Check to ensure auxiliary areas equal respective cell areas !< subroutine uze_chk_aux_area(this) ! -- dummy From cde3d1aac24cb2ebafe309bfc14f4b1570e22555 Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Mon, 2 Dec 2024 09:42:19 -0800 Subject: [PATCH 14/22] remove leftover code from previous fix attemps --- src/Model/GroundWaterEnergy/gwe-uze.f90 | 28 +++---------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index 6adcee74baa..4c5050567a5 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -209,9 +209,9 @@ subroutine find_uze_package(this) call this%parser%StoreErrorUnit() end if ! - ! Check for multiple UZF objects per cell, if found report to user - ! Determine index of 'gwf' entry in flowbudptr since the variable - ! this%idxbudgwf has not been set yet + ! When GWE and GWF models are run in separate simulations, determine + ! the index of 'gwf' entry in flowbudptr since the variable this%idxbudgwf + ! has not been set yet nbudterm = this%tspapttype%flowbudptr%nbudterm do idxbudgwf = 1, nbudterm if (this%flowbudptr%budterm(idxbudgwf)%flowtype == ' GWF') exit @@ -280,28 +280,6 @@ subroutine find_uze_package(this) this%idxbudtheq = this%flowbudptr%nbudterm + 1 end subroutine find_uze_package - subroutine uze_rp(this) - ! -- dummy - class(GweUzeType), intent(inout) :: this - ! -- local - integer(I4B) :: nuz - integer(I4B) :: idxbudgwf - integer(I4B) :: nbudterm - ! - ! Check for multiple UZF objects per cell, if found report to user - ! Determine index of 'gwf' entry in flowbudptr since the variable - ! this%idxbudgwf has not been set yet - nbudterm = this%tspapttype%flowbudptr%nbudterm - do idxbudgwf = 1, nbudterm - if (this%flowbudptr%budterm(idxbudgwf)%flowtype == ' GWF') exit - end do - nuz = this%flowbudptr%budterm(idxbudgwf)%maxlist - call this%uzarea_chk(nuz, idxbudgwf) - ! - ! -- call parent _rp routines - call this%TspAptType%bnd_rp() - end subroutine uze_rp - !> @brief Check to ensure auxiliary areas equal respective cell areas !< subroutine uze_chk_aux_area(this) From 6397c00cb432f3b134b9bb6d938813ff5e3fa081 Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Mon, 2 Dec 2024 10:04:42 -0800 Subject: [PATCH 15/22] clean-up note added to uze.tex --- doc/mf6io/gwe/uze.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/mf6io/gwe/uze.tex b/doc/mf6io/gwe/uze.tex index c0981185beb..5343658c683 100644 --- a/doc/mf6io/gwe/uze.tex +++ b/doc/mf6io/gwe/uze.tex @@ -1,6 +1,6 @@ Unsaturated Zone Energy Transport (UZE) Package information is read from the file that is specified by ``UZE6'' as the file type. There can be as many UZE Packages as necessary for a GWE model. Each UZE Package is designed to work with flows from a corresponding GWF UZF Package. By default \mf uses the UZE package name to determine which UZF Package corresponds to the UZE Package. Therefore, the package name of the UZE Package (as specified in the GWE name file) must match with the name of the corresponding UZF Package (as specified in the GWF name file). Alternatively, the name of the flow package can be specified using the FLOW\_PACKAGE\_NAME keyword in the options block. The GWE UZE Package cannot be used without a corresponding GWF UZF Package. -The UZE Package does not have a dimensions block; instead, dimensions for the UZE Package are set using the dimensions from the corresponding UZF Package. For example, the UZF Package requires specification of the number of cells (NUZFCELLS). UZE sets the number of UZE cells equal to NUZFCELLS. Therefore, the PACKAGEDATA block below must have NUZFCELLS entries in it. UZE assumes that the area of the corresponding UZF object is equal to the area of the host grid cell. The GWE model will exit with an error message indicating which cell is in violation of this condition. If this error condition occurs, users can disable the AUXMULTNAME option in the OPTIONS block of the corresponding UZF input file. Users should not create two (or more) UZF objects in the same cell using multiple UZF input packages. +The UZE Package does not have a dimensions block; instead, dimensions for the UZE Package are set using the dimensions from the corresponding UZF Package. For example, the UZF Package requires specification of the number of cells (NUZFCELLS). UZE sets the number of UZE cells equal to NUZFCELLS. Therefore, the PACKAGEDATA block below must have NUZFCELLS entries in it. Furthermore, UZE requires the area of each UZE object to equal to the area of the grid cell hosting the corresponding UZF object. If the area of a UZF object is different than the host grid cell, the GWE model will exit with an error message indicating which cell is in violation of this condition. This check is unique to UZE, UZT does not require the area of the corresponding UZF object to equal the area of the host grid cell. If this error condition occurs, users should check whether the AUXMULTNAME option in the OPTIONS block of the corresponding UZF input file is activated. Finally, users should not create two (or more) UZF objects in the same cell using multiple UZF input packages. \vspace{5mm} \subsubsection{Structure of Blocks} From cc393f4e7e65d5d3852aa5921f6434c83cab4f05 Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Tue, 3 Dec 2024 08:38:39 -0800 Subject: [PATCH 16/22] rename apt_chk_aux_area() to apt-chk and move function to end of _rp() routine --- src/Model/GroundWaterEnergy/gwe-uze.f90 | 2 +- src/Model/TransportModel/tsp-apt.f90 | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index 4c5050567a5..af77235d924 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -79,7 +79,7 @@ module GweUzeModule procedure :: pak_rp_obs => uze_rp_obs procedure :: pak_bd_obs => uze_bd_obs procedure :: pak_set_stressperiod => uze_set_stressperiod - procedure :: apt_chk_aux_area => uze_chk_aux_area + procedure :: apt_chk => uze_chk_aux_area procedure :: bnd_ac => uze_ac procedure :: bnd_mc => uze_mc procedure :: get_mvr_depvar diff --git a/src/Model/TransportModel/tsp-apt.f90 b/src/Model/TransportModel/tsp-apt.f90 index 2fc7acf9fb9..ed4f6b0db5d 100644 --- a/src/Model/TransportModel/tsp-apt.f90 +++ b/src/Model/TransportModel/tsp-apt.f90 @@ -136,7 +136,7 @@ module TspAptModule procedure :: bnd_reset => apt_reset procedure :: bnd_fc => apt_fc procedure, public :: apt_fc_expanded ! Made public for uze - procedure, public :: apt_chk_aux_area ! Made public for uze + procedure, public :: apt_chk ! Made public for uze procedure :: pak_fc_expanded procedure, private :: apt_fc_nonexpanded procedure, public :: apt_cfupdate ! Made public for uze @@ -384,9 +384,6 @@ subroutine apt_rp(this) character(len=*), parameter :: fmtlsp = & &"(1X,/1X,'REUSING ',A,'S FROM LAST STRESS PERIOD')" ! - ! -- run aux area check (for uze) - call this%apt_chk_aux_area() - ! ! -- set nbound to maxbound this%nbound = this%maxbound ! @@ -481,13 +478,16 @@ subroutine apt_rp(this) igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(n) this%nodelist(n) = igwfnode end do + ! + ! -- run package-specific checks + call this%apt_chk() end subroutine apt_rp - subroutine apt_chk_aux_area(this) + subroutine apt_chk(this) ! -- dummy class(TspAptType), intent(inout) :: this ! function available for override by packages - end subroutine apt_chk_aux_area + end subroutine apt_chk !> @brief Advanced package transport set stress period routine. !! From 5049af01a369c10d1b75ca2460cf09b41e841ebc Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Fri, 6 Dec 2024 09:25:57 -0800 Subject: [PATCH 17/22] try calling check from _ad() --- src/Model/GroundWaterEnergy/gwe-uze.f90 | 24 +++--------------------- src/Model/GroundWaterFlow/gwf-uzf.f90 | 19 ------------------- src/Model/TransportModel/tsp-apt.f90 | 12 ++++++------ 3 files changed, 9 insertions(+), 46 deletions(-) diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index af77235d924..b021c47eed0 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -79,7 +79,7 @@ module GweUzeModule procedure :: pak_rp_obs => uze_rp_obs procedure :: pak_bd_obs => uze_bd_obs procedure :: pak_set_stressperiod => uze_set_stressperiod - procedure :: apt_chk => uze_chk_aux_area + procedure :: apt_ad_chk => uze_chk_aux_area procedure :: bnd_ac => uze_ac procedure :: bnd_mc => uze_mc procedure :: get_mvr_depvar @@ -209,16 +209,6 @@ subroutine find_uze_package(this) call this%parser%StoreErrorUnit() end if ! - ! When GWE and GWF models are run in separate simulations, determine - ! the index of 'gwf' entry in flowbudptr since the variable this%idxbudgwf - ! has not been set yet - nbudterm = this%tspapttype%flowbudptr%nbudterm - do idxbudgwf = 1, nbudterm - if (this%flowbudptr%budterm(idxbudgwf)%flowtype == ' GWF') exit - end do - nuz = this%flowbudptr%budterm(idxbudgwf)%maxlist - call this%uzarea_chk(nuz, idxbudgwf) - ! ! -- Allocate space for idxbudssm, which indicates whether this is a ! special budget term or one that is a general source and sink call mem_allocate(this%idxbudssm, nbudterm, 'IDXBUDSSM', this%memoryPath) @@ -287,18 +277,10 @@ subroutine uze_chk_aux_area(this) class(GweUzeType), intent(inout) :: this ! -- local integer(I4B) :: nuz - integer(I4B) :: idxbudgwf - integer(I4B) :: nbudterm ! ! if discrepancy in areas found, report to user - ! Determine index of 'gwf' entry in flowbudptr since the variable - ! this%idxbudgwf has not been set yet - nbudterm = this%tspapttype%flowbudptr%nbudterm - do idxbudgwf = 1, nbudterm - if (this%flowbudptr%budterm(idxbudgwf)%flowtype == ' GWF') exit - end do - nuz = this%flowbudptr%budterm(idxbudgwf)%maxlist - call this%uzarea_chk(nuz, idxbudgwf) + nuz = this%flowbudptr%budterm(this%idxbudgwf)%maxlist + call this%uzarea_chk(nuz, this%idxbudgwf) end subroutine uze_chk_aux_area !> @brief Add package connection to matrix. diff --git a/src/Model/GroundWaterFlow/gwf-uzf.f90 b/src/Model/GroundWaterFlow/gwf-uzf.f90 index e1d1d08664b..00f7910b3f7 100644 --- a/src/Model/GroundWaterFlow/gwf-uzf.f90 +++ b/src/Model/GroundWaterFlow/gwf-uzf.f90 @@ -649,9 +649,6 @@ subroutine uzf_rp(this) integer(I4B) :: j integer(I4B) :: jj integer(I4B) :: ierr - integer(I4B) :: idxbudgwf - integer(I4B) :: nbudterm - real(DP) :: rval1 real(DP), pointer :: bndElem => null() ! -- table output character(len=20) :: cellid @@ -918,22 +915,6 @@ subroutine uzf_rp(this) ! ! -- Save old ss flag this%issflagold = this%issflag - ! - ! -- Update uzf area - if (this%iauxmultcol > 0) then - nbudterm = this%budobj%nbudterm - do idxbudgwf = 1, nbudterm - if (this%budobj%budterm(idxbudgwf)%flowtype == ' GWF') exit - end do - - do i = 1, this%nodes - if (this%noupdateauxvar(this%iauxmultcol) /= 0) cycle - this%auxvar(this%iauxmultcol, i) = this%uauxvar(this%iauxmultcol, i) - rval1 = this%uauxvar(this%iauxmultcol, i) - call this%uzfobj%setdatauzfarea(i, rval1) - this%budobj%budterm(idxbudgwf)%auxvar(1, i) = this%uzfobj%uzfarea(i) - end do - end if end subroutine uzf_rp !> @brief Advance UZF Package diff --git a/src/Model/TransportModel/tsp-apt.f90 b/src/Model/TransportModel/tsp-apt.f90 index ed4f6b0db5d..bfaeee35317 100644 --- a/src/Model/TransportModel/tsp-apt.f90 +++ b/src/Model/TransportModel/tsp-apt.f90 @@ -136,7 +136,7 @@ module TspAptModule procedure :: bnd_reset => apt_reset procedure :: bnd_fc => apt_fc procedure, public :: apt_fc_expanded ! Made public for uze - procedure, public :: apt_chk ! Made public for uze + procedure, public :: apt_ad_chk procedure :: pak_fc_expanded procedure, private :: apt_fc_nonexpanded procedure, public :: apt_cfupdate ! Made public for uze @@ -478,16 +478,13 @@ subroutine apt_rp(this) igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(n) this%nodelist(n) = igwfnode end do - ! - ! -- run package-specific checks - call this%apt_chk() end subroutine apt_rp - subroutine apt_chk(this) + subroutine apt_ad_chk(this) ! -- dummy class(TspAptType), intent(inout) :: this ! function available for override by packages - end subroutine apt_chk + end subroutine apt_ad_chk !> @brief Advanced package transport set stress period routine. !! @@ -695,6 +692,9 @@ subroutine apt_ad(this) ! simulation time from "current" to "preceding" and reset ! "current" value. call this%obs%obs_ad() + ! + ! -- run package-specific checks + call this%apt_ad_chk() end subroutine apt_ad !> @brief Override bnd reset for custom mover logic From 0025c3a54203565044269a62d380dc22351f04c8 Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Fri, 6 Dec 2024 09:36:09 -0800 Subject: [PATCH 18/22] Remove unused variables --- src/Model/GroundWaterEnergy/gwe-uze.f90 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index b021c47eed0..b71e026f6ab 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -160,9 +160,8 @@ subroutine find_uze_package(this) class(GweUzeType) :: this ! -- local class(BndType), pointer :: packobj - integer(I4B) :: ip, icount, nuz + integer(I4B) :: ip, icount integer(I4B) :: nbudterm - integer(I4B) :: idxbudgwf character(len=LINELENGTH) :: errmsg logical :: found ! From 3ed45d9ce24848d9e858fe38ab4a68b50a3c02db Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Fri, 6 Dec 2024 10:41:19 -0800 Subject: [PATCH 19/22] restore accidentally deleted line --- src/Model/GroundWaterEnergy/gwe-uze.f90 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index b71e026f6ab..108d808955f 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -210,6 +210,7 @@ subroutine find_uze_package(this) ! ! -- Allocate space for idxbudssm, which indicates whether this is a ! special budget term or one that is a general source and sink + nbudterm = this%flowbudptr%nbudterm call mem_allocate(this%idxbudssm, nbudterm, 'IDXBUDSSM', this%memoryPath) ! ! -- Process budget terms and identify special budget terms From c25a3a2b71d7820292005a2f9d0c0a37dc98050c Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Fri, 6 Dec 2024 14:20:55 -0800 Subject: [PATCH 20/22] changes in response to https://github.com/MODFLOW-USGS/modflow6/pull/2073#discussion_r1874020188 --- src/Model/GroundWaterEnergy/gwe-uze.f90 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index 108d808955f..7ec8aab928e 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -156,13 +156,13 @@ end subroutine uze_create subroutine find_uze_package(this) ! -- modules use MemoryManagerModule, only: mem_allocate + use SimVariablesModule, only: errmsg ! -- dummy class(GweUzeType) :: this ! -- local class(BndType), pointer :: packobj integer(I4B) :: ip, icount integer(I4B) :: nbudterm - character(len=LINELENGTH) :: errmsg logical :: found ! ! -- Initialize found to false, and error later if flow package cannot @@ -1349,11 +1349,12 @@ end subroutine uzarea_chk !! equal to that of the host cell !< subroutine print_uz_err(this, iloc) + ! -- modules + use SimVariablesModule, only: errmsg ! -- dummy class(GweUzeType) :: this integer(I4B) :: iloc ! -- local - character(len=LINELENGTH) :: errmsg character(len=30) :: nodestr ! call this%dis%noder_to_string(iloc, nodestr) From 189d4e645c237a7ad5352ca9de8f518733918c03 Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Fri, 6 Dec 2024 14:40:14 -0800 Subject: [PATCH 21/22] changes in response https://github.com/MODFLOW-USGS/modflow6/pull/2073#discussion_r1874016904 --- src/Model/GroundWaterEnergy/gwe-uze.f90 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index 7ec8aab928e..36ae5639e9b 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -84,7 +84,7 @@ module GweUzeModule procedure :: bnd_mc => uze_mc procedure :: get_mvr_depvar procedure, private :: uzarea_chk - procedure, private :: print_uz_err + procedure, private :: area_error end type GweUzeType @@ -1322,6 +1322,7 @@ subroutine uzarea_chk(this, nuz, idxbudgwf) ! -- modules use ConstantsModule, only: IZERO use MathUtilModule, only: is_close + use SimModule, only: count_errors ! -- dummy class(GweUzeType) :: this integer(I4B) :: nuz @@ -1340,15 +1341,18 @@ subroutine uzarea_chk(this, nuz, idxbudgwf) uzarea = this%flowbudptr%budterm(idxbudgwf)%auxvar(1, n) ! compare areas if (.not. is_close(carea, uzarea)) then - call this%print_uz_err(igwfnode) + call this%area_error(igwfnode) end if end do + if (count_errors() > 0) then + call this%parser%StoreErrorUnit() + end if end subroutine uzarea_chk !> @brief Print and store error msg indicating area of UZF object is not !! equal to that of the host cell !< - subroutine print_uz_err(this, iloc) + subroutine area_error(this, iloc) ! -- modules use SimVariablesModule, only: errmsg ! -- dummy @@ -1364,8 +1368,7 @@ subroutine print_uz_err(this, iloc) trim(adjustl(nodestr)), '. Check use of AUXMULTNAME option in UZF & &package.' call store_error(errmsg) - call this%parser%StoreErrorUnit() - end subroutine print_uz_err + end subroutine area_error !> @brief Sets the stress period attributes for keyword use. !< From 1ebcad44745003b11b716860630f46e194e5f6f6 Mon Sep 17 00:00:00 2001 From: emorway-usgs Date: Fri, 6 Dec 2024 14:58:08 -0800 Subject: [PATCH 22/22] changes in response to https://github.com/MODFLOW-USGS/modflow6/pull/2073#discussion_r1874010317 --- src/Model/GroundWaterEnergy/gwe-uze.f90 | 33 ++++++++----------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/src/Model/GroundWaterEnergy/gwe-uze.f90 b/src/Model/GroundWaterEnergy/gwe-uze.f90 index 36ae5639e9b..8816ccdebb1 100644 --- a/src/Model/GroundWaterEnergy/gwe-uze.f90 +++ b/src/Model/GroundWaterEnergy/gwe-uze.f90 @@ -79,11 +79,10 @@ module GweUzeModule procedure :: pak_rp_obs => uze_rp_obs procedure :: pak_bd_obs => uze_bd_obs procedure :: pak_set_stressperiod => uze_set_stressperiod - procedure :: apt_ad_chk => uze_chk_aux_area + procedure :: apt_ad_chk => uze_ad_chk procedure :: bnd_ac => uze_ac procedure :: bnd_mc => uze_mc procedure :: get_mvr_depvar - procedure, private :: uzarea_chk procedure, private :: area_error end type GweUzeType @@ -270,19 +269,6 @@ subroutine find_uze_package(this) this%idxbudtheq = this%flowbudptr%nbudterm + 1 end subroutine find_uze_package - !> @brief Check to ensure auxiliary areas equal respective cell areas - !< - subroutine uze_chk_aux_area(this) - ! -- dummy - class(GweUzeType), intent(inout) :: this - ! -- local - integer(I4B) :: nuz - ! - ! if discrepancy in areas found, report to user - nuz = this%flowbudptr%budterm(this%idxbudgwf)%maxlist - call this%uzarea_chk(nuz, this%idxbudgwf) - end subroutine uze_chk_aux_area - !> @brief Add package connection to matrix. !! !! Overrides apt_ac to fold the UZE heat balance terms into the row @@ -1311,34 +1297,35 @@ subroutine uze_bd_obs(this, obstypeid, jj, v, found) end select end subroutine uze_bd_obs - !> @brief Stop simulation when UZF object area is not equal to the cell area + !> @brief Check if UZF object area is not equal to the cell area !! !! GWE equilibrates the temperature of a UZE object with the host cell. UZE !! assumes that the area associated with a specific UZE object is equal to !! the area of the host cell. When this condition is not true, the code !! exits with an appropriate message. !< - subroutine uzarea_chk(this, nuz, idxbudgwf) + subroutine uze_ad_chk(this) ! -- modules use ConstantsModule, only: IZERO use MathUtilModule, only: is_close use SimModule, only: count_errors ! -- dummy - class(GweUzeType) :: this - integer(I4B) :: nuz - integer(I4B) :: idxbudgwf + class(GweUzeType), intent(inout) :: this ! -- local + integer(I4B) :: nuz integer(I4B) :: n integer(I4B) :: igwfnode real(DP) :: carea real(DP) :: uzarea + nuz = this%flowbudptr%budterm(this%idxbudgwf)%maxlist + ! cycle through uze objects, stop at first occurrence of more than one ! uze object in a cell do n = 1, nuz - igwfnode = this%flowbudptr%budterm(idxbudgwf)%id2(n) + igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(n) carea = this%dis%area(igwfnode) - uzarea = this%flowbudptr%budterm(idxbudgwf)%auxvar(1, n) + uzarea = this%flowbudptr%budterm(this%idxbudgwf)%auxvar(1, n) ! compare areas if (.not. is_close(carea, uzarea)) then call this%area_error(igwfnode) @@ -1347,7 +1334,7 @@ subroutine uzarea_chk(this, nuz, idxbudgwf) if (count_errors() > 0) then call this%parser%StoreErrorUnit() end if - end subroutine uzarea_chk + end subroutine uze_ad_chk !> @brief Print and store error msg indicating area of UZF object is not !! equal to that of the host cell