Skip to content

Commit 866bb58

Browse files
authored
update(ModflowWel): add basic support for mfnwt tabfile based well files (#2755)
* update(intersect): update days calculation to fix dropped precision * replace timedelta.days with timedelta.total_seconds() / 86400 * linting * update test_modeltime.py, remove note in hfb_util.py * update(ModflowWel): add basic support for tabfile based well files * Linting * remove "flux" sfac_column for tabfile wel records * update tabfile option check * update aux variable check for tabfile type list records * update option block check for tabfiles
1 parent 579507e commit 866bb58

2 files changed

Lines changed: 48 additions & 14 deletions

File tree

flopy/modflow/mfwel.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ def __init__(
163163
self.url = "wel.html"
164164
self.np = 0
165165

166+
tabfiles = False
166167
if options is None:
167168
options = []
168169
self.specify = False
@@ -178,6 +179,9 @@ def __init__(
178179
self.phiramp = self.options.phiramp
179180
self.iunitramp = self.options.iunitramp
180181
# this is to grab the aux variables...
182+
if self.options.tabfiles:
183+
tabfiles = True
184+
181185
options = []
182186

183187
else:
@@ -196,7 +200,9 @@ def __init__(
196200
self.dtype = self.get_default_dtype(structured=self.parent.structured)
197201

198202
# determine if any aux variables in dtype
199-
dt = self.get_default_dtype(structured=self.parent.structured)
203+
dt = self.get_default_dtype(
204+
structured=self.parent.structured, tabfiles=tabfiles
205+
)
200206
if len(self.dtype.names) > len(dt.names):
201207
for name in self.dtype.names[len(dt.names) :]:
202208
ladd = True
@@ -295,24 +301,38 @@ def add_record(self, kper, index, values):
295301
raise Exception(f"mfwel error adding record to list: {e!s}")
296302

297303
@staticmethod
298-
def get_default_dtype(structured=True):
299-
if structured:
300-
dtype = np.dtype(
301-
[
302-
("k", int),
303-
("i", int),
304-
("j", int),
305-
("flux", np.float32),
306-
]
307-
)
304+
def get_default_dtype(structured=True, tabfiles=False):
305+
if not tabfiles:
306+
if structured:
307+
dtype = np.dtype(
308+
[
309+
("k", int),
310+
("i", int),
311+
("j", int),
312+
("flux", np.float32),
313+
]
314+
)
315+
else:
316+
dtype = np.dtype([("node", int), ("flux", np.float32)])
308317
else:
309-
dtype = np.dtype([("node", int), ("flux", np.float32)])
318+
if structured:
319+
dtype = np.dtype(
320+
[
321+
("tabunit", int),
322+
("tabval", int),
323+
("k", int),
324+
("i", int),
325+
("j", int),
326+
]
327+
)
328+
else:
329+
dtype = np.dtype([("tabunit", int), ("tabval", int), ("node", int)])
310330
return dtype
311331

312332
@staticmethod
313-
def get_empty(ncells=0, aux_names=None, structured=True):
333+
def get_empty(ncells=0, aux_names=None, structured=True, tabfiles=False):
314334
# get an empty recarray that corresponds to dtype
315-
dtype = ModflowWel.get_default_dtype(structured=structured)
335+
dtype = ModflowWel.get_default_dtype(structured=structured, tabfiles=tabfiles)
316336
if aux_names is not None:
317337
dtype = Package.add_to_dtype(dtype, aux_names, np.float32)
318338
return create_empty_recarray(ncells, dtype, default_value=-1.0e10)

flopy/pakbase.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,8 @@ def load(
961961
nwt_options = OptionBlock.load_options(f, pak_type)
962962
line = f.readline()
963963

964+
nwt_tabfiles = False
965+
964966
# check for parameters
965967
nppak = 0
966968
if "parameter" in line.lower():
@@ -1062,6 +1064,11 @@ def load(
10621064
options = nwt_options
10631065
else:
10641066
f.seek(ipos)
1067+
1068+
if isinstance(options, OptionBlock):
1069+
if options.tabfiles:
1070+
nwt_tabfiles = True
1071+
10651072
elif "flopy.modflow.mfchd.modflowchd".lower() in pak_type_str:
10661073
partype = ["shead", "ehead"]
10671074

@@ -1085,6 +1092,13 @@ def load(
10851092
bnd_output_cln = None
10861093
stress_period_data_cln = {}
10871094
current_cln = None
1095+
1096+
if nwt_tabfiles:
1097+
# pass tabfile flag using the existing usg_args dict, change nper to 1
1098+
nper = 1
1099+
sfac_columns = []
1100+
usg_args["tabfiles"] = True
1101+
10881102
for iper in range(nper):
10891103
if model.verbose:
10901104
msg = f" loading {pak_type} for kper {iper + 1:5d}"

0 commit comments

Comments
 (0)