Exemplo n.º 1
0
def test_mt3d():
    for spth in test_dirs:
        # -- get modflow name files
        namefilesmf = []
        pth = config.testpaths[2]
        tpth = os.path.join(pth, spth)
        namefilesmf += get_namefiles(tpth, exclude='mt')
        # -- get mt3d name files
        namefilesmt = []
        tpth = os.path.join(pth, spth)
        namefilesmt += get_namefiles(tpth, exclude='mf')
        # -- process name files
        for (nm1, nm2) in zip(namefilesmf, namefilesmt):
            yield run_mt3d, nm1, nm2
    return
Exemplo n.º 2
0
def test_mfusg():
    namefiles = []
    for pth in config.testpaths[0:2]:
        namefiles += get_namefiles(pth, exclude='.cmp')
    # for namefile in ['../test-reg/test042_45usg/45usg.nam']:
    for namefile in namefiles:
        yield run_mfusg, namefile
    return
Exemplo n.º 3
0
def test_mf2005():
    target = config.target_release
    assert os.path.isfile(target), 'Target {} does not exist.'.format(target)
    target = config.target_previous
    assert os.path.isfile(target), 'Target {} does not exist.'.format(target)

    namefiles = get_namefiles(config.testpaths[0], exclude=config.exclude)
    for namefile in namefiles:
        yield run_mf2005, namefile
    return
Exemplo n.º 4
0
def test_mfusg():
    if config.exclude is None:
        exclude = []
    else:
        exclude = list(config.exclude)
    exclude.append('.cmp')
    namefiles = get_namefiles(config.testpaths[2], exclude=exclude)
    for namefile in namefiles:
        yield run_mfusg, namefile
    return
Exemplo n.º 5
0
    if os.path.isfile(config.target_previous):
        print('Removing ' + config.target_previous)
        os.remove(config.target_previous)

    if os.path.isfile(config.target_release):
        print('Removing ' + config.target_release)
        os.remove(config.target_release)

    # remove release source files if target was built
    if os.path.isdir(config.dir_release):
        print('Removing folder ' + config.dir_release)
        shutil.rmtree(config.dir_release)

    # remove previous release source files if target was built
    if os.path.isdir(config.dir_previous):
        print('Removing folder ' + config.dir_previous)
        shutil.rmtree(config.dir_previous)

    return


if __name__ == '__main__':
    test_compile_ref()
    test_compile_prev()

    namefiles = get_namefiles(config.testpaths[0], exclude=config.exclude)
    for namefile in namefiles:
        run_mf2005(namefile)

    test_teardown()
Exemplo n.º 6
0
        tpth = os.path.join(pth, spth)
        namefilesmt += get_namefiles(tpth, exclude='mf')
        # -- process name files
        for (nm1, nm2) in zip(namefilesmf, namefilesmt):
            yield run_mt3d, nm1, nm2
    return


if __name__ == '__main__':
    for spth in test_dirs:
        # -- initialize name file lists
        namefilesmf5 = []
        namefilesmf6 = []
        namefilesmt = []

        # -- get pre-MF6 directory
        pth = config.testpaths[2]
        tpth = os.path.join(pth, spth, 'mf5_' + spth)
        namefilesmf5 += get_namefiles(tpth, exclude='_mt')

        # -- get pre-MF6 directory
        tpth = os.path.join(pth, spth, 'mf6_' + spth)
        namefilesmf6 += get_namefiles(tpth, exclude=spth + '.nam')

        # -- get mt3d name files
        tpth = os.path.join(pth, spth, 'mt_' + spth)
        namefilesmt += get_namefiles(tpth)

        # -- process name files
        run_mt3d(str(namefilesmf5[0]), str(namefilesmf6[0]), namefilesmt)
