Skip to content

Commit

Permalink
feat(swf-pcp): add precipitation package for CHF and OLF models (#2160)
Browse files Browse the repository at this point in the history
* feat(swf-pcp): add precipitation package for CHF and OLF models

* fprettify

* update makefile

* update io guide

* apply precip to maximum top width of the channel
ensure cross sections are defined by at least 2 points
ensure precip is greater than or equal to zero
  • Loading branch information
langevin-usgs authored Jan 24, 2025
1 parent 2fb2872 commit 3f6af23
Show file tree
Hide file tree
Showing 37 changed files with 2,992 additions and 156 deletions.
30 changes: 21 additions & 9 deletions autotest/test_chf_dfw_swrt2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
from framework import TestFramework

cases = [
"chf-swr-t2",
"chf-swrt2-01",
"chf-swrt2-02",
]


def build_models(idx, test):
dx = 500.0
width = dx
nreach = 11
nper = 1
perlen = [5040 * 2 * 60.0] # 7 days (in seconds)
Expand Down Expand Up @@ -89,7 +91,7 @@ def build_models(idx, test):
export_array_ascii=True,
nodes=nodes,
nvert=nvert,
width=dx,
width=width,
bottom=reach_bottom,
idomain=1,
vertices=vertices,
Expand Down Expand Up @@ -131,13 +133,23 @@ def build_models(idx, test):
# flw
inflow_reach = 0
qinflow = 23.570
flw = flopy.mf6.ModflowChfflw(
chf,
maxbound=1,
print_input=True,
print_flows=True,
stress_period_data=[(inflow_reach, qinflow)],
)
if idx == 0:
flw = flopy.mf6.ModflowChfflw(
chf,
maxbound=1,
print_input=True,
print_flows=True,
stress_period_data=[(inflow_reach, qinflow)],
)

if idx == 1:
pcp = flopy.mf6.ModflowOlfpcp(
chf,
maxbound=1,
print_input=True,
print_flows=True,
stress_period_data=[(inflow_reach, qinflow / dx / width)],
)

chd = flopy.mf6.ModflowChfchd(
chf,
Expand Down
34 changes: 24 additions & 10 deletions autotest/test_olf_dfw_swrt2dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
from framework import TestFramework

cases = [
"olf-swr-t2-dis",
"olf-swrt2-dis01",
"olf-swrt2-dis02",
]


Expand Down Expand Up @@ -113,16 +114,29 @@ def build_models(idx, test):
],
)

# flw
qinflow = 23.570
spd = [(i, 0, qinflow) for i in range(nrow)]
flw = flopy.mf6.ModflowOlfflw(
olf,
maxbound=len(spd),
print_input=True,
print_flows=True,
stress_period_data=spd,
)

if idx == 0:
# apply inflow with flw package
spd = [(i, 0, qinflow) for i in range(nrow)]
flw = flopy.mf6.ModflowOlfflw(
olf,
maxbound=len(spd),
print_input=True,
print_flows=True,
stress_period_data=spd,
)

if idx == 1:
# apply inflow with pcp package
spd = spd = [(i, 0, qinflow / dx**2) for i in range(nrow)]
pcp = flopy.mf6.ModflowOlfpcp(
olf,
maxbound=len(spd),
print_input=True,
print_flows=True,
stress_period_data=spd,
)

