Exemplo n.º 1
0
def test_sto_setup(get_pleasant_mf6_with_dis):

    m = get_pleasant_mf6_with_dis  #deepcopy(model_with_grid)
    sto = m.setup_sto()
    sto.write()
    assert os.path.exists(os.path.join(m.model_ws, sto.filename))
    assert isinstance(sto, mf6.ModflowGwfsto)
    for var in ['sy', 'ss']:
        model_array = getattr(sto, var).array
        for k, item in enumerate(m.cfg['sto']['griddata'][var]):
            f = item['filename']
            assert os.path.exists(f)
            data = np.loadtxt(f)
            assert np.array_equal(model_array[k], data)
    period_data = read_mf6_block(sto.filename, 'period')
    assert period_data[1] == ['steady-state']
    assert period_data[2] == ['transient']

    # compare values to parent model
    inset_parent_layer_mapping = {0: 0, 1: 0, 2: 1, 3: 2, 4: 3}
    for var in ['ss', 'sy']:
        parent_array = m.parent.upw.__dict__[var].array
        inset_array = sto.__dict__[var].array
        compare_inset_parent_values(inset_array, parent_array,
                                    m.modelgrid, m.parent.modelgrid,
                                    inset_parent_layer_mapping,
                                    nodata=1.0,
                                    rtol=0.05
                                    )
Exemplo n.º 2
0
def test_npf_setup(get_pleasant_mf6_with_dis, simulate_high_k_lakes):
    m = get_pleasant_mf6_with_dis
    m.cfg['high_k_lakes']['simulate_high_k_lakes'] = simulate_high_k_lakes
    npf = m.setup_npf()
    npf.write()
    assert isinstance(npf, mf6.ModflowGwfnpf)
    assert os.path.exists(os.path.join(m.model_ws, npf.filename))

    # compare values to parent model
    # mapping of variables and layers between parent and inset
    variables = {
        'hk': 'k',
        'vka': 'k33',
    }
    inset_parent_layer_mapping = {0: 0, 1: 0, 2: 1, 3: 2, 4: 3}
    for parent_var, inset_var in variables.items():
        parent_array = m.parent.upw.__dict__[parent_var].array
        inset_array = npf.__dict__[inset_var].array
        compare_inset_parent_values(inset_array,
                                    parent_array,
                                    m.modelgrid,
                                    m.parent.modelgrid,
                                    inset_parent_layer_mapping,
                                    nodata=float(
                                        m.cfg['parent']['hiKlakes_value']),
                                    rtol=0.1)
    if not simulate_high_k_lakes:
        assert not np.any(m._isbc2d == 2)
        assert npf.k.array.max() < m.cfg['high_k_lakes']['high_k_value']
        # for now, k33 not adjusted in setting high-k lakes
    else:
        assert np.any(m._isbc2d == 2)
        assert npf.k.array.max() == m.cfg['high_k_lakes']['high_k_value']
def test_npf_setup(get_pleasant_mf6_with_dis):
    m = get_pleasant_mf6_with_dis
    npf = m.setup_npf()
    npf.write()
    assert isinstance(npf, mf6.ModflowGwfnpf)
    assert os.path.exists(os.path.join(m.model_ws, npf.filename))

    # compare values to parent model
    # mapping of variables and layers between parent and inset
    variables = {
        'hk': 'k',
        'vka': 'k33',
    }
    inset_parent_layer_mapping = {0: 0, 1: 0, 2: 1, 3: 2, 4: 3}
    for parent_var, inset_var in variables.items():
        parent_array = m.parent.upw.__dict__[parent_var].array
        inset_array = npf.__dict__[inset_var].array
        compare_inset_parent_values(inset_array,
                                    parent_array,
                                    m.modelgrid,
                                    m.parent.modelgrid,
                                    inset_parent_layer_mapping,
                                    nodata=float(
                                        m.cfg['parent']['hiKlakes_value']),
                                    rtol=0.1)
