Ejemplo n.º 1
0
def pleasant_lgr_stand_alone_parent(pleasant_lgr_test_cfg_path, tmpdir):
    """Stand-alone version of lgr parent model for comparing with LGR results.
    """
    # Edit the configuration file before the file paths within it are converted to absolute
    # (model.load_cfg converts the file paths)
    cfg = load(pleasant_lgr_test_cfg_path)
    del cfg['setup_grid']['lgr']
    cfg['simulation']['sim_ws'] = os.path.join(tmpdir,
                                               'pleasant_lgr_just_parent')

    # save out the edited configuration file
    path, fname = os.path.split(pleasant_lgr_test_cfg_path)
    new_file = os.path.join(path, 'pleasant_lgr_just_parent.yml')
    dump(new_file, cfg)

    # load in the edited configuration file, converting the paths to absolute
    cfg = MF6model.load_cfg(new_file)
    # add some stuff just for the tests
    cfg['gisdir'] = os.path.join(cfg['simulation']['sim_ws'], 'gis')

    m = MF6model.setup_from_cfg(cfg)
    m.write_input()
    #if hasattr(m, 'sfr'):
    #    sfr_package_filename = os.path.join(m.model_ws, m.sfr.filename)
    #    m.sfrdata.write_package(sfr_package_filename,
    #                                version='mf6'
    #                                )
    return m
Ejemplo n.º 2
0
def test_setup_from_yaml_issue(project_root_path, remake_top):
    cfg = MF6model.load_cfg(
        Path(project_root_path) / 'examples/pleasant_lgr_parent.yml')
    lgr_test_path = Path(project_root_path) / 'examples/pleasant_lgr'
    shutil.rmtree(lgr_test_path, ignore_errors=True)
    keep_keys = {
        'simulation', 'model', 'parent', 'setup_grid', 'dis', 'tdis',
        'intermediate_data', 'postprocessing', 'filename'
    }
    new_cfg = {k: v for k, v in cfg.items() if k in keep_keys}
    new_cfg['model']['packages'] = ['dis']
    new_cfg['dis']['remake_top'] = remake_top
    del new_cfg['setup_grid']['lgr']
    MF6model.setup_from_cfg(new_cfg)
Ejemplo n.º 3
0
def test_solver_defaults(test_data_path, tmpdir):
    """Verify that default values aren't applied to solver
    packages if the simplified settings options are used
    (e.g. simple/moderate/complex)"""

    # modflow-6 IMS package
    mf6_model_config = test_data_path / 'pleasant_mf6_test.yml'
    cfg = MF6model.load_cfg(mf6_model_config)
    keep_keys = {
        'simulation', 'model', 'parent', 'setup_grid', 'dis', 'tdis',
        'intermediate_data', 'postprocessing'
    }
    new_cfg = {k: v for k, v in cfg.items() if k in keep_keys}
    new_cfg['model']['packages'] = ['dis']
    new_cfg['ims'] = {'options': {'complexity': 'moderate'}}
    temp_yaml = Path(tmpdir) / 'junk.yml'
    dump(temp_yaml, new_cfg)
    m = MF6model.setup_from_yaml(temp_yaml)
    assert 'nonlinear' not in m.cfg['ims']
    assert 'linear' not in m.cfg['ims']

    # modflow-nwt NWT package
    mfnwt_model_config = test_data_path / 'pleasant_nwt_test.yml'
    cfg = MFnwtModel.load_cfg(mfnwt_model_config)
    keep_keys = {
        'simulation', 'model', 'parent', 'setup_grid', 'dis', 'bas6',
        'intermediate_data', 'postprocessing'
    }
    new_cfg = {k: v for k, v in cfg.items() if k in keep_keys}
    new_cfg['model']['packages'] = ['dis', 'bas6']
    new_cfg['nwt'] = {'options': 'moderate'}
    temp_yaml = Path(tmpdir) / 'junk.yml'
    dump(temp_yaml, new_cfg)
    m = MFnwtModel.setup_from_yaml(temp_yaml)
    expected_keys = {
        'headtol', 'fluxtol', 'maxiterout', 'thickfact', 'linmeth', 'iprnwt',
        'ibotav', 'Continue', 'use_existing_file', 'options'
    }
    assert not set(m.cfg['nwt'].keys()).difference(expected_keys)
    assert m.cfg['nwt']['options'] == 'moderate'