Skip to content

Commit a8e241d

Browse files
authored
add(test_rhs_hcof_advanced): add additional test (MODFLOW-ORG#13)
* added test for getting and setting rhs, hcof, and advanced variable values * update project to use unix line separators * use np.testing.assert_allclose() instead of AssertionError
1 parent 61ccbb6 commit a8e241d

40 files changed

+1491
-1444
lines changed

autotest/test_interface.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,50 @@ def callback(sim, step):
323323
run_simulation(so, test_pth, callback)
324324
except Exception as e:
325325
raise Exception(e)
326+
327+
328+
def test_rhs_hcof_advanced(tmpdir):
329+
def callback(sim, step):
330+
model = sim.test_model
331+
if step == Callbacks.timestep_start:
332+
333+
wel = model.wel
334+
rhs = wel.rhs
335+
rhs[0:3] = [-150, -100, -50]
336+
wel.rhs = rhs
337+
338+
rhs2 = wel.get_advanced_var("rhs")
339+
np.testing.assert_allclose(
340+
rhs, rhs2, err_msg="rhs variable not being properly set"
341+
)
342+
343+
hcof = wel.hcof
344+
hcof[0: 3] = np.abs(rhs)[0:3] / 2
345+
346+
wel.hcof = hcof
347+
348+
hcof2 = wel.get_advanced_var("hcof")
349+
350+
np.testing.assert_allclose(
351+
hcof, hcof2, err_msg="hcof is not being properly set"
352+
)
353+
354+
rhs *= 1.2
355+
wel.set_advanced_var('rhs', rhs)
356+
rhs3 = wel.rhs
357+
358+
np.testing.assert_allclose(
359+
rhs,
360+
rhs3,
361+
err_msg="set advanced var method not working properly"
362+
)
363+
364+
name = "dis_model"
365+
sim_pth = data_pth / name
366+
test_pth = tmpdir / name
367+
shutil.copytree(sim_pth, test_pth, dirs_exist_ok=True)
368+
369+
try:
370+
run_simulation(so, test_pth, callback)
371+
except Exception as e:
372+
raise Exception(e)

examples/data/ats0/gwf_ats01a.ats

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2-
BEGIN dimensions
3-
MAXATS 2
4-
END dimensions
5-
6-
BEGIN perioddata
7-
1 5.00000000 1.00100000E-05 10.00000000 2.00000000 5.00000000
8-
8 5.00000000 1.00100000E-05 10.00000000 2.00000000 5.00000000
9-
END perioddata
10-
1+
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2+
BEGIN dimensions
3+
MAXATS 2
4+
END dimensions
5+
6+
BEGIN perioddata
7+
1 5.00000000 1.00100000E-05 10.00000000 2.00000000 5.00000000
8+
8 5.00000000 1.00100000E-05 10.00000000 2.00000000 5.00000000
9+
END perioddata
10+

examples/data/ats0/gwf_ats01a.dis

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2-
BEGIN options
3-
END options
4-
5-
BEGIN dimensions
6-
NLAY 1
7-
NROW 1
8-
NCOL 2
9-
END dimensions
10-
11-
BEGIN griddata
12-
delr
13-
CONSTANT 100.00000000
14-
delc
15-
CONSTANT 1.00000000
16-
top
17-
CONSTANT 100.00000000
18-
botm
19-
CONSTANT 0.00000000
20-
idomain
21-
INTERNAL FACTOR 1
22-
1 1
23-
END griddata
24-
1+
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2+
BEGIN options
3+
END options
4+
5+
BEGIN dimensions
6+
NLAY 1
7+
NROW 1
8+
NCOL 2
9+
END dimensions
10+
11+
BEGIN griddata
12+
delr
13+
CONSTANT 100.00000000
14+
delc
15+
CONSTANT 1.00000000
16+
top
17+
CONSTANT 100.00000000
18+
botm
19+
CONSTANT 0.00000000
20+
idomain
21+
INTERNAL FACTOR 1
22+
1 1
23+
END griddata
24+

examples/data/ats0/gwf_ats01a.ghb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2-
BEGIN options
3-
PRINT_INPUT
4-
PRINT_FLOWS
5-
END options
6-
7-
BEGIN dimensions
8-
MAXBOUND 1
9-
END dimensions
10-
11-
BEGIN period 1
12-
1 1 1 50.00000000 1.00000000
13-
END period 1
14-
1+
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2+
BEGIN options
3+
PRINT_INPUT
4+
PRINT_FLOWS
5+
END options
6+
7+
BEGIN dimensions
8+
MAXBOUND 1
9+
END dimensions
10+
11+
BEGIN period 1
12+
1 1 1 50.00000000 1.00000000
13+
END period 1
14+

examples/data/ats0/gwf_ats01a.ic

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2-
BEGIN griddata
3-
strt
4-
CONSTANT 50.00000000
5-
END griddata
6-
1+
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2+
BEGIN griddata
3+
strt
4+
CONSTANT 50.00000000
5+
END griddata
6+

examples/data/ats0/gwf_ats01a.ims

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2-
BEGIN options
3-
PRINT_OPTION summary
4-
END options
5-
6-
BEGIN nonlinear
7-
OUTER_DVCLOSE 1.00000000E-06
8-
OUTER_MAXIMUM 10
9-
UNDER_RELAXATION dbd
10-
UNDER_RELAXATION_THETA 0.70000000
11-
END nonlinear
12-
13-
BEGIN linear
14-
INNER_MAXIMUM 2
15-
INNER_DVCLOSE 1.00000000E-06
16-
inner_rclose 1.00000000E-06
17-
LINEAR_ACCELERATION cg
18-
RELAXATION_FACTOR 0.97000000
19-
SCALING_METHOD none
20-
REORDERING_METHOD none
21-
END linear
22-
1+
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2+
BEGIN options
3+
PRINT_OPTION summary
4+
END options
5+
6+
BEGIN nonlinear
7+
OUTER_DVCLOSE 1.00000000E-06
8+
OUTER_MAXIMUM 10
9+
UNDER_RELAXATION dbd
10+
UNDER_RELAXATION_THETA 0.70000000
11+
END nonlinear
12+
13+
BEGIN linear
14+
INNER_MAXIMUM 2
15+
INNER_DVCLOSE 1.00000000E-06
16+
inner_rclose 1.00000000E-06
17+
LINEAR_ACCELERATION cg
18+
RELAXATION_FACTOR 0.97000000
19+
SCALING_METHOD none
20+
REORDERING_METHOD none
21+
END linear
22+

examples/data/ats0/gwf_ats01a.nam

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2-
BEGIN options
3-
END options
4-
5-
BEGIN packages
6-
DIS6 gwf_ats01a.dis dis
7-
IC6 gwf_ats01a.ic ic
8-
NPF6 gwf_ats01a.npf npf
9-
STO6 gwf_ats01a.sto sto
10-
WEL6 gwf_ats01a.wel wel_0
11-
GHB6 gwf_ats01a.ghb ghb_0
12-
OC6 gwf_ats01a.oc oc
13-
OBS6 gwf_ats01a.obs head_obs
14-
END packages
15-
1+
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2+
BEGIN options
3+
END options
4+
5+
BEGIN packages
6+
DIS6 gwf_ats01a.dis dis
7+
IC6 gwf_ats01a.ic ic
8+
NPF6 gwf_ats01a.npf npf
9+
STO6 gwf_ats01a.sto sto
10+
WEL6 gwf_ats01a.wel wel_0
11+
GHB6 gwf_ats01a.ghb ghb_0
12+
OC6 gwf_ats01a.oc oc
13+
OBS6 gwf_ats01a.obs head_obs
14+
END packages
15+

examples/data/ats0/gwf_ats01a.npf

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2-
BEGIN options
3-
END options
4-
5-
BEGIN griddata
6-
icelltype
7-
CONSTANT 1
8-
k
9-
CONSTANT 1.00000000
10-
END griddata
11-
1+
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2+
BEGIN options
3+
END options
4+
5+
BEGIN griddata
6+
icelltype
7+
CONSTANT 1
8+
k
9+
CONSTANT 1.00000000
10+
END griddata
11+

examples/data/ats0/gwf_ats01a.obs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2-
BEGIN options
3-
DIGITS 20
4-
END options
5-
6-
BEGIN continuous FILEOUT gwf_ats01a.obs.csv
7-
obs1 head 1 1 1
8-
obs2 head 1 1 2
9-
END continuous FILEOUT gwf_ats01a.obs.csv
10-
1+
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2+
BEGIN options
3+
DIGITS 20
4+
END options
5+
6+
BEGIN continuous FILEOUT gwf_ats01a.obs.csv
7+
obs1 head 1 1 1
8+
obs2 head 1 1 2
9+
END continuous FILEOUT gwf_ats01a.obs.csv
10+

examples/data/ats0/gwf_ats01a.oc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2-
BEGIN options
3-
BUDGET FILEOUT gwf_ats01a.cbc
4-
BUDGETCSV FILEOUT gwf_ats01a.csv
5-
HEAD FILEOUT gwf_ats01a.hds
6-
HEAD PRINT_FORMAT COLUMNS 10 WIDTH 15 DIGITS 6 GENERAL
7-
END options
8-
9-
BEGIN period 1
10-
SAVE HEAD ALL
11-
PRINT HEAD ALL
12-
PRINT BUDGET ALL
13-
END period 1
14-
1+
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2+
BEGIN options
3+
BUDGET FILEOUT gwf_ats01a.cbc
4+
BUDGETCSV FILEOUT gwf_ats01a.csv
5+
HEAD FILEOUT gwf_ats01a.hds
6+
HEAD PRINT_FORMAT COLUMNS 10 WIDTH 15 DIGITS 6 GENERAL
7+
END options
8+
9+
BEGIN period 1
10+
SAVE HEAD ALL
11+
PRINT HEAD ALL
12+
PRINT BUDGET ALL
13+
END period 1
14+

examples/data/ats0/gwf_ats01a.sto

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2-
BEGIN options
3-
END options
4-
5-
BEGIN griddata
6-
iconvert
7-
CONSTANT 1
8-
ss
9-
CONSTANT 0.00000000
10-
sy
11-
CONSTANT 0.10000000
12-
END griddata
13-
14-
BEGIN period 1
15-
TRANSIENT
16-
END period 1
17-
1+
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2+
BEGIN options
3+
END options
4+
5+
BEGIN griddata
6+
iconvert
7+
CONSTANT 1
8+
ss
9+
CONSTANT 0.00000000
10+
sy
11+
CONSTANT 0.10000000
12+
END griddata
13+
14+
BEGIN period 1
15+
TRANSIENT
16+
END period 1
17+

examples/data/ats0/gwf_ats01a.tdis

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2-
BEGIN options
3-
TIME_UNITS days
4-
ATS6 FILEIN gwf_ats01a.ats
5-
END options
6-
7-
BEGIN dimensions
8-
NPER 1
9-
END dimensions
10-
11-
BEGIN perioddata
12-
10.00000000 1 1.00000000
13-
END perioddata
14-
1+
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
2+
BEGIN options
3+
TIME_UNITS days
4+
ATS6 FILEIN gwf_ats01a.ats
5+
END options
6+
7+
BEGIN dimensions
8+
NPER 1
9+
END dimensions
10+
11+
BEGIN perioddata
12+
10.00000000 1 1.00000000
13+
END perioddata
14+

0 commit comments

Comments
 (0)