Exemplo n.º 7
0
def run_mt3d(spth, comparison=True):
    """
    Run the simulations.

    """

    # Path to folder containing tests
    pth = config.testpaths[0]

    # -- get modflow name files
    tpth = os.path.join(pth, spth)
    namefilesmf = []
    namefilesmf += get_namefiles(tpth, exclude='mt')

    # -- get mt3d name files
    tpth = os.path.join(pth, spth)
    namefilesmt = []
    namefilesmt += get_namefiles(tpth, exclude='mf')

    mfnamefile = namefilesmf[0]
    mtnamefile = namefilesmt[0]
    print(mfnamefile, mtnamefile)

    # Set root as the directory name where namefile is located
    testname = pymake.get_sim_name(mfnamefile.replace('_mf', ''),
                                   rootpth=os.path.dirname(mfnamefile))[0]

    # Setup modflow
    testpth = os.path.join(config.testdir, testname)
    pymake.setup(mfnamefile, testpth)
    # Setup mt3d
    pymake.setup(mtnamefile, testpth, remove_existing=False)

    # Remove HSS file reference line from MT3D-USGS name file
    f = open(mtnamefile, 'r')
    lines = f.read()
    f.close()

    lines = lines.splitlines()
    f = open(os.path.join(testpth, testname + '_mt.nam'), 'w')
    for line in lines:
        if ('hss_source' in line):
            f.write('\n')
        else:
            f.write(line + '\n')
    f.close()

    # run modflow to generate flow field for mt3d-usgs
    print('running modflow-nwt model...{}'.format(testname))
    nam = os.path.basename(mfnamefile)
    exe_name = config.target_dict['mfnwt']
    success, buff = flopy.run_model(exe_name,
                                    nam,
                                    model_ws=testpth,
                                    silent=False,
                                    report=True)

    # if modflow ran successfully, then run mt3d-usgs
    if success:
        print('running mt3d-usgs model...{}'.format(testname))
        nam = os.path.basename(mtnamefile)
        exe_name = os.path.abspath(config.target)
        success, buff = flopy.run_model(exe_name,
                                        nam,
                                        model_ws=testpth,
                                        silent=False,
                                        report=True,
                                        normal_msg='program completed')

    success_cmp = True
    if success and comparison:
        action = pymake.setup_comparison(mfnamefile, testpth)
        action = pymake.setup_comparison(mtnamefile,
                                         testpth,
                                         remove_existing=False)
        testpth_cmp = os.path.join(testpth, action)
        if action is not None:
            files_cmp = None
            if action.lower() == '.cmp':
                files_cmp = []
                files = os.listdir(testpth_cmp)

                # Go through all files in the .cmp folder and do a separate
                # comparison for each one.  This will ensure that the
                # individual ucn files for sorbed and multi-species will be
                # compared.
                for file in files:
                    files1 = os.path.join(testpth, file[:-4])
                    files2 = os.path.join(testpth_cmp, file)
                    outfileucn = os.path.join(testpth, file + '.txt')
                    success_ucn = pymake.compare_concs(None,
                                                       None,
                                                       ctol=0.002,
                                                       outfile=outfileucn,
                                                       files1=files1,
                                                       files2=files2)
                    if not success_ucn:
                        success_cmp = False

            else:
                print('running comparison modflow-nwt model...{}'.format(
                    testpth_cmp))
                key = action.lower().replace('.cmp', '')
                nam = os.path.basename(mfnamefile)
                exe_name = os.path.abspath(config.target_dict['mfnwt'])
                success_cmp, buff = flopy.run_model(exe_name,
                                                    nam,
                                                    model_ws=testpth_cmp,
                                                    silent=False,
                                                    report=True)
                if success_cmp:
                    print('running comparison mt3dms model...{}'.format(
                        testpth_cmp))
                    key = action.lower().replace('.cmp', '')
                    nam = os.path.basename(mtnamefile)
                    exe_name = os.path.abspath(config.target_release)
                    success_cmp, buff = flopy.run_model(
                        exe_name,
                        nam,
                        model_ws=testpth_cmp,
                        silent=False,
                        report=True,
                        normal_msg='program completed')

                if success_cmp:
                    nam = os.path.basename(mtnamefile)
                    namefile1 = os.path.join(testpth, nam)
                    namefile2 = os.path.join(testpth_cmp, nam)
                    outfileucn = os.path.join(
                        os.path.split(os.path.join(testpth, nam))[0],
                        'ucn.cmp')
                    success_ucn = pymake.compare_concs(namefile1,
                                                       namefile2,
                                                       ctol=0.002,
                                                       outfile=outfileucn,
                                                       files2=files_cmp)

                if success_cmp and success_ucn:
                    success_cmp = True
                else:
                    success_cmp = False
    # Clean things up
    if success and success_cmp and not config.retain:
        pymake.teardown(testpth)
    assert success, 'model did not run'
    assert success_cmp, 'comparison model did not meet comparison criteria'
    return
