Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: check.py inconsistancies/errors #2167

Open
tdeyster opened this issue Apr 25, 2024 · 0 comments
Open

bug: check.py inconsistancies/errors #2167

tdeyster opened this issue Apr 25, 2024 · 0 comments
Labels
Milestone

Comments

@tdeyster
Copy link

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):

@tdeyster tdeyster added the bug label Apr 25, 2024
@wpbonelli wpbonelli added this to the 3.7.0 milestone May 1, 2024
@wpbonelli wpbonelli modified the milestones: 3.7.0, 3.7.1 May 23, 2024
@wpbonelli wpbonelli modified the milestones: 3.7.1, 3.8.0 Jun 17, 2024
@wpbonelli wpbonelli modified the milestones: 3.8.0, 3.8.1 Aug 5, 2024
@wpbonelli wpbonelli modified the milestones: 3.8.1, 3.9.1 Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants