Note
This page was generated from Notebooks/drain_return_example. Download as
.
a Jupyter notebook (.ipynb) or Python script (.py) or launch interactively with Binder Flopy Drain Return (DRT) capabilities
[1]:
import os
[2]:
import sys
from tempfile import TemporaryDirectory
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import flopy
print(sys.version)
print("numpy version: {}".format(np.__version__))
print("matplotlib version: {}".format(mpl.__version__))
print("flopy version: {}".format(flopy.__version__))
3.8.17 (default, Jun 7 2023, 12:29:56)
[GCC 11.3.0]
numpy version: 1.24.4
matplotlib version: 3.7.2
flopy version: 3.4.2
[3]:
# temporary directory
temp_dir = TemporaryDirectory()
modelpth = temp_dir.name
# creat the model package
m = flopy.modflow.Modflow(
"drt_test",
model_ws=modelpth,
exe_name="mfnwt",
version="mfnwt",
)
d = flopy.modflow.ModflowDis(
m,
nlay=1,
nrow=10,
ncol=10,
nper=1,
perlen=1,
top=10,
botm=0,
steady=True,
)
b = flopy.modflow.ModflowBas(m, strt=10, ibound=1)
u = flopy.modflow.ModflowUpw(m, hk=10)
n = flopy.modflow.ModflowNwt(m)
o = flopy.modflow.ModflowOc(m)
[4]:
# create the drt package
spd = []
for i in range(m.nrow):
spd.append([0, i, m.ncol - 1, 5.0, 50.0, 1, 1, 1, 1.0])
d = flopy.modflow.ModflowDrt(m, stress_period_data={0: spd})
[5]:
# run the drt model
m.write_input()
success, buff = m.run_model(silent=True, report=True)
if success:
for line in buff:
print(line)
else:
raise ValueError("Failed to run.")
MODFLOW-NWT-SWR1
U.S. GEOLOGICAL SURVEY MODULAR FINITE-DIFFERENCE GROUNDWATER-FLOW MODEL
WITH NEWTON FORMULATION
Version 1.3.0 07/01/2022
BASED ON MODFLOW-2005 Version 1.12.0 02/03/2017
SWR1 Version 1.05.0 03/10/2022
Using NAME file: drt_test.nam
Run start date and time (yyyy/mm/dd hh:mm:ss): 2023/08/25 23:26:50
Solving: Stress period: 1 Time step: 1 Groundwater-Flow Eqn.
Run end date and time (yyyy/mm/dd hh:mm:ss): 2023/08/25 23:26:50
Elapsed run time: 0.001 Seconds
Normal termination of simulation
[6]:
# plot heads for the drt model
hds = flopy.utils.HeadFile(os.path.join(m.model_ws, m.name + ".hds"))
hds.plot(colorbar=True)
[6]:
<Axes: title={'center': 'data Layer 1'}>
[7]:
# remove the drt package and create a standard drain file
spd = []
for i in range(m.nrow):
spd.append([0, i, m.ncol - 1, 5.0, 1.0])
m.remove_package("DRT")
d = flopy.modflow.ModflowDrn(m, stress_period_data={0: spd})
[8]:
# run the drain model
m.write_input()
success, buff = m.run_model(silent=True, report=True)
if success:
for line in buff:
print(line)
else:
raise ValueError("Failed to run.")
MODFLOW-NWT-SWR1
U.S. GEOLOGICAL SURVEY MODULAR FINITE-DIFFERENCE GROUNDWATER-FLOW MODEL
WITH NEWTON FORMULATION
Version 1.3.0 07/01/2022
BASED ON MODFLOW-2005 Version 1.12.0 02/03/2017
SWR1 Version 1.05.0 03/10/2022
Using NAME file: drt_test.nam
Run start date and time (yyyy/mm/dd hh:mm:ss): 2023/08/25 23:26:50
Solving: Stress period: 1 Time step: 1 Groundwater-Flow Eqn.
Run end date and time (yyyy/mm/dd hh:mm:ss): 2023/08/25 23:26:50
Elapsed run time: 0.002 Seconds
Normal termination of simulation
[9]:
# plot the heads for the model with the drain
hds = flopy.utils.HeadFile(os.path.join(m.model_ws, m.name + ".hds"))
hds.plot(colorbar=True)
[9]:
<Axes: title={'center': 'data Layer 1'}>
[10]:
try:
# ignore PermissionError on Windows
temp_dir.cleanup()
except:
pass