Exemplo n.º 8
0
    # Clean things up
    if success and success_cmp and not config.retain:
        pymake.teardown(testpth)
    assert success, 'model did not run'
    assert success_cmp, 'comparison model did not meet comparison criteria'

    return


def test_mfusg():
    if config.exclude is None:
        exclude = []
    else:
        exclude = list(config.exclude)
    exclude.append('.cmp')
    namefiles = get_namefiles(config.testpaths[2], exclude=exclude)
    for namefile in namefiles:
        yield run_mfusg, namefile
    return


if __name__ == '__main__':
    if config.exclude is None:
        exclude = []
    else:
        exclude = list(config.exclude)
    exclude.append('.cmp')
    namefiles = get_namefiles(config.testpaths[2], exclude=exclude)
    for namefile in namefiles:
        run_mfusg(namefile)
Exemplo n.º 9
0
def run_mt3d(spth, comparison=True):
    """
    Run the simulations.

    """

    # Path to folder containing tests
    pth = config.testpaths[0]

    # -- get modflow name files
    tpth = os.path.join(pth, spth)
    namefilesmf = []
    namefilesmf += get_namefiles(tpth, exclude='mt')

    # -- get mt3d name files
    tpth = os.path.join(pth, spth)
    namefilesmt = []
    namefilesmt += get_namefiles(tpth, exclude='mf')

    mfnamefile = namefilesmf[0]
    mtnamefile = namefilesmt[0]
    print(mfnamefile, mtnamefile)

    # Set root as the directory name where namefile is located
    testname = pymake.get_sim_name(mfnamefile.replace('_mf', ''), 
                                   rootpth=os.path.dirname(mfnamefile))[0]

    # Setup modflow
    testpth = os.path.join(config.testdir, testname)
    pymake.setup(mfnamefile, testpth)
    # Setup mt3d
    pymake.setup(mtnamefile, testpth, remove_existing=False)

    # run test models
    print('running modflow-nwt model...{}'.format(testname))
    nam = os.path.basename(mfnamefile)
    exe_name = config.target_dict['mfnwt']
    success, buff = flopy.run_model(exe_name, nam, model_ws=testpth,
                                    silent=True)

    if success:
        print('running mt3d-usgs model...{}'.format(testname))
        nam = os.path.basename(mtnamefile)
        exe_name = os.path.abspath(config.target)
        success, buff = flopy.run_model(exe_name, nam, model_ws=testpth,
                                        silent=True,
                                        normal_msg='program completed')

    success_cmp = True
    if success and comparison:
        action = pymake.setup_comparison(mfnamefile, testpth)
        action = pymake.setup_comparison(mtnamefile, testpth, 
                                         remove_existing=False)
        testpth_cmp = os.path.join(testpth, action)
        if action is not None:
            files_cmp = None
            if action.lower() == '.cmp':
                files_cmp = []
                files = os.listdir(testpth_cmp)
                for file in files:
                    files1 = os.path.join(testpth, file[:-4])
                    files2 = os.path.join(testpth_cmp, file)
                    outfileucn = os.path.join(testpth, file + '.txt')
                    success_ucn = pymake.compare_concs(None, None,
                                                       ctol=0.002,
                                                       outfile=outfileucn,
                                                       files1=files1,
                                                       files2=files2)
                    if not success_ucn:
                        success_cmp = False

            else:
                print('running comparison modflow-nwt model...{}'.format(testpth_cmp))
                key = action.lower().replace('.cmp', '')
                nam = os.path.basename(mfnamefile)
                exe_name = os.path.abspath(config.target_dict['mfnwt'])
                success_cmp, buff = flopy.run_model(exe_name, nam,
                                                    model_ws=testpth_cmp,
                                                    silent=True)
                if success_cmp:
                    print('running comparison mt3dms model...{}'.format(testpth_cmp))
                    key = action.lower().replace('.cmp', '')
                    nam = os.path.basename(mtnamefile)
                    exe_name = os.path.abspath(config.target_release)
                    success_cmp, buff = flopy.run_model(exe_name, nam,
                                                        model_ws=testpth_cmp,
                                                        silent=True,
                                                        normal_msg='program completed')

                if success_cmp:
                    nam = os.path.basename(mtnamefile)
                    namefile1 = os.path.join(testpth, nam)
                    namefile2 = os.path.join(testpth_cmp, nam)
                    outfileucn = os.path.join(
                                 os.path.split(os.path.join(testpth, nam))[0],
                                 'ucn.cmp')
                    success_ucn = pymake.compare_concs(namefile1, namefile2,
                                                       ctol=0.002,
                                                       outfile=outfileucn,
                                                       files2=files_cmp)

                if success_cmp and success_ucn:
                    success_cmp = True
                else:
                    success_cmp = False
    # Clean things up
    if success and success_cmp and not config.retain:
        pymake.teardown(testpth)
    assert success, 'model did not run'
    assert success_cmp, 'comparison model did not meet comparison criteria'
    return
