LeaningCactus
LeaningCactus

Reputation: 1

Loading existing MODFLOW-USG model w/ Voronoi Mesh in FloPy

I am trying to load an existing MODFLOW-USG model with FloPy (Windows environment). The model has a Voronoi mesh, and this seems to trip the "load" function:

m1=flopy.modflow.Modflow.load(model_name+".nam",model_ws=model_dir,verbose=True,check=False,exe_name="mfusg.exe",version='mfusg')

I get the following error, which appears to relate to the fact that FloPy is expecting a structured grid with rows and columns:

TypeError                                 Traceback (most recent call last)
<ipython-input-33-62420c415719> in <module>
      6 head_file = os.path.join(model_dir,model_name+'.hds')
      7 print(head_file)
----> 8 m1=flopy.modflow.Modflow.load(model_name+".nam",model_ws=model_dir,verbose=True,check=False,exe_name="mfusg.exe",version='mfusg')
      9 headobj = bf.HeadUFile(head_file,verbose=True,text='HEADU')
     10 headobj.list_records()

~\Anaconda3\lib\site-packages\flopy\modflow\mf.py in load(f, version, exe_name, verbose, model_ws, load_only, forgive, check)
    797                             item.package.load(item.filehandle, ml,
    798                                               ext_unit_dict=ext_unit_dict,
--> 799                                               check=False)
    800                         else:
    801                             item.package.load(item.filehandle, ml,

~\Anaconda3\lib\site-packages\flopy\modflow\mfrch.py in load(f, model, nper, ext_unit_dict, check)
    408                         print(txt)
    409                     t = Util2d.load(f, model, (nrow, ncol), np.float32, 'rech',
--> 410                                     ext_unit_dict)
    411                 else:
    412                     parm_dict = {}

~\Anaconda3\lib\site-packages\flopy\utils\util_array.py in load(f_handle, model, shape, dtype, name, ext_unit_dict, array_free_format, array_format)
   2699 
   2700         elif cr_dict['type'] == 'internal':
-> 2701             data = Util2d.load_txt(shape, f_handle, dtype, cr_dict['fmtin'])
   2702             u2d = Util2d(model, shape, dtype, data, name=name,
   2703                          iprn=cr_dict['iprn'], fmtin="(FREE)",

~\Anaconda3\lib\site-packages\flopy\utils\util_array.py in load_txt(shape, file_in, dtype, fmtin)
   2376         elif len(shape) == 2:
   2377             nrow, ncol = shape
-> 2378             num_items = nrow * ncol
   2379         else:
   2380             raise ValueError(

TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

I could not find any documentation or Jupyter notebooks with examples of loading an existing model with Voronoi mesh, only creating new triangular meshes or structured / local-grid-refined grids.

Upvotes: 0

Views: 297

Answers (1)

Garth Cooper
Garth Cooper

Reputation: 155

Try the code with forgive = True.

m1=flopy.modflow.Modflow.load(model_name+".nam",model_ws=model_dir,verbose=True,check=False,exe_name="mfusg.exe",version='mfusg', forgive = True)

Upvotes: 0

Related Questions