Skip to content

Commit 351c5b7

Browse files
authored
fix(column lengths): autoscale array write to ncol for structured multi-model simulations (#2507)
1 parent 1464053 commit 351c5b7

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

autotest/test_model_splitter.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
def test_structured_model_splitter(function_tmpdir):
1515
sim_path = get_example_data_path() / "mf6-freyberg"
1616

17+
from pathlib import Path
18+
19+
function_tmpdir = Path("./temp")
20+
21+
split_path = function_tmpdir / "split_model"
22+
1723
sim = MFSimulation.load(sim_ws=sim_path)
1824
sim.set_sim_path(function_tmpdir)
1925
sim.write_simulation()
@@ -32,7 +38,7 @@ def test_structured_model_splitter(function_tmpdir):
3238
mfsplit = Mf6Splitter(sim)
3339
new_sim = mfsplit.split_model(array)
3440

35-
new_sim.set_sim_path(function_tmpdir / "split_model")
41+
new_sim.set_sim_path(split_path)
3642
new_sim.write_simulation()
3743
new_sim.run_simulation()
3844

@@ -49,6 +55,21 @@ def test_structured_model_splitter(function_tmpdir):
4955
err_msg = "Heads from original and split models do not match"
5056
np.testing.assert_allclose(new_heads, original_heads, err_msg=err_msg)
5157

58+
# test that line length is ncol for each model....
59+
ll_dict = {
60+
split_path / "freyberg_001.npf": ml0.dis.ncol.get_data(),
61+
split_path / "freyberg_100.npf": ml1.dis.ncol.get_data(),
62+
}
63+
for f, ncol in ll_dict.items():
64+
with open(f) as foo:
65+
while "internal" not in foo.readline().lower():
66+
continue
67+
68+
line = foo.readline().strip()
69+
tmp = line.split()
70+
if len(tmp) != ncol:
71+
raise AssertionError("Array column length is not equal to ncol")
72+
5273

5374
@requires_exe("mf6")
5475
def test_vertex_model_splitter(function_tmpdir):

flopy/mf6/mfmodel.py

+7
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,13 @@ def write(self, ext_file_action=ExtFileAction.copy_relative_paths):
13181318

13191319
self.name_file.write(ext_file_action=ext_file_action)
13201320

1321+
if not self.simulation_data.max_columns_user_set:
1322+
grid_type = self.get_grid_type()
1323+
if grid_type == DiscretizationType.DIS:
1324+
self.simulation_data.max_columns_of_data = self.dis.ncol.get_data()
1325+
self.simulation_data.max_columns_user_set = False
1326+
self.simulation_data.max_columns_auto_set = True
1327+
13211328
# write packages
13221329
for pp in self.packagelist:
13231330
if (

0 commit comments

Comments
 (0)