Exemplo n.º 10
0
def test_mf2005():
    namefiles = get_namefiles(config.testpaths[0], exclude=config.exclude)
    for namefile in namefiles:
        yield run_mf2005, namefile
    return
Exemplo n.º 11
0
def run_mt3d(spth, comparison=True):
    """
    Run the simulations.

    """

    # Path to folder containing tests
    pth = config.testpaths[0]

    # -- get modflow name files
    tpth = os.path.join(pth, spth)
    namefilesmf = []
    namefilesmf += get_namefiles(tpth, exclude='mt')

    # -- get mt3d name files
    tpth = os.path.join(pth, spth)
    namefilesmt = []
    namefilesmt += get_namefiles(tpth, exclude='mf')

    mfnamefile = namefilesmf[0]
    mtnamefile = namefilesmt[0]
    print(mfnamefile, mtnamefile)

    # Set root as the directory name where namefile is located
    testname = pymake.get_sim_name(mfnamefile.replace('_mf', ''),
                                   rootpth=os.path.dirname(mfnamefile))[0]

    # Setup modflow
    testpth = os.path.join(config.testdir, testname)
    pymake.setup(mfnamefile, testpth)
    # Setup mt3d
    pymake.setup(mtnamefile, testpth, remove_existing=False)

    # run test models
    print('running modflow-nwt model...{}'.format(testname))
    nam = os.path.basename(mfnamefile)
    exe_name = config.target_dict['mfnwt']
    success, buff = flopy.run_model(exe_name,
                                    nam,
                                    model_ws=testpth,
                                    silent=False,
                                    report=True)

    if success:
        # For this particular test, a lengthy period of "stop flow"
        # needs to be inserted into the linker file for simulating
        # a period of equilibration.
        print('running insert_stopflow_period.py...{}'.format(testname))
        insert_stopflow_period.InsStpFlw()

        print('running mt3d-usgs model...{}'.format(testname))
        nam = os.path.basename(mtnamefile)
        exe_name = os.path.abspath(config.target)
        success, buff = flopy.run_model(exe_name,
                                        nam,
                                        model_ws=testpth,
                                        silent=False,
                                        report=True,
                                        normal_msg='program completed')

    success_cmp = True
    if success and comparison:
        action = pymake.setup_comparison(mfnamefile, testpth)
        action = pymake.setup_comparison(mtnamefile,
                                         testpth,
                                         remove_existing=False)
        testpth_cmp = os.path.join(testpth, action)
        if action is not None:
            files_cmp = None
            if action.lower() == '.cmp':
                files_cmp = []
                files = os.listdir(testpth_cmp)

                # Go through all files in the .cmp folder and do a separate
                # comparison for each one.  This will ensure that the
                # individual ucn files for sorbed and multi-species will be
                # compared.
                for file in files:
                    files1 = os.path.join(testpth, file[:-4])
                    files2 = os.path.join(testpth_cmp, file)
                    outfileucn = os.path.join(testpth, file + '.txt')
                    success_ucn = pymake.compare_concs(None,
                                                       None,
                                                       ctol=0.002,
                                                       outfile=outfileucn,
                                                       files1=files1,
                                                       files2=files2)
                    if not success_ucn:
                        success_cmp = False

            else:
                print('running comparison modflow-nwt model...{}'.format(
                    testpth_cmp))
                key = action.lower().replace('.cmp', '')
                nam = os.path.basename(mfnamefile)
                exe_name = os.path.abspath(config.target_dict['mfnwt'])
                success_cmp, buff = flopy.run_model(exe_name,
                                                    nam,
                                                    model_ws=testpth_cmp,
                                                    silent=False,
                                                    report=True)
                if success_cmp:
                    print('running comparison mt3dms model...{}'.format(
                        testpth_cmp))
                    key = action.lower().replace('.cmp', '')
                    nam = os.path.basename(mtnamefile)
                    exe_name = os.path.abspath(config.target_release)
                    success_cmp, buff = flopy.run_model(
                        exe_name,
                        nam,
                        model_ws=testpth_cmp,
                        silent=False,
                        report=True,
                        normal_msg='program completed')

                if success_cmp:
                    nam = os.path.basename(mtnamefile)
                    namefile1 = os.path.join(testpth, nam)
                    namefile2 = os.path.join(testpth_cmp, nam)
                    outfileucn = os.path.join(
                        os.path.split(os.path.join(testpth, nam))[0],
                        'ucn.cmp')
                    success_ucn = pymake.compare_concs(namefile1,
                                                       namefile2,
                                                       ctol=0.002,
                                                       outfile=outfileucn,
                                                       files2=files_cmp)

                if success_cmp and success_ucn:
                    success_cmp = True
                else:
                    success_cmp = False
    # Clean things up
    if success and success_cmp and not config.retain:
        pymake.teardown(testpth)
    assert success, 'model did not run'
    assert success_cmp, 'comparison model did not meet comparison criteria'
    return
