Skip to content

Commit

Permalink
fix(mfmodel): fix budgetkey for transport models (#2176)
Browse files Browse the repository at this point in the history
* add budgetkey param to MF6Output and pass it down to MF6ListBudget in MF6Output.__list()
* update MFModel.output to set budgetkey to "MASS..." instead of volume for transport models
* todo: revisit and generalize for additional model types
  • Loading branch information
wpbonelli committed May 3, 2024
1 parent 864732d commit 8e16aab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 5 additions & 2 deletions flopy/mf6/mfmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,13 @@ def laycbd(self):

@property
def output(self):
budgetkey = None
if self.model_type == "gwt6":
budgetkey = "MASS BUDGET FOR ENTIRE MODEL"
try:
return self.oc.output
return MF6Output(self.oc, budgetkey=budgetkey)
except AttributeError:
return MF6Output(self)
return MF6Output(self, budgetkey=budgetkey)

def export(self, f, **kwargs):
"""Method to export a model to a shapefile or netcdf file
Expand Down
9 changes: 7 additions & 2 deletions flopy/mf6/utils/output_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MF6Output:
"""

def __init__(self, obj):
def __init__(self, obj, budgetkey=None):
from ..modflow import ModflowGwfoc, ModflowGwtoc, ModflowUtlobs

# set initial observation definitions
Expand All @@ -39,6 +39,11 @@ def __init__(self, obj):
self._obj = obj
self._methods = []
self._sim_ws = obj.simulation_data.mfpath.get_sim_path()
self._budgetkey = (
"VOLUME BUDGET FOR ENTIRE MODEL"
if budgetkey is None
else budgetkey
)
self.__budgetcsv = False

if not isinstance(obj, (PackageInterface, ModelInterface)):
Expand Down Expand Up @@ -382,7 +387,7 @@ def __list(self):
if self._lst is not None:
try:
list_file = os.path.join(self._sim_ws, self._lst)
return Mf6ListBudget(list_file)
return Mf6ListBudget(list_file, budgetkey=self._budgetkey)
except (AssertionError, OSError):
return None

Expand Down

0 comments on commit 8e16aab

Please sign in to comment.