Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(exchange and gnc package cellids) #1866

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 181 additions & 0 deletions autotest/regression/test_mf6.py
Original file line number Diff line number Diff line change
Expand Up @@ -3600,6 +3600,187 @@ def test005_advgw_tidal(function_tmpdir, example_data_path):
)


@requires_exe("mf6")
@pytest.mark.regression
def test006_2models_different_dis(function_tmpdir, example_data_path):
# init paths
test_ex_name = "test006_2models_diff_dis"
model_name_1 = "model1"
model_name_2 = "model2"
pth = example_data_path / "mf6" / "create_tests" / test_ex_name

expected_output_folder = os.path.join(pth, "expected_output")
expected_head_file_1 = os.path.join(expected_output_folder, "model1.hds")
expected_head_file_2 = os.path.join(expected_output_folder, "model2.hds")

# create simulation
sim = MFSimulation(
sim_name=test_ex_name, version="mf6", exe_name="mf6", sim_ws=pth
)
tdis_rc = [(1.0, 1, 1.0)]
tdis_package = ModflowTdis(
sim, time_units="DAYS", nper=1, perioddata=tdis_rc
)
model_1 = ModflowGwf(
sim,
modelname=model_name_1,
model_nam_file=f"{model_name_1}.nam",
)
model_2 = ModflowGwf(
sim,
modelname=model_name_2,
model_nam_file=f"{model_name_2}.nam",
)
ims_package = ModflowIms(
sim,
print_option="SUMMARY",
outer_dvclose=0.00000001,
outer_maximum=1000,
under_relaxation="NONE",
inner_maximum=1000,
inner_dvclose=0.00000001,
rcloserecord=0.01,
linear_acceleration="BICGSTAB",
scaling_method="NONE",
reordering_method="NONE",
relaxation_factor=0.97,
)
sim.register_ims_package(ims_package, [model_1.name, model_2.name])
dis_package = ModflowGwfdis(
model_1,
length_units="METERS",
nlay=1,
nrow=7,
ncol=7,
idomain=1,
delr=100.0,
delc=100.0,
top=0.0,
botm=-100.0,
filename=f"{model_name_1}.dis",
)

vertices = testutils.read_vertices(os.path.join(pth, "vertices.txt"))
c2drecarray = testutils.read_cell2d(os.path.join(pth, "cell2d.txt"))
disv_package = ModflowGwfdisv(
model_2,
ncpl=121,
nlay=1,
nvert=148,
top=0.0,
botm=-40.0,
idomain=1,
vertices=vertices,
cell2d=c2drecarray,
filename=f"{model_name_2}.disv",
)
ic_package_1 = ModflowGwfic(
model_1, strt=1.0, filename=f"{model_name_1}.ic"
)
ic_package_2 = ModflowGwfic(
model_2, strt=1.0, filename=f"{model_name_2}.ic"
)
npf_package_1 = ModflowGwfnpf(
model_1, save_flows=True, perched=True, icelltype=0, k=1.0, k33=1.0
)
npf_package_2 = ModflowGwfnpf(
model_2, save_flows=True, perched=True, icelltype=0, k=1.0, k33=1.0
)
oc_package_1 = ModflowGwfoc(
model_1,
budget_filerecord="model1.cbc",
head_filerecord="model1.hds",
saverecord=[("HEAD", "ALL"), ("BUDGET", "ALL")],
printrecord=[("HEAD", "ALL"), ("BUDGET", "ALL")],
)
oc_package_2 = ModflowGwfoc(
model_2,
budget_filerecord="model2.cbc",
head_filerecord="model2.hds",
saverecord=[("HEAD", "ALL"), ("BUDGET", "ALL")],
printrecord=[("HEAD", "ALL"), ("BUDGET", "ALL")],
)

# build periodrecarray for chd package
set_1 = [0, 7, 14, 18, 22, 26, 33]
set_2 = [6, 13, 17, 21, 25, 32, 39]
stress_period_data = []
for value in range(0, 7):
stress_period_data.append(((0, value, 0), 1.0))
for value in range(0, 7):
stress_period_data.append(((0, value, 6), 0.0))
chd_package = ModflowGwfchd(
model_1,
print_input=True,
print_flows=True,
save_flows=True,
maxbound=30,
stress_period_data=stress_period_data,
)
exgrecarray = testutils.read_exchangedata(
os.path.join(pth, "exg.txt"), 3, 2
)

# build obs dictionary
gwf_obs = {
("gwfgwf_obs.csv"): [
("gwf-1-3-2_1-1-1", "flow-ja-face", (0, 2, 1), (0, 0, 0)),
("gwf-1-3-2_1-2-1", "flow-ja-face", (0, 2, 1), (0, 1, 0)),
]
}

exg_package = ModflowGwfgwf(
sim,
print_input=True,
print_flows=True,
save_flows=True,
auxiliary="testaux",
nexg=9,
exchangedata=exgrecarray,
exgtype="gwf6-gwf6",
exgmnamea=model_name_1,
exgmnameb=model_name_2,
observations=gwf_obs,
)