Exemplo n.º 12
0
    for spth in test_dirs:
        # -- get modflow name files
        namefilesmf = []
        pth = config.testpaths[1]
        tpth = os.path.join(pth, spth)
        namefilesmf += get_namefiles(tpth, exclude='mt')
        # -- get mt3d name files
        namefilesmt = []
        tpth = os.path.join(pth, spth)
        namefilesmt += get_namefiles(tpth, exclude='mf')
        # -- process name files
        for (nm1, nm2) in zip(namefilesmf, namefilesmt):
            yield run_mt3d, nm1, nm2
    return


if __name__ == '__main__':
    for spth in test_dirs:
        # -- get modflow name files
        namefilesmf = []
        pth = config.testpaths[1]
        tpth = os.path.join(pth, spth)
        namefilesmf += get_namefiles(tpth, exclude='mt')
        # -- get mt3d name files
        namefilesmt = []
        tpth = os.path.join(pth, spth)
        namefilesmt += get_namefiles(tpth, exclude='mf')
        # -- process name files
        for (nm1, nm2) in zip(namefilesmf, namefilesmt):
            run_mt3d(nm1, nm2)
Exemplo n.º 13
0
        # Make comparison
        success = compare(os.path.join(testpth, nam),
                          os.path.join(testpth_reg, nam))
        assert success, 'Models do not compare: {} and {}'.format(
            testname, testname_reg)

    # Clean things up
    if success and not config.retain:
        pymake.teardown(testpth)
    assert success and success_reg

    return


def test_mfusg():
    namefiles = []
    for pth in config.testpaths[0:2]:
        namefiles += get_namefiles(pth, exclude='.cmp')
    # for namefile in ['../test-reg/test042_45usg/45usg.nam']:
    for namefile in namefiles:
        yield run_mfusg, namefile
    return


if __name__ == '__main__':
    namefiles = []
    for pth in config.testpaths[0:2]:
        namefiles += get_namefiles(pth, exclude='.cmp')
    for namefile in namefiles:
        run_mfusg(namefile)
Exemplo n.º 14
0
def test_mf2005():
    namefiles = get_namefiles(testpaths[0], exclude=exclude)
    for namefile in namefiles:
        yield run_mf2005, namefile
    return
Exemplo n.º 15
0
    if os.path.isfile(target_previous):
        print('Removing ' + target_previous)
        os.remove(target_previous)

    if os.path.isfile(target_release):
        print('Removing ' + target_release)
        os.remove(target_release)

    # remove release source files if target was built
    if os.path.isdir(testdir_release):
        print('Removing folder ' + testdir_release)
        shutil.rmtree(testdir_release)

    # remove previous release source files if target was built
    if os.path.isdir(testdir_previous):
        print('Removing folder ' + testdir_previous)
        shutil.rmtree(testdir_previous)

    return


if __name__ == '__main__':
    test_compile_ref()
    test_compile_prev()

    namefiles = get_namefiles(testpaths[0], exclude=exclude)
    for namefile in namefiles:
        run_mf2005(namefile)

    test_teardown()