def test_load(pfl_nwt_setup_from_yaml, pfl_nwt_test_cfg_path): m = pfl_nwt_setup_from_yaml #deepcopy(pfl_nwt_setup_from_yaml) m2 = MFnwtModel.load(pfl_nwt_test_cfg_path) m3 = MFnwtModel.load(pfl_nwt_test_cfg_path, forgive=True) assert m == m2 assert m2 == m3
def test_init(pfl_nwt_cfg): cfg = pfl_nwt_cfg.copy() cfg['model']['packages'] = [] # test initialization with no packages m = MFnwtModel(cfg=cfg, **cfg['model']) assert isinstance(m, MFnwtModel) # test initialization with no arguments m = MFnwtModel() assert isinstance(m, MFnwtModel)
def pleasant_nwt_setup_from_yaml(pleasant_nwt_test_cfg_path): m = MFnwtModel.setup_from_yaml(pleasant_nwt_test_cfg_path) m.write_input() # verify that observation data were added and written sfr_package_filename = os.path.join(m.model_ws, m.sfr.file_name[0]) #m.sfrdata.write_package(sfr_package_filename) return m
def test_packagelist(pfl_nwt_test_cfg_path): cfg = load_cfg(pfl_nwt_test_cfg_path, default_file='/mfnwt_defaults.yml') assert len(cfg['model']['packages']) > 0 kwargs = get_input_arguments(cfg['model'], MFnwtModel) m = MFnwtModel(cfg=cfg, **kwargs) assert m.package_list == [p for p in m._package_setup_order if p in cfg['model']['packages']]
def test_remake_a_package(pfl_nwt_setup_from_yaml, pfl_nwt_test_cfg_path): m = pfl_nwt_setup_from_yaml shutil.copy(m.lak.fn_path, 'lakefile1.lak') m2 = MFnwtModel.load(pfl_nwt_test_cfg_path, load_only=['dis']) lak = m2.setup_lak() lakefile2 = lak.fn_path lak.write_file() assert filecmp.cmp('lakefile1.lak', lakefile2)
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'
def get_pleasant_nwt(pleasant_nwt_cfg): print('creating Pleasant Lake MFnwtModel instance from cfgfile...') cfg = pleasant_nwt_cfg.copy() m = MFnwtModel(cfg=cfg, **cfg['model']) return m
def pfl_nwt(pfl_nwt_cfg): print('pytest fixture pfl_nwt') cfg = pfl_nwt_cfg.copy() m = MFnwtModel(cfg=cfg, **cfg['model']) return m
def test_load(pfl_nwt_setup_from_yaml, pfl_nwt_test_cfg_path): m = pfl_nwt_setup_from_yaml #deepcopy(pfl_nwt_setup_from_yaml) m2 = MFnwtModel.load(pfl_nwt_test_cfg_path) assert m == m2
def pfl_nwt_setup_from_yaml(pfl_nwt_test_cfg_path): m = MFnwtModel.setup_from_yaml(pfl_nwt_test_cfg_path) m.write_input() return m