Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/ex-prt-mp7-p01.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,4 +988,4 @@ def scenario(silent=False):


# We are now ready to run the example problem. Subproblems 1A and 1B are solved by a single MODFLOW 6 run and a single MODPATH 7 run, so they are included under one "scenario". Each of the two subproblems is represented by its own particle release package (for MODFLOW 6) or particle group (for MODPATH 7).
scenario(silent=True)
scenario()
32 changes: 5 additions & 27 deletions scripts/ex-prt-mp7-p02.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from pprint import pformat

import flopy
import flopy.utils.binaryfile as bf
import git
import matplotlib as mpl
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -464,11 +463,13 @@ def add_prp(part):

# Instantiate the MODFLOW 6 prt flow model interface
# using "time-reversed" budget and head files
gwf_headfile = f"{gwf_name}.hds"
gwf_budgetfile = f"{gwf_name}.cbb"
pd = [
("GWFHEAD", Path(f"../{gwf_ws.name}/{headfile_bkwd}")),
("GWFBUDGET", Path(f"../{gwf_ws.name}/{budgetfile_bkwd}")),
("GWFHEAD", Path(f"../{gwf_ws.name}/{gwf_headfile}")),
("GWFBUDGET", Path(f"../{gwf_ws.name}/{gwf_budgetfile}")),
]
flopy.mf6.ModflowPrtfmi(prt, packagedata=pd)
flopy.mf6.ModflowPrtfmi(prt, packagedata=pd, backward=True)

# Create an explicit model solution (EMS) for the MODFLOW 6 prt model
ems = flopy.mf6.ModflowEms(
Expand Down Expand Up @@ -547,32 +548,9 @@ def run_models(*sims, silent=False):
success, buff = sim.run_model(silent=silent, report=True)
assert success, pformat(buff)

if "gwf" in sim.name:
# Reverse budget and head files for backward tracking
reverse_budgetfile(gwf_ws / budgetfile, gwf_ws / budgetfile_bkwd, sim.tdis)
reverse_headfile(gwf_ws / headfile, gwf_ws / headfile_bkwd, sim.tdis)


# -

# Because this problem tracks particles backwards, we need to reverse the head and budget files after running the groundwater flow model and before running the particle tracking model. Define functions to do this.

# +


def reverse_budgetfile(fpth, rev_fpth, tdis):
f = bf.CellBudgetFile(fpth, tdis=tdis)
f.reverse(rev_fpth)


def reverse_headfile(fpth, rev_fpth, tdis):
f = bf.HeadFile(fpth, tdis=tdis)
f.reverse(rev_fpth)


# -


# Define a function to load pathline data from MODFLOW 6 PRT and MODPATH 7 pathline files.

# +
Expand Down
2 changes: 1 addition & 1 deletion scripts/ex-prt-mp7-p03.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,4 +939,4 @@ def scenario(silent=False):

# Run the MODPATH 7 example problem 3 scenario.

scenario(silent=True)
scenario()
23 changes: 4 additions & 19 deletions scripts/ex-prt-mp7-p04.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from pprint import pformat

import flopy
import flopy.utils.binaryfile as bf
import git
import matplotlib as mpl
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -609,9 +608,10 @@ def build_prt():
flopy.mf6.ModflowPrtfmi(
prt,
packagedata=[
("GWFHEAD", Path(f"../{gwf_ws.name}/{headfile_bkwd}")),
("GWFBUDGET", Path(f"../{gwf_ws.name}/{budgetfile_bkwd}")),
("GWFHEAD", Path(f"../{gwf_ws.name}/{headfile}")),
("GWFBUDGET", Path(f"../{gwf_ws.name}/{budgetfile}")),
],
backward=True,
)

# Create an explicit model solution (EMS) for the MODFLOW 6 prt model
Expand Down Expand Up @@ -658,16 +658,6 @@ def build_models():
return gwfsim, prtsim, mp7sim


def reverse_budgetfile(fpth, rev_fpth, tdis):
f = bf.CellBudgetFile(fpth, tdis=tdis)
f.reverse(rev_fpth)


def reverse_headfile(fpth, rev_fpth, tdis):
f = bf.HeadFile(fpth, tdis=tdis)
f.reverse(rev_fpth)


def write_models(*sims, silent=False):
for sim in sims:
if isinstance(sim, MFSimulation):
Expand All @@ -685,11 +675,6 @@ def run_models(*sims, silent=False):
success, buff = sim.run_model(silent=silent, report=True)
assert success, pformat(buff)

if "gwf" in sim.name:
# Reverse budget and head files for backward tracking
reverse_budgetfile(gwf_ws / budgetfile, gwf_ws / budgetfile_bkwd, sim.tdis)
reverse_headfile(gwf_ws / headfile, gwf_ws / headfile_bkwd, sim.tdis)


# -

Expand Down Expand Up @@ -960,6 +945,6 @@ def scenario(silent=False):


# Now run the scenario for example problem 4.
scenario(silent=False)
scenario()

# -
Loading