Skip to content

bug: check.py inconsistancies/errors #2167

@tdeyster

Description

@tdeyster

Describe the bug
model.check() is inconsistant and has at least 2 uncaught errors for disv models.

To Reproduce
Steps to reproduce the behavior:

Bug1:

  import flopy
  sim = flopy.mf6.MFSimulation()
  gwf = flopy.mf6.ModflowGwf(simulation=sim)
  disv = flopy.mf6.ModflowGwfdisv(model=gwf)
  sim.check(verbose=1)

returns:
"ValueError: could not assign tuple of length 5 to structure with 6 fields."
This is because in _add_to_summary() disv models are given 5 fields, (type, package, node, value, desc), while in mf6check._get_ dtype() disv models have 6 fields (type, package, layer, cell2d, value, desc) (note that check._get_dtype() works properly because it doesn't support disv models).

Bug2:

import flopy
from flopy.utils.cvfdutil import gridlist_to_disv_gridprops
import numpy as np
sim = flopy.mf6.MFSimulation()
tdis = flopy.mf6.ModflowTdis(simulation=sim)
gwf = flopy.mf6.ModflowGwf(simulation=sim)
grids = [flopy.discretization.StructuredGrid(
                    delc=np.array([1]*3), delr=np.array([1]*3),
                    top=np.zeros((3,3)), botm=np.ones((1,3,3))*-1,
                    idomain=np.ones((1,3,3)),
                    nlay=1, nrow=3, ncol=3)]
dat = gridlist_to_disv_gridprops(grids)
disv = flopy.mf6.ModflowGwfdisv(model=gwf,nlay=1,**dat,top=np.zeros(9),botm=np.ones((1,9))*-1)
sto = flopy.mf6.ModflowGwfsto(model=gwf,ss=-1)
sim.check(verbose=1)

returns:
"ValueError: could not assign tuple of length 7 to structure with 6 fields."
This is because in _get_summary_array() disv models have 6 fields (type, package, layer, cell2d, value, desc) , while in check.values() disv models trigger the structured model 2D condition (indsT.shape[1] == 2) and are padded with zeros gaining 7 fields (type, package, layer, row, col, value, desc).

Expected behavior
disv models should be handled in .check() method. My quick fixes:
Bug1:
in def _add_to_summary() add condition for disv models (lay,cell2d)

col_list = [type, package]
# col_list += [k, i, j] if self.structured else [node] #TDE/04/25/24 original code commented out doesn't handle disv
col_list += [k, i, j] if self.structured else [k,node] if len(self.\_get\_dtype())==6 else [node] #TDE/04/25/24 (could probably check is modelgrid==disv instead
col_list += [value, desc]

Bug2:
in def values() only apply 2d correction for structured models

# if indsT.shape[1] == 2: #TDE/04/25/2024 original code
if self.structured and indsT.shape[1] == 2: #TDE/04/25/2024 added "self.structured" condition
    indsT = np.column_stack(
        [np.zeros(indsT.shape[0], dtype=int), indsT]
    )

Desktop (please complete the following information):

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions