---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-1-3901b9f6c6b6> in <module>
2 sim = flopy.mf6.MFSimulation(sim_name="sim", sim_ws='models')
3 tdis = flopy.mf6.ModflowTdis(sim, time_units="DAYS")
----> 4 gwf = flopy.mf6.ModflowGwf(sim, modelname='base', model_rel_path='base')
C:\Anaconda64\lib\site-packages\flopy\mf6\modflow\mfgwf.py in __init__(self, simulation, modelname, model_nam_file, version, exe_name, model_rel_path, list, print_input, print_flows, save_flows, newtonoptions, packages, **kwargs)
85 version=version, exe_name=exe_name,
86 model_rel_path=model_rel_path,
---> 87 **kwargs)
88
89 self.name_file.list.set_data(list)
C:\Anaconda64\lib\site-packages\flopy\mf6\mfmodel.py in __init__(self, simulation, model_type, modelname, model_nam_file, version, exe_name, add_to_simulation, structure, model_rel_path, verbose, **kwargs)
102 model_nam_file = '{}.nam'.format(modelname)
103
--> 104 self.set_model_relative_path(model_rel_path)
105 if add_to_simulation:
106 self.structure = simulation.register_model(self, model_type,
C:\Anaconda64\lib\site-packages\flopy\mf6\mfmodel.py in set_model_relative_path(self, model_ws)
700 models = self.simulation.name_file.models
701 models_data = models.get_data()
--> 702 for index, entry in enumerate(models_data):
703 old_model_file_name = os.path.split(entry[1])[1]
704 old_model_base_name = os.path.splitext(old_model_file_name)[0]
When I run the following snippet I get a
TypeError:Details
It appears to fail because I set a relative path immediately for the first model, when the simulation does not contain any models with a path yet. The workaround to use
model_rel_path='.'and callset_model_relative_pathmanually aftewards also fails:Details
This now seems to be caused by the fact that the model doesn't contain any packages yet, confirmed by the fact the following code does work as it's supposed: