From e833199b6497329b1ecada74b1865522f847b4a8 Mon Sep 17 00:00:00 2001 From: jdhughes-usgs Date: Wed, 21 Oct 2020 11:45:57 -0400 Subject: [PATCH] feat(mf6): Update t503 autotest to use mf6examples zip file --- autotest/t503_test.py | 67 ++++++++++++++++++++++++---------- flopy/mf6/data/dfn/gwt-dsp.dfn | 2 +- flopy/mf6/modflow/mfgwtdsp.py | 4 +- 3 files changed, 50 insertions(+), 23 deletions(-) diff --git a/autotest/t503_test.py b/autotest/t503_test.py index 797e2eea14..d7a30a7cbb 100644 --- a/autotest/t503_test.py +++ b/autotest/t503_test.py @@ -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) @@ -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) @@ -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) diff --git a/flopy/mf6/data/dfn/gwt-dsp.dfn b/flopy/mf6/data/dfn/gwt-dsp.dfn index 62df43101f..ea56e8c0f6 100644 --- a/flopy/mf6/data/dfn/gwt-dsp.dfn +++ b/flopy/mf6/data/dfn/gwt-dsp.dfn @@ -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 diff --git a/flopy/mf6/modflow/mfgwtdsp.py b/flopy/mf6/modflow/mfgwtdsp.py index d5a119d537..493fff4114 100644 --- a/flopy/mf6/modflow/mfgwtdsp.py +++ b/flopy/mf6/modflow/mfgwtdsp.py @@ -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