gnc_path = os.path.join("gnc", "test006_2models_gnc.gnc")
gncrecarray = testutils.read_gncrecarray(
os.path.join(pth, "gnc.txt"), 3, 2
)
gnc_package = exg_package.gnc.initialize(
filename=gnc_path,
print_input=True,
print_flows=True,
numgnc=9,
numalphaj=1,
gncdata=gncrecarray,
)

# change folder to save simulation
sim.set_sim_path(function_tmpdir)

# write simulation to new location
sim.write_simulation()
# run simulation
success, buff = sim.run_simulation()
assert success

sim2 = MFSimulation.load(sim_ws=sim.sim_path)
exh = sim2.get_package("gwfgwf")
exh_data = exh.exchangedata.get_data()
assert exh_data[0][0] == (0, 2, 1)
assert exh_data[0][1] == (0, 0)
assert exh_data[3][0] == (0, 3, 1)
assert exh_data[3][1] == (0, 3)
gnc = sim2.get_package("gnc")
gnc_data = gnc.gncdata.get_data()
assert gnc_data[0][0] == (0, 2, 1)
assert gnc_data[0][1] == (0, 0)
assert gnc_data[0][2] == (0, 1, 1)

sim.delete_output_files()


@requires_exe("mf6")
@pytest.mark.regression
def test006_gwf3(function_tmpdir, example_data_path):
Expand Down
121 changes: 121 additions & 0 deletions examples/data/mf6/create_tests/test006_2models_diff_dis/cell2d.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
1 50.0 650.0 5 1 2 10 9 1
2 150.0 650.0 5 2 3 11 10 2
3 250.0 650.0 5 3 4 12 11 3
4 350.0 650.0 5 4 5 13 12 4
5 450.0 650.0 5 5 6 14 13 5
6 550.0 650.0 5 6 7 15 14 6
7 650.0 650.0 5 7 8 16 15 7
8 50.0 550.0 5 9 10 18 17 9
9 150.0 550.0 5 10 11 19 18 10
10 250.0 550.0 7 11 12 22 21 20 19 11
11 350.0 550.0 7 12 13 25 24 23 22 12
12 450.0 550.0 7 13 14 28 27 26 25 13
13 550.0 550.0 5 14 15 29 28 14
14 650.0 550.0 5 15 16 30 29 15
15 50.0 450.0 5 17 18 52 51 17
16 150.0 450.0 7 18 19 31 41 53 52 18
17 550.0 450.0 7 28 29 63 62 50 40 28
18 650.0 450.0 5 29 30 64 63 29
19 50.0 350.0 5 51 52 86 85 51
20 150.0 350.0 7 52 53 65 75 87 86 52
21 550.0 350.0 7 62 63 97 96 84 74 62
22 650.0 350.0 5 63 64 98 97 63
23 50.0 250.0 5 85 86 120 119 85
24 150.0 250.0 7 86 87 99 109 121 120 86
25 550.0 250.0 7 96 97 131 130 118 108 96
26 650.0 250.0 5 97 98 132 131 97
27 50.0 150.0 5 119 120 134 133 119
28 150.0 150.0 5 120 121 135 134 120
29 250.0 150.0 7 121 122 123 124 136 135 121
30 350.0 150.0 7 124 125 126 127 137 136 124
31 450.0 150.0 7 127 128 129 130 138 137 127
32 550.0 150.0 5 130 131 139 138 130
33 650.0 150.0 5 131 132 140 139 131
34 50.0 50.0 5 133 134 142 141 133
35 150.0 50.0 5 134 135 143 142 134
36 250.0 50.0 5 135 136 144 143 135
37 350.0 50.0 5 136 137 145 144 136
38 450.0 50.0 5 137 138 146 145 137
39 550.0 50.0 5 138 139 147 146 138
40 650.0 50.0 5 139 140 148 147 139
41 216.666666667 483.333333333 5 19 20 32 31 19
42 250.0 483.333333333 5 20 21 33 32 20
43 283.333333333 483.333333333 5 21 22 34 33 21
44 316.666666667 483.333333333 5 22 23 35 34 22
45 350.0 483.333333333 5 23 24 36 35 23
46 383.333333333 483.333333333 5 24 25 37 36 24
47 416.666666667 483.333333333 5 25 26 38 37 25
48 450.0 483.333333333 5 26 27 39 38 26
49 483.333333333 483.333333333 5 27 28 40 39 27
50 216.666666667 450.0 5 31 32 42 41 31
51 250.0 450.0 5 32 33 43 42 32
52 283.333333333 450.0 5 33 34 44 43 33
53 316.666666667 450.0 5 34 35 45 44 34
54 350.0 450.0 5 35 36 46 45 35
55 383.333333333 450.0 5 36 37 47 46 36
56 416.666666667 450.0 5 37 38 48 47 37
57 450.0 450.0 5 38 39 49 48 38
58 483.333333333 450.0 5 39 40 50 49 39
59 216.666666667 416.666666667 5 41 42 54 53 41
60 250.0 416.666666667 5 42 43 55 54 42
61 283.333333333 416.666666667 5 43 44 56 55 43
62 316.666666667 416.666666667 5 44 45 57 56 44
63 350.0 416.666666667 5 45 46 58 57 45
64 383.333333333 416.666666667 5 46 47 59 58 46
65 416.666666667 416.666666667 5 47 48 60 59 47
66 450.0 416.666666667 5 48 49 61 60 48
67 483.333333333 416.666666667 5 49 50 62 61 49
68 216.666666667 383.333333333 5 53 54 66 65 53
69 250.0 383.333333333 5 54 55 67 66 54
70 283.333333333 383.333333333 5 55 56 68 67 55
71 316.666666667 383.333333333 5 56 57 69 68 56
72 350.0 383.333333333 5 57 58 70 69 57
73 383.333333333 383.333333333 5 58 59 71 70 58
74 416.666666667 383.333333333 5 59 60 72 71 59
75 450.0 383.333333333 5 60 61 73 72 60
76 483.333333333 383.333333333 5 61 62 74 73 61
77 216.666666667 350.0 5 65 66 76 75 65
78 250.0 350.0 5 66 67 77 76 66
79 283.333333333 350.0 5 67 68 78 77 67
80 316.666666667 350.0 5 68 69 79 78 68
81 350.0 350.0 5 69 70 80 79 69
82 383.333333333 350.0 5 70 71 81 80 70
83 416.666666667 350.0 5 71 72 82 81 71
84 450.0 350.0 5 72 73 83 82 72
85 483.333333333 350.0 5 73 74 84 83 73
86 216.666666667 316.666666667 5 75 76 88 87 75
87 250.0 316.666666667 5 76 77 89 88 76
88 283.333333333 316.666666667 5 77 78 90 89 77
89 316.666666667 316.666666667 5 78 79 91 90 78
90 350.0 316.666666667 5 79 80 92 91 79
91 383.333333333 316.666666667 5 80 81 93 92 80
92 416.666666667 316.666666667 5 81 82 94 93 81
93 450.0 316.666666667 5 82 83 95 94 82
94 483.333333333 316.666666667 5 83 84 96 95 83
95 216.666666667 283.333333333 5 87 88 100 99 87
96 250.0 283.333333333 5 88 89 101 100 88
97 283.333333333 283.333333333 5 89 90 102 101 89
98 316.666666667 283.333333333 5 90 91 103 102 90
99 350.0 283.333333333 5 91 92 104 103 91
100 383.333333333 283.333333333 5 92 93 105 104 92
101 416.666666667 283.333333333 5 93 94 106 105 93
102 450.0 283.333333333 5 94 95 107 106 94
103 483.333333333 283.333333333 5 95 96 108 107 95
104 216.666666667 250.0 5 99 100 110 109 99
105 250.0 250.0 5 100 101 111 110 100
106 283.333333333 250.0 5 101 102 112 111 101
107 316.666666667 250.0 5 102 103 113 112 102
108 350.0 250.0 5 103 104 114 113 103
109 383.333333333 250.0 5 104 105 115 114 104
110 416.666666667 250.0 5 105 106 116 115 105
111 450.0 250.0 5 106 107 117 116 106
112 483.333333333 250.0 5 107 108 118 117 107
113 216.666666667 216.666666667 5 109 110 122 121 109
114 250.0 216.666666667 5 110 111 123 122 110
115 283.333333333 216.666666667 5 111 112 124 123 111
116 316.666666667 216.666666667 5 112 113 125 124 112
117 350.0 216.666666667 5 113 114 126 125 113
118 383.333333333 216.666666667 5 114 115 127 126 114
119 416.666666667 216.666666667 5 115 116 128 127 115
120 450.0 216.666666667 5 116 117 129 128 116
121 483.333333333 216.666666667 5 117 118 130 129 117
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
1 3 2 1 1 1 50. 16.67 33.33 100.99
1 3 2 1 2 1 50. 16.67 33.33 100.99
1 3 2 1 3 1 50. 16.67 33.33 100.99
1 4 2 1 4 1 50. 16.67 33.33 100.99
1 4 2 1 5 1 50. 16.67 33.33 100.99
1 4 2 1 6 1 50. 16.67 33.33 100.99
1 5 2 1 7 1 50. 16.67 33.33 100.99
1 5 2 1 8 1 50. 16.67 33.33 100.99
1 5 2 1 9 1 50. 16.67 33.33 100.99
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
1 3 2 1 1 1 2 2 0.333333333333
1 3 2 1 2 0 0 0 0.333333333333
1 3 2 1 3 1 4 2 0.333333333333
1 4 2 1 4 1 3 2 0.333333333333
1 4 2 1 5 0 0 0 0.333333333333
1 4 2 1 6 1 5 2 0.333333333333
1 5 2 1 7 1 4 2 0.333333333333
1 5 2 1 8 0 0 0 0.333333333333
1 5 2 1 9 1 6 2 0.333333333333
Loading