Skip to content

Commit

Permalink
Fixes in response to MODFLOW-USGS#1493 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
emorway-usgs committed Dec 30, 2023
1 parent 27d7741 commit 49d33cf
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 41 deletions.
11 changes: 4 additions & 7 deletions autotest/test_gwe_drycell_conduction0.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@
scheme = "UPSTREAM"
# scheme = "TVD"

ex = ["drycell0"]
exdirs = []
for s in ex:
exdirs.append(os.path.join("temp", s))
cases = ["drycell0"]

# Model units
length_units = "meters"
Expand Down Expand Up @@ -116,7 +113,7 @@
def build_models(idx, test):
# Base MF6 GWF model type
ws = test.workspace
name = ex[idx]
name = cases[idx]

print("Building MF6 model...()".format(name))

Expand Down Expand Up @@ -345,7 +342,7 @@ def check_output(idx, test):
print("evaluating results...")

# read transport results from GWE model
name = ex[idx]
name = cases[idx]
gwename = "gwe-" + name

fpth = os.path.join(test.workspace, f"{gwename}.ucn")
Expand Down Expand Up @@ -411,7 +408,7 @@ def check_output(idx, test):
# - No need to change any code below
@pytest.mark.parametrize(
"idx, name",
list(enumerate(ex)),
list(enumerate(cases)),
)
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
Expand Down
11 changes: 6 additions & 5 deletions autotest/test_gwe_drycell_conduction1.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

from framework import TestFramework


# Monotonicity function
def isMonotonic(A):
x, y = [], []
Expand All @@ -56,7 +57,7 @@ def isMonotonic(A):
scheme = "UPSTREAM"
# scheme = "TVD"

ex = [
cases = [
"drycell2-a", # 2-cell model, horizontally connected with tops and bots aligned
"drycell2-b", # 2-cell model, vertically connected
"drycell2-c", # 2-cell model, horizontally connected with staggered alignment (reduced shared cell face area)
Expand Down Expand Up @@ -151,7 +152,7 @@ def build_models(idx, test):

# Base MF6 GWF model type
ws = test.workspace
name = ex[idx]
name = cases[idx]

print("Building MF6 model...()".format(name))

Expand Down Expand Up @@ -397,7 +398,7 @@ def check_output(idx, test):
print("evaluating results...")

# read transport results from GWE model
name = ex[idx]
name = cases[idx]
gwename = "gwe-" + name

# All indices are 0 based
Expand Down Expand Up @@ -468,14 +469,14 @@ def check_output(idx, test):
# - No need to change any code below
@pytest.mark.parametrize(
"idx, name",
list(enumerate(ex)),
list(enumerate(cases)),
)
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
workspace=function_tmpdir,
targets=targets,
build=lambda t: build_models(idx, t),
check=lambda t: check_output(idx, t)
check=lambda t: check_output(idx, t),
)
test.run()
44 changes: 22 additions & 22 deletions autotest/test_gwe_drycell_conduction2.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

# Base simulation and model name and workspace


def my_ceil(a, precision=0):
return np.round(a + 0.5 * 10 ** (-precision), precision)

Expand All @@ -76,10 +77,7 @@ def isMonotonic(A):
scheme = "UPSTREAM"
# scheme = "TVD"

ex = ["drycl-cnduct"]
exdirs = []
for s in ex:
exdirs.append(os.path.join("temp", s))
cases = ["drycl-cnduct"]

# Model units
length_units = "meters"
Expand Down Expand Up @@ -192,7 +190,7 @@ def isMonotonic(A):
def build_models(idx, test):
# Base MF6 GWF model type
ws = test.workspace
name = ex[idx]
name = cases[idx]

print("Building MF6 model...()".format(name))

Expand Down Expand Up @@ -537,7 +535,7 @@ def check_output(idx, test):
print("evaluating results...")

# read transport results from GWE model
name = ex[idx]
name = cases[idx]
gwfname = "gwf-" + name
gwtname = "gwt-" + name
gwename = "gwe-" + name
Expand Down Expand Up @@ -618,10 +616,10 @@ def check_output(idx, test):
assert np.all(
np.diff(temp1[-1, :, 0, :-1]) < 0
), "Temperature change in the downstream direction should be negative"
assert isMonotonic(
np.diff(temp1[-1, :, 0, :-1])
), "A monotonic increase in the amount of heat lost to neighboring dry " \
"cells is expected"
assert isMonotonic(np.diff(temp1[-1, :, 0, :-1])), (
"A monotonic increase in the amount of heat lost to neighboring dry "
"cells is expected"
)

# Check temporal changes in temperature in the most upstream and downstream
# dry cells. Cell bottoms in row 2 were calculated using a rounding function
Expand All @@ -631,32 +629,34 @@ def check_output(idx, test):
# also conduction among its two dry neighbors (also with variable thickness
colid = 0
m_arr = np.diff(temp1[1:, 0, 1, colid])
assert isMonotonic(
m_arr
), "Temperatures should be monotonically tapering-off in their " \
"relative temperature increase with time in the upstream-most" \
"dry cell"
assert isMonotonic(m_arr), (
"Temperatures should be monotonically tapering-off in their "
"relative temperature increase with time in the upstream-most"
"dry cell"
)

colid = 11
m_arr = np.diff(temp1[1:, 0, 1, colid])
assert isMonotonic(
m_arr
), "Temperatures should be monotonically tapering-off in their " \
"relative temperature increase with time in the downstream-most" \
"dry cell"
assert isMonotonic(m_arr), (
"Temperatures should be monotonically tapering-off in their "
"relative temperature increase with time in the downstream-most"
"dry cell"
)

# Run a few checks between GWE and its GWT counterpart
# In GWT there is no solute interaction with a dry cell, so concentrations
# in the dry cell should remain inactive (i.e., no "molecular diffusion")
# and greater than their GWE counterpart temperatures since there is
# no "retardation" of concentration (temperature) owing to conduction
assert np.all(conc1[:, :, 1, :] < 0), "The dry cells should never have a non-inactive concentration value"
assert np.all(
conc1[:, :, 1, :] < 0
), "The dry cells should never have a non-inactive concentration value"


# - No need to change any code below
@pytest.mark.parametrize(
"idx, name",
list(enumerate(ex)),
list(enumerate(cases)),
)
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
Expand Down
11 changes: 4 additions & 7 deletions autotest/test_gwe_dsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@
# Base simulation and model name and workspace

viscosity_on = [False]
ex = ["dsp01"]
exdirs = []
for s in ex:
exdirs.append(os.path.join("temp", s))
cases = ["dsp01"]

# Model units

Expand Down Expand Up @@ -124,7 +121,7 @@
def build_models(idx, test):
# Base MF6 GWE model type
ws = test.workspace
name = ex[idx]
name = cases[idx]

print("Building MF6 model...()".format(name))

Expand Down Expand Up @@ -358,7 +355,7 @@ def check_output(idx, test):
print("evaluating results...")

# read transport results from GWE model
name = ex[idx]
name = cases[idx]
gwename = "gwe-" + name

fpth = os.path.join(test.workspace, f"{gwename}.ucn")
Expand Down Expand Up @@ -483,7 +480,7 @@ def check_output(idx, test):
# - No need to change any code below
@pytest.mark.parametrize(
"idx, name",
list(enumerate(ex)),
list(enumerate(cases)),
)
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
Expand Down

0 comments on commit 49d33cf

Please sign in to comment.