diff --git a/autotest/test_gwf_sfr_inactive.py b/autotest/test_gwf_sfr_inactive.py index f3993681d1b..47ea86849d3 100644 --- a/autotest/test_gwf_sfr_inactive.py +++ b/autotest/test_gwf_sfr_inactive.py @@ -1,4 +1,28 @@ -# test based on issue 1585 fix +""" +This test inactivation of SFR reaches during a simulation. +The test is based on the example provided with issue 1585, +which resulted in a divide by zero error when reaches were +inactivated in the second stress period. + +The test has 6 sfr reaches that are not connected to the +groundwater model. + + Reaches + 1 -o- 2 -o- 3 -o- 4 -o- 5 -o- 6 + +Test parameters: + + 1. initially all reaches are active + 2. in the 2nd stress period reaches 4, 5, and 6 are + inactivated + 3. in the 3rd stress period reach 4 is reactivated + 4. in the 4th stress period reach 5 is reactivated + 5. in the 5th stress period reach 6 is reactivated + +The test evaluates OUTFLOW and EXT-OUTFLOW for reaches +3, 4, 5, and 6 against expected values. +""" + import flopy import numpy as np import pytest @@ -12,7 +36,7 @@ def build_models(idx, test): # static model data # temporal discretization - nper = 2 + nper = 5 tdis_rc = [] for _ in range(nper): tdis_rc.append((1.0, 1, 1.0)) @@ -188,16 +212,22 @@ def build_models(idx, test): [4, "status", "inactive"], [5, "status", "inactive"], ], + 2: [ + [3, "status", "active"], + ], + 3: [ + [4, "status", "active"], + ], + 4: [ + [5, "status", "active"], + ], } - sfr_dict = { - f"{paktest}_obs.csv": [ - ("r3_out", "outflow", (2,)), - ("r3_ext", "ext-outflow", (2,)), - ("r6_out", "outflow", (5,)), - ("r6_ext", "ext-outflow", (5,)), - ] - } + sfr_obs = [] + for i in range(2, 6): + sfr_obs.append((f"r{i + 1}_out", "outflow", (i,))) + sfr_obs.append((f"r{i + 1}_ext", "ext-outflow", (i,))) + sfr_dict = {f"{paktest}_obs.csv": sfr_obs} sfr = flopy.mf6.ModflowGwfsfr( gwf, print_stage=True, @@ -224,10 +254,14 @@ def check_output(idx, test): print("Checking sfr outflow and external outflow") obs_values = flopy.utils.Mf6Obs(test.workspace / f"{paktest}_obs.csv") test_values = { - "R3_OUT": [-1.0, 0.0], - "R3_EXT": [0.0, -1.0], - "R6_OUT": [0.0, 0.0], - "R6_EXT": [-1.0, 0.0], + "R3_OUT": [-1.0, 0.0, -1.0, -1.0, -1.0], + "R3_EXT": [0.0, -1.0, 0.0, 0.0, 0.0], + "R6_OUT": [0.0, 0.0, 0.0, 0.0, 0.0], + "R6_EXT": [-1.0, 0.0, 0.0, 0.0, -1.0], + "R4_OUT": [-1.0, 0.0, 0.0, -1.0, -1.0], + "R4_EXT": [0.0, 0.0, -1.0, 0.0, 0.0], + "R5_OUT": [-1.0, 0.0, 0.0, 0.0, -1.0], + "R5_EXT": [0.0, 0.0, 0.0, -1.0, 0.0], } for key, value in test_values.items(): assert np.array_equal( diff --git a/doc/ReleaseNotes/develop.tex b/doc/ReleaseNotes/develop.tex index cbef622e93b..188a45ba0fc 100644 --- a/doc/ReleaseNotes/develop.tex +++ b/doc/ReleaseNotes/develop.tex @@ -17,7 +17,7 @@ % \item xxx %\end{itemize} - %\textbf{\underline{BUG FIXES AND OTHER CHANGES TO EXISTING FUNCTIONALITY}} \\ + \textbf{\underline{BUG FIXES AND OTHER CHANGES TO EXISTING FUNCTIONALITY}} \\ %\underline{BASIC FUNCTIONALITY} %\begin{itemize} % \item xxx @@ -39,12 +39,12 @@ % \item xxx %\end{itemize} - %\underline{ADVANCED STRESS PACKAGES} - %\begin{itemize} - % \item + \underline{ADVANCED STRESS PACKAGES} + \begin{itemize} + \item A divide by zero error would occur in the Streamflow Routing package when reaches were deactivated during a simulation. This bug was fixed by checking if the downstream reach is inactive before calculating the flow to the downstream reach. % \item xxx % \item xxx - %\end{itemize} + \end{itemize} %\underline{SOLUTION} %\begin{itemize}