spd = [(i, ncol - 1, 1.05) for i in range(nrow)]
chd = flopy.mf6.ModflowOlfchd(
Expand Down
4 changes: 4 additions & 0 deletions doc/mf6io/chf/chf.tex
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ \subsection{Constant Head (CHD) Package}
\subsection{Inflow (FLW) Package}
\input{chf/flw}

\newpage
\subsection{Precipitation (PCP) Package}
\input{chf/pcp}

\newpage
\subsection{Zero-Depth Gradient (ZDG) Package}
\input{chf/zdg}
Expand Down
47 changes: 47 additions & 0 deletions doc/mf6io/chf/pcp.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Input to the Precipitation (PCP) Package is read from the file that has type ``PCP6'' in the Name File. Any number of PCP Packages can be specified for a single surface water flow model.

\vspace{5mm}
\subsubsection{Structure of Blocks}
\vspace{5mm}

\noindent \textit{FOR EACH SIMULATION}
\lstinputlisting[style=blockdefinition]{./mf6ivar/tex/chf-pcp-options.dat}
\lstinputlisting[style=blockdefinition]{./mf6ivar/tex/chf-pcp-dimensions.dat}
\vspace{5mm}
\noindent \textit{FOR ANY STRESS PERIOD}
\lstinputlisting[style=blockdefinition]{./mf6ivar/tex/chf-pcp-period.dat}
\packageperioddescription

\vspace{5mm}
\subsubsection{Explanation of Variables}
\begin{description}
\input{./mf6ivar/tex/chf-pcp-desc.tex}
\end{description}

\vspace{5mm}
\subsubsection{Example Input File}
\lstinputlisting[style=inputfile]{./mf6ivar/examples/chf-pcp-example.dat}

%\vspace{5mm}
%\subsubsection{Available observation types}
%Well Package observations include the simulated well rates (\texttt{wel}), the well discharge that is available for the MVR package (\texttt{to-mvr}), and the reduction in the specified \texttt{q} when the \texttt{AUTO\_FLOW\_REDUCE} option is enabled. The data required for each WEL Package observation type is defined in table~\ref{table:gwf-welobstype}. The sum of \texttt{wel} and \texttt{to-mvr} is equal to the simulated well discharge rate, which may be less than the specified \texttt{q} if the \texttt{AUTO\_FLOW\_REDUCE} option is enabled. The \texttt{DNODATA} value is returned if the \texttt{wel-reduction} observation is specified but the \texttt{AUTO\_FLOW\_REDUCE} option is not enabled. Negative and positive values for an observation represent a loss from and gain to the GWF model, respectively.

%\begin{longtable}{p{2cm} p{2.75cm} p{2cm} p{1.25cm} p{7cm}}
%\caption{Available WEL Package observation types} \tabularnewline

%\hline
%\hline
%\textbf{Stress Package} & \textbf{Observation type} & \textbf{ID} & \textbf{ID2} & \textbf{Description} \\
%\hline
%\endhead

%\hline
%\endfoot

%\input{../Common/gwf-welobs.tex}
%\label{table:gwf-welobstype}
%\end{longtable}

%\vspace{5mm}
%\subsubsection{Example Observation Input File}
%\lstinputlisting[style=inputfile]{./mf6ivar/examples/gwf-wel-example-obs.dat}
2 changes: 1 addition & 1 deletion doc/mf6io/mf6ivar/dfn/chf-cxs.dfn
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ tagged false
in_record true
reader urword
longname number of points used to define cross section
description integer value that defines the number of points used to define the define the shape of a section. NXSPOINTS must be greater than zero or the program will terminate with an error. NXSPOINTS defines the number of points that must be entered for the reach in the CROSSSECTIONDATA block. The sum of NXSPOINTS for all sections must equal the NPOINTS dimension.
description integer value that defines the number of points used to define the define the shape of a section. NXSPOINTS must be greater than 1 or the program will terminate with an error. NXSPOINTS defines the number of points that must be entered for the reach in the CROSSSECTIONDATA block. The sum of NXSPOINTS for all sections must equal the NPOINTS dimension.

# --------------------- chf cxs crosssectiondata ---------------------

Expand Down
211 changes: 211 additions & 0 deletions doc/mf6io/mf6ivar/dfn/chf-pcp.dfn
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
# --------------------- swf pcp options ---------------------
# flopy multi-package

block options
name auxiliary
type string
shape (naux)
reader urword
optional true
longname keyword to specify aux variables
description REPLACE auxnames {'{#1}': 'Surface Water Flow'}

block options
name auxmultname
type string
shape
reader urword
optional true
longname name of auxiliary variable for multiplier
description REPLACE auxmultname {'{#1}': 'precipitation'}

block options
name boundnames
type keyword
shape
reader urword
optional true
longname
description REPLACE boundnames {'{#1}': 'precipitation'}

block options
name print_input
type keyword
reader urword
optional true
longname print input to listing file
description REPLACE print_input {'{#1}': 'precipitation'}
mf6internal iprpak

block options
name print_flows
type keyword
reader urword
optional true
longname print precipitation rates to listing file
description REPLACE print_flows {'{#1}': 'precipitation'}
mf6internal iprflow

block options
name save_flows
type keyword
reader urword
optional true
longname save precipitation to budget file
description REPLACE save_flows {'{#1}': 'precipitation'}
mf6internal ipakcb

block options
name ts_filerecord
type record ts6 filein ts6_filename
shape
reader urword
tagged true
optional true
longname
description

block options
name ts6
type keyword
shape
in_record true
reader urword
tagged true
optional false
longname head keyword
description keyword to specify that record corresponds to a time-series file.

block options
name filein
type keyword
shape
in_record true
reader urword
tagged true
optional false
longname file keyword
description keyword to specify that an input filename is expected next.

block options
name ts6_filename
type string
preserve_case true
in_record true
reader urword
optional false
tagged false
longname file name of time series information
description REPLACE timeseriesfile {}

block options
name obs_filerecord
type record obs6 filein obs6_filename
shape
reader urword
tagged true
optional true
longname
description

block options
name obs6
type keyword
shape
in_record true
reader urword
tagged true
optional false
longname obs keyword
description keyword to specify that record corresponds to an observations file.

block options
name obs6_filename
type string
preserve_case true
in_record true
tagged false
reader urword
optional false
longname obs6 input filename
description REPLACE obs6_filename {'{#1}': 'Precipitation'}

# --------------------- swf pcp dimensions ---------------------

block dimensions
name maxbound
type integer
reader urword
optional false
longname maximum number of precipitation cells
description REPLACE maxbound {'{#1}': 'precipitation cells'}


# --------------------- swf pcp period ---------------------

block period
name iper
type integer
block_variable True
in_record true
tagged false
shape
valid
reader urword
optional false
longname stress period number
description REPLACE iper {}

block period
name stress_period_data
type recarray cellid precipitation aux boundname
shape (maxbound)
reader urword
longname
description
mf6internal spd

block period
name cellid
type integer
shape (ncelldim)
tagged false
in_record true
reader urword
longname cell identifier
description REPLACE cellid {}

block period
name precipitation
type double precision
shape
tagged false
in_record true
reader urword
time_series true
longname precipitation rate
description is the precipitation flux rate ($LT^{-1}$). This rate is multiplied inside the program by the surface area of the cell to calculate the volumetric precipitation rate. If the Options block includes a TIMESERIESFILE entry (see the ``Time-Variable Input'' section), values can be obtained from a time series by entering the time-series name in place of a numeric value.

block period
name aux
type double precision
in_record true
tagged false
shape (naux)
reader urword
optional true
time_series true
longname auxiliary variables
description REPLACE aux {'{#1}': 'precipitation'}
mf6internal auxvar

block period
name boundname
type string
shape
tagged false
in_record true
reader urword
optional true
longname precipitation name
description REPLACE boundname {'{#1}': 'precipitation'}
4 changes: 2 additions & 2 deletions doc/mf6io/mf6ivar/dfn/olf-flw.dfn
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ tagged false
in_record true
reader urword
time_series true
longname well rate
description is the volumetric inflow rate. A positive value indicates inflow to the stream. Negative values are not allows. If the Options block includes a TIMESERIESFILE entry (see the ``Time-Variable Input'' section), values can be obtained from a time series by entering the time-series name in place of a numeric value.
longname flow rate
description is the volumetric inflow rate. A positive value indicates inflow to the stream. Negative values are not allowed. If the Options block includes a TIMESERIESFILE entry (see the ``Time-Variable Input'' section), values can be obtained from a time series by entering the time-series name in place of a numeric value.

block period
name aux
Expand Down
Loading

0 comments on commit 3f6af23

Please sign in to comment.