Exemplo n.º 4
0
def test_sto_setup(get_pleasant_mf6_with_dis, simulate_high_k_lakes):
    m = get_pleasant_mf6_with_dis  #deepcopy(model_with_grid)
    m.cfg['high_k_lakes']['simulate_high_k_lakes'] = simulate_high_k_lakes
    sto = m.setup_sto()
    sto.write()
    assert os.path.exists(os.path.join(m.model_ws, sto.filename))
    assert isinstance(sto, mf6.ModflowGwfsto)
    for var in ['sy', 'ss']:
        model_array = getattr(sto, var).array
        for k, item in enumerate(m.cfg['sto']['griddata'][var]):
            f = item['filename']
            assert os.path.exists(f)
            data = np.loadtxt(f)
            assert np.array_equal(model_array[k], data)
    period_data = read_mf6_block(sto.filename, 'period')
    assert period_data[1] == ['steady-state']
    assert period_data[2] == ['transient']

    # compare values to parent model
    inset_parent_layer_mapping = {0: 0, 1: 0, 2: 1, 3: 2, 4: 3}
    for var in ['ss', 'sy']:
        parent_array = m.parent.upw.__dict__[var].array
        inset_array = sto.__dict__[var].array
        # with addition of high-k lakes block,
        # ss has a different default value than parent
        if simulate_high_k_lakes and var == 'ss':
            continue
        compare_inset_parent_values(inset_array,
                                    parent_array,
                                    m.modelgrid,
                                    m.parent.modelgrid,
                                    inset_parent_layer_mapping,
                                    nodata=1.0,
                                    rtol=0.05)

    if not simulate_high_k_lakes:
        assert not np.any(m._isbc2d == 2)
        assert sto.sy.array.max() < m.cfg['high_k_lakes']['sy']
        assert sto.ss.array.min() > m.cfg['high_k_lakes']['ss']
    else:
        assert np.any(m._isbc2d == 2)
        assert sto.sy.array.max() == m.cfg['high_k_lakes']['sy']
        assert sto.ss.array.min() == m.cfg['high_k_lakes']['ss']
Exemplo n.º 5
0
def test_lgr_model_run(pleasant_lgr_stand_alone_parent,
                       pleasant_lgr_setup_from_yaml, tmpdir, mf6_exe):
    """Build a MODFLOW-6 version of Pleasant test case
    with LGR around the lake.

    Notes
    -----
    This effectively tests for gwf exchange connections involving inactive
    cells; Pleasant case has many due to layer pinchouts.
    """
    m1 = pleasant_lgr_stand_alone_parent
    m1.simulation.exe_name = mf6_exe

    m2 = pleasant_lgr_setup_from_yaml
    m2.simulation.exe_name = mf6_exe

    # run stand-alone parent and lgr version
    for model in m1, m2:
        success = False
        if exe_exists(mf6_exe):
            success, buff = model.simulation.run_simulation()
            if not success:
                list_file = model.name_file.list.array
                with open(list_file) as src:
                    list_output = src.read()
        assert success, 'model run did not terminate successfully:\n{}'.format(
            list_output)

    # compare heads from lgr model to stand-alone parent
    kstpkper = (0, 0)
    parent_hdsobj = bf.HeadFile(
        os.path.join(tmpdir, 'pleasant_lgr_just_parent',
                     'plsnt_lgr_parent.hds'))
    parent_heads = parent_hdsobj.get_data(kstpkper=kstpkper)
    inset_hdsobj = bf.HeadFile(
        os.path.join(tmpdir, 'pleasant_lgr', 'plsnt_lgr_inset.hds'))
    inset_heads = inset_hdsobj.get_data(kstpkper=kstpkper)
    compare_inset_parent_values(inset_heads,
                                parent_heads,
                                m2.modelgrid,
                                m1.modelgrid,
                                nodata=1e30,
                                rtol=0.05)