Skip to content

Commit

Permalink
feat(mf6): Update t503 autotest to use mf6examples zip file (#1007)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhughes-usgs committed Oct 21, 2020
1 parent 0bc91e4 commit 133f07f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 23 deletions.
67 changes: 47 additions & 20 deletions autotest/t503_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
import pymake


def download_mf6_distribution():
def download_mf6_examples():
"""
Download mf6 distribution and return location of folder
Download mf6 examples and return location of folder
"""

# set url
dirname = 'mf6.1.0'
url = 'https://water.usgs.gov/water-resources/software/' + \
'MODFLOW-6/{0}.zip'.format(dirname)
dirname = "mf6examples"
url = "https://github.com/MODFLOW-USGS/modflow6-examples/releases/" + \
"download/current/modflow6-examples.zip"

# create folder for mf6 distribution download
cpth = os.getcwd()
dstpth = os.path.join('temp', 'mf6dist')
dstpth = os.path.join('temp', dirname)
print('create...{}'.format(dstpth))
if not os.path.exists(dstpth):
os.makedirs(dstpth)
Expand All @@ -30,26 +30,53 @@ def download_mf6_distribution():
os.chdir(cpth)

# return the absolute path to the distribution
mf6path = os.path.abspath(os.path.join(dstpth, dirname))
mf6path = os.path.abspath(dstpth)

return mf6path


out_dir = os.path.join('temp', 't503')
out_dir = os.path.join("temp", "t503")
if os.path.exists(out_dir):
shutil.rmtree(out_dir)
os.mkdir(out_dir)

mf6path = download_mf6_distribution()
distpth = os.path.join(mf6path, 'examples')
folders = sorted([f for f in os.listdir(distpth)
if os.path.isdir(os.path.join(distpth, f))])

for f in folders:
src = os.path.join(distpth, f)
dst = os.path.join(out_dir, f)
print('copying {}'.format(f))
mf6path = download_mf6_examples()
distpth = os.path.join(mf6path)
# folders = sorted([f for f in os.listdir(distpth)
# if os.path.isdir(os.path.join(distpth, f))])

exclude_models = ("gwt",)
exclude_examples = ("sagehen", "keating",)
src_folders = []

for dirName, subdirList, fileList in os.walk(mf6path):
dirBase = os.path.basename(os.path.normpath(dirName))
useModel = True
for exclude in exclude_models:
if exclude in dirBase:
useModel = False
break
if useModel:
for exclude in exclude_examples:
if exclude in dirBase:
useModel = False
break
if useModel:
for file_name in fileList:
if file_name.lower() == "mfsim.nam":
print('Found directory: {}'.format(dirName))
src_folders.append(dirName)
src_folders = sorted(src_folders)

folders = []
for src in src_folders:
dirBase = src.partition("{0}mf6examples{0}".format(os.path.sep))[2]
dst = os.path.join(out_dir, dirBase)

print('copying {} -> {}'.format(src, dst))
folders.append(dst)
shutil.copytree(src, dst)
folders = sorted(folders)

exe_name = 'mf6'
v = flopy.which(exe_name)
Expand All @@ -58,14 +85,14 @@ def download_mf6_distribution():
run = False


def runmodel(f):
def runmodel(folder):
f = os.path.basename(os.path.normpath(folder))
print('\n\n')
print('**** RUNNING TEST: {} ****'.format(f))
print('\n')

# load the model into a flopy simulation
folder = os.path.join(out_dir, f)
print('loading {}'.format(folder))
print('loading {}'.format(f))
sim = flopy.mf6.MFSimulation.load(f, 'mf6', exe_name, folder)
assert isinstance(sim, flopy.mf6.MFSimulation)

Expand Down
2 changes: 1 addition & 1 deletion flopy/mf6/data/dfn/gwt-dsp.dfn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ shape
reader urword
optional true
longname deactivate xt3d
description deactivate the xt3d method to and use the faster and less accurate approximation. This option may provide a fast and accurate solution under some circumstances, such as when flow aligns with the model grid, there is no mechanical dispersion, or when the longitudinal and transverse dispersivities are equal. This option may also be used to assess the computational demand of the XT3D approach by noting the run time differences with and without this option on.
description deactivate the xt3d method and use the faster and less accurate approximation. This option may provide a fast and accurate solution under some circumstances, such as when flow aligns with the model grid, there is no mechanical dispersion, or when the longitudinal and transverse dispersivities are equal. This option may also be used to assess the computational demand of the XT3D approach by noting the run time differences with and without this option on.

block options
name xt3d_rhs
Expand Down
4 changes: 2 additions & 2 deletions flopy/mf6/modflow/mfgwtdsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class ModflowGwtdsp(mfpackage.MFPackage):
Do not set this parameter. It is intended for debugging and internal
processing purposes only.
xt3d_off : boolean
* xt3d_off (boolean) deactivate the xt3d method to and use the faster
and less accurate approximation. This option may provide a fast and
* xt3d_off (boolean) deactivate the xt3d method and use the faster and
less accurate approximation. This option may provide a fast and
accurate solution under some circumstances, such as when flow aligns
with the model grid, there is no mechanical dispersion, or when the
longitudinal and transverse dispersivities are equal. This option may
Expand Down

0 comments on commit 133f07f

Please sign in to comment.