Skip to content

MF6 model not loaded if ims package is not defined #1558

@giovannifi

Description

@giovannifi

Describe the bug
I created the grid of a model using flopy and saved it as a disv package (my model is vertically structured). Then I wrote the packages (the disv package only). I tried to re-load the model and I got the following error:

loading simulation... loading simulation name file... loading tdis package... loading model gwf6... loading package disv... WARNING: Unable to resolve dimension of ('gwf6', 'disv', 'cell2d', 'cell2d', 'icvert') based on shape "ncvert". Traceback (most recent call last): File "H:\scripts\Intera_scripts\test_load_mf.py", line 9, in <module> sim = flopy.mf6.MFSimulation.load(sim_name=name, exe_name=path_exe, sim_ws=workspace, version="mf6", File "C:\Program Files\Python39\lib\site-packages\flopy\mf6\modflow\mfsimulation.py", line 839, in load for solution_group in solution_group_dict.values(): AttributeError: 'NoneType' object has no attribute 'values'

I have then went back to the script that created the original package and this time I also created the "ims" package. When I tried to load the model, this time everything went OK. I wonder if this is the expected behaviour of the code.

To Reproduce
Steps to reproduce the behavior:

  1. create a new simulation: sim = flopy.mf6.MFSimulation(sim_name=mf_name, exe_name=exe_name, version="mf6", sim_ws=workspace)
  2. create a new gwf class: gwf = flopy.mf6.ModflowGwf(sim, modelname=mf_name, save_flows=True, newtonoptions='UNDER_RELAXATION')
  3. define your disv package: disv = flopy.mf6.ModflowGwfdisv(gwf, length_units='METERS', nlay=nlays, ncpl=ncpl, nvert=nvert, top=top, botm=bots, vertices=vertices, cell2d=cell2d)
  4. write the packages: sim.write_simulation()
  5. create a new script where you load the model create above: sim = flopy.mf6.MFSimulation.load(sim_name=name, exe_name=path_exe, sim_ws=workspace, version="mf6", load_only=['disv'])
  6. error:
    loading simulation... loading simulation name file... loading tdis package... loading model gwf6... loading package disv... WARNING: Unable to resolve dimension of ('gwf6', 'disv', 'cell2d', 'cell2d', 'icvert') based on shape "ncvert". Traceback (most recent call last): File "H:\scripts\Intera_scripts\test_load_mf.py", line 9, in <module> sim = flopy.mf6.MFSimulation.load(sim_name=name, exe_name=path_exe, sim_ws=workspace, version="mf6", File "C:\Program Files\Python39\lib\site-packages\flopy\mf6\modflow\mfsimulation.py", line 839, in load for solution_group in solution_group_dict.values(): AttributeError: 'NoneType' object has no attribute 'values'

Expected behavior
I would expect no errors. As I said before if I create the IMS package and then load the model everything works fine.

Desktop (please complete the following information):

  • OS: Windows 10
  • I use pycharm 2021 with python 3.9

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions