Skip to content

Commit

Permalink
add(test_rhs_hcof_advanced): add additional test (#13)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jlarsen-usgs authored Mar 29, 2023
1 parent 61ccbb6 commit a8e241d
Show file tree
Hide file tree
Showing 40 changed files with 1,491 additions and 1,444 deletions.
47 changes: 47 additions & 0 deletions autotest/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,50 @@ def callback(sim, step):
run_simulation(so, test_pth, callback)
except Exception as e:
raise Exception(e)


def test_rhs_hcof_advanced(tmpdir):
def callback(sim, step):
model = sim.test_model
if step == Callbacks.timestep_start:

wel = model.wel
rhs = wel.rhs
rhs[0:3] = [-150, -100, -50]
wel.rhs = rhs

rhs2 = wel.get_advanced_var("rhs")
np.testing.assert_allclose(
rhs, rhs2, err_msg="rhs variable not being properly set"
)

hcof = wel.hcof
hcof[0: 3] = np.abs(rhs)[0:3] / 2

wel.hcof = hcof

hcof2 = wel.get_advanced_var("hcof")

np.testing.assert_allclose(
hcof, hcof2, err_msg="hcof is not being properly set"
)

rhs *= 1.2
wel.set_advanced_var('rhs', rhs)
rhs3 = wel.rhs

np.testing.assert_allclose(
rhs,
rhs3,
err_msg="set advanced var method not working properly"
)

name = "dis_model"
sim_pth = data_pth / name
test_pth = tmpdir / name
shutil.copytree(sim_pth, test_pth, dirs_exist_ok=True)

try:
run_simulation(so, test_pth, callback)
except Exception as e:
raise Exception(e)
20 changes: 10 additions & 10 deletions examples/data/ats0/gwf_ats01a.ats
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN dimensions
MAXATS 2
END dimensions
BEGIN perioddata
1 5.00000000 1.00100000E-05 10.00000000 2.00000000 5.00000000
8 5.00000000 1.00100000E-05 10.00000000 2.00000000 5.00000000
END perioddata
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN dimensions
MAXATS 2
END dimensions

BEGIN perioddata
1 5.00000000 1.00100000E-05 10.00000000 2.00000000 5.00000000
8 5.00000000 1.00100000E-05 10.00000000 2.00000000 5.00000000
END perioddata

48 changes: 24 additions & 24 deletions examples/data/ats0/gwf_ats01a.dis
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
END options
BEGIN dimensions
NLAY 1
NROW 1
NCOL 2
END dimensions
BEGIN griddata
delr
CONSTANT 100.00000000
delc
CONSTANT 1.00000000
top
CONSTANT 100.00000000
botm
CONSTANT 0.00000000
idomain
INTERNAL FACTOR 1
1 1
END griddata
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
END options

BEGIN dimensions
NLAY 1
NROW 1
NCOL 2
END dimensions

BEGIN griddata
delr
CONSTANT 100.00000000
delc
CONSTANT 1.00000000
top
CONSTANT 100.00000000
botm
CONSTANT 0.00000000
idomain
INTERNAL FACTOR 1
1 1
END griddata

28 changes: 14 additions & 14 deletions examples/data/ats0/gwf_ats01a.ghb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
PRINT_INPUT
PRINT_FLOWS
END options
BEGIN dimensions
MAXBOUND 1
END dimensions
BEGIN period 1
1 1 1 50.00000000 1.00000000
END period 1
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
PRINT_INPUT
PRINT_FLOWS
END options

BEGIN dimensions
MAXBOUND 1
END dimensions

BEGIN period 1
1 1 1 50.00000000 1.00000000
END period 1

12 changes: 6 additions & 6 deletions examples/data/ats0/gwf_ats01a.ic
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN griddata
strt
CONSTANT 50.00000000
END griddata
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN griddata
strt
CONSTANT 50.00000000
END griddata

44 changes: 22 additions & 22 deletions examples/data/ats0/gwf_ats01a.ims
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
PRINT_OPTION summary
END options
BEGIN nonlinear
OUTER_DVCLOSE 1.00000000E-06
OUTER_MAXIMUM 10
UNDER_RELAXATION dbd
UNDER_RELAXATION_THETA 0.70000000
END nonlinear
BEGIN linear
INNER_MAXIMUM 2
INNER_DVCLOSE 1.00000000E-06
inner_rclose 1.00000000E-06
LINEAR_ACCELERATION cg
RELAXATION_FACTOR 0.97000000
SCALING_METHOD none
REORDERING_METHOD none
END linear
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
PRINT_OPTION summary
END options

BEGIN nonlinear
OUTER_DVCLOSE 1.00000000E-06
OUTER_MAXIMUM 10
UNDER_RELAXATION dbd
UNDER_RELAXATION_THETA 0.70000000
END nonlinear

BEGIN linear
INNER_MAXIMUM 2
INNER_DVCLOSE 1.00000000E-06
inner_rclose 1.00000000E-06
LINEAR_ACCELERATION cg
RELAXATION_FACTOR 0.97000000
SCALING_METHOD none
REORDERING_METHOD none
END linear

30 changes: 15 additions & 15 deletions examples/data/ats0/gwf_ats01a.nam
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
END options
BEGIN packages
DIS6 gwf_ats01a.dis dis
IC6 gwf_ats01a.ic ic
NPF6 gwf_ats01a.npf npf
STO6 gwf_ats01a.sto sto
WEL6 gwf_ats01a.wel wel_0
GHB6 gwf_ats01a.ghb ghb_0
OC6 gwf_ats01a.oc oc
OBS6 gwf_ats01a.obs head_obs
END packages
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
END options

BEGIN packages
DIS6 gwf_ats01a.dis dis
IC6 gwf_ats01a.ic ic
NPF6 gwf_ats01a.npf npf
STO6 gwf_ats01a.sto sto
WEL6 gwf_ats01a.wel wel_0
GHB6 gwf_ats01a.ghb ghb_0
OC6 gwf_ats01a.oc oc
OBS6 gwf_ats01a.obs head_obs
END packages

22 changes: 11 additions & 11 deletions examples/data/ats0/gwf_ats01a.npf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
END options
BEGIN griddata
icelltype
CONSTANT 1
k
CONSTANT 1.00000000
END griddata
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
END options

BEGIN griddata
icelltype
CONSTANT 1
k
CONSTANT 1.00000000
END griddata

20 changes: 10 additions & 10 deletions examples/data/ats0/gwf_ats01a.obs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
DIGITS 20
END options
BEGIN continuous FILEOUT gwf_ats01a.obs.csv
obs1 head 1 1 1
obs2 head 1 1 2
END continuous FILEOUT gwf_ats01a.obs.csv
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
DIGITS 20
END options

BEGIN continuous FILEOUT gwf_ats01a.obs.csv
obs1 head 1 1 1
obs2 head 1 1 2
END continuous FILEOUT gwf_ats01a.obs.csv

28 changes: 14 additions & 14 deletions examples/data/ats0/gwf_ats01a.oc
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
BUDGET FILEOUT gwf_ats01a.cbc
BUDGETCSV FILEOUT gwf_ats01a.csv
HEAD FILEOUT gwf_ats01a.hds
HEAD PRINT_FORMAT COLUMNS 10 WIDTH 15 DIGITS 6 GENERAL
END options
BEGIN period 1
SAVE HEAD ALL
PRINT HEAD ALL
PRINT BUDGET ALL
END period 1
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
BUDGET FILEOUT gwf_ats01a.cbc
BUDGETCSV FILEOUT gwf_ats01a.csv
HEAD FILEOUT gwf_ats01a.hds
HEAD PRINT_FORMAT COLUMNS 10 WIDTH 15 DIGITS 6 GENERAL
END options

BEGIN period 1
SAVE HEAD ALL
PRINT HEAD ALL
PRINT BUDGET ALL
END period 1

34 changes: 17 additions & 17 deletions examples/data/ats0/gwf_ats01a.sto
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
END options
BEGIN griddata
iconvert
CONSTANT 1
ss
CONSTANT 0.00000000
sy
CONSTANT 0.10000000
END griddata
BEGIN period 1
TRANSIENT
END period 1
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
END options

BEGIN griddata
iconvert
CONSTANT 1
ss
CONSTANT 0.00000000
sy
CONSTANT 0.10000000
END griddata

BEGIN period 1
TRANSIENT
END period 1

28 changes: 14 additions & 14 deletions examples/data/ats0/gwf_ats01a.tdis
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
TIME_UNITS days
ATS6 FILEIN gwf_ats01a.ats
END options
BEGIN dimensions
NPER 1
END dimensions
BEGIN perioddata
10.00000000 1 1.00000000
END perioddata
# File generated by Flopy version 3.3.6 on 12/21/2022 at 10:15:53.
BEGIN options
TIME_UNITS days
ATS6 FILEIN gwf_ats01a.ats
END options

BEGIN dimensions
NPER 1
END dimensions

BEGIN perioddata
10.00000000 1 1.00000000
END perioddata

Loading

0 comments on commit a8e241d

Please sign in to comment.