0

I am trying to learn flopy, and I tried to load one of the MODFLOW-USG test cases. The test case is a 1-layer model with a nested grid and GNC package (example 01B). I did not modify the test case files distributed with MODFLOW-USG, and the test case ran fine with the run.bat file.

First I tried to follow the example for loading a name file using the flopy.modflow.mf module:

m = flopy.modflow.Modflow.load('flow.nam', version='mfusg')

But I got the following ValueError:

File "C:\Users\Kent\Anaconda3\lib\site-packages\flopy\modflow\mf.py", line 758, in load
  ml.check(f='{}.chk'.format(ml.name), verbose=ml.verbose, level=0)

File "C:\Users\Kent\Anaconda3\lib\site-packages\flopy\mbase.py", line 1121, in check
  level=level - 1)

File "C:\Users\Kent\Anaconda3\lib\site-packages\flopy\modflow\mfbas.py", line 185, in check
  neighbors = get_neighbors(self.ibound.array)

File "C:\Users\Kent\Anaconda3\lib\site-packages\flopy\utils\check.py", line 590, in get_neighbors
  nk, ni, nj = a.shape

ValueError: not enough values to unpack (expected 3, got 1)

Then I tried to load the DISU package following the example for the flopy.modflow.mfdisu module:

m = flopy.modflow.Modflow(version='mfusg')
disu = flopy.modflow.ModflowDisU.load('flow.disu', m)

But this gave me the following TypeError:

File "C:\Users\Kent\Anaconda3\lib\site-packages\flopy\modflow\mfdisu.py", line 622, in load
  fahl = Util2d.load(f, model, (n,), np.float32, 'fahl', ext_unit_dict)

File "C:\Users\Kent\Anaconda3\lib\site-packages\flopy\utils\util_array.py", line 2678, in load
  ext_unit = ext_unit_dict[cr_dict['nunit']]

TypeError: 'NoneType' object is not subscriptable

What is the correct way to load an existing MODFLOW-USG model with flopy?

Kent D.
  • 13
  • 5
  • Kent, it looks like in that first `ValueError` that `flopy` is trying to unpack the shape of the ibound array which should be 3-dimensional, but the returned shape is either empty or 1-d. You could try adding `check=False` to your `.load()` call so that `flopy` will skip the consistency checks during the load. At that point you could look at the ibound array directly and try to figure out what's going on. – Jason Bellino Apr 25 '19 at 14:25
  • Thanks, Jason. But isn't the array supposed to be 1D for an unstructured grid? Because flopy supports MODFLOW-USG, I would expect it to recognize the 1D array of an unstructured grid without throwing an error message. Particularly if I explicitly set the version to 'mfusg'. How can you read in a MODFLOW-USG name file if flopy requires the ibound array to be 3D? – Kent D. Apr 27 '19 at 03:57
  • Kent, you're right—I tried loading the example and got the same error. The problem seems to be with the `get_neighbors()` function in the check module...it's expecting a 3-d array regardless of model type. You may want to post this as an issue in the GitHub repo to elicit a fix. In the meantime you can just use `check=False` in your model-load call to skip the checking functions. `m = flopy.modflow.Modflow.load('flow.nam', version='mfusg', check=False)` – Jason Bellino Apr 29 '19 at 13:24

0 Answers0