modflowpy / flopy

A Python package to create, run, and post-process MODFLOW-based models.
https://flopy.readthedocs.io
Other
517 stars 313 forks source link

bug: mf6 package name alters behavior with flopy #2118

Closed mwtoews closed 6 months ago

mwtoews commented 7 months ago

A short version of the bug is demonstrated with:

import flopy

sim = flopy.mf6.MFSimulation()
tdis = flopy.mf6.ModflowTdis(sim)
gwf = flopy.mf6.ModflowGwf(sim)
print(f"{hasattr(gwf, 'sto')=}, {hasattr(gwf, 'modeltime')=}")
flopy.mf6.ModflowGwfdrn(gwf, pname="storm")
print(f"{hasattr(gwf, 'sto')=}, {hasattr(gwf, 'modeltime')=}")

showing the output before and after adding a troubling package name:

hasattr(gwf, 'sto')=False, hasattr(gwf, 'modeltime')=True hasattr(gwf, 'sto')=True, hasattr(gwf, 'modeltime')=False

The issue is caused by the user-defined package name pname="storm", which raises this error:

gwf.modeltime
# AttributeError: modeltime

note that modeltime is a property that is expected to be available.

Changing pname to other values, like pname="strm" allows normal operation. The package name should not influence the behavior of flopy. It seems that flopy might have confused "storm" with an unrelated and unused "sto" package.

Observed with Windows and Linux. Flopy version 3.7.0.dev0 (current development), and with several other older releases back to flopy-3.4.3 (i.e. this isn't new). This not an issue with the mf6 executable.

spaulins-usgs commented 6 months ago

A fix has been checked in to the develop branch for this issue.